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_task", |
25 |
|
"permission_suffix" => "modifier", |
26 |
|
); |
27 |
|
$this->class_actions[996] = array( |
28 |
|
"identifier" => "json_data", |
29 |
|
"view" => "view_add_task", |
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) { |
204 |
$timestamp_log = json_encode(array( |
$timestamp_log = json_encode(array( |
205 |
'creation_date' => date('Y-m-d H:i:s'), |
'creation_date' => date('Y-m-d H:i:s'), |
206 |
)); |
)); |
207 |
|
|
208 |
|
// Si la tâche est de type ajout_piece et de stream input alors on ajoute le fichier |
209 |
|
// et on ajoute l'uid dans le champ json_payload avant l'ajout de la tâche |
210 |
|
if (isset($params['val']['type']) |
211 |
|
&& $params['val']['type'] == "ajout_piece" |
212 |
|
&& isset($params['val']['stream']) |
213 |
|
&& $params['val']['stream'] == "input" ) { |
214 |
|
// |
215 |
|
$json_payload = json_decode($params['val']['json_payload'], true); |
216 |
|
$document_numerise = $json_payload['document_numerise']; |
217 |
|
$file_content = base64_decode($document_numerise["file_content"]); |
218 |
|
if ($file_content === false){ |
219 |
|
$this->addToMessage(__("Le contenu du fichier lié à la tâche n'a pas pu etre recupere.")); |
220 |
|
return $this->end_treatment(__METHOD__, false); |
221 |
|
} |
222 |
|
$metadata = array( |
223 |
|
"filename" => $document_numerise['nom_fichier'], |
224 |
|
"size" => strlen($file_content), |
225 |
|
"mimetype" => $document_numerise['file_content_type'], |
226 |
|
"date_creation" => $document_numerise['date_creation'], |
227 |
|
); |
228 |
|
$uid_fichier = $this->f->storage->create($file_content, $metadata, "from_content"); |
229 |
|
if ($uid_fichier === OP_FAILURE) { |
230 |
|
$this->addToMessage(__("Erreur lors de la creation du fichier lié à la tâche.")); |
231 |
|
return $this->end_treatment(__METHOD__, false); |
232 |
|
} |
233 |
|
$json_payload["document_numerise"]["uid"] = $uid_fichier; |
234 |
|
$params['val']['json_payload'] = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
235 |
|
} |
236 |
|
|
237 |
// Mise à jour du DI |
// Mise à jour du DI |
238 |
$valF = array( |
$valF = array( |
239 |
'task' => '', |
'task' => '', |
241 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
242 |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : 'new', |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : 'new', |
243 |
'object_id' => $params['val']['object_id'], |
'object_id' => $params['val']['object_id'], |
244 |
|
'dossier' => $params['val']['dossier'], |
245 |
|
'stream' => isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output', |
246 |
|
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
247 |
); |
); |
248 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
if($valF["stream"] != "input"){ |
249 |
if ($task_exists !== false) { |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
250 |
$inst_task = $this->f->get_inst__om_dbform(array( |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
251 |
"obj" => "task", |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
252 |
"idx" => $task_exists, |
} |
253 |
)); |
if ($task_exists !== false) { |
254 |
$update_params = array( |
$inst_task = $this->f->get_inst__om_dbform(array( |
255 |
'val' => array( |
"obj" => "task", |
256 |
'state' => $inst_task->getVal('state'), |
"idx" => $task_exists, |
257 |
), |
)); |
258 |
); |
$update_state = $inst_task->getVal('state'); |
259 |
return $inst_task->update_task($update_params); |
if (isset($params['update_val']['state']) === true) { |
260 |
|
$update_state = $params['update_val']['state']; |
261 |
|
} |
262 |
|
$update_params = array( |
263 |
|
'val' => array( |
264 |
|
'state' => $update_state, |
265 |
|
), |
266 |
|
); |
267 |
|
return $inst_task->update_task($update_params); |
268 |
|
} |
269 |
} |
} |
270 |
$add = $this->ajouter($valF); |
$add = $this->ajouter($valF); |
271 |
if ($add === false) { |
if ($add === false) { |
301 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
302 |
'state' => $params['val']['state'], |
'state' => $params['val']['state'], |
303 |
'object_id' => $this->getVal('object_id'), |
'object_id' => $this->getVal('object_id'), |
304 |
|
'stream' => $this->getVal('stream'), |
305 |
|
'dossier' => $this->getVal('dossier'), |
306 |
|
'json_payload' => $this->getVal('json_payload'), |
307 |
); |
); |
308 |
$update = $this->modifier($valF); |
$update = $this->modifier($valF); |
309 |
if ($update === false) { |
if ($update === false) { |
362 |
* |
* |
363 |
FROM %1$stask |
FROM %1$stask |
364 |
%2$s |
%2$s |
365 |
|
ORDER BY task ASC |
366 |
', |
', |
367 |
DB_PREFIXE, |
DB_PREFIXE, |
368 |
$where |
$where |
373 |
} |
} |
374 |
$list_tasks = array(); |
$list_tasks = array(); |
375 |
foreach ($res['result'] as $task) { |
foreach ($res['result'] as $task) { |
376 |
|
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
377 |
|
$task['dossier'] = $task['object_id']; |
378 |
|
if ($this->get_lien_objet_by_type($task['type']) === 'document_numerise') { |
379 |
|
$val_dn = $this->get_document_numerise_data($task['object_id']); |
380 |
|
$task['dossier'] = $val_dn['dossier']; |
381 |
|
} |
382 |
$list_tasks[$task['task']] = $task; |
$list_tasks[$task['task']] = $task; |
383 |
} |
} |
384 |
printf(json_encode($list_tasks)); |
printf(json_encode($list_tasks)); |
390 |
"obj" => "dossier", |
"obj" => "dossier", |
391 |
"idx" => $dossier, |
"idx" => $dossier, |
392 |
)); |
)); |
393 |
$val_di = json_decode($inst_di->get_json_data(), true); |
$val_di = $inst_di->get_json_data(); |
394 |
if ($val_di['dossier_instruction_type_code'] === 'T') { |
if ($val_di['dossier_instruction_type_code'] === 'T') { |
395 |
$val_di['date_decision_transfert'] = $val_di['date_decision']; |
$val_di['date_decision_transfert'] = $val_di['date_decision']; |
396 |
} |
} |
405 |
"obj" => "dossier_autorisation", |
"obj" => "dossier_autorisation", |
406 |
"idx" => $da, |
"idx" => $da, |
407 |
)); |
)); |
408 |
$val_da = json_decode($inst_da->get_json_data(), true); |
$val_da = $inst_da->get_json_data(); |
409 |
return $val_da; |
return $val_da; |
410 |
} |
} |
411 |
|
|
427 |
$val_dt['am_exist_date_num'] = $val_dt['am_exist_date']; |
$val_dt['am_exist_date_num'] = $val_dt['am_exist_date']; |
428 |
} |
} |
429 |
} |
} |
430 |
|
// Correspond à la nomenclature de Plat'AU STATUT_INFO |
431 |
|
$val_dt['tax_statut_info'] = 'Déclaré'; |
432 |
|
// |
433 |
|
if ($inst_dt->is_tab_surf_ssdest_enabled() === true) { |
434 |
|
$fields_tab_surf_dest = $inst_dt->get_fields_tab_surf_dest(); |
435 |
|
foreach ($fields_tab_surf_dest as $field) { |
436 |
|
if (isset($val_dt[$field]) === true) { |
437 |
|
unset($val_dt[$field]); |
438 |
|
} |
439 |
|
} |
440 |
|
} else { |
441 |
|
$fields_tab_surf_ssdest = $inst_dt->get_fields_tab_surf_ssdest(); |
442 |
|
foreach ($fields_tab_surf_ssdest as $field) { |
443 |
|
if (isset($val_dt[$field]) === true) { |
444 |
|
unset($val_dt[$field]); |
445 |
|
} |
446 |
|
} |
447 |
|
} |
448 |
|
// Correspond à la nouvelle ligne CERFA v7 dans le DENSI imposition 1.2.3 |
449 |
|
if (isset($val_dt['tax_su_non_habit_surf2']) === true |
450 |
|
&& isset($val_dt['tax_su_non_habit_surf3']) === true |
451 |
|
&& (($val_dt['tax_su_non_habit_surf2'] !== null |
452 |
|
&& $val_dt['tax_su_non_habit_surf2'] !== '') |
453 |
|
|| ($val_dt['tax_su_non_habit_surf3'] !== null |
454 |
|
&& $val_dt['tax_su_non_habit_surf3'] !== ''))) { |
455 |
|
// |
456 |
|
$val_dt['tax_su_non_habit_surf8'] = intval($val_dt['tax_su_non_habit_surf2']) + intval($val_dt['tax_su_non_habit_surf3']); |
457 |
|
} |
458 |
|
if (isset($val_dt['tax_su_non_habit_surf_stat2']) === true |
459 |
|
&& isset($val_dt['tax_su_non_habit_surf_stat3']) === true |
460 |
|
&& (($val_dt['tax_su_non_habit_surf_stat2'] !== null |
461 |
|
&& $val_dt['tax_su_non_habit_surf_stat2'] !== '') |
462 |
|
|| ($val_dt['tax_su_non_habit_surf_stat3'] !== null |
463 |
|
&& $val_dt['tax_su_non_habit_surf_stat3'] !== ''))) { |
464 |
|
// |
465 |
|
$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']); |
466 |
|
} |
467 |
|
// Cas particulier d'un projet réduit à l'extension d'une habitation existante |
468 |
|
$particular_case = false; |
469 |
|
$fields_tab_crea_loc_hab = $inst_dt->get_fields_tab_crea_loc_hab(); |
470 |
|
foreach ($fields_tab_crea_loc_hab as $field) { |
471 |
|
if (isset($val_dt[$field]) === false |
472 |
|
|| (isset($val_dt[$field]) === true |
473 |
|
&& ($val_dt[$field] === null |
474 |
|
|| $val_dt[$field] === ''))) { |
475 |
|
// |
476 |
|
$particular_case = true; |
477 |
|
} |
478 |
|
} |
479 |
|
if ($particular_case === true) { |
480 |
|
if (isset($val_dt['tax_ext_pret']) === true |
481 |
|
&& $val_dt['tax_ext_pret'] === 'f') { |
482 |
|
// |
483 |
|
$val_dt['tax_su_princ_surf1'] = $val_dt['tax_surf_tot_cstr']; |
484 |
|
$val_dt['tax_su_princ_surf_stat1'] = $val_dt['tax_surf_loc_stat']; |
485 |
|
} |
486 |
|
if (isset($val_dt['tax_ext_pret']) === true |
487 |
|
&& $val_dt['tax_ext_pret'] === 't') { |
488 |
|
// |
489 |
|
if (isset($val_dt['tax_ext_desc']) === true) { |
490 |
|
if (preg_match('/[pP].*[lL].*[aA].*[iI]/', $val_dt['tax_ext_desc']) === 1 |
491 |
|
|| preg_match('/[lL].*[lL].*[tT].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
492 |
|
// |
493 |
|
$val_dt['tax_su_princ_surf2'] = $val_dt['tax_surf_tot_cstr']; |
494 |
|
$val_dt['tax_su_princ_surf_stat2'] = $val_dt['tax_surf_loc_stat']; |
495 |
|
} |
496 |
|
// if (preg_match('/[pP].*[tT].*[zZ]/', $val_dt['tax_ext_desc']) === 1) { |
497 |
|
// $val_dt['tax_su_princ_surf4'] = $val_dt['tax_surf_tot_cstr']; |
498 |
|
// $val_dt['tax_su_princ_surf_stat4'] = $val_dt['tax_surf_loc_stat']; |
499 |
|
// } |
500 |
|
// if (preg_match('/[pP].*[lL].*[uU].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
501 |
|
// || preg_match('/[lL].*[eE].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
502 |
|
// || preg_match('/[pP].*[sS].*[lL].*[aA]/', $val_dt['tax_ext_desc']) === 1 |
503 |
|
// || preg_match('/[pP].*[lL].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
504 |
|
// || preg_match('/[lL].*[lL].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
505 |
|
// // |
506 |
|
// $val_dt['tax_su_princ_surf3'] = $val_dt['tax_surf_tot_cstr']; |
507 |
|
// $val_dt['tax_su_princ_surf_stat3'] = $val_dt['tax_surf_loc_stat']; |
508 |
|
// } |
509 |
|
} |
510 |
|
} |
511 |
|
} |
512 |
|
// Cas particulier de la surface taxable démolie |
513 |
|
if (isset($val_dt['tax_surf_tot_demo']) === true |
514 |
|
&& isset($val_dt['tax_surf_tax_demo']) === true |
515 |
|
&& ($val_dt['tax_surf_tot_demo'] === null |
516 |
|
|| $val_dt['tax_surf_tot_demo'] === '')) { |
517 |
|
// |
518 |
|
$val_dt['tax_surf_tot_demo'] = $val_dt['tax_surf_tax_demo']; |
519 |
|
} |
520 |
return $val_dt; |
return $val_dt; |
521 |
} |
} |
522 |
|
|
523 |
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
524 |
$inst_external_uid_da = $this->f->get_inst__by_other_idx(array( |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
525 |
"obj" => "lien_id_interne_uid_externe", |
"obj" => "lien_id_interne_uid_externe", |
526 |
"fk_field" => 'object_id', |
"fk_field" => 'object_id', |
527 |
"fk_idx" => $fk_idx, |
"fk_idx" => $fk_idx, |
528 |
"fk_field_2" => 'object', |
"fk_field_2" => 'object', |
529 |
"fk_idx_2" => $fk_idx_2, |
"fk_idx_2" => $fk_idx_2, |
530 |
)); |
)); |
531 |
return $inst_external_uid_da->getVal('external_uid'); |
return $inst_external_uid->getVal('external_uid'); |
532 |
} |
} |
533 |
|
|
534 |
protected function get_demandeurs_data(string $dossier) { |
protected function get_demandeurs_data(string $dossier) { |
543 |
"obj" => "demandeur", |
"obj" => "demandeur", |
544 |
"idx" => $demandeur['demandeur'], |
"idx" => $demandeur['demandeur'], |
545 |
)); |
)); |
546 |
$val_demandeur[$demandeur['demandeur']] = json_decode($inst_demandeur->get_json_data(), true); |
$val_demandeur[$demandeur['demandeur']] = $inst_demandeur->get_json_data(); |
547 |
$val_demandeur[$demandeur['demandeur']]['petitionnaire_principal'] = $demandeur['petitionnaire_principal']; |
$val_demandeur[$demandeur['demandeur']]['petitionnaire_principal'] = $demandeur['petitionnaire_principal']; |
548 |
} |
} |
549 |
return $val_demandeur; |
return $val_demandeur; |
550 |
} |
} |
551 |
|
|
552 |
protected function get_architecte_data($architecte = null) { |
protected function get_architecte_data($architecte = null) { |
553 |
$val_architecte = array(); |
$val_architecte = null; |
554 |
if ($architecte !== null |
if ($architecte !== null |
555 |
&& $architecte !== '') { |
&& $architecte !== '') { |
556 |
// |
// |
558 |
"obj" => "architecte", |
"obj" => "architecte", |
559 |
"idx" => $architecte, |
"idx" => $architecte, |
560 |
)); |
)); |
561 |
$val_architecte = json_decode($inst_architecte->get_json_data(), true); |
$val_architecte = $inst_architecte->get_json_data(); |
562 |
} |
} |
563 |
return $val_architecte; |
return $val_architecte; |
564 |
} |
} |
565 |
|
|
566 |
protected function get_instruction_data(string $dossier) { |
protected function get_instruction_data(string $dossier, $type = 'decision') { |
567 |
$val_instruction = array(); |
$val_instruction = null; |
568 |
|
$instruction_with_doc = null; |
569 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
570 |
"obj" => "dossier", |
"obj" => "dossier", |
571 |
"idx" => $dossier, |
"idx" => $dossier, |
572 |
)); |
)); |
573 |
|
$idx = null; |
574 |
|
if ($type === 'decision') { |
575 |
|
$idx = $inst_di->get_last_instruction_decision(); |
576 |
|
} |
577 |
|
if ($type === 'incompletude') { |
578 |
|
$idx = $inst_di->get_last_instruction_incompletude(); |
579 |
|
} |
580 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
581 |
"obj" => "instruction", |
"obj" => "instruction", |
582 |
"idx" => $inst_di->get_last_instruction_decision(), |
"idx" => $idx, |
583 |
)); |
)); |
584 |
if (count($inst_instruction->val) > 0) { |
if (count($inst_instruction->val) > 0) { |
585 |
$val_instruction = json_decode($inst_instruction->get_json_data(), true); |
$val_instruction = array(); |
586 |
|
$instruction_data = $inst_instruction->get_json_data(); |
587 |
|
$val_instruction = $this->sort_instruction_data($instruction_data, $val_instruction); |
588 |
|
if ($instruction_data['om_fichier_instruction'] !== null |
589 |
|
&& $instruction_data['om_fichier_instruction'] !== '') { |
590 |
|
// |
591 |
|
$instruction_with_doc = $inst_instruction->getVal($inst_instruction->clePrimaire); |
592 |
|
} |
593 |
|
$inst_ev = $this->f->get_inst__om_dbform(array( |
594 |
|
"obj" => "evenement", |
595 |
|
"idx" => $inst_instruction->getVal('evenement'), |
596 |
|
)); |
597 |
|
if ($inst_ev->getVal('retour') === 't') { |
598 |
|
$instructions_related = $inst_instruction->get_related_instructions(); |
599 |
|
foreach ($instructions_related as $instruction) { |
600 |
|
if ($instruction !== null && $instruction !== '') { |
601 |
|
$inst_related_instruction = $this->f->get_inst__om_dbform(array( |
602 |
|
"obj" => "instruction", |
603 |
|
"idx" => $instruction, |
604 |
|
)); |
605 |
|
$instruction_data = $inst_related_instruction->get_json_data(); |
606 |
|
$val_instruction = $this->sort_instruction_data($instruction_data, $val_instruction); |
607 |
|
if ($instruction_data['om_fichier_instruction'] !== null |
608 |
|
&& $instruction_data['om_fichier_instruction'] !== '') { |
609 |
|
// |
610 |
|
$instruction_with_doc = $inst_related_instruction->getVal($inst_related_instruction->clePrimaire); |
611 |
|
} |
612 |
|
} |
613 |
|
} |
614 |
|
} |
615 |
|
if ($instruction_with_doc !== null) { |
616 |
|
// |
617 |
|
$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); |
618 |
|
} |
619 |
} |
} |
620 |
return $val_instruction; |
return $val_instruction; |
621 |
} |
} |
622 |
|
|
623 |
|
protected function sort_instruction_data(array $values, array $res) { |
624 |
|
$fields = array( |
625 |
|
"date_envoi_signature", |
626 |
|
"date_retour_signature", |
627 |
|
"date_envoi_rar", |
628 |
|
"date_retour_rar", |
629 |
|
"date_envoi_controle_legalite", |
630 |
|
"date_retour_controle_legalite", |
631 |
|
"signataire_arrete", |
632 |
|
"om_fichier_instruction", |
633 |
|
"tacite", |
634 |
|
"lettretype", |
635 |
|
); |
636 |
|
foreach ($values as $key => $value) { |
637 |
|
if (in_array($key, $fields) === true) { |
638 |
|
if (array_key_exists($key, $res) === false |
639 |
|
&& $value !== null |
640 |
|
&& $value !== '') { |
641 |
|
// |
642 |
|
$res[$key] = $value; |
643 |
|
} elseif ($key === 'tacite' |
644 |
|
&& $value === 't') { |
645 |
|
// |
646 |
|
$res[$key] = $value; |
647 |
|
} |
648 |
|
} |
649 |
|
} |
650 |
|
return $res; |
651 |
|
} |
652 |
|
|
653 |
protected function get_document_numerise_data(string $dn) { |
protected function get_document_numerise_data(string $dn) { |
654 |
$val_dn = array(); |
$val_dn = array(); |
655 |
$inst_dn = $this->f->get_inst__om_dbform(array( |
$inst_dn = $this->f->get_inst__om_dbform(array( |
656 |
"obj" => "document_numerise", |
"obj" => "document_numerise", |
657 |
"idx" => $dn, |
"idx" => $dn, |
658 |
)); |
)); |
659 |
$val_dn = json_decode($inst_dn->get_json_data(), true); |
$val_dn = $inst_dn->get_json_data(); |
660 |
$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')); |
661 |
|
// Correspond à la nomenclature Plat'AU NATURE_PIECE |
662 |
|
$val_dn['nature'] = $val_dn['document_numerise_nature_libelle']; |
663 |
return $val_dn; |
return $val_dn; |
664 |
} |
} |
665 |
|
|
682 |
return $val_dp; |
return $val_dp; |
683 |
} |
} |
684 |
|
|
685 |
protected function view_form_json() { |
protected function view_form_json($in_field = false) { |
686 |
// Mise à jour des valeurs |
// |
687 |
if ($this->f->get_submitted_get_value('valid') === 'true' |
if ($this->f->get_submitted_post_value('valid') === null) { |
688 |
&& $this->f->get_submitted_get_value('state') !== null) { |
// Liste des valeurs à afficher |
689 |
|
$val = array(); |
690 |
// |
// |
691 |
$params = array( |
$val_task = array_combine($this->champs, $this->val); |
692 |
'val' => array( |
foreach ($val_task as $key => $value) { |
693 |
'state' => $this->f->get_submitted_get_value('state') |
$val_task[$key] = strip_tags($value); |
|
), |
|
|
); |
|
|
$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.') |
|
|
); |
|
694 |
} |
} |
695 |
$this->f->displayMessage($message_class, $message); |
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
696 |
} |
$val['task'] = $val_task; |
|
// |
|
|
if ($this->f->get_submitted_get_value('valid') === 'true' |
|
|
&& $this->f->get_submitted_get_value('external_uid') !== null) { |
|
697 |
// |
// |
698 |
$inst_lien = $this->f->get_inst__om_dbform(array( |
if ($this->getVal('type') === 'creation_DA') { |
699 |
"obj" => "lien_id_interne_uid_externe", |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
700 |
"idx" => ']', |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
701 |
)); |
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
702 |
$valF = array( |
$val_external_uid = array(); |
703 |
'lien_id_interne_uid_externe' => '', |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
704 |
'object' => $this->get_lien_objet_by_type($this->getVal('type')), |
$val['external_uids'] = $val_external_uid; |
705 |
'object_id' => $this->getVal('object_id'), |
} |
706 |
'external_uid' => $this->f->get_submitted_get_value('external_uid'), |
// |
707 |
); |
if ($this->getVal('type') === 'creation_DI' |
708 |
$add = $inst_lien->ajouter($valF); |
|| $this->getVal('type') === 'modification_DI' |
709 |
$message_class = "valid"; |
|| $this->getVal('type') === 'depot_DI') { |
710 |
$message = $inst_lien->msg; |
// |
711 |
if ($add === false) { |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
712 |
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction'); |
713 |
$message_class = "error"; |
$val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']); |
714 |
$message = sprintf( |
$architecte = isset($val['donnees_techniques']['architecte']) === true ? $val['donnees_techniques']['architecte'] : null; |
715 |
'%s %s', |
$val['architecte'] = $this->get_architecte_data($architecte); |
716 |
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
$val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']); |
717 |
__('Veuillez contacter votre administrateur.') |
$val_external_uid = array(); |
718 |
); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
719 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
720 |
|
$val['external_uids'] = $val_external_uid; |
721 |
} |
} |
|
$this->f->displayMessage($message_class, $message); |
|
|
} |
|
|
|
|
|
// Liste des valeurs à afficher |
|
|
$val = array(); |
|
|
// |
|
|
$val_task = array_combine($this->champs, $this->val); |
|
|
$val['task'] = $val_task; |
|
|
// |
|
|
if ($this->getVal('type') === 'creation_DA') { |
|
|
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
|
|
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
|
|
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val['external_uid'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'creation_DI' |
|
|
|| $this->getVal('type') === 'modification_DI') { |
|
722 |
// |
// |
723 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
if ($this->getVal('type') === 'qualification_DI') { |
724 |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction'); |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
725 |
$val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']); |
$val_external_uid = array(); |
726 |
$val['architecte'] = $this->get_architecte_data($val['donnees_techniques']['architecte']); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
727 |
$val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
728 |
$val_external_uid = array(); |
$val['external_uids'] = $val_external_uid; |
729 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
} |
730 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
// |
731 |
$val['external_uid'] = $val_external_uid; |
if ($this->getVal('type') === 'ajout_piece') { |
732 |
|
$val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id')); |
733 |
|
$val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']); |
734 |
|
$val_external_uid = array(); |
735 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
736 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
737 |
|
$val_external_uid['document_numerise'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'document_numerise'); |
738 |
|
$val['external_uids'] = $val_external_uid; |
739 |
|
} |
740 |
|
// |
741 |
|
if ($this->getVal('type') === 'decision_DI') { |
742 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
743 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier']); |
744 |
|
$val_external_uid = array(); |
745 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
746 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
747 |
|
$val['external_uids'] = $val_external_uid; |
748 |
|
} |
749 |
|
// |
750 |
|
if ($this->getVal('type') === 'incompletude_DI') { |
751 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
752 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'incompletude'); |
753 |
|
$val_external_uid = array(); |
754 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
755 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
756 |
|
$val['external_uids'] = $val_external_uid; |
757 |
|
} |
758 |
|
// |
759 |
|
if ($this->getVal('type') === 'completude_DI') { |
760 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
761 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'completude'); |
762 |
|
$val_external_uid = array(); |
763 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
764 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
765 |
|
$val['external_uids'] = $val_external_uid; |
766 |
|
} |
767 |
|
|
768 |
|
if ($in_field === true) { |
769 |
|
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
770 |
|
} else { |
771 |
|
// Liste des valeurs affichée en JSON |
772 |
|
printf(json_encode($val, JSON_UNESCAPED_SLASHES)); |
773 |
|
} |
774 |
} |
} |
775 |
|
} |
776 |
|
|
777 |
|
function view_update_task() { |
778 |
|
// Mise à jour des valeurs |
779 |
// |
// |
780 |
if ($this->getVal('type') === 'qualification_DI') { |
$params = array( |
781 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
'val' => array( |
782 |
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier']); |
'state' => $this->f->get_submitted_post_value('state') |
783 |
$val_external_uid = array(); |
), |
784 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
); |
785 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$update = $this->update_task($params); |
786 |
$val['external_uid'] = $val_external_uid; |
$message_class = "valid"; |
787 |
|
$message = $this->msg; |
788 |
|
if ($update === false) { |
789 |
|
$this->addToLog($this->msg, DEBUG_MODE); |
790 |
|
$message_class = "error"; |
791 |
|
$message = sprintf( |
792 |
|
'%s %s', |
793 |
|
__('Impossible de mettre à jour la tâche.'), |
794 |
|
__('Veuillez contacter votre administrateur.') |
795 |
|
); |
796 |
} |
} |
797 |
|
$this->f->displayMessage($message_class, $message); |
798 |
// |
// |
799 |
if ($this->getVal('type') === 'ajout_piece') { |
$inst_lien = $this->f->get_inst__om_dbform(array( |
800 |
$val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id')); |
"obj" => "lien_id_interne_uid_externe", |
801 |
$val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']); |
"idx" => ']', |
802 |
$val_external_uid = array(); |
)); |
803 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$valF = array( |
804 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
'lien_id_interne_uid_externe' => '', |
805 |
$val_external_uid['document_numerise'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'document_numerise'); |
'object' => $this->get_lien_objet_by_type($this->getVal('type')), |
806 |
$val['external_uid'] = $val_external_uid; |
'object_id' => $this->getVal('object_id'), |
807 |
|
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
808 |
|
); |
809 |
|
$add = $inst_lien->ajouter($valF); |
810 |
|
$message_class = "valid"; |
811 |
|
$message = $inst_lien->msg; |
812 |
|
if ($add === false) { |
813 |
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
814 |
|
$message_class = "error"; |
815 |
|
$message = sprintf( |
816 |
|
'%s %s', |
817 |
|
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
818 |
|
__('Veuillez contacter votre administrateur.') |
819 |
|
); |
820 |
} |
} |
821 |
|
$this->f->displayMessage($message_class, $message); |
822 |
|
} |
823 |
|
|
824 |
// Liste des valeurs affichée en JSON |
function view_add_task() { |
825 |
printf(json_encode($val)); |
$params = array(); |
826 |
|
$params['val']['stream'] = 'input'; |
827 |
|
$params['val']['json_payload'] = html_entity_decode($this->f->get_submitted_post_value('json_payload')); |
828 |
|
$json_payload = json_decode($params['val']['json_payload'], true); |
829 |
|
$params['val']['type'] = $json_payload['task']['type']; |
830 |
|
$params['val']['dossier'] = $json_payload['task']['dossier']; |
831 |
|
$params['val']['object_id'] = ""; |
832 |
|
$result = $this->add_task($params); |
833 |
|
$message = $this->msg; |
834 |
|
$message_class = "valid"; |
835 |
|
if ($result === false){ |
836 |
|
$this->addToLog($this->msg, DEBUG_MODE); |
837 |
|
$message_class = "error"; |
838 |
|
$message = sprintf( |
839 |
|
'%s %s', |
840 |
|
__('Impossible d\'ajouter la tâche.'), |
841 |
|
__('Veuillez contacter votre administrateur.') |
842 |
|
); |
843 |
|
} |
844 |
|
$this->f->displayMessage($message_class, $message); |
845 |
} |
} |
846 |
|
|
847 |
protected function get_lien_objet_by_type($type) { |
protected function get_lien_objet_by_type($type) { |
850 |
if ($type === 'creation_DA') { |
if ($type === 'creation_DA') { |
851 |
$objet = 'dossier_autorisation'; |
$objet = 'dossier_autorisation'; |
852 |
} |
} |
853 |
if ($type === 'creation_DI' || $type = 'modification_DI') { |
if ($type === 'creation_DI' |
854 |
|
|| $type === 'depot_DI' |
855 |
|
|| $type === 'modification_DI' |
856 |
|
|| $type === 'qualification_DI' |
857 |
|
|| $type === 'decision_DI' |
858 |
|
|| $type === 'incompletude_DI' |
859 |
|
|| $type === 'completude_DI') { |
860 |
|
// |
861 |
$objet = 'dossier'; |
$objet = 'dossier'; |
862 |
} |
} |
863 |
if ($type === 'ajout_piece') { |
if ($type === 'ajout_piece') { |
865 |
} |
} |
866 |
return $objet; |
return $objet; |
867 |
} |
} |
868 |
|
|
869 |
|
function setLayout(&$form, $maj) { |
870 |
|
$form->setBloc('json_payload', 'D', '', 'col_6'); |
871 |
|
$form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed"); |
872 |
|
$form->setBloc('json_payload', 'F'); |
873 |
|
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
874 |
|
} |
875 |
|
|
876 |
} |
} |