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 |
|
* Liste des types de tâche concernant les services instructeurs |
19 |
|
*/ |
20 |
|
const TASK_TYPE_SI = array( |
21 |
|
'creation_DA', |
22 |
|
'creation_DI', |
23 |
|
'depot_DI', |
24 |
|
'modification_DI', |
25 |
|
'qualification_DI', |
26 |
|
'decision_DI', |
27 |
|
'incompletude_DI', |
28 |
|
'completude_DI', |
29 |
|
'ajout_piece', |
30 |
|
'add_piece', |
31 |
|
'creation_consultation', |
32 |
|
'create_DI', |
33 |
|
); |
34 |
|
|
35 |
|
/** |
36 |
|
* Liste des types de tâche concernant les services consultés |
37 |
|
*/ |
38 |
|
const TASK_TYPE_SC = array( |
39 |
|
'create_DI_for_consultation', |
40 |
|
'avis_consultation', |
41 |
|
'pec_metier_consultation', |
42 |
|
); |
43 |
|
|
44 |
/** |
/** |
45 |
* Définition des actions disponibles sur la classe. |
* Définition des actions disponibles sur la classe. |
46 |
* |
* |
56 |
); |
); |
57 |
$this->class_actions[997] = array( |
$this->class_actions[997] = array( |
58 |
"identifier" => "json_data", |
"identifier" => "json_data", |
59 |
"view" => "view_update_json_data", |
"view" => "post_update_task", |
60 |
"permission_suffix" => "modifier", |
"permission_suffix" => "modifier", |
61 |
); |
); |
62 |
$this->class_actions[996] = array( |
$this->class_actions[996] = array( |
63 |
"identifier" => "json_data", |
"identifier" => "json_data", |
64 |
"view" => "view_add_json_data", |
"view" => "post_add_task", |
65 |
"permission_suffix" => "ajouter", |
"permission_suffix" => "ajouter", |
66 |
); |
); |
67 |
} |
} |
68 |
|
|
69 |
public function setvalF($val = array()) { |
public function setvalF($val = array()) { |
70 |
|
|
71 |
|
// // les guillets doubles sont remplacés automatiquement par des simples |
72 |
|
// // dans core/om_formulaire.clasS.php::recupererPostvar() |
73 |
|
// // voir le ticket https://dev.atreal.fr/projets/openmairie/tracker/209 |
74 |
|
// // ceci est un hack sale temporaire en attendant résolution du ticket |
75 |
|
// foreach(array('json_payload', 'timestamp_log') as $key) { |
76 |
|
// if (isset($val[$key]) && ! empty($val[$key]) && |
77 |
|
// isset($_POST[$key]) && ! empty($_POST[$key])) { |
78 |
|
// $submited_payload = $_POST[$key]; |
79 |
|
// if (! empty($submited_payload)) { |
80 |
|
// $new_payload = str_replace("'", '"', $val[$key]); |
81 |
|
// if ($new_payload == $submited_payload || |
82 |
|
// strpos($submited_payload, '"') === false) { |
83 |
|
// $val[$key] = $new_payload; |
84 |
|
// } |
85 |
|
// else { |
86 |
|
// $error_msg = sprintf( |
87 |
|
// __("La convertion des guillemets de la payload JSON '%s' ". |
88 |
|
// "n'est pas idempotente (courante: %s, postée: %s, convertie: %s)"), |
89 |
|
// $key, var_export($val[$key], true), var_export($submited_payload, true), |
90 |
|
// var_export($new_payload, true)); |
91 |
|
// $this->correct = false; |
92 |
|
// $this->addToMessage($error_msg); |
93 |
|
// $this->addToLog(__METHOD__."() erreur : $error_msg", DEBUG_MODE); |
94 |
|
// return false; |
95 |
|
// } |
96 |
|
// } |
97 |
|
// } |
98 |
|
// } |
99 |
|
|
100 |
parent::setvalF($val); |
parent::setvalF($val); |
101 |
// |
|
102 |
|
// XXX Ancien code : permet de ne pas avoir d'erreru lors de la modification d'une task |
103 |
if (array_key_exists('timestamp_log', $val) === true) { |
if (array_key_exists('timestamp_log', $val) === true) { |
104 |
$this->valF['timestamp_log'] = str_replace("'", '"', $val['timestamp_log']); |
$this->valF['timestamp_log'] = str_replace("'", '"', $val['timestamp_log']); |
105 |
} |
} |
106 |
|
|
107 |
|
// récupération de l'ID de l'objet existant |
108 |
|
$id = property_exists($this, 'id') ? $this->id : null; |
109 |
|
if(isset($val[$this->clePrimaire])) { |
110 |
|
$id = $val[$this->clePrimaire]; |
111 |
|
} elseif(isset($this->valF[$this->clePrimaire])) { |
112 |
|
$id = $this->valF[$this->clePrimaire]; |
113 |
|
} |
114 |
|
|
115 |
|
// MODE MODIFIER |
116 |
|
if (! empty($id)) { |
117 |
|
|
118 |
|
// si aucune payload n'est fourni (devrait toujours être le cas) |
119 |
|
if (! isset($val['json_payload']) || empty($val['json_payload'])) { |
120 |
|
|
121 |
|
// récupère l'objet existant |
122 |
|
$existing = $this->f->findObjectById(get_class($this), $id); |
123 |
|
if (! empty($existing)) { |
124 |
|
|
125 |
|
// récupère la payload de l'objet |
126 |
|
$val['json_payload'] = $existing->getVal('json_payload'); |
127 |
|
$this->valF['json_payload'] = $existing->getVal('json_payload'); |
128 |
|
$this->f->addToLog(__METHOD__."() récupère la payload de la tâche existante ". |
129 |
|
"'$id': ".$existing->getVal('json_payload'), EXTRA_VERBOSE_MODE); |
130 |
|
} |
131 |
|
} |
132 |
|
} |
133 |
} |
} |
134 |
|
|
135 |
/** |
/** |
151 |
|
|
152 |
function setType(&$form, $maj) { |
function setType(&$form, $maj) { |
153 |
parent::setType($form, $maj); |
parent::setType($form, $maj); |
154 |
|
|
155 |
// Récupération du mode de l'action |
// Récupération du mode de l'action |
156 |
$crud = $this->get_action_crud($maj); |
$crud = $this->get_action_crud($maj); |
157 |
|
|
158 |
if ($maj < 2) { |
// MODE CREER |
159 |
|
if ($maj == 0 || $crud == 'create') { |
160 |
|
$form->setType("state", "select"); |
161 |
|
$form->setType("stream", "select"); |
162 |
|
$form->setType("json_payload", "textarea"); |
163 |
|
} |
164 |
|
// MDOE MODIFIER |
165 |
|
if ($maj == 1 || $crud == 'update') { |
166 |
$form->setType("state", "select"); |
$form->setType("state", "select"); |
167 |
$form->setType("stream", "select"); |
$form->setType("stream", "select"); |
168 |
$form->setType("json_payload", "jsonprettyprint"); |
$form->setType("json_payload", "jsonprettyprint"); |
169 |
} |
} |
170 |
if ($maj == 3){ |
// MODE CONSULTER |
171 |
|
if ($maj == 3 || $crud == 'read') { |
172 |
$form->setType('dossier', 'link'); |
$form->setType('dossier', 'link'); |
173 |
$form->setType('json_payload', 'jsonprettyprint'); |
$form->setType('json_payload', 'jsonprettyprint'); |
174 |
} |
} |
180 |
*/ |
*/ |
181 |
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
182 |
if($maj < 2) { |
if($maj < 2) { |
|
$contenu=array(); |
|
183 |
|
|
184 |
$contenu[0][0]="draft"; |
$contenu = array(); |
185 |
$contenu[1][0]=_('draft'); |
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG') as $key) { |
186 |
$contenu[0][1]="new"; |
$const_name = 'STATUS_'.$key; |
187 |
$contenu[1][1]=_('new'); |
$const_value = constant("self::$const_name"); |
188 |
$contenu[0][2]="pending"; |
$contenu[0][] = $const_value; |
189 |
$contenu[1][2]=_('pending'); |
$contenu[1][] = __($const_value); |
190 |
$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'); |
|
191 |
|
|
192 |
$form->setSelect("state", $contenu); |
$form->setSelect("state", $contenu); |
193 |
|
|
206 |
"obj" => "dossier", |
"obj" => "dossier", |
207 |
"idx" => $form->val['dossier'], |
"idx" => $form->val['dossier'], |
208 |
)); |
)); |
209 |
|
|
210 |
if($form->val['type'] == "creation_DA"){ |
if($form->val['type'] == "creation_DA"){ |
211 |
$obj_link = 'dossier_autorisation'; |
$obj_link = 'dossier_autorisation'; |
212 |
} else { |
} else { |
238 |
} |
} |
239 |
} |
} |
240 |
|
|
241 |
|
function setLib(&$form, $maj) { |
242 |
|
parent::setLib($form, $maj); |
243 |
|
|
244 |
|
// Récupération du mode de l'action |
245 |
|
$crud = $this->get_action_crud($maj); |
246 |
|
|
247 |
|
// MODE different de CREER |
248 |
|
if ($maj != 0 || $crud != 'create') { |
249 |
|
$form->setLib('json_payload', ''); |
250 |
|
} |
251 |
|
} |
252 |
|
|
253 |
public function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
public function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
254 |
parent::verifier($val, $dnu1, $dnu2); |
$ret = parent::verifier($val, $dnu1, $dnu2); |
255 |
// |
|
256 |
if (array_key_exists('timestamp_log', $this->valF) === true |
// une tâche entrante doit avoir un type et une payload non-vide |
257 |
&& is_array(json_decode($this->valF['timestamp_log'], true)) === false) { |
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
258 |
// |
if (isset($this->valF['type']) === false) { |
259 |
$this->correct = false; |
$this->correct = false; |
260 |
$this->addToMessage(sprintf( |
$this->addToMessage(sprintf( |
261 |
__("Le champ %s doit être dans un format JSON valide."), |
__("Le champ %s est obligatoire pour une tâche entrante."), |
262 |
sprintf('<span class="bold">%s</span>', $this->getLibFromField('timestamp_log')) |
sprintf('<span class="bold">%s</span>', $this->getLibFromField('type')) |
263 |
)); |
)); |
264 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
265 |
|
} |
266 |
|
if (isset($this->valF['json_payload']) === false) { |
267 |
|
$this->correct = false; |
268 |
|
$this->addToMessage(sprintf( |
269 |
|
__("Le champ %s est obligatoire pour une tâche entrante."), |
270 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
271 |
|
)); |
272 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
273 |
|
} |
274 |
|
} |
275 |
|
|
276 |
|
// les JSONs doivent être décodables |
277 |
|
foreach(array('json_payload', 'timestamp_log') as $key) { |
278 |
|
if (isset($this->valF[$key]) && ! empty($this->valF[$key]) && ( |
279 |
|
is_array(json_decode($this->valF[$key], true)) === false |
280 |
|
|| json_last_error() !== JSON_ERROR_NONE)) { |
281 |
|
$this->correct = false; |
282 |
|
$champ_text = sprintf('<span class="bold">%s</span>', $this->getLibFromField($key)); |
283 |
|
$this->addToMessage(sprintf( |
284 |
|
__("Le champ %s doit être dans un format JSON valide (erreur: %s).". |
285 |
|
"<p>%s valF:</br><pre>%s</pre></p>". |
286 |
|
"<p>%s val:</br><pre>%s</pre></p>". |
287 |
|
"<p>%s POST:</br><pre>%s</pre></p>". |
288 |
|
"<p>%s submitted POST value:</br><pre>%s</pre></p>"), |
289 |
|
$champ_text, |
290 |
|
json_last_error() !== JSON_ERROR_NONE ? json_last_error_msg() : __('invalide'), |
291 |
|
$champ_text, |
292 |
|
$this->valF[$key], |
293 |
|
$champ_text, |
294 |
|
$val[$key], |
295 |
|
$champ_text, |
296 |
|
isset($_POST[$key]) ? $_POST[$key] : '', |
297 |
|
$champ_text, |
298 |
|
$this->f->get_submitted_post_value($key) |
299 |
|
)); |
300 |
|
$this->addToLog(__METHOD__.'(): erreur JSON: '.$this->msg, DEBUG_MODE); |
301 |
|
} |
302 |
|
} |
303 |
|
|
304 |
|
// une tâche entrante doit avoir une payload avec les clés requises |
305 |
|
if ($this->correct && (isset($this->valF['stream']) === false || |
306 |
|
$this->valF['stream'] == 'input')) { |
307 |
|
|
308 |
|
// décode la payload JSON |
309 |
|
$json_payload = json_decode($this->valF['json_payload'], true); |
310 |
|
|
311 |
|
// défini une liste de chemin de clés requises |
312 |
|
$paths = array( |
313 |
|
'external_uids/dossier' |
314 |
|
); |
315 |
|
|
316 |
|
// tâche de type création de DI/DA |
317 |
|
if (isset($this->valF['type']) !== false && $this->valF['type'] == 'create_DI_for_consultation') { |
318 |
|
|
319 |
|
$paths = array_merge($paths, array( |
320 |
|
'dossier/dossier', |
321 |
|
'dossier/dossier_autorisation_type_detaille_code', |
322 |
|
'dossier/date_demande', |
323 |
|
'dossier/depot_electronique', |
324 |
|
)); |
325 |
|
|
326 |
|
// si l'option commune est activée (mode MC) |
327 |
|
if ($this->f->is_option_dossier_commune_enabled()) { |
328 |
|
$paths[] = 'dossier/insee'; |
329 |
|
} |
330 |
|
|
331 |
|
// présence d'un moyen d'identifier la collectivité/le service |
332 |
|
if (! isset($json_payload['external_uids']['acteur']) && |
333 |
|
! isset($json_payload['dossier']['om_collectivite'])) { |
334 |
|
$this->correct = false; |
335 |
|
$this->addToMessage(sprintf( |
336 |
|
__("L'une des clés %s ou %s est obligatoire dans le contenu du champ %s pour une tâche entrante."), |
337 |
|
sprintf('<span class="bold">%s</span>', 'external_uids/acteur'), |
338 |
|
sprintf('<span class="bold">%s</span>', 'dossier/om_collectivite'), |
339 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
340 |
|
)); |
341 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
342 |
|
} |
343 |
|
} |
344 |
|
|
345 |
|
// pas d'erreur déjà trouvée |
346 |
|
if($this->correct) { |
347 |
|
|
348 |
|
// pour chaque chemin |
349 |
|
foreach($paths as $path) { |
350 |
|
|
351 |
|
// décompose le chemin |
352 |
|
$tokens = explode('/', $path); |
353 |
|
$cur_depth = $json_payload; |
354 |
|
|
355 |
|
// descend au et à mesure dans l'arborescence du chemin |
356 |
|
foreach($tokens as $token) { |
357 |
|
|
358 |
|
// en vérifiant que chaque élément du chemin est défini et non-nul |
359 |
|
if (isset($cur_depth[$token]) === false) { |
360 |
|
|
361 |
|
// sinon on produit une erreur |
362 |
|
$this->correct = false; |
363 |
|
$this->addToMessage(sprintf( |
364 |
|
__("La clé %s est obligatoire dans le contenu du champ %s pour une tâche entrante."), |
365 |
|
sprintf('<span class="bold">%s</span>', $path), |
366 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
367 |
|
)); |
368 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
369 |
|
break 2; |
370 |
|
} |
371 |
|
$cur_depth = $cur_depth[$token]; |
372 |
|
} |
373 |
|
} |
374 |
|
} |
375 |
} |
} |
376 |
|
|
377 |
|
return $ret && $this->correct; |
378 |
} |
} |
379 |
|
|
380 |
protected function task_exists(string $type, string $object_id) { |
protected function task_exists(string $type, string $object_id) { |
386 |
AND object_id = \'%4$s\' |
AND object_id = \'%4$s\' |
387 |
', |
', |
388 |
DB_PREFIXE, |
DB_PREFIXE, |
389 |
'done', |
self::STATUS_DONE, |
390 |
$type, |
$type, |
391 |
$object_id |
$object_id |
392 |
); |
); |
398 |
} |
} |
399 |
|
|
400 |
/** |
/** |
401 |
|
* TRIGGER - triggerajouter. |
402 |
|
* |
403 |
|
* @param string $id |
404 |
|
* @param null &$dnu1 @deprecated Ne pas utiliser. |
405 |
|
* @param array $val Tableau des valeurs brutes. |
406 |
|
* @param null $dnu2 @deprecated Ne pas utiliser. |
407 |
|
* |
408 |
|
* @return boolean |
409 |
|
*/ |
410 |
|
function triggerajouter($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
411 |
|
|
412 |
|
// tâche entrante |
413 |
|
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
414 |
|
|
415 |
|
// décode la paylod JSON pour extraire les données métiers à ajouter |
416 |
|
// en tant que métadonnées de la tâche |
417 |
|
$json_payload = json_decode($this->valF['json_payload'], true); |
418 |
|
|
419 |
|
// si la tâche possède déjà une clé dossier |
420 |
|
if (isset($json_payload['dossier']['dossier']) && |
421 |
|
! empty($json_payload['dossier']['dossier'])) { |
422 |
|
$this->valF["dossier"] = $json_payload['dossier']['dossier']; |
423 |
|
} |
424 |
|
} |
425 |
|
} |
426 |
|
|
427 |
|
/** |
428 |
* TREATMENT - add_task |
* TREATMENT - add_task |
429 |
* Ajoute un enregistrement. |
* Ajoute un enregistrement. |
430 |
* |
* |
433 |
*/ |
*/ |
434 |
public function add_task($params = array()) { |
public function add_task($params = array()) { |
435 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
436 |
|
|
437 |
|
// Vérifie si la task doit être ajoutée en fonction du mode de l'application, |
438 |
|
// seulement pour les tasks output |
439 |
|
$task_types_si = self::TASK_TYPE_SI; |
440 |
|
$task_types_sc = self::TASK_TYPE_SC; |
441 |
|
$stream = isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output'; |
442 |
|
if ($stream === 'output' |
443 |
|
&& isset($params['val']['type']) === true |
444 |
|
&& $this->f->is_option_mode_service_consulte_enabled() === true |
445 |
|
&& in_array($params['val']['type'], $task_types_sc) === false) { |
446 |
|
// |
447 |
|
return $this->end_treatment(__METHOD__, true); |
448 |
|
} |
449 |
|
if ($stream === 'output' |
450 |
|
&& isset($params['val']['type']) === true |
451 |
|
&& $this->f->is_option_mode_service_consulte_enabled() === false |
452 |
|
&& in_array($params['val']['type'], $task_types_si) === false) { |
453 |
|
// |
454 |
|
return $this->end_treatment(__METHOD__, true); |
455 |
|
} |
456 |
|
|
457 |
$timestamp_log = json_encode(array( |
$timestamp_log = json_encode(array( |
458 |
'creation_date' => date('Y-m-d H:i:s'), |
'creation_date' => date('Y-m-d H:i:s'), |
459 |
)); |
)); |
460 |
|
|
461 |
|
// Si la tâche est de type ajout_piece et de stream input alors on ajoute le fichier |
462 |
|
// et on ajoute l'uid dans le champ json_payload avant l'ajout de la tâche |
463 |
|
if (isset($params['val']['type']) |
464 |
|
&& ($params['val']['type'] == "add_piece" || $params['val']['type'] == "avis_consultation") |
465 |
|
&& isset($params['val']['stream']) |
466 |
|
&& $params['val']['stream'] == "input" ) { |
467 |
|
// |
468 |
|
$json_payload = json_decode($params['val']['json_payload'], true); |
469 |
|
if (json_last_error() !== JSON_ERROR_NONE) { |
470 |
|
$this->addToMessage(__("Le contenu JSON de la tâche n'est pas valide.")); |
471 |
|
return $this->end_treatment(__METHOD__, false); |
472 |
|
} |
473 |
|
if (isset($json_payload['document_numerise']) === true |
474 |
|
&& empty($json_payload['document_numerise']) === false) { |
475 |
|
// |
476 |
|
$document_numerise = $json_payload['document_numerise']; |
477 |
|
$file_content = base64_decode($document_numerise["file_content"]); |
478 |
|
if ($file_content === false){ |
479 |
|
$this->addToMessage(__("Le contenu du fichier lié à la tâche n'a pas pu etre recupere.")); |
480 |
|
return $this->end_treatment(__METHOD__, false); |
481 |
|
} |
482 |
|
$metadata = array( |
483 |
|
"filename" => $document_numerise['nom_fichier'], |
484 |
|
"size" => strlen($file_content), |
485 |
|
"mimetype" => $document_numerise['file_content_type'], |
486 |
|
"date_creation" => isset($document_numerise['date_creation']) === true ? $document_numerise['date_creation'] : date("Y-m-d"), |
487 |
|
); |
488 |
|
$uid_fichier = $this->f->storage->create($file_content, $metadata, "from_content", "task.uid_fichier"); |
489 |
|
if ($uid_fichier === OP_FAILURE) { |
490 |
|
$this->addToMessage(__("Erreur lors de la creation du fichier lié à la tâche.")); |
491 |
|
return $this->end_treatment(__METHOD__, false); |
492 |
|
} |
493 |
|
$json_payload["document_numerise"]["uid"] = $uid_fichier; |
494 |
|
// Le fichier a été ajouté nous n'avons plus besoin du champ file_content dans la payload |
495 |
|
unset($json_payload["document_numerise"]["file_content"]); |
496 |
|
$params['val']['json_payload'] = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
497 |
|
} |
498 |
|
} |
499 |
|
|
500 |
// Mise à jour du DI |
// Mise à jour du DI |
501 |
$valF = array( |
$valF = array( |
502 |
'task' => '', |
'task' => '', |
503 |
'type' => $params['val']['type'], |
'type' => $params['val']['type'], |
504 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
505 |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : 'new', |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : self::STATUS_NEW, |
506 |
'object_id' => $params['val']['object_id'], |
'object_id' => isset($params['val']['object_id']) ? $params['val']['object_id'] : '', |
507 |
'dossier' => $params['val']['dossier'], |
'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '', |
508 |
'stream' => isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output', |
'stream' => $stream, |
509 |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
510 |
); |
); |
511 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
|
512 |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
// tâche sortante |
513 |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
if($valF["stream"] == "output"){ |
514 |
} |
|
515 |
if ($task_exists !== false) { |
// TODO expliquer ce code |
516 |
$inst_task = $this->f->get_inst__om_dbform(array( |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
517 |
"obj" => "task", |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
518 |
"idx" => $task_exists, |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
519 |
)); |
} |
520 |
$update_state = $inst_task->getVal('state'); |
if ($task_exists !== false) { |
521 |
if (isset($params['update_val']['state']) === true) { |
$inst_task = $this->f->get_inst__om_dbform(array( |
522 |
$update_state = $params['update_val']['state']; |
"obj" => "task", |
523 |
|
"idx" => $task_exists, |
524 |
|
)); |
525 |
|
$update_state = $inst_task->getVal('state'); |
526 |
|
if (isset($params['update_val']['state']) === true) { |
527 |
|
$update_state = $params['update_val']['state']; |
528 |
|
} |
529 |
|
$update_params = array( |
530 |
|
'val' => array( |
531 |
|
'state' => $update_state, |
532 |
|
), |
533 |
|
); |
534 |
|
return $inst_task->update_task($update_params); |
535 |
} |
} |
|
$update_params = array( |
|
|
'val' => array( |
|
|
'state' => $update_state, |
|
|
), |
|
|
); |
|
|
return $inst_task->update_task($update_params); |
|
536 |
} |
} |
537 |
|
|
538 |
$add = $this->ajouter($valF); |
$add = $this->ajouter($valF); |
539 |
|
$this->addToLog(__METHOD__."(): retour de l'ajout de tâche: ".var_export($add, true), VERBOSE_MODE); |
540 |
if ($add === false) { |
if ($add === false) { |
541 |
$this->addToLog($this->msg, DEBUG_MODE); |
$this->addToLog(__METHOD__."(): ".$this->msg, DEBUG_MODE); |
542 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
543 |
} |
} |
544 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
555 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
556 |
$timestamp_log = $this->get_timestamp_log(); |
$timestamp_log = $this->get_timestamp_log(); |
557 |
if ($timestamp_log === false) { |
if ($timestamp_log === false) { |
558 |
$this->addToLog(__('XXX'), DEBUG_MODE); |
$this->addToLog(__METHOD__."(): erreur timestamp log", DEBUG_MODE); |
559 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
560 |
} |
} |
561 |
array_push($timestamp_log, array( |
array_push($timestamp_log, array( |
585 |
/** |
/** |
586 |
* 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 |
587 |
* l'enregistrement instancié. |
* l'enregistrement instancié. |
588 |
* |
* |
589 |
* @param array $params Tableau des paramètres |
* @param array $params Tableau des paramètres |
590 |
* @return array sinon false en cas d'erreur |
* @return array sinon false en cas d'erreur |
591 |
*/ |
*/ |
643 |
$list_tasks = array(); |
$list_tasks = array(); |
644 |
foreach ($res['result'] as $task) { |
foreach ($res['result'] as $task) { |
645 |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
646 |
$task['dossier'] = $task['object_id']; |
$task['dossier'] = $task['dossier']; |
647 |
if ($this->get_lien_objet_by_type($task['type']) === 'document_numerise') { |
if ($task['type'] === 'ajout_piece') { |
648 |
$val_dn = $this->get_document_numerise_data($task['object_id']); |
$val_dn = $this->get_document_numerise_data($task['object_id']); |
649 |
$task['dossier'] = $val_dn['dossier']; |
} |
650 |
|
if ($task['stream'] === 'output') { |
651 |
|
$task['external_uids'] = $this->get_all_external_uids($task['dossier']); |
652 |
} |
} |
653 |
$list_tasks[$task['task']] = $task; |
$list_tasks[$task['task']] = $task; |
654 |
} |
} |
791 |
return $val_dt; |
return $val_dt; |
792 |
} |
} |
793 |
|
|
794 |
|
/** |
795 |
|
* Récupère la liste des objets distincts existants dans la table des liens |
796 |
|
* entre identifiants internes et identifiants externes. |
797 |
|
* |
798 |
|
* @return array |
799 |
|
*/ |
800 |
|
protected function get_list_distinct_objects_external_link() { |
801 |
|
$query = sprintf(' |
802 |
|
SELECT |
803 |
|
DISTINCT(object) |
804 |
|
FROM %1$slien_id_interne_uid_externe |
805 |
|
ORDER BY object ASC |
806 |
|
', |
807 |
|
DB_PREFIXE |
808 |
|
); |
809 |
|
$res = $this->f->get_all_results_from_db_query($query, true); |
810 |
|
if ($res['code'] === 'KO') { |
811 |
|
return array(); |
812 |
|
} |
813 |
|
$result = array(); |
814 |
|
foreach ($res['result'] as $object) { |
815 |
|
$result[] = $object['object']; |
816 |
|
} |
817 |
|
return $result; |
818 |
|
} |
819 |
|
|
820 |
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
821 |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
822 |
"obj" => "lien_id_interne_uid_externe", |
"obj" => "lien_id_interne_uid_externe", |
828 |
return $inst_external_uid->getVal('external_uid'); |
return $inst_external_uid->getVal('external_uid'); |
829 |
} |
} |
830 |
|
|
831 |
|
protected function get_all_external_uids($fk_idx, $link_objects = array()) { |
832 |
|
if (count($link_objects) == 0) { |
833 |
|
$link_objects = $this->get_list_distinct_objects_external_link(); |
834 |
|
} |
835 |
|
$val_external_uid = array(); |
836 |
|
foreach ($link_objects as $link_object) { |
837 |
|
$external_uid = $this->get_external_uid($fk_idx, $link_object); |
838 |
|
if ($external_uid !== '' && $external_uid !== null) { |
839 |
|
$val_external_uid[$link_object] = $external_uid; |
840 |
|
} |
841 |
|
} |
842 |
|
return $val_external_uid; |
843 |
|
} |
844 |
|
|
845 |
protected function get_demandeurs_data(string $dossier) { |
protected function get_demandeurs_data(string $dossier) { |
846 |
$val_demandeur = array(); |
$val_demandeur = array(); |
847 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
874 |
return $val_architecte; |
return $val_architecte; |
875 |
} |
} |
876 |
|
|
877 |
protected function get_instruction_data(string $dossier, $type = 'decision') { |
protected function get_instruction_data(string $dossier, $type = 'decision', $extra_params = array()) { |
878 |
$val_instruction = null; |
$val_instruction = null; |
879 |
$instruction_with_doc = null; |
$instruction_with_doc = null; |
880 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
888 |
if ($type === 'incompletude') { |
if ($type === 'incompletude') { |
889 |
$idx = $inst_di->get_last_instruction_incompletude(); |
$idx = $inst_di->get_last_instruction_incompletude(); |
890 |
} |
} |
891 |
|
// XXX Permet de récupérer l'instruction par son identifiant |
892 |
|
if ($type === 'with-id') { |
893 |
|
$idx = $extra_params['with-id']; |
894 |
|
} |
895 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
896 |
"obj" => "instruction", |
"obj" => "instruction", |
897 |
"idx" => $idx, |
"idx" => $idx, |
937 |
|
|
938 |
protected function sort_instruction_data(array $values, array $res) { |
protected function sort_instruction_data(array $values, array $res) { |
939 |
$fields = array( |
$fields = array( |
940 |
|
"date_evenement", |
941 |
"date_envoi_signature", |
"date_envoi_signature", |
942 |
"date_retour_signature", |
"date_retour_signature", |
943 |
"date_envoi_rar", |
"date_envoi_rar", |
998 |
return $val_dp; |
return $val_dp; |
999 |
} |
} |
1000 |
|
|
1001 |
|
protected function get_avis_decision_data(string $dossier) { |
1002 |
|
$inst_di = $this->f->get_inst__om_dbform(array( |
1003 |
|
"obj" => "dossier", |
1004 |
|
"idx" => $dossier, |
1005 |
|
)); |
1006 |
|
$ad = $inst_di->getVal('avis_decision'); |
1007 |
|
$val_ad = array(); |
1008 |
|
if ($ad !== null) { |
1009 |
|
$inst_ad = $this->f->get_inst__om_dbform(array( |
1010 |
|
"obj" => "avis_decision", |
1011 |
|
"idx" => $ad, |
1012 |
|
)); |
1013 |
|
$val_ad = $inst_ad->get_json_data(); |
1014 |
|
$val_ad['txAvis'] = "Voir document joint"; |
1015 |
|
if (isset($val_ad['tacite']) === true |
1016 |
|
&& $val_ad['tacite'] === 't') { |
1017 |
|
// |
1018 |
|
$val_ad['txAvis'] = "Sans objet"; |
1019 |
|
} |
1020 |
|
} |
1021 |
|
return $val_ad; |
1022 |
|
} |
1023 |
|
|
1024 |
|
protected function get_signataire_arrete_data(string $sa) { |
1025 |
|
$inst_sa = $this->f->get_inst__om_dbform(array( |
1026 |
|
"obj" => "signataire_arrete", |
1027 |
|
"idx" => $sa, |
1028 |
|
)); |
1029 |
|
$val_sa = array_combine($inst_sa->champs, $inst_sa->val); |
1030 |
|
foreach ($val_sa as $key => $value) { |
1031 |
|
$val_sa[$key] = strip_tags($value); |
1032 |
|
} |
1033 |
|
return $val_sa; |
1034 |
|
} |
1035 |
|
|
1036 |
|
// XXX WIP |
1037 |
|
protected function get_consultation_data(string $consultation) { |
1038 |
|
$val_consultation = array(); |
1039 |
|
$inst_consultation = $this->f->get_inst__om_dbform(array( |
1040 |
|
"obj" => "consultation", |
1041 |
|
"idx" => $consultation, |
1042 |
|
)); |
1043 |
|
$val_consultation = $inst_consultation->get_json_data(); |
1044 |
|
if (isset($val_consultation['fichier']) === true |
1045 |
|
&& $val_consultation['fichier'] !== '') { |
1046 |
|
// |
1047 |
|
$val_consultation['path_fichier'] = sprintf('%s&snippet=%s&obj=%s&champ=%s&id=%s', 'app/index.php?module=form', 'file', 'consultation', 'fichier', $this->getVal('object_id')); |
1048 |
|
} |
1049 |
|
if (isset($val_consultation['om_fichier_consultation']) === true |
1050 |
|
&& $val_consultation['om_fichier_consultation'] !== '') { |
1051 |
|
// |
1052 |
|
$val_consultation['path_om_fichier_consultation'] = sprintf('%s&snippet=%s&obj=%s&champ=%s&id=%s', 'app/index.php?module=form', 'file', 'consultation', 'om_fichier_consultation', $this->getVal('object_id')); |
1053 |
|
} |
1054 |
|
return $val_consultation; |
1055 |
|
} |
1056 |
|
|
1057 |
|
// XXX WIP |
1058 |
|
protected function get_service_data(string $service) { |
1059 |
|
$val_service = array(); |
1060 |
|
$inst_service = $this->f->get_inst__om_dbform(array( |
1061 |
|
"obj" => "service", |
1062 |
|
"idx" => $service, |
1063 |
|
)); |
1064 |
|
$val_service = $inst_service->get_json_data(); |
1065 |
|
return $val_service; |
1066 |
|
} |
1067 |
|
|
1068 |
protected function view_form_json($in_field = false) { |
protected function view_form_json($in_field = false) { |
1069 |
// |
// |
1070 |
if ($this->f->get_submitted_post_value('valid') === null) { |
if ($this->f->get_submitted_post_value('valid') === null) { |
1084 |
$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']); |
1085 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1086 |
$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'); |
1087 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1088 |
} |
} |
1089 |
// |
// |
1090 |
if ($this->getVal('type') === 'creation_DI' |
if ($this->getVal('type') === 'creation_DI' |
1100 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1101 |
$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'); |
1102 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1103 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1104 |
} |
} |
1105 |
// |
// |
1106 |
if ($this->getVal('type') === 'qualification_DI') { |
if ($this->getVal('type') === 'qualification_DI') { |
1108 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1109 |
$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'); |
1110 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1111 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1112 |
} |
} |
1113 |
// |
// |
1114 |
if ($this->getVal('type') === 'ajout_piece') { |
if ($this->getVal('type') === 'ajout_piece') { |
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['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'); |
1121 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1122 |
} |
} |
1123 |
// |
// |
1124 |
if ($this->getVal('type') === 'decision_DI') { |
if ($this->getVal('type') === 'decision_DI') { |
1125 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1126 |
$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'))); |
1127 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1128 |
$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'); |
1129 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1130 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1131 |
} |
} |
1132 |
// |
// |
1133 |
if ($this->getVal('type') === 'incompletude_DI') { |
if ($this->getVal('type') === 'incompletude_DI') { |
1134 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1135 |
$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'))); |
1136 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1137 |
$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'); |
1138 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1139 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1140 |
} |
} |
1141 |
// |
// |
1142 |
if ($this->getVal('type') === 'completude_DI') { |
if ($this->getVal('type') === 'completude_DI') { |
1143 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1144 |
$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'))); |
1145 |
|
$val_external_uid = array(); |
1146 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1147 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1148 |
|
$val['external_uids'] = $val_external_uid; |
1149 |
|
} |
1150 |
|
// |
1151 |
|
if ($this->getVal('type') === 'pec_metier_consultation') { |
1152 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1153 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1154 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1155 |
$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'); |
1156 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1157 |
$val['external_uid'] = $val_external_uid; |
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
1158 |
|
$val['external_uids'] = $val_external_uid; |
1159 |
|
} |
1160 |
|
// |
1161 |
|
if ($this->getVal('type') === 'avis_consultation') { |
1162 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1163 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1164 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
1165 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
1166 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
1167 |
|
} |
1168 |
|
$val_external_uid = array(); |
1169 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1170 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1171 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
1172 |
|
$val['external_uids'] = $val_external_uid; |
1173 |
|
} |
1174 |
|
// XXX WIP |
1175 |
|
if ($this->getVal('type') === 'creation_consultation') { |
1176 |
|
// |
1177 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1178 |
|
$val['consultation'] = $this->get_consultation_data($this->getVal('object_id')); |
1179 |
|
$val['service'] = $this->get_service_data($val['consultation']['service']); |
1180 |
|
$val_external_uid = array(); |
1181 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1182 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1183 |
|
$val['external_uids'] = $val_external_uid; |
1184 |
} |
} |
1185 |
|
|
1186 |
if ($in_field === true) { |
if ($in_field === true) { |
1187 |
return json_encode($val, JSON_PRETTY_PRINT ,JSON_UNESCAPED_SLASHES); |
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
1188 |
} else { |
} else { |
1189 |
// Liste des valeurs affichée en JSON |
// Liste des valeurs affichée en JSON |
1190 |
printf(json_encode($val, JSON_UNESCAPED_SLASHES)); |
printf(json_encode($val, JSON_UNESCAPED_SLASHES)); |
1192 |
} |
} |
1193 |
} |
} |
1194 |
|
|
1195 |
function view_update_json_data() { |
function post_update_task() { |
1196 |
// Mise à jour des valeurs |
// Mise à jour des valeurs |
1197 |
// |
|
1198 |
$params = array( |
// Modification de l'état de la tâche |
1199 |
'val' => array( |
if ($this->f->get_submitted_post_value('state') !== null) { |
1200 |
'state' => $this->f->get_submitted_post_value('state') |
$params = array( |
1201 |
), |
'val' => array( |
1202 |
); |
'state' => $this->f->get_submitted_post_value('state') |
1203 |
$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.') |
|
1204 |
); |
); |
1205 |
|
$update = $this->update_task($params); |
1206 |
|
$message_class = "valid"; |
1207 |
|
$message = $this->msg; |
1208 |
|
if ($update === false) { |
1209 |
|
$this->addToLog($this->msg, DEBUG_MODE); |
1210 |
|
$message_class = "error"; |
1211 |
|
$message = sprintf( |
1212 |
|
'%s %s', |
1213 |
|
__('Impossible de mettre à jour la tâche.'), |
1214 |
|
__('Veuillez contacter votre administrateur.') |
1215 |
|
); |
1216 |
|
} |
1217 |
|
$this->f->displayMessage($message_class, $message); |
1218 |
} |
} |
1219 |
$this->f->displayMessage($message_class, $message); |
|
1220 |
// |
// Sauvegarde de l'uid externe retourné |
1221 |
$inst_lien = $this->f->get_inst__om_dbform(array( |
if ($this->f->get_submitted_post_value('external_uid') !== null) { |
1222 |
"obj" => "lien_id_interne_uid_externe", |
// |
1223 |
"idx" => ']', |
$objects = $this->get_objects_by_task_type($this->getVal('type'), $this->getVal('stream')); |
1224 |
|
foreach ($objects as $object) { |
1225 |
|
$inst_lien = $this->f->get_inst__om_dbform(array( |
1226 |
|
"obj" => "lien_id_interne_uid_externe", |
1227 |
|
"idx" => ']', |
1228 |
|
)); |
1229 |
|
if ($inst_lien->is_exists($object, $this->getVal('object_id'), $this->f->get_submitted_post_value('external_uid'), $this->getVal('dossier')) === false) { |
1230 |
|
$valF = array( |
1231 |
|
'lien_id_interne_uid_externe' => '', |
1232 |
|
'object' => $object, |
1233 |
|
'object_id' => $this->getVal('object_id'), |
1234 |
|
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
1235 |
|
'dossier' => $this->getVal('dossier'), |
1236 |
|
); |
1237 |
|
$add = $inst_lien->ajouter($valF); |
1238 |
|
$message_class = "valid"; |
1239 |
|
$message = $inst_lien->msg; |
1240 |
|
if ($add === false) { |
1241 |
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
1242 |
|
$message_class = "error"; |
1243 |
|
$message = sprintf( |
1244 |
|
'%s %s', |
1245 |
|
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
1246 |
|
__('Veuillez contacter votre administrateur.') |
1247 |
|
); |
1248 |
|
} |
1249 |
|
$this->f->displayMessage($message_class, $message); |
1250 |
|
} |
1251 |
|
} |
1252 |
|
} |
1253 |
|
} |
1254 |
|
|
1255 |
|
function post_add_task() { |
1256 |
|
// TODO Tester de remplacer la ligne de json_payload par un $_POST |
1257 |
|
$result = $this->add_task(array( |
1258 |
|
'val' => array( |
1259 |
|
'stream' => 'input', |
1260 |
|
'json_payload' => html_entity_decode($this->f->get_submitted_post_value('json_payload')), |
1261 |
|
'type' => $this->f->get_submitted_post_value('type'), |
1262 |
|
) |
1263 |
)); |
)); |
1264 |
$valF = array( |
$message = sprintf( |
1265 |
'lien_id_interne_uid_externe' => '', |
__("Tâche %s ajoutée avec succès"), |
1266 |
'object' => $this->get_lien_objet_by_type($this->getVal('type')), |
$this->getVal($this->clePrimaire)). |
1267 |
'object_id' => $this->getVal('object_id'), |
'<br/><br/>'. |
1268 |
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
$this->msg; |
|
); |
|
|
$add = $inst_lien->ajouter($valF); |
|
1269 |
$message_class = "valid"; |
$message_class = "valid"; |
1270 |
$message = $inst_lien->msg; |
if ($result === false){ |
1271 |
if ($add === false) { |
$this->addToLog($this->msg, DEBUG_MODE); |
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
|
1272 |
$message_class = "error"; |
$message_class = "error"; |
1273 |
$message = sprintf( |
$message = sprintf( |
1274 |
'%s %s', |
'%s %s', |
1275 |
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
__('Impossible d\'ajouter la tâche.'), |
1276 |
__('Veuillez contacter votre administrateur.') |
__('Veuillez contacter votre administrateur.') |
1277 |
); |
); |
1278 |
} |
} |
1279 |
$this->f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
1280 |
} |
} |
1281 |
|
|
1282 |
function view_add_json_data() { |
function setLayout(&$form, $maj) { |
|
$params = array(); |
|
|
$params['val']['stream'] = 'input'; |
|
|
$params['val']['type'] = $this->f->get_submitted_post_value('type'); |
|
|
$params['val']['object_id'] = $this->f->get_submitted_post_value('object_id'); |
|
|
$params['val']['dossier'] = $this->f->get_submitted_post_value('dossier'); |
|
|
$params['val']['json_payload'] = $this->f->get_submitted_post_value('json_payload'); |
|
|
$this->add_task($params); |
|
|
} |
|
1283 |
|
|
1284 |
protected function get_lien_objet_by_type($type) { |
// Récupération du mode de l'action |
1285 |
// |
$crud = $this->get_action_crud($maj); |
1286 |
$objet = ''; |
|
1287 |
if ($type === 'creation_DA') { |
// MODE different de CREER |
1288 |
$objet = 'dossier_autorisation'; |
if ($maj != 0 || $crud != 'create') { |
1289 |
} |
$form->setBloc('json_payload', 'D', '', 'col_6'); |
1290 |
if ($type === 'creation_DI' |
$form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed"); |
1291 |
|| $type === 'depot_DI' |
$form->setBloc('json_payload', 'F'); |
|
|| $type === 'modification_DI' |
|
|
|| $type === 'qualification_DI' |
|
|
|| $type === 'decision_DI' |
|
|
|| $type === 'incompletude_DI' |
|
|
|| $type === 'completude_DI') { |
|
|
// |
|
|
$objet = 'dossier'; |
|
|
} |
|
|
if ($type === 'ajout_piece') { |
|
|
$objet = 'document_numerise'; |
|
1292 |
} |
} |
1293 |
return $objet; |
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
1294 |
} |
} |
1295 |
|
|
1296 |
function setLayout(&$form, $maj) { |
/** |
1297 |
$form->setBloc('json_payload', 'D', '', 'col_6'); |
* [get_objects_by_task_type description] |
1298 |
$form->setFieldset('json_payload', 'DF', _("json_payload"), "collapsible, startClosed"); |
* @param [type] $type [description] |
1299 |
$form->setBloc('json_payload', 'F'); |
* @return [type] [description] |
1300 |
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
*/ |
1301 |
|
function get_objects_by_task_type($type, $stream = 'all') { |
1302 |
|
$objects = array(); |
1303 |
|
if (in_array($type, array('creation_DA', )) === true) { |
1304 |
|
$objects = array('dossier_autorisation', ); |
1305 |
|
} |
1306 |
|
if (in_array($type, array('creation_DI', 'depot_DI', 'notification_DI', 'qualification_DI', )) === true) { |
1307 |
|
$objects = array('dossier', ); |
1308 |
|
} |
1309 |
|
if (in_array($type, array('create_DI_for_consultation', )) === true) { |
1310 |
|
$objects = array('dossier', 'dossier_consultation', ); |
1311 |
|
} |
1312 |
|
if (in_array($type, array('create_DI', )) === true |
1313 |
|
&& $stream === 'input') { |
1314 |
|
$objects = array('dossier', 'dossier_autorisation', ); |
1315 |
|
} |
1316 |
|
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
1317 |
|
$objects = array('instruction', ); |
1318 |
|
} |
1319 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
1320 |
|
&& $stream === 'output') { |
1321 |
|
$objects = array('pec_dossier_consultation', ); |
1322 |
|
} |
1323 |
|
if (in_array($type, array('avis_consultation', )) === true |
1324 |
|
&& $stream === 'output') { |
1325 |
|
$objects = array('avis_dossier_consultation', ); |
1326 |
|
} |
1327 |
|
if (in_array($type, array('ajout_piece', 'add_piece', )) === true) { |
1328 |
|
$objects = array('piece', ); |
1329 |
|
} |
1330 |
|
if (in_array($type, array('creation_consultation', )) === true) { |
1331 |
|
$objects = array('consultation', ); |
1332 |
|
} |
1333 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
1334 |
|
&& $stream === 'input') { |
1335 |
|
$objects = array('pec_metier_consultation', ); |
1336 |
|
} |
1337 |
|
if (in_array($type, array('avis_consultation', )) === true |
1338 |
|
&& $stream === 'input') { |
1339 |
|
$objects = array('avis_consultation', ); |
1340 |
|
} |
1341 |
|
return $objects; |
1342 |
} |
} |
1343 |
|
|
1344 |
} |
} |