Commit 0d1dd16f authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Complete sur l'index des instances et export

parent 356c8e88
Loading
Loading
Loading
Loading
+11 −0
Changes for module/Application/config/merged/formation.config.php: 11 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -158,6 +158,7 @@ return [
                        'envoyer-liste-complementaire',

                        'export-emargement',
                        'export-tous-emargements',
                    ],
                    'privileges' => [
                        FormationPrivileges::FORMATION_INSTANCE_MODIFIER,
@@ -337,6 +338,16 @@ return [
                            ],
                        ],
                    ],
                    'export-tous-emargements' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/export-tous-emargements/:formation-instance',
                            'defaults' => [
                                'controller' => FormationInstanceController::class,
                                'action'     => 'export-tous-emargements',
                            ],
                        ],
                    ],
                    'ajouter-agent' => [
                        'type'  => Segment::class,
                        'options' => [
+15 −0
Changes for module/Application/src/Application/Controller/FormationInstanceController.php: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -247,6 +247,17 @@ class FormationInstanceController extends AbstractActionController {
        exit;
    }

    public function exportTousEmargementsAction()
    {
        $instance = $this->getFormationInstanceService()->getRequestedFormationInstance($this);

        $exporter = new EmargementPdfExporter($this->renderer, 'A4');
        $exporter->setVars([]);
        $filemane = "formation_".$instance->getFormation()->getId()."_du_".str_replace("/","-",$instance->getDebut())."_au_".str_replace("/","-",$instance->getFin())."_emargements.pdf";
        $exporter->exportAll($instance->getJournees(), $filemane);
        exit;
    }

    /** INSCRIT ********************************************************************************************/

    public function ajouterAgentAction()
@@ -266,11 +277,15 @@ class FormationInstanceController extends AbstractActionController {
            $form->setData($data);

            if ($form->isValid()) {
                if (! $instance->hasAgent($inscrit->getAgent())) {
                    $inscrit->setListe($instance->getListeDisponible());
                    $this->getFormationInstanceInscritService()->create($inscrit);

                    $texte = ($instance->getListeDisponible() === FormationInstanceInscrit::PRINCIPALE) ? "principale" : "complémentaire";
                    $this->flashMessenger()->addSuccessMessage("L'agent <strong>" . $inscrit->getAgent()->getDenomination() . "</strong> vient d'être ajouté&middot;e en <strong>liste " . $texte . "</strong>.");
                } else {
                    $this->flashMessenger()->addErrorMessage("L'agent <strong>" . $inscrit->getAgent()->getDenomination() . "</strong> est déjà inscrit&middot;e à l'instance de formation.");
                }
            }
        }

+12 −0
Changes for module/Application/src/Application/Entity/Db/FormationInstance.php: 12 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -222,4 +222,16 @@ class FormationInstance implements HistoriqueAwareInterface {
        if ($liste === null AND ! $this->isListeComplementaireComplete()) $liste = FormationInstanceInscrit::COMPLEMENTAIRE;
        return $liste;
    }

    /**
     * @param Agent $agent
     * @return bool
     */
    public function hasAgent(Agent $agent)
    {
        foreach ($this->inscrits as $inscrit) {
            if ($inscrit->getAgent() === $agent) return true;
        }
        return false;
    }
}
 No newline at end of file
+20 −0
Changes for module/Application/src/Application/Service/Export/Formation/Emargement/EmargementPdfExporter.php: 20 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Application\Service\Export\Formation\Emargement;

use Application\Entity\Db\FicheMetier;
use Application\Entity\Db\FormationInstanceJournee;
use UnicaenApp\Exporter\Pdf as PdfExporter;
use Zend\View\Renderer\PhpRenderer;
use Zend\View\Resolver\TemplatePathStack;
@@ -35,4 +36,23 @@ class EmargementPdfExporter extends PdfExporter
        return PdfExporter::export($filename, $destination, $memoryLimit);
    }

    /**
     * @param FormationInstanceJournee[] $journees
     * @param null $filename
     * @param string $destination
     * @param null $memoryLimit
     * @return string
     */
    public function exportAll($journees, $filename = null, $destination = self::DESTINATION_BROWSER, $memoryLimit = null)
    {
        $first = true;
        $this->setHeaderScript('empty.phtml');
        $this->setFooterScript('empty.phtml');
        foreach ($journees as $journee) {
            $this->vars["journee"] = $journee;
            $this->addBodyScript('emargement.phtml', !$first, $this->vars);
            $first = false;
        }
        return PdfExporter::export($filename, $destination, $memoryLimit);
    }
}
 No newline at end of file
+9 −0
Changes for module/Application/view/application/formation-instance/afficher.phtml: 9 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -99,7 +99,16 @@ $historises = $instance->getListeHistorisee();
                    <span class="icon ajouter"></span>
                    Ajouter une journée de formation
                </a>
            <br/>
                <?php /** @see \Application\Controller\FormationInstanceController::exportTousEmargementsAction() */?>
                <a      href="<?php echo $this->url('formation-instance/export-tous-emargements', ['formation-instance' => $instance->getId()], [], true); ?>"
                        class="btn btn-primary action ajax-modal" data-event="modification">
                    <span class="icon pdf"></span>
                    Exporter les émargements
                </a>
            <?php endif; ?>
            <br/>
            <br/>
        </div>
    </div>

Loading