15 |
const STATUS_ARCHIVED = 'archived'; |
const STATUS_ARCHIVED = 'archived'; |
16 |
|
|
17 |
/** |
/** |
18 |
|
* Liste des types de tâche concernant les services instructeurs |
19 |
|
*/ |
20 |
|
const TASK_TYPE_SI = array( |
21 |
|
'creation_DA', |
22 |
|
'creation_DI', |
23 |
|
'depot_DI', |
24 |
|
'modification_DI', |
25 |
|
'qualification_DI', |
26 |
|
'decision_DI', |
27 |
|
'incompletude_DI', |
28 |
|
'completude_DI', |
29 |
|
'ajout_piece', |
30 |
|
'add_piece', |
31 |
|
'creation_consultation', |
32 |
|
); |
33 |
|
|
34 |
|
/** |
35 |
|
* Liste des types de tâche concernant les services consultés |
36 |
|
*/ |
37 |
|
const TASK_TYPE_SC = array( |
38 |
|
'create_DI_for_consultation', |
39 |
|
'avis_consultation', |
40 |
|
'pec_metier_consultation', |
41 |
|
); |
42 |
|
|
43 |
|
/** |
44 |
* Définition des actions disponibles sur la classe. |
* Définition des actions disponibles sur la classe. |
45 |
* |
* |
46 |
* @return void |
* @return void |
67 |
|
|
68 |
public function setvalF($val = array()) { |
public function setvalF($val = array()) { |
69 |
|
|
70 |
// les guillets doubles sont remplacés automatiquement par des simples |
// // les guillets doubles sont remplacés automatiquement par des simples |
71 |
// dans core/om_formulaire.clasS.php::recupererPostvar() |
// // dans core/om_formulaire.clasS.php::recupererPostvar() |
72 |
// voir le ticket https://dev.atreal.fr/projets/openmairie/tracker/209 |
// // voir le ticket https://dev.atreal.fr/projets/openmairie/tracker/209 |
73 |
// ceci est un hack sale temporaire en attendant résolution du ticket |
// // ceci est un hack sale temporaire en attendant résolution du ticket |
74 |
foreach(array('json_payload', 'timestamp_log') as $key) { |
// foreach(array('json_payload', 'timestamp_log') as $key) { |
75 |
if (isset($val[$key]) && ! empty($val[$key]) && |
// if (isset($val[$key]) && ! empty($val[$key]) && |
76 |
isset($_POST[$key]) && ! empty($_POST[$key])) { |
// isset($_POST[$key]) && ! empty($_POST[$key])) { |
77 |
$submited_payload = $_POST[$key]; |
// $submited_payload = $_POST[$key]; |
78 |
if (! empty($submited_payload)) { |
// if (! empty($submited_payload)) { |
79 |
$new_payload = str_replace("'", '"', $val[$key]); |
// $new_payload = str_replace("'", '"', $val[$key]); |
80 |
if ($new_payload == $submited_payload || |
// if ($new_payload == $submited_payload || |
81 |
strpos($submited_payload, '"') === false) { |
// strpos($submited_payload, '"') === false) { |
82 |
$val[$key] = $new_payload; |
// $val[$key] = $new_payload; |
83 |
} |
// } |
84 |
else { |
// else { |
85 |
$error_msg = sprintf( |
// $error_msg = sprintf( |
86 |
__("La convertion des guillemets de la payload JSON '%s' ". |
// __("La convertion des guillemets de la payload JSON '%s' ". |
87 |
"n'est pas idempotente (courante: %s, postée: %s, convertie: %s)"), |
// "n'est pas idempotente (courante: %s, postée: %s, convertie: %s)"), |
88 |
$key, var_export($val[$key], true), var_export($submited_payload, true), |
// $key, var_export($val[$key], true), var_export($submited_payload, true), |
89 |
var_export($new_payload, true)); |
// var_export($new_payload, true)); |
90 |
$this->correct = false; |
// $this->correct = false; |
91 |
$this->addToMessage($error_msg); |
// $this->addToMessage($error_msg); |
92 |
$this->addToLog(__METHOD__."() erreur : $error_msg", DEBUG_MODE); |
// $this->addToLog(__METHOD__."() erreur : $error_msg", DEBUG_MODE); |
93 |
return false; |
// return false; |
94 |
} |
// } |
95 |
} |
// } |
96 |
} |
// } |
97 |
} |
// } |
98 |
|
|
99 |
parent::setvalF($val); |
parent::setvalF($val); |
100 |
|
|
101 |
|
// XXX Ancien code : permet de ne pas avoir d'erreru lors de la modification d'une task |
102 |
|
if (array_key_exists('timestamp_log', $val) === true) { |
103 |
|
$this->valF['timestamp_log'] = str_replace("'", '"', $val['timestamp_log']); |
104 |
|
} |
105 |
|
|
106 |
// récupération de l'ID de l'objet existant |
// récupération de l'ID de l'objet existant |
107 |
$id = property_exists($this, 'id') ? $this->id : null; |
$id = property_exists($this, 'id') ? $this->id : null; |
108 |
if(isset($val[$this->clePrimaire])) { |
if(isset($val[$this->clePrimaire])) { |
328 |
} |
} |
329 |
|
|
330 |
// présence d'un moyen d'identifier la collectivité/le service |
// présence d'un moyen d'identifier la collectivité/le service |
331 |
if (! isset($json_payload['dossier']['acteur']) && |
if (! isset($json_payload['external_uids']['acteur']) && |
332 |
! isset($json_payload['dossier']['om_collectivite'])) { |
! isset($json_payload['dossier']['om_collectivite'])) { |
333 |
$this->correct = false; |
$this->correct = false; |
334 |
$this->addToMessage(sprintf( |
$this->addToMessage(sprintf( |
335 |
__("L'une des clés %s ou %s est obligatoire dans le contenu du champ %s pour une tâche entrante."), |
__("L'une des clés %s ou %s est obligatoire dans le contenu du champ %s pour une tâche entrante."), |
336 |
sprintf('<span class="bold">%s</span>', 'dossier/acteur'), |
sprintf('<span class="bold">%s</span>', 'external_uids/acteur'), |
337 |
sprintf('<span class="bold">%s</span>', 'dossier/om_collectivite'), |
sprintf('<span class="bold">%s</span>', 'dossier/om_collectivite'), |
338 |
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
339 |
)); |
)); |
420 |
! empty($json_payload['dossier']['dossier'])) { |
! empty($json_payload['dossier']['dossier'])) { |
421 |
$this->valF["dossier"] = $json_payload['dossier']['dossier']; |
$this->valF["dossier"] = $json_payload['dossier']['dossier']; |
422 |
} |
} |
|
|
|
|
/** |
|
|
* Puisque le dossier n'a potentiellement pas encore été créé |
|
|
* alors il faut ne faut chercher à récupérer le numéro de dossier openADS |
|
|
* à partir de l'external_uids (en passant par la table de liens) |
|
|
// sinon si la tâche possède une clé external_uids/dossier |
|
|
elseif(isset($json_payload['external_uids']['dossier']) && |
|
|
! empty($json_payload['external_uids']['dossier'])) { |
|
|
|
|
|
// instancie l'objet lien_id_interne_uid_externe |
|
|
$inst_lien = $this->f->get_inst__om_dbform(array( |
|
|
"obj" => "lien_id_interne_uid_externe", |
|
|
"idx" => ']', |
|
|
)); |
|
|
if(! $dossier = $inst_lien->get_id_dossier_from_external_uid( |
|
|
$json_payload['external_uids']['dossier'])){ |
|
|
$error_msg = sprintf( |
|
|
__("Aucune correspondance de dossier pour l'external_uid.dossier '%s'."), |
|
|
$json_payload['external_uids']['dossier']); |
|
|
$this->addToLog(__METHOD__."() : erreur : $error_msg", DEBUG_MODE); |
|
|
$this->addToMessage($error_msg); |
|
|
$this->correct = false; |
|
|
return false; |
|
|
} |
|
|
$this->valF["dossier"] = $dossier; |
|
|
}*/ |
|
423 |
} |
} |
424 |
} |
} |
425 |
|
|
432 |
*/ |
*/ |
433 |
public function add_task($params = array()) { |
public function add_task($params = array()) { |
434 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
435 |
|
|
436 |
|
// Vérifie si la task doit être ajoutée en fonction du mode de l'application, |
437 |
|
// seulement pour les tasks output |
438 |
|
$task_types_si = self::TASK_TYPE_SI; |
439 |
|
$task_types_sc = self::TASK_TYPE_SC; |
440 |
|
$stream = isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output'; |
441 |
|
if ($stream === 'output' |
442 |
|
&& isset($params['val']['type']) === true |
443 |
|
&& $this->f->is_option_mode_service_consulte_enabled() === true |
444 |
|
&& in_array($params['val']['type'], $task_types_sc) === false) { |
445 |
|
// |
446 |
|
return $this->end_treatment(__METHOD__, true); |
447 |
|
} |
448 |
|
if ($stream === 'output' |
449 |
|
&& isset($params['val']['type']) === true |
450 |
|
&& $this->f->is_option_mode_service_consulte_enabled() === false |
451 |
|
&& in_array($params['val']['type'], $task_types_si) === false) { |
452 |
|
// |
453 |
|
return $this->end_treatment(__METHOD__, true); |
454 |
|
} |
455 |
|
|
456 |
$timestamp_log = json_encode(array( |
$timestamp_log = json_encode(array( |
457 |
'creation_date' => date('Y-m-d H:i:s'), |
'creation_date' => date('Y-m-d H:i:s'), |
458 |
)); |
)); |
460 |
// 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 |
461 |
// 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 |
462 |
if (isset($params['val']['type']) |
if (isset($params['val']['type']) |
463 |
&& $params['val']['type'] == "add_piece" |
&& ($params['val']['type'] == "add_piece" || $params['val']['type'] == "avis_consultation") |
464 |
&& isset($params['val']['stream']) |
&& isset($params['val']['stream']) |
465 |
&& $params['val']['stream'] == "input" ) { |
&& $params['val']['stream'] == "input" ) { |
466 |
// |
// |
467 |
$json_payload = json_decode($params['val']['json_payload'], true); |
$json_payload = json_decode($params['val']['json_payload'], true); |
468 |
$document_numerise = $json_payload['document_numerise']; |
if (json_last_error() !== JSON_ERROR_NONE) { |
469 |
$file_content = base64_decode($document_numerise["file_content"]); |
$this->addToMessage(__("Le contenu JSON de la tâche n'est pas valide.")); |
|
if ($file_content === false){ |
|
|
$this->addToMessage(__("Le contenu du fichier lié à la tâche n'a pas pu etre recupere.")); |
|
470 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
471 |
} |
} |
472 |
$metadata = array( |
if (isset($json_payload['document_numerise']) === true |
473 |
"filename" => $document_numerise['nom_fichier'], |
&& empty($json_payload['document_numerise']) === false) { |
474 |
"size" => strlen($file_content), |
// |
475 |
"mimetype" => $document_numerise['file_content_type'], |
$document_numerise = $json_payload['document_numerise']; |
476 |
"date_creation" => $document_numerise['date_creation'], |
$file_content = base64_decode($document_numerise["file_content"]); |
477 |
); |
if ($file_content === false){ |
478 |
$uid_fichier = $this->f->storage->create($file_content, $metadata, "from_content"); |
$this->addToMessage(__("Le contenu du fichier lié à la tâche n'a pas pu etre recupere.")); |
479 |
if ($uid_fichier === OP_FAILURE) { |
return $this->end_treatment(__METHOD__, false); |
480 |
$this->addToMessage(__("Erreur lors de la creation du fichier lié à la tâche.")); |
} |
481 |
return $this->end_treatment(__METHOD__, false); |
$metadata = array( |
482 |
|
"filename" => $document_numerise['nom_fichier'], |
483 |
|
"size" => strlen($file_content), |
484 |
|
"mimetype" => $document_numerise['file_content_type'], |
485 |
|
"date_creation" => isset($document_numerise['date_creation']) === true ? $document_numerise['date_creation'] : date("Y-m-d"), |
486 |
|
); |
487 |
|
$uid_fichier = $this->f->storage->create($file_content, $metadata, "from_content"); |
488 |
|
if ($uid_fichier === OP_FAILURE) { |
489 |
|
$this->addToMessage(__("Erreur lors de la creation du fichier lié à la tâche.")); |
490 |
|
return $this->end_treatment(__METHOD__, false); |
491 |
|
} |
492 |
|
$json_payload["document_numerise"]["uid"] = $uid_fichier; |
493 |
|
// Le fichier a été ajouté nous n'avons plus besoin du champ file_content dans la payload |
494 |
|
unset($json_payload["document_numerise"]["file_content"]); |
495 |
|
$params['val']['json_payload'] = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
496 |
} |
} |
|
$json_payload["document_numerise"]["uid"] = $uid_fichier; |
|
|
// Le fichier a été ajouté nous n'avons plus besoin du champ file_content dans la payload |
|
|
unset($json_payload["document_numerise"]["file_content"]); |
|
|
$params['val']['json_payload'] = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
|
497 |
} |
} |
498 |
|
|
499 |
// Mise à jour du DI |
// Mise à jour du DI |
504 |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : self::STATUS_NEW, |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : self::STATUS_NEW, |
505 |
'object_id' => isset($params['val']['object_id']) ? $params['val']['object_id'] : '', |
'object_id' => isset($params['val']['object_id']) ? $params['val']['object_id'] : '', |
506 |
'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '', |
'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '', |
507 |
'stream' => isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output', |
'stream' => $stream, |
508 |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
509 |
); |
); |
510 |
|
|
642 |
$list_tasks = array(); |
$list_tasks = array(); |
643 |
foreach ($res['result'] as $task) { |
foreach ($res['result'] as $task) { |
644 |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
645 |
$task['dossier'] = $task['object_id']; |
$task['dossier'] = $task['dossier']; |
646 |
if ($this->get_lien_objet_by_type($task['type']) === 'document_numerise') { |
if ($task['type'] === 'ajout_piece') { |
647 |
$val_dn = $this->get_document_numerise_data($task['object_id']); |
$val_dn = $this->get_document_numerise_data($task['object_id']); |
648 |
$task['dossier'] = $val_dn['dossier']; |
} |
649 |
|
if ($task['stream'] === 'output') { |
650 |
|
$task['external_uids'] = $this->get_all_external_uids($task['dossier']); |
651 |
} |
} |
652 |
$list_tasks[$task['task']] = $task; |
$list_tasks[$task['task']] = $task; |
653 |
} |
} |
790 |
return $val_dt; |
return $val_dt; |
791 |
} |
} |
792 |
|
|
793 |
|
/** |
794 |
|
* Récupère la liste des objets distincts existants dans la table des liens |
795 |
|
* entre identifiants internes et identifiants externes. |
796 |
|
* |
797 |
|
* @return array |
798 |
|
*/ |
799 |
|
protected function get_list_distinct_objects_external_link() { |
800 |
|
$query = sprintf(' |
801 |
|
SELECT |
802 |
|
DISTINCT(object) |
803 |
|
FROM %1$slien_id_interne_uid_externe |
804 |
|
ORDER BY object ASC |
805 |
|
', |
806 |
|
DB_PREFIXE |
807 |
|
); |
808 |
|
$res = $this->f->get_all_results_from_db_query($query, true); |
809 |
|
if ($res['code'] === 'KO') { |
810 |
|
return array(); |
811 |
|
} |
812 |
|
$result = array(); |
813 |
|
foreach ($res['result'] as $object) { |
814 |
|
$result[] = $object['object']; |
815 |
|
} |
816 |
|
return $result; |
817 |
|
} |
818 |
|
|
819 |
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
820 |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
821 |
"obj" => "lien_id_interne_uid_externe", |
"obj" => "lien_id_interne_uid_externe", |
827 |
return $inst_external_uid->getVal('external_uid'); |
return $inst_external_uid->getVal('external_uid'); |
828 |
} |
} |
829 |
|
|
830 |
|
protected function get_all_external_uids($fk_idx, $link_objects = array()) { |
831 |
|
if (count($link_objects) == 0) { |
832 |
|
$link_objects = $this->get_list_distinct_objects_external_link(); |
833 |
|
} |
834 |
|
$val_external_uid = array(); |
835 |
|
foreach ($link_objects as $link_object) { |
836 |
|
$external_uid = $this->get_external_uid($fk_idx, $link_object); |
837 |
|
if ($external_uid !== '' && $external_uid !== null) { |
838 |
|
$val_external_uid[$link_object] = $external_uid; |
839 |
|
} |
840 |
|
} |
841 |
|
return $val_external_uid; |
842 |
|
} |
843 |
|
|
844 |
protected function get_demandeurs_data(string $dossier) { |
protected function get_demandeurs_data(string $dossier) { |
845 |
$val_demandeur = array(); |
$val_demandeur = array(); |
846 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
997 |
return $val_dp; |
return $val_dp; |
998 |
} |
} |
999 |
|
|
1000 |
|
protected function get_avis_decision_data(string $dossier) { |
1001 |
|
$inst_di = $this->f->get_inst__om_dbform(array( |
1002 |
|
"obj" => "dossier", |
1003 |
|
"idx" => $dossier, |
1004 |
|
)); |
1005 |
|
$ad = $inst_di->getVal('avis_decision'); |
1006 |
|
$val_ad = array(); |
1007 |
|
$inst_ad = $this->f->get_inst__om_dbform(array( |
1008 |
|
"obj" => "avis_decision", |
1009 |
|
"idx" => $ad, |
1010 |
|
)); |
1011 |
|
$val_ad = $inst_ad->get_json_data(); |
1012 |
|
$val_ad['txAvis'] = "Voir document joint"; |
1013 |
|
if (isset($val_ad['tacite']) === true |
1014 |
|
&& $val_ad['tacite'] === 't') { |
1015 |
|
// |
1016 |
|
$val_ad['txAvis'] = "Sans objet"; |
1017 |
|
} |
1018 |
|
return $val_ad; |
1019 |
|
} |
1020 |
|
|
1021 |
|
protected function get_signataire_arrete_data(string $sa) { |
1022 |
|
$inst_sa = $this->f->get_inst__om_dbform(array( |
1023 |
|
"obj" => "signataire_arrete", |
1024 |
|
"idx" => $sa, |
1025 |
|
)); |
1026 |
|
$val_sa = array_combine($inst_sa->champs, $inst_sa->val); |
1027 |
|
foreach ($val_sa as $key => $value) { |
1028 |
|
$val_sa[$key] = strip_tags($value); |
1029 |
|
} |
1030 |
|
return $val_sa; |
1031 |
|
} |
1032 |
|
|
1033 |
|
// XXX WIP |
1034 |
|
protected function get_consultation_data(string $consultation) { |
1035 |
|
$val_consultation = array(); |
1036 |
|
$inst_consultation = $this->f->get_inst__om_dbform(array( |
1037 |
|
"obj" => "consultation", |
1038 |
|
"idx" => $consultation, |
1039 |
|
)); |
1040 |
|
$val_consultation = $inst_consultation->get_json_data(); |
1041 |
|
$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')); |
1042 |
|
$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')); |
1043 |
|
return $val_consultation; |
1044 |
|
} |
1045 |
|
|
1046 |
|
// XXX WIP |
1047 |
|
protected function get_service_data(string $service) { |
1048 |
|
$val_service = array(); |
1049 |
|
$inst_service = $this->f->get_inst__om_dbform(array( |
1050 |
|
"obj" => "service", |
1051 |
|
"idx" => $service, |
1052 |
|
)); |
1053 |
|
$val_service = $inst_service->get_json_data(); |
1054 |
|
return $val_service; |
1055 |
|
} |
1056 |
|
|
1057 |
protected function view_form_json($in_field = false) { |
protected function view_form_json($in_field = false) { |
1058 |
// |
// |
1059 |
if ($this->f->get_submitted_post_value('valid') === null) { |
if ($this->f->get_submitted_post_value('valid') === null) { |
1111 |
} |
} |
1112 |
// |
// |
1113 |
if ($this->getVal('type') === 'decision_DI') { |
if ($this->getVal('type') === 'decision_DI') { |
1114 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1115 |
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier']); |
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
1116 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1117 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1118 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1120 |
} |
} |
1121 |
// |
// |
1122 |
if ($this->getVal('type') === 'incompletude_DI') { |
if ($this->getVal('type') === 'incompletude_DI') { |
1123 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1124 |
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'incompletude'); |
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
1125 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1126 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1127 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1129 |
} |
} |
1130 |
// |
// |
1131 |
if ($this->getVal('type') === 'completude_DI') { |
if ($this->getVal('type') === 'completude_DI') { |
1132 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1133 |
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'completude'); |
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
1134 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1135 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1136 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1143 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1144 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1145 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1146 |
$val_external_uid['consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'consultation'); |
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
1147 |
|
$val['external_uids'] = $val_external_uid; |
1148 |
|
} |
1149 |
|
// |
1150 |
|
if ($this->getVal('type') === 'avis_consultation') { |
1151 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1152 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1153 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
1154 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
1155 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
1156 |
|
} |
1157 |
|
$val_external_uid = array(); |
1158 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1159 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1160 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
1161 |
|
$val['external_uids'] = $val_external_uid; |
1162 |
|
} |
1163 |
|
// XXX WIP |
1164 |
|
if ($this->getVal('type') === 'creation_consultation') { |
1165 |
|
// |
1166 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1167 |
|
$val['consultation'] = $this->get_consultation_data($this->getVal('object_id')); |
1168 |
|
$val['service'] = $this->get_service_data($val['consultation']['service']); |
1169 |
|
$val_external_uid = array(); |
1170 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1171 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1172 |
$val['external_uids'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1173 |
} |
} |
1174 |
|
|
1183 |
|
|
1184 |
function post_update_task() { |
function post_update_task() { |
1185 |
// Mise à jour des valeurs |
// Mise à jour des valeurs |
1186 |
// |
|
1187 |
$params = array( |
// Modification de l'état de la tâche |
1188 |
'val' => array( |
if ($this->f->get_submitted_post_value('state') !== null) { |
1189 |
'state' => $this->f->get_submitted_post_value('state') |
$params = array( |
1190 |
), |
'val' => array( |
1191 |
); |
'state' => $this->f->get_submitted_post_value('state') |
1192 |
$update = $this->update_task($params); |
), |
|
$message_class = "valid"; |
|
|
$message = $this->msg; |
|
|
if ($update === false) { |
|
|
$this->addToLog($this->msg, DEBUG_MODE); |
|
|
$message_class = "error"; |
|
|
$message = sprintf( |
|
|
'%s %s', |
|
|
__('Impossible de mettre à jour la tâche.'), |
|
|
__('Veuillez contacter votre administrateur.') |
|
1193 |
); |
); |
1194 |
|
$update = $this->update_task($params); |
1195 |
|
$message_class = "valid"; |
1196 |
|
$message = $this->msg; |
1197 |
|
if ($update === false) { |
1198 |
|
$this->addToLog($this->msg, DEBUG_MODE); |
1199 |
|
$message_class = "error"; |
1200 |
|
$message = sprintf( |
1201 |
|
'%s %s', |
1202 |
|
__('Impossible de mettre à jour la tâche.'), |
1203 |
|
__('Veuillez contacter votre administrateur.') |
1204 |
|
); |
1205 |
|
} |
1206 |
|
$this->f->displayMessage($message_class, $message); |
1207 |
} |
} |
1208 |
$this->f->displayMessage($message_class, $message); |
|
1209 |
// |
// Sauvegarde de l'uid externe retourné |
1210 |
$inst_lien = $this->f->get_inst__om_dbform(array( |
if ($this->f->get_submitted_post_value('external_uid') !== null) { |
1211 |
"obj" => "lien_id_interne_uid_externe", |
// |
1212 |
"idx" => ']', |
$objects = $this->get_objects_by_task_type($this->getVal('type'), $this->getVal('stream')); |
1213 |
)); |
foreach ($objects as $object) { |
1214 |
$valF = array( |
$inst_lien = $this->f->get_inst__om_dbform(array( |
1215 |
'lien_id_interne_uid_externe' => '', |
"obj" => "lien_id_interne_uid_externe", |
1216 |
'object' => $this->get_lien_objet_by_type($this->getVal('type')), |
"idx" => ']', |
1217 |
'object_id' => $this->getVal('object_id'), |
)); |
1218 |
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
if ($inst_lien->is_exists($object, $this->getVal('object_id'), $this->f->get_submitted_post_value('external_uid'), $this->getVal('dossier')) === false) { |
1219 |
); |
$valF = array( |
1220 |
$add = $inst_lien->ajouter($valF); |
'lien_id_interne_uid_externe' => '', |
1221 |
$message_class = "valid"; |
'object' => $object, |
1222 |
$message = $inst_lien->msg; |
'object_id' => $this->getVal('object_id'), |
1223 |
if ($add === false) { |
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
1224 |
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
'dossier' => $this->getVal('dossier'), |
1225 |
$message_class = "error"; |
); |
1226 |
$message = sprintf( |
$add = $inst_lien->ajouter($valF); |
1227 |
'%s %s', |
$message_class = "valid"; |
1228 |
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
$message = $inst_lien->msg; |
1229 |
__('Veuillez contacter votre administrateur.') |
if ($add === false) { |
1230 |
); |
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
1231 |
|
$message_class = "error"; |
1232 |
|
$message = sprintf( |
1233 |
|
'%s %s', |
1234 |
|
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
1235 |
|
__('Veuillez contacter votre administrateur.') |
1236 |
|
); |
1237 |
|
} |
1238 |
|
$this->f->displayMessage($message_class, $message); |
1239 |
|
} |
1240 |
|
} |
1241 |
} |
} |
|
$this->f->displayMessage($message_class, $message); |
|
1242 |
} |
} |
1243 |
|
|
1244 |
function post_add_task() { |
function post_add_task() { |
1250 |
'type' => $this->f->get_submitted_post_value('type'), |
'type' => $this->f->get_submitted_post_value('type'), |
1251 |
) |
) |
1252 |
)); |
)); |
1253 |
$message = $this->msg; |
$message = sprintf( |
1254 |
|
__("Tâche %s ajoutée avec succès"), |
1255 |
|
$this->getVal($this->clePrimaire)). |
1256 |
|
'<br/><br/>'. |
1257 |
|
$this->msg; |
1258 |
$message_class = "valid"; |
$message_class = "valid"; |
1259 |
if ($result === false){ |
if ($result === false){ |
1260 |
$this->addToLog($this->msg, DEBUG_MODE); |
$this->addToLog($this->msg, DEBUG_MODE); |
1268 |
$this->f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
1269 |
} |
} |
1270 |
|
|
|
function get_lien_objet_by_type($type) { |
|
|
// |
|
|
$objet = ''; |
|
|
if ($type === 'creation_DA') { |
|
|
$objet = 'dossier_autorisation'; |
|
|
} |
|
|
if ($type === 'creation_DI' |
|
|
|| $type === 'create_DI_for_consultation' |
|
|
|| $type === 'depot_DI' |
|
|
|| $type === 'modification_DI' |
|
|
|| $type === 'qualification_DI' |
|
|
|| $type === 'decision_DI' |
|
|
|| $type === 'incompletude_DI' |
|
|
|| $type === 'completude_DI' |
|
|
|| $type === 'pec_metier_consultation') { |
|
|
// |
|
|
$objet = 'dossier'; |
|
|
} |
|
|
if ($type === 'ajout_piece') { |
|
|
$objet = 'document_numerise'; |
|
|
} |
|
|
// La tâche entrante se nomme add_piece |
|
|
if ($type === 'add_piece') { |
|
|
$objet = 'piece'; |
|
|
} |
|
|
return $objet; |
|
|
} |
|
|
|
|
1271 |
function setLayout(&$form, $maj) { |
function setLayout(&$form, $maj) { |
1272 |
|
|
1273 |
// Récupération du mode de l'action |
// Récupération du mode de l'action |
1282 |
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
1283 |
} |
} |
1284 |
|
|
1285 |
|
/** |
1286 |
|
* [get_objects_by_task_type description] |
1287 |
|
* @param [type] $type [description] |
1288 |
|
* @return [type] [description] |
1289 |
|
*/ |
1290 |
|
function get_objects_by_task_type($type, $stream = 'all') { |
1291 |
|
$objects = array(); |
1292 |
|
if (in_array($type, array('creation_DA', )) === true) { |
1293 |
|
$objects = array('dossier_autorisation', ); |
1294 |
|
} |
1295 |
|
if (in_array($type, array('creation_DI', 'depot_DI', 'notification_DI', 'qualification_DI', )) === true) { |
1296 |
|
$objects = array('dossier', ); |
1297 |
|
} |
1298 |
|
if (in_array($type, array('create_DI_for_consultation', )) === true) { |
1299 |
|
$objects = array('dossier', 'dossier_consultation', ); |
1300 |
|
} |
1301 |
|
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
1302 |
|
$objects = array('instruction', ); |
1303 |
|
} |
1304 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
1305 |
|
&& $stream === 'output') { |
1306 |
|
$objects = array('pec_dossier_consultation', ); |
1307 |
|
} |
1308 |
|
if (in_array($type, array('avis_consultation', )) === true |
1309 |
|
&& $stream === 'output') { |
1310 |
|
$objects = array('avis_dossier_consultation', ); |
1311 |
|
} |
1312 |
|
if (in_array($type, array('ajout_piece', 'add_piece', )) === true) { |
1313 |
|
$objects = array('piece', ); |
1314 |
|
} |
1315 |
|
if (in_array($type, array('creation_consultation', )) === true) { |
1316 |
|
$objects = array('consultation', ); |
1317 |
|
} |
1318 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
1319 |
|
&& $stream === 'input') { |
1320 |
|
$objects = array('pec_metier_consultation', ); |
1321 |
|
} |
1322 |
|
if (in_array($type, array('avis_consultation', )) === true |
1323 |
|
&& $stream === 'input') { |
1324 |
|
$objects = array('avis_consultation', ); |
1325 |
|
} |
1326 |
|
return $objects; |
1327 |
|
} |
1328 |
|
|
1329 |
} |
} |