is_option_mode_service_consulte_enabled() === true ? ' LEFT JOIN '.DB_PREFIXE.'consultation_entrante ON dossier.dossier = consultation_entrante.dossier ' : ''; $table .= " LEFT JOIN (SELECT dossier, external_uid FROM ".DB_PREFIXE."lien_id_interne_uid_externe WHERE object = 'dossier' AND category = 'platau' ) AS dossier_platau ON dossier_platau.dossier = dossier.dossier LEFT JOIN (SELECT dossier, external_uid FROM ".DB_PREFIXE."lien_id_interne_uid_externe WHERE object = 'dossier_consultation' AND category = 'platau' ) AS consultation_platau ON consultation_platau.dossier = dossier.dossier LEFT JOIN (SELECT dossier, ARRAY_TO_STRING(ARRAY_AGG(external_uid ORDER BY external_uid ASC), ', ') AS external_uid FROM ".DB_PREFIXE."lien_id_interne_uid_externe WHERE object = 'piece' AND category = 'platau' GROUP BY dossier) AS pieces_platau ON pieces_platau.dossier = dossier.dossier LEFT JOIN (SELECT dossier, ARRAY_TO_STRING(ARRAY_AGG(object || ' : ' || external_uid), ', ') AS external_uid FROM ".DB_PREFIXE."lien_id_interne_uid_externe WHERE object != 'piece' AND object != 'dossier' AND object != 'dossier_consultation' AND category = 'platau' GROUP BY dossier) AS autres_platau ON autres_platau.dossier = dossier.dossier "; $table .= sprintf(' LEFT JOIN ( %1$slien_dossier_demandeur AS lien_dossier_demandeur_delegataire JOIN %1$sdemandeur as demandeur_delegataire ON lien_dossier_demandeur_delegataire.demandeur = demandeur_delegataire.demandeur AND demandeur_delegataire.type_demandeur = \'delegataire\' ) ON dossier.dossier = lien_dossier_demandeur_delegataire.dossier AND lien_dossier_demandeur_delegataire.petitionnaire_principal IS FALSE LEFT JOIN %1$sdonnees_techniques ON donnees_techniques.dossier_instruction = dossier.dossier LEFT JOIN %1$sarchitecte ON architecte.architecte = donnees_techniques.architecte', DB_PREFIXE) ; // Permet l'ajout de la commune si l'option est activé $champAffiche_debut_num_dossier = array( 'dossier.dossier as "'.__("dossier").'"', 'dossier.dossier_libelle as "'.__("dossier").'"', ); if ($f->is_option_dossier_commune_enabled() === true) { $champAffiche_debut_num_dossier[] = "commune.libelle as \"".__("commune")."\""; } $famille_travaux_select = sprintf( '-- use_column_name_to_sort (SELECT string_agg(ftc.libelle::text, \', \') as famille_travaux_libelle FROM ( SELECT DISTINCT dossier, famille_travaux.libelle FROM %1$slien_dossier_nature_travaux INNER JOIN %1$snature_travaux ON lien_dossier_nature_travaux.nature_travaux = nature_travaux.nature_travaux INNER JOIN %1$sfamille_travaux ON nature_travaux.famille_travaux = famille_travaux.famille_travaux ORDER BY famille_travaux.libelle ) as ftc WHERE ftc.dossier = dossier.dossier GROUP BY dossier) AS "%2$s"', DB_PREFIXE, __("Famille de travaux") ); $nature_travaux_select = sprintf( '-- use_column_name_to_sort (SELECT string_agg(ntc.libelle::text, \', \' order by ntc.libelle) as nature_travaux_libelle FROM ( SELECT DISTINCT dossier, nature_travaux.libelle FROM %1$slien_dossier_nature_travaux INNER JOIN %1$snature_travaux ON lien_dossier_nature_travaux.nature_travaux = nature_travaux.nature_travaux ) as ntc WHERE ntc.dossier = dossier.dossier GROUP BY dossier) AS "%2$s"', DB_PREFIXE, __("Nature de travaux") ); // description/nature des travaux. En cas de modif, bloc de code aussi présent dans // dossier.form.inc.php (le formulaire du DI)', 'om_requete' et 'stats à la demande' $description_projet_select = sprintf( "-- use_column_name_to_sort (SELECT CONCAT_WS( '\n', CASE WHEN co_projet_desc = '' THEN NULL ELSE TRIM(co_projet_desc) END, CASE WHEN ope_proj_desc = '' THEN NULL ELSE TRIM(ope_proj_desc) END, CASE WHEN am_projet_desc = '' THEN NULL ELSE TRIM(am_projet_desc) END, CASE WHEN dm_projet_desc = '' THEN NULL ELSE TRIM(dm_projet_desc) END, CASE WHEN donnees_techniques.erp_cstr_neuve IS TRUE THEN '".str_replace("'", "''", __('erp_cstr_neuve'))."' END, CASE WHEN donnees_techniques.erp_trvx_acc IS TRUE THEN '".str_replace("'", "''", __('erp_trvx_acc'))."' END, CASE WHEN donnees_techniques.erp_extension IS TRUE THEN '".str_replace("'", "''", __('erp_extension'))."' END, CASE WHEN donnees_techniques.erp_rehab IS TRUE THEN '".str_replace("'", "''", __('erp_rehab'))."' END, CASE WHEN donnees_techniques.erp_trvx_am IS TRUE THEN '".str_replace("'", "''", __('erp_trvx_am'))."' END, CASE WHEN donnees_techniques.erp_vol_nouv_exist IS TRUE THEN '".str_replace("'", "''", __('erp_vol_nouv_exist'))."' END, CASE WHEN mh_design_appel_denom = '' THEN NULL ELSE TRIM(mh_design_appel_denom) END, CASE WHEN mh_loc_denom = '' THEN NULL ELSE TRIM(mh_loc_denom) END ) AS description_projet FROM %1\$sdonnees_techniques WHERE donnees_techniques.dossier_instruction = dossier.dossier ) AS \"%2\$s\"", DB_PREFIXE, __("Description du projet") ); // Modifie la méthode de récupération de la nature des travaux $champAffiche_debut_commun = array( $case_demandeur.' as "'.__("petitionnaire").'"', $case_correspondant.' as "'.__("correspondant").'"', 'TRIM(CONCAT(architecte.nom, \' \', architecte.prenom)) as "'.__("architecte (nom)").'"', 'architecte.nom_cabinet as "'.__("architecte (cabinet)").'"', $trim_concat_terrain.'as "'.__("localisation").'"', 'dossier_autorisation_type_detaille.libelle as "'.__("nature_dossier").'"', 'donnees_techniques.co_tot_log_nb as "'.__("nombre de logements créés").'"', $surface_creee.' as "'.__("surface créée").'"', $surface_totale.' as "'.__("surface totale").'"', $famille_travaux_select, $nature_travaux_select, $description_projet_select, 'to_char(dossier.date_depot ,\'DD/MM/YYYY\') as "'.__("date_depot").'"', 'to_char(dossier.date_complet ,\'DD/MM/YYYY\') as "'.__("date_complet").'"', 'CASE WHEN dossier.incomplet_notifie IS TRUE AND dossier.incompletude IS TRUE THEN to_char(dossier.date_limite_incompletude ,\'DD/MM/YYYY\') ELSE to_char(dossier.date_limite ,\'DD/MM/YYYY\') END as "'.__("date_limite").'"', ); $champAffiche_demat = array( 'dossier_platau.external_uid as "dossier Plat\'AU"', 'consultation_platau.external_uid as "consultation Plat\'AU"', 'pieces_platau.external_uid as "pièce(s) Plat\'AU"', 'autres_platau.external_uid as "autres objets Plat\'AU"', ); $champAffiche_demat_sc = array(); if ($f->is_option_mode_service_consulte_enabled() === true) { $champAffiche_demat_sc = array( 'consultation_entrante.service_consultant_id as "'.__('Service consultant : identifiant').'"', 'consultation_entrante.service_consultant_libelle as "'.__('Service consultant : libellé').'"', ); } // Redéfinit la liste des champs à afficher $champAffiche = array_merge( $champAffiche_debut_num_dossier, $champAffiche_debut_commun, array('instructeur.nom as "'.__("instructeur").'"', 'division.code as "'.__("division").'"', ), $champAffiche_fin_commun, $champAffiche_demat, $champAffiche_demat_sc ); ?>