Commit 5e78dbaa authored by joriot221's avatar joriot221
Browse files

Merge remote-tracking branch 'origin/VFJ_18_RefusPiece' into VFJ_18_RefusPiece

parents c1241f4a 65d8168c
Loading
Loading
Loading
Loading
+1 −0
Changes for data/privileges.php: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -117,6 +117,7 @@ return [
            'visualisation'         => 'Visualisation',
            'edition'               => 'Édition',
            'validation'            => 'Validation',
            'refus-piece'           => 'Refus - Pièce justificative',
            'devalidation'          => 'Dévalidation',
            'archivage'             => 'Archivage',
            'gestion-edition'       => 'Gestion des pièces justificatives (édition)',
+20 −1
Changes for module/Application/config/pieces.config.php: 20 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -80,6 +80,20 @@ return [
                                    ],
                                ],
                            ],
                            'refuser'   => [
                                // refuser la PJ
                                'type'    => 'Segment',
                                'options' => [
                                    'route'       => '/refuser/:pieceJointe',
                                    'constraints' => [
                                        'pieceJointe' => '[0-9]*',
                                        'fichier'     => '[0-9]*',
                                    ],
                                    'defaults'    => [
                                        'action' => 'refuser',
                                    ],
                                ],
                            ],
                            'archiver'  => [
                                // archiver la PJ
                                'type'    => 'Segment',
@@ -310,6 +324,11 @@ return [
                    'action'     => ['supprimer'],
                    'privileges' => [Privileges::DOSSIER_SUPPRESSION],
                ],
                [
                    'controller' => 'Application\Controller\Dossier',
                    'action'     => ['supprimer'],
                    'privileges' => [Privileges::DOSSIER_SUPPRESSION],
                ],

                [
                    'controller' => 'Application\Controller\IntervenantDossier',
@@ -359,7 +378,7 @@ return [
                ],
                [
                    'controller' => 'Application\Controller\PieceJointe',
                    'action'     => ['infos', 'lister', 'validation'],
                    'action'     => ['infos', 'lister', 'validation', 'refuser'],
                    'privileges' => Privileges::PIECE_JUSTIFICATIVE_VISUALISATION,
                ],
                [
+49 −1
Changes for module/Application/src/Controller/PieceJointeController.php: 49 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ use Application\Form\PieceJointe\Traits\ModifierTypePieceJointeStatutFormAwareTr
use Application\Service\Traits\IntervenantServiceAwareTrait;
use Application\Service\Traits\PieceJointeServiceAwareTrait;
use Intervenant\Entity\Db\Statut;
use Intervenant\Form\MailerIntervenantFormAwareTrait;
use Intervenant\Entity\Db\TypeIntervenant;
use Intervenant\Service\StatutServiceAwareTrait;
use Application\Service\Traits\TypePieceJointeServiceAwareTrait;
@@ -24,6 +25,8 @@ use UnicaenApp\View\Model\MessengerViewModel;
use Laminas\View\Model\ViewModel;
use Laminas\View\Model\JsonModel;
use Application\Service\Traits\ContextServiceAwareTrait;
use Intervenant\Service\MailServiceAwareTrait;
use Intervenant\Service\NoteServiceAwareTrait;


/**
@@ -41,7 +44,9 @@ class PieceJointeController extends AbstractController
    use TypePieceJointeServiceAwareTrait;
    use TypePieceJointeStatutServiceAwareTrait;
    use WorkflowServiceAwareTrait;

    use MailServiceAwareTrait;
    use NoteServiceAwareTrait;
    use MailerIntervenantFormAwareTrait;

    /**
     * Initialisation des filtres Doctrine pour les historique.
@@ -523,4 +528,47 @@ class PieceJointeController extends AbstractController
        }
    }



    public function refuserAction()
    {
        /** @var PieceJointe $pj */

        $intervenant = $this->getServiceContext()->getSelectedIdentityRole()->getIntervenant();
        if ($intervenant && $pj->getIntervenant() != $intervenant) {
            // un intervenant tente de supprimer la PJ d'un autre intervenant
            throw new \Exception('Vous ne pouvez pas supprimer la pièce jointe d\'un autre intervenant');
        }

        $pj = $this->getEvent()->getParam('pieceJointe');

        $title = 'Rédiger un email à l\'intervenant pour le refus de pièce';

        $form = $this->getFormMailerIntervenant()->setIntervenant($pj->getIntervenant())->initForm();

        if ($this->getRequest()->isPost() && $this->getRequest()->getPost()->count() > 0) {
            try {
                $data    = $this->getRequest()->getPost();
                $from    = $data['from'];
                $to      = $data['to'];
                $subject = $data['subject'];
                $content = $data['content'];
                $this->getServiceMail()->envoyerMail($from, $to, $subject, $content);
                //Création d'une trace de l'envoi dans les notes de l'intervenant
                $this->getServiceNote()->createNoteFromEmail($pj->getIntervenant(), $subject, $content);
                $this->flashMessenger()->addSuccessMessage('Email envoyé à l\'intervenant');

                foreach ($pj->getFichier() as $fichier) {
                    $this->getServicePieceJointe()->supprimerFichier($fichier, $pj);
                }

                $this->updateTableauxBord($pj->getIntervenant());
            } catch (\Exception $e) {
                $this->flashMessenger()->addErrorMessage($this->translate($e));
            }
        }

        return compact('pj', 'title', 'form');
    }

}
+1 −0
Changes for module/Application/src/Provider/Privilege/Privileges.php: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -220,6 +220,7 @@ class Privileges extends \UnicaenAuth\Provider\Privilege\Privileges
    const PIECE_JUSTIFICATIVE_EDITION               = 'piece-justificative-edition';
    const PIECE_JUSTIFICATIVE_GESTION_EDITION       = 'piece-justificative-gestion-edition';
    const PIECE_JUSTIFICATIVE_GESTION_VISUALISATION = 'piece-justificative-gestion-visualisation';
    const PIECE_JUSTIFICATIVE_REFUS_PIECE           = 'piece-justificative-refus-piece';
    const PIECE_JUSTIFICATIVE_TELECHARGEMENT        = 'piece-justificative-telechargement';
    const PIECE_JUSTIFICATIVE_VALIDATION            = 'piece-justificative-validation';
    const PIECE_JUSTIFICATIVE_VISUALISATION         = 'piece-justificative-visualisation';
+71 −0
Changes for module/Application/view/application/piece-jointe/refuser.phtml: 71 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

echo $this->messenger()->addCurrentMessagesFromFlashMessenger();

/**
 * @var $form \Intervenant\Form\MailerIntervenantForm
 */


echo $this->form()->openTag($form);

echo $this->formControlGroup($form->get('from'));
echo $this->formControlGroup($form->get('to'));
echo $this->formControlGroup($form->get('subject'));
echo $this->formControlGroup($form->get('content'));
echo $this->formRow($form->get('submit'));
echo $this->formElement($form->get('security'));

echo $this->form()->closeTag();

?>

<script type="text/javascript">
    $(function () {
        var selector = "textarea#<?= $form->get('content')->getAttribute('id') ?>";
        var form = $("form#<?= $form->getAttribute('id') ?>");


        installEditor(selector, form);

        //  avant de POSTer
        form.submit(function (e) {
            if (!confirm(message)) {
                e.preventDefault();
                e.stopPropagation();
            }
        });
    });

    /**
     * Installation d'un éditeur WYSIWYG (vers HTML) : http://www.tinymce.com
     * NB: l'inclusion du script de TinyMCE est faite dans la vue "mère" (application/indicateur/result.phtml).
     * @param {string} selector
     * @param {object} form
     */
    function installEditor(selector, form)
    {
        WidgetInitializer.includeJs(Url('vendor/tinymce-4.4.1/js/tinymce/tinymce.min.js'));
        tinymce.editors = [];
        tinymce.init({
            selector: selector,
            language: 'fr_FR',
            width: '100%',
            height: 250,
            plugins: "link",
            statusbar: false,
            menubar: false,
            toolbar: "bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link | undo redo"
        });
        // Prevent bootstrap dialog from blocking focusin
        $(document).on('focusin', function (e) {
            if ($(e.target).closest(".mce-window").length) {
                e.stopImmediatePropagation();
            }
        });
        // Indispensable pour que le contenu du textarea soit mis à jour avant de POSTer
        form.submit(function () {
            tinymce.triggerSave();
        });
    }
</script>
 No newline at end of file
Loading