add docs for the case

This commit is contained in:
Ryan Prather 2025-01-11 22:30:54 -05:00
parent 74e811e950
commit 1cb6bedb5c
Signed by: ryan
GPG Key ID: FA4291AE0183344F
18 changed files with 398 additions and 422 deletions

View File

@ -3,6 +3,8 @@ twig:
globals: globals:
mileage_rate: '%env(MILEAGE_RATE)%' mileage_rate: '%env(MILEAGE_RATE)%'
company_timezone: '%env(COMPANY_TIMEZONE)%' company_timezone: '%env(COMPANY_TIMEZONE)%'
company_image_path: '%env(COMPANY_IMAGE_PATH)%'
user_image_path: '%env(USER_IMAGE_PATH)%'
when@test: when@test:
twig: twig:

View File

@ -2,6 +2,16 @@
use App\Kernel; use App\Kernel;
if (preg_match("/theme\//", $_SERVER['REQUEST_URI'])) {
print file_get_contents(dirname(__FILE__).$_SERVER['REQUEST_URI']);
exit;
}
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
$_SERVER['HTTPS'] = 'on';
$_SERVER['SERVER_PORT'] = 443;
}
require_once dirname(__DIR__).'/vendor/autoload_runtime.php'; require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
return function (array $context) { return function (array $context) {

View File

@ -2,18 +2,16 @@
namespace App\Controller; namespace App\Controller;
use App\Entity\CompanyDocument;
use App\Entity\Messages;
use App\Entity\Supervision; use App\Entity\Supervision;
use App\Entity\User; use App\Entity\User;
use App\Factory\MessageFactory; use App\Factory\MessageFactory;
use App\Form\CompanyDocumentFormType;
use App\Form\EditUserFormType; use App\Form\EditUserFormType;
use App\Form\SupervisorFormType; use App\Form\SupervisorFormType;
use App\Form\UserFormType; use App\Form\UserFormType;
use App\Libs\Breadcrumb; use App\Libs\Breadcrumb;
use App\Libs\NavList; use App\Libs\NavList;
use App\Libs\Libs; use App\Libs\Libs;
use App\Libs\PageParameters;
use App\Repository\UserRepository; use App\Repository\UserRepository;
use DateTime; use DateTime;
use DateTimeZone; use DateTimeZone;
@ -30,12 +28,10 @@ use Symfony\Component\String\Slugger\SluggerInterface;
#[IsGranted('ROLE_ADMIN')] #[IsGranted('ROLE_ADMIN')]
class AdminController extends AbstractController class AdminController extends AbstractController
{ {
private array $msgs;
public function __construct( public function __construct(
private readonly EntityManagerInterface $entityManager, private readonly EntityManagerInterface $entityManager,
private readonly UserPasswordHasherInterface $userPasswordHasher, private readonly UserPasswordHasherInterface $userPasswordHasher,
private array $navLinks = [] private array $navLinks = [],
) { ) {
$this->navLinks = NavList::LIST; $this->navLinks = NavList::LIST;
} }
@ -45,7 +41,6 @@ class AdminController extends AbstractController
{ {
$this->denyAccessUnlessGranted('ROLE_ADMIN'); $this->denyAccessUnlessGranted('ROLE_ADMIN');
$this->navLinks['admin_dashboard'] = NavList::PRESENT_LINK; $this->navLinks['admin_dashboard'] = NavList::PRESENT_LINK;
$this->msgs = Libs::getMessages($user, $this->entityManager);
return $this->render( return $this->render(
'internal/admin/admin-dashboard.html.twig', 'internal/admin/admin-dashboard.html.twig',
@ -55,7 +50,7 @@ class AdminController extends AbstractController
'breadcrumbs' => [ 'breadcrumbs' => [
new Breadcrumb($this->generateUrl('app_admin_dashboard'), 'Admin Dashboard') new Breadcrumb($this->generateUrl('app_admin_dashboard'), 'Admin Dashboard')
], ],
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($user, $this->entityManager),
] ]
) )
); );
@ -65,7 +60,6 @@ class AdminController extends AbstractController
public function listUsers(#[CurrentUser()] User $user): Response public function listUsers(#[CurrentUser()] User $user): Response
{ {
$this->denyAccessUnlessGranted('ROLE_ADMIN'); $this->denyAccessUnlessGranted('ROLE_ADMIN');
$this->msgs = Libs::getMessages($user, $this->entityManager);
/** @var UserRepository $repo */ /** @var UserRepository $repo */
$repo = $this->entityManager->getRepository(User::class); $repo = $this->entityManager->getRepository(User::class);
@ -89,7 +83,7 @@ class AdminController extends AbstractController
new Breadcrumb($this->generateUrl('app_list_users'), 'List Users') new Breadcrumb($this->generateUrl('app_list_users'), 'List Users')
], ],
'users' => $users, 'users' => $users,
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($user, $this->entityManager),
] ]
) )
); );
@ -102,7 +96,6 @@ class AdminController extends AbstractController
SluggerInterface $slugger SluggerInterface $slugger
): Response { ): Response {
$this->denyAccessUnlessGranted('ROLE_ADMIN'); $this->denyAccessUnlessGranted('ROLE_ADMIN');
$this->msgs = Libs::getMessages($admin, $this->entityManager);
$user = new User(); $user = new User();
$form = $this->createForm(UserFormType::class, $user); $form = $this->createForm(UserFormType::class, $user);
@ -183,7 +176,7 @@ class AdminController extends AbstractController
new Breadcrumb($this->generateUrl('app_add_user'), 'Add User') new Breadcrumb($this->generateUrl('app_add_user'), 'Add User')
], ],
'form' => $form, 'form' => $form,
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($admin, $this->entityManager),
] ]
) )
); );
@ -194,7 +187,6 @@ class AdminController extends AbstractController
{ {
/** @var UserRepository $userRepo */ /** @var UserRepository $userRepo */
$userRepo = $this->entityManager->getRepository(User::class); $userRepo = $this->entityManager->getRepository(User::class);
$this->msgs = Libs::getMessages($admin, $this->entityManager);
/** @var User $user */ /** @var User $user */
$user = $userRepo->find($id); $user = $userRepo->find($id);
@ -231,7 +223,7 @@ class AdminController extends AbstractController
], ],
'data' => $user, 'data' => $user,
'form' => $form, 'form' => $form,
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($admin, $this->entityManager),
] ]
) )
); );
@ -242,7 +234,6 @@ class AdminController extends AbstractController
{ {
/** @var UserRepository $userRepo */ /** @var UserRepository $userRepo */
$userRepo = $this->entityManager->getRepository(User::class); $userRepo = $this->entityManager->getRepository(User::class);
$this->msgs = Libs::getMessages($admin, $this->entityManager);
/** @var User $user */ /** @var User $user */
$user = $userRepo->find($id); $user = $userRepo->find($id);
@ -286,7 +277,7 @@ class AdminController extends AbstractController
'user' => $user, 'user' => $user,
'form' => $form, 'form' => $form,
'supervisors' => $userRepo->getCaseManagers($admin->getCompany()), 'supervisors' => $userRepo->getCaseManagers($admin->getCompany()),
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($admin, $this->entityManager),
] ]
) )
); );

View File

