1 |
jymadier |
4132 |
<?php |
2 |
|
|
/** |
3 |
|
|
* LISTING - Retours de consultation |
4 |
|
|
* |
5 |
|
|
* Le listing 'Retours de consultation' permet d'afficher la même liste de |
6 |
|
|
* dossiers que le widget 'Retours de consultation'. Ce script permet de |
7 |
|
|
* définir les paramètres génériques du listing qui se trouvent dans la |
8 |
|
|
* définition du widget obj/om_widget.class.php et a pour objectif d'être |
9 |
|
|
* inclus par les scripts de définition des listings spécifiques à chaque |
10 |
|
|
* filtre : instructeur, division, aucun. |
11 |
|
|
* |
12 |
|
|
* @package openads |
13 |
|
|
* @version SVN : $Id$ |
14 |
|
|
*/ |
15 |
|
|
|
16 |
|
|
// |
17 |
|
|
include "../gen/sql/pgsql/consultation.inc.php"; |
18 |
softime |
11418 |
include "../sql/pgsql/app_om_tab_common_select.inc.php"; |
19 |
jymadier |
4132 |
|
20 |
|
|
/** |
21 |
softime |
7366 |
* Filtres |
22 |
jymadier |
4132 |
*/ |
23 |
softime |
13137 |
// Selon l'entrée de menu sélectionné, on réalise l'affichage des éléments |
24 |
|
|
// en leur appliquant un filtre. Même principe de filtre que pour les widgets |
25 |
jymadier |
4132 |
if ($obj === "consultation_tous_retours") { |
26 |
softime |
13137 |
// Aucun filtre appliqué, affiche toutes les consultations ayant un retour |
27 |
|
|
// non lu |
28 |
jymadier |
4132 |
$filtre = "aucun"; |
29 |
|
|
} elseif ($obj === "consultation_retours_ma_division") { |
30 |
softime |
13137 |
// filtre division appliqué, affiche toutes les consultations appartenant |
31 |
|
|
// à un dossier affecté à la même division que l'utilisateur |
32 |
jymadier |
4132 |
$filtre = "division"; |
33 |
|
|
} else { |
34 |
softime |
13137 |
// filtre ? appliqué, affiche toutes les consultations appartenant |
35 |
|
|
// à un dossier ayant pour instructeur ou instructeur secondaire |
36 |
|
|
// l'utilisateur |
37 |
|
|
$filtre = 'instructeur_ou_instructeur_secondaire'; |
38 |
jymadier |
4132 |
} |
39 |
softime |
13137 |
// Filtre selon le filtre passé en paramètre dans l'url |
40 |
|
|
$filtreContexte = $this->get_submitted_get_value('filtre'); |
41 |
|
|
if (! empty($filtreContexte)) { |
42 |
|
|
$filtre = $filtreContexte; |
43 |
|
|
} |
44 |
|
|
|
45 |
jymadier |
4132 |
$params = array( |
46 |
|
|
"filtre" => $filtre, |
47 |
|
|
); |
48 |
|
|
|
49 |
|
|
/** |
50 |
|
|
* Récupération de la configuration de la requête à partir du widget. |
51 |
|
|
*/ |
52 |
|
|
// |
53 |
|
|
require_once "../obj/om_widget.class.php"; |
54 |
|
|
$om_widget = new om_widget(0); |
55 |
|
|
// |
56 |
|
|
$conf = $om_widget->get_config_consultation_retours($params); |
57 |
softime |
13137 |
// Ajout d'une jointure sur l'instructeur secondaire pour permettre la recherche |
58 |
|
|
// simple par instructeur secondaire |
59 |
|
|
$conf["query_ct_from"] .= sprintf( |
60 |
|
|
'LEFT JOIN %1$sinstructeur as instructeur_secondaire |
61 |
|
|
ON dossier.instructeur_2 = instructeur_secondaire.instructeur |
62 |
|
|
LEFT JOIN %1$som_utilisateur as utilisateur_2 |
63 |
softime |
19307 |
ON instructeur_secondaire.om_utilisateur = utilisateur_2.om_utilisateur', |
64 |
|
|
DB_PREFIXE |
65 |
softime |
13137 |
); |
66 |
|
|
// Récupération du filtre |
67 |
|
|
$sqlFiltre = $om_widget->get_query_filter( |
68 |
|
|
$conf["query_ct_from"].' WHERE '.$conf["query_ct_where_common"], |
69 |
|
|
$filtre |
70 |
|
|
); |
71 |
jymadier |
4132 |
|
72 |
|
|
/** |
73 |
|
|
* |
74 |
|
|
*/ |
75 |
|
|
// |
76 |
|
|
$tab_description = $conf["message_help"]; |
77 |
|
|
|
78 |
|
|
// |
79 |
softime |
18876 |
$tab_title = __("consultation"); |
80 |
jymadier |
4132 |
|
81 |
softime |
11876 |
// Traduction des termes technique du type de consultation. |
82 |
|
|
// Pour les consultations des tiers et des service la traduction est la même |
83 |
|
|
// sauf qu'on ne cherche pas les résultats dans la même table. Ce template |
84 |
|
|
// existe donc pour pouvoir être utilisé dans les 2 cas sans réécrire ce code |
85 |
|
|
$template_case_traduction_type_consultation = |
86 |
|
|
'CASE WHEN %1$s.type_consultation=\'avec_avis_attendu\' |
87 |
softime |
18876 |
THEN \''.__("avec avis attendu").'\' |
88 |
softime |
11876 |
WHEN %1$s.type_consultation=\'pour_conformite\' |
89 |
softime |
18876 |
THEN \''.__("pour conformite").'\' |
90 |
softime |
11876 |
WHEN %1$s.type_consultation=\'pour_information\' |
91 |
softime |
18876 |
THEN \''.__("pour information").'\' |
92 |
softime |
11876 |
END'; |
93 |
|
|
// Affichage du type de consultation traduit selon l'élément consulte (tiers ou service) |
94 |
|
|
$case_type_consultation = sprintf( |
95 |
|
|
'CASE WHEN consultation.service IS NOT NULL |
96 |
|
|
THEN (%1$s) |
97 |
|
|
ELSE (%2$s) |
98 |
|
|
END', |
99 |
|
|
sprintf($template_case_traduction_type_consultation, 'service'), |
100 |
|
|
sprintf($template_case_traduction_type_consultation, 'motif_consultation') |
101 |
|
|
); |
102 |
|
|
|
103 |
|
|
// Affichage du nom du service ou du tiers consulte |
104 |
|
|
$case_element_consulte = |
105 |
|
|
"CASE WHEN consultation.service IS NOT NULL |
106 |
|
|
THEN concat(service.abrege, ' - ', service.libelle) |
107 |
|
|
ELSE concat(tiers_consulte.abrege, ' - ', tiers_consulte.libelle) |
108 |
|
|
END"; |
109 |
|
|
|
110 |
jymadier |
4132 |
// |
111 |
|
|
$displayed_fields_begin = array( |
112 |
softime |
18876 |
'consultation.consultation as "'.__("consultation").'"', |
113 |
softime |
11418 |
$select__dossier_libelle__column_as, |
114 |
softime |
18876 |
$case_element_consulte.' as "'.__("service / tiers").'"', |
115 |
|
|
$case_type_consultation.' as "'.__("type_consultation").'"', |
116 |
|
|
'to_char(consultation.date_reception ,\'DD/MM/YYYY\') as "'.__("date_reception").'"', |
117 |
|
|
'to_char(consultation.date_retour ,\'DD/MM/YYYY\') as "'.__("date_retour").'"', |
118 |
|
|
'to_char(consultation.date_limite ,\'DD/MM/YYYY\') as "'.__("date_limite").'"', |
119 |
|
|
'avis_consultation.libelle as "'.__("avis_consultation").'"', |
120 |
jymadier |
4132 |
); |
121 |
|
|
$displayed_field_instructeur = array( |
122 |
softime |
18876 |
'instructeur.nom as "'.__("instructeur").'"', |
123 |
softime |
13137 |
'instructeur_secondaire.nom as "'.__("instructeur secondaire").'"', |
124 |
jymadier |
4132 |
); |
125 |
|
|
$displayed_field_division = array( |
126 |
softime |
18876 |
'division.code as "'.__("division").'"', |
127 |
jymadier |
4132 |
); |
128 |
|
|
$displayed_field_collectivite = array( |
129 |
softime |
18876 |
'om_collectivite.libelle as "'.__("collectivite").'"', |
130 |
jymadier |
4132 |
); |
131 |
softime |
15973 |
$displayed_fields_end = array($select_enjeux_dossier); |
132 |
jymadier |
4132 |
|
133 |
|
|
// FROM |
134 |
softime |
13137 |
$table = |
135 |
|
|
$conf["query_ct_from"]. |
136 |
|
|
$sqlFiltre['FROM']; |
137 |
jymadier |
4132 |
// WHERE |
138 |
|
|
$selection = sprintf( |
139 |
|
|
"WHERE |
140 |
|
|
%s |
141 |
softime |
13137 |
%s |
142 |
jymadier |
4132 |
", |
143 |
softime |
13137 |
$conf["query_ct_where_common"], |
144 |
|
|
$sqlFiltre['WHERE'] |
145 |
jymadier |
4132 |
); |
146 |
|
|
|
147 |
|
|
// |
148 |
softime |
19307 |
$tri = " ORDER BY $order_by_enjeux_priorite_dossier, consultation.date_retour "; |
149 |
|
|
$options[] = array( |
150 |
|
|
'type' => 'pagination_group_by', |
151 |
|
|
'pagination_group_by' => false |
152 |
|
|
); |
153 |
jymadier |
4132 |
// |
154 |
|
|
$tab_actions['corner']['ajouter'] = null; |
155 |
|
|
|
156 |
|
|
/** |
157 |
|
|
* Options - Style CSS sur certaines lignes |
158 |
|
|
* On met la ligne en couleur selon le type de consultation |
159 |
|
|
*/ |
160 |
|
|
$options[] = array( |
161 |
|
|
"type" => "condition", |
162 |
|
|
"field" => 'CASE WHEN service.type_consultation=\'avec_avis_attendu\' |
163 |
softime |
18876 |
THEN \''.__("avec avis attendu").'\' |
164 |
jymadier |
4132 |
WHEN service.type_consultation=\'pour_conformite\' |
165 |
softime |
18876 |
THEN \''.__("pour conformite").'\' |
166 |
jymadier |
4132 |
WHEN service.type_consultation=\'pour_information\' |
167 |
softime |
18876 |
THEN \''.__("pour information").'\' |
168 |
jymadier |
4132 |
END', |
169 |
|
|
"case" => array( |
170 |
|
|
array( |
171 |
softime |
18876 |
"values" => array(__("avec avis attendu"), ), |
172 |
jymadier |
4132 |
"style" => "consultation-avec-avis-attendu", |
173 |
|
|
), |
174 |
|
|
array( |
175 |
softime |
18876 |
"values" => array(__("pour conformite"), ), |
176 |
jymadier |
4132 |
"style" => "consultation-pour-conformite", |
177 |
|
|
), |
178 |
|
|
array( |
179 |
softime |
18876 |
"values" => array(__("pour information"), ), |
180 |
jymadier |
4132 |
"style" => "consultation-pour-information", |
181 |
|
|
), |
182 |
|
|
), |
183 |
|
|
); |
184 |
|
|
|
185 |
|
|
/** |
186 |
|
|
* Options - ADVSEARCH |
187 |
|
|
*/ |
188 |
|
|
// |
189 |
|
|
$advsearch_fields_begin = array( |
190 |
|
|
// |
191 |
|
|
'service_abrege' => array( |
192 |
|
|
'table' => 'service', |
193 |
|
|
'colonne' => 'abrege', |
194 |
|
|
'type' => 'text', |
195 |
softime |
18876 |
'libelle' => __('Service (abrege)'), |
196 |
softime |
9282 |
'taille' => '', |
197 |
|
|
'max' => '', |
198 |
jymadier |
4132 |
), |
199 |
|
|
// |
200 |
|
|
'service' => array( |
201 |
|
|
'table' => 'service', |
202 |
|
|
'colonne' => 'libelle', |
203 |
|
|
'type' => 'text', |
204 |
softime |
18876 |
'libelle' => __('Service'), |
205 |
softime |
9282 |
'taille' => '', |
206 |
|
|
'max' => '', |
207 |
jymadier |
4132 |
), |
208 |
|
|
); |
209 |
|
|
// |
210 |
|
|
$advsearch_field_instructeur = array( |
211 |
|
|
'instructeur' => array( |
212 |
|
|
'colonne' => 'nom', |
213 |
|
|
'table' => 'instructeur', |
214 |
softime |
18876 |
'libelle' => __('Instructeur'), |
215 |
jymadier |
4132 |
'type' => 'text', |
216 |
softime |
9282 |
'taille' => '', |
217 |
|
|
'max' => '', |
218 |
jymadier |
4132 |
), |
219 |
softime |
13137 |
'instructeur_2' => array( |
220 |
|
|
'table' => 'dossier', |
221 |
|
|
'colonne' => 'instructeur_2', |
222 |
|
|
'type' => 'select', |
223 |
|
|
'libelle' => __('Instructeur secondaire'), |
224 |
|
|
'subtype' => 'sqlselect', |
225 |
|
|
'sql' => "SELECT instructeur.instructeur, instructeur.nom |
226 |
|
|
FROM ".DB_PREFIXE."instructeur |
227 |
|
|
INNER JOIN ".DB_PREFIXE."instructeur_qualite ON instructeur_qualite.instructeur_qualite=instructeur.instructeur_qualite |
228 |
|
|
WHERE ((instructeur.om_validite_debut IS NULL AND (instructeur.om_validite_fin IS NULL OR instructeur.om_validite_fin > CURRENT_DATE)) OR (instructeur.om_validite_debut <= CURRENT_DATE AND (instructeur.om_validite_fin IS NULL OR instructeur.om_validite_fin > CURRENT_DATE))) |
229 |
|
|
AND LOWER(instructeur_qualite.code) = LOWER('instr') |
230 |
|
|
ORDER BY nom", |
231 |
|
|
), |
232 |
jymadier |
4132 |
); |
233 |
softime |
13137 |
|
234 |
jymadier |
4132 |
$advsearch_field_division = array( |
235 |
|
|
// |
236 |
|
|
'division' => array( |
237 |
|
|
'colonne' => 'code', |
238 |
|
|
'table' => 'division', |
239 |
softime |
18876 |
'libelle' => __('Division'), |
240 |
jymadier |
4132 |
'type' => 'text', |
241 |
softime |
9282 |
'taille' => '', |
242 |
|
|
'max' => '', |
243 |
jymadier |
4132 |
), |
244 |
|
|
); |
245 |
|
|
// |
246 |
|
|
$advsearch_field_collectivite = array( |
247 |
|
|
// |
248 |
|
|
'collectivite' => array( |
249 |
|
|
'table' => 'om_collectivite', |
250 |
|
|
'colonne' => 'libelle', |
251 |
|
|
'type' => 'text', |
252 |
softime |
18876 |
'libelle' => __('om_collectivite'), |
253 |
softime |
9282 |
'taille' => '', |
254 |
|
|
'max' => '', |
255 |
jymadier |
4132 |
), |
256 |
|
|
); |
257 |
|
|
// |
258 |
|
|
$advsearch_fields_end = array( |
259 |
|
|
// |
260 |
|
|
'date_envoi' => array( |
261 |
|
|
'colonne' => 'date_envoi', |
262 |
|
|
'table' => 'consultation', |
263 |
softime |
18876 |
'libelle' => __('Date d\'envoi'), |
264 |
jymadier |
4132 |
'type' => 'date', |
265 |
|
|
'where' => 'intervaldate', |
266 |
softime |
9282 |
'taille' => '', |
267 |
jymadier |
4132 |
), |
268 |
|
|
// |
269 |
|
|
'date_retour' => array( |
270 |
|
|
'colonne' => 'date_retour', |
271 |
|
|
'table' => 'consultation', |
272 |
softime |
18876 |
'libelle' => __('Date de retour'), |
273 |
jymadier |
4132 |
'type' => 'date', |
274 |
|
|
'where' => 'intervaldate', |
275 |
softime |
9282 |
'taille' => '', |
276 |
jymadier |
4132 |
), |
277 |
|
|
// |
278 |
|
|
'date_limite' => array( |
279 |
|
|
'colonne' => 'date_limite', |
280 |
|
|
'table' => 'consultation', |
281 |
softime |
18876 |
'libelle' => __('Date limite'), |
282 |
jymadier |
4132 |
'type' => 'date', |
283 |
|
|
'where' => 'intervaldate', |
284 |
softime |
9282 |
'taille' => '', |
285 |
jymadier |
4132 |
), |
286 |
|
|
); |
287 |
|
|
|
288 |
|
|
?> |