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

Optimisation pieces justificative :

- Ajout de l'utilisation de TBL_PIECE_JOINTE pour fiabiliser les pieces_demandées
- Remise en place des pieces restantes en ne les affichants uniquement sur l'année où elles ont été fourni
parent 1b4c6643
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -30903,7 +30903,7 @@ END UNICAEN_TBL;',
                                            AND f.histo_destruction IS NULL
                JOIN type_piece_jointe_statut tpjs ON tpjs.statut_intervenant_id = i.statut_id
                                                   AND tpjs.type_piece_jointe_id = pj.type_piece_jointe_id
                                                   AND tpjs.HISTO_DESTRUCTION IS NULL
                                                   --AND tpjs.HISTO_DESTRUCTION IS NULL
         LEFT JOIN validation             v ON v.id = pj.validation_id
                                            AND v.histo_destruction IS NULL
@@ -30931,10 +30931,10 @@ END UNICAEN_TBL;',
      ANNEE_ID             = v.ANNEE_ID,
      PIECE_JOINTE_ID      = v.PIECE_JOINTE_ID,
      DATE_ARCHIVE         = v.DATE_ARCHIVE,
      DATE_VALIDITE        = v.DATE_VALIDITE,
      DUREE_VIE            = v.DUREE_VIE,
      CODE_INTERVENANT     = v.CODE_INTERVENANT,
      DATE_VALIDITE        = v.DATE_VALIDITE,
      DATE_ARCHIVE         = v.DATE_ARCHIVE,
      to_delete = 0
    WHEN NOT MATCHED THEN INSERT (
@@ -30946,10 +30946,10 @@ END UNICAEN_TBL;',
      VALIDATION_ID,
      FICHIER_ID,
      PIECE_JOINTE_ID,
      DATE_ARCHIVE,
      DATE_VALIDITE,
      DUREE_VIE,
      CODE_INTERVENANT,
      DATE_VALIDITE,
      DATE_ARCHIVE,
      TO_DELETE
    ) VALUES (
@@ -30961,10 +30961,10 @@ END UNICAEN_TBL;',
      v.VALIDATION_ID,
      v.FICHIER_ID,
      v.PIECE_JOINTE_ID,
      v.DATE_ARCHIVE,
      v.DATE_VALIDITE,
      v.DUREE_VIE,
      v.CODE_INTERVENANT,
      v.DATE_VALIDITE,
      v.DATE_ARCHIVE,
      0
    );
@@ -36567,7 +36567,7 @@ FROM
                                    AND f.histo_destruction IS NULL
        JOIN type_piece_jointe_statut tpjs ON tpjs.statut_intervenant_id = i.statut_id
                                           AND tpjs.type_piece_jointe_id = pj.type_piece_jointe_id
                                           AND tpjs.HISTO_DESTRUCTION IS NULL
                                           --AND tpjs.HISTO_DESTRUCTION IS NULL
 LEFT JOIN validation             v ON v.id = pj.validation_id
                                    AND v.histo_destruction IS NULL
+16 −6
Original line number Diff line number Diff line
@@ -4,9 +4,11 @@ namespace Application\Controller;

use Application\Entity\Db\Intervenant;
use Application\Entity\Db\PieceJointe;
use Application\Entity\Db\TblPieceJointe;
use Application\Entity\Db\TypePieceJointe;
use Application\Entity\Db\TypePieceJointeStatut;
use Application\Form\PieceJointe\Traits\ModifierTypePieceJointeStatutFormAwareTrait;
use Application\Service\Traits\IntervenantServiceAwareTrait;
use Application\Service\Traits\PieceJointeServiceAwareTrait;
use Application\Service\Traits\StatutIntervenantServiceAwareTrait;
use Application\Service\Traits\TypePieceJointeServiceAwareTrait;
@@ -28,6 +30,7 @@ class PieceJointeController extends AbstractController
    use ContextServiceAwareTrait;
    use PieceJointeServiceAwareTrait;
    use StatutIntervenantServiceAwareTrait;
    use IntervenantServiceAwareTrait;
    use TypePieceJointeSaisieFormAwareTrait;
    use ModifierTypePieceJointeStatutFormAwareTrait;
    use TypePieceJointeServiceAwareTrait;
@@ -71,10 +74,10 @@ class PieceJointeController extends AbstractController

        $title = "Pièces justificatives <small>{$intervenant}</small>";

        $demandees       = $this->getServicePieceJointe()->getTypesPiecesDemandees($intervenant);
        $heuresPourSeuil = $this->getServicePieceJointe()->getHeuresPourSeuil($intervenant);
        $fournies  = $this->getServicePieceJointe()->getPiecesFournies($intervenant);
        //$archives        = $this->getServicePieceJointe()->getPiecesFourniesArchives($intervenant);
        $demandees = $this->getServicePieceJointe()->getTypesPiecesDemandees($intervenant);
        $synthese  = $this->getServicePieceJointe()->getPiecesSynthese($intervenant);

        $annee = $this->getServiceContext()->getAnnee();

