Commit decaf1d5 authored by Johnny Leveneur's avatar Johnny Leveneur
Browse files

initialisation scan inscription

parent 5335133b
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -203,17 +203,17 @@ class InscriptionController extends AbstractActionController
    {
        $inscription = $this->getInscriptionService()->getRequestedEntity($this);
        if ($inscription->getNombrePlacesPointees() >= $inscription->getNombrePlacesDemandees()) {
            $this->flashMessenger()->addErrorMessage("Le pointage pour "
            $this->flashMessenger()->addWarningMessage("Tous les pointages associés au compte de "
                . "<strong>" . $inscription->getParticipantDenomination() . "</strong>"
                . " à l'évènement " . "<strong>" . $inscription->getEvenement()->getLibelle() . "</strong>"
                . " n'a pu être fait");
                . " ont déjà été effectués");
        } else {
            $inscription->pointer();
            $this->getInscriptionService()->update($inscription);
            $this->flashMessenger()->addSuccessMessage("Le pointage pour <strong>"
                . "<strong>" . $inscription->getParticipantDenomination() . "</strong>"
                . " à l'évènement " . "<strong>" . $inscription->getEvenement()->getLibelle() . "</strong>"
                . "</strong> est fait.");
                . "</strong> a bien été enregistré. " . $inscription->getStringNombrePlacesLibres()) ;
        }
        $retour = $this->getRequest()->getQuery("retour");
        if ($retour) return $this->redirect()->toUrl($retour);
+26 −10
Original line number Diff line number Diff line
<?php

namespace Evenementiel\Entity\Db;

use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
@@ -117,6 +118,24 @@ class Inscription implements HistoriqueAwareInterface, HasEtatsInterface, Resour
        $this->nombrePlacesPointees = $nombrePlacesPointees;
    }

    public function getNombrePlacesLibres(): ?int
    {
        return $this->getNombrePlacesDemandees() - $this->getNombrePlacesPointees();
    }

    public function getStringNombrePlacesLibres(): string
    {
        $placesLibres = $this->getNombrePlacesLibres();
        switch ($placesLibres) {
            case 0 :
                return "L'enregistrement est complet.";
            case 1 :
                return "Il reste encore 1 place disponible.";
            default :
                return "Il reste " . $placesLibres .  " places disponibles.";
        }
    }

    public function pointer(): void
    {
        $this->setNombrePlacesPointees($this->getNombrePlacesPointees() + 1);
@@ -140,8 +159,7 @@ class Inscription implements HistoriqueAwareInterface, HasEtatsInterface, Resour

    public function setPlaces(?Collection $places): void
    {
        foreach ($places as $place)
        {
        foreach ($places as $place) {
            /** @var InscriptionPlace $place */
            $place->setInscription($this);
        }
@@ -209,8 +227,7 @@ class Inscription implements HistoriqueAwareInterface, HasEtatsInterface, Resour
    public function getArrayDenominationPlaces(): array
    {
        $tab = [];
        foreach($this->getPlaces() as $place)
        {
        foreach ($this->getPlaces() as $place) {
            /** @var InscriptionPlace $place */
            $tab[] = $place->getDenomination();
        }
@@ -259,5 +276,4 @@ class Inscription implements HistoriqueAwareInterface, HasEtatsInterface, Resour
    }



}
 No newline at end of file
+2 −3
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ use Doctrine\ORM\Mapping\Driver\XmlDriver;
use Doctrine\Persistence\Mapping\Driver\MappingDriverChain;
use Laminas\Router\Http\Literal;
use Qr\Controller\ScanController;
use Qr\Controller\ScanControllerFactory;
use UnicaenPrivilege\Guard\PrivilegeController;

return array(
@@ -85,9 +86,7 @@ return array(
    ],
    'controllers' => [
        'factories' => [
            ScanController::class => function ($container) {
                return new ScanController();
            },
            ScanController::class => ScanControllerFactory::class,
        ],
    ],
    'view_helpers' => [
+19 −1
Original line number Diff line number Diff line
<?php
namespace Qr\Controller;

use Evenementiel\Service\Inscription\InscriptionServiceAwareTrait;
use Laminas\Mvc\Controller\AbstractActionController;
use Laminas\View\Model\ViewModel;
use Laminas\View\Model\JsonModel;
@@ -8,6 +9,7 @@ use Laminas\Uri\Uri;

class ScanController extends AbstractActionController
{
    use InscriptionServiceAwareTrait ;
    /**
     * GET /qr/scan
     * Affiche la page avec le flux webcam + décodage client.
@@ -62,11 +64,27 @@ class ScanController extends AbstractActionController
            return new JsonModel(['ok' => false, 'error' => 'Path mismatch']);
        }
        $inscriptionId = (int) $m[1];
        $inscription = $this->getInscriptionService()->getEntity($inscriptionId);

        if ($inscription->getNombrePlacesPointees() >= $inscription->getNombrePlacesDemandees()) {
            $msg = "Tous les pointages associés au compte de "
                . $inscription->getParticipantDenomination()
                . " à l'évènement " . "<strong>" . $inscription->getEvenement()->getLibelle() . "</strong>"
                . " ont déjà été effectués";
        } else {
            $inscription->pointer();
            $this->getInscriptionService()->update($inscription);
            $msg = "Le pointage pour "
                . $inscription->getParticipantDenomination()
                . " à l'évènement " . $inscription->getEvenement()->getLibelle()
                . "</strong> a bien été enregistré. "
                . $inscription->getStringNombrePlacesLibres() ;
        }

        return new JsonModel([
            'ok'      => true,
            'valid'   => $valid,
            'payload' => $payload,
            'msg'     => $msg,
        ]);
    }
}
+30 −0
Original line number Diff line number Diff line
<?php

namespace Qr\Controller;

use Evenementiel\Service\Inscription\InscriptionService;
use Psr\Container\ContainerInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;

class ScanControllerFactory
{
    /**
     * @param ContainerInterface $container
     * @return ScanController
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function __invoke($container)
    {
        /**
         * @var InscriptionService $inscriptionService
         */

        $inscriptionService = $container->get(InscriptionService::class);
        $controller = new ScanController();
        $controller->setInscriptionService($inscriptionService);

        return $controller ;
    }
}
 No newline at end of file
+2 −2

File changed.

Contains only whitespace changes.

Loading