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 |
* |
* |
29 |
); |
); |
30 |
$this->class_actions[997] = array( |
$this->class_actions[997] = array( |
31 |
"identifier" => "json_data", |
"identifier" => "json_data", |
32 |
"view" => "view_update_json_data", |
"view" => "post_update_task", |
33 |
"permission_suffix" => "modifier", |
"permission_suffix" => "modifier", |
34 |
); |
); |
35 |
$this->class_actions[996] = array( |
$this->class_actions[996] = array( |
36 |
"identifier" => "json_data", |
"identifier" => "json_data", |
37 |
"view" => "view_add_json_data", |
"view" => "post_add_task", |
38 |
"permission_suffix" => "ajouter", |
"permission_suffix" => "ajouter", |
39 |
); |
); |
40 |
} |
} |
41 |
|
|
42 |
public function setvalF($val = array()) { |
public function setvalF($val = array()) { |
43 |
|
|
44 |
|
// // les guillets doubles sont remplacés automatiquement par des simples |
45 |
|
// // dans core/om_formulaire.clasS.php::recupererPostvar() |
46 |
|
// // voir le ticket https://dev.atreal.fr/projets/openmairie/tracker/209 |
47 |
|
// // ceci est un hack sale temporaire en attendant résolution du ticket |
48 |
|
// foreach(array('json_payload', 'timestamp_log') as $key) { |
49 |
|
// if (isset($val[$key]) && ! empty($val[$key]) && |
50 |
|
// isset($_POST[$key]) && ! empty($_POST[$key])) { |
51 |
|
// $submited_payload = $_POST[$key]; |
52 |
|
// if (! empty($submited_payload)) { |
53 |
|
// $new_payload = str_replace("'", '"', $val[$key]); |
54 |
|
// if ($new_payload == $submited_payload || |
55 |
|
// strpos($submited_payload, '"') === false) { |
56 |
|
// $val[$key] = $new_payload; |
57 |
|
// } |
58 |
|
// else { |
59 |
|
// $error_msg = sprintf( |
60 |
|
// __("La convertion des guillemets de la payload JSON '%s' ". |
61 |
|
// "n'est pas idempotente (courante: %s, postée: %s, convertie: %s)"), |
62 |
|
// $key, var_export($val[$key], true), var_export($submited_payload, true), |
63 |
|
// var_export($new_payload, true)); |
64 |
|
// $this->correct = false; |
65 |
|
// $this->addToMessage($error_msg); |
66 |
|
// $this->addToLog(__METHOD__."() erreur : $error_msg", DEBUG_MODE); |
67 |
|
// return false; |
68 |
|
// } |
69 |
|
// } |
70 |
|
// } |
71 |
|
// } |
72 |
|
|
73 |
parent::setvalF($val); |
parent::setvalF($val); |
74 |
// |
|
75 |
|
// XXX Ancien code : permet de ne pas avoir d'erreru lors de la modification d'une task |
76 |
if (array_key_exists('timestamp_log', $val) === true) { |
if (array_key_exists('timestamp_log', $val) === true) { |
77 |
$this->valF['timestamp_log'] = str_replace("'", '"', $val['timestamp_log']); |
$this->valF['timestamp_log'] = str_replace("'", '"', $val['timestamp_log']); |
78 |
} |
} |
79 |
|
|
80 |
|
// récupération de l'ID de l'objet existant |
81 |
|
$id = property_exists($this, 'id') ? $this->id : null; |
82 |
|
if(isset($val[$this->clePrimaire])) { |
83 |
|
$id = $val[$this->clePrimaire]; |
84 |
|
} elseif(isset($this->valF[$this->clePrimaire])) { |
85 |
|
$id = $this->valF[$this->clePrimaire]; |
86 |
|
} |
87 |
|
|
88 |
|
// MODE MODIFIER |
89 |
|
if (! empty($id)) { |
90 |
|
|
91 |
|
// si aucune payload n'est fourni (devrait toujours être le cas) |
92 |
|
if (! isset($val['json_payload']) || empty($val['json_payload'])) { |
93 |
|
|
94 |
|
// récupère l'objet existant |
95 |
|
$existing = $this->f->findObjectById(get_class($this), $id); |
96 |
|
if (! empty($existing)) { |
97 |
|
|
98 |
|
// récupère la payload de l'objet |
99 |
|
$val['json_payload'] = $existing->getVal('json_payload'); |
100 |
|
$this->valF['json_payload'] = $existing->getVal('json_payload'); |
101 |
|
$this->f->addToLog(__METHOD__."() récupère la payload de la tâche existante ". |
102 |
|
"'$id': ".$existing->getVal('json_payload'), EXTRA_VERBOSE_MODE); |
103 |
|
} |
104 |
|
} |
105 |
|
} |
106 |
} |
} |
107 |
|
|
108 |
/** |
/** |
124 |
|
|
125 |
function setType(&$form, $maj) { |
function setType(&$form, $maj) { |
126 |
parent::setType($form, $maj); |
parent::setType($form, $maj); |
127 |
|
|
128 |
// Récupération du mode de l'action |
// Récupération du mode de l'action |
129 |
$crud = $this->get_action_crud($maj); |
$crud = $this->get_action_crud($maj); |
130 |
|
|
131 |
if ($maj < 2) { |
// MODE CREER |
132 |
|
if ($maj == 0 || $crud == 'create') { |
133 |
|
$form->setType("state", "select"); |
134 |
|
$form->setType("stream", "select"); |
135 |
|
$form->setType("json_payload", "textarea"); |
136 |
|
} |
137 |
|
// MDOE MODIFIER |
138 |
|
if ($maj == 1 || $crud == 'update') { |
139 |
$form->setType("state", "select"); |
$form->setType("state", "select"); |
140 |
$form->setType("stream", "select"); |
$form->setType("stream", "select"); |
141 |
$form->setType("json_payload", "jsonprettyprint"); |
$form->setType("json_payload", "jsonprettyprint"); |
142 |
} |
} |
143 |
if ($maj == 3){ |
// MODE CONSULTER |
144 |
|
if ($maj == 3 || $crud == 'read') { |
145 |
$form->setType('dossier', 'link'); |
$form->setType('dossier', 'link'); |
146 |
$form->setType('json_payload', 'jsonprettyprint'); |
$form->setType('json_payload', 'jsonprettyprint'); |
147 |
} |
} |
153 |
*/ |
*/ |
154 |
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
155 |
if($maj < 2) { |
if($maj < 2) { |
|
$contenu=array(); |
|
156 |
|
|
157 |
$contenu[0][0]="draft"; |
$contenu = array(); |
158 |
$contenu[1][0]=_('draft'); |
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG') as $key) { |
159 |
$contenu[0][1]="new"; |
$const_name = 'STATUS_'.$key; |
160 |
$contenu[1][1]=_('new'); |
$const_value = constant("self::$const_name"); |
161 |
$contenu[0][2]="pending"; |
$contenu[0][] = $const_value; |
162 |
$contenu[1][2]=_('pending'); |
$contenu[1][] = __($const_value); |
163 |
$contenu[0][3]="done"; |
} |
|
$contenu[1][3]=_('done'); |
|
|
$contenu[0][4]="archived"; |
|
|
$contenu[1][4]=_('archived'); |
|
|
$contenu[0][5]="error"; |
|
|
$contenu[1][5]=_('error'); |
|
|
$contenu[0][6]="debug"; |
|
|
$contenu[1][6]=_('debug'); |
|
164 |
|
|
165 |
$form->setSelect("state", $contenu); |
$form->setSelect("state", $contenu); |
166 |
|
|
179 |
"obj" => "dossier", |
"obj" => "dossier", |
180 |
"idx" => $form->val['dossier'], |
"idx" => $form->val['dossier'], |
181 |
)); |
)); |
182 |
|
|
183 |
if($form->val['type'] == "creation_DA"){ |
if($form->val['type'] == "creation_DA"){ |
184 |
$obj_link = 'dossier_autorisation'; |
$obj_link = 'dossier_autorisation'; |
185 |
} else { |
} else { |
207 |
if ($this->getVal('stream') == "output") { |
if ($this->getVal('stream') == "output") { |
208 |
$form->setVal('json_payload', $this->view_form_json(true)); |
$form->setVal('json_payload', $this->view_form_json(true)); |
209 |
} else { |
} else { |
210 |
if ($this->getVal('type') == 'ajout_piece'){ |
$form->setVal('json_payload', htmlentities($this->getVal('json_payload'))); |
|
// On modifie la valeur du champ "file_content" afin de tronquer le base64 |
|
|
$json_payload = json_decode($this->getVal("json_payload"), true); |
|
|
$json_payload["document_numerise"]["file_content"] = substr($json_payload["document_numerise"]["file_content"], 0, 64)."[...]"; |
|
|
$json_payload_result = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); |
|
|
$form->setVal('json_payload', htmlentities($json_payload_result)); |
|
|
} else { |
|
|
// |
|
|
$form->setVal('json_payload', htmlentities($this->getVal('json_payload'))); |
|
|
} |
|
211 |
} |
} |
212 |
} |
} |
213 |
|
|
214 |
function setLib(&$form, $maj) { |
function setLib(&$form, $maj) { |
215 |
parent::setLib($form, $maj); |
parent::setLib($form, $maj); |
216 |
$form->setLib('json_payload', ''); |
|
217 |
|
// Récupération du mode de l'action |
218 |
|
$crud = $this->get_action_crud($maj); |
219 |
|
|
220 |
|
// MODE different de CREER |
221 |
|
if ($maj != 0 || $crud != 'create') { |
222 |
|
$form->setLib('json_payload', ''); |
223 |
|
} |
224 |
} |
} |
225 |
|
|
226 |
public function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
public function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
227 |
parent::verifier($val, $dnu1, $dnu2); |
$ret = parent::verifier($val, $dnu1, $dnu2); |
228 |
// |
|
229 |
if (array_key_exists('timestamp_log', $this->valF) === true |
// une tâche entrante doit avoir un type et une payload non-vide |
230 |
&& is_array(json_decode($this->valF['timestamp_log'], true)) === false) { |
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
231 |
// |
if (isset($this->valF['type']) === false) { |
232 |
$this->correct = false; |
$this->correct = false; |
233 |
$this->addToMessage(sprintf( |
$this->addToMessage(sprintf( |
234 |
__("Le champ %s doit être dans un format JSON valide."), |
__("Le champ %s est obligatoire pour une tâche entrante."), |
235 |
sprintf('<span class="bold">%s</span>', $this->getLibFromField('timestamp_log')) |
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['external_uids']['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>', 'external_uids/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 |
|
|
400 |
|
/** |
401 |
* TREATMENT - add_task |
* TREATMENT - add_task |
402 |
* Ajoute un enregistrement. |
* Ajoute un enregistrement. |
403 |
* |
* |
406 |
*/ |
*/ |
407 |
public function add_task($params = array()) { |
public function add_task($params = array()) { |
408 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
409 |
|
|
410 |
|
// Vérifie si la task doit être ajoutée en fonction du mode de l'application, |
411 |
|
// seulement pour les tasks output |
412 |
|
$task_types_si = array( |
413 |
|
'creation_DA', |
414 |
|
'creation_DI', |
415 |
|
'depot_DI', |
416 |
|
'modification_DI', |
417 |
|
'qualification_DI', |
418 |
|
'decision_DI', |
419 |
|
'incompletude_DI', |
420 |
|
'completude_DI', |
421 |
|
'ajout_piece', |
422 |
|
'add_piece', |
423 |
|
); |
424 |
|
$task_types_sc = array( |
425 |
|
'create_DI_for_consultation', |
426 |
|
'avis_consultation', |
427 |
|
'pec_metier_consultation', |
428 |
|
); |
429 |
|
$stream = isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output'; |
430 |
|
if ($stream === 'output' |
431 |
|
&& isset($params['val']['type']) === true |
432 |
|
&& $this->f->is_option_mode_service_consulte_enabled() === true |
433 |
|
&& in_array($params['val']['type'], $task_types_sc) === false) { |
434 |
|
// |
435 |
|
return $this->end_treatment(__METHOD__, true); |
436 |
|
} |
437 |
|
if ($stream === 'output' |
438 |
|
&& isset($params['val']['type']) === true |
439 |
|
&& $this->f->is_option_mode_service_consulte_enabled() === false |
440 |
|
&& in_array($params['val']['type'], $task_types_si) === false) { |
441 |
|
// |
442 |
|
return $this->end_treatment(__METHOD__, true); |
443 |
|
} |
444 |
|
|
445 |
$timestamp_log = json_encode(array( |
$timestamp_log = json_encode(array( |
446 |
'creation_date' => date('Y-m-d H:i:s'), |
'creation_date' => date('Y-m-d H:i:s'), |
447 |
)); |
)); |
448 |
|
|
449 |
|
// Si la tâche est de type ajout_piece et de stream input alors on ajoute le fichier |
450 |
|
// et on ajoute l'uid dans le champ json_payload avant l'ajout de la tâche |
451 |
|
if (isset($params['val']['type']) |
452 |
|
&& $params['val']['type'] == "add_piece" |
453 |
|
&& isset($params['val']['stream']) |
454 |
|
&& $params['val']['stream'] == "input" ) { |
455 |
|
// |
456 |
|
$json_payload = json_decode($params['val']['json_payload'], true); |
457 |
|
if (json_last_error() !== JSON_ERROR_NONE) { |
458 |
|
$this->addToMessage(__("Le contenu JSON de la tâche n'est pas valide.")); |
459 |
|
return $this->end_treatment(__METHOD__, false); |
460 |
|
} |
461 |
|
$document_numerise = $json_payload['document_numerise']; |
462 |
|
$file_content = base64_decode($document_numerise["file_content"]); |
463 |
|
if ($file_content === false){ |
464 |
|
$this->addToMessage(__("Le contenu du fichier lié à la tâche n'a pas pu etre recupere.")); |
465 |
|
return $this->end_treatment(__METHOD__, false); |
466 |
|
} |
467 |
|
$metadata = array( |
468 |
|
"filename" => $document_numerise['nom_fichier'], |
469 |
|
"size" => strlen($file_content), |
470 |
|
"mimetype" => $document_numerise['file_content_type'], |
471 |
|
"date_creation" => $document_numerise['date_creation'], |
472 |
|
); |
473 |
|
$uid_fichier = $this->f->storage->create($file_content, $metadata, "from_content"); |
474 |
|
if ($uid_fichier === OP_FAILURE) { |
475 |
|
$this->addToMessage(__("Erreur lors de la creation du fichier lié à la tâche.")); |
476 |
|
return $this->end_treatment(__METHOD__, false); |
477 |
|
} |
478 |
|
$json_payload["document_numerise"]["uid"] = $uid_fichier; |
479 |
|
// Le fichier a été ajouté nous n'avons plus besoin du champ file_content dans la payload |
480 |
|
unset($json_payload["document_numerise"]["file_content"]); |
481 |
|
$params['val']['json_payload'] = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
482 |
|
} |
483 |
|
|
484 |
// Mise à jour du DI |
// Mise à jour du DI |
485 |
$valF = array( |
$valF = array( |
486 |
'task' => '', |
'task' => '', |
487 |
'type' => $params['val']['type'], |
'type' => $params['val']['type'], |
488 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
489 |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : 'new', |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : self::STATUS_NEW, |
490 |
'object_id' => $params['val']['object_id'], |
'object_id' => isset($params['val']['object_id']) ? $params['val']['object_id'] : '', |
491 |
'dossier' => $params['val']['dossier'], |
'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '', |
492 |
'stream' => isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output', |
'stream' => $stream, |
493 |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
494 |
); |
); |
495 |
if($valF["stream"] != "input"){ |
|
496 |
|
// tâche sortante |
497 |
|
if($valF["stream"] == "output"){ |
498 |
|
|
499 |
|
// TODO expliquer ce code |
500 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
501 |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
502 |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
518 |
return $inst_task->update_task($update_params); |
return $inst_task->update_task($update_params); |
519 |
} |
} |
520 |
} |
} |
521 |
|
|
522 |
$add = $this->ajouter($valF); |
$add = $this->ajouter($valF); |
523 |
|
$this->addToLog(__METHOD__."(): retour de l'ajout de tâche: ".var_export($add, true), VERBOSE_MODE); |
524 |
if ($add === false) { |
if ($add === false) { |
525 |
$this->addToLog($this->msg, DEBUG_MODE); |
$this->addToLog(__METHOD__."(): ".$this->msg, DEBUG_MODE); |
526 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
527 |
} |
} |
528 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
539 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
540 |
$timestamp_log = $this->get_timestamp_log(); |
$timestamp_log = $this->get_timestamp_log(); |
541 |
if ($timestamp_log === false) { |
if ($timestamp_log === false) { |
542 |
$this->addToLog(__('XXX'), DEBUG_MODE); |
$this->addToLog(__METHOD__."(): erreur timestamp log", DEBUG_MODE); |
543 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
544 |
} |
} |
545 |
array_push($timestamp_log, array( |
array_push($timestamp_log, array( |
569 |
/** |
/** |
570 |
* 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 |
571 |
* l'enregistrement instancié. |
* l'enregistrement instancié. |
572 |
* |
* |
573 |
* @param array $params Tableau des paramètres |
* @param array $params Tableau des paramètres |
574 |
* @return array sinon false en cas d'erreur |
* @return array sinon false en cas d'erreur |
575 |
*/ |
*/ |
627 |
$list_tasks = array(); |
$list_tasks = array(); |
628 |
foreach ($res['result'] as $task) { |
foreach ($res['result'] as $task) { |
629 |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
630 |
$task['dossier'] = $task['object_id']; |
$task['dossier'] = $task['dossier']; |
631 |
if ($this->get_lien_objet_by_type($task['type']) === 'document_numerise') { |
if ($task['type'] === 'ajout_piece') { |
632 |
$val_dn = $this->get_document_numerise_data($task['object_id']); |
$val_dn = $this->get_document_numerise_data($task['object_id']); |
633 |
$task['dossier'] = $val_dn['dossier']; |
} |
634 |
|
if ($task['stream'] === 'output') { |
635 |
|
$task['external_uids'] = $this->get_all_external_uids($task['dossier']); |
636 |
} |
} |
637 |
$list_tasks[$task['task']] = $task; |
$list_tasks[$task['task']] = $task; |
638 |
} |
} |
786 |
return $inst_external_uid->getVal('external_uid'); |
return $inst_external_uid->getVal('external_uid'); |
787 |
} |
} |
788 |
|
|
789 |
|
protected function get_all_external_uids($fk_idx) { |
790 |
|
$link_objects = array( |
791 |
|
'dossier_autorisation', |
792 |
|
'dossier', |
793 |
|
'dossier_consultation', |
794 |
|
'document_numerise', |
795 |
|
); |
796 |
|
$val_external_uid = array(); |
797 |
|
foreach ($link_objects as $link_object) { |
798 |
|
$external_uid = $this->get_external_uid($fk_idx, $link_object); |
799 |
|
if ($external_uid !== '' && $external_uid !== null) { |
800 |
|
$val_external_uid[$link_object] = $external_uid; |
801 |
|
} |
802 |
|
} |
803 |
|
return $val_external_uid; |
804 |
|
} |
805 |
|
|
806 |
protected function get_demandeurs_data(string $dossier) { |
protected function get_demandeurs_data(string $dossier) { |
807 |
$val_demandeur = array(); |
$val_demandeur = array(); |
808 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
835 |
return $val_architecte; |
return $val_architecte; |
836 |
} |
} |
837 |
|
|
838 |
protected function get_instruction_data(string $dossier, $type = 'decision') { |
protected function get_instruction_data(string $dossier, $type = 'decision', $extra_params = array()) { |
839 |
$val_instruction = null; |
$val_instruction = null; |
840 |
$instruction_with_doc = null; |
$instruction_with_doc = null; |
841 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
849 |
if ($type === 'incompletude') { |
if ($type === 'incompletude') { |
850 |
$idx = $inst_di->get_last_instruction_incompletude(); |
$idx = $inst_di->get_last_instruction_incompletude(); |
851 |
} |
} |
852 |
|
// XXX Permet de récupérer l'instruction par son identifiant |
853 |
|
if ($type === 'with-id') { |
854 |
|
$idx = $extra_params['with-id']; |
855 |
|
} |
856 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
857 |
"obj" => "instruction", |
"obj" => "instruction", |
858 |
"idx" => $idx, |
"idx" => $idx, |
898 |
|
|
899 |
protected function sort_instruction_data(array $values, array $res) { |
protected function sort_instruction_data(array $values, array $res) { |
900 |
$fields = array( |
$fields = array( |
901 |
|
"date_evenement", |
902 |
"date_envoi_signature", |
"date_envoi_signature", |
903 |
"date_retour_signature", |
"date_retour_signature", |
904 |
"date_envoi_rar", |
"date_envoi_rar", |
959 |
return $val_dp; |
return $val_dp; |
960 |
} |
} |
961 |
|
|
962 |
|
protected function get_avis_decision_data(string $dossier) { |
963 |
|
$inst_di = $this->f->get_inst__om_dbform(array( |
964 |
|
"obj" => "dossier", |
965 |
|
"idx" => $dossier, |
966 |
|
)); |
967 |
|
$ad = $inst_di->getVal('avis_decision'); |
968 |
|
$val_ad = array(); |
969 |
|
$inst_ad = $this->f->get_inst__om_dbform(array( |
970 |
|
"obj" => "avis_decision", |
971 |
|
"idx" => $ad, |
972 |
|
)); |
973 |
|
$val_ad = $inst_ad->get_json_data(); |
974 |
|
$val_ad['txAvis'] = "Voir document joint"; |
975 |
|
if (isset($val_ad['tacite']) === true |
976 |
|
&& $val_ad['tacite'] === 't') { |
977 |
|
// |
978 |
|
$val_ad['txAvis'] = "Sans objet"; |
979 |
|
} |
980 |
|
return $val_ad; |
981 |
|
} |
982 |
|
|
983 |
|
protected function get_signataire_arrete_data(string $sa) { |
984 |
|
$inst_sa = $this->f->get_inst__om_dbform(array( |
985 |
|
"obj" => "signataire_arrete", |
986 |
|
"idx" => $sa, |
987 |
|
)); |
988 |
|
$val_sa = array_combine($inst_sa->champs, $inst_sa->val); |
989 |
|
foreach ($val_sa as $key => $value) { |
990 |
|
$val_sa[$key] = strip_tags($value); |
991 |
|
} |
992 |
|
return $val_sa; |
993 |
|
} |
994 |
|
|
995 |
protected function view_form_json($in_field = false) { |
protected function view_form_json($in_field = false) { |
996 |
// |
// |
997 |
if ($this->f->get_submitted_post_value('valid') === null) { |
if ($this->f->get_submitted_post_value('valid') === null) { |
1011 |
$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']); |
1012 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1013 |
$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'); |
1014 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1015 |
} |
} |
1016 |
// |
// |
1017 |
if ($this->getVal('type') === 'creation_DI' |
if ($this->getVal('type') === 'creation_DI' |
1027 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1028 |
$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'); |
1029 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1030 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1031 |
} |
} |
1032 |
// |
// |
1033 |
if ($this->getVal('type') === 'qualification_DI') { |
if ($this->getVal('type') === 'qualification_DI') { |
1035 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1036 |
$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'); |
1037 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1038 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1039 |
} |
} |
1040 |
// |
// |
1041 |
if ($this->getVal('type') === 'ajout_piece') { |
if ($this->getVal('type') === 'ajout_piece') { |
1045 |
$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'); |
1046 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1047 |
$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'); |
1048 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1049 |
} |
} |
1050 |
// |
// |
1051 |
if ($this->getVal('type') === 'decision_DI') { |
if ($this->getVal('type') === 'decision_DI') { |
1052 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1053 |
$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'))); |
1054 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1055 |
$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'); |
1056 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1057 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1058 |
} |
} |
1059 |
// |
// |
1060 |
if ($this->getVal('type') === 'incompletude_DI') { |
if ($this->getVal('type') === 'incompletude_DI') { |
1061 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1062 |
$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'))); |
1063 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1064 |
$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'); |
1065 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1066 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1067 |
} |
} |
1068 |
// |
// |
1069 |
if ($this->getVal('type') === 'completude_DI') { |
if ($this->getVal('type') === 'completude_DI') { |
1070 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1071 |
$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'))); |
1072 |
|
$val_external_uid = array(); |
1073 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1074 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1075 |
|
$val['external_uids'] = $val_external_uid; |
1076 |
|
} |
1077 |
|
// |
1078 |
|
if ($this->getVal('type') === 'pec_metier_consultation') { |
1079 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1080 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1081 |
|
$val_external_uid = array(); |
1082 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1083 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1084 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
1085 |
|
$val['external_uids'] = $val_external_uid; |
1086 |
|
} |
1087 |
|
// |
1088 |
|
if ($this->getVal('type') === 'avis_consultation') { |
1089 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1090 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1091 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
1092 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
1093 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
1094 |
|
} |
1095 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1096 |
$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'); |
1097 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1098 |
$val['external_uid'] = $val_external_uid; |
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
1099 |
|
$val['external_uids'] = $val_external_uid; |
1100 |
} |
} |
1101 |
|
|
1102 |
if ($in_field === true) { |
if ($in_field === true) { |
1108 |
} |
} |
1109 |
} |
} |
1110 |
|
|
1111 |
function view_update_json_data() { |
function post_update_task() { |
1112 |
// Mise à jour des valeurs |
// Mise à jour des valeurs |
1113 |
// |
// |
1114 |
$params = array( |
$params = array( |
1129 |
); |
); |
1130 |
} |
} |
1131 |
$this->f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
1132 |
// |
|
1133 |
$inst_lien = $this->f->get_inst__om_dbform(array( |
// Sauvegarde des uid externes retournés s'ils ne le sont pas encore |
1134 |
"obj" => "lien_id_interne_uid_externe", |
if (is_array($this->f->get_submitted_post_value('external_uids')) === true) { |
1135 |
"idx" => ']', |
// |
1136 |
|
foreach ($this->f->get_submitted_post_value('external_uids') as $object => $external_uid) { |
1137 |
|
// |
1138 |
|
if (in_array($object, $this->get_objects_by_task_type($this->getVal('type'))) === true) { |
1139 |
|
// |
1140 |
|
$inst_lien = $this->f->get_inst__om_dbform(array( |
1141 |
|
"obj" => "lien_id_interne_uid_externe", |
1142 |
|
"idx" => ']', |
1143 |
|
)); |
1144 |
|
if ($inst_lien->is_exists($object, $document_numerise_id, $external_uid, $attachment_values['dossier']) === false) { |
1145 |
|
// |
1146 |
|
$valF = array( |
1147 |
|
'lien_id_interne_uid_externe' => '', |
1148 |
|
'object' => $object, |
1149 |
|
'object_id' => $this->getVal('object_id'), |
1150 |
|
'external_uid' => $external_uid, |
1151 |
|
'dossier' => $this->getVal('dossier'), |
1152 |
|
); |
1153 |
|
$add = $inst_lien->ajouter($valF); |
1154 |
|
$message_class = "valid"; |
1155 |
|
$message = $inst_lien->msg; |
1156 |
|
if ($add === false) { |
1157 |
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
1158 |
|
$message_class = "error"; |
1159 |
|
$message = sprintf( |
1160 |
|
'%s %s', |
1161 |
|
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
1162 |
|
__('Veuillez contacter votre administrateur.') |
1163 |
|
); |
1164 |
|
} |
1165 |
|
$this->f->displayMessage($message_class, $message); |
1166 |
|
} |
1167 |
|
} |
1168 |
|
} |
1169 |
|
} |
1170 |
|
} |
1171 |
|
|
1172 |
|
function post_add_task() { |
1173 |
|
// TODO Tester de remplacer la ligne de json_payload par un $_POST |
1174 |
|
$result = $this->add_task(array( |
1175 |
|
'val' => array( |
1176 |
|
'stream' => 'input', |
1177 |
|
'json_payload' => html_entity_decode($this->f->get_submitted_post_value('json_payload')), |
1178 |
|
'type' => $this->f->get_submitted_post_value('type'), |
1179 |
|
) |
1180 |
)); |
)); |
1181 |
$valF = array( |
$message = sprintf( |
1182 |
'lien_id_interne_uid_externe' => '', |
__("Tâche %s ajoutée avec succès"), |
1183 |
'object' => $this->get_lien_objet_by_type($this->getVal('type')), |
$this->getVal($this->clePrimaire)). |
1184 |
'object_id' => $this->getVal('object_id'), |
'<br/><br/>'. |
1185 |
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
$this->msg; |
|
); |
|
|
$add = $inst_lien->ajouter($valF); |
|
1186 |
$message_class = "valid"; |
$message_class = "valid"; |
1187 |
$message = $inst_lien->msg; |
if ($result === false){ |
1188 |
if ($add === false) { |
$this->addToLog($this->msg, DEBUG_MODE); |
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
|
1189 |
$message_class = "error"; |
$message_class = "error"; |
1190 |
$message = sprintf( |
$message = sprintf( |
1191 |
'%s %s', |
'%s %s', |
1192 |
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
__('Impossible d\'ajouter la tâche.'), |
1193 |
__('Veuillez contacter votre administrateur.') |
__('Veuillez contacter votre administrateur.') |
1194 |
); |
); |
1195 |
} |
} |
1196 |
$this->f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
1197 |
} |
} |
1198 |
|
|
1199 |
function view_add_json_data() { |
function setLayout(&$form, $maj) { |
1200 |
$params = array(); |
|
1201 |
$params['val']['stream'] = 'input'; |
// Récupération du mode de l'action |
1202 |
$params['val']['json_payload'] = $this->f->get_submitted_post_value('json_payload'); |
$crud = $this->get_action_crud($maj); |
1203 |
$json_payload = json_decode($params['val']['json_payload'], true); |
|
1204 |
$params['val']['type'] = $json_payload['task']['type']; |
// MODE different de CREER |
1205 |
$params['val']['dossier'] = $json_payload['task']['dossier']; |
if ($maj != 0 || $crud != 'create') { |
1206 |
$params['val']['object_id'] = ""; |
$form->setBloc('json_payload', 'D', '', 'col_6'); |
1207 |
if ($params['val']['type'] == 'ajout_piece') { |
$form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed"); |
1208 |
$document_numerise = $json_payload['document_numerise']; |
$form->setBloc('json_payload', 'F'); |
|
$file_content = base64_decode($document_numerise["file_content"]); |
|
|
if ($file_content === false){ |
|
|
$this->addToMessage(__("Le contenu du fichier lié à la tâche n'a pas pu etre recupere.")); |
|
|
return false; |
|
|
} |
|
|
$metadata = array( |
|
|
"filename" => $document_numerise['nom_fichier'], |
|
|
"size" => strlen($file_content), |
|
|
"mimetype" => $document_numerise['file_content_type'], |
|
|
"date_creation" => $document_numerise['date_creation'], |
|
|
); |
|
|
$uid_fichier = $this->f->storage->create($file_content, $metadata, "from_content"); |
|
|
if ($uid_fichier === OP_FAILURE) { |
|
|
$this->addToMessage(__("Erreur lors de la creation du fichier lié à la tâche.")); |
|
|
return false; |
|
|
} |
|
|
$json_payload["document_numerise"]["uid"] = $uid_fichier; |
|
|
$params['val']['json_payload'] = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
|
1209 |
} |
} |
1210 |
$this->add_task($params); |
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
1211 |
} |
} |
1212 |
|
|
1213 |
protected function get_lien_objet_by_type($type) { |
/** |
1214 |
// |
* [get_objects_by_task_type description] |
1215 |
$objet = ''; |
* @param [type] $type [description] |
1216 |
if ($type === 'creation_DA') { |
* @return [type] [description] |
1217 |
$objet = 'dossier_autorisation'; |
*/ |
1218 |
} |
function get_objects_by_task_type($type) { |
1219 |
if ($type === 'creation_DI' |
$objects = array(); |
1220 |
|| $type === 'depot_DI' |
if (in_array($type, array('creation_DA', )) === true) { |
1221 |
|| $type === 'modification_DI' |
$objects = array('dossier_autorisation', ); |
|
|| $type === 'qualification_DI' |
|
|
|| $type === 'decision_DI' |
|
|
|| $type === 'incompletude_DI' |
|
|
|| $type === 'completude_DI') { |
|
|
// |
|
|
$objet = 'dossier'; |
|
1222 |
} |
} |
1223 |
if ($type === 'ajout_piece') { |
if (in_array($type, array('creation_DI', 'depot_DI', 'notification_DI', 'qualification_DI', )) === true) { |
1224 |
$objet = 'document_numerise'; |
$objects = array('dossier', ); |
1225 |
} |
} |
1226 |
return $objet; |
if (in_array($type, array('create_DI_for_consultation', )) === true) { |
1227 |
} |
$objects = array('dossier', 'dossier_consultation', ); |
1228 |
|
} |
1229 |
function setLayout(&$form, $maj) { |
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
1230 |
$form->setBloc('json_payload', 'D', '', 'col_6'); |
$objects = array('instruction', ); |
1231 |
$form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed"); |
} |
1232 |
$form->setBloc('json_payload', 'F'); |
if (in_array($type, array('pec_metier_consultation', )) === true) { |
1233 |
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
$objects = array('pec_dossier_consultation', ); |
1234 |
|
} |
1235 |
|
if (in_array($type, array('avis_consultation', )) === true) { |
1236 |
|
$objects = array('avis_dossier_consultation', ); |
1237 |
|
} |
1238 |
|
if (in_array($type, array('ajout_piece', 'add_piece', )) === true) { |
1239 |
|
$objects = array('piece', ); |
1240 |
|
} |
1241 |
|
return $objects; |
1242 |
} |
} |
1243 |
|
|
1244 |
} |
} |