@ -8,7 +8,6 @@ use App\Entity\CompanyDocument;
use App\Entity\Location; use App\Entity\Location;
use App\Entity\Member; use App\Entity\Member;
use App\Entity\MemberCase; use App\Entity\MemberCase;
use App\Entity\Messages;
use App\Entity\ReferralSource; use App\Entity\ReferralSource;
use App\Entity\User; use App\Entity\User;
use App\Entity\UserCase; use App\Entity\UserCase;
@ -29,13 +28,6 @@ use Symfony\Component\Security\Http\Attribute\CurrentUser;
class CaseController extends AbstractController class CaseController extends AbstractController
{ {
/**
* Variable to store unread notification messages
*
* @var array
*/
private array $msgs;
public function __construct( public function __construct(
private EntityManagerInterface $entityManager, private EntityManagerInterface $entityManager,
private array $navLinks = [] private array $navLinks = []
@ -48,10 +40,9 @@ class CaseController extends AbstractController
public function myCases(#[CurrentUser()] User $user, Request $request): Response public function myCases(#[CurrentUser()] User $user, Request $request): Response
{ {
$this->navLinks['my_cases'] = NavList::PRESENT_LINK; $this->navLinks['my_cases'] = NavList::PRESENT_LINK;
$this->navLinks['case_list'] = 'nav-link text-dark'; $this->navLinks['case_list'] = NavList::DEFAULT;
$ucs = $this->entityManager->getRepository(UserCase::class)->findBy(['user' => $user]); $ucs = $this->entityManager->getRepository(UserCase::class)->findBy(['user' => $user]);
$this->msgs = Libs::getMessages($user, $this->entityManager);
$cases = []; $cases = [];
foreach ($ucs as $uc) { foreach ($ucs as $uc) {
@ -71,7 +62,7 @@ class CaseController extends AbstractController
: new Breadcrumb($this->generateUrl('app_my_cases'), 'My Cases') : new Breadcrumb($this->generateUrl('app_my_cases'), 'My Cases')
), ),
], ],
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($user, $this->entityManager),
'cases' => $cases, 'cases' => $cases,
] ]
) )
@ -85,7 +76,6 @@ class CaseController extends AbstractController
$cases = $this->entityManager->getRepository(MemberCase::class)->findAll(); $cases = $this->entityManager->getRepository(MemberCase::class)->findAll();
$workers = $this->entityManager->getRepository(User::class)->getCaseWorkers(); $workers = $this->entityManager->getRepository(User::class)->getCaseWorkers();
$this->msgs = Libs::getMessages($user, $this->entityManager);
return $this->render( return $this->render(
'internal/admin/cases/list-cases.html.twig', 'internal/admin/cases/list-cases.html.twig',
@ -95,7 +85,7 @@ class CaseController extends AbstractController
'breadcrumbs' => [ 'breadcrumbs' => [
new Breadcrumb($this->generateUrl('app_list_cases'), 'List Cases') new Breadcrumb($this->generateUrl('app_list_cases'), 'List Cases')
], ],
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($user, $this->entityManager),
'cases' => $cases, 'cases' => $cases,
'workers' => $workers, 'workers' => $workers,
] ]
@ -115,8 +105,6 @@ class CaseController extends AbstractController
$compDocs = $this->entityManager->getRepository(CompanyDocument::class)->findBy(['company' => $user->getCompany()]); $compDocs = $this->entityManager->getRepository(CompanyDocument::class)->findBy(['company' => $user->getCompany()]);
$sources = $this->entityManager->getRepository(ReferralSource::class)->findAll(); $sources = $this->entityManager->getRepository(ReferralSource::class)->findAll();
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($this->getUser());
return $this->render( return $this->render(
'internal/cases/view-case.html.twig', 'internal/cases/view-case.html.twig',
array_merge( array_merge(
@ -130,7 +118,7 @@ class CaseController extends AbstractController
new Breadcrumb($this->generateUrl('app_list_cases'), 'List Cases'), new Breadcrumb($this->generateUrl('app_list_cases'), 'List Cases'),
new Breadcrumb($this->generateUrl('app_view_case', ['caseId' => $case->getId()]), 'View Case') new Breadcrumb($this->generateUrl('app_view_case', ['caseId' => $case->getId()]), 'View Case')
], ],
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($user, $this->entityManager),
] ]
) )
); );
@ -140,7 +128,6 @@ class CaseController extends AbstractController
public function addCase(Request $request, #[CurrentUser()] User $admin): Response public function addCase(Request $request, #[CurrentUser()] User $admin): Response
{ {
$this->denyAccessUnlessGranted('ROLE_ADMIN'); $this->denyAccessUnlessGranted('ROLE_ADMIN');
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($admin);
$companyDocs = $this->entityManager->getRepository(CompanyDocument::class)->findBy(['company' => $admin->getCompany()]); $companyDocs = $this->entityManager->getRepository(CompanyDocument::class)->findBy(['company' => $admin->getCompany()]);
$case = new MemberCase(); $case = new MemberCase();
@ -169,7 +156,7 @@ class CaseController extends AbstractController
new Breadcrumb($this->generateUrl('app_list_cases'), 'List Cases'), new Breadcrumb($this->generateUrl('app_list_cases'), 'List Cases'),
new Breadcrumb($this->generateUrl('app_add_case'), 'Add Case') new Breadcrumb($this->generateUrl('app_add_case'), 'Add Case')
], ],
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($admin, $this->entityManager),
'form' => $form, 'form' => $form,
'sources' => $this->entityManager->getRepository(ReferralSource::class)->retrieveOrderedList(), 'sources' => $this->entityManager->getRepository(ReferralSource::class)->retrieveOrderedList(),
'docs' => $companyDocs, 'docs' => $companyDocs,
@ -182,7 +169,6 @@ class CaseController extends AbstractController
public function editCase(Request $request, #[CurrentUser()] User $admin, string $id): Response public function editCase(Request $request, #[CurrentUser()] User $admin, string $id): Response
{ {
$this->denyAccessUnlessGranted('ROLE_ADMIN'); $this->denyAccessUnlessGranted('ROLE_ADMIN');
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($admin);
$case = $this->entityManager->getRepository(MemberCase::class)->find($id); $case = $this->entityManager->getRepository(MemberCase::class)->find($id);
$form = $this->createForm(MemberCaseFormType::class, $case); $form = $this->createForm(MemberCaseFormType::class, $case);
@ -208,7 +194,7 @@ class CaseController extends AbstractController
new Breadcrumb($this->generateUrl('app_list_cases'), 'List Cases'), new Breadcrumb($this->generateUrl('app_list_cases'), 'List Cases'),
new Breadcrumb($this->generateUrl('app_edit_case', ['id' => $id]), 'Edit Case') new Breadcrumb($this->generateUrl('app_edit_case', ['id' => $id]), 'Edit Case')
], ],
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($admin, $this->entityManager),
'form' => $form, 'form' => $form,
'case' => $case, 'case' => $case,
'sources' => $this->entityManager->getRepository(ReferralSource::class)->retrieveOrderedList(), 'sources' => $this->entityManager->getRepository(ReferralSource::class)->retrieveOrderedList(),
@ -221,7 +207,6 @@ class CaseController extends AbstractController
public function assignCase(string $id, Request $request, #[CurrentUser()] User $admin): Response public function assignCase(string $id, Request $request, #[CurrentUser()] User $admin): Response
{ {
$this->denyAccessUnlessGranted('ROLE_ADMIN'); $this->denyAccessUnlessGranted('ROLE_ADMIN');
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($admin);
$caseWorkers = $this->entityManager->getRepository(User::class)->getCaseWorkers(); $caseWorkers = $this->entityManager->getRepository(User::class)->getCaseWorkers();
$case = $this->entityManager->getRepository(MemberCase::class)->find($id); $case = $this->entityManager->getRepository(MemberCase::class)->find($id);
@ -263,7 +248,7 @@ class CaseController extends AbstractController
new Breadcrumb($this->generateUrl('app_list_cases'), 'List Cases'), new Breadcrumb($this->generateUrl('app_list_cases'), 'List Cases'),
new Breadcrumb($this->generateUrl('app_assign_case', ['id' => $id]), 'Assign User') new Breadcrumb($this->generateUrl('app_assign_case', ['id' => $id]), 'Assign User')
], ],
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($admin, $this->entityManager),
'case' => $case, 'case' => $case,
'form' => $form, 'form' => $form,
'id' => $id, 'id' => $id,
@ -281,7 +266,6 @@ class CaseController extends AbstractController
$this->navLinks['case_list'] = 'nav-link text-dark'; $this->navLinks['case_list'] = 'nav-link text-dark';
$addresses = $this->entityManager->getRepository(Location::class)->getUserLocations($user); $addresses = $this->entityManager->getRepository(Location::class)->getUserLocations($user);
$this->msgs = Libs::getMessages($user, $this->entityManager);
$ucs = $this->entityManager->getRepository(UserCase::class)->findBy(['user' => $user]); $ucs = $this->entityManager->getRepository(UserCase::class)->findBy(['user' => $user]);
$cases = []; $cases = [];
@ -300,7 +284,7 @@ class CaseController extends AbstractController
new Breadcrumb($this->generateUrl('app_my_cases'), 'My Cases'), new Breadcrumb($this->generateUrl('app_my_cases'), 'My Cases'),
new Breadcrumb($this->generateUrl('app_list_case_addresses'), 'List Case Addresses') new Breadcrumb($this->generateUrl('app_list_case_addresses'), 'List Case Addresses')
], ],
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($user, $this->entityManager),
'addresses' => $addresses, 'addresses' => $addresses,
'cases' => $cases, 'cases' => $cases,
] ]
@ -314,8 +298,6 @@ class CaseController extends AbstractController
$this->navLinks['case_itinerary'] = NavList::PRESENT_LINK; $this->navLinks['case_itinerary'] = NavList::PRESENT_LINK;
$this->navLinks['case_list'] = 'nav-link text-dark'; $this->navLinks['case_list'] = 'nav-link text-dark';
$this->msgs = Libs::getMessages($user, $this->entityManager);
$ucs = $this->entityManager->getRepository(UserCase::class)->findBy(['user' => $user]); $ucs = $this->entityManager->getRepository(UserCase::class)->findBy(['user' => $user]);
$cases = []; $cases = [];
@ -365,7 +347,7 @@ class CaseController extends AbstractController
new Breadcrumb($this->generateUrl('app_list_case_addresses'), 'List Addresses'), new Breadcrumb($this->generateUrl('app_list_case_addresses'), 'List Addresses'),
new Breadcrumb($this->generateUrl('app_case_add_address'), 'Add Case Address') new Breadcrumb($this->generateUrl('app_case_add_address'), 'Add Case Address')
], ],
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($user, $this->entityManager),
'form' => $form, 'form' => $form,
'cases' => $cases, 'cases' => $cases,
] ]
@ -374,13 +356,11 @@ class CaseController extends AbstractController
} }
#[Route('/addresses/edit/{id}', name: 'app_case_edit_address')] #[Route('/addresses/edit/{id}', name: 'app_case_edit_address')]
public function editCaseAddress(Request $request, string $id): Response public function editCaseAddress(Request $request, string $id, #[CurrentUser()] User $user): Response
{ {
$this->navLinks['case_itinerary'] = NavList::PRESENT_LINK; $this->navLinks['case_itinerary'] = NavList::PRESENT_LINK;
$this->navLinks['case_list'] = 'nav-link text-dark'; $this->navLinks['case_list'] = 'nav-link text-dark';
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($this->getUser());
$ucs = $this->entityManager->getRepository(UserCase::class)->findBy(['user' => $this->getUser()]); $ucs = $this->entityManager->getRepository(UserCase::class)->findBy(['user' => $this->getUser()]);
$lcs = $this->entityManager->getRepository(CaseLocation::class)->findBy(['location' => $id]); $lcs = $this->entityManager->getRepository(CaseLocation::class)->findBy(['location' => $id]);
@ -424,7 +404,7 @@ class CaseController extends AbstractController
'cases' => $cases, 'cases' => $cases,
'inCases' => $inCases, 'inCases' => $inCases,
'form' => $form, 'form' => $form,
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($user, $this->entityManager),
] ]
) )
); );
@ -433,7 +413,6 @@ class CaseController extends AbstractController
#[Route('/assign-case-doc/{caseId}/{memberId}', name: 'app_assign_case_documents')] #[Route('/assign-case-doc/{caseId}/{memberId}', name: 'app_assign_case_documents')]
public function assignCaseDocument(string $caseId, string $memberId, Request $request, #[CurrentUser()] User $user): Response public function assignCaseDocument(string $caseId, string $memberId, Request $request, #[CurrentUser()] User $user): Response
{ {
$this->msgs = Libs::getMessages($user, $this->entityManager);
$case = $this->entityManager->getRepository(MemberCase::class)->find($caseId); $case = $this->entityManager->getRepository(MemberCase::class)->find($caseId);
$member = $this->entityManager->getRepository(Member::class)->find($memberId); $member = $this->entityManager->getRepository(Member::class)->find($memberId);
$companyDocs = $this->entityManager->getRepository(CompanyDocument::class)->findBy(['company' => $user->getCompany()]); $companyDocs = $this->entityManager->getRepository(CompanyDocument::class)->findBy(['company' => $user->getCompany()]);
@ -457,7 +436,7 @@ class CaseController extends AbstractController
array_merge( array_merge(
$this->navLinks, $this->navLinks,
[ [
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($user, $this->entityManager),
'breadcrumbs' => [ 'breadcrumbs' => [
new Breadcrumb($this->generateUrl('app_dashboard'), 'Dashboard'), new Breadcrumb($this->generateUrl('app_dashboard'), 'Dashboard'),
new Breadcrumb($this->generateUrl('app_list_cases'), 'List Cases'), new Breadcrumb($this->generateUrl('app_list_cases'), 'List Cases'),
@ -470,8 +449,6 @@ class CaseController extends AbstractController
] ]
) )
); );
return new Response();
} }
#[Route('/sign-case-doc/{caseId}/{docId}/{memberId}', name: 'app_display_case_document')] #[Route('/sign-case-doc/{caseId}/{docId}/{memberId}', name: 'app_display_case_document')]
@ -479,49 +456,4 @@ class CaseController extends AbstractController
{ {
return new Response(); return new Response();
} }
#[Route('/api/filter-address-by-case/{caseId}', name: 'ajax_filter_address_by_case')]
public function filterAddressByCase(string $caseId, Request $request): Response
{
$case = $this->entityManager->getRepository(MemberCase::class)->find($caseId);
$addresses = $this->entityManager->getRepository(Location::class)->getLocationsByCase($case);
return $this->json($addresses);
}
#[Route('/api/case/{caseId}/user/{userId}', name: 'ajax_case_user_level_check')]
public function checkUserCaseLevel(string $caseId, string $userId) : Response
{
$ret = true;
$user = $this->entityManager->getRepository(User::class)->find($userId);
$case = $this->entityManager->getRepository(MemberCase::class)->find($caseId);
$res = UserCase::checkLevel($user, $case);
if (!$res) {
$ret = [
'userLevel' => ucwords(str_replace('_', ' ', strtolower($user->getLevel()->name))),
'caseLevel' => ucwords(str_replace('_', ' ', strtolower($case->getLevel()->name))),
];
}
return $this->json($ret);
}
#[Route('/api/filter-cases-by-user', name: 'ajax_filter_cases_by_user')]
public function filterCasesByUser(Request $request): Response
{
/** @var User $user */
$user = $this->entityManager->getRepository(User::class)->find($request->query->get('userId'));
/** @var UserCase[] $ucs */
$ucs = $this->entityManager->getRepository(UserCase::class)->findBy(['user' => $user]);
$ret = [];
foreach ($ucs as $uc) {
$ret[] = $uc->getMemberCase();
}
return $this->json($ret);
}
} }

