Loading data/Etats de sortie/export_mission_csv.php 0 → 100644 +127 −0 Original line number Diff line number Diff line <?php /** * @return array * @var $etatSortie \Application\Entity\Db\EtatSortie * @var $data array * @var $filtres array * @var $entityManager \Doctrine\ORM\EntityManager * @var $role \Application\Acl\Role * @var $options array * * @var $csv \UnicaenApp\View\Model\CsvModel */ // initialisation $head = [ 'type_etat' => 'Type État', 'date_extraction' => 'Date d\'extraction', 'annee' => 'Année universitaire', 'code_intervenant' => 'Code intervenant', 'code_rh' => 'Code RH', 'intervenant_nom_prenom' => 'Intervenant (NOM Prénom)', 'date_naissance' => 'Date de naissance', 'email_perso' => 'Adresse mail personnelle', 'composante_service' => 'Composante / service', 'type_mission' => 'Mission (Type) - parmi les 8 missions prédéfinies', 'libelle' => 'Mission (Libellé)', 'date_debut' => 'Date de début mission', 'date_fin' => 'Date fin mission', 'heures' => 'Nb d\'heures de la mission', 'taux_remu' => 'Taux de rémunération', 'taux_remu_majore' => 'Taux majoré', 'heures_formation' => 'Nb d\'heures de formation prévues (si tutorat)', ]; $res = []; $periodes = []; $months = [ '01' => 'janvier', '02' => 'février', '03' => 'mars', '04' => 'avril', '05' => 'mai', '06' => 'juin', '07' => 'juillet', '08' => 'août', '09' => 'septembre', '10' => 'octobre', '11' => 'novembre', '12' => 'décembre', ]; $dateExtraction = new \DateTime(); foreach ($data as $ddb) { $id = (int)$ddb['MISSION_ID']; $d = [ 'type_etat' => $ddb['TYPE_ETAT'], 'date_extraction' => $dateExtraction, 'annee' => $ddb['ANNEE'], 'code_intervenant' => $ddb['CODE_INTERVENANT'], 'code_rh' => $ddb['CODE_RH'], 'intervenant_nom_prenom' => $ddb['INTERVENANT_NOM_PRENOM'], 'date_naissance' => \DateTime::createFromFormat('Y-m-d', substr($ddb['DATE_NAISSANCE'], 0, 10)), 'email_perso' => $ddb['EMAIL_PERSO'], 'composante_service' => $ddb['COMPOSANTE_SERVICE'], 'type_mission' => $ddb['TYPE_MISSION'], 'libelle' => $ddb['LIBELLE'], 'date_debut' => \DateTime::createFromFormat('Y-m-d', substr($ddb['DATE_DEBUT'], 0, 10)), 'date_fin' => \DateTime::createFromFormat('Y-m-d', substr($ddb['DATE_FIN'], 0, 10)), 'heures' => (float)$ddb['HEURES'], 'taux_remu' => $ddb['TAUX_REMU'], 'taux_remu_majore' => $ddb['TAUX_REMU_MAJORE'], 'heures_formation' => $ddb['HEURES_FORMATION'], 'total' => 0, ]; if (!isset($res[$id])){ $res[$id] = $d; } $anneeId = (int)$ddb['ANNEE_ID']; $mois = $ddb['MOIS_REALISATION']; $heuresRealisees = (float)$ddb['HEURES_REALISEES']; if ($heuresRealisees > 0) { if (!array_key_exists($mois, $res[$id])) { $res[$id][$mois] = 0; } $res[$id][$mois] += $heuresRealisees; $res[$id]['total'] += $heuresRealisees; if (!array_key_exists($mois, $periodes)) { if ($mois) { [$a,$m] = explode('-',$mois); $moisLib = 'Total heures '.$months[$m] . ' ' . $a; }else{ $mois = 'inconnue'; $moisLib = 'Période inconnue'; } $periodes[$mois] = $moisLib; } } } ksort($periodes); foreach($periodes as $periode => $libelle){ $head[$periode] = $libelle; } $head['total'] = 'TOTAL GLOBAL'; $result = []; foreach( $res as $r ){ if ($r['total'] > 0) { $rlt = []; foreach ($head as $h => $null) { $rlt[$h] = $r[$h] ?? null; } $result[] = $rlt; } } $csv->setHeader($head); $csv->addLines($result); No newline at end of file data/ddl/view/V_EXPORT_MISSION.sql 0 → 100644 +140 −0 Original line number Diff line number Diff line CREATE OR REPLACE FORCE VIEW V_EXPORT_MISSION AS SELECT NULL id, annee_id, mission_id, NULL service_id, NULL service_referentiel_id, intervenant_id, type_volume_horaire_id, etat_volume_horaire_id, NULL element_pedagogique_id, NULL etablissement_id, structure_aff_id, structure_aff_ids, structure_ens_id, structure_ens_ids, NULL periode_id, NULL type_intervention_id, NULL fonction_referentiel_id, NULL motif_non_paiement_id, NULL tag_id, type_etat, date_extraction, annee, code_intervenant, code_rh, intervenant_nom_prenom, date_naissance, email_perso, composante_service, type_mission, libelle, date_debut, date_fin, heures, taux_remu, taux_remu_majore, heures_formation, mois_realisation, SUM( CASE etat_volume_horaire_code WHEN 'saisi' THEN heures_realisees ELSE CASE WHEN valide = 1 THEN heures_realisees ELSE 0 END END ) heures_realisees FROM ( SELECT a.id annee_id, i.id intervenant_id, m.id mission_id, tvh.id type_volume_horaire_id, evh.id etat_volume_horaire_id, istr.id structure_aff_id, istr.ids structure_aff_ids, str.id structure_ens_id, str.ids structure_ens_ids, evh.code etat_volume_horaire_code, tvh.libelle || ' ' || lower(evh.libelle) type_etat, sysdate date_extraction, a.libelle annee, i.code code_intervenant, i.code_rh code_rh, i.nom_usuel || ' ' || i.prenom intervenant_nom_prenom, i.date_naissance date_naissance, COALESCE(i.email_perso,d.email_perso) email_perso, str.libelle_court composante_service, tm.libelle type_mission, m.libelle_mission libelle, m.date_debut date_debut, m.date_fin date_fin, CASE evh.code WHEN 'saisi' THEN tblm.heures_prevues_saisies ELSE tblm.heures_prevues_validees END heures, tr.libelle taux_remu, trm.libelle taux_remu_majore, m.heures_formation heures_formation, vhm.id vhm_id, to_char(vhm.horaire_debut, 'YYYY-MM') mois_realisation, vhm.heures heures_realisees, CASE WHEN vhm.auto_validation = 1 OR max(v.id) over (partition by vhm.id) IS NOT NULL THEN 1 ELSE 0 END valide, vhm.auto_validation, max(v.id) over (partition by vhm.id) validation_id, row_number() OVER (PARTITION BY vhm.id ORDER BY vhm.id) r FROM mission m JOIN type_volume_horaire tvh ON tvh.code = 'PREVU' JOIN type_volume_horaire tvhr ON tvhr.code = 'REALISE' JOIN etat_volume_horaire evh ON 1=1 JOIN intervenant i ON i.id = m.intervenant_id JOIN annee a ON a.id = i.annee_id JOIN structure str ON str.id = m.structure_id JOIN type_mission tm ON tm.id = m.type_mission_id JOIN tbl_mission tblm ON tblm.mission_id = m.id LEFT JOIN structure istr ON istr.id = i.structure_id LEFT JOIN volume_horaire_mission vhm ON vhm.mission_id = m.id AND vhm.type_volume_horaire_id = tvhr.id AND vhm.histo_destruction IS NULL LEFT JOIN intervenant_dossier d ON d.intervenant_id = i.id AND d.histo_destruction IS NULL LEFT JOIN taux_remu tr ON tr.id = COALESCE(m.taux_remu_id, tm.taux_remu_id) LEFT JOIN taux_remu trm ON trm.id = COALESCE(m.taux_remu_majore_id, m.taux_remu_id, tm.taux_remu_majore_id, tm.taux_remu_id) LEFT JOIN validation_vol_horaire_miss vvhm ON vvhm.volume_horaire_mission_id = vhm.id LEFT JOIN validation v ON v.id = vvhm.validation_id AND v.histo_destruction IS NULL WHERE m.histo_destruction IS NULL ) t WHERE r = 1 GROUP BY annee_id, intervenant_id, mission_id, type_volume_horaire_id, etat_volume_horaire_id, structure_aff_id, structure_aff_ids, structure_ens_id, structure_ens_ids, type_etat, date_extraction, annee, code_intervenant, code_rh, intervenant_nom_prenom, date_naissance, email_perso, composante_service, type_mission, libelle, date_debut, date_fin, heures, taux_remu, taux_remu_majore, heures_formation, mois_realisation ORDER BY intervenant_nom_prenom, mois_realisation No newline at end of file data/etats_sortie.php +7 −0 Original line number Diff line number Diff line Loading @@ -351,6 +351,13 @@ ORDER BY etape_libelle, etablissement_libelle, element_libelle, fonction_referentiel_libelle', ], [ 'CODE' => 'export-missions', 'LIBELLE' => 'Export CSV des missions', 'PDF_TRAITEMENT' => null, 'CSV_TRAITEMENT' => '/data/Etats de sortie/export_mission_csv.php', 'REQUETE' => 'select * FROM v_export_mission', ], [ 'CODE' => 'imputation-budgetaire', 'LIBELLE' => 'Export des imputations budgétaires', Loading Loading
data/Etats de sortie/export_mission_csv.php 0 → 100644 +127 −0 Original line number Diff line number Diff line <?php /** * @return array * @var $etatSortie \Application\Entity\Db\EtatSortie * @var $data array * @var $filtres array * @var $entityManager \Doctrine\ORM\EntityManager * @var $role \Application\Acl\Role * @var $options array * * @var $csv \UnicaenApp\View\Model\CsvModel */ // initialisation $head = [ 'type_etat' => 'Type État', 'date_extraction' => 'Date d\'extraction', 'annee' => 'Année universitaire', 'code_intervenant' => 'Code intervenant', 'code_rh' => 'Code RH', 'intervenant_nom_prenom' => 'Intervenant (NOM Prénom)', 'date_naissance' => 'Date de naissance', 'email_perso' => 'Adresse mail personnelle', 'composante_service' => 'Composante / service', 'type_mission' => 'Mission (Type) - parmi les 8 missions prédéfinies', 'libelle' => 'Mission (Libellé)', 'date_debut' => 'Date de début mission', 'date_fin' => 'Date fin mission', 'heures' => 'Nb d\'heures de la mission', 'taux_remu' => 'Taux de rémunération', 'taux_remu_majore' => 'Taux majoré', 'heures_formation' => 'Nb d\'heures de formation prévues (si tutorat)', ]; $res = []; $periodes = []; $months = [ '01' => 'janvier', '02' => 'février', '03' => 'mars', '04' => 'avril', '05' => 'mai', '06' => 'juin', '07' => 'juillet', '08' => 'août', '09' => 'septembre', '10' => 'octobre', '11' => 'novembre', '12' => 'décembre', ]; $dateExtraction = new \DateTime(); foreach ($data as $ddb) { $id = (int)$ddb['MISSION_ID']; $d = [ 'type_etat' => $ddb['TYPE_ETAT'], 'date_extraction' => $dateExtraction, 'annee' => $ddb['ANNEE'], 'code_intervenant' => $ddb['CODE_INTERVENANT'], 'code_rh' => $ddb['CODE_RH'], 'intervenant_nom_prenom' => $ddb['INTERVENANT_NOM_PRENOM'], 'date_naissance' => \DateTime::createFromFormat('Y-m-d', substr($ddb['DATE_NAISSANCE'], 0, 10)), 'email_perso' => $ddb['EMAIL_PERSO'], 'composante_service' => $ddb['COMPOSANTE_SERVICE'], 'type_mission' => $ddb['TYPE_MISSION'], 'libelle' => $ddb['LIBELLE'], 'date_debut' => \DateTime::createFromFormat('Y-m-d', substr($ddb['DATE_DEBUT'], 0, 10)), 'date_fin' => \DateTime::createFromFormat('Y-m-d', substr($ddb['DATE_FIN'], 0, 10)), 'heures' => (float)$ddb['HEURES'], 'taux_remu' => $ddb['TAUX_REMU'], 'taux_remu_majore' => $ddb['TAUX_REMU_MAJORE'], 'heures_formation' => $ddb['HEURES_FORMATION'], 'total' => 0, ]; if (!isset($res[$id])){ $res[$id] = $d; } $anneeId = (int)$ddb['ANNEE_ID']; $mois = $ddb['MOIS_REALISATION']; $heuresRealisees = (float)$ddb['HEURES_REALISEES']; if ($heuresRealisees > 0) { if (!array_key_exists($mois, $res[$id])) { $res[$id][$mois] = 0; } $res[$id][$mois] += $heuresRealisees; $res[$id]['total'] += $heuresRealisees; if (!array_key_exists($mois, $periodes)) { if ($mois) { [$a,$m] = explode('-',$mois); $moisLib = 'Total heures '.$months[$m] . ' ' . $a; }else{ $mois = 'inconnue'; $moisLib = 'Période inconnue'; } $periodes[$mois] = $moisLib; } } } ksort($periodes); foreach($periodes as $periode => $libelle){ $head[$periode] = $libelle; } $head['total'] = 'TOTAL GLOBAL'; $result = []; foreach( $res as $r ){ if ($r['total'] > 0) { $rlt = []; foreach ($head as $h => $null) { $rlt[$h] = $r[$h] ?? null; } $result[] = $rlt; } } $csv->setHeader($head); $csv->addLines($result); No newline at end of file
data/ddl/view/V_EXPORT_MISSION.sql 0 → 100644 +140 −0 Original line number Diff line number Diff line CREATE OR REPLACE FORCE VIEW V_EXPORT_MISSION AS SELECT NULL id, annee_id, mission_id, NULL service_id, NULL service_referentiel_id, intervenant_id, type_volume_horaire_id, etat_volume_horaire_id, NULL element_pedagogique_id, NULL etablissement_id, structure_aff_id, structure_aff_ids, structure_ens_id, structure_ens_ids, NULL periode_id, NULL type_intervention_id, NULL fonction_referentiel_id, NULL motif_non_paiement_id, NULL tag_id, type_etat, date_extraction, annee, code_intervenant, code_rh, intervenant_nom_prenom, date_naissance, email_perso, composante_service, type_mission, libelle, date_debut, date_fin, heures, taux_remu, taux_remu_majore, heures_formation, mois_realisation, SUM( CASE etat_volume_horaire_code WHEN 'saisi' THEN heures_realisees ELSE CASE WHEN valide = 1 THEN heures_realisees ELSE 0 END END ) heures_realisees FROM ( SELECT a.id annee_id, i.id intervenant_id, m.id mission_id, tvh.id type_volume_horaire_id, evh.id etat_volume_horaire_id, istr.id structure_aff_id, istr.ids structure_aff_ids, str.id structure_ens_id, str.ids structure_ens_ids, evh.code etat_volume_horaire_code, tvh.libelle || ' ' || lower(evh.libelle) type_etat, sysdate date_extraction, a.libelle annee, i.code code_intervenant, i.code_rh code_rh, i.nom_usuel || ' ' || i.prenom intervenant_nom_prenom, i.date_naissance date_naissance, COALESCE(i.email_perso,d.email_perso) email_perso, str.libelle_court composante_service, tm.libelle type_mission, m.libelle_mission libelle, m.date_debut date_debut, m.date_fin date_fin, CASE evh.code WHEN 'saisi' THEN tblm.heures_prevues_saisies ELSE tblm.heures_prevues_validees END heures, tr.libelle taux_remu, trm.libelle taux_remu_majore, m.heures_formation heures_formation, vhm.id vhm_id, to_char(vhm.horaire_debut, 'YYYY-MM') mois_realisation, vhm.heures heures_realisees, CASE WHEN vhm.auto_validation = 1 OR max(v.id) over (partition by vhm.id) IS NOT NULL THEN 1 ELSE 0 END valide, vhm.auto_validation, max(v.id) over (partition by vhm.id) validation_id, row_number() OVER (PARTITION BY vhm.id ORDER BY vhm.id) r FROM mission m JOIN type_volume_horaire tvh ON tvh.code = 'PREVU' JOIN type_volume_horaire tvhr ON tvhr.code = 'REALISE' JOIN etat_volume_horaire evh ON 1=1 JOIN intervenant i ON i.id = m.intervenant_id JOIN annee a ON a.id = i.annee_id JOIN structure str ON str.id = m.structure_id JOIN type_mission tm ON tm.id = m.type_mission_id JOIN tbl_mission tblm ON tblm.mission_id = m.id LEFT JOIN structure istr ON istr.id = i.structure_id LEFT JOIN volume_horaire_mission vhm ON vhm.mission_id = m.id AND vhm.type_volume_horaire_id = tvhr.id AND vhm.histo_destruction IS NULL LEFT JOIN intervenant_dossier d ON d.intervenant_id = i.id AND d.histo_destruction IS NULL LEFT JOIN taux_remu tr ON tr.id = COALESCE(m.taux_remu_id, tm.taux_remu_id) LEFT JOIN taux_remu trm ON trm.id = COALESCE(m.taux_remu_majore_id, m.taux_remu_id, tm.taux_remu_majore_id, tm.taux_remu_id) LEFT JOIN validation_vol_horaire_miss vvhm ON vvhm.volume_horaire_mission_id = vhm.id LEFT JOIN validation v ON v.id = vvhm.validation_id AND v.histo_destruction IS NULL WHERE m.histo_destruction IS NULL ) t WHERE r = 1 GROUP BY annee_id, intervenant_id, mission_id, type_volume_horaire_id, etat_volume_horaire_id, structure_aff_id, structure_aff_ids, structure_ens_id, structure_ens_ids, type_etat, date_extraction, annee, code_intervenant, code_rh, intervenant_nom_prenom, date_naissance, email_perso, composante_service, type_mission, libelle, date_debut, date_fin, heures, taux_remu, taux_remu_majore, heures_formation, mois_realisation ORDER BY intervenant_nom_prenom, mois_realisation No newline at end of file
data/etats_sortie.php +7 −0 Original line number Diff line number Diff line Loading @@ -351,6 +351,13 @@ ORDER BY etape_libelle, etablissement_libelle, element_libelle, fonction_referentiel_libelle', ], [ 'CODE' => 'export-missions', 'LIBELLE' => 'Export CSV des missions', 'PDF_TRAITEMENT' => null, 'CSV_TRAITEMENT' => '/data/Etats de sortie/export_mission_csv.php', 'REQUETE' => 'select * FROM v_export_mission', ], [ 'CODE' => 'imputation-budgetaire', 'LIBELLE' => 'Export des imputations budgétaires', Loading