4 |
|
|
5 |
require_once "../gen/obj/task.class.php"; |
require_once "../gen/obj/task.class.php"; |
6 |
|
|
7 |
|
|
8 |
class task extends task_gen { |
class task extends task_gen { |
9 |
|
|
10 |
const STATUS_DRAFT = 'draft'; |
const STATUS_DRAFT = 'draft'; |
15 |
const STATUS_DEBUG = 'debug'; |
const STATUS_DEBUG = 'debug'; |
16 |
const STATUS_ARCHIVED = 'archived'; |
const STATUS_ARCHIVED = 'archived'; |
17 |
const STATUS_CANCELED = 'canceled'; |
const STATUS_CANCELED = 'canceled'; |
18 |
|
const STATUS_INVALID = 'invalid'; |
19 |
|
|
20 |
|
/** |
21 |
|
* Définie le code platau correspondant aux documents de type consultation |
22 |
|
* |
23 |
|
* @var integer |
24 |
|
*/ |
25 |
|
const CODE_PLATAU_CONSULTATION = 7; |
26 |
|
|
27 |
/** |
/** |
28 |
* Liste des types de tâche concernant les services instructeurs |
* Liste des types de tâche concernant les services instructeurs |
37 |
'incompletude_DI', |
'incompletude_DI', |
38 |
'completude_DI', |
'completude_DI', |
39 |
'ajout_piece', |
'ajout_piece', |
40 |
|
'modification_piece', |
41 |
|
'suppression_piece', |
42 |
'add_piece', |
'add_piece', |
43 |
'creation_consultation', |
'creation_consultation', |
44 |
'modification_DA', |
'modification_DA', |
50 |
'notification_service_consulte', |
'notification_service_consulte', |
51 |
'notification_tiers_consulte', |
'notification_tiers_consulte', |
52 |
'notification_depot_demat', |
'notification_depot_demat', |
53 |
'notification_commune' |
'notification_commune', |
54 |
|
'notification_signataire', |
55 |
|
'lettre_incompletude', |
56 |
|
'lettre_majoration', |
57 |
|
'ajout_documents_specifiques' |
58 |
); |
); |
59 |
|
|
60 |
/** |
/** |
72 |
'notification_tiers_consulte', |
'notification_tiers_consulte', |
73 |
'notification_depot_demat', |
'notification_depot_demat', |
74 |
'prescription', |
'prescription', |
75 |
|
'ajout_documents_specifiques' |
76 |
|
); |
77 |
|
|
78 |
|
/** |
79 |
|
* Liste des types de tâche pouvant avoir des documents associés |
80 |
|
*/ |
81 |
|
const TASK_WITH_DOCUMENT = array( |
82 |
|
'add_piece', |
83 |
|
'avis_consultation', |
84 |
|
'pec_metier_consultation', |
85 |
|
'ajout_documents_specifiques' |
86 |
); |
); |
87 |
|
|
88 |
/** |
/** |
89 |
|
* Préfixe pour identifier les codes de suivi |
90 |
|
* @var string |
91 |
|
*/ |
92 |
|
const CS_PREFIX = 'code-suivi://'; |
93 |
|
|
94 |
|
/** |
95 |
* Catégorie de la tâche |
* Catégorie de la tâche |
96 |
*/ |
*/ |
97 |
var $category = 'platau'; |
var $category = PLATAU; |
98 |
|
|
99 |
/** |
/** |
100 |
* Définition des actions disponibles sur la classe. |
* Définition des actions disponibles sur la classe. |
289 |
|
|
290 |
function stateTranslation ($currentState) { |
function stateTranslation ($currentState) { |
291 |
switch ($currentState){ |
switch ($currentState){ |
292 |
case "draft": |
case self::STATUS_DRAFT: |
293 |
return __('brouillon'); |
return __('brouillon'); |
294 |
break; |
break; |
295 |
case "new": |
case self::STATUS_NEW: |
296 |
return __('à traiter'); |
return __('à traiter'); |
297 |
break; |
break; |
298 |
case "pending": |
case self::STATUS_PENDING: |
299 |
return __('en cours'); |
return __('en cours'); |
300 |
break; |
break; |
301 |
case "done": |
case self::STATUS_DONE: |
302 |
return __('terminé'); |
return __('terminé'); |
303 |
break; |
break; |
304 |
case "archived": |
case self::STATUS_ARCHIVED: |
305 |
return __('archivé'); |
return __('archivé'); |
306 |
break; |
break; |
307 |
case "error": |
case self::STATUS_ERROR: |
308 |
return __('erreur'); |
return __('erreur'); |
309 |
break; |
break; |
310 |
case "debug": |
case self::STATUS_DEBUG: |
311 |
return __('debug'); |
return __('debug'); |
312 |
break; |
break; |
313 |
case "canceled": |
case self::STATUS_CANCELED: |
314 |
return __('annulé'); |
return __('annulé'); |
315 |
break; |
break; |
316 |
|
case self::STATUS_INVALID: |
317 |
|
return __('invalide'); |
318 |
|
break; |
319 |
} |
} |
320 |
} |
} |
321 |
|
|
322 |
/** |
/** |
323 |
* |
* |
324 |
*/ |
*/ |
325 |
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
326 |
if($maj <= 3) { |
if($maj <= 3) { |
327 |
$contenu = array(); |
$contenu = array(); |
328 |
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG', 'ARCHIVED', 'CANCELED') as $key) { |
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG', 'ARCHIVED', 'CANCELED', 'INVALID') as $key) { |
329 |
$const_name = 'STATUS_'.$key; |
$const_name = 'STATUS_'.$key; |
330 |
$const_value = constant("self::$const_name"); |
$const_value = constant("self::$const_name"); |
331 |
$contenu[0][] = $const_value; |
$contenu[0][] = $const_value; |
372 |
case "add_piece": |
case "add_piece": |
373 |
$value_type = __('Ajout pièce (entrant)'); |
$value_type = __('Ajout pièce (entrant)'); |
374 |
break; |
break; |
375 |
|
case "modification_piece": |
376 |
|
$value_type = __('Modification pièce (sortant)'); |
377 |
|
break; |
378 |
|
case "suppression_piece": |
379 |
|
$value_type = __('Suppression pièce (sortant)'); |
380 |
|
break; |
381 |
case "depot_DI": |
case "depot_DI": |
382 |
$value_type = __('Dépôt DI'); |
$value_type = __('Dépôt DI'); |
383 |
break; |
break; |
423 |
case "notification_tiers_consulte": |
case "notification_tiers_consulte": |
424 |
$value_type = __('Notification tiers consulté'); |
$value_type = __('Notification tiers consulté'); |
425 |
break; |
break; |
426 |
|
case "notification_signataire": |
427 |
|
$value_type = __('Notification signataire'); |
428 |
|
break; |
429 |
case "completude_DI": |
case "completude_DI": |
430 |
$value_type = __('complétude DI'); |
$value_type = __('complétude DI'); |
431 |
break; |
break; |
432 |
case "incompletude_DI": |
case "incompletude_DI": |
433 |
$value_type = __('incomplétude DI'); |
$value_type = __('incomplétude DI'); |
434 |
break; |
break; |
435 |
|
case "lettre_incompletude": |
436 |
|
$value_type = __('Lettre au pétitionnaire d\'incompletude'); |
437 |
|
break; |
438 |
|
case "lettre_majoration": |
439 |
|
$value_type = __('Lettre au pétitionnaire de majoration'); |
440 |
|
break; |
441 |
|
case "ajout_documents_specifiques": |
442 |
|
$value_type = __('Ajout Document Spécifique'); |
443 |
|
break; |
444 |
} |
} |
445 |
|
|
446 |
$contenu_type[1][] = $value_type; |
$contenu_type[1][] = $value_type; |
450 |
} |
} |
451 |
|
|
452 |
if ($maj == 3) { |
if ($maj == 3) { |
453 |
|
$dossier = $form->val['dossier']; |
454 |
// Récupération du numéro du dossier si il n'est pas renseigné dans la tâche |
// Récupération du numéro du dossier si il n'est pas renseigné dans la tâche |
455 |
if ($form->val['dossier'] == '' || $form->val['dossier'] == null) { |
|
456 |
|
if ($dossier == '' || $dossier == null) { |
457 |
// Récupération de la payload de la taĉhe. |
// Récupération de la payload de la taĉhe. |
458 |
// Si la tâche est une tâche input la payload est associée à la tâche. |
// Si la tâche est une tâche input la payload est associée à la tâche. |
459 |
// Si la tâche est une tâche en output la payload est "calculé" à l'ouverture |
// Si la tâche est une tâche en output la payload est "calculé" à l'ouverture |
473 |
) { |
) { |
474 |
$external_uid = $json_payload['external_uids']['dossier']; |
$external_uid = $json_payload['external_uids']['dossier']; |
475 |
} elseif (array_key_exists('external_uids', $json_payload) |
} elseif (array_key_exists('external_uids', $json_payload) |
476 |
&& array_key_exists('dossier', $json_payload['external_uids'])) { |
&& array_key_exists('demande', $json_payload['external_uids'])) { |
477 |
$external_uid = $json_payload['external_uids']['dossier']; |
$external_uid = $json_payload['external_uids']['demande']; |
478 |
} |
} |
479 |
// Recherche l'external uid dans la base de données pour récupèrer le numéro de |
// Recherche l'external uid dans la base de données pour récupèrer le numéro de |
480 |
// DI / DA correspondant. On stocke le numéro de dossier dans la propriété val |
// DI / DA correspondant. On stocke le numéro de dossier dans la propriété val |
481 |
// du formulaire pour pouvoir l'afficher |
// du formulaire pour pouvoir l'afficher |
482 |
if ($external_uid != '') { |
if ($external_uid != '') { |
483 |
$uid = sprintf( |
$qres = $this->f->get_one_result_from_db_query( |
484 |
'SELECT |
sprintf( |
485 |
lien_id_interne_uid_externe.dossier |
'SELECT |
486 |
FROM |
lien_id_interne_uid_externe.dossier |
487 |
%1$slien_id_interne_uid_externe |
FROM |
488 |
WHERE |
%1$slien_id_interne_uid_externe |
489 |
lien_id_interne_uid_externe.external_uid = \'%2$s\'', |
WHERE |
490 |
DB_PREFIXE, |
lien_id_interne_uid_externe.external_uid = \'%2$s\'', |
491 |
$external_uid |
DB_PREFIXE, |
492 |
|
$this->f->db->escapeSimple($external_uid) |
493 |
|
), |
494 |
|
array( |
495 |
|
"origin" => __METHOD__, |
496 |
|
) |
497 |
); |
); |
498 |
$res_external_uid = $this->f->get_one_result_from_db_query($uid); |
if (! empty($qres["result"])) { |
499 |
if (! empty($res_external_uid['result'])) { |
$dossier = $qres["result"]; |
|
$form->val['dossier'] = $res_external_uid['result']; |
|
500 |
} |
} |
501 |
} |
} |
502 |
} |
} |
507 |
$obj_link = ''; |
$obj_link = ''; |
508 |
if ($form->val['type'] == "creation_DA" || $form->val['type'] == "modification_DA") { |
if ($form->val['type'] == "creation_DA" || $form->val['type'] == "modification_DA") { |
509 |
// Vérification que le numéro de DA affiché dans le formulaire existe |
// Vérification que le numéro de DA affiché dans le formulaire existe |
510 |
$idDA = sprintf( |
$qres = $this->f->get_one_result_from_db_query( |
511 |
'SELECT |
sprintf( |
512 |
dossier_autorisation.dossier_autorisation |
'SELECT |
513 |
FROM |
dossier_autorisation.dossier_autorisation |
514 |
%1$sdossier_autorisation |
FROM |
515 |
WHERE |
%1$sdossier_autorisation |
516 |
dossier_autorisation.dossier_autorisation = \'%2$s\'', |
WHERE |
517 |
DB_PREFIXE, |
dossier_autorisation.dossier_autorisation = \'%2$s\'', |
518 |
$form->val['dossier'] |
DB_PREFIXE, |
519 |
|
$this->f->db->escapeSimple($form->val['dossier']) |
520 |
|
), |
521 |
|
array( |
522 |
|
"origin" => __METHOD__, |
523 |
|
) |
524 |
); |
); |
|
$resIdDA=$this->f->get_one_result_from_db_query($idDA); |
|
525 |
// Si on a un résultat c'est que le dossier existe, il faut afficher le lien |
// Si on a un résultat c'est que le dossier existe, il faut afficher le lien |
526 |
if (! empty($resIdDA['result'])) { |
if (! empty($qres["result"])) { |
527 |
$obj_link = 'dossier_autorisation'; |
$obj_link = 'dossier_autorisation'; |
528 |
} |
} |
529 |
} else { |
} else { |
530 |
// Vérification que le numéro de DI affiché dans le formulaire existe |
// Vérification que le numéro de DI affiché dans le formulaire existe |
531 |
$idDI = sprintf( |
$sql = sprintf( |
532 |
'SELECT |
'SELECT |
533 |
dossier.dossier |
dossier.dossier, |
534 |
|
dossier.dossier_parent |
535 |
FROM |
FROM |
536 |
%1$sdossier |
%1$sdossier |
537 |
WHERE |
WHERE |
538 |
dossier.dossier = \'%2$s\'', |
dossier.dossier = \'%2$s\'', |
539 |
DB_PREFIXE, |
DB_PREFIXE, |
540 |
$form->val['dossier'] |
$this->f->db->escapeSimple($dossier) |
541 |
|
); |
542 |
|
$qres = $this->f->get_all_results_from_db_query( |
543 |
|
$sql, |
544 |
|
array( |
545 |
|
"origin" => __METHOD__, |
546 |
|
) |
547 |
); |
); |
|
$resDI = $this->f->get_one_result_from_db_query($idDI); |
|
548 |
// Si on a un résultat c'est que le dossier existe, il faut afficher le lien |
// Si on a un résultat c'est que le dossier existe, il faut afficher le lien |
549 |
if (! empty($resDI['result'])) { |
if (! empty($qres['result']) && $qres['row_count'] > 0) { |
550 |
$obj_link = 'dossier_instruction'; |
$obj_link = 'dossier_instruction'; |
551 |
|
if (! empty($qres['result'][0]['dossier_parent'])) { |
552 |
|
$dossier = $qres['result'][0]['dossier_parent']; |
553 |
|
} |
554 |
} |
} |
555 |
} |
} |
556 |
// Pour afficher le lien vers un dossier ont utilise un champ de type "link". |
// Pour afficher le lien vers un dossier ont utilise un champ de type "link". |
563 |
// contiennent les informations nécessaire à l'affichage du champs. |
// contiennent les informations nécessaire à l'affichage du champs. |
564 |
$params = array( |
$params = array( |
565 |
'obj' => $obj_link, |
'obj' => $obj_link, |
566 |
'libelle' => $form->val['dossier'], |
'libelle' => $dossier, |
567 |
'title' => "Consulter le dossier", |
'title' => "Consulter le dossier", |
568 |
'idx' => $form->val['dossier'] |
'idx' => $dossier |
569 |
); |
); |
570 |
$form->setSelect("dossier", $params); |
$form->setSelect("dossier", $params); |
571 |
} |
} |
579 |
function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) { |
function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) { |
580 |
// parent::setVal($form, $maj, $validation); |
// parent::setVal($form, $maj, $validation); |
581 |
// |
// |
582 |
if ($this->getVal('stream') == "output") { |
if ($this->getVal('stream') == "output" |
583 |
|
&& $this->getVal('type') !== 'suppression_piece' |
584 |
|
&& ($this->getVal('state') !== self::STATUS_DONE |
585 |
|
|| $this->getVal('json_payload') === "{}")) { |
586 |
|
// |
587 |
$form->setVal('json_payload', $this->view_form_json(true)); |
$form->setVal('json_payload', $this->view_form_json(true)); |
588 |
} else { |
} else { |
589 |
$form->setVal('json_payload', json_encode(json_decode($this->getVal('json_payload'), true), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); |
$form->setVal('json_payload', json_encode(json_decode($this->getVal('json_payload'), true), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); |
590 |
} |
} |
591 |
|
// Gestion du contenu de l'historique |
592 |
|
if ($this->getVal('timestamp_log') !== '' |
593 |
|
&& $this->getVal('timestamp_log') !== null) { |
594 |
|
// |
595 |
|
$form->setVal('timestamp_log', $this->getVal('timestamp_log')); |
596 |
|
} |
597 |
} |
} |
598 |
|
|
599 |
function setLib(&$form, $maj) { |
function setLib(&$form, $maj) { |
621 |
public function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
public function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
622 |
$ret = parent::verifier($val, $dnu1, $dnu2); |
$ret = parent::verifier($val, $dnu1, $dnu2); |
623 |
|
|
624 |
|
$allowed_state = array( |
625 |
|
self::STATUS_DRAFT, |
626 |
|
self::STATUS_NEW, |
627 |
|
self::STATUS_PENDING, |
628 |
|
self::STATUS_DONE, |
629 |
|
self::STATUS_ERROR, |
630 |
|
self::STATUS_DEBUG, |
631 |
|
self::STATUS_ARCHIVED, |
632 |
|
self::STATUS_CANCELED, |
633 |
|
self::STATUS_INVALID); |
634 |
|
|
635 |
|
$task_id = $this->getVal($this->clePrimaire); |
636 |
|
$task_id_text = sprintf(__("la tâche '%s'"), $task_id); |
637 |
|
if (empty($task_id) || $task_id === ']') { |
638 |
|
$task_id_text = __("la nouvelle tâche"); |
639 |
|
} |
640 |
|
|
641 |
|
if (! isset($this->valF['state']) || empty($this->valF['state'])) { |
642 |
|
$this->correct = false; |
643 |
|
$err_msg = sprintf( |
644 |
|
__("Champ '%s' obligatoire pour %s"), |
645 |
|
'state', $task_id_text); |
646 |
|
$this->addToMessage($err_msg); |
647 |
|
$this->addToLog(__METHOD__.'(): '.$err_msg, DEBUG_MODE); |
648 |
|
} |
649 |
|
elseif (! in_array($this->valF['state'], $allowed_state)) { |
650 |
|
$this->correct = false; |
651 |
|
$err_msg = sprintf( |
652 |
|
__("Champ '%s' invalide (%s) pour %s"), |
653 |
|
'state', var_export($this->valF['state'], true), $task_id_text); |
654 |
|
$this->addToMessage($err_msg); |
655 |
|
$this->addToLog(__METHOD__.'(): '.$err_msg, DEBUG_MODE); |
656 |
|
} |
657 |
|
|
658 |
// une tâche entrante doit avoir un type et une payload non-vide |
// une tâche entrante doit avoir un type et une payload non-vide |
659 |
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
660 |
if (isset($this->valF['type']) === false) { |
if (isset($this->valF['type']) === false) { |
708 |
$this->valF['stream'] == 'input')) { |
$this->valF['stream'] == 'input')) { |
709 |
|
|
710 |
// décode la payload JSON |
// décode la payload JSON |
711 |
|
// TODO : COMMENTER |
712 |
$json_payload = json_decode($this->valF['json_payload'], true); |
$json_payload = json_decode($this->valF['json_payload'], true); |
713 |
|
|
714 |
// défini une liste de chemin de clés requises |
// défini une liste de chemin de clés requises |
715 |
$paths = array(); |
$paths = array(); |
716 |
if ($this->valF['category'] === 'platau') { |
if ($this->valF['category'] === PLATAU) { |
717 |
$paths = array( |
$paths = array( |
718 |
'external_uids/dossier' |
'external_uids/dossier' |
719 |
); |
); |
789 |
* @param string $object_id [description] |
* @param string $object_id [description] |
790 |
* @param bool $is_not_done [description] |
* @param bool $is_not_done [description] |
791 |
* @return [type] [description] |
* @return [type] [description] |
792 |
|
* |
793 |
|
* Cette méthode est déprécier, car elle cause des cas illogique avec PENDING qui ne compte pas dans le is_not_done. |
794 |
|
* L'utilisation de task_exists_multi_search() est à privilegier pour éviter les problèmes et les risques |
795 |
*/ |
*/ |
796 |
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) { |
797 |
$query = sprintf(' |
$qres = $this->f->get_one_result_from_db_query( |
798 |
SELECT task |
sprintf( |
799 |
FROM %1$stask |
'SELECT |
800 |
WHERE %2$s |
task |
801 |
type = \'%3$s\' |
FROM |
802 |
AND (object_id = \'%4$s\' |
%1$stask |
803 |
%5$s) |
WHERE |
804 |
AND state != \'%6$s\' |
%2$s |
805 |
', |
type = \'%3$s\' |
806 |
DB_PREFIXE, |
AND ( |
807 |
$is_not_done == true ? 'state != \''.self::STATUS_DONE.'\' AND' : '', |
object_id = \'%4$s\' |
808 |
$type, |
%5$s |
809 |
$object_id, |
) |
810 |
$dossier !== null ? sprintf('OR dossier = \'%s\'', $dossier) : '', |
AND state != \'%6$s\'', |
811 |
self::STATUS_CANCELED |
DB_PREFIXE, |
812 |
|
$is_not_done == true ? 'state != \''.self::STATUS_DONE.'\' AND' : '', |
813 |
|
$type, |
814 |
|
$object_id, |
815 |
|
$dossier !== null ? sprintf('OR dossier = \'%s\'', $dossier) : '', |
816 |
|
self::STATUS_CANCELED |
817 |
|
), |
818 |
|
array( |
819 |
|
"origin" => __METHOD__, |
820 |
|
) |
821 |
); |
); |
822 |
$res = $this->f->get_one_result_from_db_query($query); |
if (! empty($qres["result"])) { |
823 |
if ($res['result'] !== null && $res['result'] !== '') { |
return $qres["result"]; |
|
return $res['result']; |
|
824 |
} |
} |
825 |
return false; |
return false; |
826 |
} |
} |
833 |
*/ |
*/ |
834 |
public function task_exists_multi_search(array $search_values) { |
public function task_exists_multi_search(array $search_values) { |
835 |
$query = sprintf(' |
$query = sprintf(' |
836 |
SELECT * |
SELECT task, state |
837 |
FROM %1$stask |
FROM %1$stask |
838 |
%2$s |
%2$s |
839 |
%3$s |
%3$s |
840 |
|
ORDER BY task ASC |
841 |
', |
', |
842 |
DB_PREFIXE, |
DB_PREFIXE, |
843 |
empty($search_values) === false ? ' WHERE ' : '', |
empty($search_values) === false ? ' WHERE ' : '', |
844 |
implode(' AND ', $search_values) |
implode(' AND ', $search_values) |
845 |
); |
); |
846 |
$res = $this->f->get_all_results_from_db_query($query); |
$res = $this->f->get_all_results_from_db_query( |
847 |
|
$query, |
848 |
|
array( |
849 |
|
"origin" => __METHOD__, |
850 |
|
) |
851 |
|
); |
852 |
if (count($res['result']) > 0) { |
if (count($res['result']) > 0) { |
853 |
return $res['result']; |
return $res['result']; |
854 |
} |
} |
866 |
* @return boolean |
* @return boolean |
867 |
*/ |
*/ |
868 |
function triggerajouter($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
function triggerajouter($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
869 |
|
$parent_res = parent::triggerajouter($id, $dnu1, $val); |
870 |
|
if ($parent_res === false) return $parent_res; |
871 |
|
|
872 |
// tâche entrante |
// tâche entrante |
873 |
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
892 |
|| $val['type'] === 'notification_tiers_consulte' |
|| $val['type'] === 'notification_tiers_consulte' |
893 |
|| $val['type'] === 'notification_depot_demat' |
|| $val['type'] === 'notification_depot_demat' |
894 |
|| $val['type'] === 'notification_commune' |
|| $val['type'] === 'notification_commune' |
895 |
|
|| $val['type'] === 'notification_signataire' |
896 |
) { |
) { |
897 |
// Récupère la payload de la tache |
// Récupère la payload de la tache |
898 |
$data = array(); |
$data = array(); |
912 |
$envoiMail = $inst_notif->send_mail_notification($data, $val['type']); |
$envoiMail = $inst_notif->send_mail_notification($data, $val['type']); |
913 |
// Passage de la tache à done si elle a réussi et à error |
// Passage de la tache à done si elle a réussi et à error |
914 |
// si l'envoi a échoué |
// si l'envoi a échoué |
915 |
$this->valF['state'] = 'done'; |
$this->valF['state'] = self::STATUS_DONE; |
916 |
if ($envoiMail === false) { |
if ($envoiMail === false) { |
917 |
$this->valF['state'] = 'error'; |
$this->valF['state'] = self::STATUS_ERROR; |
918 |
} |
} |
919 |
} |
} |
920 |
} |
} |
951 |
$this->valF['object_id'] = $new_values['object_id']; |
$this->valF['object_id'] = $new_values['object_id']; |
952 |
$this->valF['last_modification_date'] = date('Y-m-d'); |
$this->valF['last_modification_date'] = date('Y-m-d'); |
953 |
$this->valF['last_modification_time'] = date('H:i:s'); |
$this->valF['last_modification_time'] = date('H:i:s'); |
954 |
|
if ($val['stream'] === 'output' |
955 |
|
&& $val['type'] !== 'suppression_piece') { |
956 |
|
// Lorsque la task passe d'un état qui n'est pas "done" à l'état "done" |
957 |
|
if ($this->getVal("state") !== self::STATUS_DONE |
958 |
|
&& $this->valF['state'] === self::STATUS_DONE) { |
959 |
|
// |
960 |
|
$this->valF['json_payload'] = $this->view_form_json(true); |
961 |
|
} |
962 |
|
// Lorsque la task passe d'un état "done" à un état qui n'est pas "done" |
963 |
|
if ($this->getVal("state") === self::STATUS_DONE |
964 |
|
&& $this->valF['state'] !== self::STATUS_DONE) { |
965 |
|
// |
966 |
|
$this->valF['json_payload'] = "{}"; |
967 |
|
} |
968 |
|
} |
969 |
|
|
970 |
return true; |
return true; |
971 |
} |
} |
1008 |
$tables = $this->get_tables_by_task_type($this->getVal('type'), $this->getVal('stream')); |
$tables = $this->get_tables_by_task_type($this->getVal('type'), $this->getVal('stream')); |
1009 |
foreach ($tables as $table) { |
foreach ($tables as $table) { |
1010 |
// Vérifie s'il y a un ou aucun résultat |
// Vérifie s'il y a un ou aucun résultat |
1011 |
$query = sprintf(' |
$qres = $this->f->get_one_result_from_db_query( |
1012 |
SELECT COUNT(%2$s) |
sprintf( |
1013 |
FROM %1$s%2$s |
'SELECT |
1014 |
WHERE %2$s::CHARACTER VARYING = \'%3$s\' |
COUNT(%2$s) |
1015 |
', |
FROM |
1016 |
DB_PREFIXE, |
%1$s%2$s |
1017 |
$table, |
WHERE |
1018 |
$value['prev_object_id'] |
%2$s::CHARACTER VARYING = \'%3$s\'', |
1019 |
|
DB_PREFIXE, |
1020 |
|
$table, |
1021 |
|
$value['prev_object_id'] |
1022 |
|
), |
1023 |
|
array( |
1024 |
|
"origin" => __METHOD__, |
1025 |
|
"force_return" => true, |
1026 |
|
) |
1027 |
); |
); |
1028 |
$res = $this->f->get_one_result_from_db_query($query, true); |
if ($qres["code"] !== "OK") { |
|
if ($res['code'] === 'KO') { |
|
1029 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
1030 |
} |
} |
1031 |
// Affectation des valeurs et sortie de la boucle |
// Affectation des valeurs et sortie de la boucle |
1032 |
if ($res['result'] == '1') { |
if ($qres["result"] == '1') { |
1033 |
$params['object_id'] = $value['prev_object_id']; |
$params['object_id'] = $value['prev_object_id']; |
1034 |
$params['state'] = $this->getVal('state'); |
$params['state'] = $this->getVal('state'); |
1035 |
break; |
break; |
1086 |
// 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 |
1087 |
// 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é |
1088 |
if (isset($val['category']) === true |
if (isset($val['category']) === true |
1089 |
&& $val['category'] === 'portal' |
&& $val['category'] === PORTAL |
1090 |
&& isset($val['type']) === true |
&& isset($val['type']) === true |
1091 |
&& ($val['type'] === 'notification_recepisse' |
&& ($val['type'] === 'notification_recepisse' |
1092 |
|| $val['type'] === 'notification_instruction' |
|| $val['type'] === 'notification_instruction' |
1129 |
} |
} |
1130 |
$valF_instruction['date_envoi_rar'] = date('d/m/Y'); |
$valF_instruction['date_envoi_rar'] = date('d/m/Y'); |
1131 |
$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')); |
1132 |
$inst_instruction->setParameter('maj', 1); |
// Action spécifique pour identifier que la modification |
1133 |
|
// est une notification de demandeur |
1134 |
|
$inst_instruction->setParameter('maj', 175); |
1135 |
$update_instruction = $inst_instruction->modifier($valF_instruction); |
$update_instruction = $inst_instruction->modifier($valF_instruction); |
1136 |
if ($update_instruction === false) { |
if ($update_instruction === false) { |
1137 |
$this->addToLog(__METHOD__."(): ".$inst_instruction->msg, DEBUG_MODE); |
$this->addToLog(__METHOD__."(): ".$inst_instruction->msg, DEBUG_MODE); |
1165 |
"obj" => "instruction", |
"obj" => "instruction", |
1166 |
"idx" => $this->getVal('object_id'), |
"idx" => $this->getVal('object_id'), |
1167 |
)); |
)); |
1168 |
if ($inst_instruction->has_an_edition() === true) { |
$valF_instruction = array(); |
1169 |
$valF_instruction = array(); |
foreach ($inst_instruction->champs as $champ) { |
1170 |
foreach ($inst_instruction->champs as $champ) { |
$valF_instruction[$champ] = $inst_instruction->getVal($champ); |
|
$valF_instruction[$champ] = $inst_instruction->getVal($champ); |
|
|
} |
|
1171 |
} |
} |
1172 |
|
// On met à jour la date d'envoi au CL seulement si l'instruction a une édition liée |
1173 |
$valF_instruction['date_envoi_controle_legalite'] = date("Y-m-d"); |
$valF_instruction['date_envoi_controle_legalite'] = date("Y-m-d"); |
1174 |
$inst_instruction->setParameter('maj', 1); |
$inst_instruction->setParameter('maj', 1); |
1175 |
$update_instruction = $inst_instruction->modifier($valF_instruction); |
$update_instruction = $inst_instruction->modifier($valF_instruction); |
1222 |
// 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 |
1223 |
// 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 |
1224 |
if (isset($params['val']['type']) |
if (isset($params['val']['type']) |
1225 |
&& ($params['val']['type'] == "add_piece" || $params['val']['type'] == "avis_consultation") |
&& in_array($params['val']['type'], self::TASK_WITH_DOCUMENT) |
1226 |
&& isset($params['val']['stream']) |
&& isset($params['val']['stream']) |
1227 |
&& $params['val']['stream'] == "input" ) { |
&& $params['val']['stream'] == "input" ) { |
1228 |
// |
// |
1258 |
} |
} |
1259 |
} |
} |
1260 |
|
|
1261 |
// Mise à jour du DI |
if (isset($params['val']['state'])) { |
1262 |
|
$allowed_state = array( |
1263 |
|
self::STATUS_DRAFT, |
1264 |
|
self::STATUS_NEW, |
1265 |
|
self::STATUS_PENDING, |
1266 |
|
self::STATUS_DONE, |
1267 |
|
self::STATUS_ERROR, |
1268 |
|
self::STATUS_DEBUG, |
1269 |
|
self::STATUS_ARCHIVED, |
1270 |
|
self::STATUS_CANCELED, |
1271 |
|
self::STATUS_INVALID); |
1272 |
|
|
1273 |
|
if (empty($params['val']['state'])) { |
1274 |
|
throw new InvalidArgumentException( |
1275 |
|
"État ('state') vide pour la nouvelle tâche"); |
1276 |
|
} |
1277 |
|
elseif (! in_array($params['val']['state'], $allowed_state)) { |
1278 |
|
throw new InvalidArgumentException( |
1279 |
|
"État ('state') invalide (".var_export($params['val']['state'], true). |
1280 |
|
") pour la nouvelle tâche"); |
1281 |
|
} |
1282 |
|
} |
1283 |
|
|
1284 |
|
// Valeurs de la tâche |
1285 |
$valF = array( |
$valF = array( |
1286 |
'task' => '', |
'task' => '', |
1287 |
'type' => $params['val']['type'], |
'type' => $params['val']['type'], |
1299 |
'comment' => null, |
'comment' => null, |
1300 |
); |
); |
1301 |
|
|
1302 |
// tâche sortante |
// Gestion de la mise à jour des tâches sortantes |
1303 |
$typeNonConcerne = array( |
$typeNonConcerne = array( |
1304 |
'notification_recepisse', |
'notification_recepisse', |
1305 |
'notification_instruction', |
'notification_instruction', |
1306 |
'notification_decision', |
'notification_decision', |
1307 |
'notification_service_consulte', |
'notification_service_consulte', |
1308 |
'notification_tiers_consulte' |
'notification_tiers_consulte', |
1309 |
|
'notification_depot_demat', |
1310 |
|
'notification_commune', |
1311 |
|
'notification_signataire', |
1312 |
); |
); |
1313 |
if ($valF["stream"] == "output" |
if ($valF["stream"] == "output" |
1314 |
&& ! in_array($valF['type'], $typeNonConcerne)) { |
&& ! in_array($valF['type'], $typeNonConcerne)) { |
1315 |
// TODO expliquer ce code |
// Vérification de l'existance d'une tâche pour l'objet concerné |
1316 |
$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 |
1317 |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
$search_values_common = array( |
1318 |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
sprintf('state != \'%s\'', self::STATUS_CANCELED), |
1319 |
} |
sprintf('state != \'%s\'', self::STATUS_DONE), |
1320 |
if ($valF['type'] === 'modification_DA' && $task_exists === false) { |
); |
1321 |
$task_exists = $this->task_exists('creation_DA', $valF['object_id']); |
$search_values_others = array( |
1322 |
} |
sprintf('type = \'%s\'', $valF['type']), |
1323 |
if ($valF['type'] === 'ajout_piece') { |
sprintf('(object_id = \'%s\' OR dossier = \'%s\')', $valF['object_id'], $valF['dossier']), |
1324 |
$task_exists = $this->task_exists('ajout_piece', $valF['object_id']); |
); |
1325 |
|
$search_values_specifics = array( |
1326 |
|
sprintf('object_id = \'%s\'', $valF['object_id']), |
1327 |
|
); |
1328 |
|
|
1329 |
|
// Recherche multi-critères sur les tâches |
1330 |
|
// Si l'object id/dossier à des tâches de type $valF['type'] qui lui est associé |
1331 |
|
// Et que ces tâches ont des statut différents de canceled et done |
1332 |
|
// Alors on récupère ces tâches |
1333 |
|
// Sinon return false |
1334 |
|
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_others)); |
1335 |
|
|
1336 |
|
// Vérifie si une tâche existe déjà pour les types de tâches ayant un fonctionnement particulier. |
1337 |
|
// Il existe 2 cas : |
1338 |
|
// - Aucune tâche déjà existante n'a été récupérées mais on veut faire une vérification supplémentaire |
1339 |
|
// - Les tâches pour lesquelles on fait une vérification supplémentaire qu'une correspondance ait été |
1340 |
|
// trouvée ou pas |
1341 |
|
// Une tâche ne pouvant avoir qu'un seul type si elle est trouvée, il n'est pas nécessaire de |
1342 |
|
// vérifier les autres |
1343 |
|
$is_type_voulu_traite = false; |
1344 |
|
// Cas 1 : Aucune tâche déjà existante n'a été récupérées mais effectue une vérification supplémentaire |
1345 |
|
$cas_specifiques_tache_non_existante = array( |
1346 |
|
'modification_DI' => array("type = 'creation_DI'"), |
1347 |
|
'modification_DA' => array("type = 'creation_DA'") |
1348 |
|
); |
1349 |
|
foreach ($cas_specifiques_tache_non_existante as $type_task => $conditions_specifiques) { |
1350 |
|
// S'il n'existe pas de tâche de type voulu pour l'object id/dossier |
1351 |
|
if ($valF['type'] === $type_task && $task_exists === false) { |
1352 |
|
// On se réfère à la tâche de type 'ajout piece' de l'object id |
1353 |
|
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_specifics, $conditions_specifiques)); |
1354 |
|
$is_type_voulu_traite = true; |
1355 |
|
break; |
1356 |
|
} |
1357 |
} |
} |
1358 |
if ($valF['type'] === 'creation_consultation') { |
|
1359 |
$task_exists = $this->task_exists('creation_consultation', $valF['object_id']); |
// Cas 2 : Vérification supplémentaire qu'une correspondance ait été trouvé ou pas |
1360 |
|
if (! $is_type_voulu_traite) { |
1361 |
|
$cas_specifiques = array( |
1362 |
|
'ajout_piece', |
1363 |
|
'modification_piece', |
1364 |
|
'suppression_piece', |
1365 |
|
'creation_consultation', |
1366 |
|
'ajout_documents_specifiques', |
1367 |
|
); |
1368 |
|
foreach ($cas_specifiques as $type_task) { |
1369 |
|
if ($valF['type'] === $type_task) { |
1370 |
|
// On se réfère à la tâche de type 'ajout piece' de l'object id |
1371 |
|
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_specifics, array("type = '$type_task'"))); |
1372 |
|
break; |
1373 |
|
} |
1374 |
|
} |
1375 |
} |
} |
1376 |
|
|
1377 |
|
// S'il existe une tâche pour l'objet concerné, pas d'ajout de nouvelle |
1378 |
|
// tâche mais mise à jour de l'existante |
1379 |
if ($task_exists !== false) { |
if ($task_exists !== false) { |
1380 |
$inst_task = $this->f->get_inst__om_dbform(array( |
// Plusieurs tâches pourraient exister, elles sont contôler par ordre croissant |
1381 |
"obj" => "task", |
foreach ($task_exists as $task) { |
1382 |
"idx" => $task_exists, |
$inst_task = $this->f->get_inst__om_dbform(array( |
1383 |
)); |
"obj" => "task", |
1384 |
$update_state = $inst_task->getVal('state'); |
"idx" => $task['task'], |
1385 |
if (isset($params['update_val']['state']) === true) { |
)); |
1386 |
$update_state = $params['update_val']['state']; |
$update_state = $inst_task->getVal('state'); |
1387 |
} |
if (isset($params['update_val']['state']) === true) { |
1388 |
$update_params = array( |
$update_state = $params['update_val']['state']; |
1389 |
'val' => array( |
} |
1390 |
'state' => $update_state, |
$object_id = $inst_task->getVal('object_id'); |
1391 |
), |
if (!empty($valF['object_id'])) { |
1392 |
'object_id' => $valF['object_id'], |
$object_id = $valF['object_id']; |
1393 |
); |
} |
1394 |
return $inst_task->update_task($update_params); |
// Pour être mise à jour, la tâche existante ne doit pas être en cours de traitement |
1395 |
|
$task_pending = $inst_task->getVal('state') === self::STATUS_PENDING |
1396 |
|
&& $update_state === self::STATUS_PENDING |
1397 |
|
&& $inst_task->getVal('object_id') !== $object_id; |
1398 |
|
if ($task_pending === false) { |
1399 |
|
$update_params = array( |
1400 |
|
'val' => array( |
1401 |
|
'state' => $update_state, |
1402 |
|
), |
1403 |
|
'object_id' => $object_id, |
1404 |
|
); |
1405 |
|
return $inst_task->update_task($update_params); |
1406 |
|
} |
1407 |
|
} |
1408 |
} |
} |
1409 |
} |
} |
1410 |
$add = $this->ajouter($valF); |
$add = $this->ajouter($valF); |
1411 |
$this->addToLog(__METHOD__."(): retour de l'ajout de tâche: ".var_export($add, true), VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): retour de l'ajout de tâche: ".var_export($add, true), VERBOSE_MODE); |
1412 |
|
|
1413 |
|
// Création de la payload JSON dans le cas ou nous avons un suppression d'objet |
1414 |
|
if ($stream === 'output' |
1415 |
|
&& $add === true |
1416 |
|
&& isset($valF['type']) === true |
1417 |
|
&& strpos($valF['type'], 'suppression_piece') !== false |
1418 |
|
) { |
1419 |
|
$inst_task_empty = $this->f->get_inst__om_dbform(array( |
1420 |
|
"obj" => "task", |
1421 |
|
"idx" => 0, |
1422 |
|
)); |
1423 |
|
// Vérification de l'éxistence d'une tache de suppression de pièce |
1424 |
|
$task_exists = $inst_task_empty->task_exists('suppression_piece', $valF['object_id']); |
1425 |
|
$valF['task'] = $task_exists; |
1426 |
|
$inst_task = $this->f->get_inst__om_dbform(array( |
1427 |
|
"obj" => "task", |
1428 |
|
"idx" => $task_exists, |
1429 |
|
)); |
1430 |
|
$valF['json_payload'] = $inst_task->view_form_json(true); |
1431 |
|
$update = $this->modifier($valF); |
1432 |
|
if ($update === false) { |
1433 |
|
$this->addToLog(__METHOD__."(): ".$this->msg, DEBUG_MODE); |
1434 |
|
return $this->end_treatment(__METHOD__, false); |
1435 |
|
} |
1436 |
|
} |
1437 |
|
|
1438 |
if ($add === false) { |
if ($add === false) { |
1439 |
$this->addToLog(__METHOD__."(): ".$this->msg, DEBUG_MODE); |
$this->addToLog(__METHOD__."(): ".$this->msg, DEBUG_MODE); |
1440 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
1452 |
public function update_task($params = array()) { |
public function update_task($params = array()) { |
1453 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
1454 |
|
|
1455 |
|
$allowed_state = array( |
1456 |
|
self::STATUS_DRAFT, |
1457 |
|
self::STATUS_NEW, |
1458 |
|
self::STATUS_PENDING, |
1459 |
|
self::STATUS_DONE, |
1460 |
|
self::STATUS_ERROR, |
1461 |
|
self::STATUS_DEBUG, |
1462 |
|
self::STATUS_ARCHIVED, |
1463 |
|
self::STATUS_CANCELED, |
1464 |
|
self::STATUS_INVALID); |
1465 |
|
|
1466 |
|
$task_id = $this->getVal($this->clePrimaire); |
1467 |
|
|
1468 |
|
if (! isset($params['val']['state']) || empty($params['val']['state'])) { |
1469 |
|
throw new InvalidArgumentException( |
1470 |
|
"État ('state') non spécifié ou vide pour la tâche '$task_id'"); |
1471 |
|
} |
1472 |
|
elseif (! in_array($params['val']['state'], $allowed_state)) { |
1473 |
|
throw new InvalidArgumentException( |
1474 |
|
"État ('state') invalide (".var_export($params['val']['state'], true). |
1475 |
|
") pour la tâche '$task_id'"); |
1476 |
|
} |
1477 |
|
|
1478 |
// Mise à jour de la tâche |
// Mise à jour de la tâche |
1479 |
$valF = array( |
$valF = array( |
1480 |
'task' => $this->getVal($this->clePrimaire), |
'task' => $task_id, |
1481 |
'type' => $this->getVal('type'), |
'type' => $this->getVal('type'), |
1482 |
'timestamp_log' => '[]', |
'timestamp_log' => '[]', |
1483 |
'state' => $params['val']['state'], |
'state' => $params['val']['state'], |
1490 |
'creation_time' => $this->getVal('creation_time'), |
'creation_time' => $this->getVal('creation_time'), |
1491 |
'last_modification_date' => date('Y-m-d'), |
'last_modification_date' => date('Y-m-d'), |
1492 |
'last_modification_time' => date('H:i:s'), |
'last_modification_time' => date('H:i:s'), |
1493 |
'comment' => $this->getVal('comment'), |
'comment' => isset($params['comment']) == true ? $params['comment'] : $this->getVal('comment'), |
1494 |
); |
); |
1495 |
$update = $this->modifier($valF); |
$update = $this->modifier($valF); |
1496 |
if ($update === false) { |
if ($update === false) { |
1501 |
} |
} |
1502 |
|
|
1503 |
/** |
/** |
1504 |
|
* A partir des éléments fournis en paramètre compose une url permettant |
1505 |
|
* d'accéder à un document. |
1506 |
|
* |
1507 |
|
* @param string $nom_objet : nom de l'objet d'appartenance du document |
1508 |
|
* @param string $champ : champ contenant l'uid du document |
1509 |
|
* @param string|integer $id_objet : id de l'objet d'appartenance du document |
1510 |
|
* |
1511 |
|
* @return string url d'accès au document |
1512 |
|
*/ |
1513 |
|
function compose_url_acces_document(string $nom_objet, string $champ, $id_objet) { |
1514 |
|
return sprintf( |
1515 |
|
'app/index.php?module=form&snippet=file&obj=%s&champ=%s&id=%s', |
1516 |
|
$nom_objet, |
1517 |
|
$champ, |
1518 |
|
$id_objet |
1519 |
|
); |
1520 |
|
} |
1521 |
|
|
1522 |
|
/** |
1523 |
* Récupère le journal d'horodatage dans le champ timestamp_log de |
* Récupère le journal d'horodatage dans le champ timestamp_log de |
1524 |
* l'enregistrement instancié. |
* l'enregistrement instancié. |
1525 |
* |
* |
1547 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
1548 |
$this->f->disableLog(); |
$this->f->disableLog(); |
1549 |
if ($this->getParameter('idx') !== ']' |
if ($this->getParameter('idx') !== ']' |
1550 |
&& $this->getParameter('idx') !== '0') { |
&& $this->getParameter('idx') !== '0' |
1551 |
// |
) { |
1552 |
$this->view_form_json(); |
if ($this->getVal('json_payload') !== "{}") { |
1553 |
|
// On prend la Payload en BDD |
1554 |
|
echo( |
1555 |
|
json_encode( |
1556 |
|
json_decode($this->getVal('json_payload'), true), |
1557 |
|
JSON_UNESCAPED_SLASHES |
1558 |
|
) |
1559 |
|
); |
1560 |
|
} else { |
1561 |
|
// On Calcule la payload JSON |
1562 |
|
$this->view_form_json(); |
1563 |
|
} |
1564 |
} |
} |
1565 |
else { |
else { |
1566 |
$this->view_tab_json(); |
$this->view_tab_json(); |
1611 |
// |
// |
1612 |
$query = sprintf(' |
$query = sprintf(' |
1613 |
SELECT |
SELECT |
1614 |
task.* |
DISTINCT (task.task), |
1615 |
|
task.type, |
1616 |
|
task.object_id, |
1617 |
|
task.dossier, |
1618 |
|
task.stream, |
1619 |
|
task.category, |
1620 |
|
task.creation_date, |
1621 |
|
task.creation_time, |
1622 |
|
task.last_modification_date, |
1623 |
|
task.last_modification_time, |
1624 |
|
task.comment |
1625 |
FROM %1$stask |
FROM %1$stask |
1626 |
LEFT JOIN %1$slien_id_interne_uid_externe |
LEFT JOIN %1$slien_id_interne_uid_externe |
1627 |
ON task.object_id = lien_id_interne_uid_externe.object_id |
ON task.object_id = lien_id_interne_uid_externe.object_id |
1632 |
DB_PREFIXE, |
DB_PREFIXE, |
1633 |
$where |
$where |
1634 |
); |
); |
1635 |
$res = $this->f->get_all_results_from_db_query($query, true); |
$res = $this->f->get_all_results_from_db_query( |
1636 |
|
$query, |
1637 |
|
array( |
1638 |
|
"origin" => __METHOD__, |
1639 |
|
"force_return" => true, |
1640 |
|
) |
1641 |
|
); |
1642 |
if ($res['code'] === 'KO') { |
if ($res['code'] === 'KO') { |
1643 |
return false; |
return false; |
1644 |
} |
} |
1645 |
$list_tasks = array(); |
$list_tasks = array(); |
1646 |
foreach ($res['result'] as $task) { |
foreach ($res['result'] as $task) { |
|
unset($task['timestamp_log']); |
|
|
unset($task['json_payload']); |
|
|
if ($task['type'] === 'ajout_piece') { |
|
|
$val_dn = $this->get_document_numerise_data($task['object_id']); |
|
|
} |
|
1647 |
if ($task['stream'] === 'output') { |
if ($task['stream'] === 'output') { |
1648 |
$task['external_uids'] = array_merge( |
$task['external_uids'] = array_merge( |
1649 |
$this->get_all_external_uids($task['dossier'], array(), $category !== null ? $category : $task['category']), |
$this->get_all_external_uids($task['dossier'], array(), $category !== null ? $category : $task['category']), |
1754 |
if (isset($val_dt['tax_ext_pret']) === true |
if (isset($val_dt['tax_ext_pret']) === true |
1755 |
&& $val_dt['tax_ext_pret'] === 'f') { |
&& $val_dt['tax_ext_pret'] === 'f') { |
1756 |
// |
// |
1757 |
$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'] : ''; |
1758 |
$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'] : ''; |
1759 |
} |
} |
1760 |
if (isset($val_dt['tax_ext_pret']) === true |
if (isset($val_dt['tax_ext_pret']) === true |
1761 |
&& $val_dt['tax_ext_pret'] === 't') { |
&& $val_dt['tax_ext_pret'] === 't') { |
1764 |
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 |
1765 |
|| preg_match('/[lL].*[lL].*[tT].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
|| preg_match('/[lL].*[lL].*[tT].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
1766 |
// |
// |
1767 |
$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'] : ''; |
1768 |
$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'] : ''; |
1769 |
} |
} |
1770 |
// if (preg_match('/[pP].*[tT].*[zZ]/', $val_dt['tax_ext_desc']) === 1) { |
// if (preg_match('/[pP].*[tT].*[zZ]/', $val_dt['tax_ext_desc']) === 1) { |
1771 |
// $val_dt['tax_su_princ_surf4'] = $val_dt['tax_surf_tot_cstr']; |
// $val_dt['tax_su_princ_surf4'] = $val_dt['tax_surf_tot_cstr']; |
1809 |
', |
', |
1810 |
DB_PREFIXE |
DB_PREFIXE |
1811 |
); |
); |
1812 |
$res = $this->f->get_all_results_from_db_query($query, true); |
$res = $this->f->get_all_results_from_db_query( |
1813 |
|
$query, |
1814 |
|
array( |
1815 |
|
"origin" => __METHOD__, |
1816 |
|
"force_return" => true, |
1817 |
|
) |
1818 |
|
); |
1819 |
if ($res['code'] === 'KO') { |
if ($res['code'] === 'KO') { |
1820 |
return array(); |
return array(); |
1821 |
} |
} |
1826 |
return $result; |
return $result; |
1827 |
} |
} |
1828 |
|
|
1829 |
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') { |
1830 |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
1831 |
"obj" => "lien_id_interne_uid_externe", |
"obj" => "lien_id_interne_uid_externe", |
1832 |
"fk_field" => 'object_id', |
"fk_field" => 'object_id', |
1841 |
return $inst_external_uid->getVal('external_uid'); |
return $inst_external_uid->getVal('external_uid'); |
1842 |
} |
} |
1843 |
|
|
1844 |
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) { |
1845 |
if (count($link_objects) == 0) { |
if (count($link_objects) == 0) { |
1846 |
$link_objects = $this->get_list_distinct_objects_external_link(); |
$link_objects = $this->get_list_distinct_objects_external_link(); |
1847 |
} |
} |
1915 |
"obj" => "instruction", |
"obj" => "instruction", |
1916 |
"idx" => $idx, |
"idx" => $idx, |
1917 |
)); |
)); |
1918 |
|
$id_instruction = $inst_instruction->getVal($inst_instruction->clePrimaire); |
1919 |
if (count($inst_instruction->val) > 0) { |
if (count($inst_instruction->val) > 0) { |
1920 |
$val_instruction = array(); |
$val_instruction = array(); |
1921 |
$instruction_data = $inst_instruction->get_json_data(); |
$instruction_data = $inst_instruction->get_json_data(); |
1923 |
if ($instruction_data['om_fichier_instruction'] !== null |
if ($instruction_data['om_fichier_instruction'] !== null |
1924 |
&& $instruction_data['om_fichier_instruction'] !== '') { |
&& $instruction_data['om_fichier_instruction'] !== '') { |
1925 |
// |
// |
1926 |
$instruction_with_doc = $inst_instruction->getVal($inst_instruction->clePrimaire); |
$instruction_with_doc = $id_instruction; |
1927 |
} |
} |
1928 |
$inst_ev = $this->f->get_inst__om_dbform(array( |
$inst_ev = $this->f->get_inst__om_dbform(array( |
1929 |
"obj" => "evenement", |
"obj" => "evenement", |
1949 |
} |
} |
1950 |
if ($instruction_with_doc !== null) { |
if ($instruction_with_doc !== null) { |
1951 |
// |
// |
1952 |
$val_instruction['path'] = sprintf('%s&snippet=%s&obj=%s&champ=%s&id=%s', 'app/index.php?module=form', 'file', 'instruction', 'om_fichier_instruction', $instruction_with_doc); |
$val_instruction['path'] = $this->compose_url_acces_document('instruction', 'om_fichier_instruction', $instruction_with_doc); |
1953 |
|
} |
1954 |
|
// Si il y a des annexes compatibles avec l'instruction elles sont ajoutées à la payload |
1955 |
|
if (! empty($annexes = $this->ajouter_annexes_a_la_payload($id_instruction, true))) { |
1956 |
|
$val_instruction['annexes'] = $annexes; |
1957 |
} |
} |
1958 |
} |
} |
1959 |
return $val_instruction; |
return $val_instruction; |
2000 |
$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']; |
2001 |
} |
} |
2002 |
|
|
2003 |
// Récupération des liens vers les documents et des id et type des annexes |
if ($typeNotification == 'notification_signataire') { |
2004 |
$infoDocNotif = $inst_in->getInfosDocumentsNotif($inst_in->getVal($inst_in->clePrimaire), $category); |
$val_in['lien_page_signature'] = $inst_in->getLienPageSignature($inst_instruction); |
2005 |
$cle = $category == 'portal' ? 'path' : 'lien_telechargement_document'; |
} |
2006 |
$val_in[$cle] = $infoDocNotif['document']['path']; |
else { |
2007 |
$val_in['annexes'] = $infoDocNotif['annexes']; |
// Récupération des liens vers les documents et des id et type des annexes |
2008 |
|
$infoDocNotif = $inst_in->getInfosDocumentsNotif($inst_in->getVal($inst_in->clePrimaire), $category); |
2009 |
|
$cle = $category == PORTAL ? 'path' : 'lien_telechargement_document'; |
2010 |
|
$val_in[$cle] = $infoDocNotif['document']['path']; |
2011 |
|
$val_in['annexes'] = $infoDocNotif['annexes']; |
2012 |
|
} |
2013 |
} |
} |
2014 |
return $val_in; |
return $val_in; |
2015 |
} |
} |
2016 |
|
|
2017 |
|
/** |
2018 |
|
* Récupère les informations concernant la lettre au pétitionnaire. |
2019 |
|
* |
2020 |
|
* @param string identifiant du dossier |
2021 |
|
* @param string type de tâche |
2022 |
|
* @param array paramètre supplémentaire permettant de récupérer les informations |
2023 |
|
* |
2024 |
|
* @return array information concernant la lettre au pétitionnaire |
2025 |
|
*/ |
2026 |
|
protected function get_lettre_petitionnaire_data($dossier, $type, $extra_params = array()) { |
2027 |
|
// Si la date limite de notification n'a pas été dépassé le type de lettre est 1 |
2028 |
|
// Si la date a été dépassé et qu'il s'agit d'une demande de pièce le type est 3 |
2029 |
|
// Si la date a été dépassé et qu'il s'agit d'une prolongation le type est 4 |
2030 |
|
// Le type de document dépend du type de pièce |
2031 |
|
$nomTypeLettre = ''; |
2032 |
|
$nomTypeDocument = ''; |
2033 |
|
if ($type === 'lettre_incompletude') { |
2034 |
|
$nomTypeLettre = '3'; |
2035 |
|
$nomTypeDocument = '4'; |
2036 |
|
} elseif ($type === 'lettre_majoration') { |
2037 |
|
$nomTypeLettre = '4'; |
2038 |
|
$nomTypeDocument = '6'; |
2039 |
|
} |
2040 |
|
|
2041 |
|
$inst_di = $this->f->get_inst__om_dbform(array( |
2042 |
|
"obj" => "dossier", |
2043 |
|
"idx" => $dossier, |
2044 |
|
)); |
2045 |
|
$date_limite_notification = DateTime::createFromFormat('Y-m-d', $inst_di->getVal('date_notification_delai')); |
2046 |
|
$aujourdhui = new DateTime(); |
2047 |
|
if (! $date_limite_notification instanceof DateTime) { |
2048 |
|
$nomTypeLettre = ''; |
2049 |
|
$nomTypeDocument = ''; |
2050 |
|
} elseif ($aujourdhui < $date_limite_notification) { |
2051 |
|
$nomTypeLettre = '1'; |
2052 |
|
$nomTypeDocument = '3'; |
2053 |
|
} |
2054 |
|
|
2055 |
|
return array( |
2056 |
|
'nomEtatLettre' => '3', |
2057 |
|
'nomModaliteNotifMetier' => '4', |
2058 |
|
'nomTypeLettre' => $nomTypeLettre, |
2059 |
|
'nomTypeDocument' => $nomTypeDocument |
2060 |
|
); |
2061 |
|
} |
2062 |
|
|
2063 |
protected function sort_instruction_data(array $values, array $res) { |
protected function sort_instruction_data(array $values, array $res) { |
2064 |
$fields = array( |
$fields = array( |
2065 |
|
"instruction", |
2066 |
"date_evenement", |
"date_evenement", |
2067 |
"date_envoi_signature", |
"date_envoi_signature", |
2068 |
"date_retour_signature", |
"date_retour_signature", |
2091 |
} |
} |
2092 |
} |
} |
2093 |
} |
} |
2094 |
|
|
2095 |
|
if (! empty($values['document_type_instruction'])){ |
2096 |
|
// Gestion du type de document : |
2097 |
|
$document_type = $this->f->get_inst__om_dbform(array( |
2098 |
|
"obj" => "document_type", |
2099 |
|
"idx" => $values['document_type_instruction'], |
2100 |
|
)); |
2101 |
|
if (count($document_type->val) > 0) { |
2102 |
|
$res['document_type'] = $document_type->getVal('code'); |
2103 |
|
} |
2104 |
|
} |
2105 |
return $res; |
return $res; |
2106 |
} |
} |
2107 |
|
|
2116 |
if ($instruction === null) { |
if ($instruction === null) { |
2117 |
return false; |
return false; |
2118 |
} |
} |
2119 |
$query = sprintf(' |
$qres = $this->f->get_one_result_from_db_query( |
2120 |
SELECT demande_type.dossier_instruction_type |
sprintf( |
2121 |
FROM %1$sdemande |
'SELECT |
2122 |
INNER JOIN %1$sdemande_type ON demande.demande_type = demande_type.demande_type |
demande_type.dossier_instruction_type |
2123 |
WHERE demande.instruction_recepisse = %2$s |
FROM |
2124 |
', |
%1$sdemande |
2125 |
DB_PREFIXE, |
INNER JOIN %1$sdemande_type |
2126 |
$instruction |
ON demande.demande_type = demande_type.demande_type |
2127 |
); |
WHERE |
2128 |
$res = $this->f->get_one_result_from_db_query( |
demande.instruction_recepisse = %2$d', |
2129 |
$query, |
DB_PREFIXE, |
2130 |
true |
intval($instruction) |
2131 |
|
), |
2132 |
|
array( |
2133 |
|
"origin" => __METHOD__, |
2134 |
|
"force_return" => true, |
2135 |
|
) |
2136 |
); |
); |
2137 |
if ($res['code'] === 'KO') { |
if ($qres["code"] !== "OK") { |
2138 |
return null; |
return null; |
2139 |
} |
} |
2140 |
if ($res['result'] === '') { |
if ($qres["result"] === "") { |
2141 |
return true; |
return true; |
2142 |
} |
} |
2143 |
return false; |
return false; |
2145 |
|
|
2146 |
protected function get_document_numerise_data(string $dn) { |
protected function get_document_numerise_data(string $dn) { |
2147 |
$val_dn = array(); |
$val_dn = array(); |
2148 |
$inst_dn = $this->f->get_inst__om_dbform(array( |
$qres = $this->f->get_all_results_from_db_query( |
2149 |
"obj" => "document_numerise", |
sprintf( |
2150 |
"idx" => $dn, |
'SELECT |
2151 |
)); |
document_numerise.document_numerise, |
2152 |
$val_dn = $inst_dn->get_json_data(); |
document_numerise.uid, |
2153 |
$val_dn['path'] = sprintf('%s&snippet=%s&obj=%s&champ=%s&id=%s', 'app/index.php?module=form', 'file', 'document_numerise', 'uid', $this->getVal('object_id')); |
document_numerise.dossier, |
2154 |
// Correspond à la nomenclature Plat'AU NATURE_PIECE |
document_numerise.nom_fichier, |
2155 |
$val_dn['nature'] = $val_dn['document_numerise_nature_libelle']; |
document_numerise.date_creation, |
2156 |
|
document_numerise.document_numerise_type, |
2157 |
|
document_numerise.uid_dossier_final, |
2158 |
|
document_numerise.document_numerise_nature, |
2159 |
|
document_numerise.uid_thumbnail, |
2160 |
|
document_numerise.description_type, |
2161 |
|
document_numerise.document_travail, |
2162 |
|
document_numerise_type.code AS document_numerise_type_code, |
2163 |
|
document_numerise_type.libelle AS document_numerise_type_libelle, |
2164 |
|
document_numerise_nature.code AS document_numerise_nature_code, |
2165 |
|
document_numerise_nature.libelle AS document_numerise_nature_libelle, |
2166 |
|
document_numerise_nature.libelle AS nature |
2167 |
|
FROM |
2168 |
|
%1$sdocument_numerise |
2169 |
|
LEFT JOIN %1$sdocument_numerise_type |
2170 |
|
ON document_numerise.document_numerise_type = document_numerise_type.document_numerise_type |
2171 |
|
LEFT JOIN %1$sdocument_numerise_nature |
2172 |
|
ON document_numerise.document_numerise_nature = document_numerise_nature.document_numerise_nature |
2173 |
|
WHERE |
2174 |
|
document_numerise.document_numerise = %2$d', |
2175 |
|
DB_PREFIXE, |
2176 |
|
intval($dn) |
2177 |
|
), |
2178 |
|
array( |
2179 |
|
"origin" => __METHOD__, |
2180 |
|
) |
2181 |
|
); |
2182 |
|
if ($qres["result"] !== null |
2183 |
|
&& $qres["result"] !== "" |
2184 |
|
&& count($qres["result"]) > 0) { |
2185 |
|
// |
2186 |
|
$val_dn = $qres["result"][0]; |
2187 |
|
} |
2188 |
|
$val_dn['path'] = $this->compose_url_acces_document('document_numerise', 'uid', $this->getVal('object_id')); |
2189 |
return $val_dn; |
return $val_dn; |
2190 |
} |
} |
2191 |
|
|
2215 |
)); |
)); |
2216 |
$ad = $inst_di->getVal('avis_decision'); |
$ad = $inst_di->getVal('avis_decision'); |
2217 |
$val_ad = array(); |
$val_ad = array(); |
2218 |
if ($ad !== null) { |
if ($ad !== null && trim($ad) !== '') { |
2219 |
$inst_ad = $this->f->get_inst__om_dbform(array( |
$inst_ad = $this->f->get_inst__om_dbform(array( |
2220 |
"obj" => "avis_decision", |
"obj" => "avis_decision", |
2221 |
"idx" => $ad, |
"idx" => $ad, |
2254 |
if (isset($val_consultation['fichier']) === true |
if (isset($val_consultation['fichier']) === true |
2255 |
&& $val_consultation['fichier'] !== '') { |
&& $val_consultation['fichier'] !== '') { |
2256 |
// |
// |
2257 |
$val_consultation['path_fichier'] = sprintf('%s&snippet=%s&obj=%s&champ=%s&id=%s', 'app/index.php?module=form', 'file', 'consultation', 'fichier', $this->getVal('object_id')); |
$val_consultation['path_fichier'] = $this->compose_url_acces_document('consultation', 'fichier', $this->getVal('object_id')); |
2258 |
} |
} |
2259 |
if (isset($val_consultation['om_fichier_consultation']) === true |
if (isset($val_consultation['om_fichier_consultation']) === true |
2260 |
&& $val_consultation['om_fichier_consultation'] !== '') { |
&& $val_consultation['om_fichier_consultation'] !== '') { |
2261 |
// |
// |
2262 |
$val_consultation['path_om_fichier_consultation'] = sprintf('%s&snippet=%s&obj=%s&champ=%s&id=%s', 'app/index.php?module=form', 'file', 'consultation', 'om_fichier_consultation', $this->getVal('object_id')); |
$val_consultation['path_om_fichier_consultation'] = $this->compose_url_acces_document('consultation', 'om_fichier_consultation', $this->getVal('object_id')); |
2263 |
} |
} |
2264 |
return $val_consultation; |
return $val_consultation; |
2265 |
} |
} |
2275 |
return $val_service; |
return $val_service; |
2276 |
} |
} |
2277 |
|
|
2278 |
protected function view_form_json($in_field = false) { |
/** |
2279 |
|
* Recupere le numéro du dossier ou le numéro du dossier parent s'il existe, |
2280 |
|
* @param string $dossier : le numéro du dossier |
2281 |
|
* |
2282 |
|
* @return string $dossier | $dossier_parent |
2283 |
|
*/ |
2284 |
|
protected function get_id_dossier_parent(string $dossier){ |
2285 |
|
$query = sprintf(' |
2286 |
|
SELECT |
2287 |
|
dossier.dossier_parent |
2288 |
|
FROM |
2289 |
|
%1$sdossier |
2290 |
|
WHERE |
2291 |
|
dossier.dossier = \'%2$s\' |
2292 |
|
ORDER BY |
2293 |
|
dossier.dossier', |
2294 |
|
DB_PREFIXE, |
2295 |
|
$dossier |
2296 |
|
); |
2297 |
|
|
2298 |
|
$res = $this->f->get_all_results_from_db_query( |
2299 |
|
$query, |
2300 |
|
array( |
2301 |
|
"origin" => __METHOD__, |
2302 |
|
// "force_return" => true, |
2303 |
|
) |
2304 |
|
); |
2305 |
|
if ($res['code'] === 'KO') { |
2306 |
|
return false; |
2307 |
|
} |
2308 |
|
if ( isset($res['result'][0]["dossier_parent"]) |
2309 |
|
&& ! empty($res['result'][0]["dossier_parent"] ) |
2310 |
|
) { |
2311 |
|
return $res['result'][0]["dossier_parent"]; |
2312 |
|
} |
2313 |
|
return $dossier; |
2314 |
|
|
2315 |
|
} |
2316 |
|
|
2317 |
|
/** |
2318 |
|
* Renvoie un tableau, contenant les informations nécessaire à l'ajout des annexes |
2319 |
|
* à une payload. |
2320 |
|
* |
2321 |
|
* Récupère la liste des annexes paramétrées dans la table parametrage_annexe |
2322 |
|
* pour l'instruction voulu. A partir de cette liste, construit un tableau avec |
2323 |
|
* une entrée par annexe. Chaque entrées contiens les informations suivantes : |
2324 |
|
* - path : url d'accès au fichier |
2325 |
|
* - document_type : code du document dans plat'au |
2326 |
|
* - document_id : uid du document |
2327 |
|
* |
2328 |
|
* @param int $instruction_id : identifiant de l'instruction dont ont doit récuperer les annexes |
2329 |
|
* @param bool $document_platau_uniquement : limite les annexes renvoyées a celles typées pour platau |
2330 |
|
* |
2331 |
|
* @return array $annexes |
2332 |
|
*/ |
2333 |
|
protected function ajouter_annexes_a_la_payload(int $instruction_id, bool $document_platau_uniquement = false) { |
2334 |
|
$annexes = array(); |
2335 |
|
$annexes_a_lier = $this->f->recuperer_documents_a_annexe($instruction_id, $document_platau_uniquement); |
2336 |
|
foreach ($annexes_a_lier as $annexe_info) { |
2337 |
|
$objet = $annexe_info['objet']; |
2338 |
|
$id_objet = $annexe_info['id']; |
2339 |
|
// Récupère l'objet identifié en tant qu'annexe. Si l'objet n'est pas |
2340 |
|
// récupéré on passe à l'itération suivante |
2341 |
|
if (empty($inst_objet = $this->f->findObjectById($objet, $id_objet, true))) { |
2342 |
|
$this->f->addToLog(__METHOD__."() : L'objet *$objet* d'identifiant *$id_objet* n'a pas pu être instancié, son document ne peut pas être ajouté aux annexes."); |
2343 |
|
continue; |
2344 |
|
} |
2345 |
|
|
2346 |
|
// Détermine le champ contenant l'uid et le type de document |
2347 |
|
switch ($objet) { |
2348 |
|
case 'document_numerise': |
2349 |
|
$champ_uid = 'uid'; |
2350 |
|
/* TODO : Gestion du document_type |
2351 |
|
$document_numerise_type = $this->f->get_inst__om_dbform(array( |
2352 |
|
"obj" => 'document_numerise_type', |
2353 |
|
"idx" => $inst_objet->getVal('document_numerise_type'), |
2354 |
|
)); |
2355 |
|
$document_numerise_type_categorie = $this->f->get_inst__om_dbform(array( |
2356 |
|
"obj" => 'document_numerise_type_categorie', |
2357 |
|
"idx" => $document_numerise_type->getVal('document_numerise_type_categorie'), |
2358 |
|
)); |
2359 |
|
$annexe['document_type'] = |
2360 |
|
*/ |
2361 |
|
$document_type = ''; |
2362 |
|
break; |
2363 |
|
case 'instruction': |
2364 |
|
$champ_uid = 'om_fichier_instruction'; |
2365 |
|
$inst_document_type = $this->f->findObjectById('document_type', $inst_objet->getVal('document_type_instruction')); |
2366 |
|
$document_type = $inst_document_type->getVal('code'); |
2367 |
|
break; |
2368 |
|
case 'consultation': |
2369 |
|
$champ_uid = 'fichier'; |
2370 |
|
// Gestion du document_type, Code platau de la consultation |
2371 |
|
$document_type = self::CODE_PLATAU_CONSULTATION; |
2372 |
|
break; |
2373 |
|
default : |
2374 |
|
// Si le type de document n'est pas géré on passe au document suivant. |
2375 |
|
// Ajoute une ligne dans les logs pour comprendre pourquoi le document n'apparaît pas. |
2376 |
|
$this->f->addToLog( |
2377 |
|
__METHOD__. |
2378 |
|
"() : L'ajout d'annexe lié aux *$objet* n'est pas implémenté. |
2379 |
|
Le document de *$objet* et d'identifiant *$id_objet* n'a pas été ajouté aux annexes.", |
2380 |
|
DEBUG_MODE |
2381 |
|
); |
2382 |
|
continue 2; |
2383 |
|
} |
2384 |
|
|
2385 |
|
$annexes[] = array( |
2386 |
|
'path' => $this->compose_url_acces_document($objet, $champ_uid, $id_objet), |
2387 |
|
'document_type' => $document_type, |
2388 |
|
'document_id' => $inst_objet->getVal($champ_uid) |
2389 |
|
); |
2390 |
|
} |
2391 |
|
return $annexes; |
2392 |
|
} |
2393 |
|
|
2394 |
|
/** |
2395 |
|
* Fonction de récupération des UID externes en fonction des besoins. |
2396 |
|
* - Factorisation du code |
2397 |
|
* |
2398 |
|
* @param array $val : Tableau des valeurs du flux. |
2399 |
|
* @param array $elements default array() : liste des élément à ajouter au tableau des UID_externes |
2400 |
|
* @param array $val_external_uid default array() : tableau des UIDs externes du flux |
2401 |
|
* |
2402 |
|
* @return array $val_external_uid |
2403 |
|
* |
2404 |
|
*/ |
2405 |
|
protected function val_external_uid(array $val, array $elements = array(), array $val_external_uid = array()) { |
2406 |
|
|
2407 |
|
if (in_array('dossier_autorisation', $elements)) { |
2408 |
|
if (empty($val['dossier_autorisation']['dossier_autorisation'])) { |
2409 |
|
$dossier_autorisation = $val['dossier']['dossier_autorisation']; |
2410 |
|
} else { |
2411 |
|
$dossier_autorisation = $val['dossier_autorisation']['dossier_autorisation']; |
2412 |
|
} |
2413 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($dossier_autorisation, 'dossier_autorisation'); |
2414 |
|
} |
2415 |
|
|
2416 |
|
if (in_array('dossier', $elements)) { |
2417 |
|
$val_external_uid['dossier'] = $this->get_external_uid( |
2418 |
|
$this->get_id_dossier_parent($val['dossier']['dossier']), |
2419 |
|
'dossier' |
2420 |
|
); |
2421 |
|
} |
2422 |
|
|
2423 |
|
if (in_array('piece', $elements)) { |
2424 |
|
$val_external_uid['piece'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'piece'); |
2425 |
|
} |
2426 |
|
if (in_array('dossier_consultation', $elements)) { |
2427 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid( |
2428 |
|
$this->get_id_dossier_parent($val['dossier']['dossier']), |
2429 |
|
'dossier_consultation' |
2430 |
|
); |
2431 |
|
} |
2432 |
|
if (in_array('prescription', $elements)) { |
2433 |
|
$val_external_uid['prescription'] = $this->get_external_uid($this->getVal('object_id'), 'prescription'); |
2434 |
|
} |
2435 |
|
if (in_array('avis_dossier_consultation', $elements)) { |
2436 |
|
$val_external_uid['avis_dossier_consultation'] = $this->get_external_uid( |
2437 |
|
$this->getVal('object_id'), 'avis_dossier_consultation'); |
2438 |
|
} |
2439 |
|
if (in_array('decision', $elements)) { |
2440 |
|
$val_external_uid['decision'] = $this->get_external_uid($this->getVal('object_id'), 'instruction'); |
2441 |
|
if ($val_external_uid['decision'] === '') { |
2442 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
2443 |
|
"obj" => "instruction", |
2444 |
|
"idx" => $this->getVal('object_id'), |
2445 |
|
)); |
2446 |
|
$val_external_uid['decision'] = $this->get_external_uid($inst_instruction->get_related_instructions_next('retour_signature'), 'instruction'); |
2447 |
|
} |
2448 |
|
} |
2449 |
|
if (in_array('instruction_notification', $elements)) { |
2450 |
|
$val_external_uid['instruction_notification'] = $this->get_external_uid($this->getVal('object_id'), 'instruction_notification', PORTAL); |
2451 |
|
} |
2452 |
|
return $val_external_uid; |
2453 |
|
} |
2454 |
|
|
2455 |
|
/** |
2456 |
|
* |
2457 |
|
* |
2458 |
|
*/ |
2459 |
|
protected function view_form_json(bool $in_field = false) { |
2460 |
// |
// |
2461 |
if ($this->f->get_submitted_post_value('valid') === null |
$check_state = isset($this->valF['state']) === true ? $this->valF['state'] : $this->getVal('state'); |
2462 |
&& $this->getVal('state') !== self::STATUS_CANCELED) { |
if ($check_state !== self::STATUS_CANCELED) { |
2463 |
|
|
2464 |
|
$data = array('in_field' => $in_field); |
2465 |
|
$this->f->module_manager->run_hooks('view_form_json_pre', $this, $data); |
2466 |
|
|
2467 |
// Liste des valeurs à afficher |
// Liste des valeurs à afficher |
2468 |
$val = array(); |
$val = array(); |
2469 |
|
|
2470 |
// |
// |
2471 |
$val_task = array_combine($this->champs, $this->val); |
$val_task = array_combine($this->champs, $this->val); |
2472 |
foreach ($val_task as $key => $value) { |
foreach ($val_task as $key => $value) { |
2473 |
$val_task[$key] = strip_tags($value); |
$val_task[$key] = strip_tags($value); |
2474 |
} |
} |
2475 |
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
|
2476 |
unset($val_task['timestamp_log_hidden']); |
// Vérifie pour les tâches dont l'affichage de la payload est calculée si l'objet |
2477 |
$val['task'] = $val_task; |
// de référence de la tâche existe. |
2478 |
// |
$objectRefExist = true; |
2479 |
if ($this->getVal('type') === 'creation_DA' |
if ($val_task['stream'] === 'output' |
2480 |
|| $this->getVal('type') === 'modification_DA') { |
&& (empty($val_task['json_payload']) || $val_task['json_payload'] === '{}')) { |
2481 |
// |
$objectRefExist = $this->does_referenced_object_exist( |
2482 |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
$val_task['object_id'], |
2483 |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
$val_task['type'] |
2484 |
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
); |
|
$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; |
|
2485 |
} |
} |
2486 |
// |
|
2487 |
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 |
2488 |
|
// renvoie une payload contenant le message d'erreur. |
2489 |
|
// Sinon constitue la payload du json. |
2490 |
|
if (! $objectRefExist) { |
2491 |
|
$this->f->addToLog( |
2492 |
|
sprintf( |
2493 |
|
__('Impossible de récupérer la payload car l\'objet de réference n\'existe pas pour la tâche : %s'), |
2494 |
|
$val_task['task'] |
2495 |
|
), |
2496 |
|
DEBUG_MODE |
2497 |
|
); |
2498 |
|
$val = __('Impossible de recuperer la payload car l\'objet de reference n\'existe pas.'); |
2499 |
|
} else { |
2500 |
|
|
2501 |
|
// L'historique n'est pas nécessaire dans l'affichage en JSON |
2502 |
|
if ($in_field === true) { |
2503 |
|
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
2504 |
|
} else { |
2505 |
|
unset($val_task['timestamp_log']); |
2506 |
|
} |
2507 |
|
unset($val_task['timestamp_log_hidden']); |
2508 |
|
$val['task'] = $val_task; |
2509 |
// |
// |
2510 |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
if ($this->getVal('type') === 'creation_DA' |
2511 |
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
|| $this->getVal('type') === 'modification_DA') { |
2512 |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($val['dossier']['dossier_autorisation']); |
// |
2513 |
$val_external_uid = array(); |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
2514 |
$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'); |
2515 |
$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']); |
2516 |
$val_external_uid['decision'] = $this->get_external_uid($this->getVal('object_id'), 'instruction'); |
// Recupération des UID externes |
2517 |
if ($val_external_uid['decision'] === '') { |
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation')); |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
|
|
"obj" => "instruction", |
|
|
"idx" => $this->getVal('object_id'), |
|
|
)); |
|
|
$val_external_uid['decision'] = $this->get_external_uid($inst_instruction->get_related_instructions_next('retour_signature'), 'instruction'); |
|
2518 |
} |
} |
2519 |
$val['external_uids'] = $val_external_uid; |
// |
2520 |
} |
if ($this->getVal('type') === 'creation_DI' |
2521 |
if ($this->getVal('type') === 'notification_instruction' |
|| $this->getVal('type') === 'modification_DI' |
2522 |
|| $this->getVal('type') === 'notification_recepisse' |
|| $this->getVal('type') === 'depot_DI') { |
2523 |
|| $this->getVal('type') === 'notification_decision' |
// |
2524 |
|| $this->getVal('type') === 'notification_service_consulte' |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
2525 |
|| $this->getVal('type') === 'notification_tiers_consulte') { |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction'); |
2526 |
// |
$val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']); |
2527 |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
$architecte = isset($val['donnees_techniques']['architecte']) === true ? $val['donnees_techniques']['architecte'] : null; |
2528 |
$dossier_id = isset($val['dossier']['dossier']) === true ? $val['dossier']['dossier'] : null; |
$val['architecte'] = $this->get_architecte_data($architecte); |
2529 |
$val['demandeur'] = $this->get_demandeurs_data($dossier_id); |
$val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']); |
2530 |
$val['instruction_notification'] = $this->get_instruction_notification_data($this->getVal('category'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
// Recupération des UID externes |
2531 |
$instruction_id = isset($val['instruction_notification']['instruction']) === true ? $val['instruction_notification']['instruction'] : null; |
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier')); |
2532 |
$instruction_annexes = isset($val['instruction_notification']['annexes']) === true ? $val['instruction_notification']['annexes'] : null; |
} |
2533 |
$val['instruction'] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $instruction_id)); |
// |
2534 |
// Précise qu'il s'agit d'une instruction final si l'instruction est liée à une |
if ($this->getVal('type') === 'qualification_DI') { |
2535 |
// demande dont le type ne génère pas de dossier |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2536 |
if ($this->is_demande_instruction_recepisse_without_dossier($instruction_id) === true) { |
// Recupération des UID externes |
2537 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier')); |
2538 |
|
} |
2539 |
|
// |
2540 |
|
if ($this->getVal('type') === 'ajout_piece') { |
2541 |
|
$val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id')); |
2542 |
|
$val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']); |
2543 |
|
// Recupération des UID externes |
2544 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier', 'piece')); |
2545 |
|
} |
2546 |
|
// |
2547 |
|
if ($this->getVal('type') === 'modification_piece') { |
2548 |
|
$val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id')); |
2549 |
|
$val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']); |
2550 |
|
// Recupération des UID externes |
2551 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier', 'piece')); |
2552 |
|
} |
2553 |
|
// |
2554 |
|
if ($this->getVal('type') === 'suppression_piece') { |
2555 |
|
$val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id')); |
2556 |
|
$val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']); |
2557 |
|
// Recupération des UID externes |
2558 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier', 'piece')); |
2559 |
|
} |
2560 |
|
// |
2561 |
|
if ($this->getVal('type') === 'decision_DI') { |
2562 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2563 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
2564 |
$val['instruction']['final'] = 't'; |
$val['instruction']['final'] = 't'; |
2565 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
2566 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
2567 |
|
} |
2568 |
|
// Recupération des UID externes |
2569 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier')); |
2570 |
|
} |
2571 |
|
// |
2572 |
|
if ($this->getVal('type') === 'incompletude_DI') { |
2573 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2574 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
2575 |
|
// Recupération des UID externes |
2576 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier')); |
2577 |
|
} |
2578 |
|
// |
2579 |
|
if ($this->getVal('type') === 'completude_DI') { |
2580 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2581 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
2582 |
|
// Recupération des UID externes |
2583 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier')); |
2584 |
|
} |
2585 |
|
// |
2586 |
|
if ($this->getVal('type') === 'lettre_incompletude' |
2587 |
|
|| $this->getVal('type') === 'lettre_majoration') { |
2588 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2589 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
2590 |
|
$val['lettre_petitionnaire'] = $this->get_lettre_petitionnaire_data($val['dossier']['dossier'], $this->getVal('type')); |
2591 |
|
// Recupération des UID externes |
2592 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier')); |
2593 |
|
} |
2594 |
|
// |
2595 |
|
if ($this->getVal('type') === 'pec_metier_consultation') { |
2596 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2597 |
|
$val['instruction'] = $this->get_instruction_data( |
2598 |
|
$this->getVal('dossier'), |
2599 |
|
'with-id', |
2600 |
|
array('with-id' => $this->getVal('object_id')) |
2601 |
|
); |
2602 |
|
// Recupération des UID externes |
2603 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier', 'dossier_consultation')); |
2604 |
|
} |
2605 |
|
// |
2606 |
|
if ($this->getVal('type') === 'avis_consultation') { |
2607 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2608 |
|
$val['instruction'] = $this->get_instruction_data( |
2609 |
|
$this->getVal('dossier'), |
2610 |
|
'with-id', |
2611 |
|
array('with-id' => $this->getVal('object_id')) |
2612 |
|
); |
2613 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
2614 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
2615 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
2616 |
|
} |
2617 |
|
// Recupération des UID externes |
2618 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier', 'dossier_consultation', 'avis_dossier_consultation')); |
2619 |
|
} |
2620 |
|
// |
2621 |
|
if ($this->getVal('type') === 'creation_consultation') { |
2622 |
|
// |
2623 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2624 |
|
$val['consultation'] = $this->get_consultation_data($this->getVal('object_id')); |
2625 |
|
$val['service'] = $this->get_service_data($val['consultation']['service']); |
2626 |
|
// Recupération des UID externes |
2627 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier')); |
2628 |
|
} |
2629 |
|
// |
2630 |
|
if ($this->getVal('type') === 'envoi_CL') { |
2631 |
|
// |
2632 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2633 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2634 |
|
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($val['dossier']['dossier_autorisation']); |
2635 |
|
// Recupération des UID externes |
2636 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier', 'decision')); |
2637 |
|
} |
2638 |
|
if ($this->getVal('type') === 'notification_instruction' |
2639 |
|
|| $this->getVal('type') === 'notification_recepisse' |
2640 |
|
|| $this->getVal('type') === 'notification_decision' |
2641 |
|
|| $this->getVal('type') === 'notification_service_consulte' |
2642 |
|
|| $this->getVal('type') === 'notification_tiers_consulte' |
2643 |
|
|| $this->getVal('type') === 'notification_signataire') { |
2644 |
|
// |
2645 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2646 |
|
$dossier_id = isset($val['dossier']['dossier']) === true ? $val['dossier']['dossier'] : null; |
2647 |
|
$val['demandeur'] = $this->get_demandeurs_data($dossier_id); |
2648 |
|
$val['instruction_notification'] = $this->get_instruction_notification_data($this->getVal('category'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2649 |
|
$instruction_id = isset($val['instruction_notification']['instruction']) === true ? $val['instruction_notification']['instruction'] : null; |
2650 |
|
$val['instruction'] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $instruction_id)); |
2651 |
|
// Précise qu'il s'agit d'une instruction final si l'instruction est liée à une |
2652 |
|
// demande dont le type ne génère pas de dossier |
2653 |
|
if ($this->is_demande_instruction_recepisse_without_dossier($instruction_id) === true) { |
2654 |
|
$val['instruction']['final'] = 't'; |
2655 |
|
} |
2656 |
|
// Recupération des UID externes |
2657 |
|
$val_external_uid = array(); |
2658 |
|
// Affiche l'identifiant externe lié à l'instruction si cette combinaison existe, sinon celui lié au dossier |
2659 |
|
$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'); |
2660 |
|
$val_external_uid['demande (instruction)'] = $this->get_external_uid($instruction_id, 'demande', PORTAL, 'ASC'); |
2661 |
|
$val['external_uids'] = $this->val_external_uid($val, array('demande', 'demande (instruction)', 'instruction_notification'), $val_external_uid ); |
2662 |
|
} |
2663 |
|
// |
2664 |
|
if ($this->getVal('type') === 'prescription') { |
2665 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2666 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2667 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
2668 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
2669 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
2670 |
|
} |
2671 |
|
// Recupération des UID externes |
2672 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier', 'dossier_consultation', 'prescription')); |
2673 |
|
} |
2674 |
|
// |
2675 |
|
if ($this->getVal('type') === 'ajout_documents_specifiques') { |
2676 |
|
// Data blocs |
2677 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2678 |
|
$val['instruction'] = $this->get_instruction_data( |
2679 |
|
$this->getVal('dossier'), |
2680 |
|
'with-id', |
2681 |
|
array('with-id' => $this->getVal('object_id')) |
2682 |
|
); |
2683 |
|
// Recupération des UID externes |
2684 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier', 'dossier_consultation')); |
2685 |
} |
} |
|
$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_uid['demande (instruction)'] = $this->get_external_uid($instruction_id, 'demande', 'portal', 'ASC'); |
|
|
$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') === '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; |
|
2686 |
} |
} |
2687 |
|
|
2688 |
|
$data = array('in_field' => $in_field, 'val' => &$val); |
2689 |
|
$this->f->module_manager->run_hooks('view_form_json_post', $this, $data); |
2690 |
|
|
2691 |
if ($in_field === true) { |
if ($in_field === true) { |
2692 |
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
2693 |
} else { |
} else { |
2707 |
'state' => $this->f->get_submitted_post_value('state') |
'state' => $this->f->get_submitted_post_value('state') |
2708 |
), |
), |
2709 |
); |
); |
2710 |
|
if ($this->f->get_submitted_post_value('comment') !== null) { |
2711 |
|
$params['comment'] = $this->f->get_submitted_post_value('comment'); |
2712 |
|
} |
2713 |
$update = $this->update_task($params); |
$update = $this->update_task($params); |
2714 |
$message_class = "valid"; |
$message_class = "valid"; |
2715 |
$message = $this->msg; |
$message = $this->msg; |
2726 |
} |
} |
2727 |
|
|
2728 |
// Sauvegarde de l'uid externe retourné |
// Sauvegarde de l'uid externe retourné |
2729 |
if ($this->f->get_submitted_post_value('external_uid') !== null) { |
$external_uid = $this->f->get_submitted_post_value('external_uid'); |
2730 |
|
if ($external_uid !== null) { |
2731 |
// |
// |
2732 |
$objects = $this->get_objects_by_task_type($this->getVal('type'), $this->getVal('stream')); |
$objects = $this->get_objects_by_task_type($this->getVal('type'), $this->getVal('stream')); |
2733 |
|
// Si l'identifiant externe contient le préfixe pour identifier les codes de suivi, |
2734 |
|
// le seul objet concerné sera celui du code de suivi |
2735 |
|
if (strpos($external_uid, self::CS_PREFIX) !== false) { |
2736 |
|
$objects = array('code-suivi', ); |
2737 |
|
$external_uid = str_replace(self::CS_PREFIX, '', $external_uid); |
2738 |
|
} |
2739 |
foreach ($objects as $object) { |
foreach ($objects as $object) { |
2740 |
$inst_lien = $this->f->get_inst__om_dbform(array( |
$inst_lien = $this->f->get_inst__om_dbform(array( |
2741 |
"obj" => "lien_id_interne_uid_externe", |
"obj" => "lien_id_interne_uid_externe", |
2742 |
"idx" => ']', |
"idx" => ']', |
2743 |
)); |
)); |
2744 |
$object_id = $this->getVal('object_id'); |
$object_id = $this->getVal('object_id'); |
2745 |
$is_exists = $inst_lien->is_exists($object, $object_id, $this->f->get_submitted_post_value('external_uid'), $this->getVal('dossier')); |
$is_exists = $inst_lien->is_exists($object, $object_id, $external_uid, $this->getVal('dossier')); |
2746 |
// Dans le cas spécifique de la mise à jour d'une notification |
// Dans le cas spécifique de la mise à jour d'une notification |
2747 |
// et de la création d'une liaison d'identifiant pour l'objet demande, |
// et de la création d'une liaison d'identifiant pour l'objet demande, |
2748 |
// l'identifiant de l'objet n'est plus celui de la notification |
// l'identifiant de l'objet n'est plus celui de la notification |
2752 |
|| $this->getVal('type') === 'notification_instruction' |
|| $this->getVal('type') === 'notification_instruction' |
2753 |
|| $this->getVal('type') === 'notification_decision' |
|| $this->getVal('type') === 'notification_decision' |
2754 |
|| $this->getVal('type') === 'notification_service_consulte' |
|| $this->getVal('type') === 'notification_service_consulte' |
2755 |
|| $this->getVal('type') === 'notification_tiers_consulte')) { |
|| $this->getVal('type') === 'notification_tiers_consulte' |
2756 |
|
|| $this->getVal('type') === 'notification_signataire')) { |
2757 |
// |
// |
2758 |
$object_id = $this->getVal('dossier'); |
$object_id = $this->getVal('dossier'); |
2759 |
// 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" |
2764 |
'lien_id_interne_uid_externe' => '', |
'lien_id_interne_uid_externe' => '', |
2765 |
'object' => $object, |
'object' => $object, |
2766 |
'object_id' => $object_id, |
'object_id' => $object_id, |
2767 |
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
'external_uid' => $external_uid, |
2768 |
'dossier' => $this->getVal('dossier'), |
'dossier' => $this->getVal('dossier'), |
2769 |
'category' => $this->getVal('category'), |
'category' => $this->getVal('category'), |
2770 |
); |
); |
2791 |
$result = $this->add_task(array( |
$result = $this->add_task(array( |
2792 |
'val' => array( |
'val' => array( |
2793 |
'stream' => 'input', |
'stream' => 'input', |
2794 |
'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), |
2795 |
'type' => $this->f->get_submitted_post_value('type'), |
'type' => $this->f->get_submitted_post_value('type'), |
2796 |
'category' => $this->f->get_submitted_post_value('category'), |
'category' => $this->f->get_submitted_post_value('category'), |
2797 |
) |
) |
2817 |
function setLayout(&$form, $maj) { |
function setLayout(&$form, $maj) { |
2818 |
// |
// |
2819 |
$form->setBloc('json_payload', 'D', '', 'col_6'); |
$form->setBloc('json_payload', 'D', '', 'col_6'); |
2820 |
$form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed"); |
$fieldset_title_payload = __("json_payload (calculée)"); |
2821 |
|
if ($this->getVal('json_payload') !== "{}") { |
2822 |
|
$fieldset_title_payload = __("json_payload"); |
2823 |
|
} |
2824 |
|
$form->setFieldset('json_payload', 'DF', $fieldset_title_payload, "collapsible, startClosed"); |
2825 |
$form->setBloc('json_payload', 'F'); |
$form->setBloc('json_payload', 'F'); |
2826 |
$form->setBloc('timestamp_log', 'DF', __("historique"), 'col_9 timestamp_log_jsontotab'); |
$form->setBloc('timestamp_log', 'DF', __("historique"), 'col_9 timestamp_log_jsontotab'); |
2827 |
} |
} |
2850 |
&& $stream === 'input') { |
&& $stream === 'input') { |
2851 |
$objects = array('dossier', 'dossier_autorisation', 'demande', ); |
$objects = array('dossier', 'dossier_autorisation', 'demande', ); |
2852 |
} |
} |
2853 |
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
if (in_array($type, array( |
2854 |
|
'decision_DI', |
2855 |
|
'incompletude_DI', |
2856 |
|
'completude_DI', |
2857 |
|
'lettre_incompletude', |
2858 |
|
'lettre_majoration' |
2859 |
|
)) === true) { |
2860 |
$objects = array('instruction', ); |
$objects = array('instruction', ); |
2861 |
} |
} |
2862 |
if (in_array($type, array('envoi_CL', )) === true) { |
if (in_array($type, array('envoi_CL', )) === true) { |
2874 |
&& $stream === 'output') { |
&& $stream === 'output') { |
2875 |
$objects = array('prescription', ); |
$objects = array('prescription', ); |
2876 |
} |
} |
2877 |
if (in_array($type, array('ajout_piece', 'add_piece', )) === true) { |
if (in_array($type, array('ajout_piece', 'add_piece', 'modification_piece', 'suppression_piece', )) === true) { |
2878 |
$objects = array('piece', ); |
$objects = array('piece', ); |
2879 |
} |
} |
2880 |
if (in_array($type, array('creation_consultation', )) === true) { |
if (in_array($type, array('creation_consultation', )) === true) { |
2881 |
$objects = array('consultation', ); |
$objects = array('consultation', ); |
2882 |
} |
} |
2883 |
|
if (in_array($type, array('ajout_documents_specifiques', )) === true |
2884 |
|
&& $stream === 'output') { |
2885 |
|
$objects = array('dossier', 'instruction', 'instruction_notification',); |
2886 |
|
} |
2887 |
if (in_array($type, array('pec_metier_consultation', )) === true |
if (in_array($type, array('pec_metier_consultation', )) === true |
2888 |
&& $stream === 'input') { |
&& $stream === 'input') { |
2889 |
$objects = array('pec_metier_consultation', ); |
$objects = array('pec_metier_consultation', ); |
2904 |
'notification_decision', |
'notification_decision', |
2905 |
'notification_service_consulte', |
'notification_service_consulte', |
2906 |
'notification_tiers_consulte', |
'notification_tiers_consulte', |
2907 |
|
'notification_signataire', |
2908 |
) |
) |
2909 |
) === true) { |
) === true) { |
2910 |
$objects = array('instruction_notification', 'demande', ); |
$objects = array('instruction_notification', 'demande', ); |
2925 |
if (in_array($type, array('creation_DA', 'modification_DA', )) === true) { |
if (in_array($type, array('creation_DA', 'modification_DA', )) === true) { |
2926 |
$tables = array('dossier_autorisation', ); |
$tables = array('dossier_autorisation', ); |
2927 |
} |
} |
2928 |
if (in_array($type, array('creation_DI', 'depot_DI', )) === true) { |
if (in_array($type, array('creation_DI', 'depot_DI', 'modification_DI',)) === true) { |
2929 |
$tables = array('dossier', ); |
$tables = array('dossier', ); |
2930 |
} |
} |
2931 |
if (in_array($type, array('qualification_DI', )) === true) { |
if (in_array($type, array('qualification_DI', )) === true) { |
2938 |
&& $stream === 'input') { |
&& $stream === 'input') { |
2939 |
$tables = array('dossier', 'dossier_autorisation', 'demande', ); |
$tables = array('dossier', 'dossier_autorisation', 'demande', ); |
2940 |
} |
} |
2941 |
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
if (in_array($type, array( |
2942 |
|
'decision_DI', |
2943 |
|
'incompletude_DI', |
2944 |
|
'completude_DI', |
2945 |
|
'lettre_incompletude', |
2946 |
|
'lettre_majoration' |
2947 |
|
)) === true) { |
2948 |
|
$tables = array('instruction', ); |
2949 |
|
} |
2950 |
|
if (in_array($type, array('ajout_documents_specifiques', )) === true |
2951 |
|
&& in_array($stream, array('output', 'all', )) === true ) { |
2952 |
|
$tables = array('instruction', 'dossier', ); |
2953 |
|
} |
2954 |
|
if (in_array($type, array('envoi_CL', )) === true) { |
2955 |
$tables = array('instruction', ); |
$tables = array('instruction', ); |
2956 |
} |
} |
2957 |
if (in_array($type, array('pec_metier_consultation', )) === true |
if (in_array($type, array('pec_metier_consultation', )) === true |
2958 |
&& $stream === 'output') { |
&& $stream === 'output') { |
2959 |
$tables = array('instruction', ); |
$tables = array('dossier', 'instruction', 'instruction_notification', ); |
2960 |
} |
} |
2961 |
if (in_array($type, array('avis_consultation', )) === true |
if (in_array($type, array('avis_consultation', )) === true |
2962 |
&& $stream === 'output') { |
&& $stream === 'output') { |
2966 |
&& $stream === 'output') { |
&& $stream === 'output') { |
2967 |
$tables = array('instruction', ); |
$tables = array('instruction', ); |
2968 |
} |
} |
2969 |
if (in_array($type, array('ajout_piece', 'add_piece', )) === true) { |
if (in_array($type, array('ajout_piece', 'add_piece', 'modification_piece', 'suppression_piece', )) === true) { |
2970 |
$tables = array('document_numerise', ); |
$tables = array('document_numerise', ); |
2971 |
} |
} |
2972 |
if (in_array($type, array('creation_consultation', )) === true) { |
if (in_array($type, array('creation_consultation', )) === true) { |
2991 |
'notification_instruction', |
'notification_instruction', |
2992 |
'notification_decision', |
'notification_decision', |
2993 |
'notification_service_consulte', |
'notification_service_consulte', |
2994 |
'notification_tiers_consulte' |
'notification_tiers_consulte', |
2995 |
|
'notification_signataire' |
2996 |
) |
) |
2997 |
) === true) { |
) === true) { |
2998 |
$tables = array('instruction_notification', ); |
$tables = array('instruction_notification', ); |
3000 |
return $tables; |
return $tables; |
3001 |
} |
} |
3002 |
|
|
3003 |
|
/** |
3004 |
|
* Vérifie si l'objet référencé par la tâche existe en base de données. |
3005 |
|
* |
3006 |
|
* Récupère la liste des tables de référence associé à la tâche à partir |
3007 |
|
* du type de tâche et de son flux (input ou output). |
3008 |
|
* Pour chaque table potentiellement référencé par la tâche on essaye d'instancier |
3009 |
|
* l'objet correspondant à partir de l'identifiant de l'objet de référence de la tâche. |
3010 |
|
* Si l'élément instancié existe renvoie true sinon renvoie false. |
3011 |
|
* |
3012 |
|
* @param string|integer $taskObjectId : identifiant de l'objet de référence de la tâche |
3013 |
|
* @param string $taskType : type de la tâche |
3014 |
|
* @param string $taskStream : flux entrant (output - valeur par défaut) ou sortant (input) |
3015 |
|
* @return boolean |
3016 |
|
*/ |
3017 |
|
protected function does_referenced_object_exist($taskObjectId, string $taskType, string $taskStream = 'output') { |
3018 |
|
$refTables = $this->get_tables_by_task_type($taskType, $taskStream); |
3019 |
|
if (empty($refTables) === true) { |
3020 |
|
$this->f->addToLog( |
3021 |
|
sprintf( |
3022 |
|
__("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."), |
3023 |
|
$taskType, |
3024 |
|
"get_tables_by_task_type()" |
3025 |
|
), |
3026 |
|
DEBUG_MODE |
3027 |
|
); |
3028 |
|
return true; |
3029 |
|
} |
3030 |
|
foreach ($refTables as $table) { |
3031 |
|
$inst = $this->f->get_inst__om_dbform(array( |
3032 |
|
'obj' => $table, |
3033 |
|
'idx' => $taskObjectId |
3034 |
|
)); |
3035 |
|
if ($inst->exists() === true) { |
3036 |
|
return true; |
3037 |
|
} |
3038 |
|
} |
3039 |
|
return false; |
3040 |
|
} |
3041 |
|
|
3042 |
} |
} |