Skip to content
Snippets Groups Projects
Commit b5bfc03d authored by lecluse's avatar lecluse
Browse files

Refonte de la gestion des pièces justificatives.

parent 73eb24ce
No related branches found
No related tags found
No related merge requests found
...@@ -290,19 +290,19 @@ return [ ...@@ -290,19 +290,19 @@ return [
[ [
'controller' => 'Application\Controller\Dossier', 'controller' => 'Application\Controller\Dossier',
'action' => ['voir'], 'action' => ['voir'],
'privileges' => [Privileges::DOSSIER_VISUALISATION], 'privileges' => Privileges::DOSSIER_VISUALISATION,
'assertion' => 'assertionDossierPieces', 'assertion' => 'assertionDossierPieces',
], ],
[ [
'controller' => 'Application\Controller\Dossier', 'controller' => 'Application\Controller\Dossier',
'action' => ['modifier'], 'action' => ['modifier'],
'privileges' => [Privileges::DOSSIER_EDITION], 'privileges' => Privileges::DOSSIER_EDITION,
'assertion' => 'assertionDossierPieces', 'assertion' => 'assertionDossierPieces',
], ],
[ [
'controller' => 'Application\Controller\Validation', 'controller' => 'Application\Controller\Validation',
'action' => ['dossier'], 'action' => ['dossier'],
'privileges' => [Privileges::DOSSIER_VALIDATION], 'privileges' => Privileges::DOSSIER_VALIDATION,
'assertion' => 'assertionDossierPieces', 'assertion' => 'assertionDossierPieces',
], ],
...@@ -310,55 +310,52 @@ return [ ...@@ -310,55 +310,52 @@ return [
[ [
'controller' => 'Application\Controller\PieceJointe', 'controller' => 'Application\Controller\PieceJointe',
'action' => ['type-piece-jointe-statut'], 'action' => ['type-piece-jointe-statut'],
'privileges' => [ 'privileges' => Privileges::PIECE_JUSTIFICATIVE_GESTION_VISUALISATION
Privileges::PIECE_JUSTIFICATIVE_GESTION_VISUALISATION,
Privileges::PIECE_JUSTIFICATIVE_GESTION_EDITION,
],
], ],
[ [
'controller' => 'Application\Controller\PieceJointe', 'controller' => 'Application\Controller\PieceJointe',
'action' => ['modifier-type-piece-jointe-statut'], 'action' => ['modifier-type-piece-jointe-statut'],
'privileges' => [ 'privileges' => Privileges::PIECE_JUSTIFICATIVE_GESTION_EDITION,
Privileges::PIECE_JUSTIFICATIVE_GESTION_EDITION,
],
], ],
[ [
'controller' => 'Application\Controller\PieceJointe', 'controller' => 'Application\Controller\PieceJointe',
'action' => ['configuration'], 'action' => ['configuration'],
'privileges' => [ 'privileges' => Privileges::PIECE_JUSTIFICATIVE_GESTION_VISUALISATION,
Privileges::PIECE_JUSTIFICATIVE_GESTION_VISUALISATION,
Privileges::PIECE_JUSTIFICATIVE_GESTION_EDITION,
],
], ],
/* Pièces jointes */ /* Pièces jointes */
[ [
'controller' => 'Application\Controller\PieceJointe', 'controller' => 'Application\Controller\PieceJointe',
'action' => ['index'], 'action' => ['index'],
'privileges' => [Privileges::PIECE_JUSTIFICATIVE_VISUALISATION], 'privileges' => Privileges::PIECE_JUSTIFICATIVE_VISUALISATION,
'assertion' => 'assertionDossierPieces', 'assertion' => 'assertionDossierPieces',
], ],
[ [
'controller' => 'Application\Controller\PieceJointe', 'controller' => 'Application\Controller\PieceJointe',
'action' => ['infos', 'lister', 'telecharger', 'validation'], 'action' => ['infos', 'lister', 'validation'],
'privileges' => [Privileges::PIECE_JUSTIFICATIVE_VISUALISATION], 'privileges' => Privileges::PIECE_JUSTIFICATIVE_VISUALISATION,
],
[
'controller' => 'Application\Controller\PieceJointe',
'action' => ['telecharger'],
'privileges' => Privileges::PIECE_JUSTIFICATIVE_TELECHARGEMENT,
], ],
[ [
'controller' => 'Application\Controller\PieceJointe', 'controller' => 'Application\Controller\PieceJointe',
'action' => ['televerser', 'supprimer'], 'action' => ['televerser', 'supprimer'],
'privileges' => [Privileges::PIECE_JUSTIFICATIVE_EDITION], 'privileges' => Privileges::PIECE_JUSTIFICATIVE_EDITION,
'assertion' => 'assertionDossierPieces', 'assertion' => 'assertionDossierPieces',
], ],
[ [
'controller' => 'Application\Controller\PieceJointe', 'controller' => 'Application\Controller\PieceJointe',
'action' => ['valider'], 'action' => ['valider'],
'privileges' => [Privileges::PIECE_JUSTIFICATIVE_VALIDATION], 'privileges' => Privileges::PIECE_JUSTIFICATIVE_VALIDATION,
'assertion' => 'assertionDossierPieces', 'assertion' => 'assertionDossierPieces',
], ],
[ [
'controller' => 'Application\Controller\PieceJointe', 'controller' => 'Application\Controller\PieceJointe',
'action' => ['devalider'], 'action' => ['devalider'],
'privileges' => [Privileges::PIECE_JUSTIFICATIVE_DEVALIDATION], 'privileges' => Privileges::PIECE_JUSTIFICATIVE_DEVALIDATION,
'assertion' => 'assertionDossierPieces', 'assertion' => 'assertionDossierPieces',
], ],
], ],
......
...@@ -37,10 +37,12 @@ class DossierPiecesAssertion extends AbstractAssertion ...@@ -37,10 +37,12 @@ class DossierPiecesAssertion extends AbstractAssertion
switch ($action) { switch ($action) {
case 'voir': case 'voir':
if (!$this->assertPriv(Privileges::DOSSIER_VISUALISATION)) return false; if (!$this->assertPriv(Privileges::DOSSIER_VISUALISATION)) return false;
return $this->assertDossierEdition($intervenant); return $this->assertDossierEdition($intervenant);
break; break;
case 'modifier': case 'modifier':
if (!$this->assertPriv(Privileges::DOSSIER_EDITION)) return false; if (!$this->assertPriv(Privileges::DOSSIER_EDITION)) return false;
return $this->assertDossierEdition($intervenant); return $this->assertDossierEdition($intervenant);
break; break;
} }
...@@ -49,7 +51,24 @@ class DossierPiecesAssertion extends AbstractAssertion ...@@ -49,7 +51,24 @@ class DossierPiecesAssertion extends AbstractAssertion
switch ($action) { switch ($action) {
case 'index': case 'index':
if (!$this->assertPriv(Privileges::PIECE_JUSTIFICATIVE_VISUALISATION)) return false; if (!$this->assertPriv(Privileges::PIECE_JUSTIFICATIVE_VISUALISATION)) return false;
return $this->assertPieceJointeVisualisation($intervenant);
return $this->assertPieceJointeAction($intervenant);
break;
case 'televerser':
case 'supprimer':
if (!$this->assertPriv(Privileges::PIECE_JUSTIFICATIVE_EDITION)) return false;
return $this->assertPieceJointeAction($intervenant);
break;
case 'valider':
if (!$this->assertPriv(Privileges::PIECE_JUSTIFICATIVE_VALIDATION)) return false;
return $this->assertPieceJointeValidationAction($intervenant);
break;
case 'devalider':
if (!$this->assertPriv(Privileges::PIECE_JUSTIFICATIVE_DEVALIDATION)) return false;
return $this->assertPieceJointeValidationAction($intervenant);
break; break;
} }
break; break;
...@@ -57,6 +76,7 @@ class DossierPiecesAssertion extends AbstractAssertion ...@@ -57,6 +76,7 @@ class DossierPiecesAssertion extends AbstractAssertion
switch ($action) { switch ($action) {
case 'dossier': case 'dossier':
if (!$this->assertPriv(Privileges::DOSSIER_VALIDATION)) return false; if (!$this->assertPriv(Privileges::DOSSIER_VALIDATION)) return false;
return $this->assertDossierValidation($intervenant); return $this->assertDossierValidation($intervenant);
break; break;
} }
...@@ -103,11 +123,23 @@ class DossierPiecesAssertion extends AbstractAssertion ...@@ -103,11 +123,23 @@ class DossierPiecesAssertion extends AbstractAssertion
protected function assertPieceJointeVisualisation(Intervenant $intervenant = null) protected function assertPieceJointeAction(Intervenant $intervenant = null)
{ {
if (!$this->assertEtapeAtteignable(WfEtape::CODE_PJ_SAISIE, $intervenant)) { if (!$this->assertEtapeAtteignable(WfEtape::CODE_PJ_SAISIE, $intervenant)) {
return false; return false;
} }
return true;
}
protected function assertPieceJointeValidationAction(Intervenant $intervenant = null)
{
if (!$this->assertEtapeAtteignable(WfEtape::CODE_PJ_VALIDATION, $intervenant)) {
return false;
}
return true; return true;
} }
......
...@@ -35,11 +35,13 @@ class Privileges extends \UnicaenAuth\Provider\Privilege\Privileges ...@@ -35,11 +35,13 @@ class Privileges extends \UnicaenAuth\Provider\Privilege\Privileges
const DOSSIER_EDITION = 'dossier-edition'; const DOSSIER_EDITION = 'dossier-edition';
const DOSSIER_VALIDATION = 'dossier-validation'; const DOSSIER_VALIDATION = 'dossier-validation';
const DOSSIER_DEVALIDATION = 'dossier-devalidation'; const DOSSIER_DEVALIDATION = 'dossier-devalidation';
const DOSSIER_VALIDATION_VISUALISATION = 'dossier-validation-visualisation';
const PIECE_JUSTIFICATIVE_VISUALISATION = 'piece-justificative-visualisation'; const PIECE_JUSTIFICATIVE_VISUALISATION = 'piece-justificative-visualisation';
const PIECE_JUSTIFICATIVE_EDITION = 'piece-justificative-edition'; const PIECE_JUSTIFICATIVE_EDITION = 'piece-justificative-edition';
const PIECE_JUSTIFICATIVE_VALIDATION = 'piece-justificative-validation'; const PIECE_JUSTIFICATIVE_VALIDATION = 'piece-justificative-validation';
const PIECE_JUSTIFICATIVE_DEVALIDATION = 'piece-justificative-devalidation'; const PIECE_JUSTIFICATIVE_DEVALIDATION = 'piece-justificative-devalidation';
const PIECE_JUSTIFICATIVE_GESTION_EDITION = 'piece-justificative-gestion-edition'; const PIECE_JUSTIFICATIVE_GESTION_EDITION = 'piece-justificative-gestion-edition';
const PIECE_JUSTIFICATIVE_TELECHARGEMENT = 'piece-justificative-telechargement';
const PIECE_JUSTIFICATIVE_GESTION_VISUALISATION = 'piece-justificative-gestion-visualisation'; const PIECE_JUSTIFICATIVE_GESTION_VISUALISATION = 'piece-justificative-gestion-visualisation';
const ENSEIGNEMENT_VISUALISATION = 'enseignement-visualisation'; const ENSEIGNEMENT_VISUALISATION = 'enseignement-visualisation';
const ENSEIGNEMENT_EDITION = 'enseignement-edition'; const ENSEIGNEMENT_EDITION = 'enseignement-edition';
......
...@@ -14,7 +14,9 @@ use Application\Provider\Privilege\Privileges; ...@@ -14,7 +14,9 @@ use Application\Provider\Privilege\Privileges;
$this->headTitle()->append($intervenant->getNomComplet())->append("Pièces justificatives"); $this->headTitle()->append($intervenant->getNomComplet())->append("Pièces justificatives");
$canEdit = $this->isAllowed($intervenant, Privileges::PIECE_JUSTIFICATIVE_EDITION); $canEdit = $this->isAllowed(Privileges::getResourceId(Privileges::PIECE_JUSTIFICATIVE_EDITION));
$canValider = $this->isAllowed(Privileges::getResourceId(Privileges::PIECE_JUSTIFICATIVE_VALIDATION));
$canDevalider = $this->isAllowed(Privileges::getResourceId(Privileges::PIECE_JUSTIFICATIVE_DEVALIDATION));
$infosUrl = $this->url('piece-jointe/intervenant/infos', ['intervenant' => $intervenant->getSourceCode()]); $infosUrl = $this->url('piece-jointe/intervenant/infos', ['intervenant' => $intervenant->getSourceCode()]);
...@@ -59,7 +61,7 @@ $infosUrl = $this->url('piece-jointe/intervenant/infos', ['intervenant' => $inte ...@@ -59,7 +61,7 @@ $infosUrl = $this->url('piece-jointe/intervenant/infos', ['intervenant' => $inte
} else { } else {
$pj = null; $pj = null;
} }
echo $this->partial('application/piece-jointe/partial/piece-jointe', compact('intervenant', 'tpj', 'pj', 'canEdit', 'obligatoire')); echo $this->partial('application/piece-jointe/partial/piece-jointe', compact('intervenant', 'tpj', 'pj', 'canEdit', 'canValider', 'canDevalider', 'obligatoire'));
} }
if ($alertContrat) { if ($alertContrat) {
...@@ -81,7 +83,7 @@ $infosUrl = $this->url('piece-jointe/intervenant/infos', ['intervenant' => $inte ...@@ -81,7 +83,7 @@ $infosUrl = $this->url('piece-jointe/intervenant/infos', ['intervenant' => $inte
$obligatoire = false; $obligatoire = false;
foreach ($restantes as $tpjId => $pj) { // on liste les pièces fournies mais qui ne sont pas demandées... foreach ($restantes as $tpjId => $pj) { // on liste les pièces fournies mais qui ne sont pas demandées...
$tpj = $pj->getType(); $tpj = $pj->getType();
echo $this->partial('application/piece-jointe/partial/piece-jointe', compact('intervenant', 'tpj', 'pj', 'canEdit', 'obligatoire')); echo $this->partial('application/piece-jointe/partial/piece-jointe', compact('intervenant', 'tpj', 'pj', 'canEdit', 'canValider', 'canDevalider', 'obligatoire'));
} }
} }
......
...@@ -9,9 +9,10 @@ use Application\Provider\Privilege\Privileges; ...@@ -9,9 +9,10 @@ use Application\Provider\Privilege\Privileges;
$fichiers = $pj ? $pj->getFichier() : []; /* @var $fichiers \Application\Entity\Db\Fichier[] */ $fichiers = $pj ? $pj->getFichier() : []; /* @var $fichiers \Application\Entity\Db\Fichier[] */
?> $canEdit = $this->isAllowed(Privileges::getResourceId(Privileges::PIECE_JUSTIFICATIVE_EDITION));
$canDownload = $this->isAllowed(Privileges::getResourceId(Privileges::PIECE_JUSTIFICATIVE_TELECHARGEMENT));
<?php if (!empty($fichiers)): ?> if (!empty($fichiers)): ?>
<ul> <ul>
<?php foreach ($fichiers as $fichier): ?> <?php foreach ($fichiers as $fichier): ?>
...@@ -19,13 +20,14 @@ $fichiers = $pj ? $pj->getFichier() : []; /* @var $fichiers \Application\Entity\ ...@@ -19,13 +20,14 @@ $fichiers = $pj ? $pj->getFichier() : []; /* @var $fichiers \Application\Entity\
<!-- lien de téléchargement du fichier --> <!-- lien de téléchargement du fichier -->
<?php <?php
$canEdit = $this->isAllowed($pj, Privileges::PIECE_JUSTIFICATIVE_EDITION);
if ($canEdit) {
$paramsTelecharger = ['fichier' => $fichier->getId(), 'nomFichier' => $fichier->getNom()]; $paramsTelecharger = ['fichier' => $fichier->getId(), 'nomFichier' => $fichier->getNom()];
if ($canDownload){
$urlTelecharger = $this->url('piece-jointe/intervenant/fichier/telecharger', $paramsTelecharger, [], true); $urlTelecharger = $this->url('piece-jointe/intervenant/fichier/telecharger', $paramsTelecharger, [], true);
echo $this->uploader()->renderUploadedFile($fichier, $urlTelecharger); }else{
$urlTelecharger = null;
} }
echo $this->uploader()->renderUploadedFile($fichier, $urlTelecharger);
if ($canEdit && !$pj->getValidation()) { if ($canEdit && !$pj->getValidation()) {
$paramsSupprimer = ['pieceJointe' => $pj->getId(), 'fichier' => $fichier->getId()]; $paramsSupprimer = ['pieceJointe' => $pj->getId(), 'fichier' => $fichier->getId()];
......
...@@ -6,9 +6,13 @@ ...@@ -6,9 +6,13 @@
* @var $pj \Application\Entity\Db\PieceJointe * @var $pj \Application\Entity\Db\PieceJointe
* @var $intervenant \Application\Entity\Db\Intervenant * @var $intervenant \Application\Entity\Db\Intervenant
* @var $canEdit boolean * @var $canEdit boolean
* @var $canValider boolean
* @var $canDevalider boolean
* @var $obligatoire boolean * @var $obligatoire boolean
*/ */
$hasValidation = $pj && $pj->getValidation();
$linksModelesDocs = null; $linksModelesDocs = null;
if (($url = $tpj->getUrlModeleDoc())) { if (($url = $tpj->getUrlModeleDoc())) {
$href = $this->basePath($url); $href = $this->basePath($url);
...@@ -36,10 +40,12 @@ $uploader = $this->uploader()->setUrl($this->url('piece-jointe/intervenant/fichi ...@@ -36,10 +40,12 @@ $uploader = $this->uploader()->setUrl($this->url('piece-jointe/intervenant/fichi
> >
<div class="panel-heading"> <div class="panel-heading">
<h3> <h3>
<?php if ((!$hasValidation && $canValider) || ($hasValidation && $canDevalider)): ?>
<div class="validation-bar pull-right" <div class="validation-bar pull-right"
data-url="<?php echo $this->url('piece-jointe/intervenant/validation', ['typePieceJointe' => $tpj->getId()], [], true) ?>"> data-url="<?php echo $this->url('piece-jointe/intervenant/validation', ['typePieceJointe' => $tpj->getId()], [], true) ?>">
<?php echo $this->partial('application/piece-jointe/validation', compact('pj')) ?> <?php echo $this->partial('application/piece-jointe/validation', compact('pj')) ?>
</div> </div>
<?php endif; ?>
<?php echo $type ?><br/> <?php echo $type ?><br/>
</h3> </h3>
</div> </div>
......
<?php
use Application\Assertion\FichierAssertion;
?>
<!-- actions de validation du fichier -->
<?php if ($this->isAllowed($this->fichier, FichierAssertion::PRIVILEGE_VALIDER)): ?>
<?php
$paramsValider = ['pieceJointe' => $pj->getId(), 'fichier' => $this->fichier->getId()];
$urlValider = $this->url('piece-jointe/intervenant/valider', $paramsValider, [], true);
?>
<a class="valider-pj btn btn-xs btn-default" href="<?php echo $urlValider ?>" title="Valider le fichier '<?php echo $this->fichier->getNom() ?>'" data-loading-text="Patientez...">
<span class="glyphicon glyphicon-thumbs-up"></span> Valider</a>
<?php endif ?>
<!-- affichage de la validation éventuelle du fichier -->
<?php if ($this->fichier && $this->fichier->getValidation()): ?>
<?php $title = (string) $this->fichier->getValidation() ?>
<span class="label label-success" title="<?php echo $title ?>"><span class="glyphicon glyphicon-thumbs-up"></span> Validé</span>
<?php endif ?>
<!-- actions de dévalidation du fichier -->
<?php if ($this->isAllowed($this->fichier, FichierAssertion::PRIVILEGE_DEVALIDER)): ?>
<?php
$paramsDevalider = ['pieceJointe' => $pj->getId(), 'fichier' => $this->fichier->getId()];
$urlDevalider = $this->url('piece-jointe/intervenant/devalider', $paramsDevalider, [], true);
?>
<a class="devalider-pj btn btn-xs btn-default" href="<?php echo $urlDevalider ?>" title="Dévalider le fichier '<?php echo $this->fichier->getNom() ?>'" data-loading-text="Patientez...">
<span class="glyphicon glyphicon-thumbs-down"></span> Dévalider</a>
<?php endif ?>
\ No newline at end of file
...@@ -16,7 +16,7 @@ $params = [ ...@@ -16,7 +16,7 @@ $params = [
?> ?>
<!-- actions de validation de la pièce jointe entière --> <!-- actions de validation de la pièce jointe entière -->
<?php if (!$pj->getValidation() && $this->isAllowed($pj, Privileges::PIECE_JUSTIFICATIVE_VALIDATION)): ?> <?php if (!$pj->getValidation() && $this->isAllowed(Privileges::getResourceId(Privileges::PIECE_JUSTIFICATIVE_VALIDATION))): ?>
<a class="valider-pj btn btn-success" <a class="valider-pj btn btn-success"
href="<?php echo $this->url('piece-jointe/intervenant/valider', $params, [], true) ?>" href="<?php echo $this->url('piece-jointe/intervenant/valider', $params, [], true) ?>"
title="Valider la pièce justificative '<?php echo $pj->getType() ?>'" title="Valider la pièce justificative '<?php echo $pj->getType() ?>'"
...@@ -27,7 +27,7 @@ $params = [ ...@@ -27,7 +27,7 @@ $params = [
<?php endif ?> <?php endif ?>
<!-- actions de dévalidation de la pièce jointe entière --> <!-- actions de dévalidation de la pièce jointe entière -->
<?php if ($pj->getValidation() && $this->isAllowed($pj, Privileges::PIECE_JUSTIFICATIVE_DEVALIDATION)): ?> <?php if ($pj->getValidation() && $this->isAllowed(Privileges::getResourceId(Privileges::PIECE_JUSTIFICATIVE_DEVALIDATION))): ?>
<a class="devalider-pj btn btn-danger" <a class="devalider-pj btn btn-danger"
href="<?php echo $this->url('piece-jointe/intervenant/devalider', $params, [], true) ?>" href="<?php echo $this->url('piece-jointe/intervenant/devalider', $params, [], true) ?>"
title="Dévalider la pièce justificative <?php echo "'".$pj->getType() . "'.\n" . $pj->getValidation() ?>" title="Dévalider la pièce justificative <?php echo "'".$pj->getType() . "'.\n" . $pj->getValidation() ?>"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment