1 |
<?php |
<?php |
2 |
//$Id$ |
//$Id$ |
3 |
//gen openMairie le 14/04/2020 14:11 |
//gen openMairie le 14/04/2020 14:11 |
4 |
|
|
5 |
require_once "../gen/obj/task.class.php"; |
require_once "../gen/obj/task.class.php"; |
6 |
|
|
7 |
class task extends task_gen { |
class task extends task_gen { |
8 |
|
|
9 |
|
const STATUS_DRAFT = 'draft'; |
10 |
|
const STATUS_NEW = 'new'; |
11 |
|
const STATUS_PENDING = 'pending'; |
12 |
|
const STATUS_DONE = 'done'; |
13 |
|
const STATUS_ERROR = 'error'; |
14 |
|
const STATUS_DEBUG = 'debug'; |
15 |
|
const STATUS_ARCHIVED = 'archived'; |
16 |
|
const STATUS_CANCELED = 'canceled'; |
17 |
|
|
18 |
|
/** |
19 |
|
* Liste des types de tâche concernant les services instructeurs |
20 |
|
*/ |
21 |
|
const TASK_TYPE_SI = array( |
22 |
|
'creation_DA', |
23 |
|
'creation_DI', |
24 |
|
'depot_DI', |
25 |
|
'modification_DI', |
26 |
|
'qualification_DI', |
27 |
|
'decision_DI', |
28 |
|
'incompletude_DI', |
29 |
|
'completude_DI', |
30 |
|
'ajout_piece', |
31 |
|
'add_piece', |
32 |
|
'creation_consultation', |
33 |
|
'modification_DA', |
34 |
|
'create_DI', |
35 |
|
'envoi_CL', |
36 |
|
'notification_recepisse', |
37 |
|
'notification_instruction', |
38 |
|
'notification_decision', |
39 |
|
'notification_service_consulte', |
40 |
|
'notification_tiers_consulte', |
41 |
|
'notification_depot_demat', |
42 |
|
'notification_commune' |
43 |
|
); |
44 |
|
|
45 |
|
/** |
46 |
|
* Liste des types de tâche concernant les services consultés |
47 |
|
*/ |
48 |
|
const TASK_TYPE_SC = array( |
49 |
|
'create_DI_for_consultation', |
50 |
|
'avis_consultation', |
51 |
|
'pec_metier_consultation', |
52 |
|
'create_message', |
53 |
|
'notification_recepisse', |
54 |
|
'notification_instruction', |
55 |
|
'notification_decision', |
56 |
|
'notification_service_consulte', |
57 |
|
'notification_tiers_consulte', |
58 |
|
'notification_depot_demat', |
59 |
|
'prescription', |
60 |
|
); |
61 |
|
|
62 |
|
/** |
63 |
|
* Catégorie de la tâche |
64 |
|
*/ |
65 |
|
var $category = 'platau'; |
66 |
|
|
67 |
/** |
/** |
68 |
* Définition des actions disponibles sur la classe. |
* Définition des actions disponibles sur la classe. |
69 |
* |
* |
77 |
"view" => "view_json_data", |
"view" => "view_json_data", |
78 |
"permission_suffix" => "consulter", |
"permission_suffix" => "consulter", |
79 |
); |
); |
80 |
|
$this->class_actions[997] = array( |
81 |
|
"identifier" => "json_data", |
82 |
|
"view" => "post_update_task", |
83 |
|
"permission_suffix" => "modifier", |
84 |
|
); |
85 |
|
$this->class_actions[996] = array( |
86 |
|
"identifier" => "json_data", |
87 |
|
"view" => "post_add_task", |
88 |
|
"permission_suffix" => "ajouter", |
89 |
|
); |
90 |
|
} |
91 |
|
|
92 |
|
public function setvalF($val = array()) { |
93 |
|
|
94 |
|
// // les guillets doubles sont remplacés automatiquement par des simples |
95 |
|
// // dans core/om_formulaire.clasS.php::recupererPostvar() |
96 |
|
// // voir le ticket https://dev.atreal.fr/projets/openmairie/tracker/209 |
97 |
|
// // ceci est un hack sale temporaire en attendant résolution du ticket |
98 |
|
// foreach(array('json_payload', 'timestamp_log') as $key) { |
99 |
|
// if (isset($val[$key]) && ! empty($val[$key]) && |
100 |
|
// isset($_POST[$key]) && ! empty($_POST[$key])) { |
101 |
|
// $submited_payload = $_POST[$key]; |
102 |
|
// if (! empty($submited_payload)) { |
103 |
|
// $new_payload = str_replace("'", '"', $val[$key]); |
104 |
|
// if ($new_payload == $submited_payload || |
105 |
|
// strpos($submited_payload, '"') === false) { |
106 |
|
// $val[$key] = $new_payload; |
107 |
|
// } |
108 |
|
// else { |
109 |
|
// $error_msg = sprintf( |
110 |
|
// __("La convertion des guillemets de la payload JSON '%s' ". |
111 |
|
// "n'est pas idempotente (courante: %s, postée: %s, convertie: %s)"), |
112 |
|
// $key, var_export($val[$key], true), var_export($submited_payload, true), |
113 |
|
// var_export($new_payload, true)); |
114 |
|
// $this->correct = false; |
115 |
|
// $this->addToMessage($error_msg); |
116 |
|
// $this->addToLog(__METHOD__."() erreur : $error_msg", DEBUG_MODE); |
117 |
|
// return false; |
118 |
|
// } |
119 |
|
// } |
120 |
|
// } |
121 |
|
// } |
122 |
|
|
123 |
|
parent::setvalF($val); |
124 |
|
|
125 |
|
// XXX Ancien code : permet de ne pas avoir d'erreru lors de la modification d'une task |
126 |
|
if (array_key_exists('timestamp_log', $val) === true) { |
127 |
|
$this->valF['timestamp_log'] = str_replace("'", '"', $val['timestamp_log']); |
128 |
|
} |
129 |
|
|
130 |
|
// récupération de l'ID de l'objet existant |
131 |
|
$id = property_exists($this, 'id') ? $this->id : null; |
132 |
|
if(isset($val[$this->clePrimaire])) { |
133 |
|
$id = $val[$this->clePrimaire]; |
134 |
|
} elseif(isset($this->valF[$this->clePrimaire])) { |
135 |
|
$id = $this->valF[$this->clePrimaire]; |
136 |
|
} |
137 |
|
|
138 |
|
// MODE MODIFIER |
139 |
|
if (! empty($id)) { |
140 |
|
|
141 |
|
// si aucune payload n'est fourni (devrait toujours être le cas) |
142 |
|
if (! isset($val['json_payload']) || empty($val['json_payload'])) { |
143 |
|
|
144 |
|
// récupère l'objet existant |
145 |
|
$existing = $this->f->findObjectById('task', $id); |
146 |
|
if (! empty($existing)) { |
147 |
|
|
148 |
|
// récupère la payload de l'objet |
149 |
|
$val['json_payload'] = $existing->getVal('json_payload'); |
150 |
|
$this->valF['json_payload'] = $existing->getVal('json_payload'); |
151 |
|
$this->f->addToLog(__METHOD__."() récupère la payload de la tâche existante ". |
152 |
|
"'$id': ".$existing->getVal('json_payload'), EXTRA_VERBOSE_MODE); |
153 |
|
} |
154 |
|
} |
155 |
|
} |
156 |
|
|
157 |
|
if (array_key_exists('category', $val) === false |
158 |
|
|| $this->valF['category'] === '' |
159 |
|
|| $this->valF['category'] === null) { |
160 |
|
// |
161 |
|
$this->valF['category'] = $this->category; |
162 |
|
} |
163 |
|
|
164 |
|
// Si last_modification_time est vide, la valeur est remplacée par NULL |
165 |
|
// pour eviter d'avoir une erreur de base de données car le champ est au format time. |
166 |
|
if ($val['last_modification_time'] == "") { |
167 |
|
$this->valF['last_modification_time'] = NULL; |
168 |
|
} else { |
169 |
|
$this->valF['last_modification_time'] = $val['last_modification_time']; |
170 |
|
} |
171 |
|
|
172 |
|
// Si creation_time est vide, la valeur est remplacée par NULL |
173 |
|
// pour eviter d'avoir une erreur de base de données car le champ est au format time. |
174 |
|
if ($val['creation_time'] == "") { |
175 |
|
$this->valF['creation_time'] = NULL; |
176 |
|
} else { |
177 |
|
$this->valF['creation_time'] = $val['creation_time']; |
178 |
|
} |
179 |
|
} |
180 |
|
|
181 |
|
/** |
182 |
|
* |
183 |
|
* @return array |
184 |
|
*/ |
185 |
|
function get_var_sql_forminc__champs() { |
186 |
|
return array( |
187 |
|
"task", |
188 |
|
"type", |
189 |
|
"state", |
190 |
|
"object_id", |
191 |
|
"dossier", |
192 |
|
"stream", |
193 |
|
"creation_date", |
194 |
|
"creation_time", |
195 |
|
"CONCAT_WS(' ', to_char(task.creation_date, 'DD/MM/YYYY'), task.creation_time) AS date_creation", |
196 |
|
'last_modification_date', |
197 |
|
'last_modification_time', |
198 |
|
"CONCAT_WS(' ', to_char(task.last_modification_date, 'DD/MM/YYYY'), task.last_modification_time) AS date_modification", |
199 |
|
"comment", |
200 |
|
"json_payload", |
201 |
|
"timestamp_log", |
202 |
|
"timestamp_log AS timestamp_log_hidden", |
203 |
|
"category", |
204 |
|
); |
205 |
|
} |
206 |
|
|
207 |
|
function setType(&$form, $maj) { |
208 |
|
parent::setType($form, $maj); |
209 |
|
|
210 |
|
// Récupération du mode de l'action |
211 |
|
$crud = $this->get_action_crud($maj); |
212 |
|
|
213 |
|
// ALL |
214 |
|
$form->setType("category", "hidden"); |
215 |
|
$form->setType("timestamp_log_hidden", "hidden"); |
216 |
|
|
217 |
|
// MODE CREER |
218 |
|
if ($maj == 0 || $crud == 'create') { |
219 |
|
$form->setType("type", "select"); |
220 |
|
$form->setType("state", "select"); |
221 |
|
$form->setType("stream", "select"); |
222 |
|
$form->setType("json_payload", "textarea"); |
223 |
|
} |
224 |
|
// MODE MODIFIER |
225 |
|
if ($maj == 1 || $crud == 'update') { |
226 |
|
$form->setType("task", "hiddenstatic"); |
227 |
|
$form->setType("state", "select"); |
228 |
|
$form->setType("stream", "hiddenstatic"); |
229 |
|
$form->setType("json_payload", "jsonprettyprint"); |
230 |
|
$form->setType("timestamp_log", "jsontotab"); |
231 |
|
$form->setType("type", "hiddenstatic"); |
232 |
|
$form->setType("creation_date", "hidden"); |
233 |
|
$form->setType("creation_time", "hidden"); |
234 |
|
$form->setType("object_id", "hiddenstatic"); |
235 |
|
$form->setType("dossier", "hiddenstatic"); |
236 |
|
$form->setType("date_creation", "hiddenstatic"); |
237 |
|
$form->setType("last_modification_date", "hidden"); |
238 |
|
$form->setType("last_modification_time", "hidden"); |
239 |
|
$form->setType("date_modification", "static"); |
240 |
|
} |
241 |
|
// MODE CONSULTER |
242 |
|
if ($maj == 3 || $crud == 'read') { |
243 |
|
$form->setType("state", "selecthiddenstatic"); |
244 |
|
$form->setType("stream", "selecthiddenstatic"); |
245 |
|
$form->setType('dossier', 'link'); |
246 |
|
$form->setType('json_payload', 'jsonprettyprint'); |
247 |
|
$form->setType("type", "selecthiddenstatic"); |
248 |
|
$form->setType("creation_date", "hidden"); |
249 |
|
$form->setType("creation_time", "hidden"); |
250 |
|
$form->setType("date_creation", "static"); |
251 |
|
$form->setType("last_modification_date", "hidden"); |
252 |
|
$form->setType("last_modification_time", "hidden"); |
253 |
|
$form->setType("date_modification", "static"); |
254 |
|
$form->setType("timestamp_log", "jsontotab"); |
255 |
|
} |
256 |
|
} |
257 |
|
|
258 |
|
function stateTranslation ($currentState) { |
259 |
|
switch ($currentState){ |
260 |
|
case "draft": |
261 |
|
return __('brouillon'); |
262 |
|
break; |
263 |
|
case "new": |
264 |
|
return __('à traiter'); |
265 |
|
break; |
266 |
|
case "pending": |
267 |
|
return __('en cours'); |
268 |
|
break; |
269 |
|
case "done": |
270 |
|
return __('terminé'); |
271 |
|
break; |
272 |
|
case "archived": |
273 |
|
return __('archivé'); |
274 |
|
break; |
275 |
|
case "error": |
276 |
|
return __('erreur'); |
277 |
|
break; |
278 |
|
case "debug": |
279 |
|
return __('debug'); |
280 |
|
break; |
281 |
|
case "canceled": |
282 |
|
return __('annulé'); |
283 |
|
break; |
284 |
|
} |
285 |
|
} |
286 |
|
/** |
287 |
|
* |
288 |
|
*/ |
289 |
|
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
290 |
|
if($maj <= 3) { |
291 |
|
$contenu = array(); |
292 |
|
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG', 'ARCHIVED', 'CANCELED') as $key) { |
293 |
|
$const_name = 'STATUS_'.$key; |
294 |
|
$const_value = constant("self::$const_name"); |
295 |
|
$contenu[0][] = $const_value; |
296 |
|
|
297 |
|
|
298 |
|
$contenu[1][] = $this->stateTranslation($const_value); |
299 |
|
|
300 |
|
} |
301 |
|
|
302 |
|
$form->setSelect("state", $contenu); |
303 |
|
|
304 |
|
$contenu_stream =array(); |
305 |
|
$contenu_stream[0][0]="input"; |
306 |
|
$contenu_stream[1][0]=__('input'); |
307 |
|
$contenu_stream[0][1]="output"; |
308 |
|
$contenu_stream[1][1]=__('output'); |
309 |
|
$form->setSelect("stream", $contenu_stream); |
310 |
|
|
311 |
|
$tab_type = array_unique(array_merge(self::TASK_TYPE_SI, self::TASK_TYPE_SC)); |
312 |
|
|
313 |
|
foreach ($tab_type as $type) { |
314 |
|
|
315 |
|
$contenu_type[0][] = $type; |
316 |
|
|
317 |
|
switch ($type) { |
318 |
|
case "creation_DA": |
319 |
|
$value_type = __('Création DA'); |
320 |
|
break; |
321 |
|
case "create_DI": |
322 |
|
$value_type = __('Création demande'); |
323 |
|
break; |
324 |
|
case "creation_DI": |
325 |
|
$value_type = __('Création DI'); |
326 |
|
break; |
327 |
|
case "modification_DA": |
328 |
|
$value_type = __('Modification DA'); |
329 |
|
break; |
330 |
|
case "modification_DI": |
331 |
|
$value_type = __('Modification DI'); |
332 |
|
break; |
333 |
|
case "ajout_piece": |
334 |
|
$value_type = __('Ajout pièce (sortant)'); |
335 |
|
break; |
336 |
|
case "add_piece": |
337 |
|
$value_type = __('Ajout pièce (entrant)'); |
338 |
|
break; |
339 |
|
case "depot_DI": |
340 |
|
$value_type = __('Dépôt DI'); |
341 |
|
break; |
342 |
|
case "qualification_DI": |
343 |
|
$value_type = __('Qualification DI'); |
344 |
|
break; |
345 |
|
case "creation_consultation": |
346 |
|
$value_type = __('Création consultation'); |
347 |
|
break; |
348 |
|
case "decision_DI": |
349 |
|
$value_type = __('Décision DI'); |
350 |
|
break; |
351 |
|
case "envoi_CL": |
352 |
|
$value_type = __('Envoi contrôle de légalité'); |
353 |
|
break; |
354 |
|
case "pec_metier_consultation": |
355 |
|
$value_type = __('PeC consultation'); |
356 |
|
break; |
357 |
|
case "avis_consultation": |
358 |
|
$value_type = __('Avis'); |
359 |
|
break; |
360 |
|
case "prescription": |
361 |
|
$value_type = __('Prescription'); |
362 |
|
break; |
363 |
|
case "create_DI_for_consultation": |
364 |
|
$value_type = __('Création DI pour consultation'); |
365 |
|
break; |
366 |
|
case "create_message": |
367 |
|
$value_type = __('Message'); |
368 |
|
break; |
369 |
|
case "notification_recepisse": |
370 |
|
$value_type = __('Notification récépissé'); |
371 |
|
break; |
372 |
|
case "notification_instruction": |
373 |
|
$value_type = __('Notification instruction'); |
374 |
|
break; |
375 |
|
case "notification_decision": |
376 |
|
$value_type = __('Notification décision'); |
377 |
|
break; |
378 |
|
case "notification_service_consulte": |
379 |
|
$value_type = __('Notification service consulté'); |
380 |
|
break; |
381 |
|
case "notification_tiers_consulte": |
382 |
|
$value_type = __('Notification tiers consulté'); |
383 |
|
break; |
384 |
|
case "completude_DI": |
385 |
|
$value_type = __('complétude DI'); |
386 |
|
break; |
387 |
|
case "incompletude_DI": |
388 |
|
$value_type = __('incomplétude DI'); |
389 |
|
break; |
390 |
|
} |
391 |
|
|
392 |
|
$contenu_type[1][] = $value_type; |
393 |
|
} |
394 |
|
|
395 |
|
$form->setselect('type', $contenu_type); |
396 |
|
} |
397 |
|
|
398 |
|
if ($maj == 3) { |
399 |
|
// Récupération du numéro du dossier si il n'est pas renseigné dans la tâche |
400 |
|
if ($form->val['dossier'] == '' || $form->val['dossier'] == null) { |
401 |
|
// Récupération de la payload de la taĉhe. |
402 |
|
// Si la tâche est une tâche input la payload est associée à la tâche. |
403 |
|
// Si la tâche est une tâche en output la payload est "calculé" à l'ouverture |
404 |
|
// du formulaire. |
405 |
|
if ($this->getVal('stream') == 'input') { |
406 |
|
$json_payload = json_decode($this->getVal('json_payload'), true); |
407 |
|
} else { |
408 |
|
$json_payload = json_decode($form->val['json_payload'], true); |
409 |
|
} |
410 |
|
// A partir de la payload de la tâche ont récupère les externals uid |
411 |
|
// Si un external uid de DI (dossier) existe ont le récupère et on stocke le numéro |
412 |
|
// pour l'afficher sur le formulaire. |
413 |
|
// Si l'external UID du DI n'existe pas on récupère celui du DA |
414 |
|
$external_uid = ''; |
415 |
|
if (array_key_exists('external_uids', $json_payload) |
416 |
|
&& array_key_exists('dossier', $json_payload['external_uids']) |
417 |
|
) { |
418 |
|
$external_uid = $json_payload['external_uids']['dossier']; |
419 |
|
} elseif (array_key_exists('external_uids', $json_payload) |
420 |
|
&& array_key_exists('dossier', $json_payload['external_uids'])) { |
421 |
|
$external_uid = $json_payload['external_uids']['dossier']; |
422 |
|
} |
423 |
|
// Recherche l'external uid dans la base de données pour récupèrer le numéro de |
424 |
|
// DI / DA correspondant. On stocke le numéro de dossier dans la propriété val |
425 |
|
// du formulaire pour pouvoir l'afficher |
426 |
|
if ($external_uid != '') { |
427 |
|
$uid = sprintf( |
428 |
|
'SELECT |
429 |
|
lien_id_interne_uid_externe.dossier |
430 |
|
FROM |
431 |
|
%1$slien_id_interne_uid_externe |
432 |
|
WHERE |
433 |
|
lien_id_interne_uid_externe.external_uid = \'%2$s\'', |
434 |
|
DB_PREFIXE, |
435 |
|
$external_uid |
436 |
|
); |
437 |
|
$res_external_uid = $this->f->get_one_result_from_db_query($uid); |
438 |
|
if (! empty($res_external_uid['result'])) { |
439 |
|
$form->val['dossier'] = $res_external_uid['result']; |
440 |
|
} |
441 |
|
} |
442 |
|
} |
443 |
|
|
444 |
|
// Vérifie si le numéro de dossier associé à la tâche existe dans la base. |
445 |
|
// Si c'est le cas ce numéro sera lié au dossier (DI ou DA) correspondant |
446 |
|
// TODO : vérifier la liste des tâches lié à des DA |
447 |
|
$obj_link = ''; |
448 |
|
if ($form->val['type'] == "creation_DA" || $form->val['type'] == "modification_DA") { |
449 |
|
// Vérification que le numéro de DA affiché dans le formulaire existe |
450 |
|
$idDA = sprintf( |
451 |
|
'SELECT |
452 |
|
dossier_autorisation.dossier_autorisation |
453 |
|
FROM |
454 |
|
%1$sdossier_autorisation |
455 |
|
WHERE |
456 |
|
dossier_autorisation.dossier_autorisation = \'%2$s\'', |
457 |
|
DB_PREFIXE, |
458 |
|
$form->val['dossier'] |
459 |
|
); |
460 |
|
$resIdDA=$this->f->get_one_result_from_db_query($idDA); |
461 |
|
// Si on a un résultat c'est que le dossier existe, il faut afficher le lien |
462 |
|
if (! empty($resIdDA['result'])) { |
463 |
|
$obj_link = 'dossier_autorisation'; |
464 |
|
} |
465 |
|
} else { |
466 |
|
// Vérification que le numéro de DI affiché dans le formulaire existe |
467 |
|
$idDI = sprintf( |
468 |
|
'SELECT |
469 |
|
dossier.dossier |
470 |
|
FROM |
471 |
|
%1$sdossier |
472 |
|
WHERE |
473 |
|
dossier.dossier = \'%2$s\'', |
474 |
|
DB_PREFIXE, |
475 |
|
$form->val['dossier'] |
476 |
|
); |
477 |
|
$resDI = $this->f->get_one_result_from_db_query($idDI); |
478 |
|
// Si on a un résultat c'est que le dossier existe, il faut afficher le lien |
479 |
|
if (! empty($resDI['result'])) { |
480 |
|
$obj_link = 'dossier_instruction'; |
481 |
|
} |
482 |
|
} |
483 |
|
// Pour afficher le lien vers un dossier ont utilise un champ de type "link". |
484 |
|
// Pour paramétrer ce champs on a besoin de savoir : |
485 |
|
// - quel objet est visé par le lien |
486 |
|
// - le label (libellé) du lien |
487 |
|
// - l'identifiant de l'objet qui sera utilisé dans le lien |
488 |
|
// - le titre associé au lien |
489 |
|
// Pour cela on remplit le champs comme un select et les valeurs du select |
490 |
|
// contiennent les informations nécessaire à l'affichage du champs. |
491 |
|
$params = array( |
492 |
|
'obj' => $obj_link, |
493 |
|
'libelle' => $form->val['dossier'], |
494 |
|
'title' => "Consulter le dossier", |
495 |
|
'idx' => $form->val['dossier'] |
496 |
|
); |
497 |
|
$form->setSelect("dossier", $params); |
498 |
|
} |
499 |
} |
} |
500 |
|
|
501 |
protected function task_exists(string $type, string $object_id) { |
/** |
502 |
|
* SETTER_FORM - setVal (setVal). |
503 |
|
* |
504 |
|
* @return void |
505 |
|
*/ |
506 |
|
function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) { |
507 |
|
// parent::setVal($form, $maj, $validation); |
508 |
|
// |
509 |
|
if ($this->getVal('stream') == "output") { |
510 |
|
$form->setVal('json_payload', $this->view_form_json(true)); |
511 |
|
} else { |
512 |
|
$form->setVal('json_payload', json_encode(json_decode($this->getVal('json_payload'), true), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); |
513 |
|
} |
514 |
|
} |
515 |
|
|
516 |
|
function setLib(&$form, $maj) { |
517 |
|
parent::setLib($form, $maj); |
518 |
|
|
519 |
|
// Récupération du mode de l'action |
520 |
|
$crud = $this->get_action_crud($maj); |
521 |
|
|
522 |
|
$form->setLib('date_creation', __("Date de création")); |
523 |
|
$form->setLib('date_modification', __("Date de dernière modification")); |
524 |
|
$form->setLib('comment', __("commentaire")); |
525 |
|
|
526 |
|
// MODE different de CREER |
527 |
|
if ($maj != 0 || $crud != 'create') { |
528 |
|
$form->setLib('json_payload', ''); |
529 |
|
$form->setLib("task", __("identifiant")); |
530 |
|
$form->setLib("Task_portal", __("task_portal")); |
531 |
|
$form->setLib("type", __("type")); |
532 |
|
$form->setLib("object_id", __("Réf. interne")); |
533 |
|
$form->setLib("stream", __("flux")); |
534 |
|
$form->setLib("timestamp_log", __("Historique")); |
535 |
|
} |
536 |
|
} |
537 |
|
|
538 |
|
public function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
539 |
|
$ret = parent::verifier($val, $dnu1, $dnu2); |
540 |
|
|
541 |
|
// une tâche entrante doit avoir un type et une payload non-vide |
542 |
|
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
543 |
|
if (isset($this->valF['type']) === false) { |
544 |
|
$this->correct = false; |
545 |
|
$this->addToMessage(sprintf( |
546 |
|
__("Le champ %s est obligatoire pour une tâche entrante."), |
547 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('type')) |
548 |
|
)); |
549 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
550 |
|
} |
551 |
|
if (isset($this->valF['json_payload']) === false) { |
552 |
|
$this->correct = false; |
553 |
|
$this->addToMessage(sprintf( |
554 |
|
__("Le champ %s est obligatoire pour une tâche entrante."), |
555 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
556 |
|
)); |
557 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
558 |
|
} |
559 |
|
} |
560 |
|
|
561 |
|
// les JSONs doivent être décodables |
562 |
|
foreach(array('json_payload', 'timestamp_log') as $key) { |
563 |
|
if (isset($this->valF[$key]) && ! empty($this->valF[$key]) && ( |
564 |
|
is_array(json_decode($this->valF[$key], true)) === false |
565 |
|
|| json_last_error() !== JSON_ERROR_NONE)) { |
566 |
|
$this->correct = false; |
567 |
|
$champ_text = sprintf('<span class="bold">%s</span>', $this->getLibFromField($key)); |
568 |
|
$this->addToMessage(sprintf( |
569 |
|
__("Le champ %s doit être dans un format JSON valide (erreur: %s).". |
570 |
|
"<p>%s valF:</br><pre>%s</pre></p>". |
571 |
|
"<p>%s val:</br><pre>%s</pre></p>". |
572 |
|
"<p>%s POST:</br><pre>%s</pre></p>". |
573 |
|
"<p>%s submitted POST value:</br><pre>%s</pre></p>"), |
574 |
|
$champ_text, |
575 |
|
json_last_error() !== JSON_ERROR_NONE ? json_last_error_msg() : __('invalide'), |
576 |
|
$champ_text, |
577 |
|
$this->valF[$key], |
578 |
|
$champ_text, |
579 |
|
$val[$key], |
580 |
|
$champ_text, |
581 |
|
isset($_POST[$key]) ? $_POST[$key] : '', |
582 |
|
$champ_text, |
583 |
|
$this->f->get_submitted_post_value($key) |
584 |
|
)); |
585 |
|
$this->addToLog(__METHOD__.'(): erreur JSON: '.$this->msg, DEBUG_MODE); |
586 |
|
} |
587 |
|
} |
588 |
|
|
589 |
|
// une tâche entrante doit avoir une payload avec les clés requises |
590 |
|
if ($this->correct && (isset($this->valF['stream']) === false || |
591 |
|
$this->valF['stream'] == 'input')) { |
592 |
|
|
593 |
|
// décode la payload JSON |
594 |
|
$json_payload = json_decode($this->valF['json_payload'], true); |
595 |
|
|
596 |
|
// défini une liste de chemin de clés requises |
597 |
|
$paths = array(); |
598 |
|
if ($this->valF['category'] === 'platau') { |
599 |
|
$paths = array( |
600 |
|
'external_uids/dossier' |
601 |
|
); |
602 |
|
} |
603 |
|
|
604 |
|
// tâche de type création de DI/DA |
605 |
|
if (isset($this->valF['type']) !== false && $this->valF['type'] == 'create_DI_for_consultation') { |
606 |
|
|
607 |
|
$paths = array_merge($paths, array( |
608 |
|
'dossier/dossier', |
609 |
|
'dossier/dossier_autorisation_type_detaille_code', |
610 |
|
'dossier/date_demande', |
611 |
|
'dossier/depot_electronique', |
612 |
|
)); |
613 |
|
|
614 |
|
// si l'option commune est activée (mode MC) |
615 |
|
if ($this->f->is_option_dossier_commune_enabled()) { |
616 |
|
$paths[] = 'dossier/insee'; |
617 |
|
} |
618 |
|
|
619 |
|
// présence d'un moyen d'identifier la collectivité/le service |
620 |
|
if (! isset($json_payload['external_uids']['acteur']) && |
621 |
|
! isset($json_payload['dossier']['om_collectivite'])) { |
622 |
|
$this->correct = false; |
623 |
|
$this->addToMessage(sprintf( |
624 |
|
__("L'une des clés %s ou %s est obligatoire dans le contenu du champ %s pour une tâche entrante."), |
625 |
|
sprintf('<span class="bold">%s</span>', 'external_uids/acteur'), |
626 |
|
sprintf('<span class="bold">%s</span>', 'dossier/om_collectivite'), |
627 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
628 |
|
)); |
629 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
630 |
|
} |
631 |
|
} |
632 |
|
|
633 |
|
// pas d'erreur déjà trouvée |
634 |
|
if($this->correct) { |
635 |
|
|
636 |
|
// pour chaque chemin |
637 |
|
foreach($paths as $path) { |
638 |
|
|
639 |
|
// décompose le chemin |
640 |
|
$tokens = explode('/', $path); |
641 |
|
$cur_depth = $json_payload; |
642 |
|
|
643 |
|
// descend au et à mesure dans l'arborescence du chemin |
644 |
|
foreach($tokens as $token) { |
645 |
|
|
646 |
|
// en vérifiant que chaque élément du chemin est défini et non-nul |
647 |
|
if (isset($cur_depth[$token]) === false) { |
648 |
|
|
649 |
|
// sinon on produit une erreur |
650 |
|
$this->correct = false; |
651 |
|
$this->addToMessage(sprintf( |
652 |
|
__("La clé %s est obligatoire dans le contenu du champ %s pour une tâche entrante."), |
653 |
|
sprintf('<span class="bold">%s</span>', $path), |
654 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
655 |
|
)); |
656 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
657 |
|
break 2; |
658 |
|
} |
659 |
|
$cur_depth = $cur_depth[$token]; |
660 |
|
} |
661 |
|
} |
662 |
|
} |
663 |
|
} |
664 |
|
|
665 |
|
return $ret && $this->correct; |
666 |
|
} |
667 |
|
|
668 |
|
/** |
669 |
|
* [task_exists description] |
670 |
|
* @param string $type [description] |
671 |
|
* @param string $object_id [description] |
672 |
|
* @param bool $is_not_done [description] |
673 |
|
* @return [type] [description] |
674 |
|
*/ |
675 |
|
public function task_exists(string $type, string $object_id, string $dossier = null, bool $is_not_done = true) { |
676 |
$query = sprintf(' |
$query = sprintf(' |
677 |
SELECT task |
SELECT task |
678 |
FROM %1$stask |
FROM %1$stask |
679 |
WHERE state != \'%2$s\' |
WHERE %2$s |
680 |
AND type = \'%3$s\' |
type = \'%3$s\' |
681 |
AND object_id = \'%4$s\' |
AND (object_id = \'%4$s\' |
682 |
|
%5$s) |
683 |
|
AND state != \'%6$s\' |
684 |
', |
', |
685 |
DB_PREFIXE, |
DB_PREFIXE, |
686 |
'done', |
$is_not_done == true ? 'state != \''.self::STATUS_DONE.'\' AND' : '', |
687 |
$type, |
$type, |
688 |
$object_id |
$object_id, |
689 |
|
$dossier !== null ? sprintf('OR dossier = \'%s\'', $dossier) : '', |
690 |
|
self::STATUS_CANCELED |
691 |
); |
); |
692 |
$res = $this->f->get_one_result_from_db_query($query); |
$res = $this->f->get_one_result_from_db_query($query); |
693 |
if ($res['result'] !== null && $res['result'] !== '') { |
if ($res['result'] !== null && $res['result'] !== '') { |
697 |
} |
} |
698 |
|
|
699 |
/** |
/** |
700 |
|
* Permet la recherche multi-critères des tasks. |
701 |
|
* |
702 |
|
* @param array $search_values Chaque entrée du tableau est une ligne dans le WHERE |
703 |
|
* @return mixed Retourne le résultat de la requête ou false |
704 |
|
*/ |
705 |
|
public function task_exists_multi_search(array $search_values) { |
706 |
|
$query = sprintf(' |
707 |
|
SELECT * |
708 |
|
FROM %1$stask |
709 |
|
%2$s |
710 |
|
%3$s |
711 |
|
', |
712 |
|
DB_PREFIXE, |
713 |
|
empty($search_values) === false ? ' WHERE ' : '', |
714 |
|
implode(' AND ', $search_values) |
715 |
|
); |
716 |
|
$res = $this->f->get_all_results_from_db_query($query); |
717 |
|
if (count($res['result']) > 0) { |
718 |
|
return $res['result']; |
719 |
|
} |
720 |
|
return false; |
721 |
|
} |
722 |
|
|
723 |
|
/** |
724 |
|
* TRIGGER - triggerajouter. |
725 |
|
* |
726 |
|
* @param string $id |
727 |
|
* @param null &$dnu1 @deprecated Ne pas utiliser. |
728 |
|
* @param array $val Tableau des valeurs brutes. |
729 |
|
* @param null $dnu2 @deprecated Ne pas utiliser. |
730 |
|
* |
731 |
|
* @return boolean |
732 |
|
*/ |
733 |
|
function triggerajouter($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
734 |
|
|
735 |
|
// tâche entrante |
736 |
|
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
737 |
|
|
738 |
|
// décode la paylod JSON pour extraire les données métiers à ajouter |
739 |
|
// en tant que métadonnées de la tâche |
740 |
|
$json_payload = json_decode($this->valF['json_payload'], true); |
741 |
|
|
742 |
|
// si la tâche possède déjà une clé dossier |
743 |
|
if (isset($json_payload['dossier']['dossier']) && |
744 |
|
! empty($json_payload['dossier']['dossier'])) { |
745 |
|
$this->valF["dossier"] = $json_payload['dossier']['dossier']; |
746 |
|
} |
747 |
|
} |
748 |
|
|
749 |
|
// gestion d'une tache de type notification et de category mail |
750 |
|
if (isset($val['type']) |
751 |
|
&& (($val['type'] === 'notification_instruction' || $val['type'] === 'notification_decision') |
752 |
|
&& isset($val['category']) |
753 |
|
&& $val['category'] === 'mail') |
754 |
|
|| $val['type'] === 'notification_service_consulte' |
755 |
|
|| $val['type'] === 'notification_tiers_consulte' |
756 |
|
|| $val['type'] === 'notification_depot_demat' |
757 |
|
|| $val['type'] === 'notification_commune' |
758 |
|
) { |
759 |
|
// Récupère la payload de la tache |
760 |
|
$data = array(); |
761 |
|
$data['instruction_notification'] = $this->get_instruction_notification_data( |
762 |
|
$this->valF['category'], |
763 |
|
'with-id', |
764 |
|
array('with-id' => $this->valF['object_id']) |
765 |
|
); |
766 |
|
$data['dossier'] = $this->get_dossier_data($this->valF['dossier']); |
767 |
|
|
768 |
|
// Récupère l'instance de la notification |
769 |
|
$inst_notif = $this->f->get_inst__om_dbform(array( |
770 |
|
"obj" => "instruction_notification", |
771 |
|
"idx" => $val['object_id'], |
772 |
|
)); |
773 |
|
// Envoi le mail et met à jour le suivi |
774 |
|
$envoiMail = $inst_notif->send_mail_notification($data, $val['type']); |
775 |
|
// Passage de la tache à done si elle a réussi et à error |
776 |
|
// si l'envoi a échoué |
777 |
|
$this->valF['state'] = 'done'; |
778 |
|
if ($envoiMail === false) { |
779 |
|
$this->valF['state'] = 'error'; |
780 |
|
} |
781 |
|
} |
782 |
|
} |
783 |
|
|
784 |
|
/** |
785 |
|
* TRIGGER - triggermodifier. |
786 |
|
* |
787 |
|
* @param string $id |
788 |
|
* @param null &$dnu1 @deprecated Ne pas utiliser. |
789 |
|
* @param array $val Tableau des valeurs brutes. |
790 |
|
* @param null $dnu2 @deprecated Ne pas utiliser. |
791 |
|
* |
792 |
|
* @return boolean |
793 |
|
*/ |
794 |
|
function triggermodifier($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
795 |
|
parent::triggermodifier($id, $dnu1, $val, $dnu2); |
796 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
797 |
|
|
798 |
|
// Mise à jour des valeurs, notamment du timestamp_log en fonction de plusieurs critères |
799 |
|
$values = array( |
800 |
|
'state' => $this->valF['state'], |
801 |
|
'object_id' => $this->valF['object_id'], |
802 |
|
'comment' => $this->valF['comment'], |
803 |
|
); |
804 |
|
$new_values = $this->set_values_for_update($values); |
805 |
|
if ($new_values === false) { |
806 |
|
$this->addToLog(__METHOD__."(): erreur timestamp log", DEBUG_MODE); |
807 |
|
return false; |
808 |
|
} |
809 |
|
|
810 |
|
// Mise à jour des valeurs |
811 |
|
$this->valF['timestamp_log'] = $new_values['timestamp_log']; |
812 |
|
$this->valF['state'] = $new_values['state']; |
813 |
|
$this->valF['object_id'] = $new_values['object_id']; |
814 |
|
$this->valF['last_modification_date'] = date('Y-m-d'); |
815 |
|
$this->valF['last_modification_time'] = date('H:i:s'); |
816 |
|
|
817 |
|
return true; |
818 |
|
} |
819 |
|
|
820 |
|
|
821 |
|
/** |
822 |
|
* Applique nouvelle valeur après traitement. |
823 |
|
* |
824 |
|
* @param array $params Tableau des valeurs en entrées |
825 |
|
* @return array Tableau des valeurs en sorties |
826 |
|
*/ |
827 |
|
public function set_values_for_update($params = array()) { |
828 |
|
|
829 |
|
// Récupération du timestamp_log existant |
830 |
|
$timestamp_log = $this->get_timestamp_log(); |
831 |
|
if ($timestamp_log === false) { |
832 |
|
return false; |
833 |
|
} |
834 |
|
|
835 |
|
// Vérification des object_id précédent en cas de tentative d'appliquer |
836 |
|
// l'état CANCELED sur la tâche |
837 |
|
if (isset($params['state']) === true |
838 |
|
&& $params['state'] === self::STATUS_CANCELED) { |
839 |
|
// Récupération du journal d'activité de la tâche sous forme de tableau |
840 |
|
// trié par ordre décroissant |
841 |
|
$log = $timestamp_log; |
842 |
|
krsort($log); |
843 |
|
// Pour chaque entrée dans le journal d'activité de la tâche : |
844 |
|
// - vérification de la présence de l'object_id précédent |
845 |
|
// - vérification que l'object_id précédent existe toujours dans la base de données |
846 |
|
// - l'object_id est mise à jour avec la valeur de l'object_id précédent |
847 |
|
// - le state n'est pas modifié |
848 |
|
// - sortie du traitement dès que le premier object_id précédent existant est trouvé |
849 |
|
// - si aucun object_id précédent existant n'est trouvé alors ni le state, ni l'object_id n'est modifiés |
850 |
|
foreach ($log as $key => $value) { |
851 |
|
// |
852 |
|
if (isset($value['prev_object_id']) === true |
853 |
|
&& $this->getVal('object_id') !== $value['prev_object_id']) { |
854 |
|
// Récupère la liste des tables potentielles pour un type de tâche |
855 |
|
$tables = $this->get_tables_by_task_type($this->getVal('type'), $this->getVal('stream')); |
856 |
|
foreach ($tables as $table) { |
857 |
|
// Vérifie s'il y a un ou aucun résultat |
858 |
|
$query = sprintf(' |
859 |
|
SELECT COUNT(%2$s) |
860 |
|
FROM %1$s%2$s |
861 |
|
WHERE %2$s::CHARACTER VARYING = \'%3$s\' |
862 |
|
', |
863 |
|
DB_PREFIXE, |
864 |
|
$table, |
865 |
|
$value['prev_object_id'] |
866 |
|
); |
867 |
|
$res = $this->f->get_one_result_from_db_query($query, true); |
868 |
|
if ($res['code'] === 'KO') { |
869 |
|
return $this->end_treatment(__METHOD__, false); |
870 |
|
} |
871 |
|
// Affectation des valeurs et sortie de la boucle |
872 |
|
if ($res['result'] == '1') { |
873 |
|
$params['object_id'] = $value['prev_object_id']; |
874 |
|
$params['state'] = $this->getVal('state'); |
875 |
|
break; |
876 |
|
} |
877 |
|
} |
878 |
|
// Sortie de la boucle si les valeurs sont affectées |
879 |
|
if ($params['object_id'] !== null |
880 |
|
&& $params['object_id'] === $value['prev_object_id']) { |
881 |
|
// |
882 |
|
break; |
883 |
|
} |
884 |
|
} |
885 |
|
} |
886 |
|
} |
887 |
|
|
888 |
|
// Mise à jour du journal d'activité de la tâche |
889 |
|
array_push($timestamp_log, array( |
890 |
|
'modification_date' => date('Y-m-d H:i:s'), |
891 |
|
'object_id' => $params['object_id'] !== null ? $params['object_id'] : $this->getVal('object_id'), |
892 |
|
'prev_object_id' => $this->getVal('object_id'), |
893 |
|
'state' => $params['state'], |
894 |
|
'prev_state' => $this->getVal('state'), |
895 |
|
'comment' => isset($params['comment']) ? $params['comment'] : $this->getVal('comment'), |
896 |
|
)); |
897 |
|
// |
898 |
|
$timestamp_log = json_encode($timestamp_log); |
899 |
|
|
900 |
|
|
901 |
|
// Les nouvelles valeurs après vérification des critères |
902 |
|
$result = array( |
903 |
|
'timestamp_log' => $timestamp_log, |
904 |
|
'object_id' => $params['object_id'], |
905 |
|
'state' => $params['state'], |
906 |
|
'comment' => $params['comment'], |
907 |
|
); |
908 |
|
return $result; |
909 |
|
} |
910 |
|
|
911 |
|
|
912 |
|
/** |
913 |
|
* TRIGGER - triggermodifierapres. |
914 |
|
* |
915 |
|
* @param string $id |
916 |
|
* @param null &$dnu1 @deprecated Ne pas utiliser. |
917 |
|
* @param array $val Tableau des valeurs brutes. |
918 |
|
* @param null $dnu2 @deprecated Ne pas utiliser. |
919 |
|
* |
920 |
|
* @return boolean |
921 |
|
*/ |
922 |
|
public function triggermodifierapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
923 |
|
parent::triggermodifierapres($id, $dnu1, $val, $dnu2); |
924 |
|
|
925 |
|
// Suivi des notificiations |
926 |
|
// En cas de changement de l'état de la tâche de notification, alors |
927 |
|
// le suivi des dates de la notification et de l'instruction, est effectué |
928 |
|
if (isset($val['category']) === true |
929 |
|
&& $val['category'] === 'portal' |
930 |
|
&& isset($val['type']) === true |
931 |
|
&& ($val['type'] === 'notification_recepisse' |
932 |
|
|| $val['type'] === 'notification_instruction' |
933 |
|
|| $val['type'] === 'notification_decision' |
934 |
|
|| $val['type'] === 'notification_service_consulte' |
935 |
|
|| $val['type'] === 'notification_tiers_consulte')) { |
936 |
|
// |
937 |
|
if (isset($this->valF['state']) === true |
938 |
|
&& $this->valF['state'] !== $this->getVal('state') |
939 |
|
&& $this->valF['state'] !== self::STATUS_CANCELED) { |
940 |
|
// |
941 |
|
$inst_in = $this->f->get_inst__om_dbform(array( |
942 |
|
"obj" => "instruction_notification", |
943 |
|
"idx" => $val['object_id'], |
944 |
|
)); |
945 |
|
$valF_in = array(); |
946 |
|
foreach ($inst_in->champs as $champ) { |
947 |
|
$valF_in[$champ] = $inst_in->getVal($champ); |
948 |
|
} |
949 |
|
// Par défaut la date d'envoi et la date de premier accès sur |
950 |
|
// la notification ne sont pas renseignées |
951 |
|
$valF_in['date_envoi'] = null; |
952 |
|
$valF_in['date_premier_acces'] = null; |
953 |
|
// Lorsque la tâche est correctement traitée |
954 |
|
if ($this->valF['state'] === self::STATUS_DONE) { |
955 |
|
// |
956 |
|
$valF_in['statut'] = __("envoyé"); |
957 |
|
$valF_in['commentaire'] = __("Notification traitée"); |
958 |
|
$valF_in['date_envoi'] = date('d/m/Y H:i:s'); |
959 |
|
// Si l'instruction possède un document lié, alors ses dates |
960 |
|
// de suivi sont mises à jour |
961 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
962 |
|
"obj" => "instruction", |
963 |
|
"idx" => $inst_in->getVal('instruction'), |
964 |
|
)); |
965 |
|
if ($inst_instruction->has_an_edition() === true) { |
966 |
|
$valF_instruction = array(); |
967 |
|
foreach ($inst_instruction->champs as $champ) { |
968 |
|
$valF_instruction[$champ] = $inst_instruction->getVal($champ); |
969 |
|
} |
970 |
|
$valF_instruction['date_envoi_rar'] = date('d/m/Y'); |
971 |
|
$valF_instruction['date_retour_rar'] = date('d/m/Y', strtotime('now + 1 day')); |
972 |
|
$inst_instruction->setParameter('maj', 1); |
973 |
|
$update_instruction = $inst_instruction->modifier($valF_instruction); |
974 |
|
if ($update_instruction === false) { |
975 |
|
$this->addToLog(__METHOD__."(): ".$inst_instruction->msg, DEBUG_MODE); |
976 |
|
return false; |
977 |
|
} |
978 |
|
} |
979 |
|
} |
980 |
|
// En cas d'erreur lors du traitement de la task |
981 |
|
if ($this->valF['state'] === self::STATUS_ERROR) { |
982 |
|
$valF_in['statut'] = __("échec"); |
983 |
|
$valF_in['commentaire'] = __("Le traitement de la notification a échoué"); |
984 |
|
} |
985 |
|
// Met à jour la notification |
986 |
|
$inst_in->setParameter('maj', 1); |
987 |
|
$update_in = $inst_in->modifier($valF_in); |
988 |
|
if ($update_in === false) { |
989 |
|
$this->addToLog(__METHOD__."(): ".$inst_in->msg, DEBUG_MODE); |
990 |
|
return false; |
991 |
|
} |
992 |
|
} |
993 |
|
} |
994 |
|
|
995 |
|
// Envoi au contrôle de légalité |
996 |
|
// En cas de changement de l'état de la tâche envoi_CL, alors le suivi |
997 |
|
// des dates de l'instruction est effectué |
998 |
|
if ($val['type'] === 'envoi_CL' |
999 |
|
&& isset($this->valF['state']) === true |
1000 |
|
&& $this->valF['state'] === self::STATUS_DONE) { |
1001 |
|
// |
1002 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
1003 |
|
"obj" => "instruction", |
1004 |
|
"idx" => $this->getVal('object_id'), |
1005 |
|
)); |
1006 |
|
if ($inst_instruction->has_an_edition() === true) { |
1007 |
|
$valF_instruction = array(); |
1008 |
|
foreach ($inst_instruction->champs as $champ) { |
1009 |
|
$valF_instruction[$champ] = $inst_instruction->getVal($champ); |
1010 |
|
} |
1011 |
|
} |
1012 |
|
$valF_instruction['date_envoi_controle_legalite'] = date("Y-m-d"); |
1013 |
|
$inst_instruction->setParameter('maj', 1); |
1014 |
|
$update_instruction = $inst_instruction->modifier($valF_instruction); |
1015 |
|
if ($update_instruction === false) { |
1016 |
|
$this->addToLog(__METHOD__."(): ".$inst_instruction->msg, DEBUG_MODE); |
1017 |
|
return false; |
1018 |
|
} |
1019 |
|
} |
1020 |
|
|
1021 |
|
// |
1022 |
|
return true; |
1023 |
|
} |
1024 |
|
|
1025 |
|
/** |
1026 |
* TREATMENT - add_task |
* TREATMENT - add_task |
1027 |
* Ajoute un enregistrement. |
* Ajoute un enregistrement. |
1028 |
* |
* |
1031 |
*/ |
*/ |
1032 |
public function add_task($params = array()) { |
public function add_task($params = array()) { |
1033 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
1034 |
$timestamp_log = json_encode(array( |
|
1035 |
'creation_date' => date('Y-m-d H:i:s'), |
// Vérifie si la task doit être ajoutée en fonction du mode de l'application, |
1036 |
)); |
// seulement pour les tasks output |
1037 |
|
$task_types_si = self::TASK_TYPE_SI; |
1038 |
|
$task_types_sc = self::TASK_TYPE_SC; |
1039 |
|
$stream = isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output'; |
1040 |
|
if ($stream === 'output' |
1041 |
|
&& isset($params['val']['type']) === true |
1042 |
|
&& $this->f->is_option_mode_service_consulte_enabled() === true |
1043 |
|
&& in_array($params['val']['type'], $task_types_sc) === false) { |
1044 |
|
// |
1045 |
|
return $this->end_treatment(__METHOD__, true); |
1046 |
|
} |
1047 |
|
if ($stream === 'output' |
1048 |
|
&& isset($params['val']['type']) === true |
1049 |
|
&& $this->f->is_option_mode_service_consulte_enabled() === false |
1050 |
|
&& in_array($params['val']['type'], $task_types_si) === false) { |
1051 |
|
// |
1052 |
|
return $this->end_treatment(__METHOD__, true); |
1053 |
|
} |
1054 |
|
|
1055 |
|
// |
1056 |
|
$timestamp_log = json_encode(array()); |
1057 |
|
|
1058 |
|
// |
1059 |
|
$category = isset($params['val']['category']) === true ? $params['val']['category'] : $this->category; |
1060 |
|
|
1061 |
|
// Si la tâche est de type ajout_piece et de stream input alors on ajoute le fichier |
1062 |
|
// et on ajoute l'uid dans le champ json_payload avant l'ajout de la tâche |
1063 |
|
if (isset($params['val']['type']) |
1064 |
|
&& ($params['val']['type'] == "add_piece" || $params['val']['type'] == "avis_consultation") |
1065 |
|
&& isset($params['val']['stream']) |
1066 |
|
&& $params['val']['stream'] == "input" ) { |
1067 |
|
// |
1068 |
|
$json_payload = json_decode($params['val']['json_payload'], true); |
1069 |
|
if (json_last_error() !== JSON_ERROR_NONE) { |
1070 |
|
$this->addToMessage(__("Le contenu JSON de la tâche n'est pas valide.")); |
1071 |
|
return $this->end_treatment(__METHOD__, false); |
1072 |
|
} |
1073 |
|
if (isset($json_payload['document_numerise']["file_content"]) === true |
1074 |
|
&& empty($json_payload['document_numerise']["file_content"]) === false) { |
1075 |
|
// |
1076 |
|
$document_numerise = $json_payload['document_numerise']; |
1077 |
|
$file_content = base64_decode($document_numerise["file_content"]); |
1078 |
|
if ($file_content === false){ |
1079 |
|
$this->addToMessage(__("Le contenu du fichier lié à la tâche n'a pas pu etre recupere.")); |
1080 |
|
return $this->end_treatment(__METHOD__, false); |
1081 |
|
} |
1082 |
|
$metadata = array( |
1083 |
|
"filename" => $document_numerise['nom_fichier'], |
1084 |
|
"size" => strlen($file_content), |
1085 |
|
"mimetype" => $document_numerise['file_content_type'], |
1086 |
|
"date_creation" => isset($document_numerise['date_creation']) === true ? $document_numerise['date_creation'] : date("Y-m-d"), |
1087 |
|
); |
1088 |
|
$uid_fichier = $this->f->storage->create($file_content, $metadata, "from_content", "task.uid_fichier"); |
1089 |
|
if ($uid_fichier === OP_FAILURE) { |
1090 |
|
$this->addToMessage(__("Erreur lors de la creation du fichier lié à la tâche.")); |
1091 |
|
return $this->end_treatment(__METHOD__, false); |
1092 |
|
} |
1093 |
|
$json_payload["document_numerise"]["uid"] = $uid_fichier; |
1094 |
|
// Le fichier a été ajouté nous n'avons plus besoin du champ file_content dans la payload |
1095 |
|
unset($json_payload["document_numerise"]["file_content"]); |
1096 |
|
$params['val']['json_payload'] = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
1097 |
|
} |
1098 |
|
} |
1099 |
|
|
1100 |
// Mise à jour du DI |
// Mise à jour du DI |
1101 |
$valF = array( |
$valF = array( |
1102 |
'task' => '', |
'task' => '', |
1103 |
'type' => $params['val']['type'], |
'type' => $params['val']['type'], |
1104 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
1105 |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : 'new', |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : self::STATUS_NEW, |
1106 |
'object_id' => $params['val']['object_id'], |
'object_id' => isset($params['val']['object_id']) ? $params['val']['object_id'] : '', |
1107 |
|
'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '', |
1108 |
|
'stream' => $stream, |
1109 |
|
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
1110 |
|
'category' => $category, |
1111 |
|
'creation_date' => date('Y-m-d'), |
1112 |
|
'creation_time' => date('H:i:s'), |
1113 |
|
'last_modification_date' => null, |
1114 |
|
'last_modification_time' => null, |
1115 |
|
'comment' => null, |
1116 |
); |
); |
1117 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
|
1118 |
if ($task_exists !== false) { |
// tâche sortante |
1119 |
$inst_task = $this->f->get_inst__om_dbform(array( |
$typeNonConcerne = array( |
1120 |
"obj" => "task", |
'notification_recepisse', |
1121 |
"idx" => $task_exists, |
'notification_instruction', |
1122 |
)); |
'notification_decision', |
1123 |
$update_params = array( |
'notification_service_consulte', |
1124 |
'val' => array( |
'notification_tiers_consulte' |
1125 |
'state' => $inst_task->getVal('state'), |
); |
1126 |
), |
if ($valF["stream"] == "output" |
1127 |
); |
&& ! in_array($valF['type'], $typeNonConcerne)) { |
1128 |
return $inst_task->update_task($update_params); |
// TODO expliquer ce code |
1129 |
|
$task_exists = $this->task_exists($valF['type'], $valF['object_id'], $valF['dossier']); |
1130 |
|
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
1131 |
|
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
1132 |
|
} |
1133 |
|
if ($valF['type'] === 'modification_DA' && $task_exists === false) { |
1134 |
|
$task_exists = $this->task_exists('creation_DA', $valF['object_id']); |
1135 |
|
} |
1136 |
|
if ($valF['type'] === 'ajout_piece') { |
1137 |
|
$task_exists = $this->task_exists('ajout_piece', $valF['object_id']); |
1138 |
|
} |
1139 |
|
if ($valF['type'] === 'creation_consultation') { |
1140 |
|
$task_exists = $this->task_exists('creation_consultation', $valF['object_id']); |
1141 |
|
} |
1142 |
|
if ($task_exists !== false) { |
1143 |
|
$inst_task = $this->f->get_inst__om_dbform(array( |
1144 |
|
"obj" => "task", |
1145 |
|
"idx" => $task_exists, |
1146 |
|
)); |
1147 |
|
$update_state = $inst_task->getVal('state'); |
1148 |
|
if (isset($params['update_val']['state']) === true) { |
1149 |
|
$update_state = $params['update_val']['state']; |
1150 |
|
} |
1151 |
|
$update_params = array( |
1152 |
|
'val' => array( |
1153 |
|
'state' => $update_state, |
1154 |
|
), |
1155 |
|
'object_id' => $valF['object_id'], |
1156 |
|
); |
1157 |
|
return $inst_task->update_task($update_params); |
1158 |
|
} |
1159 |
} |
} |
1160 |
$add = $this->ajouter($valF); |
$add = $this->ajouter($valF); |
1161 |
|
$this->addToLog(__METHOD__."(): retour de l'ajout de tâche: ".var_export($add, true), VERBOSE_MODE); |
1162 |
if ($add === false) { |
if ($add === false) { |
1163 |
$this->addToLog($this->msg, DEBUG_MODE); |
$this->addToLog(__METHOD__."(): ".$this->msg, DEBUG_MODE); |
1164 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
1165 |
} |
} |
1166 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
1175 |
*/ |
*/ |
1176 |
public function update_task($params = array()) { |
public function update_task($params = array()) { |
1177 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
1178 |
$timestamp_log = $this->get_timestamp_log(); |
|
1179 |
if ($timestamp_log === false) { |
// Mise à jour de la tâche |
|
$this->addToLog(__('XXX'), DEBUG_MODE); |
|
|
return $this->end_treatment(__METHOD__, false); |
|
|
} |
|
|
array_push($timestamp_log, array( |
|
|
'modification_date' => date('Y-m-d H:i:s'), |
|
|
'state' => $params['val']['state'], |
|
|
'prev_state' => $this->getVal('state'), |
|
|
)); |
|
|
$timestamp_log = json_encode($timestamp_log); |
|
1180 |
$valF = array( |
$valF = array( |
1181 |
'task' => $this->getVal($this->clePrimaire), |
'task' => $this->getVal($this->clePrimaire), |
1182 |
'type' => $this->getVal('type'), |
'type' => $this->getVal('type'), |
1183 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => '[]', |
1184 |
'state' => $params['val']['state'], |
'state' => $params['val']['state'], |
1185 |
'object_id' => $this->getVal('object_id'), |
'object_id' => isset($params['object_id']) == true ? $params['object_id'] : $this->getVal('object_id'), |
1186 |
|
'stream' => $this->getVal('stream'), |
1187 |
|
'dossier' => $this->getVal('dossier'), |
1188 |
|
'json_payload' => $this->getVal('json_payload'), |
1189 |
|
'category' => $this->getVal('category'), |
1190 |
|
'creation_date' => $this->getVal('creation_date'), |
1191 |
|
'creation_time' => $this->getVal('creation_time'), |
1192 |
|
'last_modification_date' => date('Y-m-d'), |
1193 |
|
'last_modification_time' => date('H:i:s'), |
1194 |
|
'comment' => $this->getVal('comment'), |
1195 |
); |
); |
1196 |
$update = $this->modifier($valF); |
$update = $this->modifier($valF); |
1197 |
if ($update === false) { |
if ($update === false) { |
1204 |
/** |
/** |
1205 |
* Récupère le journal d'horodatage dans le champ timestamp_log de |
* Récupère le journal d'horodatage dans le champ timestamp_log de |
1206 |
* l'enregistrement instancié. |
* l'enregistrement instancié. |
1207 |
* |
* |
1208 |
* @param array $params Tableau des paramètres |
* @param array $params Tableau des paramètres |
1209 |
* @return array sinon false en cas d'erreur |
* @return array sinon false en cas d'erreur |
1210 |
*/ |
*/ |
1240 |
|
|
1241 |
protected function view_tab_json() { |
protected function view_tab_json() { |
1242 |
$where = ''; |
$where = ''; |
1243 |
if ($this->f->get_submitted_get_value('state') !== null |
$category = null; |
1244 |
&& $this->f->get_submitted_get_value('state') !== '') { |
// Liste des paramètres possibles pour la recherche des tâches |
1245 |
|
$params = array( |
1246 |
|
'task', |
1247 |
|
'type', |
1248 |
|
'state', |
1249 |
|
'object_id', |
1250 |
|
'dossier', |
1251 |
|
'stream', |
1252 |
|
'category', |
1253 |
|
'lien_id_interne_uid_externe', |
1254 |
|
'object', |
1255 |
|
'external_uid', |
1256 |
|
); |
1257 |
|
// Pour chaque paramètre possible, vérification de son existance et de sa |
1258 |
|
// valeur pour compléter la requête de recherche |
1259 |
|
foreach ($params as $param) { |
1260 |
// |
// |
1261 |
$where = sprintf(' WHERE state = \'%s\' ', $this->f->get_submitted_get_value('state')); |
if ($this->f->get_submitted_get_value($param) !== null |
1262 |
|
&& $this->f->get_submitted_get_value($param) !== '') { |
1263 |
|
// Condition spécifique au champ 'category' |
1264 |
|
if ($param === 'category') { |
1265 |
|
$category = $this->f->get_submitted_get_value('category'); |
1266 |
|
} |
1267 |
|
// |
1268 |
|
$where_or_and = 'WHERE'; |
1269 |
|
if ($where !== '') { |
1270 |
|
$where_or_and = 'AND'; |
1271 |
|
} |
1272 |
|
$table = 'task'; |
1273 |
|
if ($param === 'lien_id_interne_uid_externe' |
1274 |
|
|| $param === 'object' |
1275 |
|
|| $param === 'external_uid') { |
1276 |
|
// |
1277 |
|
$table = 'lien_id_interne_uid_externe'; |
1278 |
|
} |
1279 |
|
$where .= sprintf(' %s %s.%s = \'%s\' ', $where_or_and, $table, $param, $this->f->get_submitted_get_value($param)); |
1280 |
|
} |
1281 |
} |
} |
1282 |
|
// |
1283 |
$query = sprintf(' |
$query = sprintf(' |
1284 |
SELECT |
SELECT |
1285 |
* |
task.* |
1286 |
FROM %1$stask |
FROM %1$stask |
1287 |
|
LEFT JOIN %1$slien_id_interne_uid_externe |
1288 |
|
ON task.object_id = lien_id_interne_uid_externe.object_id |
1289 |
|
AND task.category = lien_id_interne_uid_externe.category |
1290 |
%2$s |
%2$s |
1291 |
|
ORDER BY task ASC |
1292 |
', |
', |
1293 |
DB_PREFIXE, |
DB_PREFIXE, |
1294 |
$where |
$where |
1299 |
} |
} |
1300 |
$list_tasks = array(); |
$list_tasks = array(); |
1301 |
foreach ($res['result'] as $task) { |
foreach ($res['result'] as $task) { |
1302 |
|
unset($task['timestamp_log']); |
1303 |
|
unset($task['json_payload']); |
1304 |
|
if ($task['type'] === 'ajout_piece') { |
1305 |
|
$val_dn = $this->get_document_numerise_data($task['object_id']); |
1306 |
|
} |
1307 |
|
if ($task['stream'] === 'output') { |
1308 |
|
$task['external_uids'] = array_merge( |
1309 |
|
$this->get_all_external_uids($task['dossier'], array(), $category !== null ? $category : $task['category']), |
1310 |
|
$this->get_all_external_uids($task['object_id'], array(), $category !== null ? $category : $task['category']) |
1311 |
|
); |
1312 |
|
} |
1313 |
$list_tasks[$task['task']] = $task; |
$list_tasks[$task['task']] = $task; |
1314 |
} |
} |
1315 |
printf(json_encode($list_tasks)); |
echo(json_encode($list_tasks)); |
1316 |
} |
} |
1317 |
|
|
1318 |
protected function get_dossier_data(string $dossier) { |
protected function get_dossier_data(string $dossier) { |
1321 |
"obj" => "dossier", |
"obj" => "dossier", |
1322 |
"idx" => $dossier, |
"idx" => $dossier, |
1323 |
)); |
)); |
1324 |
$val_di = json_decode($inst_di->get_json_data(), true); |
if (empty($inst_di->val) === true) { |
1325 |
|
return $val_di; |
1326 |
|
} |
1327 |
|
$val_di = $inst_di->get_json_data(); |
1328 |
if ($val_di['dossier_instruction_type_code'] === 'T') { |
if ($val_di['dossier_instruction_type_code'] === 'T') { |
1329 |
$val_di['date_decision_transfert'] = $val_di['date_decision']; |
$val_di['date_decision_transfert'] = $val_di['date_decision']; |
1330 |
} |
} |
1339 |
"obj" => "dossier_autorisation", |
"obj" => "dossier_autorisation", |
1340 |
"idx" => $da, |
"idx" => $da, |
1341 |
)); |
)); |
1342 |
$val_da = json_decode($inst_da->get_json_data(), true); |
$val_da = $inst_da->get_json_data(); |
1343 |
return $val_da; |
return $val_da; |
1344 |
} |
} |
1345 |
|
|
1361 |
$val_dt['am_exist_date_num'] = $val_dt['am_exist_date']; |
$val_dt['am_exist_date_num'] = $val_dt['am_exist_date']; |
1362 |
} |
} |
1363 |
} |
} |
1364 |
|
// Correspond à la nomenclature de Plat'AU STATUT_INFO |
1365 |
|
$val_dt['tax_statut_info'] = 'Déclaré'; |
1366 |
|
// |
1367 |
|
if ($inst_dt->is_tab_surf_ssdest_enabled() === true) { |
1368 |
|
$fields_tab_surf_dest = $inst_dt->get_fields_tab_surf_dest(); |
1369 |
|
foreach ($fields_tab_surf_dest as $field) { |
1370 |
|
if (isset($val_dt[$field]) === true) { |
1371 |
|
unset($val_dt[$field]); |
1372 |
|
} |
1373 |
|
} |
1374 |
|
} else { |
1375 |
|
$fields_tab_surf_ssdest = $inst_dt->get_fields_tab_surf_ssdest(); |
1376 |
|
foreach ($fields_tab_surf_ssdest as $field) { |
1377 |
|
if (isset($val_dt[$field]) === true) { |
1378 |
|
unset($val_dt[$field]); |
1379 |
|
} |
1380 |
|
} |
1381 |
|
} |
1382 |
|
// Correspond à la nouvelle ligne CERFA v7 dans le DENSI imposition 1.2.3 |
1383 |
|
if (isset($val_dt['tax_su_non_habit_surf2']) === true |
1384 |
|
&& isset($val_dt['tax_su_non_habit_surf3']) === true |
1385 |
|
&& (($val_dt['tax_su_non_habit_surf2'] !== null |
1386 |
|
&& $val_dt['tax_su_non_habit_surf2'] !== '') |
1387 |
|
|| ($val_dt['tax_su_non_habit_surf3'] !== null |
1388 |
|
&& $val_dt['tax_su_non_habit_surf3'] !== ''))) { |
1389 |
|
// |
1390 |
|
$val_dt['tax_su_non_habit_surf8'] = intval($val_dt['tax_su_non_habit_surf2']) + intval($val_dt['tax_su_non_habit_surf3']); |
1391 |
|
} |
1392 |
|
if (isset($val_dt['tax_su_non_habit_surf_stat2']) === true |
1393 |
|
&& isset($val_dt['tax_su_non_habit_surf_stat3']) === true |
1394 |
|
&& (($val_dt['tax_su_non_habit_surf_stat2'] !== null |
1395 |
|
&& $val_dt['tax_su_non_habit_surf_stat2'] !== '') |
1396 |
|
|| ($val_dt['tax_su_non_habit_surf_stat3'] !== null |
1397 |
|
&& $val_dt['tax_su_non_habit_surf_stat3'] !== ''))) { |
1398 |
|
// |
1399 |
|
$val_dt['tax_su_non_habit_surf_stat8'] = intval($val_dt['tax_su_non_habit_surf_stat2']) + intval($val_dt['tax_su_non_habit_surf_stat3']); |
1400 |
|
} |
1401 |
|
// Cas particulier d'un projet réduit à l'extension d'une habitation existante |
1402 |
|
$particular_case = false; |
1403 |
|
$fields_tab_crea_loc_hab = $inst_dt->get_fields_tab_crea_loc_hab(); |
1404 |
|
foreach ($fields_tab_crea_loc_hab as $field) { |
1405 |
|
if (isset($val_dt[$field]) === false |
1406 |
|
|| (isset($val_dt[$field]) === true |
1407 |
|
&& ($val_dt[$field] === null |
1408 |
|
|| $val_dt[$field] === ''))) { |
1409 |
|
// |
1410 |
|
$particular_case = true; |
1411 |
|
} |
1412 |
|
} |
1413 |
|
if ($particular_case === true) { |
1414 |
|
if (isset($val_dt['tax_ext_pret']) === true |
1415 |
|
&& $val_dt['tax_ext_pret'] === 'f') { |
1416 |
|
// |
1417 |
|
$val_dt['tax_su_princ_surf1'] = $val_dt['tax_surf_tot_cstr']; |
1418 |
|
$val_dt['tax_su_princ_surf_stat1'] = $val_dt['tax_surf_loc_stat']; |
1419 |
|
} |
1420 |
|
if (isset($val_dt['tax_ext_pret']) === true |
1421 |
|
&& $val_dt['tax_ext_pret'] === 't') { |
1422 |
|
// |
1423 |
|
if (isset($val_dt['tax_ext_desc']) === true) { |
1424 |
|
if (preg_match('/[pP].*[lL].*[aA].*[iI]/', $val_dt['tax_ext_desc']) === 1 |
1425 |
|
|| preg_match('/[lL].*[lL].*[tT].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
1426 |
|
// |
1427 |
|
$val_dt['tax_su_princ_surf2'] = $val_dt['tax_surf_tot_cstr']; |
1428 |
|
$val_dt['tax_su_princ_surf_stat2'] = $val_dt['tax_surf_loc_stat']; |
1429 |
|
} |
1430 |
|
// if (preg_match('/[pP].*[tT].*[zZ]/', $val_dt['tax_ext_desc']) === 1) { |
1431 |
|
// $val_dt['tax_su_princ_surf4'] = $val_dt['tax_surf_tot_cstr']; |
1432 |
|
// $val_dt['tax_su_princ_surf_stat4'] = $val_dt['tax_surf_loc_stat']; |
1433 |
|
// } |
1434 |
|
// if (preg_match('/[pP].*[lL].*[uU].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
1435 |
|
// || preg_match('/[lL].*[eE].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
1436 |
|
// || preg_match('/[pP].*[sS].*[lL].*[aA]/', $val_dt['tax_ext_desc']) === 1 |
1437 |
|
// || preg_match('/[pP].*[lL].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
1438 |
|
// || preg_match('/[lL].*[lL].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
1439 |
|
// // |
1440 |
|
// $val_dt['tax_su_princ_surf3'] = $val_dt['tax_surf_tot_cstr']; |
1441 |
|
// $val_dt['tax_su_princ_surf_stat3'] = $val_dt['tax_surf_loc_stat']; |
1442 |
|
// } |
1443 |
|
} |
1444 |
|
} |
1445 |
|
} |
1446 |
|
// Cas particulier de la surface taxable démolie |
1447 |
|
if (isset($val_dt['tax_surf_tot_demo']) === true |
1448 |
|
&& isset($val_dt['tax_surf_tax_demo']) === true |
1449 |
|
&& ($val_dt['tax_surf_tot_demo'] === null |
1450 |
|
|| $val_dt['tax_surf_tot_demo'] === '')) { |
1451 |
|
// |
1452 |
|
$val_dt['tax_surf_tot_demo'] = $val_dt['tax_surf_tax_demo']; |
1453 |
|
} |
1454 |
return $val_dt; |
return $val_dt; |
1455 |
} |
} |
1456 |
|
|
1457 |
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
/** |
1458 |
$inst_external_uid_da = $this->f->get_inst__by_other_idx(array( |
* Récupère la liste des objets distincts existants dans la table des liens |
1459 |
|
* entre identifiants internes et identifiants externes. |
1460 |
|
* |
1461 |
|
* @return array |
1462 |
|
*/ |
1463 |
|
protected function get_list_distinct_objects_external_link() { |
1464 |
|
$query = sprintf(' |
1465 |
|
SELECT |
1466 |
|
DISTINCT(object) |
1467 |
|
FROM %1$slien_id_interne_uid_externe |
1468 |
|
ORDER BY object ASC |
1469 |
|
', |
1470 |
|
DB_PREFIXE |
1471 |
|
); |
1472 |
|
$res = $this->f->get_all_results_from_db_query($query, true); |
1473 |
|
if ($res['code'] === 'KO') { |
1474 |
|
return array(); |
1475 |
|
} |
1476 |
|
$result = array(); |
1477 |
|
foreach ($res['result'] as $object) { |
1478 |
|
$result[] = $object['object']; |
1479 |
|
} |
1480 |
|
return $result; |
1481 |
|
} |
1482 |
|
|
1483 |
|
protected function get_external_uid($fk_idx, string $fk_idx_2, $fk_idx_3 = 'platau', $order_asc_desc = 'DESC') { |
1484 |
|
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
1485 |
"obj" => "lien_id_interne_uid_externe", |
"obj" => "lien_id_interne_uid_externe", |
1486 |
"fk_field" => 'object_id', |
"fk_field" => 'object_id', |
1487 |
"fk_idx" => $fk_idx, |
"fk_idx" => $fk_idx, |
1488 |
"fk_field_2" => 'object', |
"fk_field_2" => 'object', |
1489 |
"fk_idx_2" => $fk_idx_2, |
"fk_idx_2" => $fk_idx_2, |
1490 |
|
"fk_field_3" => 'category', |
1491 |
|
"fk_idx_3" => $fk_idx_3, |
1492 |
|
"order_field" => 'lien_id_interne_uid_externe', |
1493 |
|
"order_asc_desc" => $order_asc_desc, |
1494 |
)); |
)); |
1495 |
return $inst_external_uid_da->getVal('external_uid'); |
return $inst_external_uid->getVal('external_uid'); |
1496 |
} |
} |
1497 |
|
|
1498 |
protected function get_demandeurs_data(string $dossier) { |
protected function get_all_external_uids($fk_idx, $link_objects = array(), $category='platau') { |
1499 |
|
if (count($link_objects) == 0) { |
1500 |
|
$link_objects = $this->get_list_distinct_objects_external_link(); |
1501 |
|
} |
1502 |
|
$val_external_uid = array(); |
1503 |
|
foreach ($link_objects as $link_object) { |
1504 |
|
$external_uid = $this->get_external_uid($fk_idx, $link_object, $category); |
1505 |
|
if ($external_uid !== '' && $external_uid !== null) { |
1506 |
|
$val_external_uid[$link_object] = $external_uid; |
1507 |
|
} |
1508 |
|
} |
1509 |
|
return $val_external_uid; |
1510 |
|
} |
1511 |
|
|
1512 |
|
protected function get_demandeurs_data($dossier) { |
1513 |
$val_demandeur = array(); |
$val_demandeur = array(); |
1514 |
|
if ($dossier === null) { |
1515 |
|
return $val_demandeur; |
1516 |
|
} |
1517 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
1518 |
"obj" => "dossier", |
"obj" => "dossier", |
1519 |
"idx" => $dossier, |
"idx" => $dossier, |
1524 |
"obj" => "demandeur", |
"obj" => "demandeur", |
1525 |
"idx" => $demandeur['demandeur'], |
"idx" => $demandeur['demandeur'], |
1526 |
)); |
)); |
1527 |
$val_demandeur[$demandeur['demandeur']] = json_decode($inst_demandeur->get_json_data(), true); |
$val_demandeur[$demandeur['demandeur']] = $inst_demandeur->get_json_data(); |
1528 |
$val_demandeur[$demandeur['demandeur']]['petitionnaire_principal'] = $demandeur['petitionnaire_principal']; |
$val_demandeur[$demandeur['demandeur']]['petitionnaire_principal'] = $demandeur['petitionnaire_principal']; |
1529 |
} |
} |
1530 |
return $val_demandeur; |
return $val_demandeur; |
1531 |
} |
} |
1532 |
|
|
1533 |
protected function get_architecte_data($architecte = null) { |
protected function get_architecte_data($architecte = null) { |
1534 |
$val_architecte = array(); |
$val_architecte = null; |
1535 |
if ($architecte !== null |
if ($architecte !== null |
1536 |
&& $architecte !== '') { |
&& $architecte !== '') { |
1537 |
// |
// |
1539 |
"obj" => "architecte", |
"obj" => "architecte", |
1540 |
"idx" => $architecte, |
"idx" => $architecte, |
1541 |
)); |
)); |
1542 |
$val_architecte = json_decode($inst_architecte->get_json_data(), true); |
$val_architecte = $inst_architecte->get_json_data(); |
1543 |
} |
} |
1544 |
return $val_architecte; |
return $val_architecte; |
1545 |
} |
} |
1546 |
|
|
1547 |
protected function get_instruction_data(string $dossier) { |
protected function get_instruction_data($dossier, $type = 'decision', $extra_params = array()) { |
1548 |
$val_instruction = array(); |
$val_instruction = null; |
1549 |
|
if ($dossier === null) { |
1550 |
|
return $val_instruction; |
1551 |
|
} |
1552 |
|
$instruction_with_doc = null; |
1553 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
1554 |
"obj" => "dossier", |
"obj" => "dossier", |
1555 |
"idx" => $dossier, |
"idx" => $dossier, |
1556 |
)); |
)); |
1557 |
|
$idx = null; |
1558 |
|
if ($type === 'decision') { |
1559 |
|
$idx = $inst_di->get_last_instruction_decision(); |
1560 |
|
} |
1561 |
|
if ($type === 'incompletude') { |
1562 |
|
$idx = $inst_di->get_last_instruction_incompletude(); |
1563 |
|
} |
1564 |
|
// XXX Permet de récupérer l'instruction par son identifiant |
1565 |
|
if ($type === 'with-id') { |
1566 |
|
$idx = $extra_params['with-id']; |
1567 |
|
} |
1568 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
1569 |
"obj" => "instruction", |
"obj" => "instruction", |
1570 |
"idx" => $inst_di->get_last_instruction_decision(), |
"idx" => $idx, |
1571 |
)); |
)); |
1572 |
if (count($inst_instruction->val) > 0) { |
if (count($inst_instruction->val) > 0) { |
1573 |
$val_instruction = json_decode($inst_instruction->get_json_data(), true); |
$val_instruction = array(); |
1574 |
|
$instruction_data = $inst_instruction->get_json_data(); |
1575 |
|
$val_instruction = $this->sort_instruction_data($instruction_data, $val_instruction); |
1576 |
|
if ($instruction_data['om_fichier_instruction'] !== null |
1577 |
|
&& $instruction_data['om_fichier_instruction'] !== '') { |
1578 |
|
// |
1579 |
|
$instruction_with_doc = $inst_instruction->getVal($inst_instruction->clePrimaire); |
1580 |
|
} |
1581 |
|
$inst_ev = $this->f->get_inst__om_dbform(array( |
1582 |
|
"obj" => "evenement", |
1583 |
|
"idx" => $inst_instruction->getVal('evenement'), |
1584 |
|
)); |
1585 |
|
if ($inst_ev->getVal('retour') === 't') { |
1586 |
|
$instructions_related = $inst_instruction->get_related_instructions(); |
1587 |
|
foreach ($instructions_related as $instruction) { |
1588 |
|
if ($instruction !== null && $instruction !== '') { |
1589 |
|
$inst_related_instruction = $this->f->get_inst__om_dbform(array( |
1590 |
|
"obj" => "instruction", |
1591 |
|
"idx" => $instruction, |
1592 |
|
)); |
1593 |
|
$instruction_data = $inst_related_instruction->get_json_data(); |
1594 |
|
$val_instruction = $this->sort_instruction_data($instruction_data, $val_instruction); |
1595 |
|
if ($instruction_data['om_fichier_instruction'] !== null |
1596 |
|
&& $instruction_data['om_fichier_instruction'] !== '') { |
1597 |
|
// |
1598 |
|
$instruction_with_doc = $inst_related_instruction->getVal($inst_related_instruction->clePrimaire); |
1599 |
|
} |
1600 |
|
} |
1601 |
|
} |
1602 |
|
} |
1603 |
|
if ($instruction_with_doc !== null) { |
1604 |
|
// |
1605 |
|
$val_instruction['path'] = sprintf('%s&snippet=%s&obj=%s&champ=%s&id=%s', 'app/index.php?module=form', 'file', 'instruction', 'om_fichier_instruction', $instruction_with_doc); |
1606 |
|
} |
1607 |
} |
} |
1608 |
return $val_instruction; |
return $val_instruction; |
1609 |
} |
} |
1610 |
|
|
1611 |
|
|
1612 |
|
/** |
1613 |
|
* Récupère les informations pour les notifications ayant plusieurs annexe |
1614 |
|
*/ |
1615 |
|
protected function get_instruction_notification_data($category, $type = '', $extra_params = array()) { |
1616 |
|
$val_in = null; |
1617 |
|
|
1618 |
|
$idx = null; |
1619 |
|
if ($type === 'with-id') { |
1620 |
|
$idx = $extra_params['with-id']; |
1621 |
|
} |
1622 |
|
|
1623 |
|
// Récupération du type de notification. Le type est nécessaire pour récupérer |
1624 |
|
// le message et le titre de notification. |
1625 |
|
$typeNotification = $this->getVal('type'); |
1626 |
|
if (isset($this->valF['type'])) { |
1627 |
|
$typeNotification = $this->valF['type']; |
1628 |
|
} |
1629 |
|
|
1630 |
|
// récupére les données à intégrer à la payload |
1631 |
|
$inst_in = $this->f->get_inst__om_dbform(array( |
1632 |
|
"obj" => "instruction_notification", |
1633 |
|
"idx" => $idx, |
1634 |
|
)); |
1635 |
|
if (count($inst_in->val) > 0) { |
1636 |
|
$val_in = $inst_in->get_json_data(); |
1637 |
|
|
1638 |
|
$val_in['parametre_courriel_type_titre'] = ''; |
1639 |
|
$val_in['parametre_courriel_type_message'] = ''; |
1640 |
|
// Récupération du message et du titre |
1641 |
|
if ($category === 'mail') { |
1642 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
1643 |
|
"obj" => "instruction", |
1644 |
|
"idx" => $inst_in->getVal('instruction'), |
1645 |
|
)); |
1646 |
|
$collectivite_id = $inst_instruction->get_dossier_instruction_om_collectivite($inst_instruction->getVal('dossier')); |
1647 |
|
$phrase_type_notification = $this->f->get_notification_parametre_courriel_type($collectivite_id, $typeNotification); |
1648 |
|
$val_in['parametre_courriel_type_titre'] = $phrase_type_notification['parametre_courriel_type_titre']; |
1649 |
|
$val_in['parametre_courriel_type_message'] = $phrase_type_notification['parametre_courriel_type_message']; |
1650 |
|
} |
1651 |
|
|
1652 |
|
// Récupération des liens vers les documents et des id et type des annexes |
1653 |
|
$infoDocNotif = $inst_in->getInfosDocumentsNotif($inst_in->getVal($inst_in->clePrimaire), $category); |
1654 |
|
$cle = $category == 'portal' ? 'path' : 'lien_telechargement_document'; |
1655 |
|
$val_in[$cle] = $infoDocNotif['document']['path']; |
1656 |
|
$val_in['annexes'] = $infoDocNotif['annexes']; |
1657 |
|
} |
1658 |
|
return $val_in; |
1659 |
|
} |
1660 |
|
|
1661 |
|
protected function sort_instruction_data(array $values, array $res) { |
1662 |
|
$fields = array( |
1663 |
|
"date_evenement", |
1664 |
|
"date_envoi_signature", |
1665 |
|
"date_retour_signature", |
1666 |
|
"date_envoi_rar", |
1667 |
|
"date_retour_rar", |
1668 |
|
"date_envoi_controle_legalite", |
1669 |
|
"date_retour_controle_legalite", |
1670 |
|
"signataire_arrete", |
1671 |
|
"om_fichier_instruction", |
1672 |
|
"tacite", |
1673 |
|
"lettretype", |
1674 |
|
"commentaire", |
1675 |
|
"complement_om_html", |
1676 |
|
); |
1677 |
|
foreach ($values as $key => $value) { |
1678 |
|
if (in_array($key, $fields) === true) { |
1679 |
|
if (array_key_exists($key, $res) === false |
1680 |
|
&& $value !== null |
1681 |
|
&& $value !== '') { |
1682 |
|
// |
1683 |
|
$res[$key] = $value; |
1684 |
|
} elseif ($key === 'tacite' |
1685 |
|
&& $value === 't') { |
1686 |
|
// |
1687 |
|
$res[$key] = $value; |
1688 |
|
} |
1689 |
|
} |
1690 |
|
} |
1691 |
|
return $res; |
1692 |
|
} |
1693 |
|
|
1694 |
|
/** |
1695 |
|
* Permet de définir si l'instruction passée en paramètre est une instruction |
1696 |
|
* récépissé d'une demande et si la demande en question a générée un dossier d'instruction. |
1697 |
|
* |
1698 |
|
* @param integer $instruction Identifiant de l'instruction |
1699 |
|
* @return boolean |
1700 |
|
*/ |
1701 |
|
protected function is_demande_instruction_recepisse_without_dossier($instruction) { |
1702 |
|
if ($instruction === null) { |
1703 |
|
return false; |
1704 |
|
} |
1705 |
|
$query = sprintf(' |
1706 |
|
SELECT demande_type.dossier_instruction_type |
1707 |
|
FROM %1$sdemande |
1708 |
|
INNER JOIN %1$sdemande_type ON demande.demande_type = demande_type.demande_type |
1709 |
|
WHERE demande.instruction_recepisse = %2$s |
1710 |
|
', |
1711 |
|
DB_PREFIXE, |
1712 |
|
$instruction |
1713 |
|
); |
1714 |
|
$res = $this->f->get_one_result_from_db_query( |
1715 |
|
$query, |
1716 |
|
true |
1717 |
|
); |
1718 |
|
if ($res['code'] === 'KO') { |
1719 |
|
return null; |
1720 |
|
} |
1721 |
|
if ($res['result'] === '') { |
1722 |
|
return true; |
1723 |
|
} |
1724 |
|
return false; |
1725 |
|
} |
1726 |
|
|
1727 |
protected function get_document_numerise_data(string $dn) { |
protected function get_document_numerise_data(string $dn) { |
1728 |
$val_dn = array(); |
$val_dn = array(); |
1729 |
$inst_dn = $this->f->get_inst__om_dbform(array( |
$inst_dn = $this->f->get_inst__om_dbform(array( |
1730 |
"obj" => "document_numerise", |
"obj" => "document_numerise", |
1731 |
"idx" => $dn, |
"idx" => $dn, |
1732 |
)); |
)); |
1733 |
$val_dn = json_decode($inst_dn->get_json_data(), true); |
$val_dn = $inst_dn->get_json_data(); |
1734 |
$val_dn['path'] = sprintf('%s/%s&snippet=%s&obj=%s&champ=%s&id=%s', $_SERVER['HTTP_HOST'], 'openads/app/index.php?module=form', 'file', 'document_numerise', 'uid', $this->getVal('object_id')); |
$val_dn['path'] = sprintf('%s&snippet=%s&obj=%s&champ=%s&id=%s', 'app/index.php?module=form', 'file', 'document_numerise', 'uid', $this->getVal('object_id')); |
1735 |
|
// Correspond à la nomenclature Plat'AU NATURE_PIECE |
1736 |
|
$val_dn['nature'] = $val_dn['document_numerise_nature_libelle']; |
1737 |
return $val_dn; |
return $val_dn; |
1738 |
} |
} |
1739 |
|
|
1756 |
return $val_dp; |
return $val_dp; |
1757 |
} |
} |
1758 |
|
|
1759 |
protected function view_form_json() { |
protected function get_avis_decision_data(string $dossier) { |
1760 |
// Mise à jour des valeurs |
$inst_di = $this->f->get_inst__om_dbform(array( |
1761 |
if ($this->f->get_submitted_post_value('valid') === 'true' |
"obj" => "dossier", |
1762 |
&& $this->f->get_submitted_post_value('state') !== null) { |
"idx" => $dossier, |
1763 |
// |
)); |
1764 |
$params = array( |
$ad = $inst_di->getVal('avis_decision'); |
1765 |
'val' => array( |
$val_ad = array(); |
1766 |
'state' => $this->f->get_submitted_post_value('state') |
if ($ad !== null) { |
1767 |
), |
$inst_ad = $this->f->get_inst__om_dbform(array( |
1768 |
); |
"obj" => "avis_decision", |
1769 |
$update = $this->update_task($params); |
"idx" => $ad, |
1770 |
$message_class = "valid"; |
)); |
1771 |
$message = $this->msg; |
$val_ad = $inst_ad->get_json_data(); |
1772 |
if ($update === false) { |
$val_ad['txAvis'] = "Voir document joint"; |
1773 |
$this->addToLog($this->msg, DEBUG_MODE); |
if (isset($val_ad['tacite']) === true |
1774 |
$message_class = "error"; |
&& $val_ad['tacite'] === 't') { |
1775 |
$message = sprintf( |
// |
1776 |
'%s %s', |
$val_ad['txAvis'] = "Sans objet"; |
|
__('Impossible de mettre à jour la tâche.'), |
|
|
__('Veuillez contacter votre administrateur.') |
|
|
); |
|
1777 |
} |
} |
|
$this->f->displayMessage($message_class, $message); |
|
1778 |
} |
} |
1779 |
// |
return $val_ad; |
1780 |
if ($this->f->get_submitted_post_value('valid') === 'true' |
} |
1781 |
&& $this->f->get_submitted_post_value('external_uid') !== null) { |
|
1782 |
|
protected function get_signataire_arrete_data(string $sa) { |
1783 |
|
$inst_sa = $this->f->get_inst__om_dbform(array( |
1784 |
|
"obj" => "signataire_arrete", |
1785 |
|
"idx" => $sa, |
1786 |
|
)); |
1787 |
|
$val_sa = array_combine($inst_sa->champs, $inst_sa->val); |
1788 |
|
foreach ($val_sa as $key => $value) { |
1789 |
|
$val_sa[$key] = strip_tags($value); |
1790 |
|
} |
1791 |
|
return $val_sa; |
1792 |
|
} |
1793 |
|
|
1794 |
|
// XXX WIP |
1795 |
|
protected function get_consultation_data(string $consultation) { |
1796 |
|
$val_consultation = array(); |
1797 |
|
$inst_consultation = $this->f->get_inst__om_dbform(array( |
1798 |
|
"obj" => "consultation", |
1799 |
|
"idx" => $consultation, |
1800 |
|
)); |
1801 |
|
$val_consultation = $inst_consultation->get_json_data(); |
1802 |
|
if (isset($val_consultation['fichier']) === true |
1803 |
|
&& $val_consultation['fichier'] !== '') { |
1804 |
// |
// |
1805 |
$inst_lien = $this->f->get_inst__om_dbform(array( |
$val_consultation['path_fichier'] = sprintf('%s&snippet=%s&obj=%s&champ=%s&id=%s', 'app/index.php?module=form', 'file', 'consultation', 'fichier', $this->getVal('object_id')); |
1806 |
"obj" => "lien_id_interne_uid_externe", |
} |
1807 |
"idx" => ']', |
if (isset($val_consultation['om_fichier_consultation']) === true |
1808 |
)); |
&& $val_consultation['om_fichier_consultation'] !== '') { |
1809 |
$valF = array( |
// |
1810 |
'lien_id_interne_uid_externe' => '', |
$val_consultation['path_om_fichier_consultation'] = sprintf('%s&snippet=%s&obj=%s&champ=%s&id=%s', 'app/index.php?module=form', 'file', 'consultation', 'om_fichier_consultation', $this->getVal('object_id')); |
|
'object' => $this->get_lien_objet_by_type($this->getVal('type')), |
|
|
'object_id' => $this->getVal('object_id'), |
|
|
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
|
|
); |
|
|
$add = $inst_lien->ajouter($valF); |
|
|
$message_class = "valid"; |
|
|
$message = $inst_lien->msg; |
|
|
if ($add === false) { |
|
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
|
|
$message_class = "error"; |
|
|
$message = sprintf( |
|
|
'%s %s', |
|
|
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
|
|
__('Veuillez contacter votre administrateur.') |
|
|
); |
|
|
} |
|
|
$this->f->displayMessage($message_class, $message); |
|
1811 |
} |
} |
1812 |
|
return $val_consultation; |
1813 |
|
} |
1814 |
|
|
1815 |
|
// XXX WIP |
1816 |
|
protected function get_service_data(string $service) { |
1817 |
|
$val_service = array(); |
1818 |
|
$inst_service = $this->f->get_inst__om_dbform(array( |
1819 |
|
"obj" => "service", |
1820 |
|
"idx" => $service, |
1821 |
|
)); |
1822 |
|
$val_service = $inst_service->get_json_data(); |
1823 |
|
return $val_service; |
1824 |
|
} |
1825 |
|
|
1826 |
|
protected function view_form_json($in_field = false) { |
1827 |
// |
// |
1828 |
if ($this->f->get_submitted_post_value('valid') === null) { |
if ($this->f->get_submitted_post_value('valid') === null |
1829 |
|
&& $this->getVal('state') !== self::STATUS_CANCELED) { |
1830 |
// Liste des valeurs à afficher |
// Liste des valeurs à afficher |
1831 |
$val = array(); |
$val = array(); |
1832 |
// |
// |
1833 |
$val_task = array_combine($this->champs, $this->val); |
$val_task = array_combine($this->champs, $this->val); |
1834 |
|
foreach ($val_task as $key => $value) { |
1835 |
|
$val_task[$key] = strip_tags($value); |
1836 |
|
} |
1837 |
|
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
1838 |
|
unset($val_task['timestamp_log_hidden']); |
1839 |
$val['task'] = $val_task; |
$val['task'] = $val_task; |
1840 |
// |
// |
1841 |
if ($this->getVal('type') === 'creation_DA') { |
if ($this->getVal('type') === 'creation_DA' |
1842 |
|
|| $this->getVal('type') === 'modification_DA') { |
1843 |
|
// |
1844 |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
1845 |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
1846 |
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
1847 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1848 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
1849 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1850 |
} |
} |
1851 |
// |
// |
1852 |
if ($this->getVal('type') === 'creation_DI' |
if ($this->getVal('type') === 'creation_DI' |
1853 |
|| $this->getVal('type') === 'modification_DI') { |
|| $this->getVal('type') === 'modification_DI' |
1854 |
|
|| $this->getVal('type') === 'depot_DI') { |
1855 |
// |
// |
1856 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
1857 |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction'); |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction'); |
1858 |
$val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']); |
$val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']); |
1859 |
$val['architecte'] = $this->get_architecte_data($val['donnees_techniques']['architecte']); |
$architecte = isset($val['donnees_techniques']['architecte']) === true ? $val['donnees_techniques']['architecte'] : null; |
1860 |
|
$val['architecte'] = $this->get_architecte_data($architecte); |
1861 |
$val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']); |
$val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']); |
1862 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1863 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1864 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1865 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1866 |
} |
} |
1867 |
// |
// |
1868 |
if ($this->getVal('type') === 'qualification_DI') { |
if ($this->getVal('type') === 'qualification_DI') { |
1869 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier']); |
|
1870 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1871 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1872 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1873 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1874 |
} |
} |
1875 |
// |
// |
1876 |
if ($this->getVal('type') === 'ajout_piece') { |
if ($this->getVal('type') === 'ajout_piece') { |
1879 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1880 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1881 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1882 |
$val_external_uid['document_numerise'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'document_numerise'); |
$val_external_uid['piece'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'piece'); |
1883 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1884 |
|
} |
1885 |
|
// |
1886 |
|
if ($this->getVal('type') === 'decision_DI') { |
1887 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1888 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
1889 |
|
$val['instruction']['final'] = 't'; |
1890 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
1891 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
1892 |
|
} |
1893 |
|
$val_external_uid = array(); |
1894 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1895 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1896 |
|
$val['external_uids'] = $val_external_uid; |
1897 |
|
} |
1898 |
|
// |
1899 |
|
if ($this->getVal('type') === 'incompletude_DI') { |
1900 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1901 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
1902 |
|
$val_external_uid = array(); |
1903 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1904 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1905 |
|
$val['external_uids'] = $val_external_uid; |
1906 |
|
} |
1907 |
|
// |
1908 |
|
if ($this->getVal('type') === 'completude_DI') { |
1909 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1910 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
1911 |
|
$val_external_uid = array(); |
1912 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1913 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1914 |
|
$val['external_uids'] = $val_external_uid; |
1915 |
|
} |
1916 |
|
// |
1917 |
|
if ($this->getVal('type') === 'pec_metier_consultation') { |
1918 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1919 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1920 |
|
$val_external_uid = array(); |
1921 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1922 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1923 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
1924 |
|
$val['external_uids'] = $val_external_uid; |
1925 |
|
} |
1926 |
|
// |
1927 |
|
if ($this->getVal('type') === 'avis_consultation') { |
1928 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1929 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1930 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
1931 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
1932 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
1933 |
|
} |
1934 |
|
$val_external_uid = array(); |
1935 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1936 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1937 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
1938 |
|
$val_external_uid['avis_dossier_consultation'] = $this->get_external_uid($this->getVal('object_id'), 'avis_dossier_consultation'); |
1939 |
|
$val['external_uids'] = $val_external_uid; |
1940 |
|
} |
1941 |
|
// XXX WIP |
1942 |
|
if ($this->getVal('type') === 'creation_consultation') { |
1943 |
|
// |
1944 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1945 |
|
$val['consultation'] = $this->get_consultation_data($this->getVal('object_id')); |
1946 |
|
$val['service'] = $this->get_service_data($val['consultation']['service']); |
1947 |
|
$val_external_uid = array(); |
1948 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1949 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1950 |
|
$val['external_uids'] = $val_external_uid; |
1951 |
|
} |
1952 |
|
// |
1953 |
|
if ($this->getVal('type') === 'envoi_CL') { |
1954 |
|
// |
1955 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1956 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1957 |
|
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($val['dossier']['dossier_autorisation']); |
1958 |
|
$val_external_uid = array(); |
1959 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1960 |
|
$val_external_uid['dossier'] = $this->get_external_uid($this->getVal('dossier'), 'dossier'); |
1961 |
|
$val_external_uid['decision'] = $this->get_external_uid($this->getVal('object_id'), 'instruction'); |
1962 |
|
if ($val_external_uid['decision'] === '') { |
1963 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
1964 |
|
"obj" => "instruction", |
1965 |
|
"idx" => $this->getVal('object_id'), |
1966 |
|
)); |
1967 |
|
$val_external_uid['decision'] = $this->get_external_uid($inst_instruction->get_related_instructions_next('retour_signature'), 'instruction'); |
1968 |
|
} |
1969 |
|
$val['external_uids'] = $val_external_uid; |
1970 |
|
} |
1971 |
|
if ($this->getVal('type') === 'notification_instruction' |
1972 |
|
|| $this->getVal('type') === 'notification_recepisse' |
1973 |
|
|| $this->getVal('type') === 'notification_decision' |
1974 |
|
|| $this->getVal('type') === 'notification_service_consulte' |
1975 |
|
|| $this->getVal('type') === 'notification_tiers_consulte') { |
1976 |
|
// |
1977 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1978 |
|
$dossier_id = isset($val['dossier']['dossier']) === true ? $val['dossier']['dossier'] : null; |
1979 |
|
$val['demandeur'] = $this->get_demandeurs_data($dossier_id); |
1980 |
|
$val['instruction_notification'] = $this->get_instruction_notification_data($this->getVal('category'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1981 |
|
$instruction_id = isset($val['instruction_notification']['instruction']) === true ? $val['instruction_notification']['instruction'] : null; |
1982 |
|
$instruction_annexes = isset($val['instruction_notification']['annexes']) === true ? $val['instruction_notification']['annexes'] : null; |
1983 |
|
$val['instruction'] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $instruction_id)); |
1984 |
|
// Précise qu'il s'agit d'une instruction final si l'instruction est liée à une |
1985 |
|
// demande dont le type ne génère pas de dossier |
1986 |
|
if ($this->is_demande_instruction_recepisse_without_dossier($instruction_id) === true) { |
1987 |
|
$val['instruction']['final'] = 't'; |
1988 |
|
} |
1989 |
|
$val_external_uid = array(); |
1990 |
|
// Affiche l'identifiant externe lié à l'instruction si cette combinaison existe, sinon celui lié au dossier |
1991 |
|
$val_external_uid['demande'] = $this->get_external_uid($instruction_id, 'demande') !== '' ? $this->get_external_uid($instruction_id, 'demande') : $this->get_external_uid($dossier_id, 'demande'); |
1992 |
|
$val_external_uid['demande (instruction)'] = $this->get_external_uid($instruction_id, 'demande', 'portal', 'ASC'); |
1993 |
|
$val_external_uid['instruction_notification'] = $this->get_external_uid($this->getVal('object_id'), 'instruction_notification', 'portal'); |
1994 |
|
$val['external_uids'] = $val_external_uid; |
1995 |
|
} |
1996 |
|
// |
1997 |
|
if ($this->getVal('type') === 'prescription') { |
1998 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1999 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2000 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
2001 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
2002 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
2003 |
|
} |
2004 |
|
$val_external_uid = array(); |
2005 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2006 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2007 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
2008 |
|
$val_external_uid['prescription'] = $this->get_external_uid($this->getVal('object_id'), 'prescription'); |
2009 |
|
$val['external_uids'] = $val_external_uid; |
2010 |
} |
} |
2011 |
|
|
2012 |
// Liste des valeurs affichée en JSON |
if ($in_field === true) { |
2013 |
printf(json_encode($val)); |
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
2014 |
|
} else { |
2015 |
|
// Liste des valeurs affichée en JSON |
2016 |
|
echo(json_encode($val, JSON_UNESCAPED_SLASHES)); |
2017 |
|
} |
2018 |
} |
} |
2019 |
} |
} |
2020 |
|
|
2021 |
protected function get_lien_objet_by_type($type) { |
function post_update_task() { |
2022 |
|
// Mise à jour des valeurs |
2023 |
|
|
2024 |
|
// Modification de l'état de la tâche |
2025 |
|
if ($this->f->get_submitted_post_value('state') !== null) { |
2026 |
|
$params = array( |
2027 |
|
'val' => array( |
2028 |
|
'state' => $this->f->get_submitted_post_value('state') |
2029 |
|
), |
2030 |
|
); |
2031 |
|
$update = $this->update_task($params); |
2032 |
|
$message_class = "valid"; |
2033 |
|
$message = $this->msg; |
2034 |
|
if ($update === false) { |
2035 |
|
$this->addToLog($this->msg, DEBUG_MODE); |
2036 |
|
$message_class = "error"; |
2037 |
|
$message = sprintf( |
2038 |
|
'%s %s', |
2039 |
|
__('Impossible de mettre à jour la tâche.'), |
2040 |
|
__('Veuillez contacter votre administrateur.') |
2041 |
|
); |
2042 |
|
} |
2043 |
|
$this->f->displayMessage($message_class, $message); |
2044 |
|
} |
2045 |
|
|
2046 |
|
// Sauvegarde de l'uid externe retourné |
2047 |
|
if ($this->f->get_submitted_post_value('external_uid') !== null) { |
2048 |
|
// |
2049 |
|
$objects = $this->get_objects_by_task_type($this->getVal('type'), $this->getVal('stream')); |
2050 |
|
foreach ($objects as $object) { |
2051 |
|
$inst_lien = $this->f->get_inst__om_dbform(array( |
2052 |
|
"obj" => "lien_id_interne_uid_externe", |
2053 |
|
"idx" => ']', |
2054 |
|
)); |
2055 |
|
$object_id = $this->getVal('object_id'); |
2056 |
|
$is_exists = $inst_lien->is_exists($object, $object_id, $this->f->get_submitted_post_value('external_uid'), $this->getVal('dossier')); |
2057 |
|
// Dans le cas spécifique de la mise à jour d'une notification |
2058 |
|
// et de la création d'une liaison d'identifiant pour l'objet demande, |
2059 |
|
// l'identifiant de l'objet n'est plus celui de la notification |
2060 |
|
// d'instruction mais celui du dossier d'instruction |
2061 |
|
if ($object === 'demande' |
2062 |
|
&& ($this->getVal('type') === 'notification_recepisse' |
2063 |
|
|| $this->getVal('type') === 'notification_instruction' |
2064 |
|
|| $this->getVal('type') === 'notification_decision' |
2065 |
|
|| $this->getVal('type') === 'notification_service_consulte' |
2066 |
|
|| $this->getVal('type') === 'notification_tiers_consulte')) { |
2067 |
|
// |
2068 |
|
$object_id = $this->getVal('dossier'); |
2069 |
|
// Il ne doit y avoir qu'une liaison entre le numéro du dossier interne et un uid externe de "demande" |
2070 |
|
$is_exists = $inst_lien->is_exists($object, $object_id, null, $this->getVal('dossier')); |
2071 |
|
} |
2072 |
|
if ($is_exists === false) { |
2073 |
|
$valF = array( |
2074 |
|
'lien_id_interne_uid_externe' => '', |
2075 |
|
'object' => $object, |
2076 |
|
'object_id' => $object_id, |
2077 |
|
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
2078 |
|
'dossier' => $this->getVal('dossier'), |
2079 |
|
'category' => $this->getVal('category'), |
2080 |
|
); |
2081 |
|
$add = $inst_lien->ajouter($valF); |
2082 |
|
$message_class = "valid"; |
2083 |
|
$message = $inst_lien->msg; |
2084 |
|
if ($add === false) { |
2085 |
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
2086 |
|
$message_class = "error"; |
2087 |
|
$message = sprintf( |
2088 |
|
'%s %s', |
2089 |
|
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
2090 |
|
__('Veuillez contacter votre administrateur.') |
2091 |
|
); |
2092 |
|
} |
2093 |
|
$this->f->displayMessage($message_class, $message); |
2094 |
|
} |
2095 |
|
} |
2096 |
|
} |
2097 |
|
} |
2098 |
|
|
2099 |
|
function post_add_task() { |
2100 |
|
// TODO Tester de remplacer la ligne de json_payload par un $_POST |
2101 |
|
$result = $this->add_task(array( |
2102 |
|
'val' => array( |
2103 |
|
'stream' => 'input', |
2104 |
|
'json_payload' => html_entity_decode($this->f->get_submitted_post_value('json_payload')), |
2105 |
|
'type' => $this->f->get_submitted_post_value('type'), |
2106 |
|
'category' => $this->f->get_submitted_post_value('category'), |
2107 |
|
) |
2108 |
|
)); |
2109 |
|
$message = sprintf( |
2110 |
|
__("Tâche %s ajoutée avec succès"), |
2111 |
|
$this->getVal($this->clePrimaire)). |
2112 |
|
'<br/><br/>'. |
2113 |
|
$this->msg; |
2114 |
|
$message_class = "valid"; |
2115 |
|
if ($result === false){ |
2116 |
|
$this->addToLog($this->msg, DEBUG_MODE); |
2117 |
|
$message_class = "error"; |
2118 |
|
$message = sprintf( |
2119 |
|
'%s %s', |
2120 |
|
__('Impossible d\'ajouter la tâche.'), |
2121 |
|
__('Veuillez contacter votre administrateur.') |
2122 |
|
); |
2123 |
|
} |
2124 |
|
$this->f->displayMessage($message_class, $message); |
2125 |
|
} |
2126 |
|
|
2127 |
|
function setLayout(&$form, $maj) { |
2128 |
// |
// |
2129 |
$objet = ''; |
$form->setBloc('json_payload', 'D', '', 'col_6'); |
2130 |
if ($type === 'creation_DA') { |
$form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed"); |
2131 |
$objet = 'dossier_autorisation'; |
$form->setBloc('json_payload', 'F'); |
2132 |
|
$form->setBloc('timestamp_log', 'DF', __("historique"), 'col_9 timestamp_log_jsontotab'); |
2133 |
|
} |
2134 |
|
|
2135 |
|
/** |
2136 |
|
* Récupère le nom de l'objet à mentionner dans la table lien_id_interne_uid_externe |
2137 |
|
* en fonction du type et du stream de la tâche. |
2138 |
|
* |
2139 |
|
* @param string $type Type de la tâche |
2140 |
|
* @param string $stream Stream de la tâche |
2141 |
|
* |
2142 |
|
* @return array |
2143 |
|
*/ |
2144 |
|
function get_objects_by_task_type($type, $stream = 'all') { |
2145 |
|
$objects = array(); |
2146 |
|
if (in_array($type, array('creation_DA', 'modification_DA', )) === true) { |
2147 |
|
$objects = array('dossier_autorisation', ); |
2148 |
|
} |
2149 |
|
if (in_array($type, array('creation_DI', 'depot_DI', 'notification_DI', 'qualification_DI', )) === true) { |
2150 |
|
$objects = array('dossier', ); |
2151 |
|
} |
2152 |
|
if (in_array($type, array('create_DI_for_consultation', )) === true) { |
2153 |
|
$objects = array('dossier', 'dossier_consultation', ); |
2154 |
|
} |
2155 |
|
if (in_array($type, array('create_DI', )) === true |
2156 |
|
&& $stream === 'input') { |
2157 |
|
$objects = array('dossier', 'dossier_autorisation', 'demande', ); |
2158 |
|
} |
2159 |
|
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
2160 |
|
$objects = array('instruction', ); |
2161 |
|
} |
2162 |
|
if (in_array($type, array('envoi_CL', )) === true) { |
2163 |
|
$objects = array('instruction_action_cl', ); |
2164 |
} |
} |
2165 |
if ($type === 'creation_DI' || $type = 'modification_DI') { |
if (in_array($type, array('pec_metier_consultation', )) === true |
2166 |
$objet = 'dossier'; |
&& $stream === 'output') { |
2167 |
|
$objects = array('pec_dossier_consultation', ); |
2168 |
} |
} |
2169 |
if ($type === 'ajout_piece') { |
if (in_array($type, array('avis_consultation', )) === true |
2170 |
$objet = 'document_numerise'; |
&& $stream === 'output') { |
2171 |
|
$objects = array('avis_dossier_consultation', ); |
2172 |
} |
} |
2173 |
return $objet; |
if (in_array($type, array('prescription', )) === true |
2174 |
|
&& $stream === 'output') { |
2175 |
|
$objects = array('prescription', ); |
2176 |
|
} |
2177 |
|
if (in_array($type, array('ajout_piece', 'add_piece', )) === true) { |
2178 |
|
$objects = array('piece', ); |
2179 |
|
} |
2180 |
|
if (in_array($type, array('creation_consultation', )) === true) { |
2181 |
|
$objects = array('consultation', ); |
2182 |
|
} |
2183 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
2184 |
|
&& $stream === 'input') { |
2185 |
|
$objects = array('pec_metier_consultation', ); |
2186 |
|
} |
2187 |
|
if (in_array($type, array('avis_consultation', )) === true |
2188 |
|
&& $stream === 'input') { |
2189 |
|
$objects = array('avis_consultation', ); |
2190 |
|
} |
2191 |
|
if (in_array($type, array('create_message', )) === true |
2192 |
|
&& $stream === 'input') { |
2193 |
|
$objects = array('dossier_message', ); |
2194 |
|
} |
2195 |
|
if (in_array( |
2196 |
|
$type, |
2197 |
|
array( |
2198 |
|
'notification_recepisse', |
2199 |
|
'notification_instruction', |
2200 |
|
'notification_decision', |
2201 |
|
'notification_service_consulte', |
2202 |
|
'notification_tiers_consulte', |
2203 |
|
) |
2204 |
|
) === true) { |
2205 |
|
$objects = array('instruction_notification', 'demande', ); |
2206 |
|
} |
2207 |
|
return $objects; |
2208 |
|
} |
2209 |
|
|
2210 |
|
/** |
2211 |
|
* Récupère les tables auxquelles pourrait être rattaché l'objet lié à la tâche, |
2212 |
|
* par rapport à son type. |
2213 |
|
* |
2214 |
|
* @param string $type Type de la tâche |
2215 |
|
* @param string $stream input ou output |
2216 |
|
* @return array |
2217 |
|
*/ |
2218 |
|
function get_tables_by_task_type($type, $stream = 'all') { |
2219 |
|
$tables = array(); |
2220 |
|
if (in_array($type, array('creation_DA', 'modification_DA', )) === true) { |
2221 |
|
$tables = array('dossier_autorisation', ); |
2222 |
|
} |
2223 |
|
if (in_array($type, array('creation_DI', 'depot_DI', )) === true) { |
2224 |
|
$tables = array('dossier', ); |
2225 |
|
} |
2226 |
|
if (in_array($type, array('qualification_DI', )) === true) { |
2227 |
|
$tables = array('instruction', 'dossier', ); |
2228 |
|
} |
2229 |
|
if (in_array($type, array('create_DI_for_consultation', )) === true) { |
2230 |
|
$tables = array('dossier', ); |
2231 |
|
} |
2232 |
|
if (in_array($type, array('create_DI', )) === true |
2233 |
|
&& $stream === 'input') { |
2234 |
|
$tables = array('dossier', 'dossier_autorisation', 'demande', ); |
2235 |
|
} |
2236 |
|
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
2237 |
|
$tables = array('instruction', ); |
2238 |
|
} |
2239 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
2240 |
|
&& $stream === 'output') { |
2241 |
|
$tables = array('instruction', ); |
2242 |
|
} |
2243 |
|
if (in_array($type, array('avis_consultation', )) === true |
2244 |
|
&& $stream === 'output') { |
2245 |
|
$tables = array('instruction', ); |
2246 |
|
} |
2247 |
|
if (in_array($type, array('prescription', )) === true |
2248 |
|
&& $stream === 'output') { |
2249 |
|
$tables = array('instruction', ); |
2250 |
|
} |
2251 |
|
if (in_array($type, array('ajout_piece', 'add_piece', )) === true) { |
2252 |
|
$tables = array('document_numerise', ); |
2253 |
|
} |
2254 |
|
if (in_array($type, array('creation_consultation', )) === true) { |
2255 |
|
$tables = array('consultation', ); |
2256 |
|
} |
2257 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
2258 |
|
&& $stream === 'input') { |
2259 |
|
$tables = array('consultation', ); |
2260 |
|
} |
2261 |
|
if (in_array($type, array('avis_consultation', )) === true |
2262 |
|
&& $stream === 'input') { |
2263 |
|
$tables = array('consultation', ); |
2264 |
|
} |
2265 |
|
if (in_array($type, array('create_message', )) === true |
2266 |
|
&& $stream === 'input') { |
2267 |
|
$tables = array('dossier_message', ); |
2268 |
|
} |
2269 |
|
if (in_array( |
2270 |
|
$type, |
2271 |
|
array( |
2272 |
|
'notification_recepisse', |
2273 |
|
'notification_instruction', |
2274 |
|
'notification_decision', |
2275 |
|
'notification_service_consulte', |
2276 |
|
'notification_tiers_consulte' |
2277 |
|
) |
2278 |
|
) === true) { |
2279 |
|
$tables = array('instruction_notification', ); |
2280 |
|
} |
2281 |
|
return $tables; |
2282 |
} |
} |
2283 |
|
|
2284 |
} |
} |