15 |
parent::init_class_actions(); |
parent::init_class_actions(); |
16 |
// |
// |
17 |
$this->class_actions[998] = array( |
$this->class_actions[998] = array( |
18 |
"identifier" => "view_json", |
"identifier" => "json_data", |
19 |
"view" => "view_json", |
"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 |
|
} |
143 |
|
} |
144 |
|
|
145 |
|
public function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
146 |
|
parent::verifier($val, $dnu1, $dnu2); |
147 |
|
// |
148 |
|
if (array_key_exists('timestamp_log', $this->valF) === true |
149 |
|
&& is_array(json_decode($this->valF['timestamp_log'], true)) === false) { |
150 |
|
// |
151 |
|
$this->correct = false; |
152 |
|
$this->addToMessage(sprintf( |
153 |
|
__("Le champ %s doit être dans un format JSON valide."), |
154 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('timestamp_log')) |
155 |
|
)); |
156 |
|
} |
157 |
|
} |
158 |
|
|
159 |
|
protected function task_exists(string $type, string $object_id) { |
160 |
|
$query = sprintf(' |
161 |
|
SELECT task |
162 |
|
FROM %1$stask |
163 |
|
WHERE state != \'%2$s\' |
164 |
|
AND type = \'%3$s\' |
165 |
|
AND object_id = \'%4$s\' |
166 |
|
', |
167 |
|
DB_PREFIXE, |
168 |
|
'done', |
169 |
|
$type, |
170 |
|
$object_id |
171 |
|
); |
172 |
|
$res = $this->f->get_one_result_from_db_query($query); |
173 |
|
if ($res['result'] !== null && $res['result'] !== '') { |
174 |
|
return $res['result']; |
175 |
|
} |
176 |
|
return false; |
177 |
} |
} |
178 |
|
|
179 |
/** |
/** |
193 |
'task' => '', |
'task' => '', |
194 |
'type' => $params['val']['type'], |
'type' => $params['val']['type'], |
195 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
196 |
'state' => 'draft', |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : 'new', |
197 |
'id' => $params['val']['id'], |
'object_id' => $params['val']['object_id'], |
198 |
|
'dossier' => $params['val']['dossier'], |
199 |
|
'stream' => isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output', |
200 |
|
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
201 |
); |
); |
202 |
|
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
203 |
|
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
204 |
|
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
205 |
|
} |
206 |
|
if ($task_exists !== false) { |
207 |
|
$inst_task = $this->f->get_inst__om_dbform(array( |
208 |
|
"obj" => "task", |
209 |
|
"idx" => $task_exists, |
210 |
|
)); |
211 |
|
$update_state = $inst_task->getVal('state'); |
212 |
|
if (isset($params['update_val']['state']) === true) { |
213 |
|
$update_state = $params['update_val']['state']; |
214 |
|
} |
215 |
|
$update_params = array( |
216 |
|
'val' => array( |
217 |
|
'state' => $update_state, |
218 |
|
), |
219 |
|
); |
220 |
|
return $inst_task->update_task($update_params); |
221 |
|
} |
222 |
$add = $this->ajouter($valF); |
$add = $this->ajouter($valF); |
223 |
if ($add === false) { |
if ($add === false) { |
224 |
$this->addToLog($this->msg, DEBUG_MODE); |
$this->addToLog($this->msg, DEBUG_MODE); |
252 |
'type' => $this->getVal('type'), |
'type' => $this->getVal('type'), |
253 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
254 |
'state' => $params['val']['state'], |
'state' => $params['val']['state'], |
255 |
'id' => $this->getVal('id'), |
'object_id' => $this->getVal('object_id'), |
256 |
|
'stream' => $this->getVal('stream'), |
257 |
|
'dossier' => $this->getVal('dossier'), |
258 |
|
'json_payload' => $this->getVal('json_payload'), |
259 |
); |
); |
260 |
$update = $this->modifier($valF); |
$update = $this->modifier($valF); |
261 |
if ($update === false) { |
if ($update === false) { |
284 |
} |
} |
285 |
|
|
286 |
/** |
/** |
287 |
* VIEW - view_json |
* VIEW - view_json_data |
288 |
* Affiche l'enregistrement dans le format JSON. |
* Affiche l'enregistrement dans le format JSON. |
289 |
* |
* |
290 |
* @return void |
* @return void |
291 |
*/ |
*/ |
292 |
public function view_json() { |
public function view_json_data() { |
293 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
294 |
$val = array_combine($this->champs, $this->val); |
$this->f->disableLog(); |
295 |
printf(json_encode($val)); |
if ($this->getParameter('idx') !== ']' |
296 |
if ($this->f->get_submitted_post_value('valid') === 'true' |
&& $this->getParameter('idx') !== '0') { |
|
&& $this->f->get_submitted_post_value('state') !== null) { |
|
297 |
// |
// |
298 |
$params = array( |
$this->view_form_json(); |
299 |
'val' => array( |
} |
300 |
'state' => $this->f->get_submitted_post_value('state') |
else { |
301 |
), |
$this->view_tab_json(); |
302 |
|
} |
303 |
|
} |
304 |
|
|
305 |
|
protected function view_tab_json() { |
306 |
|
$where = ''; |
307 |
|
if ($this->f->get_submitted_get_value('state') !== null |
308 |
|
&& $this->f->get_submitted_get_value('state') !== '') { |
309 |
|
// |
310 |
|
$where = sprintf(' WHERE state = \'%s\' ', $this->f->get_submitted_get_value('state')); |
311 |
|
} |
312 |
|
$query = sprintf(' |
313 |
|
SELECT |
314 |
|
* |
315 |
|
FROM %1$stask |
316 |
|
%2$s |
317 |
|
ORDER BY task ASC |
318 |
|
', |
319 |
|
DB_PREFIXE, |
320 |
|
$where |
321 |
|
); |
322 |
|
$res = $this->f->get_all_results_from_db_query($query, true); |
323 |
|
if ($res['code'] === 'KO') { |
324 |
|
return false; |
325 |
|
} |
326 |
|
$list_tasks = array(); |
327 |
|
foreach ($res['result'] as $task) { |
328 |
|
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
329 |
|
$task['dossier'] = $task['object_id']; |
330 |
|
if ($this->get_lien_objet_by_type($task['type']) === 'document_numerise') { |
331 |
|
$val_dn = $this->get_document_numerise_data($task['object_id']); |
332 |
|
$task['dossier'] = $val_dn['dossier']; |
333 |
|
} |
334 |
|
$list_tasks[$task['task']] = $task; |
335 |
|
} |
336 |
|
printf(json_encode($list_tasks)); |
337 |
|
} |
338 |
|
|
339 |
|
protected function get_dossier_data(string $dossier) { |
340 |
|
$val_di = array(); |
341 |
|
$inst_di = $this->f->get_inst__om_dbform(array( |
342 |
|
"obj" => "dossier", |
343 |
|
"idx" => $dossier, |
344 |
|
)); |
345 |
|
$val_di = $inst_di->get_json_data(); |
346 |
|
if ($val_di['dossier_instruction_type_code'] === 'T') { |
347 |
|
$val_di['date_decision_transfert'] = $val_di['date_decision']; |
348 |
|
} |
349 |
|
unset($val_di['initial_dt']); |
350 |
|
unset($val_di['log_instructions']); |
351 |
|
return $val_di; |
352 |
|
} |
353 |
|
|
354 |
|
protected function get_dossier_autorisation_data(string $da) { |
355 |
|
$val_da = array(); |
356 |
|
$inst_da = $this->f->get_inst__om_dbform(array( |
357 |
|
"obj" => "dossier_autorisation", |
358 |
|
"idx" => $da, |
359 |
|
)); |
360 |
|
$val_da = $inst_da->get_json_data(); |
361 |
|
return $val_da; |
362 |
|
} |
363 |
|
|
364 |
|
protected function get_donnees_techniques_data(string $fk_idx, string $fk_field) { |
365 |
|
$val_dt = array(); |
366 |
|
$inst_dt = $this->f->get_inst__by_other_idx(array( |
367 |
|
"obj" => "donnees_techniques", |
368 |
|
"fk_field" => $fk_field, |
369 |
|
"fk_idx" => $fk_idx, |
370 |
|
)); |
371 |
|
$val_dt = array( |
372 |
|
'donnees_techniques' => $inst_dt->getVal($inst_dt->clePrimaire), |
373 |
|
'cerfa' => $inst_dt->getVal('cerfa'), |
374 |
|
); |
375 |
|
$val_dt = array_merge($val_dt, $inst_dt->get_donnees_techniques_applicables()); |
376 |
|
if (isset($val_dt['am_exist_date']) === true) { |
377 |
|
$val_dt['am_exist_date_num'] = ''; |
378 |
|
if (is_numeric($val_dt['am_exist_date']) === true) { |
379 |
|
$val_dt['am_exist_date_num'] = $val_dt['am_exist_date']; |
380 |
|
} |
381 |
|
} |
382 |
|
// Correspond à la nomenclature de Plat'AU STATUT_INFO |
383 |
|
$val_dt['tax_statut_info'] = 'Déclaré'; |
384 |
|
// |
385 |
|
if ($inst_dt->is_tab_surf_ssdest_enabled() === true) { |
386 |
|
$fields_tab_surf_dest = $inst_dt->get_fields_tab_surf_dest(); |
387 |
|
foreach ($fields_tab_surf_dest as $field) { |
388 |
|
if (isset($val_dt[$field]) === true) { |
389 |
|
unset($val_dt[$field]); |
390 |
|
} |
391 |
|
} |
392 |
|
} else { |
393 |
|
$fields_tab_surf_ssdest = $inst_dt->get_fields_tab_surf_ssdest(); |
394 |
|
foreach ($fields_tab_surf_ssdest as $field) { |
395 |
|
if (isset($val_dt[$field]) === true) { |
396 |
|
unset($val_dt[$field]); |
397 |
|
} |
398 |
|
} |
399 |
|
} |
400 |
|
// Correspond à la nouvelle ligne CERFA v7 dans le DENSI imposition 1.2.3 |
401 |
|
if (isset($val_dt['tax_su_non_habit_surf2']) === true |
402 |
|
&& isset($val_dt['tax_su_non_habit_surf3']) === true |
403 |
|
&& (($val_dt['tax_su_non_habit_surf2'] !== null |
404 |
|
&& $val_dt['tax_su_non_habit_surf2'] !== '') |
405 |
|
|| ($val_dt['tax_su_non_habit_surf3'] !== null |
406 |
|
&& $val_dt['tax_su_non_habit_surf3'] !== ''))) { |
407 |
|
// |
408 |
|
$val_dt['tax_su_non_habit_surf8'] = intval($val_dt['tax_su_non_habit_surf2']) + intval($val_dt['tax_su_non_habit_surf3']); |
409 |
|
} |
410 |
|
if (isset($val_dt['tax_su_non_habit_surf_stat2']) === true |
411 |
|
&& isset($val_dt['tax_su_non_habit_surf_stat3']) === true |
412 |
|
&& (($val_dt['tax_su_non_habit_surf_stat2'] !== null |
413 |
|
&& $val_dt['tax_su_non_habit_surf_stat2'] !== '') |
414 |
|
|| ($val_dt['tax_su_non_habit_surf_stat3'] !== null |
415 |
|
&& $val_dt['tax_su_non_habit_surf_stat3'] !== ''))) { |
416 |
|
// |
417 |
|
$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']); |
418 |
|
} |
419 |
|
// Cas particulier d'un projet réduit à l'extension d'une habitation existante |
420 |
|
$particular_case = false; |
421 |
|
$fields_tab_crea_loc_hab = $inst_dt->get_fields_tab_crea_loc_hab(); |
422 |
|
foreach ($fields_tab_crea_loc_hab as $field) { |
423 |
|
if (isset($val_dt[$field]) === false |
424 |
|
|| (isset($val_dt[$field]) === true |
425 |
|
&& ($val_dt[$field] === null |
426 |
|
|| $val_dt[$field] === ''))) { |
427 |
|
// |
428 |
|
$particular_case = true; |
429 |
|
} |
430 |
|
} |
431 |
|
if ($particular_case === true) { |
432 |
|
if (isset($val_dt['tax_ext_pret']) === true |
433 |
|
&& $val_dt['tax_ext_pret'] === 'f') { |
434 |
|
// |
435 |
|
$val_dt['tax_su_princ_surf1'] = $val_dt['tax_surf_tot_cstr']; |
436 |
|
$val_dt['tax_su_princ_surf_stat1'] = $val_dt['tax_surf_loc_stat']; |
437 |
|
} |
438 |
|
if (isset($val_dt['tax_ext_pret']) === true |
439 |
|
&& $val_dt['tax_ext_pret'] === 't') { |
440 |
|
// |
441 |
|
if (isset($val_dt['tax_ext_desc']) === true) { |
442 |
|
if (preg_match('/[pP].*[lL].*[aA].*[iI]/', $val_dt['tax_ext_desc']) === 1 |
443 |
|
|| preg_match('/[lL].*[lL].*[tT].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
444 |
|
// |
445 |
|
$val_dt['tax_su_princ_surf2'] = $val_dt['tax_surf_tot_cstr']; |
446 |
|
$val_dt['tax_su_princ_surf_stat2'] = $val_dt['tax_surf_loc_stat']; |
447 |
|
} |
448 |
|
// if (preg_match('/[pP].*[tT].*[zZ]/', $val_dt['tax_ext_desc']) === 1) { |
449 |
|
// $val_dt['tax_su_princ_surf4'] = $val_dt['tax_surf_tot_cstr']; |
450 |
|
// $val_dt['tax_su_princ_surf_stat4'] = $val_dt['tax_surf_loc_stat']; |
451 |
|
// } |
452 |
|
// if (preg_match('/[pP].*[lL].*[uU].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
453 |
|
// || preg_match('/[lL].*[eE].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
454 |
|
// || preg_match('/[pP].*[sS].*[lL].*[aA]/', $val_dt['tax_ext_desc']) === 1 |
455 |
|
// || preg_match('/[pP].*[lL].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
456 |
|
// || preg_match('/[lL].*[lL].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
457 |
|
// // |
458 |
|
// $val_dt['tax_su_princ_surf3'] = $val_dt['tax_surf_tot_cstr']; |
459 |
|
// $val_dt['tax_su_princ_surf_stat3'] = $val_dt['tax_surf_loc_stat']; |
460 |
|
// } |
461 |
|
} |
462 |
|
} |
463 |
|
} |
464 |
|
// Cas particulier de la surface taxable démolie |
465 |
|
if (isset($val_dt['tax_surf_tot_demo']) === true |
466 |
|
&& isset($val_dt['tax_surf_tax_demo']) === true |
467 |
|
&& ($val_dt['tax_surf_tot_demo'] === null |
468 |
|
|| $val_dt['tax_surf_tot_demo'] === '')) { |
469 |
|
// |
470 |
|
$val_dt['tax_surf_tot_demo'] = $val_dt['tax_surf_tax_demo']; |
471 |
|
} |
472 |
|
return $val_dt; |
473 |
|
} |
474 |
|
|
475 |
|
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
476 |
|
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
477 |
|
"obj" => "lien_id_interne_uid_externe", |
478 |
|
"fk_field" => 'object_id', |
479 |
|
"fk_idx" => $fk_idx, |
480 |
|
"fk_field_2" => 'object', |
481 |
|
"fk_idx_2" => $fk_idx_2, |
482 |
|
)); |
483 |
|
return $inst_external_uid->getVal('external_uid'); |
484 |
|
} |
485 |
|
|
486 |
|
protected function get_demandeurs_data(string $dossier) { |
487 |
|
$val_demandeur = array(); |
488 |
|
$inst_di = $this->f->get_inst__om_dbform(array( |
489 |
|
"obj" => "dossier", |
490 |
|
"idx" => $dossier, |
491 |
|
)); |
492 |
|
$list_demandeurs = $inst_di->get_demandeurs(); |
493 |
|
foreach ($list_demandeurs as $demandeur) { |
494 |
|
$inst_demandeur = $this->f->get_inst__om_dbform(array( |
495 |
|
"obj" => "demandeur", |
496 |
|
"idx" => $demandeur['demandeur'], |
497 |
|
)); |
498 |
|
$val_demandeur[$demandeur['demandeur']] = $inst_demandeur->get_json_data(); |
499 |
|
$val_demandeur[$demandeur['demandeur']]['petitionnaire_principal'] = $demandeur['petitionnaire_principal']; |
500 |
|
} |
501 |
|
return $val_demandeur; |
502 |
|
} |
503 |
|
|
504 |
|
protected function get_architecte_data($architecte = null) { |
505 |
|
$val_architecte = null; |
506 |
|
if ($architecte !== null |
507 |
|
&& $architecte !== '') { |
508 |
|
// |
509 |
|
$inst_architecte = $this->f->get_inst__om_dbform(array( |
510 |
|
"obj" => "architecte", |
511 |
|
"idx" => $architecte, |
512 |
|
)); |
513 |
|
$val_architecte = $inst_architecte->get_json_data(); |
514 |
|
} |
515 |
|
return $val_architecte; |
516 |
|
} |
517 |
|
|
518 |
|
protected function get_instruction_data(string $dossier, $type = 'decision') { |
519 |
|
$val_instruction = null; |
520 |
|
$instruction_with_doc = null; |
521 |
|
$inst_di = $this->f->get_inst__om_dbform(array( |
522 |
|
"obj" => "dossier", |
523 |
|
"idx" => $dossier, |
524 |
|
)); |
525 |
|
$idx = null; |
526 |
|
if ($type === 'decision') { |
527 |
|
$idx = $inst_di->get_last_instruction_decision(); |
528 |
|
} |
529 |
|
if ($type === 'incompletude') { |
530 |
|
$idx = $inst_di->get_last_instruction_incompletude(); |
531 |
|
} |
532 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
533 |
|
"obj" => "instruction", |
534 |
|
"idx" => $idx, |
535 |
|
)); |
536 |
|
if (count($inst_instruction->val) > 0) { |
537 |
|
$val_instruction = array(); |
538 |
|
$instruction_data = $inst_instruction->get_json_data(); |
539 |
|
$val_instruction = $this->sort_instruction_data($instruction_data, $val_instruction); |
540 |
|
if ($instruction_data['om_fichier_instruction'] !== null |
541 |
|
&& $instruction_data['om_fichier_instruction'] !== '') { |
542 |
|
// |
543 |
|
$instruction_with_doc = $inst_instruction->getVal($inst_instruction->clePrimaire); |
544 |
|
} |
545 |
|
$inst_ev = $this->f->get_inst__om_dbform(array( |
546 |
|
"obj" => "evenement", |
547 |
|
"idx" => $inst_instruction->getVal('evenement'), |
548 |
|
)); |
549 |
|
if ($inst_ev->getVal('retour') === 't') { |
550 |
|
$instructions_related = $inst_instruction->get_related_instructions(); |
551 |
|
foreach ($instructions_related as $instruction) { |
552 |
|
if ($instruction !== null && $instruction !== '') { |
553 |
|
$inst_related_instruction = $this->f->get_inst__om_dbform(array( |
554 |
|
"obj" => "instruction", |
555 |
|
"idx" => $instruction, |
556 |
|
)); |
557 |
|
$instruction_data = $inst_related_instruction->get_json_data(); |
558 |
|
$val_instruction = $this->sort_instruction_data($instruction_data, $val_instruction); |
559 |
|
if ($instruction_data['om_fichier_instruction'] !== null |
560 |
|
&& $instruction_data['om_fichier_instruction'] !== '') { |
561 |
|
// |
562 |
|
$instruction_with_doc = $inst_related_instruction->getVal($inst_related_instruction->clePrimaire); |
563 |
|
} |
564 |
|
} |
565 |
|
} |
566 |
|
} |
567 |
|
if ($instruction_with_doc !== null) { |
568 |
|
// |
569 |
|
$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); |
570 |
|
} |
571 |
|
} |
572 |
|
return $val_instruction; |
573 |
|
} |
574 |
|
|
575 |
|
protected function sort_instruction_data(array $values, array $res) { |
576 |
|
$fields = array( |
577 |
|
"date_envoi_signature", |
578 |
|
"date_retour_signature", |
579 |
|
"date_envoi_rar", |
580 |
|
"date_retour_rar", |
581 |
|
"date_envoi_controle_legalite", |
582 |
|
"date_retour_controle_legalite", |
583 |
|
"signataire_arrete", |
584 |
|
"om_fichier_instruction", |
585 |
|
"tacite", |
586 |
|
"lettretype", |
587 |
|
); |
588 |
|
foreach ($values as $key => $value) { |
589 |
|
if (in_array($key, $fields) === true) { |
590 |
|
if (array_key_exists($key, $res) === false |
591 |
|
&& $value !== null |
592 |
|
&& $value !== '') { |
593 |
|
// |
594 |
|
$res[$key] = $value; |
595 |
|
} elseif ($key === 'tacite' |
596 |
|
&& $value === 't') { |
597 |
|
// |
598 |
|
$res[$key] = $value; |
599 |
|
} |
600 |
|
} |
601 |
|
} |
602 |
|
return $res; |
603 |
|
} |
604 |
|
|
605 |
|
protected function get_document_numerise_data(string $dn) { |
606 |
|
$val_dn = array(); |
607 |
|
$inst_dn = $this->f->get_inst__om_dbform(array( |
608 |
|
"obj" => "document_numerise", |
609 |
|
"idx" => $dn, |
610 |
|
)); |
611 |
|
$val_dn = $inst_dn->get_json_data(); |
612 |
|
$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')); |
613 |
|
// Correspond à la nomenclature Plat'AU NATURE_PIECE |
614 |
|
$val_dn['nature'] = $val_dn['document_numerise_nature_libelle']; |
615 |
|
return $val_dn; |
616 |
|
} |
617 |
|
|
618 |
|
protected function get_parcelles_data(string $object, string $idx) { |
619 |
|
$val_dp = array(); |
620 |
|
$inst_di = $this->f->get_inst__om_dbform(array( |
621 |
|
"obj" => $object, |
622 |
|
"idx" => $idx, |
623 |
|
)); |
624 |
|
$list_parcelles = $inst_di->get_parcelles(); |
625 |
|
$no_ordre = 1; |
626 |
|
foreach ($list_parcelles as $parcelle) { |
627 |
|
$val_dp[$parcelle[$object.'_parcelle']] = array( |
628 |
|
$object.'_parcelle' => $parcelle[$object.'_parcelle'], |
629 |
|
'libelle' => $parcelle['libelle'], |
630 |
|
'no_ordre' => $no_ordre, |
631 |
); |
); |
632 |
$update = $this->update_task($params); |
$no_ordre++; |
633 |
$message_class = "valid"; |
} |
634 |
$message = $this->msg; |
return $val_dp; |
635 |
if ($update === false) { |
} |
636 |
$this->addToLog($this->msg, DEBUG_MODE); |
|
637 |
$message_class = "error"; |
protected function view_form_json($in_field = false) { |
638 |
$message = sprintf( |
// |
639 |
'%s %s', |
if ($this->f->get_submitted_post_value('valid') === null) { |
640 |
__('Impossible de mettre à jour la tâche.'), |
// Liste des valeurs à afficher |
641 |
__('Veuillez contacter votre administrateur.') |
$val = array(); |
642 |
); |
// |
643 |
|
$val_task = array_combine($this->champs, $this->val); |
644 |
|
foreach ($val_task as $key => $value) { |
645 |
|
$val_task[$key] = strip_tags($value); |
646 |
|
} |
647 |
|
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
648 |
|
$val['task'] = $val_task; |
649 |
|
// |
650 |
|
if ($this->getVal('type') === 'creation_DA') { |
651 |
|
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
652 |
|
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
653 |
|
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
654 |
|
$val_external_uid = array(); |
655 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
656 |
|
$val['external_uid'] = $val_external_uid; |
657 |
|
} |
658 |
|
// |
659 |
|
if ($this->getVal('type') === 'creation_DI' |
660 |
|
|| $this->getVal('type') === 'modification_DI' |
661 |
|
|| $this->getVal('type') === 'depot_DI') { |
662 |
|
// |
663 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
664 |
|
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction'); |
665 |
|
$val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']); |
666 |
|
$architecte = isset($val['donnees_techniques']['architecte']) === true ? $val['donnees_techniques']['architecte'] : null; |
667 |
|
$val['architecte'] = $this->get_architecte_data($architecte); |
668 |
|
$val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']); |
669 |
|
$val_external_uid = array(); |
670 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
671 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
672 |
|
$val['external_uid'] = $val_external_uid; |
673 |
|
} |
674 |
|
// |
675 |
|
if ($this->getVal('type') === 'qualification_DI') { |
676 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
677 |
|
$val_external_uid = array(); |
678 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
679 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
680 |
|
$val['external_uid'] = $val_external_uid; |
681 |
|
} |
682 |
|
// |
683 |
|
if ($this->getVal('type') === 'ajout_piece') { |
684 |
|
$val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id')); |
685 |
|
$val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']); |
686 |
|
$val_external_uid = array(); |
687 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
688 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
689 |
|
$val_external_uid['document_numerise'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'document_numerise'); |
690 |
|
$val['external_uid'] = $val_external_uid; |
691 |
|
} |
692 |
|
// |
693 |
|
if ($this->getVal('type') === 'decision_DI') { |
694 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
695 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier']); |
696 |
|
$val_external_uid = array(); |
697 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
698 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
699 |
|
$val['external_uid'] = $val_external_uid; |
700 |
} |
} |
701 |
$this->f->displayMessage($message_class, $message); |
// |
702 |
|
if ($this->getVal('type') === 'incompletude_DI') { |
703 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
704 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'incompletude'); |
705 |
|
$val_external_uid = array(); |
706 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
707 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
708 |
|
$val['external_uid'] = $val_external_uid; |
709 |
|
} |
710 |
|
// |
711 |
|
if ($this->getVal('type') === 'completude_DI') { |
712 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
713 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'completude'); |
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 ($in_field === true) { |
721 |
|
return json_encode($val, JSON_PRETTY_PRINT ,JSON_UNESCAPED_SLASHES); |
722 |
|
} else { |
723 |
|
// Liste des valeurs affichée en JSON |
724 |
|
printf(json_encode($val, JSON_UNESCAPED_SLASHES)); |
725 |
|
} |
726 |
|
} |
727 |
|
} |
728 |
|
|
729 |
|
function view_update_json_data() { |
730 |
|
// Mise à jour des valeurs |
731 |
|
// |
732 |
|
$params = array( |
733 |
|
'val' => array( |
734 |
|
'state' => $this->f->get_submitted_post_value('state') |
735 |
|
), |
736 |
|
); |
737 |
|
$update = $this->update_task($params); |
738 |
|
$message_class = "valid"; |
739 |
|
$message = $this->msg; |
740 |
|
if ($update === false) { |
741 |
|
$this->addToLog($this->msg, DEBUG_MODE); |
742 |
|
$message_class = "error"; |
743 |
|
$message = sprintf( |
744 |
|
'%s %s', |
745 |
|
__('Impossible de mettre à jour la tâche.'), |
746 |
|
__('Veuillez contacter votre administrateur.') |
747 |
|
); |
748 |
|
} |
749 |
|
$this->f->displayMessage($message_class, $message); |
750 |
|
// |
751 |
|
$inst_lien = $this->f->get_inst__om_dbform(array( |
752 |
|
"obj" => "lien_id_interne_uid_externe", |
753 |
|
"idx" => ']', |
754 |
|
)); |
755 |
|
$valF = array( |
756 |
|
'lien_id_interne_uid_externe' => '', |
757 |
|
'object' => $this->get_lien_objet_by_type($this->getVal('type')), |
758 |
|
'object_id' => $this->getVal('object_id'), |
759 |
|
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
760 |
|
); |
761 |
|
$add = $inst_lien->ajouter($valF); |
762 |
|
$message_class = "valid"; |
763 |
|
$message = $inst_lien->msg; |
764 |
|
if ($add === false) { |
765 |
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
766 |
|
$message_class = "error"; |
767 |
|
$message = sprintf( |
768 |
|
'%s %s', |
769 |
|
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
770 |
|
__('Veuillez contacter votre administrateur.') |
771 |
|
); |
772 |
|
} |
773 |
|
$this->f->displayMessage($message_class, $message); |
774 |
|
} |
775 |
|
|
776 |
|
function view_add_json_data() { |
777 |
|
$params = array(); |
778 |
|
$params['val']['stream'] = 'input'; |
779 |
|
$params['val']['type'] = $this->f->get_submitted_post_value('type'); |
780 |
|
$params['val']['object_id'] = $this->f->get_submitted_post_value('object_id'); |
781 |
|
$params['val']['dossier'] = $this->f->get_submitted_post_value('dossier'); |
782 |
|
$params['val']['json_payload'] = $this->f->get_submitted_post_value('json_payload'); |
783 |
|
$this->add_task($params); |
784 |
|
} |
785 |
|
|
786 |
|
protected function get_lien_objet_by_type($type) { |
787 |
|
// |
788 |
|
$objet = ''; |
789 |
|
if ($type === 'creation_DA') { |
790 |
|
$objet = 'dossier_autorisation'; |
791 |
} |
} |
792 |
|
if ($type === 'creation_DI' |
793 |
|
|| $type === 'depot_DI' |
794 |
|
|| $type === 'modification_DI' |
795 |
|
|| $type === 'qualification_DI' |
796 |
|
|| $type === 'decision_DI' |
797 |
|
|| $type === 'incompletude_DI' |
798 |
|
|| $type === 'completude_DI') { |
799 |
|
// |
800 |
|
$objet = 'dossier'; |
801 |
|
} |
802 |
|
if ($type === 'ajout_piece') { |
803 |
|
$objet = 'document_numerise'; |
804 |
|
} |
805 |
|
return $objet; |
806 |
} |
} |
807 |
|
|
808 |
|
function setLayout(&$form, $maj) { |
809 |
|
$form->setBloc('json_payload', 'D', '', 'col_6'); |
810 |
|
$form->setFieldset('json_payload', 'DF', _("json_payload"), "collapsible, startClosed"); |
811 |
|
$form->setBloc('json_payload', 'F'); |
812 |
|
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
813 |
|
} |
814 |
|
|
815 |
} |
} |