41 |
|
|
42 |
public function setvalF($val = array()) { |
public function setvalF($val = array()) { |
43 |
|
|
44 |
// les guillets doubles sont remplacés automatiquement par des simples |
// // les guillets doubles sont remplacés automatiquement par des simples |
45 |
// dans core/om_formulaire.clasS.php::recupererPostvar() |
// // dans core/om_formulaire.clasS.php::recupererPostvar() |
46 |
// voir le ticket https://dev.atreal.fr/projets/openmairie/tracker/209 |
// // voir le ticket https://dev.atreal.fr/projets/openmairie/tracker/209 |
47 |
// ceci est un hack sale temporaire en attendant résolution du ticket |
// // ceci est un hack sale temporaire en attendant résolution du ticket |
48 |
foreach(array('json_payload', 'timestamp_log') as $key) { |
// foreach(array('json_payload', 'timestamp_log') as $key) { |
49 |
if (isset($val[$key]) && ! empty($val[$key]) && |
// if (isset($val[$key]) && ! empty($val[$key]) && |
50 |
isset($_POST[$key]) && ! empty($_POST[$key])) { |
// isset($_POST[$key]) && ! empty($_POST[$key])) { |
51 |
$submited_payload = $_POST[$key]; |
// $submited_payload = $_POST[$key]; |
52 |
if (! empty($submited_payload)) { |
// if (! empty($submited_payload)) { |
53 |
$new_payload = str_replace("'", '"', $val[$key]); |
// $new_payload = str_replace("'", '"', $val[$key]); |
54 |
if ($new_payload == $submited_payload || |
// if ($new_payload == $submited_payload || |
55 |
strpos($submited_payload, '"') === false) { |
// strpos($submited_payload, '"') === false) { |
56 |
$val[$key] = $new_payload; |
// $val[$key] = $new_payload; |
57 |
} |
// } |
58 |
else { |
// else { |
59 |
$error_msg = sprintf( |
// $error_msg = sprintf( |
60 |
__("La convertion des guillemets de la payload JSON '%s' ". |
// __("La convertion des guillemets de la payload JSON '%s' ". |
61 |
"n'est pas idempotente (courante: %s, postée: %s, convertie: %s)"), |
// "n'est pas idempotente (courante: %s, postée: %s, convertie: %s)"), |
62 |
$key, var_export($val[$key], true), var_export($submited_payload, true), |
// $key, var_export($val[$key], true), var_export($submited_payload, true), |
63 |
var_export($new_payload, true)); |
// var_export($new_payload, true)); |
64 |
$this->correct = false; |
// $this->correct = false; |
65 |
$this->addToMessage($error_msg); |
// $this->addToMessage($error_msg); |
66 |
$this->addToLog(__METHOD__."() erreur : $error_msg", DEBUG_MODE); |
// $this->addToLog(__METHOD__."() erreur : $error_msg", DEBUG_MODE); |
67 |
return false; |
// return false; |
68 |
} |
// } |
69 |
} |
// } |
70 |
} |
// } |
71 |
} |
// } |
72 |
|
|
73 |
parent::setvalF($val); |
parent::setvalF($val); |
74 |
|
|
75 |
|
// XXX Ancien code : permet de ne pas avoir d'erreru lors de la modification d'une task |
76 |
|
if (array_key_exists('timestamp_log', $val) === true) { |
77 |
|
$this->valF['timestamp_log'] = str_replace("'", '"', $val['timestamp_log']); |
78 |
|
} |
79 |
|
|
80 |
// récupération de l'ID de l'objet existant |
// récupération de l'ID de l'objet existant |
81 |
$id = property_exists($this, 'id') ? $this->id : null; |
$id = property_exists($this, 'id') ? $this->id : null; |
82 |
if(isset($val[$this->clePrimaire])) { |
if(isset($val[$this->clePrimaire])) { |
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 = array( |
439 |
|
'creation_DA', |
440 |
|
'creation_DI', |
441 |
|
'depot_DI', |
442 |
|
'modification_DI', |
443 |
|
'qualification_DI', |
444 |
|
'decision_DI', |
445 |
|
'incompletude_DI', |
446 |
|
'completude_DI', |
447 |
|
'ajout_piece', |
448 |
|
'add_piece', |
449 |
|
); |
450 |
|
$task_types_sc = array( |
451 |
|
'create_DI_for_consultation', |
452 |
|
'avis_consultation', |
453 |
|
'pec_metier_consultation', |
454 |
|
); |
455 |
|
$stream = isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output'; |
456 |
|
if ($stream === 'output' |
457 |
|
&& isset($params['val']['type']) === true |
458 |
|
&& $this->f->is_option_mode_service_consulte_enabled() === true |
459 |
|
&& in_array($params['val']['type'], $task_types_sc) === false) { |
460 |
|
// |
461 |
|
return $this->end_treatment(__METHOD__, true); |
462 |
|
} |
463 |
|
if ($stream === 'output' |
464 |
|
&& isset($params['val']['type']) === true |
465 |
|
&& $this->f->is_option_mode_service_consulte_enabled() === false |
466 |
|
&& in_array($params['val']['type'], $task_types_si) === false) { |
467 |
|
// |
468 |
|
return $this->end_treatment(__METHOD__, true); |
469 |
|
} |
470 |
|
|
471 |
$timestamp_log = json_encode(array( |
$timestamp_log = json_encode(array( |
472 |
'creation_date' => date('Y-m-d H:i:s'), |
'creation_date' => date('Y-m-d H:i:s'), |
473 |
)); |
)); |
511 |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : self::STATUS_NEW, |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : self::STATUS_NEW, |
512 |
'object_id' => isset($params['val']['object_id']) ? $params['val']['object_id'] : '', |
'object_id' => isset($params['val']['object_id']) ? $params['val']['object_id'] : '', |
513 |
'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '', |
'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '', |
514 |
'stream' => isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output', |
'stream' => $stream, |
515 |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
516 |
); |
); |
517 |
|
|
649 |
$list_tasks = array(); |
$list_tasks = array(); |
650 |
foreach ($res['result'] as $task) { |
foreach ($res['result'] as $task) { |
651 |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
652 |
$task['dossier'] = $task['object_id']; |
$task['dossier'] = $task['dossier']; |
653 |
|
$task['external_uid'] = $this->get_external_uid($task['dossier'], 'dossier'); |
654 |
if ($this->get_lien_objet_by_type($task['type']) === 'document_numerise') { |
if ($this->get_lien_objet_by_type($task['type']) === 'document_numerise') { |
655 |
$val_dn = $this->get_document_numerise_data($task['object_id']); |
$val_dn = $this->get_document_numerise_data($task['object_id']); |
656 |
$task['dossier'] = $val_dn['dossier']; |
$task['dossier'] = $val_dn['dossier']; |
839 |
return $val_architecte; |
return $val_architecte; |
840 |
} |
} |
841 |
|
|
842 |
protected function get_instruction_data(string $dossier, $type = 'decision') { |
protected function get_instruction_data(string $dossier, $type = 'decision', $extra_params = array()) { |
843 |
$val_instruction = null; |
$val_instruction = null; |
844 |
$instruction_with_doc = null; |
$instruction_with_doc = null; |
845 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
853 |
if ($type === 'incompletude') { |
if ($type === 'incompletude') { |
854 |
$idx = $inst_di->get_last_instruction_incompletude(); |
$idx = $inst_di->get_last_instruction_incompletude(); |
855 |
} |
} |
856 |
|
// XXX Permet de récupérer l'instruction par son identifiant |
857 |
|
if ($type === 'with-id') { |
858 |
|
$idx = $extra_params['with-id']; |
859 |
|
} |
860 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
861 |
"obj" => "instruction", |
"obj" => "instruction", |
862 |
"idx" => $idx, |
"idx" => $idx, |
902 |
|
|
903 |
protected function sort_instruction_data(array $values, array $res) { |
protected function sort_instruction_data(array $values, array $res) { |
904 |
$fields = array( |
$fields = array( |
905 |
|
"date_evenement", |
906 |
"date_envoi_signature", |
"date_envoi_signature", |
907 |
"date_retour_signature", |
"date_retour_signature", |
908 |
"date_envoi_rar", |
"date_envoi_rar", |
963 |
return $val_dp; |
return $val_dp; |
964 |
} |
} |
965 |
|
|
966 |
|
protected function get_avis_decision_data(string $dossier) { |
967 |
|
$inst_di = $this->f->get_inst__om_dbform(array( |
968 |
|
"obj" => "dossier", |
969 |
|
"idx" => $dossier, |
970 |
|
)); |
971 |
|
$ad = $inst_di->getVal('avis_decision'); |
972 |
|
$val_ad = array(); |
973 |
|
$inst_ad = $this->f->get_inst__om_dbform(array( |
974 |
|
"obj" => "avis_decision", |
975 |
|
"idx" => $ad, |
976 |
|
)); |
977 |
|
$val_ad = $inst_ad->get_json_data(); |
978 |
|
$val_ad['txAvis'] = "Voir document joint"; |
979 |
|
if (isset($val_ad['tacite']) === true |
980 |
|
&& $val_ad['tacite'] === 't') { |
981 |
|
// |
982 |
|
$val_ad['txAvis'] = "Sans objet"; |
983 |
|
} |
984 |
|
return $val_ad; |
985 |
|
} |
986 |
|
|
987 |
|
protected function get_signataire_arrete_data(string $sa) { |
988 |
|
$inst_sa = $this->f->get_inst__om_dbform(array( |
989 |
|
"obj" => "signataire_arrete", |
990 |
|
"idx" => $sa, |
991 |
|
)); |
992 |
|
$val_sa = array_combine($inst_sa->champs, $inst_sa->val); |
993 |
|
foreach ($val_sa as $key => $value) { |
994 |
|
$val_sa[$key] = strip_tags($value); |
995 |
|
} |
996 |
|
return $val_sa; |
997 |
|
} |
998 |
|
|
999 |
protected function view_form_json($in_field = false) { |
protected function view_form_json($in_field = false) { |
1000 |
// |
// |
1001 |
if ($this->f->get_submitted_post_value('valid') === null) { |
if ($this->f->get_submitted_post_value('valid') === null) { |
1053 |
} |
} |
1054 |
// |
// |
1055 |
if ($this->getVal('type') === 'decision_DI') { |
if ($this->getVal('type') === 'decision_DI') { |
1056 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1057 |
$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'))); |
1058 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1059 |
$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'); |
1060 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1062 |
} |
} |
1063 |
// |
// |
1064 |
if ($this->getVal('type') === 'incompletude_DI') { |
if ($this->getVal('type') === 'incompletude_DI') { |
1065 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1066 |
$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'))); |
1067 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1068 |
$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'); |
1069 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1071 |
} |
} |
1072 |
// |
// |
1073 |
if ($this->getVal('type') === 'completude_DI') { |
if ($this->getVal('type') === 'completude_DI') { |
1074 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1075 |
$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'))); |
1076 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1077 |
$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'); |
1078 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1079 |
$val['external_uids'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1080 |
} |
} |
1081 |
|
// |
1082 |
|
if ($this->getVal('type') === 'pec_metier_consultation') { |
1083 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1084 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1085 |
|
$val_external_uid = array(); |
1086 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1087 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1088 |
|
$val_external_uid['consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'consultation'); |
1089 |
|
$val['external_uids'] = $val_external_uid; |
1090 |
|
} |
1091 |
|
// |
1092 |
|
if ($this->getVal('type') === 'avis_consultation') { |
1093 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1094 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1095 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
1096 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
1097 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
1098 |
|
} |
1099 |
|
$val_external_uid = array(); |
1100 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1101 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1102 |
|
$val_external_uid['consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'consultation'); |
1103 |
|
$val['external_uids'] = $val_external_uid; |
1104 |
|
} |
1105 |
|
|
1106 |
if ($in_field === true) { |
if ($in_field === true) { |
1107 |
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
1134 |
} |
} |
1135 |
$this->f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
1136 |
// |
// |
1137 |
$inst_lien = $this->f->get_inst__om_dbform(array( |
if ($this->f->get_submitted_post_value('external_uid') !== null |
1138 |
"obj" => "lien_id_interne_uid_externe", |
&& $this->f->get_submitted_post_value('external_uid') != "") { |
1139 |
"idx" => ']', |
$inst_lien = $this->f->get_inst__om_dbform(array( |
1140 |
)); |
"obj" => "lien_id_interne_uid_externe", |
1141 |
$valF = array( |
"idx" => ']', |
1142 |
'lien_id_interne_uid_externe' => '', |
)); |
1143 |
'object' => $this->get_lien_objet_by_type($this->getVal('type')), |
$valF = array( |
1144 |
'object_id' => $this->getVal('object_id'), |
'lien_id_interne_uid_externe' => '', |
1145 |
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
'object' => $this->get_lien_objet_by_type($this->getVal('type')), |
1146 |
); |
'object_id' => $this->getVal('object_id'), |
1147 |
$add = $inst_lien->ajouter($valF); |
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
|
$message_class = "valid"; |
|
|
$message = $inst_lien->msg; |
|
|
if ($add === false) { |
|
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
|
|
$message_class = "error"; |
|
|
$message = sprintf( |
|
|
'%s %s', |
|
|
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
|
|
__('Veuillez contacter votre administrateur.') |
|
1148 |
); |
); |
1149 |
|
$add = $inst_lien->ajouter($valF); |
1150 |
|
$message_class = "valid"; |
1151 |
|
$message = $inst_lien->msg; |
1152 |
|
if ($add === false) { |
1153 |
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
1154 |
|
$message_class = "error"; |
1155 |
|
$message = sprintf( |
1156 |
|
'%s %s', |
1157 |
|
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
1158 |
|
__('Veuillez contacter votre administrateur.') |
1159 |
|
); |
1160 |
|
} |
1161 |
|
$this->f->displayMessage($message_class, $message); |
1162 |
} |
} |
|
$this->f->displayMessage($message_class, $message); |
|
1163 |
} |
} |
1164 |
|
|
1165 |
function post_add_task() { |
function post_add_task() { |
1195 |
|| $type === 'create_DI_for_consultation' |
|| $type === 'create_DI_for_consultation' |
1196 |
|| $type === 'depot_DI' |
|| $type === 'depot_DI' |
1197 |
|| $type === 'modification_DI' |
|| $type === 'modification_DI' |
1198 |
|| $type === 'qualification_DI' |
|| $type === 'qualification_DI') { |
1199 |
|
// |
1200 |
|
$objet = 'dossier'; |
1201 |
|
} |
1202 |
|
if ($type === 'pec_metier_consultation' |
1203 |
|| $type === 'decision_DI' |
|| $type === 'decision_DI' |
1204 |
|
|| $type === 'avis_consultation' |
1205 |
|| $type === 'incompletude_DI' |
|| $type === 'incompletude_DI' |
1206 |
|| $type === 'completude_DI') { |
|| $type === 'completude_DI') { |
1207 |
// |
// |
1208 |
$objet = 'dossier'; |
$objet = 'instruction'; |
1209 |
} |
} |
1210 |
if ($type === 'ajout_piece') { |
if ($type === 'ajout_piece') { |
1211 |
$objet = 'document_numerise'; |
$objet = 'document_numerise'; |
1212 |
} |
} |
1213 |
// La tâche entrante se nomme add_piece |
// La tâche entrante se nomme add_piece |
1214 |
if ($type === 'add_piece') { |
if ($type === 'add_piece') { |
1215 |
$objet = 'piece'; |
$objet = 'piece'; |
1216 |
} |
} |