Commit 30825449 authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Merge remote-tracking branch 'origin/master'

parents 96e1cbf0 f439dc72
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -223,4 +223,9 @@ Cordialement,
        "DESCRIPTION" => "Adresse email d'expéditeur des mails via les indicateur, si vide alors l'email de l'utilisateur sera utilisé",
    ],

    /* Contrat */
    "avenant"                       => [
        "VALEUR"      => "active",
        "DESCRIPTION" => "Permettre la création d'avenants au contrat",
    ],
];
 No newline at end of file
+1 −0
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
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,
                ],
                [
+5 −1
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ use Application\Assertion\ContratAssertion;
use Application\Entity\Db\Fichier;
use Application\Entity\Db\Intervenant;
use Application\Entity\Db\ModeleContrat;
use Application\Entity\Db\Parametre;
use Application\Entity\Db\Service;
use Application\Entity\Db\Structure;
use Application\Entity\Db\Validation;
@@ -26,6 +27,7 @@ use Application\Service\Traits\TypeVolumeHoraireServiceAwareTrait;
use Application\Service\Traits\ContextServiceAwareTrait;
use Application\Service\Traits\WorkflowServiceAwareTrait;
use Intervenant\Service\NoteServiceAwareTrait;
use Phan\Debug;
use UnicaenApp\Controller\Plugin\Upload\UploaderPlugin;
use UnicaenApp\Util;
use UnicaenApp\View\Model\MessengerViewModel;
@@ -134,8 +136,10 @@ class ContratController extends AbstractController
            }
            $services['non-contractualises'][$sid][] = $service;
        }
        $avenantResult = $this->getServiceParametres()->get('avenant');
        $avenant       = ($avenantResult == Parametre::AVENANT);

        return compact('title', 'intervenant', 'contrats', 'services', 'emailIntervenant');
        return compact('title', 'intervenant', 'contrats', 'services', 'emailIntervenant', 'avenant');
    }


+49 −1
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');
    }

}
Loading