6 |
|
|
7 |
class task extends task_gen { |
class task extends task_gen { |
8 |
|
|
9 |
|
const STATUS_DRAFT = 'draft'; |
10 |
|
const STATUS_NEW = 'new'; |
11 |
|
const STATUS_PENDING = 'pending'; |
12 |
|
const STATUS_DONE = 'done'; |
13 |
|
const STATUS_ERROR = 'error'; |
14 |
|
const STATUS_DEBUG = 'debug'; |
15 |
|
const STATUS_ARCHIVED = 'archived'; |
16 |
|
|
17 |
/** |
/** |
18 |
* Définition des actions disponibles sur la classe. |
* Définition des actions disponibles sur la classe. |
19 |
* |
* |
40 |
} |
} |
41 |
|
|
42 |
public function setvalF($val = array()) { |
public function setvalF($val = array()) { |
43 |
|
|
44 |
|
// // les guillets doubles sont remplacés automatiquement par des simples |
45 |
|
// // dans core/om_formulaire.clasS.php::recupererPostvar() |
46 |
|
// // voir le ticket https://dev.atreal.fr/projets/openmairie/tracker/209 |
47 |
|
// // ceci est un hack sale temporaire en attendant résolution du ticket |
48 |
|
// foreach(array('json_payload', 'timestamp_log') as $key) { |
49 |
|
// if (isset($val[$key]) && ! empty($val[$key]) && |
50 |
|
// isset($_POST[$key]) && ! empty($_POST[$key])) { |
51 |
|
// $submited_payload = $_POST[$key]; |
52 |
|
// if (! empty($submited_payload)) { |
53 |
|
// $new_payload = str_replace("'", '"', $val[$key]); |
54 |
|
// if ($new_payload == $submited_payload || |
55 |
|
// strpos($submited_payload, '"') === false) { |
56 |
|
// $val[$key] = $new_payload; |
57 |
|
// } |
58 |
|
// else { |
59 |
|
// $error_msg = sprintf( |
60 |
|
// __("La convertion des guillemets de la payload JSON '%s' ". |
61 |
|
// "n'est pas idempotente (courante: %s, postée: %s, convertie: %s)"), |
62 |
|
// $key, var_export($val[$key], true), var_export($submited_payload, true), |
63 |
|
// var_export($new_payload, true)); |
64 |
|
// $this->correct = false; |
65 |
|
// $this->addToMessage($error_msg); |
66 |
|
// $this->addToLog(__METHOD__."() erreur : $error_msg", DEBUG_MODE); |
67 |
|
// 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) { |
if (array_key_exists('timestamp_log', $val) === true) { |
77 |
$this->valF['timestamp_log'] = str_replace("'", '"', $val['timestamp_log']); |
$this->valF['timestamp_log'] = str_replace("'", '"', $val['timestamp_log']); |
78 |
} |
} |
79 |
|
|
80 |
|
// récupération de l'ID de l'objet existant |
81 |
|
$id = property_exists($this, 'id') ? $this->id : null; |
82 |
|
if(isset($val[$this->clePrimaire])) { |
83 |
|
$id = $val[$this->clePrimaire]; |
84 |
|
} elseif(isset($this->valF[$this->clePrimaire])) { |
85 |
|
$id = $this->valF[$this->clePrimaire]; |
86 |
|
} |
87 |
|
|
88 |
|
// MODE MODIFIER |
89 |
|
if (! empty($id)) { |
90 |
|
|
91 |
|
// si aucune payload n'est fourni (devrait toujours être le cas) |
92 |
|
if (! isset($val['json_payload']) || empty($val['json_payload'])) { |
93 |
|
|
94 |
|
// récupère l'objet existant |
95 |
|
$existing = $this->f->findObjectById(get_class($this), $id); |
96 |
|
if (! empty($existing)) { |
97 |
|
|
98 |
|
// récupère la payload de l'objet |
99 |
|
$val['json_payload'] = $existing->getVal('json_payload'); |
100 |
|
$this->valF['json_payload'] = $existing->getVal('json_payload'); |
101 |
|
$this->f->addToLog(__METHOD__."() récupère la payload de la tâche existante ". |
102 |
|
"'$id': ".$existing->getVal('json_payload'), EXTRA_VERBOSE_MODE); |
103 |
|
} |
104 |
|
} |
105 |
|
} |
106 |
} |
} |
107 |
|
|
108 |
/** |
/** |
124 |
|
|
125 |
function setType(&$form, $maj) { |
function setType(&$form, $maj) { |
126 |
parent::setType($form, $maj); |
parent::setType($form, $maj); |
127 |
|
|
128 |
// Récupération du mode de l'action |
// Récupération du mode de l'action |
129 |
$crud = $this->get_action_crud($maj); |
$crud = $this->get_action_crud($maj); |
130 |
|
|
131 |
if ($maj < 2) { |
// MODE CREER |
132 |
|
if ($maj == 0 || $crud == 'create') { |
133 |
|
$form->setType("state", "select"); |
134 |
|
$form->setType("stream", "select"); |
135 |
|
$form->setType("json_payload", "textarea"); |
136 |
|
} |
137 |
|
// MDOE MODIFIER |
138 |
|
if ($maj == 1 || $crud == 'update') { |
139 |
$form->setType("state", "select"); |
$form->setType("state", "select"); |
140 |
$form->setType("stream", "select"); |
$form->setType("stream", "select"); |
141 |
$form->setType("json_payload", "jsonprettyprint"); |
$form->setType("json_payload", "jsonprettyprint"); |
142 |
} |
} |
143 |
if ($maj == 3){ |
// MODE CONSULTER |
144 |
|
if ($maj == 3 || $crud == 'read') { |
145 |
$form->setType('dossier', 'link'); |
$form->setType('dossier', 'link'); |
146 |
$form->setType('json_payload', 'jsonprettyprint'); |
$form->setType('json_payload', 'jsonprettyprint'); |
147 |
} |
} |
153 |
*/ |
*/ |
154 |
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
155 |
if($maj < 2) { |
if($maj < 2) { |
|
$contenu=array(); |
|
156 |
|
|
157 |
$contenu[0][0]="draft"; |
$contenu = array(); |
158 |
$contenu[1][0]=_('draft'); |
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG') as $key) { |
159 |
$contenu[0][1]="new"; |
$const_name = 'STATUS_'.$key; |
160 |
$contenu[1][1]=_('new'); |
$const_value = constant("self::$const_name"); |
161 |
$contenu[0][2]="pending"; |
$contenu[0][] = $const_value; |
162 |
$contenu[1][2]=_('pending'); |
$contenu[1][] = __($const_value); |
163 |
$contenu[0][3]="done"; |
} |
|
$contenu[1][3]=_('done'); |
|
|
$contenu[0][4]="archived"; |
|
|
$contenu[1][4]=_('archived'); |
|
|
$contenu[0][5]="error"; |
|
|
$contenu[1][5]=_('error'); |
|
|
$contenu[0][6]="debug"; |
|
|
$contenu[1][6]=_('debug'); |
|
164 |
|
|
165 |
$form->setSelect("state", $contenu); |
$form->setSelect("state", $contenu); |
166 |
|
|
207 |
if ($this->getVal('stream') == "output") { |
if ($this->getVal('stream') == "output") { |
208 |
$form->setVal('json_payload', $this->view_form_json(true)); |
$form->setVal('json_payload', $this->view_form_json(true)); |
209 |
} else { |
} else { |
210 |
if ($this->getVal('type') == 'ajout_piece'){ |
$form->setVal('json_payload', htmlentities($this->getVal('json_payload'))); |
|
// On modifie la valeur du champ "file_content" afin de tronquer le base64 |
|
|
$json_payload = json_decode($this->getVal("json_payload"), true); |
|
|
$json_payload["document_numerise"]["file_content"] = substr($json_payload["document_numerise"]["file_content"], 0, 64)."[...]"; |
|
|
$json_payload_result = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); |
|
|
$form->setVal('json_payload', htmlentities($json_payload_result)); |
|
|
} else { |
|
|
// |
|
|
$form->setVal('json_payload', htmlentities($this->getVal('json_payload'))); |
|
|
} |
|
211 |
} |
} |
212 |
} |
} |
213 |
|
|
214 |
function setLib(&$form, $maj) { |
function setLib(&$form, $maj) { |
215 |
parent::setLib($form, $maj); |
parent::setLib($form, $maj); |
216 |
$form->setLib('json_payload', ''); |
|
217 |
|
// Récupération du mode de l'action |
218 |
|
$crud = $this->get_action_crud($maj); |
219 |
|
|
220 |
|
// MODE different de CREER |
221 |
|
if ($maj != 0 || $crud != 'create') { |
222 |
|
$form->setLib('json_payload', ''); |
223 |
|
} |
224 |
} |
} |
225 |
|
|
226 |
public function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
public function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
227 |
$ret = parent::verifier($val, $dnu1, $dnu2); |
$ret = parent::verifier($val, $dnu1, $dnu2); |
228 |
|
|
|
if (array_key_exists('timestamp_log', $this->valF) === true |
|
|
&& is_array(json_decode($this->valF['timestamp_log'], true)) === false) { |
|
|
// |
|
|
$this->correct = false; |
|
|
$this->addToMessage(sprintf( |
|
|
__("Le champ %s doit être dans un format JSON valide."), |
|
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('timestamp_log')) |
|
|
)); |
|
|
} |
|
|
|
|
229 |
// 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 |
230 |
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
231 |
if (isset($this->valF['type']) === false) { |
if (isset($this->valF['type']) === false) { |
246 |
} |
} |
247 |
} |
} |
248 |
|
|
249 |
// le JSON doit être décodable |
// les JSONs doivent être décodables |
250 |
if (isset($this->valF['json_payload']) && ! empty($this->valF['json_payload']) && ( |
foreach(array('json_payload', 'timestamp_log') as $key) { |
251 |
is_array(json_decode($this->valF['json_payload'], true)) === false |
if (isset($this->valF[$key]) && ! empty($this->valF[$key]) && ( |
252 |
|| json_last_error() !== JSON_ERROR_NONE)) { |
is_array(json_decode($this->valF[$key], true)) === false |
253 |
$this->correct = false; |
|| json_last_error() !== JSON_ERROR_NONE)) { |
254 |
$this->addToMessage(sprintf( |
$this->correct = false; |
255 |
__("Le champ %s doit être dans un format JSON valide (erreur: %s)."), |
$champ_text = sprintf('<span class="bold">%s</span>', $this->getLibFromField($key)); |
256 |
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload'), |
$this->addToMessage(sprintf( |
257 |
json_last_error() !== JSON_ERROR_NONE ? json_last_error_msg() : __('invalide')) |
__("Le champ %s doit être dans un format JSON valide (erreur: %s).". |
258 |
)); |
"<p>%s valF:</br><pre>%s</pre></p>". |
259 |
$this->addToLog(__METHOD__.'(): erreur JSON: '.$this->msg, DEBUG_MODE); |
"<p>%s val:</br><pre>%s</pre></p>". |
260 |
|
"<p>%s POST:</br><pre>%s</pre></p>". |
261 |
|
"<p>%s submitted POST value:</br><pre>%s</pre></p>"), |
262 |
|
$champ_text, |
263 |
|
json_last_error() !== JSON_ERROR_NONE ? json_last_error_msg() : __('invalide'), |
264 |
|
$champ_text, |
265 |
|
$this->valF[$key], |
266 |
|
$champ_text, |
267 |
|
$val[$key], |
268 |
|
$champ_text, |
269 |
|
isset($_POST[$key]) ? $_POST[$key] : '', |
270 |
|
$champ_text, |
271 |
|
$this->f->get_submitted_post_value($key) |
272 |
|
)); |
273 |
|
$this->addToLog(__METHOD__.'(): erreur JSON: '.$this->msg, DEBUG_MODE); |
274 |
|
} |
275 |
} |
} |
276 |
|
|
277 |
// une tâche entrante doit avoir une payload avec les clés requises |
// une tâche entrante doit avoir une payload avec les clés requises |
278 |
elseif (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
if ($this->correct && (isset($this->valF['stream']) === false || |
279 |
|
$this->valF['stream'] == 'input')) { |
280 |
|
|
281 |
// décode la payload JSON |
// décode la payload JSON |
282 |
$json_payload = json_decode($this->valF['json_payload'], true); |
$json_payload = json_decode($this->valF['json_payload'], true); |
283 |
|
|
284 |
// défini une liste de chemin de clés requises |
// défini une liste de chemin de clés requises |
285 |
$paths = array( |
$paths = array( |
286 |
'dossier/dossier' |
'external_uids/dossier' |
287 |
); |
); |
288 |
|
|
289 |
// tâche de type création de DI/DA |
// tâche de type création de DI/DA |
290 |
if (isset($this->valF['type']) !== false && $this->valF['type'] == 'create_DI_for_consultation') { |
if (isset($this->valF['type']) !== false && $this->valF['type'] == 'create_DI_for_consultation') { |
291 |
|
|
292 |
$paths = array_merge($paths, array( |
$paths = array_merge($paths, array( |
293 |
|
'dossier/dossier', |
294 |
'dossier/dossier_autorisation_type_detaille_code', |
'dossier/dossier_autorisation_type_detaille_code', |
295 |
'dossier/date_demande', |
'dossier/date_demande', |
296 |
'dossier/depot_electronique', |
'dossier/depot_electronique', |
359 |
AND object_id = \'%4$s\' |
AND object_id = \'%4$s\' |
360 |
', |
', |
361 |
DB_PREFIXE, |
DB_PREFIXE, |
362 |
'done', |
self::STATUS_DONE, |
363 |
$type, |
$type, |
364 |
$object_id |
$object_id |
365 |
); |
); |
388 |
// décode la paylod JSON pour extraire les données métiers à ajouter |
// décode la paylod JSON pour extraire les données métiers à ajouter |
389 |
// en tant que métadonnées de la tâche |
// en tant que métadonnées de la tâche |
390 |
$json_payload = json_decode($this->valF['json_payload'], true); |
$json_payload = json_decode($this->valF['json_payload'], true); |
391 |
$this->valF["dossier"] = $json_payload['dossier']['dossier']; |
|
392 |
|
// si la tâche possède déjà une clé dossier |
393 |
|
if (isset($json_payload['dossier']['dossier']) && |
394 |
|
! empty($json_payload['dossier']['dossier'])) { |
395 |
|
$this->valF["dossier"] = $json_payload['dossier']['dossier']; |
396 |
|
} |
397 |
|
|
398 |
|
/** |
399 |
|
* Puisque le dossier n'a potentiellement pas encore été créé |
400 |
|
* alors il faut ne faut chercher à récupérer le numéro de dossier openADS |
401 |
|
* à partir de l'external_uids (en passant par la table de liens) |
402 |
|
// sinon si la tâche possède une clé external_uids/dossier |
403 |
|
elseif(isset($json_payload['external_uids']['dossier']) && |
404 |
|
! empty($json_payload['external_uids']['dossier'])) { |
405 |
|
|
406 |
|
// instancie l'objet lien_id_interne_uid_externe |
407 |
|
$inst_lien = $this->f->get_inst__om_dbform(array( |
408 |
|
"obj" => "lien_id_interne_uid_externe", |
409 |
|
"idx" => ']', |
410 |
|
)); |
411 |
|
if(! $dossier = $inst_lien->get_id_dossier_from_external_uid( |
412 |
|
$json_payload['external_uids']['dossier'])){ |
413 |
|
$error_msg = sprintf( |
414 |
|
__("Aucune correspondance de dossier pour l'external_uid.dossier '%s'."), |
415 |
|
$json_payload['external_uids']['dossier']); |
416 |
|
$this->addToLog(__METHOD__."() : erreur : $error_msg", DEBUG_MODE); |
417 |
|
$this->addToMessage($error_msg); |
418 |
|
$this->correct = false; |
419 |
|
return false; |
420 |
|
} |
421 |
|
$this->valF["dossier"] = $dossier; |
422 |
|
}*/ |
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 = 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 |
)); |
)); |
475 |
// 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 |
476 |
// 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 |
477 |
if (isset($params['val']['type']) |
if (isset($params['val']['type']) |
478 |
&& $params['val']['type'] == "ajout_piece" |
&& $params['val']['type'] == "add_piece" |
479 |
&& isset($params['val']['stream']) |
&& isset($params['val']['stream']) |
480 |
&& $params['val']['stream'] == "input" ) { |
&& $params['val']['stream'] == "input" ) { |
481 |
// |
// |
498 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
499 |
} |
} |
500 |
$json_payload["document_numerise"]["uid"] = $uid_fichier; |
$json_payload["document_numerise"]["uid"] = $uid_fichier; |
501 |
|
// Le fichier a été ajouté nous n'avons plus besoin du champ file_content dans la payload |
502 |
|
unset($json_payload["document_numerise"]["file_content"]); |
503 |
$params['val']['json_payload'] = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
$params['val']['json_payload'] = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
504 |
} |
} |
505 |
|
|
508 |
'task' => '', |
'task' => '', |
509 |
'type' => $params['val']['type'], |
'type' => $params['val']['type'], |
510 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
511 |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : '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 |
|
|
561 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
562 |
$timestamp_log = $this->get_timestamp_log(); |
$timestamp_log = $this->get_timestamp_log(); |
563 |
if ($timestamp_log === false) { |
if ($timestamp_log === false) { |
564 |
$this->addToLog(__('XXX'), DEBUG_MODE); |
$this->addToLog(__METHOD__."(): erreur timestamp log", DEBUG_MODE); |
565 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
566 |
} |
} |
567 |
array_push($timestamp_log, array( |
array_push($timestamp_log, array( |
838 |
return $val_architecte; |
return $val_architecte; |
839 |
} |
} |
840 |
|
|
841 |
protected function get_instruction_data(string $dossier, $type = 'decision') { |
protected function get_instruction_data(string $dossier, $type = 'decision', $extra_params = array()) { |
842 |
$val_instruction = null; |
$val_instruction = null; |
843 |
$instruction_with_doc = null; |
$instruction_with_doc = null; |
844 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
852 |
if ($type === 'incompletude') { |
if ($type === 'incompletude') { |
853 |
$idx = $inst_di->get_last_instruction_incompletude(); |
$idx = $inst_di->get_last_instruction_incompletude(); |
854 |
} |
} |
855 |
|
// XXX Permet de récupérer l'instruction par son identifiant |
856 |
|
if ($type === 'with-id') { |
857 |
|
$idx = $extra_params['with-id']; |
858 |
|
} |
859 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
860 |
"obj" => "instruction", |
"obj" => "instruction", |
861 |
"idx" => $idx, |
"idx" => $idx, |
901 |
|
|
902 |
protected function sort_instruction_data(array $values, array $res) { |
protected function sort_instruction_data(array $values, array $res) { |
903 |
$fields = array( |
$fields = array( |
904 |
|
"date_evenement", |
905 |
"date_envoi_signature", |
"date_envoi_signature", |
906 |
"date_retour_signature", |
"date_retour_signature", |
907 |
"date_envoi_rar", |
"date_envoi_rar", |
962 |
return $val_dp; |
return $val_dp; |
963 |
} |
} |
964 |
|
|
965 |
|
protected function get_avis_decision_data(string $dossier) { |
966 |
|
$inst_di = $this->f->get_inst__om_dbform(array( |
967 |
|
"obj" => "dossier", |
968 |
|
"idx" => $dossier, |
969 |
|
)); |
970 |
|
$ad = $inst_di->getVal('avis_decision'); |
971 |
|
$val_ad = array(); |
972 |
|
$inst_ad = $this->f->get_inst__om_dbform(array( |
973 |
|
"obj" => "avis_decision", |
974 |
|
"idx" => $ad, |
975 |
|
)); |
976 |
|
$val_ad = $inst_ad->get_json_data(); |
977 |
|
$val_ad['txAvis'] = "Voir document joint"; |
978 |
|
return $val_ad; |
979 |
|
} |
980 |
|
|
981 |
|
protected function get_signataire_arrete_data(string $sa) { |
982 |
|
$inst_sa = $this->f->get_inst__om_dbform(array( |
983 |
|
"obj" => "signataire_arrete", |
984 |
|
"idx" => $sa, |
985 |
|
)); |
986 |
|
$val_sa = array_combine($inst_sa->champs, $inst_sa->val); |
987 |
|
foreach ($val_sa as $key => $value) { |
988 |
|
$val_sa[$key] = strip_tags($value); |
989 |
|
} |
990 |
|
return $val_sa; |
991 |
|
} |
992 |
|
|
993 |
protected function view_form_json($in_field = false) { |
protected function view_form_json($in_field = false) { |
994 |
// |
// |
995 |
if ($this->f->get_submitted_post_value('valid') === null) { |
if ($this->f->get_submitted_post_value('valid') === null) { |
1047 |
} |
} |
1048 |
// |
// |
1049 |
if ($this->getVal('type') === 'decision_DI') { |
if ($this->getVal('type') === 'decision_DI') { |
1050 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1051 |
$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'))); |
1052 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1053 |
$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'); |
1054 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1056 |
} |
} |
1057 |
// |
// |
1058 |
if ($this->getVal('type') === 'incompletude_DI') { |
if ($this->getVal('type') === 'incompletude_DI') { |
1059 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1060 |
$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'))); |
1061 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1062 |
$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'); |
1063 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1065 |
} |
} |
1066 |
// |
// |
1067 |
if ($this->getVal('type') === 'completude_DI') { |
if ($this->getVal('type') === 'completude_DI') { |
1068 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1069 |
$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'))); |
1070 |
|
$val_external_uid = array(); |
1071 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1072 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1073 |
|
$val['external_uids'] = $val_external_uid; |
1074 |
|
} |
1075 |
|
// |
1076 |
|
if ($this->getVal('type') === 'pec_metier_consultation') { |
1077 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1078 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1079 |
|
$val_external_uid = array(); |
1080 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1081 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1082 |
|
$val_external_uid['consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'consultation'); |
1083 |
|
$val['external_uids'] = $val_external_uid; |
1084 |
|
} |
1085 |
|
// |
1086 |
|
if ($this->getVal('type') === 'avis_consultation') { |
1087 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1088 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1089 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
1090 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
1091 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
1092 |
|
} |
1093 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1094 |
$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'); |
1095 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1096 |
|
$val_external_uid['consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'consultation'); |
1097 |
$val['external_uids'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1098 |
} |
} |
1099 |
|
|
1128 |
} |
} |
1129 |
$this->f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
1130 |
// |
// |
1131 |
$inst_lien = $this->f->get_inst__om_dbform(array( |
if ($this->f->get_submitted_post_value('external_uid') !== null |
1132 |
"obj" => "lien_id_interne_uid_externe", |
&& $this->f->get_submitted_post_value('external_uid') != "") { |
1133 |
"idx" => ']', |
$inst_lien = $this->f->get_inst__om_dbform(array( |
1134 |
)); |
"obj" => "lien_id_interne_uid_externe", |
1135 |
$valF = array( |
"idx" => ']', |
1136 |
'lien_id_interne_uid_externe' => '', |
)); |
1137 |
'object' => $this->get_lien_objet_by_type($this->getVal('type')), |
$valF = array( |
1138 |
'object_id' => $this->getVal('object_id'), |
'lien_id_interne_uid_externe' => '', |
1139 |
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
'object' => $this->get_lien_objet_by_type($this->getVal('type')), |
1140 |
); |
'object_id' => $this->getVal('object_id'), |
1141 |
$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.') |
|
1142 |
); |
); |
1143 |
|
$add = $inst_lien->ajouter($valF); |
1144 |
|
$message_class = "valid"; |
1145 |
|
$message = $inst_lien->msg; |
1146 |
|
if ($add === false) { |
1147 |
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
1148 |
|
$message_class = "error"; |
1149 |
|
$message = sprintf( |
1150 |
|
'%s %s', |
1151 |
|
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
1152 |
|
__('Veuillez contacter votre administrateur.') |
1153 |
|
); |
1154 |
|
} |
1155 |
|
$this->f->displayMessage($message_class, $message); |
1156 |
} |
} |
|
$this->f->displayMessage($message_class, $message); |
|
1157 |
} |
} |
1158 |
|
|
1159 |
function post_add_task() { |
function post_add_task() { |
1189 |
|| $type === 'create_DI_for_consultation' |
|| $type === 'create_DI_for_consultation' |
1190 |
|| $type === 'depot_DI' |
|| $type === 'depot_DI' |
1191 |
|| $type === 'modification_DI' |
|| $type === 'modification_DI' |
1192 |
|| $type === 'qualification_DI' |
|| $type === 'qualification_DI') { |
1193 |
|
// |
1194 |
|
$objet = 'dossier'; |
1195 |
|
} |
1196 |
|
if ($type === 'pec_metier_consultation' |
1197 |
|| $type === 'decision_DI' |
|| $type === 'decision_DI' |
1198 |
|
|| $type === 'avis_consultation' |
1199 |
|| $type === 'incompletude_DI' |
|| $type === 'incompletude_DI' |
1200 |
|| $type === 'completude_DI') { |
|| $type === 'completude_DI') { |
1201 |
// |
// |
1202 |
$objet = 'dossier'; |
$objet = 'instruction'; |
1203 |
} |
} |
1204 |
if ($type === 'ajout_piece') { |
if ($type === 'ajout_piece') { |
1205 |
$objet = 'document_numerise'; |
$objet = 'document_numerise'; |
1206 |
} |
} |
1207 |
|
// La tâche entrante se nomme add_piece |
1208 |
|
if ($type === 'add_piece') { |
1209 |
|
$objet = 'piece'; |
1210 |
|
} |
1211 |
return $objet; |
return $objet; |
1212 |
} |
} |
1213 |
|
|
1214 |
function setLayout(&$form, $maj) { |
function setLayout(&$form, $maj) { |
1215 |
$form->setBloc('json_payload', 'D', '', 'col_6'); |
|
1216 |
$form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed"); |
// Récupération du mode de l'action |
1217 |
$form->setBloc('json_payload', 'F'); |
$crud = $this->get_action_crud($maj); |
1218 |
|
|
1219 |
|
// MODE different de CREER |
1220 |
|
if ($maj != 0 || $crud != 'create') { |
1221 |
|
$form->setBloc('json_payload', 'D', '', 'col_6'); |
1222 |
|
$form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed"); |
1223 |
|
$form->setBloc('json_payload', 'F'); |
1224 |
|
} |
1225 |
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
1226 |
} |
} |
1227 |
|
|