Commit 5121f0fa authored by joriot221's avatar joriot221
Browse files

change refuse piece : en cours

parent 06298b15
Loading
Loading
Loading
Loading
+1
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,
                ],
                [
+41
Changes for module/Application/src/Controller/PieceJointeController.php: 41 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -516,4 +516,45 @@ class PieceJointeController extends AbstractController
        }
    }



    public function refuserAction()
    {
        //        $this->initFilters();
        //
        //        /** @var PieceJointe $pj */
        //        $pj = $this->getEvent()->getParam('pieceJointe');
        //        $this->getServicePieceJointe()->valider($pj);
        //        $this->updateTableauxBord($pj->getIntervenant(), true);
        //
        //        $viewModel = new ViewModel();
        //        $viewModel->setTemplate('application/piece-jointe/validation');
        //        $viewModel->setVariable('pj', $pj);
        //
        //        return $viewModel;
        //
        //
        //        return $viewModel;
        /** @var PieceJointe $pj */
        $pj = $this->getEvent()->getParam('pieceJointe');

        $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');
        }

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

        $this->updateTableauxBord($pj->getIntervenant());

        $viewModel = new ViewModel();
        $viewModel->setTemplate('application/piece-jointe/validation');
        $viewModel->setVariable('pj', $pj);

        return $viewModel;
    }

}
+5
Changes for public/js/piece-jointe.js: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -12,6 +12,11 @@ $.widget("ose.pieceJointe", {
            event.preventDefault();
        });

        that.element.on('click', '.refuser-pj', function (event) {
            that.refuser($(this));
            event.preventDefault();
        });

        that.element.on('click', '.archiver-pj', function (event) {
            that.archiver($(this));
            event.preventDefault();