Loading module/Application/src/Application/Controller/PieceJointeController.php +31 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace Application\Controller; use Application\Entity\Db\Fichier; use Application\Entity\Db\Intervenant; use Application\Entity\Db\PieceJointe; use Application\Entity\Db\TblPieceJointe; Loading Loading @@ -191,6 +192,13 @@ class PieceJointeController extends AbstractController $this->initFilters(); /** @var PieceJointe $pj */ $pj = $this->getEvent()->getParam('pieceJointe'); $intervenant = $this->getServiceContext()->getSelectedIdentityRole()->getIntervenant(); if ($intervenant && $pj->getIntervenant() != $intervenant) { // un intervenant tente d'archiver la PJ d'un autre intervenant throw new \Exception('Vous ne pouvez pas archiver la pièce justificative d\'un autre intervenant'); } $pj = $this->getServicePieceJointe()->archiver($pj); $this->updateTableauxBord($pj->getIntervenant(), true); $viewModel = new ViewModel(); Loading Loading @@ -227,6 +235,11 @@ class PieceJointeController extends AbstractController if (empty($pj)) { $typePieceJointe = $this->getEvent()->getParam('typePieceJointe'); $pj = $this->getServicePieceJointe()->getByType($intervenant, $typePieceJointe); } else { if ($pj->getIntervenant() != $intervenant) { // un intervenant tente d'archiver la PJ d'un autre intervenant throw new \Exception('Vous ne pouvez pas visualiser la liste des pièces jointes d\'un autre intervenant'); } } return compact('pj'); Loading Loading @@ -257,8 +270,20 @@ class PieceJointeController extends AbstractController public function telechargerAction() { /** @var Fichier $fichier */ $fichier = $this->getEvent()->getParam('fichier'); /** @var PieceJointe $pieceJointe */ $pieceJointe = $fichier->getPieceJointe(); /** @var Intervenant $intervenant */ $intervenant = $this->getEvent()->getParam('intervenant'); if (!$pieceJointe || $pieceJointe->getIntervenant() != $intervenant) { // un intervenant tente de télécharger la PJ d'un autre intervenant throw new \Exception('La pièce jointe n\'existe pas ou bien elle appartient à un autre intervenant'); } $this->uploader()->download($fichier); } Loading @@ -274,6 +299,12 @@ class PieceJointeController extends AbstractController $pj = $this->getEvent()->getParam('pieceJointe'); $fichier = $this->getEvent()->getParam('fichier'); $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'); } if ($fichier) { $this->getServicePieceJointe()->supprimerFichier($fichier, $pj); } Loading module/Application/src/Application/Entity/Db/Fichier.php +7 −7 Original line number Diff line number Diff line Loading @@ -333,14 +333,14 @@ class Fichier implements HistoriqueAwareInterface, ResourceInterface, UploadedFi /** * Get pieceJointe * * @return \Doctrine\Common\Collections\Collection */ public function getPieceJointe() public function getPieceJointe(): ?PieceJointe { return $this->pieceJointe; $pj = $this->pieceJointe; if ($pj->count() == 1) { return $this->pieceJointe->first(); } return null; } Loading module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.Fichier.dcm.xml +1 −1 Original line number Diff line number Diff line Loading @@ -32,6 +32,6 @@ <join-column name="VALIDATION_ID" referenced-column-name="ID"/> </join-columns> </many-to-one> <one-to-many field="pieceJointe" target-entity="Application\Entity\Db\PieceJointe" mapped-by="fichier" /> <many-to-many field="pieceJointe" target-entity="Application\Entity\Db\PieceJointe" mapped-by="fichier" /> </entity> </doctrine-mapping> module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.PieceJointe.dcm.xml +1 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ <join-column name="INTERVENANT_ID" referenced-column-name="ID"/> </join-columns> </many-to-one> <many-to-many field="fichier" target-entity="Application\Entity\Db\Fichier"> <many-to-many field="fichier" inversed-by="pieceJointe" target-entity="Application\Entity\Db\Fichier"> <join-table name="PIECE_JOINTE_FICHIER"> <join-columns> <join-column name="PIECE_JOINTE_ID" referenced-column-name="ID"/> Loading Loading
module/Application/src/Application/Controller/PieceJointeController.php +31 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace Application\Controller; use Application\Entity\Db\Fichier; use Application\Entity\Db\Intervenant; use Application\Entity\Db\PieceJointe; use Application\Entity\Db\TblPieceJointe; Loading Loading @@ -191,6 +192,13 @@ class PieceJointeController extends AbstractController $this->initFilters(); /** @var PieceJointe $pj */ $pj = $this->getEvent()->getParam('pieceJointe'); $intervenant = $this->getServiceContext()->getSelectedIdentityRole()->getIntervenant(); if ($intervenant && $pj->getIntervenant() != $intervenant) { // un intervenant tente d'archiver la PJ d'un autre intervenant throw new \Exception('Vous ne pouvez pas archiver la pièce justificative d\'un autre intervenant'); } $pj = $this->getServicePieceJointe()->archiver($pj); $this->updateTableauxBord($pj->getIntervenant(), true); $viewModel = new ViewModel(); Loading Loading @@ -227,6 +235,11 @@ class PieceJointeController extends AbstractController if (empty($pj)) { $typePieceJointe = $this->getEvent()->getParam('typePieceJointe'); $pj = $this->getServicePieceJointe()->getByType($intervenant, $typePieceJointe); } else { if ($pj->getIntervenant() != $intervenant) { // un intervenant tente d'archiver la PJ d'un autre intervenant throw new \Exception('Vous ne pouvez pas visualiser la liste des pièces jointes d\'un autre intervenant'); } } return compact('pj'); Loading Loading @@ -257,8 +270,20 @@ class PieceJointeController extends AbstractController public function telechargerAction() { /** @var Fichier $fichier */ $fichier = $this->getEvent()->getParam('fichier'); /** @var PieceJointe $pieceJointe */ $pieceJointe = $fichier->getPieceJointe(); /** @var Intervenant $intervenant */ $intervenant = $this->getEvent()->getParam('intervenant'); if (!$pieceJointe || $pieceJointe->getIntervenant() != $intervenant) { // un intervenant tente de télécharger la PJ d'un autre intervenant throw new \Exception('La pièce jointe n\'existe pas ou bien elle appartient à un autre intervenant'); } $this->uploader()->download($fichier); } Loading @@ -274,6 +299,12 @@ class PieceJointeController extends AbstractController $pj = $this->getEvent()->getParam('pieceJointe'); $fichier = $this->getEvent()->getParam('fichier'); $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'); } if ($fichier) { $this->getServicePieceJointe()->supprimerFichier($fichier, $pj); } Loading
module/Application/src/Application/Entity/Db/Fichier.php +7 −7 Original line number Diff line number Diff line Loading @@ -333,14 +333,14 @@ class Fichier implements HistoriqueAwareInterface, ResourceInterface, UploadedFi /** * Get pieceJointe * * @return \Doctrine\Common\Collections\Collection */ public function getPieceJointe() public function getPieceJointe(): ?PieceJointe { return $this->pieceJointe; $pj = $this->pieceJointe; if ($pj->count() == 1) { return $this->pieceJointe->first(); } return null; } Loading
module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.Fichier.dcm.xml +1 −1 Original line number Diff line number Diff line Loading @@ -32,6 +32,6 @@ <join-column name="VALIDATION_ID" referenced-column-name="ID"/> </join-columns> </many-to-one> <one-to-many field="pieceJointe" target-entity="Application\Entity\Db\PieceJointe" mapped-by="fichier" /> <many-to-many field="pieceJointe" target-entity="Application\Entity\Db\PieceJointe" mapped-by="fichier" /> </entity> </doctrine-mapping>
module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.PieceJointe.dcm.xml +1 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ <join-column name="INTERVENANT_ID" referenced-column-name="ID"/> </join-columns> </many-to-one> <many-to-many field="fichier" target-entity="Application\Entity\Db\Fichier"> <many-to-many field="fichier" inversed-by="pieceJointe" target-entity="Application\Entity\Db\Fichier"> <join-table name="PIECE_JOINTE_FICHIER"> <join-columns> <join-column name="PIECE_JOINTE_ID" referenced-column-name="ID"/> Loading