second
This commit is contained in:
parent
0057bbcd96
commit
85125c7d6b
|
@ -6,6 +6,16 @@
|
|||
*/
|
||||
|
||||
// any CSS you import will output into a single css file (app.css in this case)
|
||||
import 'jquery';
|
||||
|
||||
// start the Stimulus application
|
||||
import GetEvent from './js/getCodeBarre';
|
||||
import './bootstrap';
|
||||
|
||||
$(document).ready(()=>{
|
||||
setTimeout(()=>{
|
||||
// utils.init();
|
||||
GetEvent.init()
|
||||
|
||||
}, 200);
|
||||
})
|
|
@ -0,0 +1,29 @@
|
|||
export default class GetEvent{
|
||||
static init(){
|
||||
this.getEvent()
|
||||
}
|
||||
|
||||
static getEvent(){
|
||||
console.log("test init");
|
||||
let saisie = $('#saisie');
|
||||
saisie.focus();
|
||||
let value;
|
||||
document.addEventListener('keydown', function (event) {
|
||||
saisie.focus();
|
||||
if(event.code == 'Tab'){
|
||||
value = saisie.val();
|
||||
saisie.val('')
|
||||
$.ajax({
|
||||
url: '/api/get-code-barre-type',
|
||||
method: "POST",
|
||||
dataType: "json",
|
||||
data: {'codeBarre': value},
|
||||
success: function(response){
|
||||
console.log(response)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
|
@ -25,6 +25,7 @@
|
|||
"@popperjs/core": "^2.11.6",
|
||||
"bootstrap": "^5.2.2",
|
||||
"jQuery": "^1.7.4",
|
||||
"jquery": "^3.6.1",
|
||||
"tom-select": "^2.2.2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,174 @@
|
|||
<?php
|
||||
namespace App\Controller\Api;
|
||||
|
||||
use App\Entity\Don;
|
||||
use App\Repository\DmuCatRepository;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
||||
/**
|
||||
* @Route("/api", name="front_api_")
|
||||
*/
|
||||
class ApiController extends AbstractController
|
||||
{
|
||||
public const REGEX_DON = '/^[0-9]{11}$/';
|
||||
public const REGEX_GROUP_POCHE = '/^\d{6}[A-Z]{3}$/';
|
||||
public const REGEX_ETIQUETTE = '/^\d{11}[\|]{1}[a-z]{1}$/';
|
||||
public const NBRE_POCHE = 'nbre_poche';
|
||||
|
||||
/** @var DmuCatRepository*/
|
||||
public $dmuCatRepository;
|
||||
|
||||
/** @var RequestStack*/
|
||||
public $requestStack;
|
||||
|
||||
public function __construct(DmuCatRepository $dmuCatRepository, RequestStack $requestStack)
|
||||
{
|
||||
$this->dmuCatRepository = $dmuCatRepository;
|
||||
$this->requestStack = $requestStack;
|
||||
}
|
||||
/**
|
||||
* @Route("/get-code-barre-type", name="code_barre_type_", methods={"POST"})
|
||||
*/
|
||||
public function GetCodeBarreType(Request $request)
|
||||
{
|
||||
$codeBarre = $request->request->get('codeBarre');
|
||||
$session = $request->getSession();
|
||||
$step = $session->get('step') ?? 0;
|
||||
|
||||
if($step != 0 && preg_match(self::REGEX_DON, $codeBarre)){
|
||||
$this->init($session, $don = $this->dmuCatRepository->findOneByGiftNumber($codeBarre));
|
||||
return $this->json(['data'=>[
|
||||
'nbre_tube'=>$don->getNbreTube(),
|
||||
'donneur'=>$don->getPatient()->getFirstname() . ' ' . $don->getPatient()->getLastname()
|
||||
]]);
|
||||
}
|
||||
switch($step){
|
||||
case 0:
|
||||
if(preg_match(self::REGEX_DON, $codeBarre)){
|
||||
$don = $this->dmuCatRepository->findOneByGiftNumber($codeBarre);
|
||||
$this->init($session, $don);
|
||||
return $this->json(['data'=>[
|
||||
'nbre_tube'=>$don->getNbreTube(),
|
||||
'donneur'=>$don->getPatient()->getFirstname() . ' ' . $don->getPatient()->getLastname()
|
||||
]]);
|
||||
}else{
|
||||
return $this->json(['data'=>'error']);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if(preg_match(self::REGEX_GROUP_POCHE, $codeBarre)){
|
||||
$dmuCatNumber = $this->dmuCatRepository->findOneByCodeBarre($codeBarre)->getPocheNumber();
|
||||
$session->set('step', 2);
|
||||
$session->set('nbre_poche' , $dmuCatNumber);
|
||||
return $this->json(['data'=>[
|
||||
'nbre_poche'=>$dmuCatNumber,
|
||||
]]);
|
||||
}else{
|
||||
return $this->json(['data'=>'error']);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if(preg_match(self::REGEX_ETIQUETTE, $codeBarre)){
|
||||
$nbrePoche = $session->get('nbre_poche');
|
||||
|
||||
$listPoche = $session->get('list_poche');
|
||||
if(!in_array($codeBarre, $listPoche)){
|
||||
$listPoche[] = $codeBarre;
|
||||
$session->set('liste_poche', $listPoche);
|
||||
}else{
|
||||
return $this->json(['data'=>'doublon']);
|
||||
}
|
||||
if($nbrePoche == 1){
|
||||
$session->set('step', 3);
|
||||
$session->set('nbre_poche', 0);
|
||||
return $this->json(['data'=>[
|
||||
'nbre_poche'=>$nbrePoche - 1,
|
||||
'poche'=>'success'
|
||||
]
|
||||
]
|
||||
);
|
||||
}else{
|
||||
$session->set('nbre_poche', $nbrePoche - 1);
|
||||
return $this->json(['data'=>[
|
||||
'nbre_poche'=>$nbrePoche - 1
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
}else{
|
||||
return $this->json(['data'=>'error']);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if(preg_match(self::REGEX_GROUP_POCHE, $codeBarre)){
|
||||
$session->set('step', 4);
|
||||
return $this->json(['data'=>[
|
||||
'tube'=>true,
|
||||
]]);
|
||||
}else{
|
||||
return $this->json(['data'=>'error']);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if(preg_match(self::REGEX_ETIQUETTE, $codeBarre)){
|
||||
$nbreTube = $session->get('nbre_tube');
|
||||
|
||||
$listTube = $session->get('list_tube');
|
||||
if(!in_array($codeBarre, $listTube)){
|
||||
$listTube[] = $codeBarre;
|
||||
$session->set('list_tube', $listTube);
|
||||
}else{
|
||||
return $this->json(['data'=>'doublon']);
|
||||
}
|
||||
if($nbreTube == 1){
|
||||
$session->set('step', 0);
|
||||
$session->set('nbre_tube', 0);
|
||||
$session->clear();
|
||||
return $this->json(['data'=>[
|
||||
'nbre_tube'=>$nbreTube - 1,
|
||||
'tube'=>'success'
|
||||
]
|
||||
]
|
||||
);
|
||||
}else{
|
||||
$session->set('nbre_tube', $nbreTube - 1);
|
||||
return $this->json(['data'=>[
|
||||
'nbre_tube'=>$nbreTube - 1
|
||||
]
|
||||
]);
|
||||
}
|
||||
}else{
|
||||
return $this->json(['data'=>'error']);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return $this->json(['data'=>'error']);
|
||||
}
|
||||
}
|
||||
|
||||
public function init($session, Don $don)
|
||||
{
|
||||
$session->set('don' , $don->getId());
|
||||
$session->set('nbre_tube', $don->getNbreTube());
|
||||
$session->set('liste_poche', []);
|
||||
$session->set('liste_tube', []);
|
||||
$session->set('donneur', $don->getDonneur()->getFirstname() . ' ' . $don->getDonneur()->getLastname());
|
||||
$session->set('step', 1);
|
||||
}
|
||||
|
||||
// public function raz()
|
||||
// {
|
||||
// $session = $this->requestStack->getSession();
|
||||
// $session->remove('don' );
|
||||
// $session->remove('nbre_tube');
|
||||
// $session->remove('liste_poche');
|
||||
// $session->remove('liste_tube');
|
||||
// $session->remove('donneur');
|
||||
// $session->remove('step');
|
||||
|
||||
// }
|
||||
|
||||
}
|
|
@ -54,7 +54,8 @@ class DmuCatController extends AbstractController
|
|||
],
|
||||
'fields' => [
|
||||
'Id' => 'Id',
|
||||
'CodeBarre' => 'CodeBarre',
|
||||
'CodeBarre' => 'CodeBarre',
|
||||
'PocheNumber'=>'PocheNumber'
|
||||
|
||||
],
|
||||
'title' => 'Tous les élements',
|
||||
|
@ -100,10 +101,9 @@ class DmuCatController extends AbstractController
|
|||
* @Route("/edit/{id}", name="edit")
|
||||
* @param Request $request
|
||||
* @param DmuCat $dmuCat
|
||||
* @param Tools $tools
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(Request $request, DmuCat $dmuCat, Tools $tools): Response
|
||||
public function edit(Request $request, DmuCat $dmuCat, DmuCatHandler $dmuCatHandler): Response
|
||||
{
|
||||
$form = $this->createForm(DmuCatType::class, $dmuCat);
|
||||
if ($dmuCatHandler->edit($form, $request)) {
|
||||
|
|
|
@ -103,7 +103,7 @@ class DonCatController extends AbstractController
|
|||
* @param Tools $tools
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(Request $request, DonCat $donCat, Tools $tools): Response
|
||||
public function edit(Request $request, DonCat $donCat,DonCatHandler $donCatHandler): Response
|
||||
{
|
||||
$form = $this->createForm(DonCatType::class, $donCat);
|
||||
if ($donCatHandler->edit($form, $request)) {
|
||||
|
|
|
@ -55,6 +55,7 @@ class DonController extends AbstractController
|
|||
'fields' => [
|
||||
'Id' => 'Id',
|
||||
'GiftNumber' => 'GiftNumber',
|
||||
'Nombre tube'=> 'NbreTube',
|
||||
'Categorie' => 'DonCat',
|
||||
'Donneur' => 'Donneur',
|
||||
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
||||
class FrontController extends AbstractController
|
||||
{
|
||||
#[Route("/", name: "app_front")]
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
return $this->render('front/index.html.twig');
|
||||
}
|
||||
}
|
|
@ -106,7 +106,7 @@ class TubeController extends AbstractController
|
|||
* @param Tools $tools
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(Request $request, Tube $tube, Tools $tools): Response
|
||||
public function edit(Request $request, Tube $tube, TubeHandler $tubeHandler): Response
|
||||
{
|
||||
$form = $this->createForm(TubeType::class, $tube);
|
||||
if ($tubeHandler->edit($form, $request)) {
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\TypeDmuRepository;
|
||||
use App\Repository\DmuCatRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: TypeDmuRepository::class)]
|
||||
#[ORM\Entity(repositoryClass: DmuCatRepository::class)]
|
||||
class DmuCat
|
||||
{
|
||||
#[ORM\Id]
|
||||
|
@ -13,7 +13,7 @@ class DmuCat
|
|||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column]
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?int $pocheNumber = null;
|
||||
|
||||
#[ORM\Column(length: 1000)]
|
||||
|
|
|
@ -14,7 +14,7 @@ class Don
|
|||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?int $giftNumber = null;
|
||||
private ?string $giftNumber = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'dons')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
|
@ -24,20 +24,20 @@ class Don
|
|||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?Patient $donneur = null;
|
||||
|
||||
#[ORM\Column(length: 1000, nullable: true)]
|
||||
private ?string $codeBarre = null;
|
||||
#[ORM\Column]
|
||||
private ?int $nbreTube = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getGiftNumber(): ?int
|
||||
public function getGiftNumber(): ?string
|
||||
{
|
||||
return $this->giftNumber;
|
||||
}
|
||||
|
||||
public function setGiftNumber(int $giftNumber): self
|
||||
public function setGiftNumber(string $giftNumber): self
|
||||
{
|
||||
$this->giftNumber = $giftNumber;
|
||||
|
||||
|
@ -68,14 +68,14 @@ class Don
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getCodeBarre(): ?string
|
||||
public function getNbreTube(): ?int
|
||||
{
|
||||
return $this->codeBarre;
|
||||
return $this->nbreTube;
|
||||
}
|
||||
|
||||
public function setCodeBarre(?string $codeBarre): self
|
||||
public function setNbreTube(int $nbreTube): self
|
||||
{
|
||||
$this->codeBarre = $codeBarre;
|
||||
$this->nbreTube = $nbreTube;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class Patient
|
|||
private ?\DateTimeInterface $birthdate = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?int $donneurNumber = null;
|
||||
private ?string $donneurNumber = null;
|
||||
|
||||
#[ORM\OneToMany(mappedBy: 'donneur', targetEntity: Don::class, orphanRemoval: true)]
|
||||
private Collection $dons;
|
||||
|
@ -77,12 +77,12 @@ class Patient
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getDonneurNumber(): ?int
|
||||
public function getDonneurNumber(): ?string
|
||||
{
|
||||
return $this->donneurNumber;
|
||||
}
|
||||
|
||||
public function setDonneurNumber(int $donneurNumber): self
|
||||
public function setDonneurNumber(string $donneurNumber): self
|
||||
{
|
||||
$this->donneurNumber = $donneurNumber;
|
||||
|
||||
|
@ -118,7 +118,7 @@ class Patient
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->firstname.' '.$this->lastname;
|
||||
|
|
|
@ -12,7 +12,9 @@ class DmuCatType extends AbstractType
|
|||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('pocheNumber')
|
||||
->add('pocheNumber', null, [
|
||||
'required'=>false,
|
||||
])
|
||||
->add('codeBarre')
|
||||
;
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@ class DonType extends AbstractType
|
|||
{
|
||||
$builder
|
||||
->add('giftNumber')
|
||||
->add('codeBarre')
|
||||
->add('donCat', EntityType::class, [
|
||||
'class'=> DonCat::class,
|
||||
'choice_label'=> 'name'
|
||||
])
|
||||
->add('nbreTube')
|
||||
->add('donneur', EntityType::class, [
|
||||
'class'=> Patient::class,
|
||||
])
|
||||
|
|
|
@ -6,6 +6,8 @@ use App\Entity\Patient;
|
|||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
|
||||
class PatientType extends AbstractType
|
||||
{
|
||||
|
@ -14,8 +16,11 @@ class PatientType extends AbstractType
|
|||
$builder
|
||||
->add('lastname')
|
||||
->add('firstname')
|
||||
->add('birthdate')
|
||||
->add('donneurNumber')
|
||||
->add('birthdate', DateType::class, [
|
||||
'years' => range(intval(date('Y')) - 10, 1920),
|
||||
|
||||
])
|
||||
->add('donneurNumber', TextType::class)
|
||||
;
|
||||
}
|
||||
|
||||
|
|
|
@ -114,10 +114,10 @@
|
|||
<span data-bs-toggle="tooltip" title="editer">
|
||||
<a href="{{ path( route~"_edit", {'id': el.id}) }}" class="btn btn-sm btn-info"><i class="fas fa-edit"></i></a>
|
||||
</span>
|
||||
<span data-bs-toggle="tooltip" title="Supprimer">
|
||||
<span title="Supprimer">
|
||||
<a href="#" data-bs-toggle="modal" data-bs-target="#deletePicture{{ el.id }}" class="btn btn-sm btn-danger"><i class="fas fa-trash-alt"></i></a>
|
||||
</span>
|
||||
<div id="deletePicture{{ el.id }}" class="text-left modal fade" role="dialog">
|
||||
<div id="deletePicture{{ el.id }}" class="text-left modal fade" role="dialog" aria-hideen="true">
|
||||
<div class="modal-dialog">
|
||||
<!-- Modal content-->
|
||||
<div class="modal-content">
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
{{ encore_entry_script_tags('app') }}
|
||||
{% endblock %}
|
||||
</head>
|
||||
.cont
|
||||
<body>
|
||||
{% block body %}{% endblock %}
|
||||
</body>
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
<!doctype html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>{% block title %}Administration{% endblock %}</title>
|
||||
<meta name="robots" content="noindex, nofollow">
|
||||
<link rel="shortcut icon" type="image/png" href="{{ asset('favicon/favicon.ico') }}"/>
|
||||
|
||||
{{ encore_entry_link_tags('adminStyle') }}
|
||||
{% block stylesheets %}
|
||||
|
||||
{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
<form action="">
|
||||
<input type="text" style="visibility:visible" id="saisie">
|
||||
</form>
|
||||
<div class="container">
|
||||
<div class="wrapper">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{{ encore_entry_script_tags('app') }}
|
||||
</body>
|
||||
</html>
|
|
@ -2786,6 +2786,11 @@ jest-worker@^29.1.2:
|
|||
merge-stream "^2.0.0"
|
||||
supports-color "^8.0.0"
|
||||
|
||||
jquery@^3.6.1:
|
||||
version "3.6.1"
|
||||
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.6.1.tgz#fab0408f8b45fc19f956205773b62b292c147a16"
|
||||
integrity sha512-opJeO4nCucVnsjiXOE+/PcCgYw9Gwpvs/a6B1LL/lQhwWwpbVEVYDZ1FokFr8PRc7ghYlrFPuyHuiiDNTQxmcw==
|
||||
|
||||
js-tokens@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
|
||||
|
|
Loading…
Reference in New Issue