@@ -82,7 +85,7 @@ class PieceJointeController extends AbstractController

        $alertContrat = $role->getIntervenant() && $intervenant->getStatut()->getPeutAvoirContrat();

        return compact('intervenant', 'title', 'demandees', 'heuresPourSeuil', 'fournies', 'messages', 'alertContrat', 'annee');
        return compact('intervenant', 'title', 'heuresPourSeuil', 'demandees', 'synthese', 'fournies', 'messages', 'alertContrat', 'annee');
    }


@@ -109,8 +112,7 @@ class PieceJointeController extends AbstractController


    /**
     * @param TypePieceJointe[] $demandees
     * @param PieceJointe[]     $fournies
     * @param TblPieceJointe[]     $synthesePiecesJointes
     */
    protected function makeMessages($demandees, $fournies)
    {
@@ -449,6 +451,14 @@ class PieceJointeController extends AbstractController
            'agrement',
            'contrat',
        ], $intervenant);

        //Récupérer tous les intervenants avec le même code intervenant
        $intervenants = $this->getServiceIntervenant()->getIntervenantByCode($intervenant->getCode());
        //On recalcule le tbl piece_jointe pour tous les intervenants ayant le même code intervenant que l'intervenant de l'année en cours
        $this->getServiceWorkflow()->calculerTableauxBord([
            'piece_jointe',
        ], $intervenants);

    }

}
+10 −0
Original line number Diff line number Diff line
@@ -167,6 +167,16 @@ class IntervenantService extends AbstractEntityService
        return $this->getBy('utilisateurCode', 'UTILISATEUR_CODE', $utilisateurCode, $annee, $autoImport);
    }

    public function getIntervenantByCode($intervenantCode, Annee $annee = null)
    {
        $findParams = ['code' => (string)$intervenantCode];
        $repo       = $this->getRepo();

        $result = $repo->findBy($findParams);

        return $result;
    }



    /**
+29 −0
Original line number Diff line number Diff line
@@ -126,6 +126,34 @@ class PieceJointeService extends AbstractEntityService
    }


    /**
     * @param Intervenant $intervenant
     *
     * @return mixed $result
     */
    public function getPiecesSynthese(Intervenant $intervenant)
    {
        $dql = "
            SELECT 
              pj
            FROM 
              Application\Entity\Db\TblPieceJointe pj
            WHERE
              pj.intervenant = :intervenant
        ";

        $listTblPieceJointe = $this->getEntityManager()->createQuery($dql)->setParameters([
            'intervenant' => $intervenant->getId(),
        ])->getResult();

        $result = [];
        foreach ($listTblPieceJointe as $TblPieceJointe) {
            $result[$TblPieceJointe->getTypePieceJointe()->getId()] = $TblPieceJointe;
        }

        return $result;
    }


    /**
     * @param Intervenant $intervenant
@@ -158,6 +186,7 @@ class PieceJointeService extends AbstractEntityService
            'annee'       => $intervenant->getAnnee()->getId(),
        ])->getResult();


        /* @var $lpjf \Application\Entity\Db\TblPieceJointeFournie[] */

        $result = [];
+18 −6
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ $menuUrl = $this->url('intervenant/services', ['intervenant' => $intervenant->ge
                //Check si piece obligatoire
                $obligatoire = $pj->isObligatoire();
                $tpj = $pj->getTypePieceJointe();
                if (isset($fournies[$tpj->getId()])) { // qu'elles soient fournies ou non
                if (isset($fournies[$tpj->getId()]) && $synthese[$tpj->getId()]->getFournie() == 1) { // qu'elles soient fournies ou non
                    $pj = $fournies[$tpj->getId()];
                    unset($restantes[$tpj->getId()]);
                } else {
@@ -64,15 +64,27 @@ $menuUrl = $this->url('intervenant/services', ['intervenant' => $intervenant->ge
            }
        }


        if (!empty($restantes)) {
            echo '<div class="well">';
            echo '<h2>Autres pièces fournies</h2>';
            $html =  '<div class="well">';
            $html .= '<h2>Autres pièces fournies</h2>';
            $obligatoire = false;
            $haveRestante = false;
            foreach ($restantes as $tpjId => $pj) { // on liste les pièces fournies mais qui ne sont pas demandées...
                //on affiche la pièce jointe restante uniquement sur l'année où elle a été fourni

                if($pj->getIntervenant()->getAnnee()->getId() == $annee->getId())
                {
                    $haveRestante = true;
                    $tpj = $pj->getType();
                echo $this->partial('application/piece-jointe/partial/piece-jointe', compact('intervenant', 'tpj', 'pj', 'canEdit', 'canValider', 'canDevalider', 'obligatoire', 'annee'));
                    $html .= $this->partial('application/piece-jointe/partial/piece-jointe', compact('intervenant', 'tpj', 'pj', 'canEdit', 'canValider', 'canDevalider', 'obligatoire', 'annee'));
                }
            }
            $html .= '</div>';
            if($haveRestante)
            {
                echo $html;
            }
            echo '</div>';
        }

        ?>
Loading