From 0650f174cc4f90931ffc888b3896dc04b05dbc1a Mon Sep 17 00:00:00 2001 From: rudy Date: Tue, 23 May 2023 16:06:53 +0200 Subject: [PATCH] correction fixtures, css --- assets/styles/front.scss | 3 +- src/Controller/Api/ApiController.php | 51 ++++++++++++++++++++++------ src/DataFixtures/CatDmuFixtures.php | 6 ++-- src/DataFixtures/DonFixtures.php | 14 +++++++- src/DataFixtures/PatientFixtures.php | 10 ++++++ templates/front/index.html.twig | 4 +-- 6 files changed, 70 insertions(+), 18 deletions(-) diff --git a/assets/styles/front.scss b/assets/styles/front.scss index 2d61a8a..816c9aa 100644 --- a/assets/styles/front.scss +++ b/assets/styles/front.scss @@ -101,8 +101,9 @@ } .gift_cb { display: grid; + text-align: center; grid-template-columns: 100%; - grid-template-rows: 75% 25%; + // grid-template-rows: 75% 25%; grid-template-areas: "cb" "number_cb"; diff --git a/src/Controller/Api/ApiController.php b/src/Controller/Api/ApiController.php index 83edfbd..f5c6d79 100644 --- a/src/Controller/Api/ApiController.php +++ b/src/Controller/Api/ApiController.php @@ -15,18 +15,47 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; class ApiController extends AbstractController { public const REGEX_DON = '/^[0-9]{11}$/'; - public const REGEX_GROUP_POCHE = '/[0-9]{6}[A-Z]{2}$/'; - public const REGEX_ETIQUETTE = '/^\d{11}[\|]{1}[a-z]{1}$/'; + public const REGEX_GROUP_POCHE = '/[0-9]{6}-[A-Z]{2}-POCHE$/'; + public const REGEX_ETIQUETTE = '/^\d{11}-[a-zA-Z]{2}$/'; public const NBRE_POCHE = 'nbre_poche'; - /** @var DonRepository*/ - public $donRepository; - /** @var DmuCatRepository*/ - public $dmuCatRepository; - - /** @var RequestStack*/ - public $requestStack; + public DonRepository $donRepository; + public DmuCatRepository $dmuCatRepository; + public RequestStack $requestStack; + // etiquette durand + // 12345678912-AA + // 12345678912-AB + // 12345678912-AC + // 12345678912-AD + // 12345678912-AE + // 12345678912-AF + // 12345678912-BA + // 12345678912-BB + // 12345678912-BC + // 12345678912-BD + // 12345678912-BE + // 12345678912-BF + // 12345678912-CA + // 12345678912-CB + // 12345678912-CC + + // etiquette Gauthier + // 12345678913-AA + // 12345678913-AB + // 12345678913-AC + // 12345678913-AD + // 12345678913-AE + // 12345678913-AF + // 12345678913-BA + // 12345678913-BB + // 12345678913-BC + // 12345678913-BD + // 12345678913-BE + // 12345678913-BF + // 12345678913-CA + // 12345678913-CB + // 12345678913-CC public function __construct(DonRepository $donRepository, RequestStack $requestStack, DmuCatRepository $dmuCatRepository) { $this->donRepository = $donRepository; @@ -104,7 +133,7 @@ class ApiController extends AbstractController if(preg_match(self::REGEX_ETIQUETTE, $codeBarre)){ $nbrePoche = $session->get('nbre_poche'); $donCodeBarre = $session->get('don_code_barre'); - $in = strpos('zz'.$codeBarre, $donCodeBarre); + $in = str_contains($codeBarre, $donCodeBarre); if(!$in){ return $this->json(['data'=>[ 'step'=> '2', @@ -174,7 +203,7 @@ class ApiController extends AbstractController if(preg_match(self::REGEX_ETIQUETTE, $codeBarre)){ $nbreTube = $session->get('nbre_tube'); $donCodeBarre = $session->get('don_code_barre'); - if(!strpos('zz'.$codeBarre, $donCodeBarre)){ + if(!str_contains($codeBarre, $donCodeBarre)){ return $this->json(['data'=>[ 'step'=>'4', 'status'=>'error_donneur' diff --git a/src/DataFixtures/CatDmuFixtures.php b/src/DataFixtures/CatDmuFixtures.php index 295ee64..fdd278b 100644 --- a/src/DataFixtures/CatDmuFixtures.php +++ b/src/DataFixtures/CatDmuFixtures.php @@ -11,19 +11,19 @@ class CatDmuFixtures extends Fixture public function load(ObjectManager $manager): void { $dmuCat1 = (new DmuCat()) - ->setCodeBarre('123456FF') + ->setCodeBarre('123456-FF-POCHE') ->setPocheNumber(3) ; $manager->persist($dmuCat1); $dmuCat2 = (new DmuCat()) - ->setCodeBarre('123456BB') + ->setCodeBarre('123456-BB-POCHE') ->setPocheNumber(4) ; $manager->persist($dmuCat2); $dmuCat3 = (new DmuCat()) - ->setCodeBarre('123456BB') + ->setCodeBarre('123456-CC-POCHE') ->setPocheNumber(5) ; $manager->persist($dmuCat3); diff --git a/src/DataFixtures/DonFixtures.php b/src/DataFixtures/DonFixtures.php index 6eb06af..fb75d1a 100644 --- a/src/DataFixtures/DonFixtures.php +++ b/src/DataFixtures/DonFixtures.php @@ -20,7 +20,7 @@ class DonFixtures extends Fixture implements DependentFixtureInterface } public function load(ObjectManager $manager): void { - $donneur = $this->patientRepository->findBy([], ['lastname'=>'ASC'], 1)[0]; + $donneur = $this->patientRepository->findOneBy(['lastname'=>'Durand']); $donCat = $this->donCatRepository->findBy([], ['name'=>'ASC'], 1)[0]; $donneur = (new Don()) ->setCodeBarre('12345678912') @@ -30,6 +30,18 @@ class DonFixtures extends Fixture implements DependentFixtureInterface ; $manager->persist($donneur); $manager->flush(); + + + $donneur = $this->patientRepository->findOneBy(['lastname'=>'Gauthier']); + $donCat = $this->donCatRepository->findBy([], ['name'=>'ASC'], 1)[0]; + $donneur = (new Don()) + ->setCodeBarre('12345678913') + ->setDonCat($donCat) + ->setNbreTube(6) + ->setDonneur($donneur) + ; + $manager->persist($donneur); + $manager->flush(); } diff --git a/src/DataFixtures/PatientFixtures.php b/src/DataFixtures/PatientFixtures.php index eac405e..69ccd12 100644 --- a/src/DataFixtures/PatientFixtures.php +++ b/src/DataFixtures/PatientFixtures.php @@ -25,5 +25,15 @@ class PatientFixtures extends Fixture ; $manager->persist($donneur); $manager->flush(); + + + $donneur = (new Patient()) + ->setLastname('Gauthier') + ->setFirstname('Isabelle') + ->setBirthdate(new DateTime('01-01-1980')) + ->setDonneurNumber('123999') + ; + $manager->persist($donneur); + $manager->flush(); } } \ No newline at end of file diff --git a/templates/front/index.html.twig b/templates/front/index.html.twig index 3b677a9..0b781ce 100644 --- a/templates/front/index.html.twig +++ b/templates/front/index.html.twig @@ -39,8 +39,8 @@