1 |
<?php |
<?php |
2 |
//$Id$ |
//$Id$ |
3 |
//gen openMairie le 14/04/2020 14:11 |
//gen openMairie le 14/04/2020 14:11 |
4 |
|
|
5 |
require_once "../gen/obj/task.class.php"; |
require_once "../gen/obj/task.class.php"; |
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 |
* |
* |
27 |
"view" => "view_json_data", |
"view" => "view_json_data", |
28 |
"permission_suffix" => "consulter", |
"permission_suffix" => "consulter", |
29 |
); |
); |
30 |
|
$this->class_actions[997] = array( |
31 |
|
"identifier" => "json_data", |
32 |
|
"view" => "post_update_task", |
33 |
|
"permission_suffix" => "modifier", |
34 |
|
); |
35 |
|
$this->class_actions[996] = array( |
36 |
|
"identifier" => "json_data", |
37 |
|
"view" => "post_add_task", |
38 |
|
"permission_suffix" => "ajouter", |
39 |
|
); |
40 |
|
} |
41 |
|
|
42 |
|
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); |
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 |
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 |
|
/** |
109 |
|
* |
110 |
|
* @return array |
111 |
|
*/ |
112 |
|
function get_var_sql_forminc__champs() { |
113 |
|
return array( |
114 |
|
"task", |
115 |
|
"type", |
116 |
|
"state", |
117 |
|
"object_id", |
118 |
|
"dossier", |
119 |
|
"stream", |
120 |
|
"json_payload", |
121 |
|
"timestamp_log", |
122 |
|
); |
123 |
|
} |
124 |
|
|
125 |
|
function setType(&$form, $maj) { |
126 |
|
parent::setType($form, $maj); |
127 |
|
|
128 |
|
// Récupération du mode de l'action |
129 |
|
$crud = $this->get_action_crud($maj); |
130 |
|
|
131 |
|
// 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"); |
140 |
|
$form->setType("stream", "select"); |
141 |
|
$form->setType("json_payload", "jsonprettyprint"); |
142 |
|
} |
143 |
|
// MODE CONSULTER |
144 |
|
if ($maj == 3 || $crud == 'read') { |
145 |
|
$form->setType('dossier', 'link'); |
146 |
|
$form->setType('json_payload', 'jsonprettyprint'); |
147 |
|
} |
148 |
|
|
149 |
|
} |
150 |
|
|
151 |
|
/** |
152 |
|
* |
153 |
|
*/ |
154 |
|
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
155 |
|
if($maj < 2) { |
156 |
|
|
157 |
|
$contenu = array(); |
158 |
|
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG') as $key) { |
159 |
|
$const_name = 'STATUS_'.$key; |
160 |
|
$const_value = constant("self::$const_name"); |
161 |
|
$contenu[0][] = $const_value; |
162 |
|
$contenu[1][] = __($const_value); |
163 |
|
} |
164 |
|
|
165 |
|
$form->setSelect("state", $contenu); |
166 |
|
|
167 |
|
$contenu_stream =array(); |
168 |
|
$contenu_stream[0][0]="input"; |
169 |
|
$contenu_stream[1][0]=_('input'); |
170 |
|
$contenu_stream[0][1]="output"; |
171 |
|
$contenu_stream[1][1]=_('output'); |
172 |
|
$form->setSelect("stream", $contenu_stream); |
173 |
|
|
174 |
|
} |
175 |
|
|
176 |
|
if ($maj == 3) { |
177 |
|
if ($this->getVal('stream') == 'output') { |
178 |
|
$inst_dossier = $this->f->get_inst__om_dbform(array( |
179 |
|
"obj" => "dossier", |
180 |
|
"idx" => $form->val['dossier'], |
181 |
|
)); |
182 |
|
|
183 |
|
if($form->val['type'] == "creation_DA"){ |
184 |
|
$obj_link = 'dossier_autorisation'; |
185 |
|
} else { |
186 |
|
$obj_link = 'dossier_instruction'; |
187 |
|
} |
188 |
|
|
189 |
|
$params = array(); |
190 |
|
$params['obj'] = $obj_link; |
191 |
|
$params['libelle'] = $inst_dossier->getVal('dossier'); |
192 |
|
$params['title'] = "Consulter le dossier"; |
193 |
|
$params['idx'] = $form->val['dossier']; |
194 |
|
$form->setSelect("dossier", $params); |
195 |
|
} |
196 |
|
} |
197 |
|
} |
198 |
|
|
199 |
|
/** |
200 |
|
* SETTER_FORM - setVal (setVal). |
201 |
|
* |
202 |
|
* @return void |
203 |
|
*/ |
204 |
|
function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) { |
205 |
|
// parent::setVal($form, $maj, $validation); |
206 |
|
// |
207 |
|
if ($this->getVal('stream') == "output") { |
208 |
|
$form->setVal('json_payload', $this->view_form_json(true)); |
209 |
|
} else { |
210 |
|
$form->setVal('json_payload', htmlentities($this->getVal('json_payload'))); |
211 |
|
} |
212 |
|
} |
213 |
|
|
214 |
|
function setLib(&$form, $maj) { |
215 |
|
parent::setLib($form, $maj); |
216 |
|
|
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) { |
227 |
|
$ret = parent::verifier($val, $dnu1, $dnu2); |
228 |
|
|
229 |
|
// une tâche entrante doit avoir un type et une payload non-vide |
230 |
|
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
231 |
|
if (isset($this->valF['type']) === false) { |
232 |
|
$this->correct = false; |
233 |
|
$this->addToMessage(sprintf( |
234 |
|
__("Le champ %s est obligatoire pour une tâche entrante."), |
235 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('type')) |
236 |
|
)); |
237 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
238 |
|
} |
239 |
|
if (isset($this->valF['json_payload']) === false) { |
240 |
|
$this->correct = false; |
241 |
|
$this->addToMessage(sprintf( |
242 |
|
__("Le champ %s est obligatoire pour une tâche entrante."), |
243 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
244 |
|
)); |
245 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
246 |
|
} |
247 |
|
} |
248 |
|
|
249 |
|
// les JSONs doivent être décodables |
250 |
|
foreach(array('json_payload', 'timestamp_log') as $key) { |
251 |
|
if (isset($this->valF[$key]) && ! empty($this->valF[$key]) && ( |
252 |
|
is_array(json_decode($this->valF[$key], true)) === false |
253 |
|
|| json_last_error() !== JSON_ERROR_NONE)) { |
254 |
|
$this->correct = false; |
255 |
|
$champ_text = sprintf('<span class="bold">%s</span>', $this->getLibFromField($key)); |
256 |
|
$this->addToMessage(sprintf( |
257 |
|
__("Le champ %s doit être dans un format JSON valide (erreur: %s).". |
258 |
|
"<p>%s valF:</br><pre>%s</pre></p>". |
259 |
|
"<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 |
278 |
|
if ($this->correct && (isset($this->valF['stream']) === false || |
279 |
|
$this->valF['stream'] == 'input')) { |
280 |
|
|
281 |
|
// décode la payload JSON |
282 |
|
$json_payload = json_decode($this->valF['json_payload'], true); |
283 |
|
|
284 |
|
// défini une liste de chemin de clés requises |
285 |
|
$paths = array( |
286 |
|
'external_uids/dossier' |
287 |
|
); |
288 |
|
|
289 |
|
// tâche de type création de DI/DA |
290 |
|
if (isset($this->valF['type']) !== false && $this->valF['type'] == 'create_DI_for_consultation') { |
291 |
|
|
292 |
|
$paths = array_merge($paths, array( |
293 |
|
'dossier/dossier', |
294 |
|
'dossier/dossier_autorisation_type_detaille_code', |
295 |
|
'dossier/date_demande', |
296 |
|
'dossier/depot_electronique', |
297 |
|
)); |
298 |
|
|
299 |
|
// si l'option commune est activée (mode MC) |
300 |
|
if ($this->f->is_option_dossier_commune_enabled()) { |
301 |
|
$paths[] = 'dossier/insee'; |
302 |
|
} |
303 |
|
|
304 |
|
// présence d'un moyen d'identifier la collectivité/le service |
305 |
|
if (! isset($json_payload['dossier']['acteur']) && |
306 |
|
! isset($json_payload['dossier']['om_collectivite'])) { |
307 |
|
$this->correct = false; |
308 |
|
$this->addToMessage(sprintf( |
309 |
|
__("L'une des clés %s ou %s est obligatoire dans le contenu du champ %s pour une tâche entrante."), |
310 |
|
sprintf('<span class="bold">%s</span>', 'dossier/acteur'), |
311 |
|
sprintf('<span class="bold">%s</span>', 'dossier/om_collectivite'), |
312 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
313 |
|
)); |
314 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
315 |
|
} |
316 |
|
} |
317 |
|
|
318 |
|
// pas d'erreur déjà trouvée |
319 |
|
if($this->correct) { |
320 |
|
|
321 |
|
// pour chaque chemin |
322 |
|
foreach($paths as $path) { |
323 |
|
|
324 |
|
// décompose le chemin |
325 |
|
$tokens = explode('/', $path); |
326 |
|
$cur_depth = $json_payload; |
327 |
|
|
328 |
|
// descend au et à mesure dans l'arborescence du chemin |
329 |
|
foreach($tokens as $token) { |
330 |
|
|
331 |
|
// en vérifiant que chaque élément du chemin est défini et non-nul |
332 |
|
if (isset($cur_depth[$token]) === false) { |
333 |
|
|
334 |
|
// sinon on produit une erreur |
335 |
|
$this->correct = false; |
336 |
|
$this->addToMessage(sprintf( |
337 |
|
__("La clé %s est obligatoire dans le contenu du champ %s pour une tâche entrante."), |
338 |
|
sprintf('<span class="bold">%s</span>', $path), |
339 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
340 |
|
)); |
341 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
342 |
|
break 2; |
343 |
|
} |
344 |
|
$cur_depth = $cur_depth[$token]; |
345 |
|
} |
346 |
|
} |
347 |
|
} |
348 |
|
} |
349 |
|
|
350 |
|
return $ret && $this->correct; |
351 |
} |
} |
352 |
|
|
353 |
protected function task_exists(string $type, string $object_id) { |
protected function task_exists(string $type, string $object_id) { |
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 |
); |
); |
371 |
} |
} |
372 |
|
|
373 |
/** |
/** |
374 |
|
* TRIGGER - triggerajouter. |
375 |
|
* |
376 |
|
* @param string $id |
377 |
|
* @param null &$dnu1 @deprecated Ne pas utiliser. |
378 |
|
* @param array $val Tableau des valeurs brutes. |
379 |
|
* @param null $dnu2 @deprecated Ne pas utiliser. |
380 |
|
* |
381 |
|
* @return boolean |
382 |
|
*/ |
383 |
|
function triggerajouter($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
384 |
|
|
385 |
|
// tâche entrante |
386 |
|
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
387 |
|
|
388 |
|
// décode la paylod JSON pour extraire les données métiers à ajouter |
389 |
|
// en tant que métadonnées de la tâche |
390 |
|
$json_payload = json_decode($this->valF['json_payload'], true); |
391 |
|
|
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 |
|
|
426 |
|
/** |
427 |
* TREATMENT - add_task |
* TREATMENT - add_task |
428 |
* Ajoute un enregistrement. |
* Ajoute un enregistrement. |
429 |
* |
* |
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 |
)); |
)); |
474 |
|
|
475 |
|
// 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 |
477 |
|
if (isset($params['val']['type']) |
478 |
|
&& $params['val']['type'] == "add_piece" |
479 |
|
&& isset($params['val']['stream']) |
480 |
|
&& $params['val']['stream'] == "input" ) { |
481 |
|
// |
482 |
|
$json_payload = json_decode($params['val']['json_payload'], true); |
483 |
|
$document_numerise = $json_payload['document_numerise']; |
484 |
|
$file_content = base64_decode($document_numerise["file_content"]); |
485 |
|
if ($file_content === false){ |
486 |
|
$this->addToMessage(__("Le contenu du fichier lié à la tâche n'a pas pu etre recupere.")); |
487 |
|
return $this->end_treatment(__METHOD__, false); |
488 |
|
} |
489 |
|
$metadata = array( |
490 |
|
"filename" => $document_numerise['nom_fichier'], |
491 |
|
"size" => strlen($file_content), |
492 |
|
"mimetype" => $document_numerise['file_content_type'], |
493 |
|
"date_creation" => $document_numerise['date_creation'], |
494 |
|
); |
495 |
|
$uid_fichier = $this->f->storage->create($file_content, $metadata, "from_content"); |
496 |
|
if ($uid_fichier === OP_FAILURE) { |
497 |
|
$this->addToMessage(__("Erreur lors de la creation du fichier lié à la tâche.")); |
498 |
|
return $this->end_treatment(__METHOD__, false); |
499 |
|
} |
500 |
|
$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); |
504 |
|
} |
505 |
|
|
506 |
// Mise à jour du DI |
// Mise à jour du DI |
507 |
$valF = array( |
$valF = array( |
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' => $params['val']['object_id'], |
'object_id' => isset($params['val']['object_id']) ? $params['val']['object_id'] : '', |
513 |
|
'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '', |
514 |
|
'stream' => $stream, |
515 |
|
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
516 |
); |
); |
517 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
|
518 |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
// tâche sortante |
519 |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
if($valF["stream"] == "output"){ |
520 |
} |
|
521 |
if ($task_exists !== false) { |
// TODO expliquer ce code |
522 |
$inst_task = $this->f->get_inst__om_dbform(array( |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
523 |
"obj" => "task", |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
524 |
"idx" => $task_exists, |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
525 |
)); |
} |
526 |
$update_state = $inst_task->getVal('state'); |
if ($task_exists !== false) { |
527 |
if (isset($params['update_val']['state']) === true) { |
$inst_task = $this->f->get_inst__om_dbform(array( |
528 |
$update_state = $params['update_val']['state']; |
"obj" => "task", |
529 |
} |
"idx" => $task_exists, |
530 |
$update_params = array( |
)); |
531 |
'val' => array( |
$update_state = $inst_task->getVal('state'); |
532 |
'state' => $update_state, |
if (isset($params['update_val']['state']) === true) { |
533 |
), |
$update_state = $params['update_val']['state']; |
534 |
); |
} |
535 |
return $inst_task->update_task($update_params); |
$update_params = array( |
536 |
|
'val' => array( |
537 |
|
'state' => $update_state, |
538 |
|
), |
539 |
|
); |
540 |
|
return $inst_task->update_task($update_params); |
541 |
|
} |
542 |
} |
} |
543 |
|
|
544 |
$add = $this->ajouter($valF); |
$add = $this->ajouter($valF); |
545 |
|
$this->addToLog(__METHOD__."(): retour de l'ajout de tâche: ".var_export($add, true), VERBOSE_MODE); |
546 |
if ($add === false) { |
if ($add === false) { |
547 |
$this->addToLog($this->msg, DEBUG_MODE); |
$this->addToLog(__METHOD__."(): ".$this->msg, DEBUG_MODE); |
548 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
549 |
} |
} |
550 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
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( |
576 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
577 |
'state' => $params['val']['state'], |
'state' => $params['val']['state'], |
578 |
'object_id' => $this->getVal('object_id'), |
'object_id' => $this->getVal('object_id'), |
579 |
|
'stream' => $this->getVal('stream'), |
580 |
|
'dossier' => $this->getVal('dossier'), |
581 |
|
'json_payload' => $this->getVal('json_payload'), |
582 |
); |
); |
583 |
$update = $this->modifier($valF); |
$update = $this->modifier($valF); |
584 |
if ($update === false) { |
if ($update === false) { |
591 |
/** |
/** |
592 |
* 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 |
593 |
* l'enregistrement instancié. |
* l'enregistrement instancié. |
594 |
* |
* |
595 |
* @param array $params Tableau des paramètres |
* @param array $params Tableau des paramètres |
596 |
* @return array sinon false en cas d'erreur |
* @return array sinon false en cas d'erreur |
597 |
*/ |
*/ |
637 |
* |
* |
638 |
FROM %1$stask |
FROM %1$stask |
639 |
%2$s |
%2$s |
640 |
|
ORDER BY task ASC |
641 |
', |
', |
642 |
DB_PREFIXE, |
DB_PREFIXE, |
643 |
$where |
$where |
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['dossier']; |
653 |
|
if ($this->get_lien_objet_by_type($task['type']) === 'document_numerise') { |
654 |
|
$val_dn = $this->get_document_numerise_data($task['object_id']); |
655 |
|
} |
656 |
|
if ($task['stream'] === 'output') { |
657 |
|
$task['external_uids'] = $this->get_all_external_uids($task['dossier']); |
658 |
|
} |
659 |
$list_tasks[$task['task']] = $task; |
$list_tasks[$task['task']] = $task; |
660 |
} |
} |
661 |
printf(json_encode($list_tasks)); |
printf(json_encode($list_tasks)); |
808 |
return $inst_external_uid->getVal('external_uid'); |
return $inst_external_uid->getVal('external_uid'); |
809 |
} |
} |
810 |
|
|
811 |
|
protected function get_all_external_uids($fk_idx) { |
812 |
|
$link_objects = array( |
813 |
|
'dossier_autorisation', |
814 |
|
'dossier', |
815 |
|
'consultation', |
816 |
|
'document_numerise', |
817 |
|
); |
818 |
|
$val_external_uid = array(); |
819 |
|
foreach ($link_objects as $link_object) { |
820 |
|
$external_uid = $this->get_external_uid($fk_idx, $link_object); |
821 |
|
if ($external_uid !== '' && $external_uid !== null) { |
822 |
|
$val_external_uid[$link_object] = $external_uid; |
823 |
|
} |
824 |
|
} |
825 |
|
return $val_external_uid; |
826 |
|
} |
827 |
|
|
828 |
protected function get_demandeurs_data(string $dossier) { |
protected function get_demandeurs_data(string $dossier) { |
829 |
$val_demandeur = array(); |
$val_demandeur = array(); |
830 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
857 |
return $val_architecte; |
return $val_architecte; |
858 |
} |
} |
859 |
|
|
860 |
protected function get_instruction_data(string $dossier, $type = 'decision') { |
protected function get_instruction_data(string $dossier, $type = 'decision', $extra_params = array()) { |
861 |
$val_instruction = null; |
$val_instruction = null; |
862 |
$instruction_with_doc = null; |
$instruction_with_doc = null; |
863 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
871 |
if ($type === 'incompletude') { |
if ($type === 'incompletude') { |
872 |
$idx = $inst_di->get_last_instruction_incompletude(); |
$idx = $inst_di->get_last_instruction_incompletude(); |
873 |
} |
} |
874 |
|
// XXX Permet de récupérer l'instruction par son identifiant |
875 |
|
if ($type === 'with-id') { |
876 |
|
$idx = $extra_params['with-id']; |
877 |
|
} |
878 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
879 |
"obj" => "instruction", |
"obj" => "instruction", |
880 |
"idx" => $idx, |
"idx" => $idx, |
912 |
} |
} |
913 |
if ($instruction_with_doc !== null) { |
if ($instruction_with_doc !== null) { |
914 |
// |
// |
915 |
$val_instruction['path'] = sprintf('%s/%s&snippet=%s&obj=%s&champ=%s&id=%s', $_SERVER['HTTP_HOST'], 'openads/app/index.php?module=form', 'file', 'instruction', 'om_fichier_instruction', $instruction_with_doc); |
$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); |
916 |
} |
} |
917 |
} |
} |
918 |
return $val_instruction; |
return $val_instruction; |
920 |
|
|
921 |
protected function sort_instruction_data(array $values, array $res) { |
protected function sort_instruction_data(array $values, array $res) { |
922 |
$fields = array( |
$fields = array( |
923 |
|
"date_evenement", |
924 |
"date_envoi_signature", |
"date_envoi_signature", |
925 |
"date_retour_signature", |
"date_retour_signature", |
926 |
"date_envoi_rar", |
"date_envoi_rar", |
930 |
"signataire_arrete", |
"signataire_arrete", |
931 |
"om_fichier_instruction", |
"om_fichier_instruction", |
932 |
"tacite", |
"tacite", |
933 |
|
"lettretype", |
934 |
); |
); |
935 |
foreach ($values as $key => $value) { |
foreach ($values as $key => $value) { |
936 |
if (in_array($key, $fields) === true) { |
if (in_array($key, $fields) === true) { |
956 |
"idx" => $dn, |
"idx" => $dn, |
957 |
)); |
)); |
958 |
$val_dn = $inst_dn->get_json_data(); |
$val_dn = $inst_dn->get_json_data(); |
959 |
$val_dn['path'] = sprintf('%s/%s&snippet=%s&obj=%s&champ=%s&id=%s', $_SERVER['HTTP_HOST'], 'openads/app/index.php?module=form', 'file', 'document_numerise', 'uid', $this->getVal('object_id')); |
$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')); |
960 |
// Correspond à la nomenclature Plat'AU NATURE_PIECE |
// Correspond à la nomenclature Plat'AU NATURE_PIECE |
961 |
$val_dn['nature'] = $val_dn['document_numerise_nature_libelle']; |
$val_dn['nature'] = $val_dn['document_numerise_nature_libelle']; |
962 |
return $val_dn; |
return $val_dn; |
981 |
return $val_dp; |
return $val_dp; |
982 |
} |
} |
983 |
|
|
984 |
protected function view_form_json() { |
protected function get_avis_decision_data(string $dossier) { |
985 |
// Mise à jour des valeurs |
$inst_di = $this->f->get_inst__om_dbform(array( |
986 |
if ($this->f->get_submitted_post_value('valid') === 'true' |
"obj" => "dossier", |
987 |
&& $this->f->get_submitted_post_value('state') !== null) { |
"idx" => $dossier, |
988 |
|
)); |
989 |
|
$ad = $inst_di->getVal('avis_decision'); |
990 |
|
$val_ad = array(); |
991 |
|
$inst_ad = $this->f->get_inst__om_dbform(array( |
992 |
|
"obj" => "avis_decision", |
993 |
|
"idx" => $ad, |
994 |
|
)); |
995 |
|
$val_ad = $inst_ad->get_json_data(); |
996 |
|
$val_ad['txAvis'] = "Voir document joint"; |
997 |
|
if (isset($val_ad['tacite']) === true |
998 |
|
&& $val_ad['tacite'] === 't') { |
999 |
// |
// |
1000 |
$params = array( |
$val_ad['txAvis'] = "Sans objet"; |
|
'val' => array( |
|
|
'state' => $this->f->get_submitted_post_value('state') |
|
|
), |
|
|
); |
|
|
$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.') |
|
|
); |
|
|
} |
|
|
$this->f->displayMessage($message_class, $message); |
|
1001 |
} |
} |
1002 |
// |
return $val_ad; |
1003 |
if ($this->f->get_submitted_post_value('valid') === 'true' |
} |
1004 |
&& $this->f->get_submitted_post_value('external_uid') !== null) { |
|
1005 |
// |
protected function get_signataire_arrete_data(string $sa) { |
1006 |
$inst_lien = $this->f->get_inst__om_dbform(array( |
$inst_sa = $this->f->get_inst__om_dbform(array( |
1007 |
"obj" => "lien_id_interne_uid_externe", |
"obj" => "signataire_arrete", |
1008 |
"idx" => ']', |
"idx" => $sa, |
1009 |
)); |
)); |
1010 |
$valF = array( |
$val_sa = array_combine($inst_sa->champs, $inst_sa->val); |
1011 |
'lien_id_interne_uid_externe' => '', |
foreach ($val_sa as $key => $value) { |
1012 |
'object' => $this->get_lien_objet_by_type($this->getVal('type')), |
$val_sa[$key] = strip_tags($value); |
|
'object_id' => $this->getVal('object_id'), |
|
|
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
|
|
); |
|
|
$add = $inst_lien->ajouter($valF); |
|
|
$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.') |
|
|
); |
|
|
} |
|
|
$this->f->displayMessage($message_class, $message); |
|
1013 |
} |
} |
1014 |
|
return $val_sa; |
1015 |
|
} |
1016 |
|
|
1017 |
|
protected function view_form_json($in_field = false) { |
1018 |
// |
// |
1019 |
if ($this->f->get_submitted_post_value('valid') === null) { |
if ($this->f->get_submitted_post_value('valid') === null) { |
1020 |
// Liste des valeurs à afficher |
// Liste des valeurs à afficher |
1033 |
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
1034 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1035 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
1036 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1037 |
} |
} |
1038 |
// |
// |
1039 |
if ($this->getVal('type') === 'creation_DI' |
if ($this->getVal('type') === 'creation_DI' |
1049 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1050 |
$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'); |
1051 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1052 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1053 |
} |
} |
1054 |
// |
// |
1055 |
if ($this->getVal('type') === 'qualification_DI') { |
if ($this->getVal('type') === 'qualification_DI') { |
1057 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1058 |
$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'); |
1059 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1060 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1061 |
} |
} |
1062 |
// |
// |
1063 |
if ($this->getVal('type') === 'ajout_piece') { |
if ($this->getVal('type') === 'ajout_piece') { |
1067 |
$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'); |
1068 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1069 |
$val_external_uid['document_numerise'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'document_numerise'); |
$val_external_uid['document_numerise'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'document_numerise'); |
1070 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1071 |
} |
} |
1072 |
// |
// |
1073 |
if ($this->getVal('type') === 'decision_DI') { |
if ($this->getVal('type') === 'decision_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']); |
$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_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1080 |
} |
} |
1081 |
// |
// |
1082 |
if ($this->getVal('type') === 'incompletude_DI') { |
if ($this->getVal('type') === 'incompletude_DI') { |
1083 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1084 |
$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'))); |
1085 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1086 |
$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'); |
1087 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1088 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1089 |
} |
} |
1090 |
|
// |
1091 |
if ($this->getVal('type') === 'completude_DI') { |
if ($this->getVal('type') === 'completude_DI') { |
1092 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1093 |
$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'))); |
1094 |
|
$val_external_uid = array(); |
1095 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1096 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1097 |
|
$val['external_uids'] = $val_external_uid; |
1098 |
|
} |
1099 |
|
// |
1100 |
|
if ($this->getVal('type') === 'pec_metier_consultation') { |
1101 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1102 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1103 |
|
$val_external_uid = array(); |
1104 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1105 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1106 |
|
$val_external_uid['consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'consultation'); |
1107 |
|
$val['external_uids'] = $val_external_uid; |
1108 |
|
} |
1109 |
|
// |
1110 |
|
if ($this->getVal('type') === 'avis_consultation') { |
1111 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1112 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1113 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
1114 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
1115 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
1116 |
|
} |
1117 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1118 |
$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'); |
1119 |
$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 |
$val['external_uid'] = $val_external_uid; |
$val_external_uid['consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'consultation'); |
1121 |
|
$val['external_uids'] = $val_external_uid; |
1122 |
} |
} |
1123 |
|
|
1124 |
// Liste des valeurs affichée en JSON |
if ($in_field === true) { |
1125 |
printf(json_encode($val)); |
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
1126 |
|
} else { |
1127 |
|
// Liste des valeurs affichée en JSON |
1128 |
|
printf(json_encode($val, JSON_UNESCAPED_SLASHES)); |
1129 |
|
} |
1130 |
} |
} |
1131 |
} |
} |
1132 |
|
|
1133 |
protected function get_lien_objet_by_type($type) { |
function post_update_task() { |
1134 |
|
// Mise à jour des valeurs |
1135 |
|
// |
1136 |
|
$params = array( |
1137 |
|
'val' => array( |
1138 |
|
'state' => $this->f->get_submitted_post_value('state') |
1139 |
|
), |
1140 |
|
); |
1141 |
|
$update = $this->update_task($params); |
1142 |
|
$message_class = "valid"; |
1143 |
|
$message = $this->msg; |
1144 |
|
if ($update === false) { |
1145 |
|
$this->addToLog($this->msg, DEBUG_MODE); |
1146 |
|
$message_class = "error"; |
1147 |
|
$message = sprintf( |
1148 |
|
'%s %s', |
1149 |
|
__('Impossible de mettre à jour la tâche.'), |
1150 |
|
__('Veuillez contacter votre administrateur.') |
1151 |
|
); |
1152 |
|
} |
1153 |
|
$this->f->displayMessage($message_class, $message); |
1154 |
|
// |
1155 |
|
if ($this->f->get_submitted_post_value('external_uid') !== null |
1156 |
|
&& $this->f->get_submitted_post_value('external_uid') != "") { |
1157 |
|
$inst_lien = $this->f->get_inst__om_dbform(array( |
1158 |
|
"obj" => "lien_id_interne_uid_externe", |
1159 |
|
"idx" => ']', |
1160 |
|
)); |
1161 |
|
$valF = array( |
1162 |
|
'lien_id_interne_uid_externe' => '', |
1163 |
|
'object' => $this->get_lien_objet_by_type($this->getVal('type')), |
1164 |
|
'object_id' => $this->getVal('object_id'), |
1165 |
|
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
1166 |
|
); |
1167 |
|
$add = $inst_lien->ajouter($valF); |
1168 |
|
$message_class = "valid"; |
1169 |
|
$message = $inst_lien->msg; |
1170 |
|
if ($add === false) { |
1171 |
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
1172 |
|
$message_class = "error"; |
1173 |
|
$message = sprintf( |
1174 |
|
'%s %s', |
1175 |
|
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
1176 |
|
__('Veuillez contacter votre administrateur.') |
1177 |
|
); |
1178 |
|
} |
1179 |
|
$this->f->displayMessage($message_class, $message); |
1180 |
|
} |
1181 |
|
} |
1182 |
|
|
1183 |
|
function post_add_task() { |
1184 |
|
// TODO Tester de remplacer la ligne de json_payload par un $_POST |
1185 |
|
$result = $this->add_task(array( |
1186 |
|
'val' => array( |
1187 |
|
'stream' => 'input', |
1188 |
|
'json_payload' => html_entity_decode($this->f->get_submitted_post_value('json_payload')), |
1189 |
|
'type' => $this->f->get_submitted_post_value('type'), |
1190 |
|
) |
1191 |
|
)); |
1192 |
|
$message = $this->msg; |
1193 |
|
$message_class = "valid"; |
1194 |
|
if ($result === false){ |
1195 |
|
$this->addToLog($this->msg, DEBUG_MODE); |
1196 |
|
$message_class = "error"; |
1197 |
|
$message = sprintf( |
1198 |
|
'%s %s', |
1199 |
|
__('Impossible d\'ajouter la tâche.'), |
1200 |
|
__('Veuillez contacter votre administrateur.') |
1201 |
|
); |
1202 |
|
} |
1203 |
|
$this->f->displayMessage($message_class, $message); |
1204 |
|
} |
1205 |
|
|
1206 |
|
function get_lien_objet_by_type($type) { |
1207 |
// |
// |
1208 |
$objet = ''; |
$objet = ''; |
1209 |
if ($type === 'creation_DA') { |
if ($type === 'creation_DA') { |
1210 |
$objet = 'dossier_autorisation'; |
$objet = 'dossier_autorisation'; |
1211 |
} |
} |
1212 |
if ($type === 'creation_DI' |
if ($type === 'creation_DI' |
1213 |
|
|| $type === 'create_DI_for_consultation' |
1214 |
|| $type === 'depot_DI' |
|| $type === 'depot_DI' |
1215 |
|| $type === 'modification_DI' |
|| $type === 'modification_DI' |
1216 |
|| $type === 'qualification_DI' |
|| $type === 'qualification_DI') { |
1217 |
|
// |
1218 |
|
$objet = 'dossier'; |
1219 |
|
} |
1220 |
|
if ($type === 'pec_metier_consultation' |
1221 |
|| $type === 'decision_DI' |
|| $type === 'decision_DI' |
1222 |
|
|| $type === 'avis_consultation' |
1223 |
|| $type === 'incompletude_DI' |
|| $type === 'incompletude_DI' |
1224 |
|| $type === 'completude_DI') { |
|| $type === 'completude_DI') { |
1225 |
// |
// |
1226 |
$objet = 'dossier'; |
$objet = 'instruction'; |
1227 |
} |
} |
1228 |
if ($type === 'ajout_piece') { |
if ($type === 'ajout_piece') { |
1229 |
$objet = 'document_numerise'; |
$objet = 'document_numerise'; |
1230 |
} |
} |
1231 |
|
// La tâche entrante se nomme add_piece |
1232 |
|
if ($type === 'add_piece') { |
1233 |
|
$objet = 'piece'; |
1234 |
|
} |
1235 |
return $objet; |
return $objet; |
1236 |
} |
} |
1237 |
|
|
1238 |
|
function setLayout(&$form, $maj) { |
1239 |
|
|
1240 |
|
// Récupération du mode de l'action |
1241 |
|
$crud = $this->get_action_crud($maj); |
1242 |
|
|
1243 |
|
// MODE different de CREER |
1244 |
|
if ($maj != 0 || $crud != 'create') { |
1245 |
|
$form->setBloc('json_payload', 'D', '', 'col_6'); |
1246 |
|
$form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed"); |
1247 |
|
$form->setBloc('json_payload', 'F'); |
1248 |
|
} |
1249 |
|
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
1250 |
|
} |
1251 |
|
|
1252 |
} |
} |