1 |
mbroquet |
3730 |
<?php |
2 |
nmeucci |
3915 |
//$Id$ |
3 |
softime |
14542 |
//gen openMairie le 22/02/2023 11:40 |
4 |
mbroquet |
3730 |
|
5 |
|
|
$DEBUG=0; |
6 |
|
|
$serie=15; |
7 |
softime |
7996 |
$ent = __("application")." -> ".__("consultation"); |
8 |
mbroquet |
3730 |
if(!isset($premier)) $premier=''; |
9 |
|
|
if(!isset($tricolsf)) $tricolsf=''; |
10 |
|
|
if(!isset($premiersf)) $premiersf=''; |
11 |
|
|
if(!isset($selection)) $selection=''; |
12 |
|
|
if(!isset($retourformulaire)) $retourformulaire=''; |
13 |
nmeucci |
5549 |
if (!isset($idxformulaire)) { |
14 |
|
|
$idxformulaire = ''; |
15 |
|
|
} |
16 |
|
|
if (!isset($tricol)) { |
17 |
|
|
$tricol = ''; |
18 |
|
|
} |
19 |
|
|
if (!isset($valide)) { |
20 |
|
|
$valide = ''; |
21 |
|
|
} |
22 |
mbroquet |
3730 |
// FROM |
23 |
|
|
$table = DB_PREFIXE."consultation |
24 |
|
|
LEFT JOIN ".DB_PREFIXE."avis_consultation |
25 |
|
|
ON consultation.avis_consultation=avis_consultation.avis_consultation |
26 |
softime |
11876 |
LEFT JOIN ".DB_PREFIXE."categorie_tiers_consulte |
27 |
|
|
ON consultation.categorie_tiers_consulte=categorie_tiers_consulte.categorie_tiers_consulte |
28 |
mbroquet |
3730 |
LEFT JOIN ".DB_PREFIXE."dossier |
29 |
|
|
ON consultation.dossier=dossier.dossier |
30 |
softime |
11876 |
LEFT JOIN ".DB_PREFIXE."motif_consultation |
31 |
|
|
ON consultation.motif_consultation=motif_consultation.motif_consultation |
32 |
mbroquet |
3730 |
LEFT JOIN ".DB_PREFIXE."service |
33 |
softime |
11876 |
ON consultation.service=service.service |
34 |
|
|
LEFT JOIN ".DB_PREFIXE."tiers_consulte |
35 |
|
|
ON consultation.tiers_consulte=tiers_consulte.tiers_consulte "; |
36 |
mbroquet |
3730 |
// SELECT |
37 |
|
|
$champAffiche = array( |
38 |
softime |
7996 |
'consultation.consultation as "'.__("consultation").'"', |
39 |
|
|
'dossier.annee as "'.__("dossier").'"', |
40 |
|
|
'to_char(consultation.date_envoi ,\'DD/MM/YYYY\') as "'.__("date_envoi").'"', |
41 |
|
|
'to_char(consultation.date_retour ,\'DD/MM/YYYY\') as "'.__("date_retour").'"', |
42 |
|
|
'to_char(consultation.date_limite ,\'DD/MM/YYYY\') as "'.__("date_limite").'"', |
43 |
|
|
'service.libelle as "'.__("service").'"', |
44 |
|
|
'avis_consultation.libelle as "'.__("avis_consultation").'"', |
45 |
|
|
'to_char(consultation.date_reception ,\'DD/MM/YYYY\') as "'.__("date_reception").'"', |
46 |
|
|
'consultation.fichier as "'.__("fichier").'"', |
47 |
|
|
"case consultation.lu when 't' then 'Oui' else 'Non' end as \"".__("lu")."\"", |
48 |
|
|
'consultation.code_barres as "'.__("code_barres").'"', |
49 |
|
|
'consultation.om_fichier_consultation as "'.__("om_fichier_consultation").'"', |
50 |
|
|
"case consultation.om_final_consultation when 't' then 'Oui' else 'Non' end as \"".__("om_final_consultation")."\"", |
51 |
|
|
"case consultation.marque when 't' then 'Oui' else 'Non' end as \"".__("marque")."\"", |
52 |
|
|
"case consultation.visible when 't' then 'Oui' else 'Non' end as \"".__("visible")."\"", |
53 |
softime |
8329 |
"case consultation.om_fichier_consultation_dossier_final when 't' then 'Oui' else 'Non' end as \"".__("om_fichier_consultation_dossier_final")."\"", |
54 |
|
|
"case consultation.fichier_dossier_final when 't' then 'Oui' else 'Non' end as \"".__("fichier_dossier_final")."\"", |
55 |
softime |
10573 |
'consultation.nom_auteur as "'.__("nom_auteur").'"', |
56 |
|
|
'consultation.prenom_auteur as "'.__("prenom_auteur").'"', |
57 |
|
|
'consultation.qualite_auteur as "'.__("qualite_auteur").'"', |
58 |
softime |
11876 |
'categorie_tiers_consulte.libelle as "'.__("categorie_tiers_consulte").'"', |
59 |
|
|
'tiers_consulte.libelle as "'.__("tiers_consulte").'"', |
60 |
|
|
'motif_consultation.libelle as "'.__("motif_consultation").'"', |
61 |
softime |
14064 |
'consultation.fichier_pec as "'.__("fichier_pec").'"', |
62 |
mbroquet |
3730 |
); |
63 |
|
|
// |
64 |
|
|
$champNonAffiche = array( |
65 |
softime |
7996 |
'consultation.motivation as "'.__("motivation").'"', |
66 |
softime |
10573 |
'consultation.texte_fondement_avis as "'.__("texte_fondement_avis").'"', |
67 |
|
|
'consultation.texte_avis as "'.__("texte_avis").'"', |
68 |
|
|
'consultation.texte_hypotheses as "'.__("texte_hypotheses").'"', |
69 |
softime |
11876 |
'consultation.commentaire as "'.__("commentaire").'"', |
70 |
softime |
14542 |
'consultation.motif_pec as "'.__("motif_pec").'"', |
71 |
mbroquet |
3730 |
); |
72 |
|
|
// |
73 |
|
|
$champRecherche = array( |
74 |
softime |
7996 |
'consultation.consultation as "'.__("consultation").'"', |
75 |
|
|
'dossier.annee as "'.__("dossier").'"', |
76 |
|
|
'service.libelle as "'.__("service").'"', |
77 |
|
|
'avis_consultation.libelle as "'.__("avis_consultation").'"', |
78 |
|
|
'consultation.fichier as "'.__("fichier").'"', |
79 |
|
|
'consultation.code_barres as "'.__("code_barres").'"', |
80 |
|
|
'consultation.om_fichier_consultation as "'.__("om_fichier_consultation").'"', |
81 |
softime |
10573 |
'consultation.nom_auteur as "'.__("nom_auteur").'"', |
82 |
|
|
'consultation.prenom_auteur as "'.__("prenom_auteur").'"', |
83 |
|
|
'consultation.qualite_auteur as "'.__("qualite_auteur").'"', |
84 |
softime |
11876 |
'categorie_tiers_consulte.libelle as "'.__("categorie_tiers_consulte").'"', |
85 |
|
|
'tiers_consulte.libelle as "'.__("tiers_consulte").'"', |
86 |
|
|
'motif_consultation.libelle as "'.__("motif_consultation").'"', |
87 |
softime |
14064 |
'consultation.fichier_pec as "'.__("fichier_pec").'"', |
88 |
mbroquet |
3730 |
); |
89 |
|
|
$tri="ORDER BY dossier.annee ASC NULLS LAST"; |
90 |
|
|
$edition="consultation"; |
91 |
|
|
/** |
92 |
|
|
* Gestion de la clause WHERE => $selection |
93 |
|
|
*/ |
94 |
|
|
// Filtre listing standard |
95 |
|
|
$selection = ""; |
96 |
|
|
// Liste des clés étrangères avec leurs éventuelles surcharges |
97 |
|
|
$foreign_keys_extended = array( |
98 |
|
|
"avis_consultation" => array("avis_consultation", ), |
99 |
softime |
11876 |
"categorie_tiers_consulte" => array("categorie_tiers_consulte", ), |
100 |
softime |
12847 |
"dossier" => array("dossier", "dossier_instruction", "dossier_instruction_mes_encours", "dossier_instruction_tous_encours", "dossier_instruction_mes_clotures", "dossier_instruction_tous_clotures", "dossier_contentieux", "dossier_contentieux_mes_infractions", "dossier_contentieux_toutes_infractions", "dossier_contentieux_mes_recours", "dossier_contentieux_tous_recours", "sous_dossier", ), |
101 |
softime |
11876 |
"motif_consultation" => array("motif_consultation", ), |
102 |
mbroquet |
3730 |
"service" => array("service", ), |
103 |
softime |
11876 |
"tiers_consulte" => array("tiers_consulte", ), |
104 |
mbroquet |
3730 |
); |
105 |
|
|
// Filtre listing sous formulaire - avis_consultation |
106 |
|
|
if (in_array($retourformulaire, $foreign_keys_extended["avis_consultation"])) { |
107 |
nmeucci |
5549 |
$selection = " WHERE (consultation.avis_consultation = ".intval($idxformulaire).") "; |
108 |
mbroquet |
3730 |
} |
109 |
softime |
11876 |
// Filtre listing sous formulaire - categorie_tiers_consulte |
110 |
|
|
if (in_array($retourformulaire, $foreign_keys_extended["categorie_tiers_consulte"])) { |
111 |
|
|
$selection = " WHERE (consultation.categorie_tiers_consulte = ".intval($idxformulaire).") "; |
112 |
|
|
} |
113 |
mbroquet |
3730 |
// Filtre listing sous formulaire - dossier |
114 |
|
|
if (in_array($retourformulaire, $foreign_keys_extended["dossier"])) { |
115 |
nmeucci |
5549 |
$selection = " WHERE (consultation.dossier = '".$f->db->escapeSimple($idxformulaire)."') "; |
116 |
mbroquet |
3730 |
} |
117 |
softime |
11876 |
// Filtre listing sous formulaire - motif_consultation |
118 |
|
|
if (in_array($retourformulaire, $foreign_keys_extended["motif_consultation"])) { |
119 |
|
|
$selection = " WHERE (consultation.motif_consultation = ".intval($idxformulaire).") "; |
120 |
|
|
} |
121 |
mbroquet |
3730 |
// Filtre listing sous formulaire - service |
122 |
|
|
if (in_array($retourformulaire, $foreign_keys_extended["service"])) { |
123 |
nmeucci |
5549 |
$selection = " WHERE (consultation.service = ".intval($idxformulaire).") "; |
124 |
mbroquet |
3730 |
} |
125 |
softime |
11876 |
// Filtre listing sous formulaire - tiers_consulte |
126 |
|
|
if (in_array($retourformulaire, $foreign_keys_extended["tiers_consulte"])) { |
127 |
|
|
$selection = " WHERE (consultation.tiers_consulte = ".intval($idxformulaire).") "; |
128 |
|
|
} |
129 |
mbroquet |
3730 |
|