38 |
'notification_decision', |
'notification_decision', |
39 |
'notification_service_consulte', |
'notification_service_consulte', |
40 |
'notification_tiers_consulte', |
'notification_tiers_consulte', |
41 |
|
'notification_depot_demat', |
42 |
|
'notification_commune', |
43 |
|
'notification_signataire', |
44 |
|
'lettre_incompletude', |
45 |
|
'lettre_majoration' |
46 |
); |
); |
47 |
|
|
48 |
/** |
/** |
58 |
'notification_decision', |
'notification_decision', |
59 |
'notification_service_consulte', |
'notification_service_consulte', |
60 |
'notification_tiers_consulte', |
'notification_tiers_consulte', |
61 |
|
'notification_depot_demat', |
62 |
'prescription', |
'prescription', |
63 |
); |
); |
64 |
|
|
65 |
/** |
/** |
66 |
|
* Liste des types de tâche pouvant avoir des documents associés |
67 |
|
*/ |
68 |
|
const TASK_WITH_DOCUMENT = array( |
69 |
|
'add_piece', |
70 |
|
'avis_consultation', |
71 |
|
'pec_metier_consultation' |
72 |
|
); |
73 |
|
|
74 |
|
/** |
75 |
* Catégorie de la tâche |
* Catégorie de la tâche |
76 |
*/ |
*/ |
77 |
var $category = 'platau'; |
var $category = PLATAU; |
78 |
|
|
79 |
/** |
/** |
80 |
* Définition des actions disponibles sur la classe. |
* Définition des actions disponibles sur la classe. |
207 |
"CONCAT_WS(' ', to_char(task.creation_date, 'DD/MM/YYYY'), task.creation_time) AS date_creation", |
"CONCAT_WS(' ', to_char(task.creation_date, 'DD/MM/YYYY'), task.creation_time) AS date_creation", |
208 |
'last_modification_date', |
'last_modification_date', |
209 |
'last_modification_time', |
'last_modification_time', |
210 |
|
"CONCAT_WS(' ', to_char(task.last_modification_date, 'DD/MM/YYYY'), task.last_modification_time) AS date_modification", |
211 |
|
"comment", |
212 |
"json_payload", |
"json_payload", |
213 |
"timestamp_log", |
"timestamp_log", |
214 |
|
"timestamp_log AS timestamp_log_hidden", |
215 |
"category", |
"category", |
216 |
); |
); |
217 |
} |
} |
224 |
|
|
225 |
// ALL |
// ALL |
226 |
$form->setType("category", "hidden"); |
$form->setType("category", "hidden"); |
227 |
|
$form->setType("timestamp_log_hidden", "hidden"); |
228 |
|
|
229 |
// MODE CREER |
// MODE CREER |
230 |
if ($maj == 0 || $crud == 'create') { |
if ($maj == 0 || $crud == 'create') { |
231 |
|
$form->setType("type", "select"); |
232 |
$form->setType("state", "select"); |
$form->setType("state", "select"); |
233 |
$form->setType("stream", "select"); |
$form->setType("stream", "select"); |
234 |
$form->setType("json_payload", "textarea"); |
$form->setType("json_payload", "textarea"); |
235 |
} |
} |
236 |
// MODE MODIFIER |
// MODE MODIFIER |
237 |
if ($maj == 1 || $crud == 'update') { |
if ($maj == 1 || $crud == 'update') { |
238 |
|
$form->setType("task", "hiddenstatic"); |
239 |
$form->setType("state", "select"); |
$form->setType("state", "select"); |
240 |
$form->setType("stream", "select"); |
$form->setType("stream", "hiddenstatic"); |
241 |
$form->setType("json_payload", "jsonprettyprint"); |
$form->setType("json_payload", "jsonprettyprint"); |
242 |
|
$form->setType("timestamp_log", "jsontotab"); |
243 |
|
$form->setType("type", "hiddenstatic"); |
244 |
$form->setType("creation_date", "hidden"); |
$form->setType("creation_date", "hidden"); |
245 |
$form->setType("creation_time", "hidden"); |
$form->setType("creation_time", "hidden"); |
246 |
$form->setType("date_creation", "static"); |
$form->setType("object_id", "hiddenstatic"); |
247 |
|
$form->setType("dossier", "hiddenstatic"); |
248 |
|
$form->setType("date_creation", "hiddenstatic"); |
249 |
$form->setType("last_modification_date", "hidden"); |
$form->setType("last_modification_date", "hidden"); |
250 |
$form->setType("last_modification_time", "hidden"); |
$form->setType("last_modification_time", "hidden"); |
251 |
|
$form->setType("date_modification", "static"); |
252 |
} |
} |
253 |
// MODE CONSULTER |
// MODE CONSULTER |
254 |
if ($maj == 3 || $crud == 'read') { |
if ($maj == 3 || $crud == 'read') { |
255 |
|
$form->setType("state", "selecthiddenstatic"); |
256 |
|
$form->setType("stream", "selecthiddenstatic"); |
257 |
$form->setType('dossier', 'link'); |
$form->setType('dossier', 'link'); |
258 |
$form->setType('json_payload', 'jsonprettyprint'); |
$form->setType('json_payload', 'jsonprettyprint'); |
259 |
|
$form->setType("type", "selecthiddenstatic"); |
260 |
$form->setType("creation_date", "hidden"); |
$form->setType("creation_date", "hidden"); |
261 |
$form->setType("creation_time", "hidden"); |
$form->setType("creation_time", "hidden"); |
262 |
$form->setType("date_creation", "static"); |
$form->setType("date_creation", "static"); |
263 |
$form->setType("last_modification_date", "hidden"); |
$form->setType("last_modification_date", "hidden"); |
264 |
$form->setType("last_modification_time", "hidden"); |
$form->setType("last_modification_time", "hidden"); |
265 |
|
$form->setType("date_modification", "static"); |
266 |
|
$form->setType("timestamp_log", "jsontotab"); |
267 |
} |
} |
|
|
|
268 |
} |
} |
269 |
|
|
270 |
|
function stateTranslation ($currentState) { |
271 |
|
switch ($currentState){ |
272 |
|
case "draft": |
273 |
|
return __('brouillon'); |
274 |
|
break; |
275 |
|
case "new": |
276 |
|
return __('à traiter'); |
277 |
|
break; |
278 |
|
case "pending": |
279 |
|
return __('en cours'); |
280 |
|
break; |
281 |
|
case "done": |
282 |
|
return __('terminé'); |
283 |
|
break; |
284 |
|
case "archived": |
285 |
|
return __('archivé'); |
286 |
|
break; |
287 |
|
case "error": |
288 |
|
return __('erreur'); |
289 |
|
break; |
290 |
|
case "debug": |
291 |
|
return __('debug'); |
292 |
|
break; |
293 |
|
case "canceled": |
294 |
|
return __('annulé'); |
295 |
|
break; |
296 |
|
} |
297 |
|
} |
298 |
/** |
/** |
299 |
* |
* |
300 |
*/ |
*/ |
301 |
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
302 |
if($maj < 2) { |
if($maj <= 3) { |
|
|
|
303 |
$contenu = array(); |
$contenu = array(); |
304 |
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG', 'ARCHIVED', 'CANCELED') as $key) { |
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG', 'ARCHIVED', 'CANCELED') as $key) { |
305 |
$const_name = 'STATUS_'.$key; |
$const_name = 'STATUS_'.$key; |
306 |
$const_value = constant("self::$const_name"); |
$const_value = constant("self::$const_name"); |
307 |
$contenu[0][] = $const_value; |
$contenu[0][] = $const_value; |
308 |
$contenu[1][] = $const_value; |
|
309 |
|
|
310 |
|
$contenu[1][] = $this->stateTranslation($const_value); |
311 |
|
|
312 |
} |
} |
313 |
|
|
314 |
$form->setSelect("state", $contenu); |
$form->setSelect("state", $contenu); |
315 |
|
|
316 |
$contenu_stream =array(); |
$contenu_stream =array(); |
317 |
$contenu_stream[0][0]="input"; |
$contenu_stream[0][0]="input"; |
318 |
$contenu_stream[1][0]=_('input'); |
$contenu_stream[1][0]=__('input'); |
319 |
$contenu_stream[0][1]="output"; |
$contenu_stream[0][1]="output"; |
320 |
$contenu_stream[1][1]=_('output'); |
$contenu_stream[1][1]=__('output'); |
321 |
$form->setSelect("stream", $contenu_stream); |
$form->setSelect("stream", $contenu_stream); |
322 |
|
|
323 |
|
$tab_type = array_unique(array_merge(self::TASK_TYPE_SI, self::TASK_TYPE_SC)); |
324 |
|
|
325 |
|
foreach ($tab_type as $type) { |
326 |
|
|
327 |
|
$contenu_type[0][] = $type; |
328 |
|
|
329 |
|
switch ($type) { |
330 |
|
case "creation_DA": |
331 |
|
$value_type = __('Création DA'); |
332 |
|
break; |
333 |
|
case "create_DI": |
334 |
|
$value_type = __('Création demande'); |
335 |
|
break; |
336 |
|
case "creation_DI": |
337 |
|
$value_type = __('Création DI'); |
338 |
|
break; |
339 |
|
case "modification_DA": |
340 |
|
$value_type = __('Modification DA'); |
341 |
|
break; |
342 |
|
case "modification_DI": |
343 |
|
$value_type = __('Modification DI'); |
344 |
|
break; |
345 |
|
case "ajout_piece": |
346 |
|
$value_type = __('Ajout pièce (sortant)'); |
347 |
|
break; |
348 |
|
case "add_piece": |
349 |
|
$value_type = __('Ajout pièce (entrant)'); |
350 |
|
break; |
351 |
|
case "depot_DI": |
352 |
|
$value_type = __('Dépôt DI'); |
353 |
|
break; |
354 |
|
case "qualification_DI": |
355 |
|
$value_type = __('Qualification DI'); |
356 |
|
break; |
357 |
|
case "creation_consultation": |
358 |
|
$value_type = __('Création consultation'); |
359 |
|
break; |
360 |
|
case "decision_DI": |
361 |
|
$value_type = __('Décision DI'); |
362 |
|
break; |
363 |
|
case "envoi_CL": |
364 |
|
$value_type = __('Envoi contrôle de légalité'); |
365 |
|
break; |
366 |
|
case "pec_metier_consultation": |
367 |
|
$value_type = __('PeC consultation'); |
368 |
|
break; |
369 |
|
case "avis_consultation": |
370 |
|
$value_type = __('Avis'); |
371 |
|
break; |
372 |
|
case "prescription": |
373 |
|
$value_type = __('Prescription'); |
374 |
|
break; |
375 |
|
case "create_DI_for_consultation": |
376 |
|
$value_type = __('Création DI pour consultation'); |
377 |
|
break; |
378 |
|
case "create_message": |
379 |
|
$value_type = __('Message'); |
380 |
|
break; |
381 |
|
case "notification_recepisse": |
382 |
|
$value_type = __('Notification récépissé'); |
383 |
|
break; |
384 |
|
case "notification_instruction": |
385 |
|
$value_type = __('Notification instruction'); |
386 |
|
break; |
387 |
|
case "notification_decision": |
388 |
|
$value_type = __('Notification décision'); |
389 |
|
break; |
390 |
|
case "notification_service_consulte": |
391 |
|
$value_type = __('Notification service consulté'); |
392 |
|
break; |
393 |
|
case "notification_tiers_consulte": |
394 |
|
$value_type = __('Notification tiers consulté'); |
395 |
|
break; |
396 |
|
case "notification_signataire": |
397 |
|
$value_type = __('Notification signataire'); |
398 |
|
break; |
399 |
|
case "completude_DI": |
400 |
|
$value_type = __('complétude DI'); |
401 |
|
break; |
402 |
|
case "incompletude_DI": |
403 |
|
$value_type = __('incomplétude DI'); |
404 |
|
break; |
405 |
|
case "lettre_incompletude": |
406 |
|
$value_type = __('Lettre au pétitionnaire d\'incompletude'); |
407 |
|
break; |
408 |
|
case "lettre_majoration": |
409 |
|
$value_type = __('Lettre au pétitionnaire de majoration'); |
410 |
|
break; |
411 |
|
} |
412 |
|
|
413 |
|
$contenu_type[1][] = $value_type; |
414 |
|
} |
415 |
|
|
416 |
|
$form->setselect('type', $contenu_type); |
417 |
} |
} |
418 |
|
|
419 |
if ($maj == 3) { |
if ($maj == 3) { |
420 |
if ($this->getVal('stream') == 'output') { |
// Récupération du numéro du dossier si il n'est pas renseigné dans la tâche |
421 |
$inst_dossier = $this->f->get_inst__om_dbform(array( |
if ($form->val['dossier'] == '' || $form->val['dossier'] == null) { |
422 |
"obj" => "dossier", |
// Récupération de la payload de la taĉhe. |
423 |
"idx" => $form->val['dossier'], |
// Si la tâche est une tâche input la payload est associée à la tâche. |
424 |
)); |
// Si la tâche est une tâche en output la payload est "calculé" à l'ouverture |
425 |
|
// du formulaire. |
426 |
|
if ($this->getVal('stream') == 'input') { |
427 |
|
$json_payload = json_decode($this->getVal('json_payload'), true); |
428 |
|
} else { |
429 |
|
$json_payload = json_decode($form->val['json_payload'], true); |
430 |
|
} |
431 |
|
// A partir de la payload de la tâche ont récupère les externals uid |
432 |
|
// Si un external uid de DI (dossier) existe ont le récupère et on stocke le numéro |
433 |
|
// pour l'afficher sur le formulaire. |
434 |
|
// Si l'external UID du DI n'existe pas on récupère celui du DA |
435 |
|
$external_uid = ''; |
436 |
|
if (array_key_exists('external_uids', $json_payload) |
437 |
|
&& array_key_exists('dossier', $json_payload['external_uids']) |
438 |
|
) { |
439 |
|
$external_uid = $json_payload['external_uids']['dossier']; |
440 |
|
} elseif (array_key_exists('external_uids', $json_payload) |
441 |
|
&& array_key_exists('demande', $json_payload['external_uids'])) { |
442 |
|
$external_uid = $json_payload['external_uids']['demande']; |
443 |
|
} |
444 |
|
// Recherche l'external uid dans la base de données pour récupèrer le numéro de |
445 |
|
// DI / DA correspondant. On stocke le numéro de dossier dans la propriété val |
446 |
|
// du formulaire pour pouvoir l'afficher |
447 |
|
if ($external_uid != '') { |
448 |
|
$qres = $this->f->get_one_result_from_db_query( |
449 |
|
sprintf( |
450 |
|
'SELECT |
451 |
|
lien_id_interne_uid_externe.dossier |
452 |
|
FROM |
453 |
|
%1$slien_id_interne_uid_externe |
454 |
|
WHERE |
455 |
|
lien_id_interne_uid_externe.external_uid = \'%2$s\'', |
456 |
|
DB_PREFIXE, |
457 |
|
$this->f->db->escapeSimple($external_uid) |
458 |
|
), |
459 |
|
array( |
460 |
|
"origin" => __METHOD__, |
461 |
|
) |
462 |
|
); |
463 |
|
if (! empty($qres["result"])) { |
464 |
|
$form->val['dossier'] = $qres["result"]; |
465 |
|
} |
466 |
|
} |
467 |
|
} |
468 |
|
|
469 |
if($form->val['type'] == "creation_DA" |
// Vérifie si le numéro de dossier associé à la tâche existe dans la base. |
470 |
|| $form->val['type'] == "modification_DA"){ |
// Si c'est le cas ce numéro sera lié au dossier (DI ou DA) correspondant |
471 |
// |
// TODO : vérifier la liste des tâches lié à des DA |
472 |
|
$obj_link = ''; |
473 |
|
if ($form->val['type'] == "creation_DA" || $form->val['type'] == "modification_DA") { |
474 |
|
// Vérification que le numéro de DA affiché dans le formulaire existe |
475 |
|
$qres = $this->f->get_one_result_from_db_query( |
476 |
|
sprintf( |
477 |
|
'SELECT |
478 |
|
dossier_autorisation.dossier_autorisation |
479 |
|
FROM |
480 |
|
%1$sdossier_autorisation |
481 |
|
WHERE |
482 |
|
dossier_autorisation.dossier_autorisation = \'%2$s\'', |
483 |
|
DB_PREFIXE, |
484 |
|
$this->f->db->escapeSimple($form->val['dossier']) |
485 |
|
), |
486 |
|
array( |
487 |
|
"origin" => __METHOD__, |
488 |
|
) |
489 |
|
); |
490 |
|
// Si on a un résultat c'est que le dossier existe, il faut afficher le lien |
491 |
|
if (! empty($qres["result"])) { |
492 |
$obj_link = 'dossier_autorisation'; |
$obj_link = 'dossier_autorisation'; |
493 |
} else { |
} |
494 |
|
} else { |
495 |
|
// Vérification que le numéro de DI affiché dans le formulaire existe |
496 |
|
$qres = $this->f->get_one_result_from_db_query( |
497 |
|
sprintf( |
498 |
|
'SELECT |
499 |
|
dossier.dossier |
500 |
|
FROM |
501 |
|
%1$sdossier |
502 |
|
WHERE |
503 |
|
dossier.dossier = \'%2$s\'', |
504 |
|
DB_PREFIXE, |
505 |
|
$this->f->db->escapeSimple($form->val['dossier']) |
506 |
|
), |
507 |
|
array( |
508 |
|
"origin" => __METHOD__, |
509 |
|
) |
510 |
|
); |
511 |
|
// Si on a un résultat c'est que le dossier existe, il faut afficher le lien |
512 |
|
if (! empty($qres["result"])) { |
513 |
$obj_link = 'dossier_instruction'; |
$obj_link = 'dossier_instruction'; |
514 |
} |
} |
|
|
|
|
$params = array(); |
|
|
$params['obj'] = $obj_link; |
|
|
$params['libelle'] = $inst_dossier->getVal('dossier'); |
|
|
$params['title'] = "Consulter le dossier"; |
|
|
$params['idx'] = $form->val['dossier']; |
|
|
$form->setSelect("dossier", $params); |
|
515 |
} |
} |
516 |
|
// Pour afficher le lien vers un dossier ont utilise un champ de type "link". |
517 |
|
// Pour paramétrer ce champs on a besoin de savoir : |
518 |
|
// - quel objet est visé par le lien |
519 |
|
// - le label (libellé) du lien |
520 |
|
// - l'identifiant de l'objet qui sera utilisé dans le lien |
521 |
|
// - le titre associé au lien |
522 |
|
// Pour cela on remplit le champs comme un select et les valeurs du select |
523 |
|
// contiennent les informations nécessaire à l'affichage du champs. |
524 |
|
$params = array( |
525 |
|
'obj' => $obj_link, |
526 |
|
'libelle' => $form->val['dossier'], |
527 |
|
'title' => "Consulter le dossier", |
528 |
|
'idx' => $form->val['dossier'] |
529 |
|
); |
530 |
|
$form->setSelect("dossier", $params); |
531 |
} |
} |
532 |
} |
} |
533 |
|
|
539 |
function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) { |
function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) { |
540 |
// parent::setVal($form, $maj, $validation); |
// parent::setVal($form, $maj, $validation); |
541 |
// |
// |
542 |
if ($this->getVal('stream') == "output") { |
if ($this->getVal('stream') == "output" |
543 |
|
&& ($this->getVal('state') !== self::STATUS_DONE |
544 |
|
|| $this->getVal('json_payload') === "{}")) { |
545 |
|
// |
546 |
$form->setVal('json_payload', $this->view_form_json(true)); |
$form->setVal('json_payload', $this->view_form_json(true)); |
547 |
} else { |
} else { |
548 |
$form->setVal('json_payload', htmlentities($this->getVal('json_payload'))); |
$form->setVal('json_payload', json_encode(json_decode($this->getVal('json_payload'), true), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); |
549 |
|
} |
550 |
|
// Gestion du contenu de l'historique |
551 |
|
if ($this->getVal('timestamp_log') !== '' |
552 |
|
&& $this->getVal('timestamp_log') !== null) { |
553 |
|
// |
554 |
|
$form->setVal('timestamp_log', $this->getVal('timestamp_log')); |
555 |
} |
} |
556 |
} |
} |
557 |
|
|
561 |
// Récupération du mode de l'action |
// Récupération du mode de l'action |
562 |
$crud = $this->get_action_crud($maj); |
$crud = $this->get_action_crud($maj); |
563 |
|
|
564 |
|
$form->setLib('date_creation', __("Date de création")); |
565 |
|
$form->setLib('date_modification', __("Date de dernière modification")); |
566 |
|
$form->setLib('comment', __("commentaire")); |
567 |
|
|
568 |
// MODE different de CREER |
// MODE different de CREER |
569 |
if ($maj != 0 || $crud != 'create') { |
if ($maj != 0 || $crud != 'create') { |
570 |
$form->setLib('json_payload', ''); |
$form->setLib('json_payload', ''); |
571 |
|
$form->setLib("task", __("identifiant")); |
572 |
|
$form->setLib("Task_portal", __("task_portal")); |
573 |
|
$form->setLib("type", __("type")); |
574 |
|
$form->setLib("object_id", __("Réf. interne")); |
575 |
|
$form->setLib("stream", __("flux")); |
576 |
|
$form->setLib("timestamp_log", __("Historique")); |
577 |
} |
} |
578 |
} |
} |
579 |
|
|
633 |
$this->valF['stream'] == 'input')) { |
$this->valF['stream'] == 'input')) { |
634 |
|
|
635 |
// décode la payload JSON |
// décode la payload JSON |
636 |
|
// TODO : COMMENTER |
637 |
$json_payload = json_decode($this->valF['json_payload'], true); |
$json_payload = json_decode($this->valF['json_payload'], true); |
638 |
|
|
639 |
// défini une liste de chemin de clés requises |
// défini une liste de chemin de clés requises |
640 |
$paths = array(); |
$paths = array(); |
641 |
if ($this->valF['category'] === 'platau') { |
if ($this->valF['category'] === PLATAU) { |
642 |
$paths = array( |
$paths = array( |
643 |
'external_uids/dossier' |
'external_uids/dossier' |
644 |
); |
); |
716 |
* @return [type] [description] |
* @return [type] [description] |
717 |
*/ |
*/ |
718 |
public function task_exists(string $type, string $object_id, string $dossier = null, bool $is_not_done = true) { |
public function task_exists(string $type, string $object_id, string $dossier = null, bool $is_not_done = true) { |
719 |
$query = sprintf(' |
$qres = $this->f->get_one_result_from_db_query( |
720 |
SELECT task |
sprintf( |
721 |
FROM %1$stask |
'SELECT |
722 |
WHERE %2$s |
task |
723 |
type = \'%3$s\' |
FROM |
724 |
AND (object_id = \'%4$s\' |
%1$stask |
725 |
%5$s) |
WHERE |
726 |
AND state != \'%6$s\' |
%2$s |
727 |
', |
type = \'%3$s\' |
728 |
DB_PREFIXE, |
AND ( |
729 |
$is_not_done == true ? 'state != \''.self::STATUS_DONE.'\' AND' : '', |
object_id = \'%4$s\' |
730 |
$type, |
%5$s |
731 |
$object_id, |
) |
732 |
$dossier !== null ? sprintf('OR dossier = \'%s\'', $dossier) : '', |
AND state != \'%6$s\'', |
733 |
self::STATUS_CANCELED |
DB_PREFIXE, |
734 |
|
$is_not_done == true ? 'state != \''.self::STATUS_DONE.'\' AND' : '', |
735 |
|
$type, |
736 |
|
$object_id, |
737 |
|
$dossier !== null ? sprintf('OR dossier = \'%s\'', $dossier) : '', |
738 |
|
self::STATUS_CANCELED |
739 |
|
), |
740 |
|
array( |
741 |
|
"origin" => __METHOD__, |
742 |
|
) |
743 |
); |
); |
744 |
$res = $this->f->get_one_result_from_db_query($query); |
if ($qres["result"] !== null && $qres["result"] !== "") { |
745 |
if ($res['result'] !== null && $res['result'] !== '') { |
return $qres["result"]; |
|
return $res['result']; |
|
746 |
} |
} |
747 |
return false; |
return false; |
748 |
} |
} |
759 |
FROM %1$stask |
FROM %1$stask |
760 |
%2$s |
%2$s |
761 |
%3$s |
%3$s |
762 |
|
ORDER BY task ASC |
763 |
', |
', |
764 |
DB_PREFIXE, |
DB_PREFIXE, |
765 |
empty($search_values) === false ? ' WHERE ' : '', |
empty($search_values) === false ? ' WHERE ' : '', |
766 |
implode(' AND ', $search_values) |
implode(' AND ', $search_values) |
767 |
); |
); |
768 |
$res = $this->f->get_all_results_from_db_query($query); |
$res = $this->f->get_all_results_from_db_query( |
769 |
|
$query, |
770 |
|
array( |
771 |
|
"origin" => __METHOD__, |
772 |
|
) |
773 |
|
); |
774 |
if (count($res['result']) > 0) { |
if (count($res['result']) > 0) { |
775 |
return $res['result']; |
return $res['result']; |
776 |
} |
} |
805 |
|
|
806 |
// gestion d'une tache de type notification et de category mail |
// gestion d'une tache de type notification et de category mail |
807 |
if (isset($val['type']) |
if (isset($val['type']) |
808 |
&& ((//$val['type'] === 'notification_recepisse' |
&& (($val['type'] === 'notification_instruction' || $val['type'] === 'notification_decision') |
809 |
$val['type'] === 'notification_instruction' |
&& isset($val['category']) |
810 |
|| $val['type'] === 'notification_decision') |
&& $val['category'] === 'mail') |
|
&& isset($val['category']) |
|
|
&& $val['category'] === 'mail') |
|
811 |
|| $val['type'] === 'notification_service_consulte' |
|| $val['type'] === 'notification_service_consulte' |
812 |
|| $val['type'] === 'notification_tiers_consulte' |
|| $val['type'] === 'notification_tiers_consulte' |
813 |
|
|| $val['type'] === 'notification_depot_demat' |
814 |
|
|| $val['type'] === 'notification_commune' |
815 |
|
|| $val['type'] === 'notification_signataire' |
816 |
) { |
) { |
817 |
// Récupère la payload de la tache |
// Récupère la payload de la tache |
818 |
$data = array(); |
$data = array(); |
819 |
// TODO : pour l'instant la gestion des notifs des demandeurs a été séparée |
$data['instruction_notification'] = $this->get_instruction_notification_data( |
820 |
// de celle des autres type de notif afin de ne pas risquer de casser l'existant |
$this->valF['category'], |
821 |
// et pour des contraintes de temps. A optimiser plus tard |
'with-id', |
822 |
if ($val['type'] === 'notification_service_consulte' |
array('with-id' => $this->valF['object_id']) |
823 |
|| $val['type'] === 'notification_tiers_consulte') { |
); |
|
$data['instruction_notification'] = $this->get_instruction_notification_data_annexe_multiple( |
|
|
$this->valF['category'], |
|
|
'with-id', |
|
|
array('with-id' => $this->valF['object_id']) |
|
|
); |
|
|
} else { |
|
|
$data['instruction_notification'] = $this->get_instruction_notification_data( |
|
|
$this->valF['category'], |
|
|
'with-id', |
|
|
array('with-id' => $this->valF['object_id']) |
|
|
); |
|
|
} |
|
824 |
$data['dossier'] = $this->get_dossier_data($this->valF['dossier']); |
$data['dossier'] = $this->get_dossier_data($this->valF['dossier']); |
825 |
|
|
826 |
// Récupère l'instance de la notification |
// Récupère l'instance de la notification |
840 |
} |
} |
841 |
|
|
842 |
/** |
/** |
843 |
|
* TRIGGER - triggermodifier. |
844 |
|
* |
845 |
|
* @param string $id |
846 |
|
* @param null &$dnu1 @deprecated Ne pas utiliser. |
847 |
|
* @param array $val Tableau des valeurs brutes. |
848 |
|
* @param null $dnu2 @deprecated Ne pas utiliser. |
849 |
|
* |
850 |
|
* @return boolean |
851 |
|
*/ |
852 |
|
function triggermodifier($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
853 |
|
parent::triggermodifier($id, $dnu1, $val, $dnu2); |
854 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
855 |
|
|
856 |
|
// Mise à jour des valeurs, notamment du timestamp_log en fonction de plusieurs critères |
857 |
|
$values = array( |
858 |
|
'state' => $this->valF['state'], |
859 |
|
'object_id' => $this->valF['object_id'], |
860 |
|
'comment' => $this->valF['comment'], |
861 |
|
); |
862 |
|
$new_values = $this->set_values_for_update($values); |
863 |
|
if ($new_values === false) { |
864 |
|
$this->addToLog(__METHOD__."(): erreur timestamp log", DEBUG_MODE); |
865 |
|
return false; |
866 |
|
} |
867 |
|
|
868 |
|
// Mise à jour des valeurs |
869 |
|
$this->valF['timestamp_log'] = $new_values['timestamp_log']; |
870 |
|
$this->valF['state'] = $new_values['state']; |
871 |
|
$this->valF['object_id'] = $new_values['object_id']; |
872 |
|
$this->valF['last_modification_date'] = date('Y-m-d'); |
873 |
|
$this->valF['last_modification_time'] = date('H:i:s'); |
874 |
|
if ($val['stream'] === 'output') { |
875 |
|
// Lorsque la task passe d'un état qui n'est pas "done" à l'état "done" |
876 |
|
if ($this->getVal("state") !== self::STATUS_DONE |
877 |
|
&& $this->valF['state'] === self::STATUS_DONE) { |
878 |
|
// |
879 |
|
$this->valF['json_payload'] = $this->view_form_json(true); |
880 |
|
} |
881 |
|
// Lorsque la task passe d'un état "done" à un état qui n'est pas "done" |
882 |
|
if ($this->getVal("state") === self::STATUS_DONE |
883 |
|
&& $this->valF['state'] !== self::STATUS_DONE) { |
884 |
|
// |
885 |
|
$this->valF['json_payload'] = "{}"; |
886 |
|
} |
887 |
|
} |
888 |
|
|
889 |
|
return true; |
890 |
|
} |
891 |
|
|
892 |
|
|
893 |
|
/** |
894 |
|
* Applique nouvelle valeur après traitement. |
895 |
|
* |
896 |
|
* @param array $params Tableau des valeurs en entrées |
897 |
|
* @return array Tableau des valeurs en sorties |
898 |
|
*/ |
899 |
|
public function set_values_for_update($params = array()) { |
900 |
|
|
901 |
|
// Récupération du timestamp_log existant |
902 |
|
$timestamp_log = $this->get_timestamp_log(); |
903 |
|
if ($timestamp_log === false) { |
904 |
|
return false; |
905 |
|
} |
906 |
|
|
907 |
|
// Vérification des object_id précédent en cas de tentative d'appliquer |
908 |
|
// l'état CANCELED sur la tâche |
909 |
|
if (isset($params['state']) === true |
910 |
|
&& $params['state'] === self::STATUS_CANCELED) { |
911 |
|
// Récupération du journal d'activité de la tâche sous forme de tableau |
912 |
|
// trié par ordre décroissant |
913 |
|
$log = $timestamp_log; |
914 |
|
krsort($log); |
915 |
|
// Pour chaque entrée dans le journal d'activité de la tâche : |
916 |
|
// - vérification de la présence de l'object_id précédent |
917 |
|
// - vérification que l'object_id précédent existe toujours dans la base de données |
918 |
|
// - l'object_id est mise à jour avec la valeur de l'object_id précédent |
919 |
|
// - le state n'est pas modifié |
920 |
|
// - sortie du traitement dès que le premier object_id précédent existant est trouvé |
921 |
|
// - si aucun object_id précédent existant n'est trouvé alors ni le state, ni l'object_id n'est modifiés |
922 |
|
foreach ($log as $key => $value) { |
923 |
|
// |
924 |
|
if (isset($value['prev_object_id']) === true |
925 |
|
&& $this->getVal('object_id') !== $value['prev_object_id']) { |
926 |
|
// Récupère la liste des tables potentielles pour un type de tâche |
927 |
|
$tables = $this->get_tables_by_task_type($this->getVal('type'), $this->getVal('stream')); |
928 |
|
foreach ($tables as $table) { |
929 |
|
// Vérifie s'il y a un ou aucun résultat |
930 |
|
$qres = $this->f->get_one_result_from_db_query( |
931 |
|
sprintf( |
932 |
|
'SELECT |
933 |
|
COUNT(%2$s) |
934 |
|
FROM |
935 |
|
%1$s%2$s |
936 |
|
WHERE |
937 |
|
%2$s::CHARACTER VARYING = \'%3$s\'', |
938 |
|
DB_PREFIXE, |
939 |
|
$table, |
940 |
|
$value['prev_object_id'] |
941 |
|
), |
942 |
|
array( |
943 |
|
"origin" => __METHOD__, |
944 |
|
"force_return" => true, |
945 |
|
) |
946 |
|
); |
947 |
|
if ($qres["code"] !== "OK") { |
948 |
|
return $this->end_treatment(__METHOD__, false); |
949 |
|
} |
950 |
|
// Affectation des valeurs et sortie de la boucle |
951 |
|
if ($qres["result"] == '1') { |
952 |
|
$params['object_id'] = $value['prev_object_id']; |
953 |
|
$params['state'] = $this->getVal('state'); |
954 |
|
break; |
955 |
|
} |
956 |
|
} |
957 |
|
// Sortie de la boucle si les valeurs sont affectées |
958 |
|
if ($params['object_id'] !== null |
959 |
|
&& $params['object_id'] === $value['prev_object_id']) { |
960 |
|
// |
961 |
|
break; |
962 |
|
} |
963 |
|
} |
964 |
|
} |
965 |
|
} |
966 |
|
|
967 |
|
// Mise à jour du journal d'activité de la tâche |
968 |
|
array_push($timestamp_log, array( |
969 |
|
'modification_date' => date('Y-m-d H:i:s'), |
970 |
|
'object_id' => $params['object_id'] !== null ? $params['object_id'] : $this->getVal('object_id'), |
971 |
|
'prev_object_id' => $this->getVal('object_id'), |
972 |
|
'state' => $params['state'], |
973 |
|
'prev_state' => $this->getVal('state'), |
974 |
|
'comment' => isset($params['comment']) ? $params['comment'] : $this->getVal('comment'), |
975 |
|
)); |
976 |
|
// |
977 |
|
$timestamp_log = json_encode($timestamp_log); |
978 |
|
|
979 |
|
|
980 |
|
// Les nouvelles valeurs après vérification des critères |
981 |
|
$result = array( |
982 |
|
'timestamp_log' => $timestamp_log, |
983 |
|
'object_id' => $params['object_id'], |
984 |
|
'state' => $params['state'], |
985 |
|
'comment' => $params['comment'], |
986 |
|
); |
987 |
|
return $result; |
988 |
|
} |
989 |
|
|
990 |
|
|
991 |
|
/** |
992 |
* TRIGGER - triggermodifierapres. |
* TRIGGER - triggermodifierapres. |
993 |
* |
* |
994 |
* @param string $id |
* @param string $id |
1005 |
// En cas de changement de l'état de la tâche de notification, alors |
// En cas de changement de l'état de la tâche de notification, alors |
1006 |
// le suivi des dates de la notification et de l'instruction, est effectué |
// le suivi des dates de la notification et de l'instruction, est effectué |
1007 |
if (isset($val['category']) === true |
if (isset($val['category']) === true |
1008 |
&& $val['category'] === 'portal' |
&& $val['category'] === PORTAL |
1009 |
&& isset($val['type']) === true |
&& isset($val['type']) === true |
1010 |
&& ($val['type'] === 'notification_recepisse' |
&& ($val['type'] === 'notification_recepisse' |
1011 |
|| $val['type'] === 'notification_instruction' |
|| $val['type'] === 'notification_instruction' |
1048 |
} |
} |
1049 |
$valF_instruction['date_envoi_rar'] = date('d/m/Y'); |
$valF_instruction['date_envoi_rar'] = date('d/m/Y'); |
1050 |
$valF_instruction['date_retour_rar'] = date('d/m/Y', strtotime('now + 1 day')); |
$valF_instruction['date_retour_rar'] = date('d/m/Y', strtotime('now + 1 day')); |
1051 |
$inst_instruction->setParameter('maj', 1); |
// Action spécifique pour identifier que la modification |
1052 |
|
// est une notification de demandeur |
1053 |
|
$inst_instruction->setParameter('maj', 175); |
1054 |
$update_instruction = $inst_instruction->modifier($valF_instruction); |
$update_instruction = $inst_instruction->modifier($valF_instruction); |
1055 |
if ($update_instruction === false) { |
if ($update_instruction === false) { |
1056 |
$this->addToLog(__METHOD__."(): ".$inst_instruction->msg, DEBUG_MODE); |
$this->addToLog(__METHOD__."(): ".$inst_instruction->msg, DEBUG_MODE); |
1142 |
// Si la tâche est de type ajout_piece et de stream input alors on ajoute le fichier |
// Si la tâche est de type ajout_piece et de stream input alors on ajoute le fichier |
1143 |
// et on ajoute l'uid dans le champ json_payload avant l'ajout de la tâche |
// et on ajoute l'uid dans le champ json_payload avant l'ajout de la tâche |
1144 |
if (isset($params['val']['type']) |
if (isset($params['val']['type']) |
1145 |
&& ($params['val']['type'] == "add_piece" || $params['val']['type'] == "avis_consultation") |
&& in_array($params['val']['type'], self::TASK_WITH_DOCUMENT) |
1146 |
&& isset($params['val']['stream']) |
&& isset($params['val']['stream']) |
1147 |
&& $params['val']['stream'] == "input" ) { |
&& $params['val']['stream'] == "input" ) { |
1148 |
// |
// |
1151 |
$this->addToMessage(__("Le contenu JSON de la tâche n'est pas valide.")); |
$this->addToMessage(__("Le contenu JSON de la tâche n'est pas valide.")); |
1152 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
1153 |
} |
} |
1154 |
if (isset($json_payload['document_numerise']) === true |
if (isset($json_payload['document_numerise']["file_content"]) === true |
1155 |
&& empty($json_payload['document_numerise']) === false) { |
&& empty($json_payload['document_numerise']["file_content"]) === false) { |
1156 |
// |
// |
1157 |
$document_numerise = $json_payload['document_numerise']; |
$document_numerise = $json_payload['document_numerise']; |
1158 |
$file_content = base64_decode($document_numerise["file_content"]); |
$file_content = base64_decode($document_numerise["file_content"]); |
1178 |
} |
} |
1179 |
} |
} |
1180 |
|
|
1181 |
// Mise à jour du DI |
// Valeurs de la tâche |
1182 |
$valF = array( |
$valF = array( |
1183 |
'task' => '', |
'task' => '', |
1184 |
'type' => $params['val']['type'], |
'type' => $params['val']['type'], |
1193 |
'creation_time' => date('H:i:s'), |
'creation_time' => date('H:i:s'), |
1194 |
'last_modification_date' => null, |
'last_modification_date' => null, |
1195 |
'last_modification_time' => null, |
'last_modification_time' => null, |
1196 |
|
'comment' => null, |
1197 |
); |
); |
1198 |
|
|
1199 |
// tâche sortante |
// Gestion de la mise à jour des tâches sortantes |
1200 |
$typeNonConcerne = array( |
$typeNonConcerne = array( |
1201 |
'notification_recepisse', |
'notification_recepisse', |
1202 |
'notification_instruction', |
'notification_instruction', |
1203 |
'notification_decision', |
'notification_decision', |
1204 |
'notification_service_consulte', |
'notification_service_consulte', |
1205 |
'notification_tiers_consulte' |
'notification_tiers_consulte', |
1206 |
|
'notification_signataire' |
1207 |
); |
); |
1208 |
if ($valF["stream"] == "output" |
if ($valF["stream"] == "output" |
1209 |
&& ! in_array($valF['type'], $typeNonConcerne)) { |
&& ! in_array($valF['type'], $typeNonConcerne)) { |
1210 |
// TODO expliquer ce code |
// Vérification de l'existance d'une tâche pour l'objet concerné |
1211 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id'], $valF['dossier']); |
// La vérification diffère en fonction de certains types de tâche |
1212 |
|
$search_values_common = array( |
1213 |
|
sprintf('state != \'%s\'', self::STATUS_CANCELED), |
1214 |
|
sprintf('state != \'%s\'', self::STATUS_DONE), |
1215 |
|
); |
1216 |
|
$search_values_others = array( |
1217 |
|
sprintf('type = \'%s\'', $valF['type']), |
1218 |
|
sprintf('(object_id = \'%s\' OR dossier = \'%s\')', $valF['object_id'], $valF['dossier']), |
1219 |
|
); |
1220 |
|
$search_values_specifics = array( |
1221 |
|
sprintf('object_id = \'%s\'', $valF['object_id']), |
1222 |
|
); |
1223 |
|
|
1224 |
|
// Recherche multi-critères sur les tâches |
1225 |
|
// Si l'object id/dossier à des tâches de type $valF['type'] qui lui est associé |
1226 |
|
// Et que ces tâches ont des statut différents de canceled et done |
1227 |
|
// Alors on récupère ces tâches |
1228 |
|
// Sinon return false |
1229 |
|
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_others)); |
1230 |
|
|
1231 |
|
// S'il n'existe pas de tâche de type 'modification DI' pour l'object id/dossier |
1232 |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
1233 |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
// On se réfère à la tâche de type 'creation DI' de l'object id |
1234 |
|
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_specifics, array("type = 'creation_DI'"))); |
1235 |
} |
} |
1236 |
|
// S'il n'existe pas de tâche de type 'modification DA' pour l'object id/dossier |
1237 |
if ($valF['type'] === 'modification_DA' && $task_exists === false) { |
if ($valF['type'] === 'modification_DA' && $task_exists === false) { |
1238 |
$task_exists = $this->task_exists('creation_DA', $valF['object_id']); |
// On se réfère à la tâche de type 'creation DA' de l'object id |
1239 |
|
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_specifics, array("type = 'creation_DA'"))); |
1240 |
} |
} |
1241 |
if ($valF['type'] === 'ajout_piece') { |
if ($valF['type'] === 'ajout_piece') { |
1242 |
$task_exists = $this->task_exists('ajout_piece', $valF['object_id']); |
// On se réfère à la tâche de type 'ajout piece' de l'object id |
1243 |
|
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_specifics, array("type = 'ajout_piece'"))); |
1244 |
} |
} |
1245 |
if ($valF['type'] === 'creation_consultation') { |
if ($valF['type'] === 'creation_consultation') { |
1246 |
$task_exists = $this->task_exists('creation_consultation', $valF['object_id']); |
// On se réfère à la tâche de type 'creation consultation' de l'object id |
1247 |
|
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_specifics, array("type = 'creation_consultation'"))); |
1248 |
} |
} |
1249 |
|
// S'il existe une tâche pour l'objet concerné, pas d'ajout de nouvelle |
1250 |
|
// tâche mais mise à jour de l'existante |
1251 |
if ($task_exists !== false) { |
if ($task_exists !== false) { |
1252 |
$inst_task = $this->f->get_inst__om_dbform(array( |
// Plusieurs tâches pourraient exister, elles sont contôler par ordre croissant |
1253 |
"obj" => "task", |
foreach ($task_exists as $task) { |
1254 |
"idx" => $task_exists, |
$inst_task = $this->f->get_inst__om_dbform(array( |
1255 |
)); |
"obj" => "task", |
1256 |
$update_state = $inst_task->getVal('state'); |
"idx" => $task['task'], |
1257 |
if (isset($params['update_val']['state']) === true) { |
)); |
1258 |
$update_state = $params['update_val']['state']; |
$update_state = $inst_task->getVal('state'); |
1259 |
} |
if (isset($params['update_val']['state']) === true) { |
1260 |
$update_params = array( |
$update_state = $params['update_val']['state']; |
1261 |
'val' => array( |
} |
1262 |
'state' => $update_state, |
$object_id = $inst_task->getVal('object_id'); |
1263 |
), |
if (!empty($valF['object_id'])) { |
1264 |
'object_id' => $valF['object_id'], |
$object_id = $valF['object_id']; |
1265 |
); |
} |
1266 |
return $inst_task->update_task($update_params); |
// Pour être mise à jour, la tâche existante ne doit pas être en cours de traitement |
1267 |
|
$task_pending = $inst_task->getVal('state') === self::STATUS_PENDING |
1268 |
|
&& $update_state === self::STATUS_PENDING |
1269 |
|
&& $inst_task->getVal('object_id') !== $object_id; |
1270 |
|
if ($task_pending === false) { |
1271 |
|
$update_params = array( |
1272 |
|
'val' => array( |
1273 |
|
'state' => $update_state, |
1274 |
|
), |
1275 |
|
'object_id' => $object_id, |
1276 |
|
); |
1277 |
|
return $inst_task->update_task($update_params); |
1278 |
|
} |
1279 |
|
} |
1280 |
} |
} |
1281 |
} |
} |
1282 |
$add = $this->ajouter($valF); |
$add = $this->ajouter($valF); |
1297 |
*/ |
*/ |
1298 |
public function update_task($params = array()) { |
public function update_task($params = array()) { |
1299 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
1300 |
$timestamp_log = $this->get_timestamp_log(); |
|
|
if ($timestamp_log === false) { |
|
|
$this->addToLog(__METHOD__."(): erreur timestamp log", DEBUG_MODE); |
|
|
return $this->end_treatment(__METHOD__, false); |
|
|
} |
|
|
// Vérification des object_id précédent en cas de tentative d'appliquer |
|
|
// l'état CANCELED sur la tâche |
|
|
if (isset($params['val']['state']) === true |
|
|
&& $params['val']['state'] === self::STATUS_CANCELED) { |
|
|
// Récupération du journal d'activité de la tâche sous forme de tableau |
|
|
// trié par ordre décroissant |
|
|
$log = $timestamp_log; |
|
|
unset($log['creation_date']); |
|
|
krsort($log); |
|
|
// Pour chaque entrée dans le journal d'activité de la tâche : |
|
|
// - vérification de la présence de l'object_id précédent |
|
|
// - vérification que l'object_id précédent existe toujours dans la base de données |
|
|
// - l'object_id est mise à jour avec la valeur de l'object_id précédent |
|
|
// - le state n'est pas modifié |
|
|
// - sortie du traitement dès que le premier object_id précédent existant est trouvé |
|
|
// - si aucun object_id précédent existant n'est trouvé alors ni le state, ni l'object_id n'est modifiés |
|
|
foreach ($log as $key => $value) { |
|
|
// |
|
|
if (isset($value['prev_object_id']) === true |
|
|
&& $this->getVal('object_id') !== $value['prev_object_id']) { |
|
|
// Récupère la liste des tables potentielles pour un type de tâche |
|
|
$tables = $this->get_tables_by_task_type($this->getVal('type'), $this->getVal('stream')); |
|
|
foreach ($tables as $table) { |
|
|
// Vérifie s'il y a un ou aucun résultat |
|
|
$query = sprintf(' |
|
|
SELECT COUNT(%2$s) |
|
|
FROM %1$s%2$s |
|
|
WHERE %2$s::CHARACTER VARYING = \'%3$s\' |
|
|
', |
|
|
DB_PREFIXE, |
|
|
$table, |
|
|
$value['prev_object_id'] |
|
|
); |
|
|
$res = $this->f->get_one_result_from_db_query($query, true); |
|
|
if ($res['code'] === 'KO') { |
|
|
return $this->end_treatment(__METHOD__, false); |
|
|
} |
|
|
// Affectation des valeurs et sortie de la boucle |
|
|
if ($res['result'] == '1') { |
|
|
$params['object_id'] = $value['prev_object_id']; |
|
|
$params['val']['state'] = $this->getVal('state'); |
|
|
break; |
|
|
} |
|
|
} |
|
|
// Sortie de la boucle si les valeurs sont affectées |
|
|
if (isset($params['object_id']) === true |
|
|
&& $params['object_id'] === $value['prev_object_id']) { |
|
|
// |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
// Mise à jour du journal d'activité de la tâche |
|
|
array_push($timestamp_log, array( |
|
|
'modification_date' => date('Y-m-d H:i:s'), |
|
|
'state' => $params['val']['state'], |
|
|
'prev_state' => $this->getVal('state'), |
|
|
'object_id' => isset($params['object_id']) == true ? $params['object_id'] : $this->getVal('object_id'), |
|
|
'prev_object_id' => $this->getVal('object_id'), |
|
|
)); |
|
|
$timestamp_log = json_encode($timestamp_log); |
|
1301 |
// Mise à jour de la tâche |
// Mise à jour de la tâche |
1302 |
$valF = array( |
$valF = array( |
1303 |
'task' => $this->getVal($this->clePrimaire), |
'task' => $this->getVal($this->clePrimaire), |
1304 |
'type' => $this->getVal('type'), |
'type' => $this->getVal('type'), |
1305 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => '[]', |
1306 |
'state' => $params['val']['state'], |
'state' => $params['val']['state'], |
1307 |
'object_id' => isset($params['object_id']) == true ? $params['object_id'] : $this->getVal('object_id'), |
'object_id' => isset($params['object_id']) == true ? $params['object_id'] : $this->getVal('object_id'), |
1308 |
'stream' => $this->getVal('stream'), |
'stream' => $this->getVal('stream'), |
1313 |
'creation_time' => $this->getVal('creation_time'), |
'creation_time' => $this->getVal('creation_time'), |
1314 |
'last_modification_date' => date('Y-m-d'), |
'last_modification_date' => date('Y-m-d'), |
1315 |
'last_modification_time' => date('H:i:s'), |
'last_modification_time' => date('H:i:s'), |
1316 |
|
'comment' => isset($params['comment']) == true ? $params['comment'] : $this->getVal('comment'), |
1317 |
); |
); |
1318 |
$update = $this->modifier($valF); |
$update = $this->modifier($valF); |
1319 |
if ($update === false) { |
if ($update === false) { |
1415 |
DB_PREFIXE, |
DB_PREFIXE, |
1416 |
$where |
$where |
1417 |
); |
); |
1418 |
$res = $this->f->get_all_results_from_db_query($query, true); |
$res = $this->f->get_all_results_from_db_query( |
1419 |
|
$query, |
1420 |
|
array( |
1421 |
|
"origin" => __METHOD__, |
1422 |
|
"force_return" => true, |
1423 |
|
) |
1424 |
|
); |
1425 |
if ($res['code'] === 'KO') { |
if ($res['code'] === 'KO') { |
1426 |
return false; |
return false; |
1427 |
} |
} |
1542 |
if (isset($val_dt['tax_ext_pret']) === true |
if (isset($val_dt['tax_ext_pret']) === true |
1543 |
&& $val_dt['tax_ext_pret'] === 'f') { |
&& $val_dt['tax_ext_pret'] === 'f') { |
1544 |
// |
// |
1545 |
$val_dt['tax_su_princ_surf1'] = $val_dt['tax_surf_tot_cstr']; |
$val_dt['tax_su_princ_surf1'] = isset($val_dt['tax_surf_tot_cstr']) === true ? $val_dt['tax_surf_tot_cstr'] : ''; |
1546 |
$val_dt['tax_su_princ_surf_stat1'] = $val_dt['tax_surf_loc_stat']; |
$val_dt['tax_su_princ_surf_stat1'] = isset($val_dt['tax_surf_loc_stat']) === true ? $val_dt['tax_surf_loc_stat'] : ''; |
1547 |
} |
} |
1548 |
if (isset($val_dt['tax_ext_pret']) === true |
if (isset($val_dt['tax_ext_pret']) === true |
1549 |
&& $val_dt['tax_ext_pret'] === 't') { |
&& $val_dt['tax_ext_pret'] === 't') { |
1552 |
if (preg_match('/[pP].*[lL].*[aA].*[iI]/', $val_dt['tax_ext_desc']) === 1 |
if (preg_match('/[pP].*[lL].*[aA].*[iI]/', $val_dt['tax_ext_desc']) === 1 |
1553 |
|| preg_match('/[lL].*[lL].*[tT].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
|| preg_match('/[lL].*[lL].*[tT].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
1554 |
// |
// |
1555 |
$val_dt['tax_su_princ_surf2'] = $val_dt['tax_surf_tot_cstr']; |
$val_dt['tax_su_princ_surf2'] = isset($val_dt['tax_surf_tot_cstr']) === true ? $val_dt['tax_surf_tot_cstr'] : ''; |
1556 |
$val_dt['tax_su_princ_surf_stat2'] = $val_dt['tax_surf_loc_stat']; |
$val_dt['tax_su_princ_surf_stat2'] = isset($val_dt['tax_surf_loc_stat']) === true ? $val_dt['tax_surf_loc_stat'] : ''; |
1557 |
} |
} |
1558 |
// if (preg_match('/[pP].*[tT].*[zZ]/', $val_dt['tax_ext_desc']) === 1) { |
// if (preg_match('/[pP].*[tT].*[zZ]/', $val_dt['tax_ext_desc']) === 1) { |
1559 |
// $val_dt['tax_su_princ_surf4'] = $val_dt['tax_surf_tot_cstr']; |
// $val_dt['tax_su_princ_surf4'] = $val_dt['tax_surf_tot_cstr']; |
1597 |
', |
', |
1598 |
DB_PREFIXE |
DB_PREFIXE |
1599 |
); |
); |
1600 |
$res = $this->f->get_all_results_from_db_query($query, true); |
$res = $this->f->get_all_results_from_db_query( |
1601 |
|
$query, |
1602 |
|
array( |
1603 |
|
"origin" => __METHOD__, |
1604 |
|
"force_return" => true, |
1605 |
|
) |
1606 |
|
); |
1607 |
if ($res['code'] === 'KO') { |
if ($res['code'] === 'KO') { |
1608 |
return array(); |
return array(); |
1609 |
} |
} |
1614 |
return $result; |
return $result; |
1615 |
} |
} |
1616 |
|
|
1617 |
protected function get_external_uid($fk_idx, string $fk_idx_2, $fk_idx_3 = 'platau', $order_asc_desc = 'DESC') { |
protected function get_external_uid($fk_idx, string $fk_idx_2, $fk_idx_3 = PLATAU, $order_asc_desc = 'DESC') { |
1618 |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
1619 |
"obj" => "lien_id_interne_uid_externe", |
"obj" => "lien_id_interne_uid_externe", |
1620 |
"fk_field" => 'object_id', |
"fk_field" => 'object_id', |
1629 |
return $inst_external_uid->getVal('external_uid'); |
return $inst_external_uid->getVal('external_uid'); |
1630 |
} |
} |
1631 |
|
|
1632 |
protected function get_all_external_uids($fk_idx, $link_objects = array(), $category='platau') { |
protected function get_all_external_uids($fk_idx, $link_objects = array(), $category=PLATAU) { |
1633 |
if (count($link_objects) == 0) { |
if (count($link_objects) == 0) { |
1634 |
$link_objects = $this->get_list_distinct_objects_external_link(); |
$link_objects = $this->get_list_distinct_objects_external_link(); |
1635 |
} |
} |
1742 |
return $val_instruction; |
return $val_instruction; |
1743 |
} |
} |
1744 |
|
|
1745 |
|
|
1746 |
/** |
/** |
1747 |
* Récupère les informations |
* Récupère les informations pour les notifications ayant plusieurs annexe |
1748 |
*/ |
*/ |
1749 |
protected function get_instruction_notification_data($category, $type = '', $extra_params = array()) { |
protected function get_instruction_notification_data($category, $type = '', $extra_params = array()) { |
1750 |
$val_in = null; |
$val_in = null; |
1754 |
$idx = $extra_params['with-id']; |
$idx = $extra_params['with-id']; |
1755 |
} |
} |
1756 |
|
|
1757 |
|
// Récupération du type de notification. Le type est nécessaire pour récupérer |
1758 |
|
// le message et le titre de notification. |
1759 |
|
$typeNotification = $this->getVal('type'); |
1760 |
|
if (isset($this->valF['type'])) { |
1761 |
|
$typeNotification = $this->valF['type']; |
1762 |
|
} |
1763 |
|
|
1764 |
// récupére les données à intégrer à la payload |
// récupére les données à intégrer à la payload |
1765 |
$inst_in = $this->f->get_inst__om_dbform(array( |
$inst_in = $this->f->get_inst__om_dbform(array( |
1766 |
"obj" => "instruction_notification", |
"obj" => "instruction_notification", |
1778 |
"idx" => $inst_in->getVal('instruction'), |
"idx" => $inst_in->getVal('instruction'), |
1779 |
)); |
)); |
1780 |
$collectivite_id = $inst_instruction->get_dossier_instruction_om_collectivite($inst_instruction->getVal('dossier')); |
$collectivite_id = $inst_instruction->get_dossier_instruction_om_collectivite($inst_instruction->getVal('dossier')); |
1781 |
$phrase_type_notification = array(); |
$phrase_type_notification = $this->f->get_notification_parametre_courriel_type($collectivite_id, $typeNotification); |
|
$phrase_type_notification = $this->f->get_notification_parametre_courriel_type($collectivite_id, $this->valF['type']); |
|
1782 |
$val_in['parametre_courriel_type_titre'] = $phrase_type_notification['parametre_courriel_type_titre']; |
$val_in['parametre_courriel_type_titre'] = $phrase_type_notification['parametre_courriel_type_titre']; |
1783 |
$val_in['parametre_courriel_type_message'] = $phrase_type_notification['parametre_courriel_type_message']; |
$val_in['parametre_courriel_type_message'] = $phrase_type_notification['parametre_courriel_type_message']; |
1784 |
} |
} |
1785 |
|
|
1786 |
// Récupération des liens vers les documents et de l'id de l'instruction |
if ($typeNotification == 'notification_signataire') { |
1787 |
// de l'annexe |
$val_in['lien_page_signature'] = $inst_in->getLienPageSignature($inst_instruction); |
1788 |
$infoDocNotif = $inst_in->getInfosDocumentsNotif($inst_in->getVal($inst_in->clePrimaire)); |
} |
1789 |
$val_in['lien_telechargement_document'] = $infoDocNotif['document']['lien']; |
else { |
1790 |
$val_in['lien_telechargement_annexe'] = $infoDocNotif['annexe']['lien']; |
// Récupération des liens vers les documents et des id et type des annexes |
1791 |
$val_in['instruction_annexe'] = $infoDocNotif['annexe']['id_instruction']; |
$infoDocNotif = $inst_in->getInfosDocumentsNotif($inst_in->getVal($inst_in->clePrimaire), $category); |
1792 |
|
$cle = $category == PORTAL ? 'path' : 'lien_telechargement_document'; |
1793 |
|
$val_in[$cle] = $infoDocNotif['document']['path']; |
1794 |
|
$val_in['annexes'] = $infoDocNotif['annexes']; |
1795 |
|
} |
1796 |
} |
} |
|
|
|
1797 |
return $val_in; |
return $val_in; |
1798 |
} |
} |
1799 |
|
|
1800 |
/** |
/** |
1801 |
* Récupère les informations pour les notifications ayant plusieurs annexe |
* Récupère les informations concernant la lettre au pétitionnaire. |
1802 |
*/ |
* |
1803 |
protected function get_instruction_notification_data_annexe_multiple($category, $type = '', $extra_params = array()) { |
* @param string identifiant du dossier |
1804 |
$val_in = null; |
* @param string type de tâche |
1805 |
|
* @param array paramètre supplémentaire permettant de récupérer les informations |
1806 |
$idx = null; |
* |
1807 |
if ($type === 'with-id') { |
* @return array information concernant la lettre au pétitionnaire |
1808 |
$idx = $extra_params['with-id']; |
*/ |
1809 |
|
protected function get_lettre_petitionnaire_data($dossier, $type, $extra_params = array()) { |
1810 |
|
// Si la date limite de notification n'a pas été dépassé le type de lettre est 1 |
1811 |
|
// Si la date a été dépassé et qu'il s'agit d'une demande de pièce le type est 3 |
1812 |
|
// Si la date a été dépassé et qu'il s'agit d'une prolongation le type est 4 |
1813 |
|
// Le type de document dépend du type de pièce |
1814 |
|
$nomTypeLettre = ''; |
1815 |
|
$nomTypeDocument = ''; |
1816 |
|
if ($type === 'lettre_incompletude') { |
1817 |
|
$nomTypeLettre = '3'; |
1818 |
|
$nomTypeDocument = '4'; |
1819 |
|
} elseif ($type === 'lettre_majoration') { |
1820 |
|
$nomTypeLettre = '4'; |
1821 |
|
$nomTypeDocument = '6'; |
1822 |
} |
} |
1823 |
|
|
1824 |
// récupére les données à intégrer à la payload |
$inst_di = $this->f->get_inst__om_dbform(array( |
1825 |
$inst_in = $this->f->get_inst__om_dbform(array( |
"obj" => "dossier", |
1826 |
"obj" => "instruction_notification", |
"idx" => $dossier, |
|
"idx" => $idx, |
|
1827 |
)); |
)); |
1828 |
if (count($inst_in->val) > 0) { |
$date_limite_notification = DateTime::createFromFormat('Y-m-d', $inst_di->getVal('date_notification_delai')); |
1829 |
$val_in = $inst_in->get_json_data(); |
$aujourdhui = new DateTime(); |
1830 |
|
if (! $date_limite_notification instanceof DateTime) { |
1831 |
$val_in['parametre_courriel_type_titre'] = ''; |
$nomTypeLettre = ''; |
1832 |
$val_in['parametre_courriel_type_message'] = ''; |
$nomTypeDocument = ''; |
1833 |
// Récupération du message et du titre |
} elseif ($aujourdhui < $date_limite_notification) { |
1834 |
if ($category === 'mail') { |
$nomTypeLettre = '1'; |
1835 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
$nomTypeDocument = '3'; |
|
"obj" => "instruction", |
|
|
"idx" => $inst_in->getVal('instruction'), |
|
|
)); |
|
|
$collectivite_id = $inst_instruction->get_dossier_instruction_om_collectivite($inst_instruction->getVal('dossier')); |
|
|
$phrase_type_notification = array(); |
|
|
$phrase_type_notification = $this->f->get_notification_parametre_courriel_type($collectivite_id, $this->valF['type']); |
|
|
$val_in['parametre_courriel_type_titre'] = $phrase_type_notification['parametre_courriel_type_titre']; |
|
|
$val_in['parametre_courriel_type_message'] = $phrase_type_notification['parametre_courriel_type_message']; |
|
|
} |
|
|
|
|
|
// Récupération des liens vers les documents et de l'id de l'instruction |
|
|
// de l'annexe |
|
|
$infoDocNotif = $inst_in->getInfosDocumentsNotifAnnexeMultiple($inst_in->getVal($inst_in->clePrimaire)); |
|
|
$val_in['lien_telechargement_document'] = $infoDocNotif['document']['lien']; |
|
|
$val_in['annexes'] = $infoDocNotif['annexes']; |
|
1836 |
} |
} |
1837 |
|
|
1838 |
return $val_in; |
return array( |
1839 |
|
'nomEtatLettre' => '3', |
1840 |
|
'nomModaliteNotifMetier' => '4', |
1841 |
|
'nomTypeLettre' => $nomTypeLettre, |
1842 |
|
'nomTypeDocument' => $nomTypeDocument |
1843 |
|
); |
1844 |
} |
} |
1845 |
|
|
1846 |
protected function sort_instruction_data(array $values, array $res) { |
protected function sort_instruction_data(array $values, array $res) { |
1887 |
if ($instruction === null) { |
if ($instruction === null) { |
1888 |
return false; |
return false; |
1889 |
} |
} |
1890 |
$query = sprintf(' |
$qres = $this->f->get_one_result_from_db_query( |
1891 |
SELECT demande_type.dossier_instruction_type |
sprintf( |
1892 |
FROM %1$sdemande |
'SELECT |
1893 |
INNER JOIN %1$sdemande_type ON demande.demande_type = demande_type.demande_type |
demande_type.dossier_instruction_type |
1894 |
WHERE demande.instruction_recepisse = %2$s |
FROM |
1895 |
', |
%1$sdemande |
1896 |
DB_PREFIXE, |
INNER JOIN %1$sdemande_type |
1897 |
$instruction |
ON demande.demande_type = demande_type.demande_type |
1898 |
); |
WHERE |
1899 |
$res = $this->f->get_one_result_from_db_query( |
demande.instruction_recepisse = %2$s', |
1900 |
$query, |
DB_PREFIXE, |
1901 |
true |
intval($instruction) |
1902 |
|
), |
1903 |
|
array( |
1904 |
|
"origin" => __METHOD__, |
1905 |
|
"force_return" => true, |
1906 |
|
) |
1907 |
); |
); |
1908 |
if ($res['code'] === 'KO') { |
if ($qres["code"] !== "OK") { |
1909 |
return null; |
return null; |
1910 |
} |
} |
1911 |
if ($res['result'] === '') { |
if ($qres["result"] === "") { |
1912 |
return true; |
return true; |
1913 |
} |
} |
1914 |
return false; |
return false; |
1953 |
)); |
)); |
1954 |
$ad = $inst_di->getVal('avis_decision'); |
$ad = $inst_di->getVal('avis_decision'); |
1955 |
$val_ad = array(); |
$val_ad = array(); |
1956 |
if ($ad !== null) { |
if ($ad !== null && trim($ad) !== '') { |
1957 |
$inst_ad = $this->f->get_inst__om_dbform(array( |
$inst_ad = $this->f->get_inst__om_dbform(array( |
1958 |
"obj" => "avis_decision", |
"obj" => "avis_decision", |
1959 |
"idx" => $ad, |
"idx" => $ad, |
2015 |
|
|
2016 |
protected function view_form_json($in_field = false) { |
protected function view_form_json($in_field = false) { |
2017 |
// |
// |
2018 |
if ($this->f->get_submitted_post_value('valid') === null |
$check_state = isset($this->valF['state']) === true ? $this->valF['state'] : $this->getVal('state'); |
2019 |
&& $this->getVal('state') !== self::STATUS_CANCELED) { |
if ($check_state !== self::STATUS_CANCELED) { |
2020 |
// Liste des valeurs à afficher |
// Liste des valeurs à afficher |
2021 |
$val = array(); |
$val = array(); |
2022 |
// |
// |
2024 |
foreach ($val_task as $key => $value) { |
foreach ($val_task as $key => $value) { |
2025 |
$val_task[$key] = strip_tags($value); |
$val_task[$key] = strip_tags($value); |
2026 |
} |
} |
2027 |
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
|
2028 |
$val['task'] = $val_task; |
// Vérifie pour les tâches dont l'affichage de la payload est calculée si l'objet |
2029 |
// |
// de référence de la tâche existe. |
2030 |
if ($this->getVal('type') === 'creation_DA' |
$objectRefExist = true; |
2031 |
|| $this->getVal('type') === 'modification_DA') { |
if ($val_task['stream'] === 'output' |
2032 |
// |
&& (empty($val_task['json_payload']) || $val_task['json_payload'] === '{}')) { |
2033 |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
$objectRefExist = $this->does_referenced_object_exist( |
2034 |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
$val_task['object_id'], |
2035 |
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
$val_task['type'] |
2036 |
$val_external_uid = array(); |
); |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'creation_DI' |
|
|
|| $this->getVal('type') === 'modification_DI' |
|
|
|| $this->getVal('type') === 'depot_DI') { |
|
|
// |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
|
|
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction'); |
|
|
$val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']); |
|
|
$architecte = isset($val['donnees_techniques']['architecte']) === true ? $val['donnees_techniques']['architecte'] : null; |
|
|
$val['architecte'] = $this->get_architecte_data($architecte); |
|
|
$val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'qualification_DI') { |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'ajout_piece') { |
|
|
$val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id')); |
|
|
$val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val_external_uid['piece'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'piece'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'decision_DI') { |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
|
|
$val['instruction']['final'] = 't'; |
|
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
|
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
|
|
} |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'incompletude_DI') { |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'completude_DI') { |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'pec_metier_consultation') { |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'avis_consultation') { |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
|
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
|
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
|
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
|
|
} |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
|
|
$val_external_uid['avis_dossier_consultation'] = $this->get_external_uid($this->getVal('object_id'), 'avis_dossier_consultation'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// XXX WIP |
|
|
if ($this->getVal('type') === 'creation_consultation') { |
|
|
// |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val['consultation'] = $this->get_consultation_data($this->getVal('object_id')); |
|
|
$val['service'] = $this->get_service_data($val['consultation']['service']); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
2037 |
} |
} |
2038 |
// |
|
2039 |
if ($this->getVal('type') === 'envoi_CL') { |
// Si l'objet de référence n'existe pas log le numéro de la tâche concerné et |
2040 |
|
// renvoie une payload contenant le message d'erreur. |
2041 |
|
// Sinon constitue la payload du json. |
2042 |
|
if (! $objectRefExist) { |
2043 |
|
$this->f->addToLog( |
2044 |
|
sprintf( |
2045 |
|
__('Impossible de récupérer la payload car l\'objet de réference n\'existe pas pour la tâche : %s'), |
2046 |
|
$val_task['task'] |
2047 |
|
), |
2048 |
|
DEBUG_MODE |
2049 |
|
); |
2050 |
|
$val = __('Impossible de recuperer la payload car l\'objet de reference n\'existe pas.'); |
2051 |
|
} else { |
2052 |
|
|
2053 |
|
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
2054 |
|
unset($val_task['timestamp_log_hidden']); |
2055 |
|
$val['task'] = $val_task; |
2056 |
// |
// |
2057 |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
if ($this->getVal('type') === 'creation_DA' |
2058 |
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
|| $this->getVal('type') === 'modification_DA') { |
2059 |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($val['dossier']['dossier_autorisation']); |
// |
2060 |
$val_external_uid = array(); |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
2061 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
2062 |
$val_external_uid['dossier'] = $this->get_external_uid($this->getVal('dossier'), 'dossier'); |
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
2063 |
$val_external_uid['decision'] = $this->get_external_uid($this->getVal('object_id'), 'instruction'); |
$val_external_uid = array(); |
2064 |
if ($val_external_uid['decision'] === '') { |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
2065 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
$val['external_uids'] = $val_external_uid; |
|
"obj" => "instruction", |
|
|
"idx" => $this->getVal('object_id'), |
|
|
)); |
|
|
$val_external_uid['decision'] = $this->get_external_uid($inst_instruction->get_related_instructions_next('retour_signature'), 'instruction'); |
|
2066 |
} |
} |
2067 |
$val['external_uids'] = $val_external_uid; |
// |
2068 |
} |
if ($this->getVal('type') === 'creation_DI' |
2069 |
// |
|| $this->getVal('type') === 'modification_DI' |
2070 |
if ($this->getVal('type') === 'notification_instruction' |
|| $this->getVal('type') === 'depot_DI') { |
2071 |
|| $this->getVal('type') === 'notification_recepisse' |
// |
2072 |
|| $this->getVal('type') === 'notification_decision') { |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
2073 |
// |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction'); |
2074 |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
$val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']); |
2075 |
$dossier_id = isset($val['dossier']['dossier']) === true ? $val['dossier']['dossier'] : null; |
$architecte = isset($val['donnees_techniques']['architecte']) === true ? $val['donnees_techniques']['architecte'] : null; |
2076 |
$val['demandeur'] = $this->get_demandeurs_data($dossier_id); |
$val['architecte'] = $this->get_architecte_data($architecte); |
2077 |
$val['instruction_notification'] = $this->get_instruction_notification_data($this->getVal('category'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
$val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']); |
2078 |
$instruction_id = isset($val['instruction_notification']['instruction']) === true ? $val['instruction_notification']['instruction'] : null; |
$val_external_uid = array(); |
2079 |
$instruction_annexe = isset($val['instruction_notification']['instruction_annexe']) === true ? $val['instruction_notification']['instruction_annexe'] : null; |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2080 |
$val['instruction'] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $instruction_id)); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2081 |
// Précise qu'il s'agit d'une instruction final si l'instruction est liée à une |
$val['external_uids'] = $val_external_uid; |
2082 |
// demande dont le type ne génère pas de dossier |
} |
2083 |
if ($this->is_demande_instruction_recepisse_without_dossier($instruction_id) === true) { |
// |
2084 |
$val['instruction']['final'] = 't'; |
if ($this->getVal('type') === 'qualification_DI') { |
2085 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2086 |
|
$val_external_uid = array(); |
2087 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2088 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2089 |
|
$val['external_uids'] = $val_external_uid; |
2090 |
} |
} |
2091 |
// |
// |
2092 |
if ($instruction_annexe != '') { |
if ($this->getVal('type') === 'ajout_piece') { |
2093 |
$val['instruction_annexe'] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $instruction_annexe)); |
$val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id')); |
2094 |
|
$val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']); |
2095 |
|
$val_external_uid = array(); |
2096 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2097 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2098 |
|
$val_external_uid['piece'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'piece'); |
2099 |
|
$val['external_uids'] = $val_external_uid; |
2100 |
} |
} |
2101 |
$val_external_uid = array(); |
// |
2102 |
// Affiche l'identifiant de la demande concernant le dossier d'instruction |
if ($this->getVal('type') === 'decision_DI') { |
2103 |
$val_external_uid['demande'] = $this->get_external_uid($dossier_id, 'demande', 'portal', 'ASC'); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2104 |
$val_external_uid['demande (instruction)'] = $this->get_external_uid($instruction_id, 'demande', 'portal', 'ASC'); |
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
|
$val_external_uid['instruction_notification'] = $this->get_external_uid($this->getVal('object_id'), 'instruction_notification', 'portal'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
if ($this->getVal('type') === 'notification_service_consulte' |
|
|
|| $this->getVal('type') === 'notification_tiers_consulte') { |
|
|
// |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$dossier_id = isset($val['dossier']['dossier']) === true ? $val['dossier']['dossier'] : null; |
|
|
$val['demandeur'] = $this->get_demandeurs_data($dossier_id); |
|
|
$val['instruction_notification'] = $this->get_instruction_notification_data_annexe_multiple($this->getVal('category'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
|
|
$instruction_id = isset($val['instruction_notification']['instruction']) === true ? $val['instruction_notification']['instruction'] : null; |
|
|
$instruction_annexes = isset($val['instruction_notification']['annexes']) === true ? $val['instruction_notification']['annexes'] : null; |
|
|
$val['instruction'] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $instruction_id)); |
|
|
// Précise qu'il s'agit d'une instruction final si l'instruction est liée à une |
|
|
// demande dont le type ne génère pas de dossier |
|
|
if ($this->is_demande_instruction_recepisse_without_dossier($instruction_id) === true) { |
|
2105 |
$val['instruction']['final'] = 't'; |
$val['instruction']['final'] = 't'; |
2106 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
2107 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
2108 |
|
} |
2109 |
|
$val_external_uid = array(); |
2110 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2111 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2112 |
|
$val['external_uids'] = $val_external_uid; |
2113 |
} |
} |
2114 |
// |
// |
2115 |
if (is_array($instruction_annexes) && $instruction_annexes != array()) { |
if ($this->getVal('type') === 'incompletude_DI') { |
2116 |
$val['instruction_annexe'] = array(); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2117 |
$numAnnexe = 0; |
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
2118 |
foreach ($instruction_annexes as $annexe) { |
$val_external_uid = array(); |
2119 |
if ($annexe['document_type'] === 'instruction') { |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2120 |
$val['instruction_annexe']['annexe_'.$numAnnexe++] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $annexe['document_id'])); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2121 |
} elseif ($annexe['document_type'] === 'consultation') { |
$val['external_uids'] = $val_external_uid; |
2122 |
$val['instruction_annexe']['annexe_'.$numAnnexe++] = $this->get_consultation_data($annexe['document_id']); |
} |
2123 |
} |
// |
2124 |
|
if ($this->getVal('type') === 'completude_DI') { |
2125 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2126 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
2127 |
|
$val_external_uid = array(); |
2128 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2129 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2130 |
|
$val['external_uids'] = $val_external_uid; |
2131 |
|
} |
2132 |
|
// |
2133 |
|
if ($this->getVal('type') === 'lettre_incompletude' |
2134 |
|
|| $this->getVal('type') === 'lettre_majoration') { |
2135 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2136 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
2137 |
|
$val['lettre_petitionnaire'] = $this->get_lettre_petitionnaire_data($val['dossier']['dossier'], $this->getVal('type')); |
2138 |
|
$val_external_uid = array(); |
2139 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2140 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2141 |
|
$val['external_uids'] = $val_external_uid; |
2142 |
|
} |
2143 |
|
// |
2144 |
|
if ($this->getVal('type') === 'pec_metier_consultation') { |
2145 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2146 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2147 |
|
$val_external_uid = array(); |
2148 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2149 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2150 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
2151 |
|
$val['external_uids'] = $val_external_uid; |
2152 |
|
} |
2153 |
|
// |
2154 |
|
if ($this->getVal('type') === 'avis_consultation') { |
2155 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2156 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2157 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
2158 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
2159 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
2160 |
} |
} |
2161 |
|
$val_external_uid = array(); |
2162 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2163 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2164 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
2165 |
|
$val_external_uid['avis_dossier_consultation'] = $this->get_external_uid($this->getVal('object_id'), 'avis_dossier_consultation'); |
2166 |
|
$val['external_uids'] = $val_external_uid; |
2167 |
|
} |
2168 |
|
// XXX WIP |
2169 |
|
if ($this->getVal('type') === 'creation_consultation') { |
2170 |
|
// |
2171 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2172 |
|
$val['consultation'] = $this->get_consultation_data($this->getVal('object_id')); |
2173 |
|
$val['service'] = $this->get_service_data($val['consultation']['service']); |
2174 |
|
$val_external_uid = array(); |
2175 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2176 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2177 |
|
$val['external_uids'] = $val_external_uid; |
2178 |
|
} |
2179 |
|
// |
2180 |
|
if ($this->getVal('type') === 'envoi_CL') { |
2181 |
|
// |
2182 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2183 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2184 |
|
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($val['dossier']['dossier_autorisation']); |
2185 |
|
$val_external_uid = array(); |
2186 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2187 |
|
$val_external_uid['dossier'] = $this->get_external_uid($this->getVal('dossier'), 'dossier'); |
2188 |
|
$val_external_uid['decision'] = $this->get_external_uid($this->getVal('object_id'), 'instruction'); |
2189 |
|
if ($val_external_uid['decision'] === '') { |
2190 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
2191 |
|
"obj" => "instruction", |
2192 |
|
"idx" => $this->getVal('object_id'), |
2193 |
|
)); |
2194 |
|
$val_external_uid['decision'] = $this->get_external_uid($inst_instruction->get_related_instructions_next('retour_signature'), 'instruction'); |
2195 |
|
} |
2196 |
|
$val['external_uids'] = $val_external_uid; |
2197 |
|
} |
2198 |
|
if ($this->getVal('type') === 'notification_instruction' |
2199 |
|
|| $this->getVal('type') === 'notification_recepisse' |
2200 |
|
|| $this->getVal('type') === 'notification_decision' |
2201 |
|
|| $this->getVal('type') === 'notification_service_consulte' |
2202 |
|
|| $this->getVal('type') === 'notification_tiers_consulte' |
2203 |
|
|| $this->getVal('type') === 'notification_signataire') { |
2204 |
|
// |
2205 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2206 |
|
$dossier_id = isset($val['dossier']['dossier']) === true ? $val['dossier']['dossier'] : null; |
2207 |
|
$val['demandeur'] = $this->get_demandeurs_data($dossier_id); |
2208 |
|
$val['instruction_notification'] = $this->get_instruction_notification_data($this->getVal('category'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2209 |
|
$instruction_id = isset($val['instruction_notification']['instruction']) === true ? $val['instruction_notification']['instruction'] : null; |
2210 |
|
$instruction_annexes = isset($val['instruction_notification']['annexes']) === true ? $val['instruction_notification']['annexes'] : null; |
2211 |
|
$val['instruction'] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $instruction_id)); |
2212 |
|
// Précise qu'il s'agit d'une instruction final si l'instruction est liée à une |
2213 |
|
// demande dont le type ne génère pas de dossier |
2214 |
|
if ($this->is_demande_instruction_recepisse_without_dossier($instruction_id) === true) { |
2215 |
|
$val['instruction']['final'] = 't'; |
2216 |
|
} |
2217 |
|
$val_external_uid = array(); |
2218 |
|
// Affiche l'identifiant externe lié à l'instruction si cette combinaison existe, sinon celui lié au dossier |
2219 |
|
$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'); |
2220 |
|
$val_external_uid['demande (instruction)'] = $this->get_external_uid($instruction_id, 'demande', PORTAL, 'ASC'); |
2221 |
|
$val_external_uid['instruction_notification'] = $this->get_external_uid($this->getVal('object_id'), 'instruction_notification', PORTAL); |
2222 |
|
$val['external_uids'] = $val_external_uid; |
2223 |
|
} |
2224 |
|
// |
2225 |
|
if ($this->getVal('type') === 'prescription') { |
2226 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2227 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2228 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
2229 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
2230 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
2231 |
|
} |
2232 |
|
$val_external_uid = array(); |
2233 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2234 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2235 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
2236 |
|
$val_external_uid['prescription'] = $this->get_external_uid($this->getVal('object_id'), 'prescription'); |
2237 |
|
$val['external_uids'] = $val_external_uid; |
2238 |
} |
} |
|
$val_external_uid = array(); |
|
|
// Affiche l'identifiant externe lié à l'instruction si cette combinaison existe, sinon celui lié au dossier |
|
|
$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'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'prescription') { |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
|
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
|
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
|
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
|
|
} |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
|
|
$val_external_uid['prescription'] = $this->get_external_uid($this->getVal('object_id'), 'prescription'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
2239 |
} |
} |
2240 |
|
|
2241 |
if ($in_field === true) { |
if ($in_field === true) { |
2257 |
'state' => $this->f->get_submitted_post_value('state') |
'state' => $this->f->get_submitted_post_value('state') |
2258 |
), |
), |
2259 |
); |
); |
2260 |
|
if ($this->f->get_submitted_post_value('comment') !== null) { |
2261 |
|
$params['comment'] = $this->f->get_submitted_post_value('comment'); |
2262 |
|
} |
2263 |
$update = $this->update_task($params); |
$update = $this->update_task($params); |
2264 |
$message_class = "valid"; |
$message_class = "valid"; |
2265 |
$message = $this->msg; |
$message = $this->msg; |
2295 |
|| $this->getVal('type') === 'notification_instruction' |
|| $this->getVal('type') === 'notification_instruction' |
2296 |
|| $this->getVal('type') === 'notification_decision' |
|| $this->getVal('type') === 'notification_decision' |
2297 |
|| $this->getVal('type') === 'notification_service_consulte' |
|| $this->getVal('type') === 'notification_service_consulte' |
2298 |
|| $this->getVal('type') === 'notification_tiers_consulte')) { |
|| $this->getVal('type') === 'notification_tiers_consulte' |
2299 |
|
|| $this->getVal('type') === 'notification_signataire')) { |
2300 |
// |
// |
2301 |
$object_id = $this->getVal('dossier'); |
$object_id = $this->getVal('dossier'); |
2302 |
// Il ne doit y avoir qu'une liaison entre le numéro du dossier interne et un uid externe de "demande" |
// Il ne doit y avoir qu'une liaison entre le numéro du dossier interne et un uid externe de "demande" |
2334 |
$result = $this->add_task(array( |
$result = $this->add_task(array( |
2335 |
'val' => array( |
'val' => array( |
2336 |
'stream' => 'input', |
'stream' => 'input', |
2337 |
'json_payload' => html_entity_decode($this->f->get_submitted_post_value('json_payload')), |
'json_payload' => html_entity_decode($this->f->get_submitted_post_value('json_payload'), ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401), |
2338 |
'type' => $this->f->get_submitted_post_value('type'), |
'type' => $this->f->get_submitted_post_value('type'), |
2339 |
'category' => $this->f->get_submitted_post_value('category'), |
'category' => $this->f->get_submitted_post_value('category'), |
2340 |
) |
) |
2358 |
} |
} |
2359 |
|
|
2360 |
function setLayout(&$form, $maj) { |
function setLayout(&$form, $maj) { |
2361 |
|
// |
2362 |
// Récupération du mode de l'action |
$form->setBloc('json_payload', 'D', '', 'col_6'); |
2363 |
$crud = $this->get_action_crud($maj); |
$fieldset_title_payload = __("json_payload (calculée)"); |
2364 |
|
if ($this->getVal('json_payload') !== "{}") { |
2365 |
// MODE different de CREER |
$fieldset_title_payload = __("json_payload"); |
2366 |
if ($maj != 0 || $crud != 'create') { |
} |
2367 |
$form->setBloc('json_payload', 'D', '', 'col_6'); |
$form->setFieldset('json_payload', 'DF', $fieldset_title_payload, "collapsible, startClosed"); |
2368 |
$form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed"); |
$form->setBloc('json_payload', 'F'); |
2369 |
$form->setBloc('json_payload', 'F'); |
$form->setBloc('timestamp_log', 'DF', __("historique"), 'col_9 timestamp_log_jsontotab'); |
|
} |
|
|
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
|
2370 |
} |
} |
2371 |
|
|
2372 |
/** |
/** |
2393 |
&& $stream === 'input') { |
&& $stream === 'input') { |
2394 |
$objects = array('dossier', 'dossier_autorisation', 'demande', ); |
$objects = array('dossier', 'dossier_autorisation', 'demande', ); |
2395 |
} |
} |
2396 |
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
if (in_array($type, array( |
2397 |
|
'decision_DI', |
2398 |
|
'incompletude_DI', |
2399 |
|
'completude_DI', |
2400 |
|
'lettre_incompletude', |
2401 |
|
'lettre_majoration' |
2402 |
|
)) === true) { |
2403 |
$objects = array('instruction', ); |
$objects = array('instruction', ); |
2404 |
} |
} |
2405 |
if (in_array($type, array('envoi_CL', )) === true) { |
if (in_array($type, array('envoi_CL', )) === true) { |
2443 |
'notification_decision', |
'notification_decision', |
2444 |
'notification_service_consulte', |
'notification_service_consulte', |
2445 |
'notification_tiers_consulte', |
'notification_tiers_consulte', |
2446 |
|
'notification_signataire', |
2447 |
) |
) |
2448 |
) === true) { |
) === true) { |
2449 |
$objects = array('instruction_notification', 'demande', ); |
$objects = array('instruction_notification', 'demande', ); |
2477 |
&& $stream === 'input') { |
&& $stream === 'input') { |
2478 |
$tables = array('dossier', 'dossier_autorisation', 'demande', ); |
$tables = array('dossier', 'dossier_autorisation', 'demande', ); |
2479 |
} |
} |
2480 |
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
if (in_array($type, array( |
2481 |
|
'decision_DI', |
2482 |
|
'incompletude_DI', |
2483 |
|
'completude_DI', |
2484 |
|
'lettre_incompletude', |
2485 |
|
'lettre_majoration' |
2486 |
|
)) === true) { |
2487 |
$tables = array('instruction', ); |
$tables = array('instruction', ); |
2488 |
} |
} |
2489 |
|
if (in_array($type, array('envoi_CL', )) === true) { |
2490 |
|
$objects = array('instruction', ); |
2491 |
|
} |
2492 |
if (in_array($type, array('pec_metier_consultation', )) === true |
if (in_array($type, array('pec_metier_consultation', )) === true |
2493 |
&& $stream === 'output') { |
&& $stream === 'output') { |
2494 |
$tables = array('instruction', ); |
$tables = array('instruction', ); |
2526 |
'notification_instruction', |
'notification_instruction', |
2527 |
'notification_decision', |
'notification_decision', |
2528 |
'notification_service_consulte', |
'notification_service_consulte', |
2529 |
'notification_tiers_consulte' |
'notification_tiers_consulte', |
2530 |
|
'notification_signataire' |
2531 |
) |
) |
2532 |
) === true) { |
) === true) { |
2533 |
$tables = array('instruction_notification', ); |
$tables = array('instruction_notification', ); |
2535 |
return $tables; |
return $tables; |
2536 |
} |
} |
2537 |
|
|
2538 |
|
/** |
2539 |
|
* Vérifie si l'objet référencé par la tâche existe en base de données. |
2540 |
|
* |
2541 |
|
* Récupère la liste des tables de référence associé à la tâche à partir |
2542 |
|
* du type de tâche et de son flux (input ou output). |
2543 |
|
* Pour chaque table potentiellement référencé par la tâche on essaye d'instancier |
2544 |
|
* l'objet correspondant à partir de l'identifiant de l'objet de référence de la tâche. |
2545 |
|
* Si l'élément instancié existe renvoie true sinon renvoie false. |
2546 |
|
* |
2547 |
|
* @param string|integer $taskObjectId : identifiant de l'objet de référence de la tâche |
2548 |
|
* @param string $taskType : type de la tâche |
2549 |
|
* @param string $taskStream : flux entrant (output - valeur par défaut) ou sortant (input) |
2550 |
|
* @return boolean |
2551 |
|
*/ |
2552 |
|
protected function does_referenced_object_exist($taskObjectId, string $taskType, string $taskStream = 'output') { |
2553 |
|
$refTables = $this->get_tables_by_task_type($taskType, $taskStream); |
2554 |
|
if (empty($refTables) === true) { |
2555 |
|
$this->f->addToLog( |
2556 |
|
sprintf( |
2557 |
|
__("Impossible de vérifier si l'objet de référence existe, car le type de task '%s' n'a pas de correspondance avec une table dans la méthode %s."), |
2558 |
|
$taskType, |
2559 |
|
"get_tables_by_task_type()" |
2560 |
|
), |
2561 |
|
DEBUG_MODE |
2562 |
|
); |
2563 |
|
return true; |
2564 |
|
} |
2565 |
|
foreach ($refTables as $table) { |
2566 |
|
$inst = $this->f->get_inst__om_dbform(array( |
2567 |
|
'obj' => $table, |
2568 |
|
'idx' => $taskObjectId |
2569 |
|
)); |
2570 |
|
if ($inst->exists() === true) { |
2571 |
|
return true; |
2572 |
|
} |
2573 |
|
} |
2574 |
|
return false; |
2575 |
|
} |
2576 |
|
|
2577 |
} |
} |