View File

@ -22,13 +22,6 @@ use Symfony\UX\Map\Point;
class CommunityResourceController extends AbstractController class CommunityResourceController extends AbstractController
{ {
/**
* Variable to store unread notification messages
*
* @var array
*/
private array $msgs;
public function __construct( public function __construct(
private readonly EntityManagerInterface $entityManager, private readonly EntityManagerInterface $entityManager,
private array $navLinks = [] private array $navLinks = []
@ -41,7 +34,6 @@ class CommunityResourceController extends AbstractController
public function list(#[CurrentUser()] User $user): Response public function list(#[CurrentUser()] User $user): Response
{ {
$rsc = $this->entityManager->getRepository(CommunityResource::class)->findAll(); $rsc = $this->entityManager->getRepository(CommunityResource::class)->findAll();
$this->msgs = Libs::getMessages($user, $this->entityManager);
return $this->render( return $this->render(
'internal/community_resource/list.html.twig', 'internal/community_resource/list.html.twig',
@ -52,7 +44,7 @@ class CommunityResourceController extends AbstractController
new Breadcrumb('#', 'Community Resources') new Breadcrumb('#', 'Community Resources')
], ],
'resources' => $rsc, 'resources' => $rsc,
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($user, $this->entityManager),
] ]
) )
); );
@ -61,8 +53,6 @@ class CommunityResourceController extends AbstractController
#[Route('/resource/map', name: 'app_community_resource_map')] #[Route('/resource/map', name: 'app_community_resource_map')]
public function map(#[CurrentUser()] User $user): Response public function map(#[CurrentUser()] User $user): Response
{ {
$this->msgs = Libs::getMessages($user, $this->entityManager);
$rcs = $this->entityManager->getRepository(CommunityResource::class)->findAll(); $rcs = $this->entityManager->getRepository(CommunityResource::class)->findAll();
$map = new Map('default'); $map = new Map('default');
@ -94,7 +84,7 @@ class CommunityResourceController extends AbstractController
new Breadcrumb($this->generateUrl('app_community_resource'), 'List Resources'), new Breadcrumb($this->generateUrl('app_community_resource'), 'List Resources'),
new Breadcrumb('#', 'Community Resources') new Breadcrumb('#', 'Community Resources')
], ],
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($user, $this->entityManager),
] ]
) )
); );
@ -103,8 +93,6 @@ class CommunityResourceController extends AbstractController
#[Route('/resource/add', name: 'app_community_resource_add')] #[Route('/resource/add', name: 'app_community_resource_add')]
public function add(#[CurrentUser()] User $user, Request $request): Response public function add(#[CurrentUser()] User $user, Request $request): Response
{ {
$this->msgs = Libs::getMessages($user, $this->entityManager);
$form = $this->createForm(ResourceFormType::class); $form = $this->createForm(ResourceFormType::class);
$form->handleRequest($request); $form->handleRequest($request);
@ -142,7 +130,7 @@ class CommunityResourceController extends AbstractController
new Breadcrumb($this->generateUrl('app_community_resource'), 'List Resources'), new Breadcrumb($this->generateUrl('app_community_resource'), 'List Resources'),
new Breadcrumb('#', 'Add Resource') new Breadcrumb('#', 'Add Resource')
], ],
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($user, $this->entityManager),
] ]
) )
); );
@ -152,8 +140,6 @@ class CommunityResourceController extends AbstractController
#[Route('/resource/edit/{id}', name: 'app_community_resource_edit')] #[Route('/resource/edit/{id}', name: 'app_community_resource_edit')]
public function edit(string $id, #[CurrentUser()] User $user, Request $request): Response public function edit(string $id, #[CurrentUser()] User $user, Request $request): Response
{ {
$this->msgs = Libs::getMessages($user, $this->entityManager);
$rsc = $this->entityManager->getRepository(CommunityResource::class)->find($id); $rsc = $this->entityManager->getRepository(CommunityResource::class)->find($id);
$form = $this->createForm(ResourceFormType::class, $rsc); $form = $this->createForm(ResourceFormType::class, $rsc);
@ -189,7 +175,7 @@ class CommunityResourceController extends AbstractController
new Breadcrumb($this->generateUrl('app_community_resource'), 'List Resources'), new Breadcrumb($this->generateUrl('app_community_resource'), 'List Resources'),
new Breadcrumb('#', 'Edit Resource') new Breadcrumb('#', 'Edit Resource')
], ],
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($user, $this->entityManager),
] ]
) )
); );
@ -217,13 +203,4 @@ class CommunityResourceController extends AbstractController
'Content-Transfer-Encoding' => 'binary' 'Content-Transfer-Encoding' => 'binary'
]); ]);
} }
#[Route('/api/filter-resource-by-county', name: 'app_api_filter_resource_by_county')]
public function filterResourceByCounty(Request $request): Response
{
$data = json_decode($request->getContent(), true);
$county = $data['county'];
$resources = $this->entityManager->getRepository(CommunityResource::class)->findBy(['county' => $county]);
return $this->json($resources);
}
} }

