diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php index 1b519a9..358b758 100644 --- a/src/Controller/AdminController.php +++ b/src/Controller/AdminController.php @@ -7,6 +7,7 @@ use App\Entity\User; use App\Form\EditUserFormType; use App\Form\SupervisorFormType; use App\Form\UserFormType; +use App\Libs\Breadcrumb; use App\Libs\NavList; use App\Repository\UserRepository; use Doctrine\ORM\EntityManagerInterface; @@ -41,7 +42,7 @@ class AdminController extends AbstractController $this->navLinks, [ 'breadcrumbs' => [ - 'Admin Dashboard' + new Breadcrumb($this->generateUrl('app_admin_dashboard'), 'Admin Dashboard') ], 'notifications' => $user->retrieveUnreadNotifications(), ] @@ -73,7 +74,7 @@ class AdminController extends AbstractController $this->navLinks, [ 'breadcrumbs' => [ - 'User List' + new Breadcrumb($this->generateUrl('app_list_users'), 'List Users') ], 'users' => $users, 'notifications' => $user->retrieveUnreadNotifications(), @@ -130,6 +131,8 @@ class AdminController extends AbstractController $this->entityManager->persist($user); $this->entityManager->flush(); + $this->addFlash('success', 'User added successfully'); + return $this->redirectToRoute('app_list_users'); } @@ -141,7 +144,8 @@ class AdminController extends AbstractController $this->navLinks, [ 'breadcrumbs' => [ - 'Add User' + new Breadcrumb($this->generateUrl('app_list_users'), 'User List'), + new Breadcrumb($this->generateUrl('app_add_user'), 'Add User') ], 'form' => $form, 'notifications' => $admin->retrieveUnreadNotifications(), @@ -175,7 +179,6 @@ class AdminController extends AbstractController ->setRate($form->get('rate')->getData()) ->setLevel($form->get('level')->getData()); - $this->entityManager->persist($user); $this->entityManager->flush(); return $this->redirectToRoute('app_list_users'); @@ -187,7 +190,8 @@ class AdminController extends AbstractController $this->navLinks, [ 'breadcrumbs' => [ - 'Edit User' + new Breadcrumb($this->generateUrl('app_list_users'), 'User List'), + new Breadcrumb($this->generateUrl('app_edit_user', ['id' => $id]), 'Edit User') ], 'data' => $user, 'form' => $form, @@ -205,7 +209,7 @@ class AdminController extends AbstractController /** @var User $user */ $user = $userRepo->find($id); - $prevSup = $this->entityManager->getRepository(Supervision::class)->findBy(['user' => $user]); + $prevSup = $this->entityManager->getRepository(Supervision::class)->findBy(['worker' => $user]); $form = $this->createForm(SupervisorFormType::class); $form->handleRequest($request); @@ -234,9 +238,10 @@ class AdminController extends AbstractController $this->navLinks, [ 'breadcrumbs' => [ - 'Assign Supervisor' + new Breadcrumb($this->generateUrl('app_list_users'), 'User List'), + new Breadcrumb($this->generateUrl('app_assign_supervisor', ['id' => $id]), 'Assign Supervisor') ], - 'data' => $user, + 'user' => $user, 'form' => $form, 'supervisors' => $userRepo->getCaseManagers($admin->getCompany()), 'notifications' => $admin->retrieveUnreadNotifications(),