Compare commits

..

No commits in common. "24877f51af1cef6e3e87df3b7780936174ab3855" and "8825f5fc369dfca5f5dd19bd2777d329943e4fa0" have entirely different histories.

12 changed files with 166 additions and 218 deletions

0
bin/console Normal file → Executable file
View File

0
bin/phpunit Normal file → Executable file
View File

View File

@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241203041202 extends AbstractMigration
final class Version20241119001243 extends AbstractMigration
{
public function getDescription(): string
{
@ -22,27 +22,23 @@ final class Version20241203041202 extends AbstractMigration
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE case_location (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', origin_location_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', dest_location_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', date DATE NOT NULL, departure TIME DEFAULT NULL, arrival TIME DEFAULT NULL, case_mileage TINYINT(1) NOT NULL, INDEX IDX_C9E3F3B6E99C7F9 (origin_location_id), INDEX IDX_C9E3F3B6BF14A4AE (dest_location_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE case_note (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', case_id_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', report_id_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', note_type VARCHAR(255) NOT NULL, file VARCHAR(255) DEFAULT NULL, INDEX IDX_4EA520A72DAD64BB (case_id_id), INDEX IDX_4EA520A75558992E (report_id_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE company (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', owner_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', name VARCHAR(255) NOT NULL, address VARCHAR(255) NOT NULL, city VARCHAR(255) NOT NULL, state VARCHAR(10) NOT NULL, zip VARCHAR(15) NOT NULL, phone VARCHAR(15) NOT NULL, email VARCHAR(64) NOT NULL, url VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_4FBF094F7E3C61F9 (owner_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE company (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', name VARCHAR(255) NOT NULL, address VARCHAR(255) NOT NULL, city VARCHAR(255) NOT NULL, state VARCHAR(10) NOT NULL, zip VARCHAR(15) NOT NULL, phone VARCHAR(15) NOT NULL, email VARCHAR(64) NOT NULL, poc VARCHAR(255) NOT NULL, url VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE location (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', name VARCHAR(45) NOT NULL, address VARCHAR(255) NOT NULL, cases LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:array)\', lat NUMERIC(10, 6) DEFAULT NULL, lon NUMERIC(10, 6) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE location_options (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', name VARCHAR(45) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE `member` (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', case_id_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', last_name VARCHAR(45) NOT NULL, first_name VARCHAR(45) NOT NULL, relationship VARCHAR(45) DEFAULT NULL, personal_id VARCHAR(45) DEFAULT NULL, gender VARCHAR(255) DEFAULT NULL, race VARCHAR(45) DEFAULT NULL, dob DATE NOT NULL, language VARCHAR(45) DEFAULT NULL, emergency_contact VARCHAR(45) DEFAULT NULL, phone VARCHAR(15) DEFAULT NULL, day_phone VARCHAR(15) DEFAULT NULL, evening_phone VARCHAR(15) DEFAULT NULL, cell_phone VARCHAR(15) DEFAULT NULL, email VARCHAR(45) DEFAULT NULL, school VARCHAR(255) DEFAULT NULL, address VARCHAR(64) DEFAULT NULL, city VARCHAR(45) DEFAULT NULL, state VARCHAR(15) DEFAULT NULL, zip VARCHAR(10) DEFAULT NULL, marital_status VARCHAR(45) DEFAULT NULL, is_child TINYINT(1) NOT NULL, is_parent TINYINT(1) NOT NULL, is_adult_child TINYINT(1) NOT NULL, is_legal_guardian TINYINT(1) NOT NULL, parents_live_together TINYINT(1) NOT NULL, INDEX IDX_70E4FA782DAD64BB (case_id_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE member_case (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', case_number VARCHAR(15) NOT NULL, hours DOUBLE PRECISION NOT NULL, end_date DATE NOT NULL, case_name VARCHAR(64) NOT NULL, service VARCHAR(45) NOT NULL, referral_number VARCHAR(45) NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, referral_type VARCHAR(45) NOT NULL, referral_source VARCHAR(45) NOT NULL, referral_source2 VARCHAR(45) DEFAULT NULL, admit_date DATE DEFAULT NULL, close_date DATE DEFAULT NULL, dcs_case_id VARCHAR(45) DEFAULT NULL, insurance VARCHAR(45) DEFAULT NULL, medicaid VARCHAR(45) DEFAULT NULL, fcm_email VARCHAR(64) DEFAULT NULL, case_email VARCHAR(45) DEFAULT NULL, address VARCHAR(64) DEFAULT NULL, city VARCHAR(45) DEFAULT NULL, state VARCHAR(15) DEFAULT NULL, zip VARCHAR(10) DEFAULT NULL, country VARCHAR(45) DEFAULT NULL, level VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE member_case (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', case_number VARCHAR(15) NOT NULL, hours DOUBLE PRECISION NOT NULL, end_date DATE NOT NULL, case_name VARCHAR(64) NOT NULL, service VARCHAR(45) NOT NULL, referral_number VARCHAR(45) NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, referral_type VARCHAR(45) NOT NULL, referral_source VARCHAR(45) NOT NULL, referral_source2 VARCHAR(45) DEFAULT NULL, admit_date DATE DEFAULT NULL, close_date DATE DEFAULT NULL, dcs_case_id VARCHAR(45) DEFAULT NULL, insurance VARCHAR(45) DEFAULT NULL, medicaid VARCHAR(45) DEFAULT NULL, fcm_email VARCHAR(64) DEFAULT NULL, case_email VARCHAR(45) DEFAULT NULL, address VARCHAR(64) DEFAULT NULL, city VARCHAR(45) DEFAULT NULL, state VARCHAR(15) DEFAULT NULL, zip VARCHAR(10) DEFAULT NULL, country VARCHAR(45) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE method_options (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', name VARCHAR(45) NOT NULL, rel VARCHAR(45) NOT NULL, idx INT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE report (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', location_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', method_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', type VARCHAR(45) NOT NULL, start_time TIME NOT NULL, end_time TIME NOT NULL, case_number VARCHAR(45) NOT NULL, others_present JSON NOT NULL, note JSON NOT NULL, INDEX IDX_C42F778464D218E (location_id), INDEX IDX_C42F778419883967 (method_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE supervision (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', supervisor_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', worker_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', INDEX IDX_30C258C019E9AC5F (supervisor_id), UNIQUE INDEX UNIQ_30C258C06B20BA36 (worker_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE user (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', company_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', username VARCHAR(45) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, name VARCHAR(45) NOT NULL, email VARCHAR(45) NOT NULL, rate_type VARCHAR(255) NOT NULL, rate NUMERIC(6, 2) NOT NULL, level VARCHAR(255) NOT NULL, case_worker TINYINT(1) NOT NULL, case_manager TINYINT(1) NOT NULL, therapist TINYINT(1) NOT NULL, su TINYINT(1) NOT NULL, INDEX IDX_8D93D649979B1AD6 (company_id), UNIQUE INDEX UNIQ_IDENTIFIER_USERNAME (username), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE user (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', company_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', username VARCHAR(45) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, name VARCHAR(45) NOT NULL, email VARCHAR(45) NOT NULL, job VARCHAR(45) NOT NULL, rate_type VARCHAR(255) NOT NULL, rate NUMERIC(6, 2) NOT NULL, INDEX IDX_8D93D649979B1AD6 (company_id), UNIQUE INDEX UNIQ_IDENTIFIER_USERNAME (username), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE user_case (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', user_id_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', case_id_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', INDEX IDX_289D5CD9D86650F (user_id_id), INDEX IDX_289D5CD2DAD64BB (case_id_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE messenger_messages (id BIGINT AUTO_INCREMENT NOT NULL, body LONGTEXT NOT NULL, headers LONGTEXT NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', available_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', delivered_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_75EA56E0FB7336F0 (queue_name), INDEX IDX_75EA56E0E3BD61CE (available_at), INDEX IDX_75EA56E016BA31DB (delivered_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE case_location ADD CONSTRAINT FK_C9E3F3B6E99C7F9 FOREIGN KEY (origin_location_id) REFERENCES location (id)');
$this->addSql('ALTER TABLE case_location ADD CONSTRAINT FK_C9E3F3B6BF14A4AE FOREIGN KEY (dest_location_id) REFERENCES location (id)');
$this->addSql('ALTER TABLE case_note ADD CONSTRAINT FK_4EA520A72DAD64BB FOREIGN KEY (case_id_id) REFERENCES member_case (id)');
$this->addSql('ALTER TABLE case_note ADD CONSTRAINT FK_4EA520A75558992E FOREIGN KEY (report_id_id) REFERENCES report (id)');
$this->addSql('ALTER TABLE company ADD CONSTRAINT FK_4FBF094F7E3C61F9 FOREIGN KEY (owner_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE `member` ADD CONSTRAINT FK_70E4FA782DAD64BB FOREIGN KEY (case_id_id) REFERENCES member_case (id)');
$this->addSql('ALTER TABLE report ADD CONSTRAINT FK_C42F778464D218E FOREIGN KEY (location_id) REFERENCES location_options (id)');
$this->addSql('ALTER TABLE report ADD CONSTRAINT FK_C42F778419883967 FOREIGN KEY (method_id) REFERENCES method_options (id)');
$this->addSql('ALTER TABLE supervision ADD CONSTRAINT FK_30C258C019E9AC5F FOREIGN KEY (supervisor_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE supervision ADD CONSTRAINT FK_30C258C06B20BA36 FOREIGN KEY (worker_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE user ADD CONSTRAINT FK_8D93D649979B1AD6 FOREIGN KEY (company_id) REFERENCES company (id)');
$this->addSql('ALTER TABLE user_case ADD CONSTRAINT FK_289D5CD9D86650F FOREIGN KEY (user_id_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE user_case ADD CONSTRAINT FK_289D5CD2DAD64BB FOREIGN KEY (case_id_id) REFERENCES member_case (id)');
@ -55,12 +51,9 @@ final class Version20241203041202 extends AbstractMigration
$this->addSql('ALTER TABLE case_location DROP FOREIGN KEY FK_C9E3F3B6BF14A4AE');
$this->addSql('ALTER TABLE case_note DROP FOREIGN KEY FK_4EA520A72DAD64BB');
$this->addSql('ALTER TABLE case_note DROP FOREIGN KEY FK_4EA520A75558992E');
$this->addSql('ALTER TABLE company DROP FOREIGN KEY FK_4FBF094F7E3C61F9');
$this->addSql('ALTER TABLE `member` DROP FOREIGN KEY FK_70E4FA782DAD64BB');
$this->addSql('ALTER TABLE report DROP FOREIGN KEY FK_C42F778464D218E');
$this->addSql('ALTER TABLE report DROP FOREIGN KEY FK_C42F778419883967');
$this->addSql('ALTER TABLE supervision DROP FOREIGN KEY FK_30C258C019E9AC5F');
$this->addSql('ALTER TABLE supervision DROP FOREIGN KEY FK_30C258C06B20BA36');
$this->addSql('ALTER TABLE user DROP FOREIGN KEY FK_8D93D649979B1AD6');
$this->addSql('ALTER TABLE user_case DROP FOREIGN KEY FK_289D5CD9D86650F');
$this->addSql('ALTER TABLE user_case DROP FOREIGN KEY FK_289D5CD2DAD64BB');
@ -73,7 +66,6 @@ final class Version20241203041202 extends AbstractMigration
$this->addSql('DROP TABLE member_case');
$this->addSql('DROP TABLE method_options');
$this->addSql('DROP TABLE report');
$this->addSql('DROP TABLE supervision');
$this->addSql('DROP TABLE user');
$this->addSql('DROP TABLE user_case');
$this->addSql('DROP TABLE messenger_messages');

View File

@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241128014243 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE company ADD owner_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', DROP poc');
$this->addSql('ALTER TABLE company ADD CONSTRAINT FK_4FBF094F7E3C61F9 FOREIGN KEY (owner_id) REFERENCES user (id)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_4FBF094F7E3C61F9 ON company (owner_id)');
$this->addSql('ALTER TABLE member_case ADD level VARCHAR(255) NOT NULL');
$this->addSql('ALTER TABLE user ADD level VARCHAR(255) NOT NULL, CHANGE company_id company_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\'');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE company DROP FOREIGN KEY FK_4FBF094F7E3C61F9');
$this->addSql('DROP INDEX UNIQ_4FBF094F7E3C61F9 ON company');
$this->addSql('ALTER TABLE company ADD poc VARCHAR(255) NOT NULL, DROP owner_id');
$this->addSql('ALTER TABLE member_case DROP level');
$this->addSql('ALTER TABLE user DROP level, CHANGE company_id company_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\'');
}
}

View File

@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241130210724 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE supervision (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', supervisor_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', worker_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', INDEX IDX_30C258C019E9AC5F (supervisor_id), UNIQUE INDEX UNIQ_30C258C06B20BA36 (worker_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE supervision ADD CONSTRAINT FK_30C258C019E9AC5F FOREIGN KEY (supervisor_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE supervision ADD CONSTRAINT FK_30C258C06B20BA36 FOREIGN KEY (worker_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE user DROP supervisor_id');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE supervision DROP FOREIGN KEY FK_30C258C019E9AC5F');
$this->addSql('ALTER TABLE supervision DROP FOREIGN KEY FK_30C258C06B20BA36');
$this->addSql('DROP TABLE supervision');
$this->addSql('ALTER TABLE user ADD supervisor_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\'');
}
}

View File

@ -7,7 +7,6 @@ use App\Entity\User;
use App\Form\EditUserFormType;
use App\Form\SupervisorFormType;
use App\Form\UserFormType;
use App\Libs\NavList;
use App\Repository\UserRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@ -26,7 +25,13 @@ class AdminController extends AbstractController
private readonly UserPasswordHasherInterface $userPasswordHasher,
private array $navLinks = []
) {
$this->navLinks = NavList::LIST;
$this->navLinks = [
'admin_dashboard' => 'nav-link text-dark',
'user_dashboard' => 'nav-link text-dark',
'profile' => 'nav-link text-dark',
'user_list' => 'nav-link text-dark',
'staff_dashboard' => 'nav-link text-dark',
];
}
#[Route('/admin-dashboard', name: 'app_admin_dashboard')]
@ -94,38 +99,23 @@ class AdminController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) {
$plainPassword = $form->get('password')->getData();
$roles = ['ROLE_USER'];
if ($form->get('caseWorker')->getData()) {
$roles[] = 'ROLE_CASE_WORKER';
}
$user->setUsername($form->get('username')->getData());
$user->setPassword(
$this->userPasswordHasher->hashPassword(
$user,
$plainPassword
)
);
$user->setRoles(['ROLE_USER']);
$user->setName($form->get('name')->getData());
$user->setEmail($form->get('email')->getData());
$user->setJob($form->get('job')->getData());
$user->setRateType($form->get('rateType')->getData());
$user->setRate($form->get('rate')->getData());
$user->setLevel($form->get('level')->getData());
if ($form->get('caseManager')->getData()) {
$roles[] = 'ROLE_CASE_MANAGER';
}
if ($form->get('therapist')->getData()) {
$roles[] = 'ROLE_THERAPIST';
}
if ($form->get('su')->getData()) {
$roles[] = 'ROLE_ADMIN';
}
$user->setUsername($form->get('username')->getData())
->setPassword(
$this->userPasswordHasher->hashPassword(
$user,
$plainPassword
)
)
->setName($form->get('name')->getData())
->setEmail($form->get('email')->getData())
->setRoles($roles)
->setRateType($form->get('rateType')->getData())
->setRate($form->get('rate')->getData())
->setLevel($form->get('level')->getData())
->setCompany($admin->getCompany());
$user->setCompany($admin->getCompany());
$this->entityManager->persist($user);
$this->entityManager->flush();
@ -167,10 +157,7 @@ class AdminController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) {
$user->setName($form->get('name')->getData())
->setEmail($form->get('email')->getData())
->setCaseWorker($form->get('caseWorker')->getData())
->setCaseManager($form->get('caseManager')->getData())
->setTherapist($form->get('therapist')->getData())
->setSu($form->get('su')->getData())
->setJob($form->get('job')->getData())
->setRateType($form->get('rateType')->getData())
->setRate($form->get('rate')->getData())
->setLevel($form->get('level')->getData());
@ -238,4 +225,23 @@ class AdminController extends AbstractController
)
);
}
#[Route('/list-cases', name: 'app_list_cases')]
public function listCases(#[CurrentUser()] User $user): Response
{
$this->denyAccessUnlessGranted('ROLE_ADMIN');
return $this->render(
'internal/cases/case-list.html.twig',
array_merge(
$this->navLinks,
[
'breadcrumbs' => [
'List Cases'
],
'notifications' => $user->retrieveUnreadNotifications(),
]
)
);
}
}

View File

@ -1,69 +0,0 @@
<?php
namespace App\Controller;
use App\Entity\MemberCase;
use App\Entity\User;
use App\Form\MemberCaseFormType;
use App\Libs\NavList;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\CurrentUser;
class CaseController extends AbstractController
{
public function __construct(
private array $navLinks = []
) {
$this->navLinks = NavList::LIST;
}
#[Route('/list-cases', name: 'app_list_cases')]
public function listCases(#[CurrentUser()] User $user): Response
{
$this->denyAccessUnlessGranted('ROLE_ADMIN');
$this->navLinks['case_list'] = 'nav-link text-white active bg-gradient-dark';
return $this->render(
'internal/cases/case-list.html.twig',
array_merge(
$this->navLinks,
[
'breadcrumbs' => [
'List Cases'
],
'notifications' => $user->retrieveUnreadNotifications(),
]
)
);
}
#[Route('/add-case', name: 'app_case')]
public function addCase(#[CurrentUser()] User $admin): Response
{
$this->denyAccessUnlessGranted('ROLE_ADMIN');
$this->navLinks['case_list'] = 'nav-link text-white active bg-gradient-dark';
$case = new MemberCase();
$form = $this->createForm(MemberCaseFormType::class, $case);
return $this->render(
'internal/admin/cases/add-case.html.twig',
array_merge(
$this->navLinks,
[
'title' => 'Add Case',
'breadcrumbs' => [
'Case',
'Add Case'
],
'notifications' => $admin->retrieveUnreadNotifications(),
'form' => $form,
]
)
);
}
}

View File

@ -3,7 +3,7 @@
namespace App\Controller;
use App\Entity\User;
use App\Libs\NavList;
use App\Form\UserFormType;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
@ -20,7 +20,13 @@ class DefaultController extends AbstractController
private readonly UserPasswordHasherInterface $userPasswordHasher,
private array $navLinks = []
) {
$this->navLinks = NavList::LIST;
$this->navLinks = [
'admin_dashboard' => 'nav-link text-dark',
'user_dashboard' => 'nav-link text-dark',
'profile' => 'nav-link text-dark',
'user_list' => 'nav-link text-dark',
'staff_dashboard' => 'nav-link text-dark',
];
}
#[Route('/dashboard', name: 'app_dashboard')]

View File

@ -80,14 +80,11 @@ class RegistrationController extends AbstractController
)
);
$user->setCaseWorker(true)
->setCaseManager(true)
->setTherapist(true)
->setSu(true)
->setRateType(RateType::FIXED)
->setRate('0.00')
->setRoles(['ROLE_ADMIN'])
->setLevel(CaseLevel::ADMIN);
$user->setJob(JobType::ADMIN);
$user->setRateType(RateType::FIXED);
$user->setRate('0.00');
$user->setRoles(['ROLE_ADMIN']);
$user->setLevel(CaseLevel::ADMIN);
// save user
$this->entityManager->persist($user);

View File

@ -3,7 +3,6 @@
namespace App\Controller;
use App\Entity\User;
use App\Libs\NavList;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
@ -18,7 +17,13 @@ class StaffController extends AbstractController
private readonly UserPasswordHasherInterface $userPasswordHasher,
private array $navLinks = []
) {
$this->navLinks = NavList::LIST;
$this->navLinks = [
'admin_dashboard' => 'nav-link text-dark',
'user_dashboard' => 'nav-link text-dark',
'profile' => 'nav-link text-dark',
'user_list' => 'nav-link text-dark',
'staff_dashboard' => 'nav-link text-dark',
];
}
#[Route('/staff-dashboard', name: 'staff')]

View File

@ -4,9 +4,10 @@ namespace App\Entity;
use App\Repository\UserRepository;
use App\Enums\RateType;
use App\Enums\CaseLevel;
use App\Enums\JobType;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Types\UuidType;
@ -14,6 +15,7 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Uid\Uuid;
use \App\Enums\CaseLevel;
#[ORM\Entity(repositoryClass: UserRepository::class)]
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_USERNAME', fields: ['username'])]
@ -47,6 +49,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
#[ORM\Column(length: 45)]
private ?string $email = null;
#[ORM\Column(length: 45)]
private ?JobType $job = null;
#[ORM\Column(enumType: RateType::class)]
private ?RateType $rateType = null;
@ -68,18 +73,6 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
private ?User $supervisor = null;
#[ORM\Column]
private ?bool $caseWorker = null;
#[ORM\Column]
private ?bool $caseManager = null;
#[ORM\Column]
private ?bool $therapist = null;
#[ORM\Column]
private ?bool $su = null;
public function __construct()
{
$this->userCases = new ArrayCollection();
@ -184,6 +177,18 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
return $this;
}
public function getJob(): ?JobType
{
return $this->job;
}
public function setJob(JobType $job): static
{
$this->job = $job;
return $this;
}
public function getRateType(): ?RateType
{
return $this->rateType;
@ -303,74 +308,4 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
return $this;
}
public function isCaseWorker(): ?bool
{
return $this->caseWorker;
}
public function setCaseWorker(bool $caseWorker): static
{
$this->caseWorker = $caseWorker;
return $this;
}
public function isCaseManager(): ?bool
{
return $this->caseManager;
}
public function setCaseManager(bool $caseManager): static
{
$this->caseManager = $caseManager;
return $this;
}
public function isTherapist(): ?bool
{
return $this->therapist;
}
public function setTherapist(bool $therapist): static
{
$this->therapist = $therapist;
return $this;
}
public function isSu(): ?bool
{
return $this->su;
}
public function setSu(bool $su): static
{
$this->su = $su;
return $this;
}
public function getJobs(): array
{
$jobs = [];
if ($this->caseWorker) {
$jobs[] = 'Case Worker';
}
if ($this->caseManager) {
$jobs[] = 'Case Manager';
}
if ($this->therapist) {
$jobs[] = 'Therapist';
}
if ($this->su) {
$jobs[] = 'Admin';
}
return $jobs;
}
}

View File

@ -37,9 +37,9 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader
public function getCaseManagers(Company $company): array
{
return $this->createQueryBuilder('u')
->andWhere('u.caseManager = :case_manager')
->andWhere('u.job != :job')
->andWhere('u.company = :company')
->setParameter('case_manager', true)
->setParameter('job', 'CASE_WORKER')
->setParameter('company', $company->getId()->toBinary())
->getQuery()
->getResult()
@ -49,9 +49,9 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader
public function getTherapists(Company $company): array
{
return $this->createQueryBuilder('u')
->andWhere('u.therapist = :therapist')
->andWhere('u.job = :job')
->andWhere('u.company = :company')
->setParameter('therapist', true)
->setParameter('job', 'THERAPIST')
->setParameter('company', $company->getId()->toBinary())
->getQuery()
->getResult()
@ -61,9 +61,9 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader
public function getAdmins(Company $company): array
{
return $this->createQueryBuilder('u')
->andWhere('u.su = :su')
->andWhere('u.job = :job')
->andWhere('u.company = :company')
->setParameter('su', true)
->setParameter('job', 'ADMIN')
->setParameter('company', $company->getId()->toBinary())
->getQuery()
->getResult()