View File

@ -24,8 +24,6 @@ use Symfony\Component\String\Slugger\SluggerInterface;
#[IsGranted('ROLE_ADMIN')] #[IsGranted('ROLE_ADMIN')]
class CompanyController extends AbstractController class CompanyController extends AbstractController
{ {
private array $msgs;
public function __construct( public function __construct(
private EntityManagerInterface $entityManager, private EntityManagerInterface $entityManager,
private array $navLinks = [] private array $navLinks = []
@ -40,7 +38,6 @@ class CompanyController extends AbstractController
SluggerInterface $slugger SluggerInterface $slugger
): Response { ): Response {
$this->navLinks['company_nav'] = NavList::PRESENT_LINK; $this->navLinks['company_nav'] = NavList::PRESENT_LINK;
$this->msgs = Libs::getMessages($user, $this->entityManager);
$company = $user->getCompany(); $company = $user->getCompany();
$form = $this->createForm(InternalCompanyFormType::class, $company); $form = $this->createForm(InternalCompanyFormType::class, $company);
@ -78,7 +75,7 @@ class CompanyController extends AbstractController
'breadcrumbs' => [ 'breadcrumbs' => [
new Breadcrumb($this->generateUrl('app_admin_dashboard'), "Admin Dashboard"), new Breadcrumb($this->generateUrl('app_admin_dashboard'), "Admin Dashboard"),
], ],
'msgs' => $this->msgs, 'msgs' => Libs::getMessages($user, $this->entityManager),
] ]
) )
); );
@ -89,7 +86,6 @@ class CompanyController extends AbstractController
{ {
$this->navLinks['company_nav'] = NavList::PRESENT_LINK; $this->navLinks['company_nav'] = NavList::PRESENT_LINK;
$this->msgs = Libs::getMessages($user, $this->entityManager);
$companyDocs = $this->entityManager->getRepository(CompanyDocument::class)->findBy(['company' => $user->getCompany()], ['title' => 'ASC']); $companyDocs = $this->entityManager->getRepository(CompanyDocument::class)->findBy(['company' => $user->getCompany()], ['title' => 'ASC']);
return $this->render( return $this->render(
@ -98,7 +94,7 @@ class CompanyController extends AbstractController
$this->navLinks, $this->navLinks,
[ [
'breadcrumbs' => [], 'breadcrumbs' => [],
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($user, $this->entityManager),
'docs' => $companyDocs, 'docs' => $companyDocs,
] ]
) )
@ -109,7 +105,6 @@ class CompanyController extends AbstractController
public function addCompanyDocument(Request $request, #[CurrentUser()] User $user): Response public function addCompanyDocument(Request $request, #[CurrentUser()] User $user): Response
{ {
$this->navLinks['company_nav'] = NavList::PRESENT_LINK; $this->navLinks['company_nav'] = NavList::PRESENT_LINK;
$this->msgs = Libs::getMessages($user, $this->entityManager);
$form = $this->createForm(CompanyDocumentFormType::class); $form = $this->createForm(CompanyDocumentFormType::class);
@ -134,7 +129,7 @@ class CompanyController extends AbstractController
$this->navLinks, $this->navLinks,
[ [
'breadcrumbs' => [], 'breadcrumbs' => [],
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($user, $this->entityManager),
'form' => $form, 'form' => $form,
] ]
) )
@ -147,8 +142,7 @@ class CompanyController extends AbstractController
$companyDoc = $this->entityManager->getRepository(CompanyDocument::class)->find($docId); $companyDoc = $this->entityManager->getRepository(CompanyDocument::class)->find($docId);
$this->navLinks['company_nav'] = NavList::PRESENT_LINK; $this->navLinks['company_nav'] = NavList::PRESENT_LINK;
$this->msgs = Libs::getMessages($user, $this->entityManager); checkdate(1, 1, 1);
$form = $this->createForm(CompanyDocumentFormType::class, $companyDoc); $form = $this->createForm(CompanyDocumentFormType::class, $companyDoc);
$form->handleRequest($request); $form->handleRequest($request);
@ -171,7 +165,7 @@ class CompanyController extends AbstractController
$this->navLinks, $this->navLinks,
[ [
'breadcrumbs' => [], 'breadcrumbs' => [],
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($user, $this->entityManager),
'form' => $form, 'form' => $form,
'doc' => $companyDoc, 'doc' => $companyDoc,
'docText' => str_replace("\r\n", "", $companyDoc->getText()) 'docText' => str_replace("\r\n", "", $companyDoc->getText())

View File

@ -2,18 +2,23 @@
namespace App\Controller; namespace App\Controller;
use App\Entity\Messages; use App\Entity\CaseItinerary;
use App\Entity\User; use App\Entity\User;
use App\Libs\Breadcrumb; use App\Libs\Breadcrumb;
use App\Libs\Libs;
use App\Libs\NavList; use App\Libs\NavList;
use DateInterval;
use DateTime; use DateTime;
use DateTimeZone;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\EmailType; use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\FileType; use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType; use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType; use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TelType;
use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@ -22,19 +27,9 @@ use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Attribute\CurrentUser; use Symfony\Component\Security\Http\Attribute\CurrentUser;
use Symfony\Component\String\Slugger\SluggerInterface; use Symfony\Component\String\Slugger\SluggerInterface;
use Vich\UploaderBundle\Entity\File;
class DefaultController extends AbstractController class DefaultController extends AbstractController
{ {
/**
* Variable to store unread notification messages
*
* @var array
*/
private array $msgs;
private int $notificationCount = 0;
public function __construct( public function __construct(
private readonly EntityManagerInterface $entityManager, private readonly EntityManagerInterface $entityManager,
private readonly UserPasswordHasherInterface $userPasswordHasher, private readonly UserPasswordHasherInterface $userPasswordHasher,
@ -47,13 +42,61 @@ class DefaultController extends AbstractController
public function dashboard(Request $request, #[CurrentUser()] ?User $user): Response public function dashboard(Request $request, #[CurrentUser()] ?User $user): Response
{ {
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY'); $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
if (!$user->getCompany()) { if (!$user->getCompany()) {
return $this->redirectToRoute('app_register_step', ['step' => RegistrationController::REGISTER_STEP_TWO]); return $this->redirectToRoute('app_register_step', ['step' => RegistrationController::REGISTER_STEP_TWO]);
} }
$ytdtravel = $this->entityManager->getRepository(CaseItinerary::class)->getYTDTravel($user);
$last30days = $this->entityManager->getRepository(CaseItinerary::class)->getTravelLast30Days($user);
$ytdMiles = 0;
$milesTravelled30Days = 0;
$caseMileageYTD = 0;
$caseMileage30Days = 0;
$totalTimeTravelledYTD = new DateInterval('PT0S');
$totalTimeTravelled30Days = new DateInterval('PT0S');
if ($ytdtravel) {
$timeTravelled = new DateTime('00:00:00');
$timeTravelYTDStart = new DateTime('00:00:00');
foreach ($ytdtravel as $travel) {
/** @var CaseItinerary $travel */
$ytdMiles += $travel->getDistance();
$timeTravelled->add($travel->getDuration());
if ($travel->isCaseMileage()) {
$caseMileageYTD += $travel->getDistance();
}
}
$totalTimeTravelledYTD = $timeTravelled->diff($timeTravelYTDStart);
}
if ($last30days) {
$timeTravelled30Days = new DateTime('00:00:00');
$timeTravel30DaysStart = new DateTime('00:00:00');
foreach ($last30days as $travel) {
/** @var CaseItinerary $travel */
$milesTravelled30Days += $travel->getDistance();
$timeTravelled30Days->add($travel->getDuration());
if ($travel->isCaseMileage()) {
$caseMileage30Days += $travel->getDistance();
}
}
$totalTimeTravelled30Days = $timeTravelled30Days->diff($timeTravel30DaysStart);
}
$activeCases = 0;
$totalCases = 0;
foreach ($user->getUserCases() as $uc) {
$totalCases++;
if (!$uc->getMemberCase()->getCloseDate()) {
$activeCases++;
}
}
$this->navLinks['user_dashboard'] = NavList::PRESENT_LINK; $this->navLinks['user_dashboard'] = NavList::PRESENT_LINK;
return $this->render( return $this->render(
@ -64,10 +107,15 @@ class DefaultController extends AbstractController
'breadcrumbs' => [ 'breadcrumbs' => [
new Breadcrumb('', 'Dashboard') new Breadcrumb('', 'Dashboard')
], ],
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($user, $this->entityManager),
'notificationCount' => $this->notificationCount, 'milesTravelledYTD' => $ytdMiles,
'milesTravelledYTD' => 0, 'milesTravelled30Days' => $milesTravelled30Days,
'milesTravelled30Days' => 0, 'totalTimeTravelledYTD' => $totalTimeTravelledYTD,
'totalTimeTravelled30Days' => $totalTimeTravelled30Days,
'activeCases' => $activeCases,
'totalCases' => $totalCases,
'caseMileageYTD' => $caseMileageYTD,
'caseMileage30Days' => $caseMileage30Days,
] ]
) )
); );
@ -80,8 +128,6 @@ class DefaultController extends AbstractController
SluggerInterface $slugger SluggerInterface $slugger
): Response { ): Response {
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY'); $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
$this->navLinks['profile'] = NavList::PRESENT_LINK; $this->navLinks['profile'] = NavList::PRESENT_LINK;
@ -104,11 +150,18 @@ class DefaultController extends AbstractController
'first_options' => ['label' => 'Password', 'label_attr' => ['class' => 'form-label']], 'first_options' => ['label' => 'Password', 'label_attr' => ['class' => 'form-label']],
'second_options' => ['label' => 'Repeat Password', 'label_attr' => ['class' => 'form-label']], 'second_options' => ['label' => 'Repeat Password', 'label_attr' => ['class' => 'form-label']],
]) ])
->add('personalPhone', TelType::class, [
'label' => 'Personal Phone',
])
->add('workPhone', TelType::class, [
'label' => 'Work Phone',
])
->add('imageName', FileType::class, [ ->add('imageName', FileType::class, [
'label' => 'Profile Picture', 'label' => 'Profile Picture',
'required' => false, 'required' => false,
'mapped' => false 'mapped' => false
]) ])
->add('signature', HiddenType::class)
->add('submit', SubmitType::class, [ ->add('submit', SubmitType::class, [
'label' => 'Save Profile', 'label' => 'Save Profile',
'attr' => ['class' => 'btn btn-lg bg-gradient-dark btn-lg w-100 mt-4 mb-0'] 'attr' => ['class' => 'btn btn-lg bg-gradient-dark btn-lg w-100 mt-4 mb-0']
@ -119,6 +172,11 @@ class DefaultController extends AbstractController
$form->handleRequest($request); $form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
if ($form->get('signature')->getData()) {
$signature = $form->get('signature')->getData();
$user->setSignature($signature);
}
$firstPassword = $form->get('password')['first']->getData(); $firstPassword = $form->get('password')['first']->getData();
$secondPassword = $form->get('password')['second']->getData(); $secondPassword = $form->get('password')['second']->getData();
@ -136,7 +194,7 @@ class DefaultController extends AbstractController
$plainPassword $plainPassword
) )
); );
$user->setPasswordChanged(new DateTime()) $user->setPasswordChanged(new DateTime('now', new DateTimeZone($_ENV['COMPANY_TIMEZONE'])));
} }
if ($form['imageName']->getData()) { if ($form['imageName']->getData()) {
@ -158,6 +216,16 @@ class DefaultController extends AbstractController
$user->setImageName($newFilename); $user->setImageName($newFilename);
} }
if ($form['personalPhone']->getData()) {
$phone = Libs::Phone($form['personalPhone']->getData());
$user->setPersonalPhone($phone);
}
if ($form['workPhone']->getData()) {
$phone = Libs::Phone($form['workPhone']->getData());
$user->setWorkPhone($phone);
}
$this->entityManager->persist($user); $this->entityManager->persist($user);
$this->entityManager->flush(); $this->entityManager->flush();
@ -174,18 +242,25 @@ class DefaultController extends AbstractController
'breadcrumbs' => [ 'breadcrumbs' => [
new Breadcrumb('', 'Profile') new Breadcrumb('', 'Profile')
], ],
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($user, $this->entityManager),
'notificationCount' => $this->notificationCount,
'currentUser' => $user, 'currentUser' => $user,
'signaturePresent' => ($user->getSignature() ? true : false),
'signature' => $user->getSignature(),
'form' => $form->createView(), 'form' => $form->createView(),
] ]
) )
); );
} }
#[Route('/uploads/user_images/{imageName}', name: 'app_user_image')] #[Route('/uploads/user_images/{imageName}', name: 'app_user_profile_image')]
public function displayUserImage(string $imageName): Response public function displayUserImage(string $imageName): Response
{ {
return new BinaryFileResponse($this->getParameter('kernel.project_dir')."/public/uploads/user_images/{$imageName}"); return new BinaryFileResponse("{$this->getParameter('kernel.project_dir')}/public/{$_ENV['USER_IMAGE_PATH']}/{$imageName}");
}
#[Route('/uploads/company_images/{companyLogo}', name: 'app_company_logo')]
public function displayCompanyLogo(string $companyLogo): Response
{
return new BinaryFileResponse("{$this->getParameter('kernel.project_dir')}/public/{$_ENV['COMPANY_IMAGE_PATH']}/{$companyLogo}");
} }
} }

