-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'v1.1.6_micro' into HEAD
- Loading branch information
Showing
138 changed files
with
5,427 additions
and
2,172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,8 +57,8 @@ public function createCustomer(Request $request) | |
|
||
// Profile upload validation | ||
$validMimeType = ['image/jpeg', 'image/png', 'image/jpg']; | ||
if(isset($uploadedFiles['profileImage'])){ | ||
if(!in_array($uploadedFiles['profileImage']->getMimeType(), $validMimeType)){ | ||
if (isset($uploadedFiles['profileImage'])) { | ||
if (!in_array($uploadedFiles['profileImage']->getMimeType(), $validMimeType)) { | ||
$this->addFlash('warning', $this->translator->trans('Error ! Profile image is not valid, please upload a valid format')); | ||
return $this->redirect($this->generateUrl('helpdesk_member_create_customer_account')); | ||
} | ||
|
@@ -74,12 +74,12 @@ public function createCustomer(Request $request) | |
|
||
$user = $this->userService->createUserInstance($formDetails['email'], $fullname, $supportRole, [ | ||
'contact' => $formDetails['contactNumber'], | ||
'source' => 'website', | ||
'active' => !empty($formDetails['isActive']) ? true : false, | ||
'image' => $uploadedFiles['profileImage'], | ||
'source' => 'website', | ||
'active' => !empty($formDetails['isActive']) ? true : false, | ||
'image' => $uploadedFiles['profileImage'], | ||
]); | ||
|
||
if(!empty($user)){ | ||
if (!empty($user)){ | ||
$user->setIsEnabled(true); | ||
$entityManager->persist($user); | ||
$entityManager->flush(); | ||
|
@@ -95,7 +95,7 @@ public function createCustomer(Request $request) | |
} | ||
|
||
return $this->render('@UVDeskCoreFramework/Customers/createSupportCustomer.html.twig', [ | ||
'user' => new User(), | ||
'user' => new User(), | ||
'errors' => json_encode([]) | ||
]); | ||
} | ||
|
@@ -109,34 +109,35 @@ public function editCustomer(Request $request) | |
$em = $this->getDoctrine()->getManager(); | ||
$repository = $em->getRepository(User::class); | ||
|
||
if($userId = $request->attributes->get('customerId')) { | ||
if ($userId = $request->attributes->get('customerId')) { | ||
$user = $repository->findOneBy(['id' => $userId]); | ||
if(!$user) | ||
if (!$user) | ||
$this->noResultFound(); | ||
} | ||
if ($request->getMethod() == "POST") { | ||
$contentFile = $request->files->get('customer_form'); | ||
|
||
// Customer Profile upload validation | ||
$validMimeType = ['image/jpeg', 'image/png', 'image/jpg']; | ||
if(isset($contentFile['profileImage'])){ | ||
if(!in_array($contentFile['profileImage']->getMimeType(), $validMimeType)){ | ||
if (isset($contentFile['profileImage'])) { | ||
if (!in_array($contentFile['profileImage']->getMimeType(), $validMimeType)) { | ||
$this->addFlash('warning', $this->translator->trans('Error ! Profile image is not valid, please upload a valid format')); | ||
return $this->render('@UVDeskCoreFramework/Customers/updateSupportCustomer.html.twig', ['user' => $user,'errors' => json_encode([])]); | ||
} | ||
} | ||
if($userId) { | ||
|
||
if ($userId) { | ||
$data = $request->request->all(); | ||
$data = $data['customer_form']; | ||
$checkUser = $em->getRepository(User::class)->findOneBy(array('email' => $data['email'])); | ||
$errorFlag = 0; | ||
|
||
if($checkUser) { | ||
if ($checkUser) { | ||
if($checkUser->getId() != $userId) | ||
$errorFlag = 1; | ||
} | ||
|
||
if(!$errorFlag && '[email protected]' !== $user->getEmail()) { | ||
if (!$errorFlag && '[email protected]' !== $user->getEmail()) { | ||
if ( | ||
isset($data['password']['first']) && !empty(trim($data['password']['first'])) | ||
&& isset($data['password']['second']) && !empty(trim($data['password']['second'])) | ||
|
@@ -146,9 +147,9 @@ public function editCustomer(Request $request) | |
} | ||
|
||
$email = $user->getEmail(); | ||
$user->setFirstName($data['firstName']); | ||
$user->setLastName($data['lastName']); | ||
$user->setEmail($data['email']); | ||
$user->setFirstName(trim($data['firstName'])); | ||
$user->setLastName(trim($data['lastName'])); | ||
$user->setEmail(trim($data['email'])); | ||
$user->setIsEnabled(true); | ||
$em->persist($user); | ||
|
||
|
@@ -158,10 +159,11 @@ public function editCustomer(Request $request) | |
$userInstance->setIsActive(isset($data['isActive']) ? $data['isActive'] : 0); | ||
$userInstance->setIsVerified(0); | ||
|
||
if(isset($data['contactNumber'])) { | ||
if (isset($data['contactNumber'])) { | ||
$userInstance->setContactNumber($data['contactNumber']); | ||
} | ||
if(isset($contentFile['profileImage'])) { | ||
|
||
if (isset($contentFile['profileImage'])) { | ||
// Removed profile image from database and path | ||
$fileService = new Fileservice; | ||
if ($userInstance->getProfileImagePath()) { | ||
|
@@ -188,12 +190,13 @@ public function editCustomer(Request $request) | |
$this->eventDispatcher->dispatch($event, 'uvdesk.automation.workflow.execute'); | ||
|
||
$this->addFlash('success', $this->translator->trans('Success ! Customer information updated successfully.')); | ||
|
||
return $this->redirect($this->generateUrl('helpdesk_member_manage_customer_account_collection')); | ||
} else { | ||
$this->addFlash('warning', $this->translator->trans('Error ! User with same email is already exist.')); | ||
} | ||
} | ||
} elseif($request->getMethod() == "PUT") { | ||
} elseif ($request->getMethod() == "PUT") { | ||
$content = json_decode($request->getContent(), true); | ||
$userId = $content['id']; | ||
$user = $repository->findOneBy(['id' => $userId]); | ||
|
@@ -212,14 +215,14 @@ public function editCustomer(Request $request) | |
if (!$errorFlag && '[email protected]' !== $user->getEmail()) { | ||
$name = explode(' ', $content['name']); | ||
$lastName = isset($name[1]) ? $name[1] : ' '; | ||
$user->setFirstName($name[0]); | ||
$user->setLastName($lastName); | ||
$user->setEmail($content['email']); | ||
$user->setFirstName(trim($name[0])); | ||
$user->setLastName(trim($lastName)); | ||
$user->setEmail(trim($content['email'])); | ||
$em->persist($user); | ||
|
||
//user Instance | ||
$userInstance = $em->getRepository(UserInstance::class)->findOneBy(array('user' => $user->getId())); | ||
if(isset($content['contactNumber'])){ | ||
if (isset($content['contactNumber'])){ | ||
$userInstance->setContactNumber($content['contactNumber']); | ||
} | ||
$em->persist($userInstance); | ||
|
@@ -234,7 +237,7 @@ public function editCustomer(Request $request) | |
|
||
return new Response(json_encode($json), 200, []); | ||
} | ||
// dump($user); die; | ||
|
||
return $this->render('@UVDeskCoreFramework/Customers/updateSupportCustomer.html.twig', [ | ||
'user' => $user, | ||
'errors' => json_encode([]) | ||
|
@@ -260,8 +263,10 @@ public function bookmarkCustomer(Request $request) | |
$data = json_decode($request->getContent(), true); | ||
$id = $request->attributes->get('id') ? : $data['id']; | ||
$user = $em->getRepository(User::class)->findOneBy(['id' => $id]); | ||
if(!$user) { | ||
|
||
if (!$user) { | ||
$json['error'] = 'resource not found'; | ||
|
||
return new JsonResponse($json, Response::HTTP_NOT_FOUND); | ||
} | ||
$userInstance = $em->getRepository(UserInstance::class)->findOneBy(array( | ||
|
@@ -270,7 +275,7 @@ public function bookmarkCustomer(Request $request) | |
) | ||
); | ||
|
||
if($userInstance->getIsStarred()) { | ||
if ($userInstance->getIsStarred()) { | ||
$userInstance->setIsStarred(0); | ||
$em->persist($userInstance); | ||
$em->flush(); | ||
|
@@ -283,8 +288,10 @@ public function bookmarkCustomer(Request $request) | |
$json['alertClass'] = 'success'; | ||
$json['message'] = $this->translator->trans('starred Action Completed successfully'); | ||
} | ||
|
||
$response = new Response(json_encode($json)); | ||
$response->headers->set('Content-Type', 'application/json'); | ||
|
||
return $response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.