19 |
"view" => "view_json_data", |
"view" => "view_json_data", |
20 |
"permission_suffix" => "consulter", |
"permission_suffix" => "consulter", |
21 |
); |
); |
22 |
|
$this->class_actions[997] = array( |
23 |
|
"identifier" => "json_data", |
24 |
|
"view" => "view_update_json_data", |
25 |
|
"permission_suffix" => "modifier", |
26 |
|
); |
27 |
|
$this->class_actions[996] = array( |
28 |
|
"identifier" => "json_data", |
29 |
|
"view" => "view_add_json_data", |
30 |
|
"permission_suffix" => "ajouter", |
31 |
|
); |
32 |
|
} |
33 |
|
|
34 |
|
public function setvalF($val = array()) { |
35 |
|
parent::setvalF($val); |
36 |
|
// |
37 |
|
if (array_key_exists('timestamp_log', $val) === true) { |
38 |
|
$this->valF['timestamp_log'] = str_replace("'", '"', $val['timestamp_log']); |
39 |
|
} |
40 |
|
} |
41 |
|
|
42 |
|
/** |
43 |
|
* |
44 |
|
* @return array |
45 |
|
*/ |
46 |
|
function get_var_sql_forminc__champs() { |
47 |
|
return array( |
48 |
|
"task", |
49 |
|
"type", |
50 |
|
"state", |
51 |
|
"object_id", |
52 |
|
"dossier", |
53 |
|
"stream", |
54 |
|
"json_payload", |
55 |
|
"timestamp_log", |
56 |
|
); |
57 |
|
} |
58 |
|
|
59 |
|
function setType(&$form, $maj) { |
60 |
|
parent::setType($form, $maj); |
61 |
|
// Récupération du mode de l'action |
62 |
|
$crud = $this->get_action_crud($maj); |
63 |
|
|
64 |
|
if ($maj < 2) { |
65 |
|
$form->setType("state", "select"); |
66 |
|
$form->setType("stream", "select"); |
67 |
|
$form->setType("json_payload", "jsonprettyprint"); |
68 |
|
} |
69 |
|
if ($maj == 3){ |
70 |
|
$form->setType('dossier', 'link'); |
71 |
|
$form->setType('json_payload', 'jsonprettyprint'); |
72 |
|
} |
73 |
|
|
74 |
|
} |
75 |
|
|
76 |
|
/** |
77 |
|
* |
78 |
|
*/ |
79 |
|
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
80 |
|
if($maj < 2) { |
81 |
|
$contenu=array(); |
82 |
|
|
83 |
|
$contenu[0][0]="draft"; |
84 |
|
$contenu[1][0]=_('draft'); |
85 |
|
$contenu[0][1]="new"; |
86 |
|
$contenu[1][1]=_('new'); |
87 |
|
$contenu[0][2]="pending"; |
88 |
|
$contenu[1][2]=_('pending'); |
89 |
|
$contenu[0][3]="done"; |
90 |
|
$contenu[1][3]=_('done'); |
91 |
|
$contenu[0][4]="archived"; |
92 |
|
$contenu[1][4]=_('archived'); |
93 |
|
$contenu[0][5]="error"; |
94 |
|
$contenu[1][5]=_('error'); |
95 |
|
$contenu[0][6]="debug"; |
96 |
|
$contenu[1][6]=_('debug'); |
97 |
|
|
98 |
|
$form->setSelect("state", $contenu); |
99 |
|
|
100 |
|
$contenu_stream =array(); |
101 |
|
$contenu_stream[0][0]="input"; |
102 |
|
$contenu_stream[1][0]=_('input'); |
103 |
|
$contenu_stream[0][1]="output"; |
104 |
|
$contenu_stream[1][1]=_('output'); |
105 |
|
$form->setSelect("stream", $contenu_stream); |
106 |
|
|
107 |
|
} |
108 |
|
|
109 |
|
if ($maj == 3) { |
110 |
|
if ($this->getVal('stream') == 'output') { |
111 |
|
$inst_dossier = $this->f->get_inst__om_dbform(array( |
112 |
|
"obj" => "dossier", |
113 |
|
"idx" => $form->val['dossier'], |
114 |
|
)); |
115 |
|
|
116 |
|
if($form->val['type'] == "creation_DA"){ |
117 |
|
$obj_link = 'dossier_autorisation'; |
118 |
|
} else { |
119 |
|
$obj_link = 'dossier_instruction'; |
120 |
|
} |
121 |
|
|
122 |
|
$params = array(); |
123 |
|
$params['obj'] = $obj_link; |
124 |
|
$params['libelle'] = $inst_dossier->getVal('dossier'); |
125 |
|
$params['title'] = "Consulter le dossier"; |
126 |
|
$params['idx'] = $form->val['dossier']; |
127 |
|
$form->setSelect("dossier", $params); |
128 |
|
} |
129 |
|
} |
130 |
|
} |
131 |
|
|
132 |
|
/** |
133 |
|
* SETTER_FORM - setVal (setVal). |
134 |
|
* |
135 |
|
* @return void |
136 |
|
*/ |
137 |
|
function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) { |
138 |
|
// parent::setVal($form, $maj, $validation); |
139 |
|
// |
140 |
|
if ($this->getVal('stream') == "output") { |
141 |
|
$form->setVal('json_payload', $this->view_form_json(true)); |
142 |
|
} else { |
143 |
|
if ($this->getVal('type') == 'ajout_piece'){ |
144 |
|
// On modifie la valeur du champ "file_content" afin de tronquer le base64 |
145 |
|
$json_payload = json_decode($this->getVal("json_payload"), true); |
146 |
|
$json_payload["document_numerise"]["file_content"] = substr($json_payload["document_numerise"]["file_content"], 0, 64)."[...]"; |
147 |
|
$json_payload_result = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); |
148 |
|
$form->setVal('json_payload', htmlentities($json_payload_result)); |
149 |
|
} else { |
150 |
|
// |
151 |
|
$form->setVal('json_payload', htmlentities($this->getVal('json_payload'))); |
152 |
|
} |
153 |
|
} |
154 |
|
} |
155 |
|
|
156 |
|
function setLib(&$form, $maj) { |
157 |
|
parent::setLib($form, $maj); |
158 |
|
$form->setLib('json_payload', ''); |
159 |
|
} |
160 |
|
|
161 |
|
public function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
162 |
|
parent::verifier($val, $dnu1, $dnu2); |
163 |
|
// |
164 |
|
if (array_key_exists('timestamp_log', $this->valF) === true |
165 |
|
&& is_array(json_decode($this->valF['timestamp_log'], true)) === false) { |
166 |
|
// |
167 |
|
$this->correct = false; |
168 |
|
$this->addToMessage(sprintf( |
169 |
|
__("Le champ %s doit être dans un format JSON valide."), |
170 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('timestamp_log')) |
171 |
|
)); |
172 |
|
} |
173 |
} |
} |
174 |
|
|
175 |
protected function task_exists(string $type, string $object_id) { |
protected function task_exists(string $type, string $object_id) { |
211 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
212 |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : 'new', |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : 'new', |
213 |
'object_id' => $params['val']['object_id'], |
'object_id' => $params['val']['object_id'], |
214 |
|
'dossier' => $params['val']['dossier'], |
215 |
|
'stream' => isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output', |
216 |
|
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
217 |
); |
); |
218 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
if($valF["stream"] != "input"){ |
219 |
if ($task_exists !== false) { |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
220 |
$inst_task = $this->f->get_inst__om_dbform(array( |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
221 |
"obj" => "task", |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
222 |
"idx" => $task_exists, |
} |
223 |
)); |
if ($task_exists !== false) { |
224 |
$update_params = array( |
$inst_task = $this->f->get_inst__om_dbform(array( |
225 |
'val' => array( |
"obj" => "task", |
226 |
'state' => $inst_task->getVal('state'), |
"idx" => $task_exists, |
227 |
), |
)); |
228 |
); |
$update_state = $inst_task->getVal('state'); |
229 |
return $inst_task->update_task($update_params); |
if (isset($params['update_val']['state']) === true) { |
230 |
|
$update_state = $params['update_val']['state']; |
231 |
|
} |
232 |
|
$update_params = array( |
233 |
|
'val' => array( |
234 |
|
'state' => $update_state, |
235 |
|
), |
236 |
|
); |
237 |
|
return $inst_task->update_task($update_params); |
238 |
|
} |
239 |
} |
} |
240 |
$add = $this->ajouter($valF); |
$add = $this->ajouter($valF); |
241 |
if ($add === false) { |
if ($add === false) { |
271 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
272 |
'state' => $params['val']['state'], |
'state' => $params['val']['state'], |
273 |
'object_id' => $this->getVal('object_id'), |
'object_id' => $this->getVal('object_id'), |
274 |
|
'stream' => $this->getVal('stream'), |
275 |
|
'dossier' => $this->getVal('dossier'), |
276 |
|
'json_payload' => $this->getVal('json_payload'), |
277 |
); |
); |
278 |
$update = $this->modifier($valF); |
$update = $this->modifier($valF); |
279 |
if ($update === false) { |
if ($update === false) { |
332 |
* |
* |
333 |
FROM %1$stask |
FROM %1$stask |
334 |
%2$s |
%2$s |
335 |
|
ORDER BY task ASC |
336 |
', |
', |
337 |
DB_PREFIXE, |
DB_PREFIXE, |
338 |
$where |
$where |
344 |
$list_tasks = array(); |
$list_tasks = array(); |
345 |
foreach ($res['result'] as $task) { |
foreach ($res['result'] as $task) { |
346 |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
347 |
|
$task['dossier'] = $task['object_id']; |
348 |
|
if ($this->get_lien_objet_by_type($task['type']) === 'document_numerise') { |
349 |
|
$val_dn = $this->get_document_numerise_data($task['object_id']); |
350 |
|
$task['dossier'] = $val_dn['dossier']; |
351 |
|
} |
352 |
$list_tasks[$task['task']] = $task; |
$list_tasks[$task['task']] = $task; |
353 |
} |
} |
354 |
printf(json_encode($list_tasks)); |
printf(json_encode($list_tasks)); |
415 |
} |
} |
416 |
} |
} |
417 |
} |
} |
418 |
|
// Correspond à la nouvelle ligne CERFA v7 dans le DENSI imposition 1.2.3 |
419 |
|
if (isset($val_dt['tax_su_non_habit_surf2']) === true |
420 |
|
&& isset($val_dt['tax_su_non_habit_surf3']) === true |
421 |
|
&& (($val_dt['tax_su_non_habit_surf2'] !== null |
422 |
|
&& $val_dt['tax_su_non_habit_surf2'] !== '') |
423 |
|
|| ($val_dt['tax_su_non_habit_surf3'] !== null |
424 |
|
&& $val_dt['tax_su_non_habit_surf3'] !== ''))) { |
425 |
|
// |
426 |
|
$val_dt['tax_su_non_habit_surf8'] = intval($val_dt['tax_su_non_habit_surf2']) + intval($val_dt['tax_su_non_habit_surf3']); |
427 |
|
} |
428 |
|
if (isset($val_dt['tax_su_non_habit_surf_stat2']) === true |
429 |
|
&& isset($val_dt['tax_su_non_habit_surf_stat3']) === true |
430 |
|
&& (($val_dt['tax_su_non_habit_surf_stat2'] !== null |
431 |
|
&& $val_dt['tax_su_non_habit_surf_stat2'] !== '') |
432 |
|
|| ($val_dt['tax_su_non_habit_surf_stat3'] !== null |
433 |
|
&& $val_dt['tax_su_non_habit_surf_stat3'] !== ''))) { |
434 |
|
// |
435 |
|
$val_dt['tax_su_non_habit_surf_stat8'] = intval($val_dt['tax_su_non_habit_surf_stat2']) + intval($val_dt['tax_su_non_habit_surf_stat3']); |
436 |
|
} |
437 |
|
// Cas particulier d'un projet réduit à l'extension d'une habitation existante |
438 |
|
$particular_case = false; |
439 |
|
$fields_tab_crea_loc_hab = $inst_dt->get_fields_tab_crea_loc_hab(); |
440 |
|
foreach ($fields_tab_crea_loc_hab as $field) { |
441 |
|
if (isset($val_dt[$field]) === false |
442 |
|
|| (isset($val_dt[$field]) === true |
443 |
|
&& ($val_dt[$field] === null |
444 |
|
|| $val_dt[$field] === ''))) { |
445 |
|
// |
446 |
|
$particular_case = true; |
447 |
|
} |
448 |
|
} |
449 |
|
if ($particular_case === true) { |
450 |
|
if (isset($val_dt['tax_ext_pret']) === true |
451 |
|
&& $val_dt['tax_ext_pret'] === 'f') { |
452 |
|
// |
453 |
|
$val_dt['tax_su_princ_surf1'] = $val_dt['tax_surf_tot_cstr']; |
454 |
|
$val_dt['tax_su_princ_surf_stat1'] = $val_dt['tax_surf_loc_stat']; |
455 |
|
} |
456 |
|
if (isset($val_dt['tax_ext_pret']) === true |
457 |
|
&& $val_dt['tax_ext_pret'] === 't') { |
458 |
|
// |
459 |
|
if (isset($val_dt['tax_ext_desc']) === true) { |
460 |
|
if (preg_match('/[pP].*[lL].*[aA].*[iI]/', $val_dt['tax_ext_desc']) === 1 |
461 |
|
|| preg_match('/[lL].*[lL].*[tT].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
462 |
|
// |
463 |
|
$val_dt['tax_su_princ_surf2'] = $val_dt['tax_surf_tot_cstr']; |
464 |
|
$val_dt['tax_su_princ_surf_stat2'] = $val_dt['tax_surf_loc_stat']; |
465 |
|
} |
466 |
|
// if (preg_match('/[pP].*[tT].*[zZ]/', $val_dt['tax_ext_desc']) === 1) { |
467 |
|
// $val_dt['tax_su_princ_surf4'] = $val_dt['tax_surf_tot_cstr']; |
468 |
|
// $val_dt['tax_su_princ_surf_stat4'] = $val_dt['tax_surf_loc_stat']; |
469 |
|
// } |
470 |
|
// if (preg_match('/[pP].*[lL].*[uU].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
471 |
|
// || preg_match('/[lL].*[eE].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
472 |
|
// || preg_match('/[pP].*[sS].*[lL].*[aA]/', $val_dt['tax_ext_desc']) === 1 |
473 |
|
// || preg_match('/[pP].*[lL].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
474 |
|
// || preg_match('/[lL].*[lL].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
475 |
|
// // |
476 |
|
// $val_dt['tax_su_princ_surf3'] = $val_dt['tax_surf_tot_cstr']; |
477 |
|
// $val_dt['tax_su_princ_surf_stat3'] = $val_dt['tax_surf_loc_stat']; |
478 |
|
// } |
479 |
|
} |
480 |
|
} |
481 |
|
} |
482 |
|
// Cas particulier de la surface taxable démolie |
483 |
|
if (isset($val_dt['tax_surf_tot_demo']) === true |
484 |
|
&& isset($val_dt['tax_surf_tax_demo']) === true |
485 |
|
&& ($val_dt['tax_surf_tot_demo'] === null |
486 |
|
|| $val_dt['tax_surf_tot_demo'] === '')) { |
487 |
|
// |
488 |
|
$val_dt['tax_surf_tot_demo'] = $val_dt['tax_surf_tax_demo']; |
489 |
|
} |
490 |
return $val_dt; |
return $val_dt; |
491 |
} |
} |
492 |
|
|
515 |
)); |
)); |
516 |
$val_demandeur[$demandeur['demandeur']] = $inst_demandeur->get_json_data(); |
$val_demandeur[$demandeur['demandeur']] = $inst_demandeur->get_json_data(); |
517 |
$val_demandeur[$demandeur['demandeur']]['petitionnaire_principal'] = $demandeur['petitionnaire_principal']; |
$val_demandeur[$demandeur['demandeur']]['petitionnaire_principal'] = $demandeur['petitionnaire_principal']; |
|
// Valeur par défaut pour expériementation sequence 1 |
|
|
$val_demandeur[$demandeur['demandeur']]['commerciale'] = 'f'; |
|
518 |
} |
} |
519 |
return $val_demandeur; |
return $val_demandeur; |
520 |
} |
} |
521 |
|
|
522 |
protected function get_architecte_data($architecte = null) { |
protected function get_architecte_data($architecte = null) { |
523 |
$val_architecte = array(); |
$val_architecte = null; |
524 |
if ($architecte !== null |
if ($architecte !== null |
525 |
&& $architecte !== '') { |
&& $architecte !== '') { |
526 |
// |
// |
533 |
return $val_architecte; |
return $val_architecte; |
534 |
} |
} |
535 |
|
|
536 |
protected function get_instruction_data(string $dossier) { |
protected function get_instruction_data(string $dossier, $type = 'decision') { |
537 |
$val_instruction = array(); |
$val_instruction = null; |
538 |
|
$instruction_with_doc = null; |
539 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
540 |
"obj" => "dossier", |
"obj" => "dossier", |
541 |
"idx" => $dossier, |
"idx" => $dossier, |
542 |
)); |
)); |
543 |
|
$idx = null; |
544 |
|
if ($type === 'decision') { |
545 |
|
$idx = $inst_di->get_last_instruction_decision(); |
546 |
|
} |
547 |
|
if ($type === 'incompletude') { |
548 |
|
$idx = $inst_di->get_last_instruction_incompletude(); |
549 |
|
} |
550 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
551 |
"obj" => "instruction", |
"obj" => "instruction", |
552 |
"idx" => $inst_di->get_last_instruction_decision(), |
"idx" => $idx, |
553 |
)); |
)); |
554 |
if (count($inst_instruction->val) > 0) { |
if (count($inst_instruction->val) > 0) { |
555 |
$val_instruction = $inst_instruction->get_json_data(); |
$val_instruction = array(); |
556 |
|
$instruction_data = $inst_instruction->get_json_data(); |
557 |
|
$val_instruction = $this->sort_instruction_data($instruction_data, $val_instruction); |
558 |
|
if ($instruction_data['om_fichier_instruction'] !== null |
559 |
|
&& $instruction_data['om_fichier_instruction'] !== '') { |
560 |
|
// |
561 |
|
$instruction_with_doc = $inst_instruction->getVal($inst_instruction->clePrimaire); |
562 |
|
} |
563 |
|
$inst_ev = $this->f->get_inst__om_dbform(array( |
564 |
|
"obj" => "evenement", |
565 |
|
"idx" => $inst_instruction->getVal('evenement'), |
566 |
|
)); |
567 |
|
if ($inst_ev->getVal('retour') === 't') { |
568 |
|
$instructions_related = $inst_instruction->get_related_instructions(); |
569 |
|
foreach ($instructions_related as $instruction) { |
570 |
|
if ($instruction !== null && $instruction !== '') { |
571 |
|
$inst_related_instruction = $this->f->get_inst__om_dbform(array( |
572 |
|
"obj" => "instruction", |
573 |
|
"idx" => $instruction, |
574 |
|
)); |
575 |
|
$instruction_data = $inst_related_instruction->get_json_data(); |
576 |
|
$val_instruction = $this->sort_instruction_data($instruction_data, $val_instruction); |
577 |
|
if ($instruction_data['om_fichier_instruction'] !== null |
578 |
|
&& $instruction_data['om_fichier_instruction'] !== '') { |
579 |
|
// |
580 |
|
$instruction_with_doc = $inst_related_instruction->getVal($inst_related_instruction->clePrimaire); |
581 |
|
} |
582 |
|
} |
583 |
|
} |
584 |
|
} |
585 |
|
if ($instruction_with_doc !== null) { |
586 |
|
// |
587 |
|
$val_instruction['path'] = sprintf('%s&snippet=%s&obj=%s&champ=%s&id=%s', 'app/index.php?module=form', 'file', 'instruction', 'om_fichier_instruction', $instruction_with_doc); |
588 |
|
} |
589 |
} |
} |
590 |
return $val_instruction; |
return $val_instruction; |
591 |
} |
} |
592 |
|
|
593 |
|
protected function sort_instruction_data(array $values, array $res) { |
594 |
|
$fields = array( |
595 |
|
"date_envoi_signature", |
596 |
|
"date_retour_signature", |
597 |
|
"date_envoi_rar", |
598 |
|
"date_retour_rar", |
599 |
|
"date_envoi_controle_legalite", |
600 |
|
"date_retour_controle_legalite", |
601 |
|
"signataire_arrete", |
602 |
|
"om_fichier_instruction", |
603 |
|
"tacite", |
604 |
|
"lettretype", |
605 |
|
); |
606 |
|
foreach ($values as $key => $value) { |
607 |
|
if (in_array($key, $fields) === true) { |
608 |
|
if (array_key_exists($key, $res) === false |
609 |
|
&& $value !== null |
610 |
|
&& $value !== '') { |
611 |
|
// |
612 |
|
$res[$key] = $value; |
613 |
|
} elseif ($key === 'tacite' |
614 |
|
&& $value === 't') { |
615 |
|
// |
616 |
|
$res[$key] = $value; |
617 |
|
} |
618 |
|
} |
619 |
|
} |
620 |
|
return $res; |
621 |
|
} |
622 |
|
|
623 |
protected function get_document_numerise_data(string $dn) { |
protected function get_document_numerise_data(string $dn) { |
624 |
$val_dn = array(); |
$val_dn = array(); |
625 |
$inst_dn = $this->f->get_inst__om_dbform(array( |
$inst_dn = $this->f->get_inst__om_dbform(array( |
627 |
"idx" => $dn, |
"idx" => $dn, |
628 |
)); |
)); |
629 |
$val_dn = $inst_dn->get_json_data(); |
$val_dn = $inst_dn->get_json_data(); |
630 |
$val_dn['path'] = sprintf('%s/%s&snippet=%s&obj=%s&champ=%s&id=%s', $_SERVER['HTTP_HOST'], 'openads/app/index.php?module=form', 'file', 'document_numerise', 'uid', $this->getVal('object_id')); |
$val_dn['path'] = sprintf('%s&snippet=%s&obj=%s&champ=%s&id=%s', 'app/index.php?module=form', 'file', 'document_numerise', 'uid', $this->getVal('object_id')); |
631 |
// Correspond à la nomenclature Plat'AU NATURE_PIECE |
// Correspond à la nomenclature Plat'AU NATURE_PIECE |
632 |
$val_dn['nature'] = 'Initiale'; |
$val_dn['nature'] = $val_dn['document_numerise_nature_libelle']; |
633 |
return $val_dn; |
return $val_dn; |
634 |
} |
} |
635 |
|
|
652 |
return $val_dp; |
return $val_dp; |
653 |
} |
} |
654 |
|
|
655 |
protected function view_form_json() { |
protected function view_form_json($in_field = false) { |
|
// Mise à jour des valeurs |
|
|
if ($this->f->get_submitted_post_value('valid') === 'true' |
|
|
&& $this->f->get_submitted_post_value('state') !== null) { |
|
|
// |
|
|
$params = array( |
|
|
'val' => array( |
|
|
'state' => $this->f->get_submitted_post_value('state') |
|
|
), |
|
|
); |
|
|
$update = $this->update_task($params); |
|
|
$message_class = "valid"; |
|
|
$message = $this->msg; |
|
|
if ($update === false) { |
|
|
$this->addToLog($this->msg, DEBUG_MODE); |
|
|
$message_class = "error"; |
|
|
$message = sprintf( |
|
|
'%s %s', |
|
|
__('Impossible de mettre à jour la tâche.'), |
|
|
__('Veuillez contacter votre administrateur.') |
|
|
); |
|
|
} |
|
|
$this->f->displayMessage($message_class, $message); |
|
|
} |
|
|
// |
|
|
if ($this->f->get_submitted_post_value('valid') === 'true' |
|
|
&& $this->f->get_submitted_post_value('external_uid') !== null) { |
|
|
// |
|
|
$inst_lien = $this->f->get_inst__om_dbform(array( |
|
|
"obj" => "lien_id_interne_uid_externe", |
|
|
"idx" => ']', |
|
|
)); |
|
|
$valF = array( |
|
|
'lien_id_interne_uid_externe' => '', |
|
|
'object' => $this->get_lien_objet_by_type($this->getVal('type')), |
|
|
'object_id' => $this->getVal('object_id'), |
|
|
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
|
|
); |
|
|
$add = $inst_lien->ajouter($valF); |
|
|
$message_class = "valid"; |
|
|
$message = $inst_lien->msg; |
|
|
if ($add === false) { |
|
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
|
|
$message_class = "error"; |
|
|
$message = sprintf( |
|
|
'%s %s', |
|
|
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
|
|
__('Veuillez contacter votre administrateur.') |
|
|
); |
|
|
} |
|
|
$this->f->displayMessage($message_class, $message); |
|
|
} |
|
|
|
|
656 |
// |
// |
657 |
if ($this->f->get_submitted_post_value('valid') === null) { |
if ($this->f->get_submitted_post_value('valid') === null) { |
658 |
// Liste des valeurs à afficher |
// Liste des valeurs à afficher |
675 |
} |
} |
676 |
// |
// |
677 |
if ($this->getVal('type') === 'creation_DI' |
if ($this->getVal('type') === 'creation_DI' |
678 |
|| $this->getVal('type') === 'modification_DI') { |
|| $this->getVal('type') === 'modification_DI' |
679 |
|
|| $this->getVal('type') === 'depot_DI') { |
680 |
// |
// |
681 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
682 |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction'); |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction'); |
692 |
// |
// |
693 |
if ($this->getVal('type') === 'qualification_DI') { |
if ($this->getVal('type') === 'qualification_DI') { |
694 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier']); |
|
695 |
$val_external_uid = array(); |
$val_external_uid = array(); |
696 |
$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'); |
697 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
707 |
$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'); |
708 |
$val['external_uid'] = $val_external_uid; |
$val['external_uid'] = $val_external_uid; |
709 |
} |
} |
710 |
|
// |
711 |
|
if ($this->getVal('type') === 'decision_DI') { |
712 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
713 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier']); |
714 |
|
$val_external_uid = array(); |
715 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
716 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
717 |
|
$val['external_uid'] = $val_external_uid; |
718 |
|
} |
719 |
|
// |
720 |
|
if ($this->getVal('type') === 'incompletude_DI') { |
721 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
722 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'incompletude'); |
723 |
|
$val_external_uid = array(); |
724 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
725 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
726 |
|
$val['external_uid'] = $val_external_uid; |
727 |
|
} |
728 |
|
// |
729 |
|
if ($this->getVal('type') === 'completude_DI') { |
730 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
731 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'completude'); |
732 |
|
$val_external_uid = array(); |
733 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
734 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
735 |
|
$val['external_uid'] = $val_external_uid; |
736 |
|
} |
737 |
|
|
738 |
// Liste des valeurs affichée en JSON |
if ($in_field === true) { |
739 |
printf(json_encode($val)); |
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
740 |
|
} else { |
741 |
|
// Liste des valeurs affichée en JSON |
742 |
|
printf(json_encode($val, JSON_UNESCAPED_SLASHES)); |
743 |
|
} |
744 |
} |
} |
745 |
} |
} |
746 |
|
|
747 |
|
function view_update_json_data() { |
748 |
|
// Mise à jour des valeurs |
749 |
|
// |
750 |
|
$params = array( |
751 |
|
'val' => array( |
752 |
|
'state' => $this->f->get_submitted_post_value('state') |
753 |
|
), |
754 |
|
); |
755 |
|
$update = $this->update_task($params); |
756 |
|
$message_class = "valid"; |
757 |
|
$message = $this->msg; |
758 |
|
if ($update === false) { |
759 |
|
$this->addToLog($this->msg, DEBUG_MODE); |
760 |
|
$message_class = "error"; |
761 |
|
$message = sprintf( |
762 |
|
'%s %s', |
763 |
|
__('Impossible de mettre à jour la tâche.'), |
764 |
|
__('Veuillez contacter votre administrateur.') |
765 |
|
); |
766 |
|
} |
767 |
|
$this->f->displayMessage($message_class, $message); |
768 |
|
// |
769 |
|
$inst_lien = $this->f->get_inst__om_dbform(array( |
770 |
|
"obj" => "lien_id_interne_uid_externe", |
771 |
|
"idx" => ']', |
772 |
|
)); |
773 |
|
$valF = array( |
774 |
|
'lien_id_interne_uid_externe' => '', |
775 |
|
'object' => $this->get_lien_objet_by_type($this->getVal('type')), |
776 |
|
'object_id' => $this->getVal('object_id'), |
777 |
|
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
778 |
|
); |
779 |
|
$add = $inst_lien->ajouter($valF); |
780 |
|
$message_class = "valid"; |
781 |
|
$message = $inst_lien->msg; |
782 |
|
if ($add === false) { |
783 |
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
784 |
|
$message_class = "error"; |
785 |
|
$message = sprintf( |
786 |
|
'%s %s', |
787 |
|
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
788 |
|
__('Veuillez contacter votre administrateur.') |
789 |
|
); |
790 |
|
} |
791 |
|
$this->f->displayMessage($message_class, $message); |
792 |
|
} |
793 |
|
|
794 |
|
function view_add_json_data() { |
795 |
|
$params = array(); |
796 |
|
$params['val']['stream'] = 'input'; |
797 |
|
$params['val']['json_payload'] = $this->f->get_submitted_post_value('json_payload'); |
798 |
|
$json_payload = json_decode($params['val']['json_payload'], true); |
799 |
|
$params['val']['type'] = $json_payload['task']['type']; |
800 |
|
$params['val']['dossier'] = $json_payload['task']['dossier']; |
801 |
|
$params['val']['object_id'] = ""; |
802 |
|
if ($params['val']['type'] == 'ajout_piece') { |
803 |
|
$document_numerise = $json_payload['document_numerise']; |
804 |
|
$file_content = base64_decode($document_numerise["file_content"]); |
805 |
|
if ($file_content === false){ |
806 |
|
$this->addToMessage(__("Le contenu du fichier lié à la tâche n'a pas pu etre recupere.")); |
807 |
|
return false; |
808 |
|
} |
809 |
|
$metadata = array( |
810 |
|
"filename" => $document_numerise['nom_fichier'], |
811 |
|
"size" => strlen($file_content), |
812 |
|
"mimetype" => $document_numerise['file_content_type'], |
813 |
|
"date_creation" => $document_numerise['date_creation'], |
814 |
|
); |
815 |
|
$uid_fichier = $this->f->storage->create($file_content, $metadata, "from_content"); |
816 |
|
if ($uid_fichier === OP_FAILURE) { |
817 |
|
$this->addToMessage(__("Erreur lors de la creation du fichier lié à la tâche.")); |
818 |
|
return false; |
819 |
|
} |
820 |
|
$json_payload["document_numerise"]["uid"] = $uid_fichier; |
821 |
|
$params['val']['json_payload'] = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
822 |
|
} |
823 |
|
$this->add_task($params); |
824 |
|
} |
825 |
|
|
826 |
protected function get_lien_objet_by_type($type) { |
protected function get_lien_objet_by_type($type) { |
827 |
// |
// |
828 |
$objet = ''; |
$objet = ''; |
829 |
if ($type === 'creation_DA') { |
if ($type === 'creation_DA') { |
830 |
$objet = 'dossier_autorisation'; |
$objet = 'dossier_autorisation'; |
831 |
} |
} |
832 |
if ($type === 'creation_DI' || $type === 'modification_DI') { |
if ($type === 'creation_DI' |
833 |
|
|| $type === 'depot_DI' |
834 |
|
|| $type === 'modification_DI' |
835 |
|
|| $type === 'qualification_DI' |
836 |
|
|| $type === 'decision_DI' |
837 |
|
|| $type === 'incompletude_DI' |
838 |
|
|| $type === 'completude_DI') { |
839 |
|
// |
840 |
$objet = 'dossier'; |
$objet = 'dossier'; |
841 |
} |
} |
842 |
if ($type === 'ajout_piece') { |
if ($type === 'ajout_piece') { |
844 |
} |
} |
845 |
return $objet; |
return $objet; |
846 |
} |
} |
847 |
|
|
848 |
|
function setLayout(&$form, $maj) { |
849 |
|
$form->setBloc('json_payload', 'D', '', 'col_6'); |
850 |
|
$form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed"); |
851 |
|
$form->setBloc('json_payload', 'F'); |
852 |
|
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
853 |
|
} |
854 |
|
|
855 |
} |
} |