View File

@ -2,11 +2,14 @@
namespace App\Controller; namespace App\Controller;
use App\Entity\CaseDocument;
use App\Entity\CompanyDocument;
use App\Entity\MemberCase;
use App\Entity\User;
use App\Libs\NavList; use App\Libs\NavList;
use App\Libs\Libs; use App\Libs\Libs;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\CurrentUser; use Symfony\Component\Security\Http\Attribute\CurrentUser;
@ -23,8 +26,6 @@ class DocumentController extends AbstractController
#[Route('/case/{caseId}/doc/{docId}', name: 'app_display_case_doc')] #[Route('/case/{caseId}/doc/{docId}', name: 'app_display_case_doc')]
public function displayCaseDocument(string $caseId, string $docId, #[CurrentUser()] User $user): Response public function displayCaseDocument(string $caseId, string $docId, #[CurrentUser()] User $user): Response
{ {
$msgs = Libs::getMessages($user, $this->entityManager);
$case = $this->entityManager->getRepository(MemberCase::class)->find($caseId); $case = $this->entityManager->getRepository(MemberCase::class)->find($caseId);
$doc = $this->entityManager->getRepository(CompanyDocument::class)->find($docId); $doc = $this->entityManager->getRepository(CompanyDocument::class)->find($docId);
$caseDoc = $this->entityManager->getRepository(CaseDocument::class)->getCaseDocument($case, $doc); $caseDoc = $this->entityManager->getRepository(CaseDocument::class)->getCaseDocument($case, $doc);
@ -34,8 +35,7 @@ class DocumentController extends AbstractController
array_merge( array_merge(
$this->navLinks, $this->navLinks,
[ [
'msgs' => $msgs, 'msgs' => Libs::getMessages($user, $this->entityManager),
'notificationCount' => count($msgs),
'breadcrumbs' => [] 'breadcrumbs' => []
] ]
) )

View File

@ -6,7 +6,6 @@ use App\Entity\CaseItinerary;
use App\Entity\CaseLocation; use App\Entity\CaseLocation;
use App\Entity\Location; use App\Entity\Location;
use App\Entity\MemberCase; use App\Entity\MemberCase;
use App\Entity\Messages;
use App\Entity\User; use App\Entity\User;
use App\Entity\UserCase; use App\Entity\UserCase;
use App\Libs\Breadcrumb; use App\Libs\Breadcrumb;
@ -29,8 +28,6 @@ use Symfony\UX\Map\Polyline;
class ItineraryController extends AbstractController class ItineraryController extends AbstractController
{ {
private array $msgs = [];
public function __construct( public function __construct(
private EntityManagerInterface $entityManager, private EntityManagerInterface $entityManager,
private array $navLinks = [] private array $navLinks = []
@ -43,8 +40,6 @@ class ItineraryController extends AbstractController
{ {
$this->navLinks['case_itinerary'] = NavList::PRESENT_LINK; $this->navLinks['case_itinerary'] = NavList::PRESENT_LINK;
$this->msgs = Libs::getMessages($user, $this->entityManager);
$itineraries = $this->entityManager->getRepository(CaseItinerary::class)->getRecentTravel( $itineraries = $this->entityManager->getRepository(CaseItinerary::class)->getRecentTravel(
$user $user
); );
@ -64,7 +59,7 @@ class ItineraryController extends AbstractController
'breadcrumbs' => [ 'breadcrumbs' => [
new Breadcrumb($this->generateUrl('app_dashboard'), 'Dashboard'), new Breadcrumb($this->generateUrl('app_dashboard'), 'Dashboard'),
], ],
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($user, $this->entityManager),
'itineraries' => $itineraries, 'itineraries' => $itineraries,
'cases' => $cases 'cases' => $cases
] ]
@ -94,8 +89,6 @@ class ItineraryController extends AbstractController
: :
null); null);
$this->msgs = Libs::getMessages($user, $this->entityManager);
$itineraries = $this->entityManager->getRepository(CaseItinerary::class)->getRecentTravel($user, [ $itineraries = $this->entityManager->getRepository(CaseItinerary::class)->getRecentTravel($user, [
'case' => $case, 'case' => $case,
'from' => $startDate, 'from' => $startDate,
@ -160,7 +153,7 @@ class ItineraryController extends AbstractController
new Breadcrumb($this->generateUrl('app_my_cases'), 'My Cases'), new Breadcrumb($this->generateUrl('app_my_cases'), 'My Cases'),
new Breadcrumb($this->generateUrl('app_report_itinerary'), 'Itinerary Report'), new Breadcrumb($this->generateUrl('app_report_itinerary'), 'Itinerary Report'),
], ],
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($user, $this->entityManager),
'map' => $map, 'map' => $map,
'total_distance' => $total_distance, 'total_distance' => $total_distance,
'total_duration' => $di->format("%H:%i'%s''"), 'total_duration' => $di->format("%H:%i'%s''"),
@ -168,105 +161,4 @@ class ItineraryController extends AbstractController
) )
); );
} }
#[Route('/api/get-case-locations/{caseId}', name: 'get_case_locations')]
public function createItinerary(string $caseId): Response
{
$case = $this->entityManager->getRepository(MemberCase::class)->find($caseId);
$cls = $this->entityManager->getRepository(CaseLocation::class)->getCaseLocations($case);
$locations = [];
foreach ($cls as $cl) {
/** @var CaseLocation $cl */
$locations[] = $cl->getLocation();
}
return $this->json($locations);
}
#[Route('/api/add-location-to-itinerary', name: 'add_location_to_itinerary')]
public function addLocationToItinerary(Request $request, Session $session): Response
{
$case = $this->entityManager->getRepository(MemberCase::class)->find($request->getPayload()->get('caseId'));
$origin = $this->entityManager->getRepository(Location::class)->find($request->getPayload()->get('origin'));
$destination = $this->entityManager->getRepository(Location::class)->find($request->getPayload()->get('destination'));
$departure = $request->getPayload()->get('departure');
$arrival = $request->getPayload()->get('arrival');
$caseMileage = (bool) $request->getPayload()->get('caseMileage');
$date = new DateTime($request->getPayload()->get('date'), new DateTimeZone($_ENV['COMPANY_TIMEZONE']));
$route = Libs::getRouteDistance($origin, $destination);
if (!$route) {
return $this->json(['success' => false, 'message' => 'No route found']);
}
$ci = new CaseItinerary();
$ci->setMemberCase($case)
->setDate($date)
->setCaseMileage($caseMileage)
->setOriginLocation($origin)
->setDestLocation($destination)
->setDeparture(new \DateTimeImmutable($departure))
->setArrival(new \DateTimeImmutable($arrival))
->setDistance($route->getDistance())
->setDuration($route->getDuration())
->setGpsRoute($route->getGeometry())
;
$this->entityManager->persist($ci);
$this->entityManager->flush();
$session->getFlashBag()->add(
'success',
'Location added to itinerary'
);
return $this->json(['success' => true, 'message' => 'Location added to itinerary']);
}
#[Route('/api/filter-itinerary-by-case', name: 'ajax_filter_itinerary_by_case')]
public function filterItineraryByCase(Request $request, #[CurrentUser()] ?User $user): Response
{
$case = null;
$startDate = null;
$endDate = null;
//dd($request->getPayload());
if ($request->getPayload()->get('caseId')) {
$caseId = $request->getPayload()->get('caseId');
$case = $this->entityManager->getRepository(MemberCase::class)->find($caseId);
}
if ($request->getPayload()->get('startDate')) {
$startDate = new DateTime($request->getPayload()->get('startDate'), new DateTimeZone($_ENV['COMPANY_TIMEZONE']));
}
if ($request->getPayload()->get('endDate')) {
$endDate = new DateTime($request->getPayload()->get('endDate'), new DateTimeZone($_ENV['COMPANY_TIMEZONE']));
}
$itineraries = $this->entityManager->getRepository(CaseItinerary::class)->getRecentTravel($user, [
'case' => $case,
'from' => $startDate,
'to' => $endDate,
]);
$ret = [];
foreach ($itineraries as $itinerary) {
/** @var CaseItinerary $itinerary */
$ret[] = [
'id' => $itinerary->getId()->toString(),
'date' => $itinerary->getDate()->format('F j, Y'),
'origin' => $itinerary->getOriginLocation(),
'destination' => $itinerary->getDestLocation(),
'distance' => $itinerary->getDistance(),
'duration' => $itinerary->getDuration()->format("%h:%i'%s''"),
'case' => $itinerary->getMemberCase()->getCaseName(),
];
}
return $this->json($ret);
}
} }

