Loading data/ddl/view/V_TBL_PIECE_JOINTE_DEMANDE.sql +10 −9 Original line number Diff line number Diff line Loading @@ -36,10 +36,9 @@ SELECT i.annee_id annee_id, i.code code_intervenant, i.id intervenant_id, tpj.id type_piece_jointe_id, MAX(COALESCE(i_h.heures, 0)) heures_pour_seuil, MAX(tpjs.obligatoire) obligatoire, MAX(COALESCE(hetd.total_hetd, 0)) heures_pour_seuil_hetd, MIN(tpjs.duree_vie) duree_vie MIN(tpjs.duree_vie) duree_vie, MAX(tpjs.demandee_apres_recrutement) demandee_apres_recrutement FROM intervenant i LEFT JOIN intervenant_dossier d ON d.intervenant_id = i.id AND d.histo_destruction IS NULL JOIN type_piece_jointe_statut tpjs Loading Loading @@ -84,7 +83,9 @@ WHERE i.histo_destruction IS NULL AND (tpjs.fc = 0 OR i_h.fc > 0) -- Filtre FA AND (tpjs.fa = 0 OR i_h.fa > 0) GROUP BY i.annee_id, GROUP BY i.annee_id, i.id, i.code, tpj.id ORDER BY i.annee_id DESC No newline at end of file module/PieceJointe/src/Tbl/Process/PieceJointeProcess.php +40 −33 Original line number Diff line number Diff line Loading @@ -89,9 +89,10 @@ class PieceJointeProcess implements ProcessInterface $piecesJointesFournies = $this->getBdd()->selectEach($sqlPiecesJointesFournies); while ($pieceJointe = $piecesJointesFournies->next()) { $codeIntervenant = $pieceJointe['CODE_INTERVENANT']; $typePieceJointe = $pieceJointe['TYPE_PIECE_JOINTE_ID']; $annee = $pieceJointe['ANNEE_ID']; mpg_lower($pieceJointe); $codeIntervenant = $pieceJointe['code_intervenant']; $typePieceJointe = $pieceJointe['type_piece_jointe_id']; $annee = $pieceJointe['annee_id']; $this->piecesJointesFournies[$codeIntervenant][$typePieceJointe][$annee] = $pieceJointe; ksort($this->piecesJointesFournies[$codeIntervenant][$typePieceJointe]); } Loading Loading @@ -141,16 +142,18 @@ class PieceJointeProcess implements ProcessInterface { //On commence par traiter toutes les pièces jointes demandées foreach ($this->piecesJointesDemandees as $pieceJointeDemandee) { $uuid = $pieceJointeDemandee['ANNEE_ID'] . '_' . $pieceJointeDemandee['INTERVENANT_ID'] . '_' . $pieceJointeDemandee['TYPE_PIECE_JOINTE_ID']; mpg_lower($pieceJointeDemandee); $uuid = $pieceJointeDemandee['annee_id'] . '_' . $pieceJointeDemandee['intervenant_id'] . '_' . $pieceJointeDemandee['TYPE_PIECE_JOINTE_ID']; $pieceJointe = new PieceJointe(); $pieceJointe->uuid = $uuid; $pieceJointe->annee = $pieceJointeDemandee['ANNEE_ID']; $pieceJointe->typePieceJointeId = $pieceJointeDemandee['TYPE_PIECE_JOINTE_ID']; $pieceJointe->intervenantId = $pieceJointeDemandee['INTERVENANT_ID']; $pieceJointe->annee = $pieceJointeDemandee['annee_id']; $pieceJointe->typePieceJointeId = $pieceJointeDemandee['type_piece_jointe_id']; $pieceJointe->intervenantId = $pieceJointeDemandee['intervenant_id']; $pieceJointe->demandee = true; $pieceJointe->fournie = false; $pieceJointe->obligatoire = true; $pieceJointe->demandeApresRecrutement = $pieceJointeDemandee['DEMANDEE_APRES_RECRUTEMENT']; $pieceJointe->demandeApresRecrutement = $pieceJointeDemandee['demande_apres_recrutement']; $this->piecesJointes[$uuid] = $pieceJointe; } Loading @@ -158,21 +161,23 @@ class PieceJointeProcess implements ProcessInterface foreach ($this->piecesJointesFournies as $codeIntervenant => $datas) { foreach ($datas as $typePieceJointeId => $piecesJointesFournies) { foreach ($piecesJointesFournies as $pieceJointeFournie) { $uuid = $pieceJointeFournie['ANNEE_ID'] . '_' . $pieceJointeFournie['INTERVENANT_ID'] . '_' . $pieceJointeFournie['TYPE_PIECE_JOINTE_ID']; mpg_lower($pieceJointeFournie); $uuid = $pieceJointeFournie['annee_id'] . '_' . $pieceJointeFournie['intervenant_id'] . '_' . $pieceJointeFournie['type_piece_jointe_id']; if (array_key_exists($uuid, $this->piecesJointes)) { $this->piecesJointes[$uuid]->pieceJointeId = $pieceJointeFournie['PIECE_JOINTE_ID']; $this->piecesJointes[$uuid]->pieceJointeId = $pieceJointeFournie['piece_jointe_id']; $this->piecesJointes[$uuid]->fournie = 1; $this->piecesJointes[$uuid]->validee = !empty($pieceJointeFournie['VALIDATION_ID']); $this->piecesJointes[$uuid]->dateValiditee = $pieceJointeFournie['DATE_VALIDITEE']; $this->piecesJointes[$uuid]->validee = !empty($pieceJointeFournie['validation_id']); $this->piecesJointes[$uuid]->dateValiditee = $pieceJointeFournie['date_validitee']; } } } } //Ensuite on cherche les pièces jointes fournies sur une potentielle année postérieure (durée de vie) foreach ($this->piecesJointesDemandees as $pieceJointeDemandee) { $codeIntervenant = $pieceJointeDemandee['CODE_INTERVENANT']; $typePieceJointeId = $pieceJointeDemandee['TYPE_PIECE_JOINTE_ID']; $uuid = $pieceJointeDemandee['ANNEE_ID'] . '_' . $pieceJointeDemandee['INTERVENANT_ID'] . "_" . $pieceJointeDemandee['TYPE_PIECE_JOINTE_ID']; mpg_lower($pieceJointeDemandee); $codeIntervenant = $pieceJointeDemandee['code_intervenant']; $typePieceJointeId = $pieceJointeDemandee['type_piece_jointe_id']; $uuid = $pieceJointeDemandee['annee_id'] . '_' . $pieceJointeDemandee['intervenant_id'] . "_" . $pieceJointeDemandee['type_piece_jointe_id']; //Piece jointe demandée déjà fournie donc on passe if ($this->piecesJointes[$uuid]->fournie == 1) { continue; Loading @@ -181,19 +186,20 @@ class PieceJointeProcess implements ProcessInterface //J'ai des pieces fournies antérieurement if (!empty($piecesJointesFournies)) { foreach ($piecesJointesFournies as $pieceJointeFournie) { mpg_lower($pieceJointeFournie); //L'année de la pièce jointe fournie est postérieur à l'année de la pièce jointe demandée if ((int)$pieceJointeDemandee['ANNEE_ID'] >= (int)$pieceJointeFournie['ANNEE_ID']) { if ((int)$pieceJointeDemandee['annee_id'] >= (int)$pieceJointeFournie['annee_id']) { if (//1 -Si la date de validité de la pièce jointe est strictement supérieure à l'année où elle est demandée (int)$pieceJointeFournie['DATE_VALIDITEE'] > (int)$pieceJointeDemandee['ANNEE_ID'] && (int)$pieceJointeFournie['date_validitee'] > (int)$pieceJointeDemandee['annee_id'] && //2 - L'année de la pièce jointe fournie correspond au critère de durée de vie de la pièce jointe demandée (int)$pieceJointeFournie['ANNEE_ID'] > round((int)$pieceJointeDemandee['ANNEE_ID'] - (int)$pieceJointeDemandee['DUREE_VIE']) && (int)$pieceJointeFournie['annee_id'] > round((int)$pieceJointeDemandee['annee_id'] - (int)$pieceJointeDemandee['duree_vie']) && //3 - Si la date d'archive de la pièce fournie est strictement supérieure à l'année où elle est demandée ((int)$pieceJointeFournie['DATE_ARCHIVE'] > (int)$pieceJointeDemandee['ANNEE_ID'] || empty($pieceJointeFournie['DATE_ARCHIVE']))) { $this->piecesJointes[$uuid]->pieceJointeId = $pieceJointeFournie['PIECE_JOINTE_ID']; $this->piecesJointes[$uuid]->dateValiditee = $pieceJointeFournie['DATE_VALIDITEE']; ((int)$pieceJointeFournie['date_archive'] > (int)$pieceJointeDemandee['annee_id'] || empty($pieceJointeFournie['date_archive']))) { $this->piecesJointes[$uuid]->pieceJointeId = $pieceJointeFournie['piece_jointe_id']; $this->piecesJointes[$uuid]->dateValiditee = $pieceJointeFournie['date_validitee']; $this->piecesJointes[$uuid]->fournie = 1; $this->piecesJointes[$uuid]->validee = !empty($pieceJointeFournie['VALIDATION_ID']); $this->piecesJointes[$uuid]->validee = !empty($pieceJointeFournie['validation_id']); } } Loading @@ -211,16 +217,16 @@ class PieceJointeProcess implements ProcessInterface { foreach ($this->piecesJointes as $uuid => $piecesJointe) { $this->tblData[] = [ 'ANNEE_ID' => $piecesJointe->annee, 'TYPE_PIECE_JOINTE_ID' => $piecesJointe->typePieceJointeId, 'PIECE_JOINTE_ID' => $piecesJointe->pieceJointeId, 'INTERVENANT_ID' => $piecesJointe->intervenantId, 'DEMANDEE' => $piecesJointe->demandee, 'FOURNIE' => $piecesJointe->fournie, 'VALIDEE' => $piecesJointe->validee, 'OBLIGATOIRE' => $piecesJointe->obligatoire, 'DATE_VALIDITEE' => $piecesJointe->dateValiditee, 'DEMANDEE_APRES_RECRUTEMENT' => $piecesJointe->demandeApresRecrutement, 'annee_id' => $piecesJointe->annee, 'type_piece_jointe_id' => $piecesJointe->typePieceJointeId, 'piece_jointe_id' => $piecesJointe->pieceJointeId, 'intervenant_id' => $piecesJointe->intervenantId, 'demandee' => $piecesJointe->demandee, 'fournie' => $piecesJointe->fournie, 'validee' => $piecesJointe->validee, 'obligatoire' => $piecesJointe->obligatoire, 'date_validitee' => $piecesJointe->dateValiditee, 'demande_apres_recrutement' => $piecesJointe->demandeApresRecrutement, ]; } Loading @@ -245,6 +251,7 @@ class PieceJointeProcess implements ProcessInterface }, ]; try { mpg_upper($this->tblData); $table->merge($this->tblData, $key, $options); } catch (\Exception $e) { dump($e->getMessage()); Loading Loading
data/ddl/view/V_TBL_PIECE_JOINTE_DEMANDE.sql +10 −9 Original line number Diff line number Diff line Loading @@ -36,10 +36,9 @@ SELECT i.annee_id annee_id, i.code code_intervenant, i.id intervenant_id, tpj.id type_piece_jointe_id, MAX(COALESCE(i_h.heures, 0)) heures_pour_seuil, MAX(tpjs.obligatoire) obligatoire, MAX(COALESCE(hetd.total_hetd, 0)) heures_pour_seuil_hetd, MIN(tpjs.duree_vie) duree_vie MIN(tpjs.duree_vie) duree_vie, MAX(tpjs.demandee_apres_recrutement) demandee_apres_recrutement FROM intervenant i LEFT JOIN intervenant_dossier d ON d.intervenant_id = i.id AND d.histo_destruction IS NULL JOIN type_piece_jointe_statut tpjs Loading Loading @@ -84,7 +83,9 @@ WHERE i.histo_destruction IS NULL AND (tpjs.fc = 0 OR i_h.fc > 0) -- Filtre FA AND (tpjs.fa = 0 OR i_h.fa > 0) GROUP BY i.annee_id, GROUP BY i.annee_id, i.id, i.code, tpj.id ORDER BY i.annee_id DESC No newline at end of file
module/PieceJointe/src/Tbl/Process/PieceJointeProcess.php +40 −33 Original line number Diff line number Diff line Loading @@ -89,9 +89,10 @@ class PieceJointeProcess implements ProcessInterface $piecesJointesFournies = $this->getBdd()->selectEach($sqlPiecesJointesFournies); while ($pieceJointe = $piecesJointesFournies->next()) { $codeIntervenant = $pieceJointe['CODE_INTERVENANT']; $typePieceJointe = $pieceJointe['TYPE_PIECE_JOINTE_ID']; $annee = $pieceJointe['ANNEE_ID']; mpg_lower($pieceJointe); $codeIntervenant = $pieceJointe['code_intervenant']; $typePieceJointe = $pieceJointe['type_piece_jointe_id']; $annee = $pieceJointe['annee_id']; $this->piecesJointesFournies[$codeIntervenant][$typePieceJointe][$annee] = $pieceJointe; ksort($this->piecesJointesFournies[$codeIntervenant][$typePieceJointe]); } Loading Loading @@ -141,16 +142,18 @@ class PieceJointeProcess implements ProcessInterface { //On commence par traiter toutes les pièces jointes demandées foreach ($this->piecesJointesDemandees as $pieceJointeDemandee) { $uuid = $pieceJointeDemandee['ANNEE_ID'] . '_' . $pieceJointeDemandee['INTERVENANT_ID'] . '_' . $pieceJointeDemandee['TYPE_PIECE_JOINTE_ID']; mpg_lower($pieceJointeDemandee); $uuid = $pieceJointeDemandee['annee_id'] . '_' . $pieceJointeDemandee['intervenant_id'] . '_' . $pieceJointeDemandee['TYPE_PIECE_JOINTE_ID']; $pieceJointe = new PieceJointe(); $pieceJointe->uuid = $uuid; $pieceJointe->annee = $pieceJointeDemandee['ANNEE_ID']; $pieceJointe->typePieceJointeId = $pieceJointeDemandee['TYPE_PIECE_JOINTE_ID']; $pieceJointe->intervenantId = $pieceJointeDemandee['INTERVENANT_ID']; $pieceJointe->annee = $pieceJointeDemandee['annee_id']; $pieceJointe->typePieceJointeId = $pieceJointeDemandee['type_piece_jointe_id']; $pieceJointe->intervenantId = $pieceJointeDemandee['intervenant_id']; $pieceJointe->demandee = true; $pieceJointe->fournie = false; $pieceJointe->obligatoire = true; $pieceJointe->demandeApresRecrutement = $pieceJointeDemandee['DEMANDEE_APRES_RECRUTEMENT']; $pieceJointe->demandeApresRecrutement = $pieceJointeDemandee['demande_apres_recrutement']; $this->piecesJointes[$uuid] = $pieceJointe; } Loading @@ -158,21 +161,23 @@ class PieceJointeProcess implements ProcessInterface foreach ($this->piecesJointesFournies as $codeIntervenant => $datas) { foreach ($datas as $typePieceJointeId => $piecesJointesFournies) { foreach ($piecesJointesFournies as $pieceJointeFournie) { $uuid = $pieceJointeFournie['ANNEE_ID'] . '_' . $pieceJointeFournie['INTERVENANT_ID'] . '_' . $pieceJointeFournie['TYPE_PIECE_JOINTE_ID']; mpg_lower($pieceJointeFournie); $uuid = $pieceJointeFournie['annee_id'] . '_' . $pieceJointeFournie['intervenant_id'] . '_' . $pieceJointeFournie['type_piece_jointe_id']; if (array_key_exists($uuid, $this->piecesJointes)) { $this->piecesJointes[$uuid]->pieceJointeId = $pieceJointeFournie['PIECE_JOINTE_ID']; $this->piecesJointes[$uuid]->pieceJointeId = $pieceJointeFournie['piece_jointe_id']; $this->piecesJointes[$uuid]->fournie = 1; $this->piecesJointes[$uuid]->validee = !empty($pieceJointeFournie['VALIDATION_ID']); $this->piecesJointes[$uuid]->dateValiditee = $pieceJointeFournie['DATE_VALIDITEE']; $this->piecesJointes[$uuid]->validee = !empty($pieceJointeFournie['validation_id']); $this->piecesJointes[$uuid]->dateValiditee = $pieceJointeFournie['date_validitee']; } } } } //Ensuite on cherche les pièces jointes fournies sur une potentielle année postérieure (durée de vie) foreach ($this->piecesJointesDemandees as $pieceJointeDemandee) { $codeIntervenant = $pieceJointeDemandee['CODE_INTERVENANT']; $typePieceJointeId = $pieceJointeDemandee['TYPE_PIECE_JOINTE_ID']; $uuid = $pieceJointeDemandee['ANNEE_ID'] . '_' . $pieceJointeDemandee['INTERVENANT_ID'] . "_" . $pieceJointeDemandee['TYPE_PIECE_JOINTE_ID']; mpg_lower($pieceJointeDemandee); $codeIntervenant = $pieceJointeDemandee['code_intervenant']; $typePieceJointeId = $pieceJointeDemandee['type_piece_jointe_id']; $uuid = $pieceJointeDemandee['annee_id'] . '_' . $pieceJointeDemandee['intervenant_id'] . "_" . $pieceJointeDemandee['type_piece_jointe_id']; //Piece jointe demandée déjà fournie donc on passe if ($this->piecesJointes[$uuid]->fournie == 1) { continue; Loading @@ -181,19 +186,20 @@ class PieceJointeProcess implements ProcessInterface //J'ai des pieces fournies antérieurement if (!empty($piecesJointesFournies)) { foreach ($piecesJointesFournies as $pieceJointeFournie) { mpg_lower($pieceJointeFournie); //L'année de la pièce jointe fournie est postérieur à l'année de la pièce jointe demandée if ((int)$pieceJointeDemandee['ANNEE_ID'] >= (int)$pieceJointeFournie['ANNEE_ID']) { if ((int)$pieceJointeDemandee['annee_id'] >= (int)$pieceJointeFournie['annee_id']) { if (//1 -Si la date de validité de la pièce jointe est strictement supérieure à l'année où elle est demandée (int)$pieceJointeFournie['DATE_VALIDITEE'] > (int)$pieceJointeDemandee['ANNEE_ID'] && (int)$pieceJointeFournie['date_validitee'] > (int)$pieceJointeDemandee['annee_id'] && //2 - L'année de la pièce jointe fournie correspond au critère de durée de vie de la pièce jointe demandée (int)$pieceJointeFournie['ANNEE_ID'] > round((int)$pieceJointeDemandee['ANNEE_ID'] - (int)$pieceJointeDemandee['DUREE_VIE']) && (int)$pieceJointeFournie['annee_id'] > round((int)$pieceJointeDemandee['annee_id'] - (int)$pieceJointeDemandee['duree_vie']) && //3 - Si la date d'archive de la pièce fournie est strictement supérieure à l'année où elle est demandée ((int)$pieceJointeFournie['DATE_ARCHIVE'] > (int)$pieceJointeDemandee['ANNEE_ID'] || empty($pieceJointeFournie['DATE_ARCHIVE']))) { $this->piecesJointes[$uuid]->pieceJointeId = $pieceJointeFournie['PIECE_JOINTE_ID']; $this->piecesJointes[$uuid]->dateValiditee = $pieceJointeFournie['DATE_VALIDITEE']; ((int)$pieceJointeFournie['date_archive'] > (int)$pieceJointeDemandee['annee_id'] || empty($pieceJointeFournie['date_archive']))) { $this->piecesJointes[$uuid]->pieceJointeId = $pieceJointeFournie['piece_jointe_id']; $this->piecesJointes[$uuid]->dateValiditee = $pieceJointeFournie['date_validitee']; $this->piecesJointes[$uuid]->fournie = 1; $this->piecesJointes[$uuid]->validee = !empty($pieceJointeFournie['VALIDATION_ID']); $this->piecesJointes[$uuid]->validee = !empty($pieceJointeFournie['validation_id']); } } Loading @@ -211,16 +217,16 @@ class PieceJointeProcess implements ProcessInterface { foreach ($this->piecesJointes as $uuid => $piecesJointe) { $this->tblData[] = [ 'ANNEE_ID' => $piecesJointe->annee, 'TYPE_PIECE_JOINTE_ID' => $piecesJointe->typePieceJointeId, 'PIECE_JOINTE_ID' => $piecesJointe->pieceJointeId, 'INTERVENANT_ID' => $piecesJointe->intervenantId, 'DEMANDEE' => $piecesJointe->demandee, 'FOURNIE' => $piecesJointe->fournie, 'VALIDEE' => $piecesJointe->validee, 'OBLIGATOIRE' => $piecesJointe->obligatoire, 'DATE_VALIDITEE' => $piecesJointe->dateValiditee, 'DEMANDEE_APRES_RECRUTEMENT' => $piecesJointe->demandeApresRecrutement, 'annee_id' => $piecesJointe->annee, 'type_piece_jointe_id' => $piecesJointe->typePieceJointeId, 'piece_jointe_id' => $piecesJointe->pieceJointeId, 'intervenant_id' => $piecesJointe->intervenantId, 'demandee' => $piecesJointe->demandee, 'fournie' => $piecesJointe->fournie, 'validee' => $piecesJointe->validee, 'obligatoire' => $piecesJointe->obligatoire, 'date_validitee' => $piecesJointe->dateValiditee, 'demande_apres_recrutement' => $piecesJointe->demandeApresRecrutement, ]; } Loading @@ -245,6 +251,7 @@ class PieceJointeProcess implements ProcessInterface }, ]; try { mpg_upper($this->tblData); $table->merge($this->tblData, $key, $options); } catch (\Exception $e) { dump($e->getMessage()); Loading