View File

@ -19,13 +19,6 @@ use Symfony\Component\Security\Http\Attribute\CurrentUser;
class MemberController extends AbstractController class MemberController extends AbstractController
{ {
/**
* Variable to store unread notification messages
*
* @var array
*/
private array $msgs;
public function __construct( public function __construct(
private EntityManagerInterface $entityManager, private EntityManagerInterface $entityManager,
private array $navLinks = [], private array $navLinks = [],
@ -37,8 +30,6 @@ class MemberController extends AbstractController
#[Route('/list-members/{id}', name: 'app_case_members')] #[Route('/list-members/{id}', name: 'app_case_members')]
public function listMembers(Request $request, #[CurrentUser()] User $user, string $id): Response public function listMembers(Request $request, #[CurrentUser()] User $user, string $id): Response
{ {
$this->msgs = Libs::getMessages($user, $this->entityManager);
$case = $this->entityManager->getRepository(MemberCase::class)->find($id); $case = $this->entityManager->getRepository(MemberCase::class)->find($id);
$members = $this->entityManager->getRepository(Member::class)->getCaseMembersByName($case); $members = $this->entityManager->getRepository(Member::class)->getCaseMembersByName($case);
@ -51,7 +42,7 @@ class MemberController extends AbstractController
new Breadcrumb($this->generateUrl('app_list_cases'), 'List Cases'), new Breadcrumb($this->generateUrl('app_list_cases'), 'List Cases'),
new Breadcrumb($this->generateUrl('app_case_members', ['id' => $id]), 'List Members'), new Breadcrumb($this->generateUrl('app_case_members', ['id' => $id]), 'List Members'),
], ],
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($user, $this->entityManager),
'case' => $case, 'case' => $case,
'members' => $members, 'members' => $members,
] ]
@ -62,8 +53,6 @@ class MemberController extends AbstractController
#[Route('/add-member/{id}', name: 'app_case_add_member')] #[Route('/add-member/{id}', name: 'app_case_add_member')]
public function addMember(Request $request, #[CurrentUser()] User $user, string $id): Response public function addMember(Request $request, #[CurrentUser()] User $user, string $id): Response
{ {
$this->msgs = Libs::getMessages($user, $this->entityManager);
/** @var MemberCase $case */ /** @var MemberCase $case */
$case = $this->entityManager->getRepository(MemberCase::class)->find($id); $case = $this->entityManager->getRepository(MemberCase::class)->find($id);
@ -123,7 +112,7 @@ class MemberController extends AbstractController
new Breadcrumb($this->generateUrl('app_case_members', ['id' => $id]), 'List Members'), new Breadcrumb($this->generateUrl('app_case_members', ['id' => $id]), 'List Members'),
new Breadcrumb($this->generateUrl('app_case_add_member', ['id' => $id]), 'Add Member'), new Breadcrumb($this->generateUrl('app_case_add_member', ['id' => $id]), 'Add Member'),
], ],
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($user, $this->entityManager),
'case' => $case, 'case' => $case,
'form' => $form->createView(), 'form' => $form->createView(),
] ]
@ -134,8 +123,6 @@ class MemberController extends AbstractController
#[Route('/case/{caseId}/edit-member/{memberId}', name: 'app_case_edit_member')] #[Route('/case/{caseId}/edit-member/{memberId}', name: 'app_case_edit_member')]
public function editMember(Request $request, #[CurrentUser()] User $user, string $caseId, string $memberId): Response public function editMember(Request $request, #[CurrentUser()] User $user, string $caseId, string $memberId): Response
{ {
$this->msgs = Libs::getMessages($user, $this->entityManager);
$member = $this->entityManager->getRepository(Member::class)->find($memberId); $member = $this->entityManager->getRepository(Member::class)->find($memberId);
$form = $this->createForm(MemberFormType::class, $member); $form = $this->createForm(MemberFormType::class, $member);
@ -190,7 +177,7 @@ class MemberController extends AbstractController
new Breadcrumb($this->generateUrl('app_case_members', ['id' => $caseId]), 'List Members'), new Breadcrumb($this->generateUrl('app_case_members', ['id' => $caseId]), 'List Members'),
new Breadcrumb($this->generateUrl('app_case_edit_member', ['caseId' => $caseId, 'memberId' => $memberId]), 'Edit Member'), new Breadcrumb($this->generateUrl('app_case_edit_member', ['caseId' => $caseId, 'memberId' => $memberId]), 'Edit Member'),
], ],
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($user, $this->entityManager),
'member' => $member, 'member' => $member,
'form' => $form->createView(), 'form' => $form->createView(),
'caseId' => $caseId, 'caseId' => $caseId,

View File

@ -49,8 +49,6 @@ class MessageController extends AbstractController
$message->setMessage($data['message']); $message->setMessage($data['message']);
$message->setType(MessageType::GENERAL); $message->setType(MessageType::GENERAL);
//dd($message);
$this->entityManager->persist($message); $this->entityManager->persist($message);
$this->entityManager->flush(); $this->entityManager->flush();

View File

@ -4,7 +4,6 @@ namespace App\Controller;
use App\Entity\Member; use App\Entity\Member;
use App\Entity\MemberCase; use App\Entity\MemberCase;
use App\Entity\Messages;
use App\Entity\Referral; use App\Entity\Referral;
use App\Entity\StandardNote; use App\Entity\StandardNote;
use App\Entity\StandardNoteMember; use App\Entity\StandardNoteMember;
@ -31,13 +30,6 @@ use Symfony\Component\Security\Http\Attribute\CurrentUser;
class NoteController extends AbstractController class NoteController extends AbstractController
{ {
/**
* Variable to store unread notification messages
*
* @var array
*/
private array $msgs;
public function __construct( public function __construct(
private EntityManagerInterface $entityManager, private EntityManagerInterface $entityManager,
private array $navLinks = [], private array $navLinks = [],
@ -49,8 +41,6 @@ class NoteController extends AbstractController
#[Route('/list-notes/{caseId?null}', name: 'app_list_notes')] #[Route('/list-notes/{caseId?null}', name: 'app_list_notes')]
public function listNotes(string $caseId = null, #[CurrentUser()] User $user, Request $request): Response public function listNotes(string $caseId = null, #[CurrentUser()] User $user, Request $request): Response
{ {
$this->msgs = Libs::getMessages($user, $this->entityManager);
/** @var UserCase[] $cases */ /** @var UserCase[] $cases */
$cases = $this->entityManager->getRepository(UserCase::class)->findBy(['user' => $user]); $cases = $this->entityManager->getRepository(UserCase::class)->findBy(['user' => $user]);
$caseNotes = null; $caseNotes = null;
@ -78,7 +68,7 @@ class NoteController extends AbstractController
'breadcrumbs' => [ 'breadcrumbs' => [
new Breadcrumb($this->generateUrl('app_list_notes'), 'List Notes') new Breadcrumb($this->generateUrl('app_list_notes'), 'List Notes')
], ],
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($user, $this->entityManager),
'cases' => $cases, 'cases' => $cases,
'caseNotes' => $caseNotes, 'caseNotes' => $caseNotes,
'case' => $case, 'case' => $case,
@ -93,7 +83,6 @@ class NoteController extends AbstractController
/** @var Referral $referral */ /** @var Referral $referral */
$referral = $this->entityManager->getRepository(Referral::class)->find($referralId); $referral = $this->entityManager->getRepository(Referral::class)->find($referralId);
$this->entityManager->getRepository(Referral::class)->populateNotes($referral); $this->entityManager->getRepository(Referral::class)->populateNotes($referral);
$this->msgs = Libs::getMessages($user, $this->entityManager);
$members = $this->entityManager->getRepository(Member::class)->findBy(['caseId' => $referral->getMemberCase()]); $members = $this->entityManager->getRepository(Member::class)->findBy(['caseId' => $referral->getMemberCase()]);
$defaultMethod = NoteMethod::BILLABLE; $defaultMethod = NoteMethod::BILLABLE;
@ -135,7 +124,7 @@ class NoteController extends AbstractController
'breadcrumbs' => [ 'breadcrumbs' => [
new Breadcrumb($this->generateUrl('app_list_notes'), 'List Notes') new Breadcrumb($this->generateUrl('app_list_notes'), 'List Notes')
], ],
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($user, $this->entityManager),
'referral' => $referral, 'referral' => $referral,
'form' => $form, 'form' => $form,
'default_method' => $defaultMethod, 'default_method' => $defaultMethod,
@ -148,8 +137,6 @@ class NoteController extends AbstractController
#[Route('/edit-note/{noteType}/{noteId}', name: 'app_edit_note')] #[Route('/edit-note/{noteType}/{noteId}', name: 'app_edit_note')]
public function editNote(string $noteId, string $noteType, #[CurrentUser()] User $user, Request $request): Response public function editNote(string $noteId, string $noteType, #[CurrentUser()] User $user, Request $request): Response
{ {
$this->msgs = Libs::getMessages($user, $this->entityManager);
$form = null; $form = null;
/** @var VisitNote|StandardNote $note */ /** @var VisitNote|StandardNote $note */
@ -171,7 +158,7 @@ class NoteController extends AbstractController
'breadcrumbs' => [ 'breadcrumbs' => [
new Breadcrumb($this->generateUrl('app_list_notes'), 'List Notes') new Breadcrumb($this->generateUrl('app_list_notes'), 'List Notes')
], ],
'notifications' => $this->msgs, 'notifications' => Libs::getMessages($user, $this->entityManager),
'note' => $note, 'note' => $note,
'referral' => $note->getReferral(), 'referral' => $note->getReferral(),
'form' => $form, 'form' => $form,
@ -180,58 +167,4 @@ class NoteController extends AbstractController
) )
); );
} }
#[Route('/api/filter-notes', name: 'api_filter_notes')]
public function filterNotes(#[CurrentUser()] User $user, Request $request): Response
{
$startDate = null;
$endDate = null;
$referral = null;
$case = null;
if ($request->getPayload()->get('startDate')) {
$startDate = new DateTime($request->getPayload()->get('startDate'), new DateTimeZone($_ENV['COMPANY_TIMEZONE']));
}
if ($request->getPayload()->get('endDate')) {
$endDate = new DateTime($request->getPayload()->get('endDate'), new DateTimeZone($_ENV['COMPANY_TIMEZONE']));
}
if ($request->getPayload()->get('referral')) {
$referral = $this->entityManager->getRepository(Referral::class)->find($request->getPayload()->get('referral'));
}
if ($request->getPayload()->get('case')) {
$case = $this->entityManager->getRepository(MemberCase::class)->find($request->getPayload()->get('case'));
}
$params = [
'startDate' => $startDate,
'endDate' => $endDate,
'referral' => $referral,
'case' => $case,
];
$notes = array_merge(
$this->entityManager->getRepository(VisitNote::class)->filterNotes($user, $params),
$this->entityManager->getRepository(StandardNote::class)->filterNotes($user, $params),
);
foreach ($notes as $idx => $note) {
/** @var VisitNote|StandardNote $note */
/** @var VisitNoteMember[]|StandardNoteMember[] $members */
if ($note instanceof VisitNote) {
$members = $this->entityManager->getRepository(VisitNoteMembers::class)->findBy(['note' => $note]);
} elseif ($note instanceof StandardNote) {
$members = $this->entityManager->getRepository(StandardNoteMember::class)->findBy(['note' => $note]);
} else {
continue;
}
$notes[$idx]->setMembers($members);
}
return new Response(json_encode($notes, 0, 3));
}
} }

View File

@ -99,7 +99,7 @@
<a href='{{ path('app_case_members', {id: c.id}) }}' class='text-secondary ' title='List Members' data-toggle='tooltip'> <a href='{{ path('app_case_members', {id: c.id}) }}' class='text-secondary ' title='List Members' data-toggle='tooltip'>
<i class='material-symbols-rounded opacity-5'>group_add</i> <i class='material-symbols-rounded opacity-5'>group_add</i>
</a> </a>
<a href='{{ path('app_case_notes', {id: c.id}) }}' class='text-secondary ' title='Show Notes' data-toggle='tooltip'> <a href='{{ path('app_list_notes', {caseId: c.id}) }}' class='text-secondary ' title='Show Notes' data-toggle='tooltip'>
<i class='material-symbols-rounded opacity-5'>clinical_notes</i> <i class='material-symbols-rounded opacity-5'>clinical_notes</i>
</a> </a>
</td> </td>

View File

@ -8,5 +8,137 @@
<main class="main-content position-relative max-height-vh-100 h-100 border-radius-lg "> <main class="main-content position-relative max-height-vh-100 h-100 border-radius-lg ">
{{ block('topnav', 'internal/libs/top-nav.html.twig') }} {{ block('topnav', 'internal/libs/top-nav.html.twig') }}
<div class='container-fluid py-2'>
<div class='row'>
<div class='ms-3' style='margin:5px;'>
<h2 class='mb-0 h4 font-weight-bolder'>Dashboard</h2>
</div>
<div class='col-xl-3 col-sm-6 mb-xl-0 mb-4'>
<div class='card'>
<div class='card-header p-2 ps-3'>
<div class='d-flex justify-content-between'>
<div>
<p class='text-sm mb-0 text-capitalize'>Miles Travelled</p>
<h4 class='mb-0' title='30 Days / YTD'>
{{ milesTravelled30Days }}
mi /
{{ milesTravelledYTD }}
mi
</h4>
</div>
<div class="icon icon-md icon-shape bg-gradient-dark shadow-dark shadow text-center border-radius-lg">
<i class="material-symbols-rounded opacity-10">weekend</i>
</div>
</div>
</div>
<hr class='dark horizontal my-0'>
<div class='card-footer p-2 ps-3'>
<p class='mb-0 text-sm'>
<span class='text-info font-weight-bolder'>
Deductable amount: ${{ (milesTravelled30Days * mileage_rate)|number_format(2, '.', ',') }} / ${{ (milesTravelledYTD * mileage_rate)|number_format(2, '.', ',') }}
</span>
</p>
</div>
</div>
</div>
<div class="col-xl-3 col-sm-6 mb-xl-0 mb-4">
<div class='card'>
<div class='card-header p-2 ps-3'>
<div class='d-flex justify-content-between'>
<div>
<p class='text-sm mb-0 text-capitalize'>Time Travelled</p>
<h4 class='mb-0'>
{{ totalTimeTravelled30Days|date("%d:%H:%i'%s''") }}
/
{{ totalTimeTravelledYTD|date("%d:%H:%i'%s''") }}
</h4>
</div>
<div class="icon icon-md icon-shape bg-gradient-dark shadow-dark shadow text-center border-radius-lg">
<i class="material-symbols-rounded opacity-10">weekend</i>
</div>
</div>
</div>
<hr class='dark horizontal my-0'>
<div class='card-footer p-2 ps-3'>
<p class='mb-0 text-sm'>
<span class='text-info font-weight-bolder'></span>
</p>
</div>
</div>
</div>
<div class="col-xl-3 col-sm-6 mb-xl-0 mb-4">
<div class='card'>
<div class='card-header p-2 ps-3'>
<div class='d-flex justify-content-between'>
<div>
<p class='text-sm mb-0 text-capitalize'>Case Mileage</p>
<h4 class='mb-0'>
{{ caseMileage30Days }} / {{ caseMileageYTD }}
</h4>
</div>
<div class="icon icon-md icon-shape bg-gradient-dark shadow-dark shadow text-center border-radius-lg">
<i class="material-symbols-rounded opacity-10">weekend</i>
</div>
</div>
</div>
<hr class='dark horizontal my-0'>
<div class='card-footer p-2 ps-3'>
<p class='mb-0 text-sm'>
<span class='text-info font-weight-bolder' title='30 Days / YTD'></span>
</p>
</div>
</div>
</div>
<div class="col-xl-3 col-sm-6 mb-xl-0 mb-4">
<div class='card'>
<div class='card-header p-2 ps-3'>
<div class='d-flex justify-content-between'>
<div>
<h4 class='mb-0'>Miles Travelled</h4>
<p class='text-sm mb-0 text-capitalize'></p>
</div>
<div class="icon icon-md icon-shape bg-gradient-dark shadow-dark shadow text-center border-radius-lg">
<i class="material-symbols-rounded opacity-10">weekend</i>
</div>
</div>
</div>
<hr class='dark horizontal my-0'>
<div class='card-footer p-2 ps-3'>
<p class='mb-0 text-sm'>
<span class='text-info font-weight-bolder' title='30 Days / YTD'>{{ milesTravelled30Days }}
mi /
{{ milesTravelledYTD }}
mi</span>
</p>
</div>
</div>
</div>
</div>
<div class='row'>
<div class="col-lg-4 col-md-6 mt-4 mb-4">
<div class="card">
<div class="card-body">
<h6 class="mb-0 ">Website Views</h6>
<p class="text-sm ">Last Campaign Performance</p>
<div class="pe-2">
<div class="chart">
<canvas id="chart-bars" class="chart-canvas" height="170"></canvas>
</div>
</div>
<hr class="dark horizontal">
<div class="d-flex ">
<i class="material-symbols-rounded text-sm my-auto me-1">schedule</i>
<p class="mb-0 text-sm">
campaign sent 2 days ago
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</main> </main>
{% endblock %} {% endblock %}

View File

@ -4,7 +4,7 @@
<i class="fas fa-times p-3 cursor-pointer text-dark opacity-5 position-absolute end-0 top-0 d-none d-xl-none" aria-hidden="true" id="iconSidenav"></i> <i class="fas fa-times p-3 cursor-pointer text-dark opacity-5 position-absolute end-0 top-0 d-none d-xl-none" aria-hidden="true" id="iconSidenav"></i>
<a class="navbar-brand px-4 py-3 m-0" href="{{ path('app_dashboard') }}"> <a class="navbar-brand px-4 py-3 m-0" href="{{ path('app_dashboard') }}">
{% if app.user.company.companyLogo %} {% if app.user.company.companyLogo %}
<img src="/uploads/company/{{ app.user.company.companyLogo }}" class="navbar-brand-img" width="30" height="30" alt="main_logo"> <img src="{{ company_image_path }}/{{ app.user.company.companyLogo }}" class="navbar-brand-img" width="30" height="30" alt="main_logo">
{% else %} {% else %}
<img src="{{ asset('img/logo-ct-dark.png') }}" class="navbar-brand-img" width="30" height="30" alt="main_logo"> <img src="{{ asset('img/logo-ct-dark.png') }}" class="navbar-brand-img" width="30" height="30" alt="main_logo">
{% endif %} {% endif %}

View File

@ -15,8 +15,8 @@
<div class="ms-md-auto pe-md-3 d-flex align-items-center"> <div class="ms-md-auto pe-md-3 d-flex align-items-center">
<div class="input-group input-group-outline"> <div class="input-group input-group-outline">
<label class="form-label">Case Search...</label> <label class="form-label" for='case-search'>Case Search...</label>
<input type="text" class="form-control"> <input type="text" id='case-search' class="form-control">
</div> </div>
</div> </div>
<ul class="navbar-nav d-flex align-items-center justify-content-end"> <ul class="navbar-nav d-flex align-items-center justify-content-end">
@ -47,7 +47,7 @@
<a class='dropdown-item border-radius-md' href="javascript:openNotification('{{ note.id }}');"> <a class='dropdown-item border-radius-md' href="javascript:openNotification('{{ note.id }}');">
<div class='d-flex py-1'> <div class='d-flex py-1'>
<div class='my-auto'> <div class='my-auto'>
{% if note.sender.imageName %}<img src='/uploads/user_images/{{ note.sender.imageName }}' class='avatar avatar-sm me-3'><br/> {% if note.sender.imageName %}<img src='{{ user_image_path }}/{{ note.sender.imageName }}' class='avatar avatar-sm me-3'><br/>
{% endif %} {% endif %}
<i class='material-symbols-rounded opacity-7'> <i class='material-symbols-rounded opacity-7'>
{% if note.type == enum('App\\Enums\\MessageType').CASE %} {% if note.type == enum('App\\Enums\\MessageType').CASE %}

View File

@ -8,14 +8,15 @@
<main class="main-content position-relative max-height-vh-100 h-100 border-radius-lg "> <main class="main-content position-relative max-height-vh-100 h-100 border-radius-lg ">
{{ block('topnav', 'internal/libs/top-nav.html.twig') }} {{ block('topnav', 'internal/libs/top-nav.html.twig') }}
{{ form_start(form) }} <form name='form' method='post' enctype='multipart/form-data' onsubmit='return saveSignatureBlock()'>
{{ form_errors(form) }} {{ form_errors(form) }}
<div class='container'> <div class='container'>
<div class='row'> <div class='row'>
<div class='col' id='profile-image'> <div class='col text-center' id='profile-image'>
<input type='hidden' name='id' value='{{ currentUser.id }}'/> <input type='hidden' name='id' value='{{ currentUser.id }}'/>
<img class='profile-image' src='{% if currentUser.imageName %}/uploads/user_images/{{ currentUser.imageName }}{% endif %}'/> <input type='hidden' name='{{ field_name(form.signature) }}' id='signature'/>
<img class='profile-image' src='{% if currentUser.imageName %}{{ user_image_path }}/{{ currentUser.imageName }}{% endif %}'/>
{{ form_row(form.imageName) }} {{ form_row(form.imageName) }}
</div> </div>
@ -52,6 +53,16 @@
</div> </div>
</div> </div>
<div class='row'>
<div class='col'>
<div class='input-group input-group-outline mb-3'>
Saved Signature:
<button id='clearSignature'>Clear Signature</button><br/>
<canvas id='signature_pad'></canvas>
</div>
</div>
</div>
<div class='row'> <div class='row'>
<div class='col text-center'> <div class='col text-center'>
<div class='input-group input-group-outline mb-3'> <div class='input-group input-group-outline mb-3'>
@ -64,11 +75,47 @@
</main> </main>
{% endblock %} {% endblock %}
{% block page_js %}
<script src="https://cdn.jsdelivr.net/npm/signature_pad@5.0.4/dist/signature_pad.umd.min.js"></script>
<script type='text/javascript'>
window.onload = createSignatureBlock;
var canvas = document.getElementById('signature_pad');
var pad = null;
var signatureData = JSON.parse('{{ signature|raw }}');
function createSignatureBlock() {
pad = new SignaturePad(canvas);
const ratio = Math.max(window.devicePixelRatio || 1, 1);
canvas.width = canvas.offsetWidth * ratio;
canvas.height = canvas.offsetHeight * ratio;
canvas.getContext("2d").scale(ratio, ratio);
{% if signaturePresent %}pad.fromData(signatureData);{% endif %}
document.getElementById('clearSignature').addEventListener('click', clearSignatureBlock);
}
function clearSignatureBlock(e) {
e.preventDefault();
pad.clear();
}
function saveSignatureBlock() {
document.getElementById('signature').value = JSON.stringify(pad.toData());
return true;
}
</script>
{% endblock %}
{% block page_css %} {% block page_css %}
<style rel='stylesheet'> <style rel='stylesheet'>
.profile-image { .profile-image {
width: 300px; width: 300px;
height: 300px; height: 300px;
} }
#signature_pad {
width: 100%;
height: 300px;
background-color: white;
}
</style> </style>
{% endblock %} {% endblock %}

View File

@ -24,8 +24,14 @@
</li> </li>
{% endif %} {% endif %}
{% if app.user %} {% if app.user %}
<li class='nav-item'>
<a class='nav-link me-2' href='{{ path('app_admin_dashboard') }}'>
<i class='fa fa-chart-pie opacity-5'></i>
Admin Dashboard
</a>
</li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link d-flex align-items-center me-2 active" aria-current="page" href="{{ path('app_dashboard') }}"> <a class="nav-link me-2" href="{{ path('app_dashboard') }}">
<i class="fa fa-chart-pie opacity-6 text-dark me-1"></i> <i class="fa fa-chart-pie opacity-6 text-dark me-1"></i>
Dashboard Dashboard
</a> </a>