1 |
<?php |
2 |
//$Id$ |
3 |
//gen openMairie le 14/04/2020 14:11 |
4 |
|
5 |
require_once "../gen/obj/task.class.php"; |
6 |
|
7 |
class task extends task_gen { |
8 |
|
9 |
/** |
10 |
* Définition des actions disponibles sur la classe. |
11 |
* |
12 |
* @return void |
13 |
*/ |
14 |
public function init_class_actions() { |
15 |
parent::init_class_actions(); |
16 |
// |
17 |
$this->class_actions[998] = array( |
18 |
"identifier" => "json_data", |
19 |
"view" => "view_json_data", |
20 |
"permission_suffix" => "consulter", |
21 |
); |
22 |
} |
23 |
|
24 |
protected function task_exists(string $type, string $object_id) { |
25 |
$query = sprintf(' |
26 |
SELECT task |
27 |
FROM %1$stask |
28 |
WHERE state != \'%2$s\' |
29 |
AND type = \'%3$s\' |
30 |
AND object_id = \'%4$s\' |
31 |
', |
32 |
DB_PREFIXE, |
33 |
'done', |
34 |
$type, |
35 |
$object_id |
36 |
); |
37 |
$res = $this->f->get_one_result_from_db_query($query); |
38 |
if ($res['result'] !== null && $res['result'] !== '') { |
39 |
return $res['result']; |
40 |
} |
41 |
return false; |
42 |
} |
43 |
|
44 |
/** |
45 |
* TREATMENT - add_task |
46 |
* Ajoute un enregistrement. |
47 |
* |
48 |
* @param array $params Tableau des paramètres |
49 |
* @return boolean |
50 |
*/ |
51 |
public function add_task($params = array()) { |
52 |
$this->begin_treatment(__METHOD__); |
53 |
$timestamp_log = json_encode(array( |
54 |
'creation_date' => date('Y-m-d H:i:s'), |
55 |
)); |
56 |
// Mise à jour du DI |
57 |
$valF = array( |
58 |
'task' => '', |
59 |
'type' => $params['val']['type'], |
60 |
'timestamp_log' => $timestamp_log, |
61 |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : 'new', |
62 |
'object_id' => $params['val']['object_id'], |
63 |
); |
64 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
65 |
if ($task_exists !== false) { |
66 |
$inst_task = $this->f->get_inst__om_dbform(array( |
67 |
"obj" => "task", |
68 |
"idx" => $task_exists, |
69 |
)); |
70 |
$update_state = $inst_task->getVal('state'); |
71 |
if (isset($params['update_val']['state']) === true) { |
72 |
$update_state = $params['update_val']['state']; |
73 |
} |
74 |
$update_params = array( |
75 |
'val' => array( |
76 |
'state' => $update_state, |
77 |
), |
78 |
); |
79 |
return $inst_task->update_task($update_params); |
80 |
} |
81 |
$add = $this->ajouter($valF); |
82 |
if ($add === false) { |
83 |
$this->addToLog($this->msg, DEBUG_MODE); |
84 |
return $this->end_treatment(__METHOD__, false); |
85 |
} |
86 |
return $this->end_treatment(__METHOD__, true); |
87 |
} |
88 |
|
89 |
/** |
90 |
* TREATMENT - update_task |
91 |
* Met à jour l'enregistrement instancié. |
92 |
* |
93 |
* @param array $params Tableau des paramètres |
94 |
* @return boolean |
95 |
*/ |
96 |
public function update_task($params = array()) { |
97 |
$this->begin_treatment(__METHOD__); |
98 |
$timestamp_log = $this->get_timestamp_log(); |
99 |
if ($timestamp_log === false) { |
100 |
$this->addToLog(__('XXX'), DEBUG_MODE); |
101 |
return $this->end_treatment(__METHOD__, false); |
102 |
} |
103 |
array_push($timestamp_log, array( |
104 |
'modification_date' => date('Y-m-d H:i:s'), |
105 |
'state' => $params['val']['state'], |
106 |
'prev_state' => $this->getVal('state'), |
107 |
)); |
108 |
$timestamp_log = json_encode($timestamp_log); |
109 |
$valF = array( |
110 |
'task' => $this->getVal($this->clePrimaire), |
111 |
'type' => $this->getVal('type'), |
112 |
'timestamp_log' => $timestamp_log, |
113 |
'state' => $params['val']['state'], |
114 |
'object_id' => $this->getVal('object_id'), |
115 |
); |
116 |
$update = $this->modifier($valF); |
117 |
if ($update === false) { |
118 |
$this->addToLog($this->msg, DEBUG_MODE); |
119 |
return $this->end_treatment(__METHOD__, false); |
120 |
} |
121 |
return $this->end_treatment(__METHOD__, true); |
122 |
} |
123 |
|
124 |
/** |
125 |
* Récupère le journal d'horodatage dans le champ timestamp_log de |
126 |
* l'enregistrement instancié. |
127 |
* |
128 |
* @param array $params Tableau des paramètres |
129 |
* @return array sinon false en cas d'erreur |
130 |
*/ |
131 |
protected function get_timestamp_log($params = array()) { |
132 |
$val = $this->getVal('timestamp_log'); |
133 |
if ($val === '') { |
134 |
$val = json_encode(array()); |
135 |
} |
136 |
if($this->isJson($val) === false) { |
137 |
return false; |
138 |
} |
139 |
return json_decode($val, true); |
140 |
} |
141 |
|
142 |
/** |
143 |
* VIEW - view_json_data |
144 |
* Affiche l'enregistrement dans le format JSON. |
145 |
* |
146 |
* @return void |
147 |
*/ |
148 |
public function view_json_data() { |
149 |
$this->checkAccessibility(); |
150 |
$this->f->disableLog(); |
151 |
if ($this->getParameter('idx') !== ']' |
152 |
&& $this->getParameter('idx') !== '0') { |
153 |
// |
154 |
$this->view_form_json(); |
155 |
} |
156 |
else { |
157 |
$this->view_tab_json(); |
158 |
} |
159 |
} |
160 |
|
161 |
protected function view_tab_json() { |
162 |
$where = ''; |
163 |
if ($this->f->get_submitted_get_value('state') !== null |
164 |
&& $this->f->get_submitted_get_value('state') !== '') { |
165 |
// |
166 |
$where = sprintf(' WHERE state = \'%s\' ', $this->f->get_submitted_get_value('state')); |
167 |
} |
168 |
$query = sprintf(' |
169 |
SELECT |
170 |
* |
171 |
FROM %1$stask |
172 |
%2$s |
173 |
', |
174 |
DB_PREFIXE, |
175 |
$where |
176 |
); |
177 |
$res = $this->f->get_all_results_from_db_query($query, true); |
178 |
if ($res['code'] === 'KO') { |
179 |
return false; |
180 |
} |
181 |
$list_tasks = array(); |
182 |
foreach ($res['result'] as $task) { |
183 |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
184 |
$list_tasks[$task['task']] = $task; |
185 |
} |
186 |
printf(json_encode($list_tasks)); |
187 |
} |
188 |
|
189 |
protected function get_dossier_data(string $dossier) { |
190 |
$val_di = array(); |
191 |
$inst_di = $this->f->get_inst__om_dbform(array( |
192 |
"obj" => "dossier", |
193 |
"idx" => $dossier, |
194 |
)); |
195 |
$val_di = $inst_di->get_json_data(); |
196 |
if ($val_di['dossier_instruction_type_code'] === 'T') { |
197 |
$val_di['date_decision_transfert'] = $val_di['date_decision']; |
198 |
} |
199 |
unset($val_di['initial_dt']); |
200 |
unset($val_di['log_instructions']); |
201 |
return $val_di; |
202 |
} |
203 |
|
204 |
protected function get_dossier_autorisation_data(string $da) { |
205 |
$val_da = array(); |
206 |
$inst_da = $this->f->get_inst__om_dbform(array( |
207 |
"obj" => "dossier_autorisation", |
208 |
"idx" => $da, |
209 |
)); |
210 |
$val_da = $inst_da->get_json_data(); |
211 |
return $val_da; |
212 |
} |
213 |
|
214 |
protected function get_donnees_techniques_data(string $fk_idx, string $fk_field) { |
215 |
$val_dt = array(); |
216 |
$inst_dt = $this->f->get_inst__by_other_idx(array( |
217 |
"obj" => "donnees_techniques", |
218 |
"fk_field" => $fk_field, |
219 |
"fk_idx" => $fk_idx, |
220 |
)); |
221 |
$val_dt = array( |
222 |
'donnees_techniques' => $inst_dt->getVal($inst_dt->clePrimaire), |
223 |
'cerfa' => $inst_dt->getVal('cerfa'), |
224 |
); |
225 |
$val_dt = array_merge($val_dt, $inst_dt->get_donnees_techniques_applicables()); |
226 |
if (isset($val_dt['am_exist_date']) === true) { |
227 |
$val_dt['am_exist_date_num'] = ''; |
228 |
if (is_numeric($val_dt['am_exist_date']) === true) { |
229 |
$val_dt['am_exist_date_num'] = $val_dt['am_exist_date']; |
230 |
} |
231 |
} |
232 |
// Correspond à la nomenclature de Plat'AU STATUT_INFO |
233 |
$val_dt['tax_statut_info'] = 'Déclaré'; |
234 |
// |
235 |
if ($inst_dt->is_tab_surf_ssdest_enabled() === true) { |
236 |
$fields_tab_surf_dest = $inst_dt->get_fields_tab_surf_dest(); |
237 |
foreach ($fields_tab_surf_dest as $field) { |
238 |
if (isset($val_dt[$field]) === true) { |
239 |
unset($val_dt[$field]); |
240 |
} |
241 |
} |
242 |
} else { |
243 |
$fields_tab_surf_ssdest = $inst_dt->get_fields_tab_surf_ssdest(); |
244 |
foreach ($fields_tab_surf_ssdest as $field) { |
245 |
if (isset($val_dt[$field]) === true) { |
246 |
unset($val_dt[$field]); |
247 |
} |
248 |
} |
249 |
} |
250 |
// Correspond à la nouvelle ligne CERFA v7 dans le DENSI imposition 1.2.3 |
251 |
if (isset($val_dt['tax_su_non_habit_surf2']) === true |
252 |
&& isset($val_dt['tax_su_non_habit_surf3']) === true |
253 |
&& (($val_dt['tax_su_non_habit_surf2'] !== null |
254 |
&& $val_dt['tax_su_non_habit_surf2'] !== '') |
255 |
|| ($val_dt['tax_su_non_habit_surf3'] !== null |
256 |
&& $val_dt['tax_su_non_habit_surf3'] !== ''))) { |
257 |
// |
258 |
$val_dt['tax_su_non_habit_surf8'] = intval($val_dt['tax_su_non_habit_surf2']) + intval($val_dt['tax_su_non_habit_surf3']); |
259 |
} |
260 |
if (isset($val_dt['tax_su_non_habit_surf_stat2']) === true |
261 |
&& isset($val_dt['tax_su_non_habit_surf_stat3']) === true |
262 |
&& (($val_dt['tax_su_non_habit_surf_stat2'] !== null |
263 |
&& $val_dt['tax_su_non_habit_surf_stat2'] !== '') |
264 |
|| ($val_dt['tax_su_non_habit_surf_stat3'] !== null |
265 |
&& $val_dt['tax_su_non_habit_surf_stat3'] !== ''))) { |
266 |
// |
267 |
$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']); |
268 |
} |
269 |
// Cas particulier d'un projet réduit à l'extension d'une habitation existante |
270 |
$particular_case = false; |
271 |
$fields_tab_crea_loc_hab = $inst_dt->get_fields_tab_crea_loc_hab(); |
272 |
foreach ($fields_tab_crea_loc_hab as $field) { |
273 |
if (isset($val_dt[$field]) === false |
274 |
|| (isset($val_dt[$field]) === true |
275 |
&& ($val_dt[$field] === null |
276 |
|| $val_dt[$field] === ''))) { |
277 |
// |
278 |
$particular_case = true; |
279 |
} |
280 |
} |
281 |
if ($particular_case === true) { |
282 |
if (isset($val_dt['tax_ext_pret']) === true |
283 |
&& $val_dt['tax_ext_pret'] === 'f') { |
284 |
// |
285 |
$val_dt['tax_su_princ_surf1'] = $val_dt['tax_surf_tot_cstr']; |
286 |
$val_dt['tax_su_princ_surf_stat1'] = $val_dt['tax_surf_loc_stat']; |
287 |
} |
288 |
if (isset($val_dt['tax_ext_pret']) === true |
289 |
&& $val_dt['tax_ext_pret'] === 't') { |
290 |
// |
291 |
if (isset($val_dt['tax_ext_desc']) === true) { |
292 |
if (preg_match('/[pP].*[lL].*[aA].*[iI]/', $val_dt['tax_ext_desc']) === 1 |
293 |
|| preg_match('/[lL].*[lL].*[tT].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
294 |
// |
295 |
$val_dt['tax_su_princ_surf2'] = $val_dt['tax_surf_tot_cstr']; |
296 |
$val_dt['tax_su_princ_surf_stat2'] = $val_dt['tax_surf_loc_stat']; |
297 |
} |
298 |
// if (preg_match('/[pP].*[tT].*[zZ]/', $val_dt['tax_ext_desc']) === 1) { |
299 |
// $val_dt['tax_su_princ_surf4'] = $val_dt['tax_surf_tot_cstr']; |
300 |
// $val_dt['tax_su_princ_surf_stat4'] = $val_dt['tax_surf_loc_stat']; |
301 |
// } |
302 |
// if (preg_match('/[pP].*[lL].*[uU].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
303 |
// || preg_match('/[lL].*[eE].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
304 |
// || preg_match('/[pP].*[sS].*[lL].*[aA]/', $val_dt['tax_ext_desc']) === 1 |
305 |
// || preg_match('/[pP].*[lL].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
306 |
// || preg_match('/[lL].*[lL].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
307 |
// // |
308 |
// $val_dt['tax_su_princ_surf3'] = $val_dt['tax_surf_tot_cstr']; |
309 |
// $val_dt['tax_su_princ_surf_stat3'] = $val_dt['tax_surf_loc_stat']; |
310 |
// } |
311 |
} |
312 |
} |
313 |
} |
314 |
// Cas particulier de la surface taxable démolie |
315 |
if (isset($val_dt['tax_surf_tot_demo']) === true |
316 |
&& isset($val_dt['tax_surf_tax_demo']) === true |
317 |
&& ($val_dt['tax_surf_tot_demo'] === null |
318 |
|| $val_dt['tax_surf_tot_demo'] === '')) { |
319 |
// |
320 |
$val_dt['tax_surf_tot_demo'] = $val_dt['tax_surf_tax_demo']; |
321 |
} |
322 |
return $val_dt; |
323 |
} |
324 |
|
325 |
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
326 |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
327 |
"obj" => "lien_id_interne_uid_externe", |
328 |
"fk_field" => 'object_id', |
329 |
"fk_idx" => $fk_idx, |
330 |
"fk_field_2" => 'object', |
331 |
"fk_idx_2" => $fk_idx_2, |
332 |
)); |
333 |
return $inst_external_uid->getVal('external_uid'); |
334 |
} |
335 |
|
336 |
protected function get_demandeurs_data(string $dossier) { |
337 |
$val_demandeur = array(); |
338 |
$inst_di = $this->f->get_inst__om_dbform(array( |
339 |
"obj" => "dossier", |
340 |
"idx" => $dossier, |
341 |
)); |
342 |
$list_demandeurs = $inst_di->get_demandeurs(); |
343 |
foreach ($list_demandeurs as $demandeur) { |
344 |
$inst_demandeur = $this->f->get_inst__om_dbform(array( |
345 |
"obj" => "demandeur", |
346 |
"idx" => $demandeur['demandeur'], |
347 |
)); |
348 |
$val_demandeur[$demandeur['demandeur']] = $inst_demandeur->get_json_data(); |
349 |
$val_demandeur[$demandeur['demandeur']]['petitionnaire_principal'] = $demandeur['petitionnaire_principal']; |
350 |
} |
351 |
return $val_demandeur; |
352 |
} |
353 |
|
354 |
protected function get_architecte_data($architecte = null) { |
355 |
$val_architecte = null; |
356 |
if ($architecte !== null |
357 |
&& $architecte !== '') { |
358 |
// |
359 |
$inst_architecte = $this->f->get_inst__om_dbform(array( |
360 |
"obj" => "architecte", |
361 |
"idx" => $architecte, |
362 |
)); |
363 |
$val_architecte = $inst_architecte->get_json_data(); |
364 |
} |
365 |
return $val_architecte; |
366 |
} |
367 |
|
368 |
protected function get_instruction_data(string $dossier) { |
369 |
$val_instruction = null; |
370 |
$instruction_with_doc = null; |
371 |
$inst_di = $this->f->get_inst__om_dbform(array( |
372 |
"obj" => "dossier", |
373 |
"idx" => $dossier, |
374 |
)); |
375 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
376 |
"obj" => "instruction", |
377 |
"idx" => $inst_di->get_last_instruction_decision(), |
378 |
)); |
379 |
if (count($inst_instruction->val) > 0) { |
380 |
$val_instruction = array(); |
381 |
$instruction_data = $inst_instruction->get_json_data(); |
382 |
$val_instruction = $this->sort_instruction_data($instruction_data, $val_instruction); |
383 |
if ($instruction_data['om_fichier_instruction'] !== null |
384 |
&& $instruction_data['om_fichier_instruction'] !== '') { |
385 |
// |
386 |
$instruction_with_doc = $inst_instruction->getVal($inst_instruction->clePrimaire); |
387 |
} |
388 |
$inst_ev = $this->f->get_inst__om_dbform(array( |
389 |
"obj" => "evenement", |
390 |
"idx" => $inst_instruction->getVal('evenement'), |
391 |
)); |
392 |
if ($inst_ev->getVal('retour') === 't') { |
393 |
$instructions_related = $inst_instruction->get_related_instructions(); |
394 |
foreach ($instructions_related as $instruction) { |
395 |
if ($instruction !== null && $instruction !== '') { |
396 |
$inst_related_instruction = $this->f->get_inst__om_dbform(array( |
397 |
"obj" => "instruction", |
398 |
"idx" => $instruction, |
399 |
)); |
400 |
$instruction_data = $inst_related_instruction->get_json_data(); |
401 |
$val_instruction = $this->sort_instruction_data($instruction_data, $val_instruction); |
402 |
if ($instruction_data['om_fichier_instruction'] !== null |
403 |
&& $instruction_data['om_fichier_instruction'] !== '') { |
404 |
// |
405 |
$instruction_with_doc = $inst_related_instruction->getVal($inst_related_instruction->clePrimaire); |
406 |
} |
407 |
} |
408 |
} |
409 |
} |
410 |
if ($instruction_with_doc !== null) { |
411 |
// |
412 |
$val_instruction['path'] = sprintf('%s/%s&snippet=%s&obj=%s&champ=%s&id=%s', $_SERVER['HTTP_HOST'], 'openads/app/index.php?module=form', 'file', 'instruction', 'om_fichier_instruction', $instruction_with_doc); |
413 |
} |
414 |
} |
415 |
return $val_instruction; |
416 |
} |
417 |
|
418 |
protected function sort_instruction_data(array $values, array $res) { |
419 |
$fields = array( |
420 |
"date_envoi_signature", |
421 |
"date_retour_signature", |
422 |
"date_envoi_rar", |
423 |
"date_retour_rar", |
424 |
"date_envoi_controle_legalite", |
425 |
"date_retour_controle_legalite", |
426 |
"signataire_arrete", |
427 |
"om_fichier_instruction", |
428 |
"tacite", |
429 |
); |
430 |
foreach ($values as $key => $value) { |
431 |
if (in_array($key, $fields) === true) { |
432 |
if (array_key_exists($key, $res) === false |
433 |
&& $value !== null |
434 |
&& $value !== '') { |
435 |
// |
436 |
$res[$key] = $value; |
437 |
} elseif ($key === 'tacite' |
438 |
&& $value === 't') { |
439 |
// |
440 |
$res[$key] = $value; |
441 |
} |
442 |
} |
443 |
} |
444 |
return $res; |
445 |
} |
446 |
|
447 |
protected function get_document_numerise_data(string $dn) { |
448 |
$val_dn = array(); |
449 |
$inst_dn = $this->f->get_inst__om_dbform(array( |
450 |
"obj" => "document_numerise", |
451 |
"idx" => $dn, |
452 |
)); |
453 |
$val_dn = $inst_dn->get_json_data(); |
454 |
$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')); |
455 |
// Correspond à la nomenclature Plat'AU NATURE_PIECE |
456 |
$val_dn['nature'] = 'Initiale'; |
457 |
return $val_dn; |
458 |
} |
459 |
|
460 |
protected function get_parcelles_data(string $object, string $idx) { |
461 |
$val_dp = array(); |
462 |
$inst_di = $this->f->get_inst__om_dbform(array( |
463 |
"obj" => $object, |
464 |
"idx" => $idx, |
465 |
)); |
466 |
$list_parcelles = $inst_di->get_parcelles(); |
467 |
$no_ordre = 1; |
468 |
foreach ($list_parcelles as $parcelle) { |
469 |
$val_dp[$parcelle[$object.'_parcelle']] = array( |
470 |
$object.'_parcelle' => $parcelle[$object.'_parcelle'], |
471 |
'libelle' => $parcelle['libelle'], |
472 |
'no_ordre' => $no_ordre, |
473 |
); |
474 |
$no_ordre++; |
475 |
} |
476 |
return $val_dp; |
477 |
} |
478 |
|
479 |
protected function view_form_json() { |
480 |
// Mise à jour des valeurs |
481 |
if ($this->f->get_submitted_post_value('valid') === 'true' |
482 |
&& $this->f->get_submitted_post_value('state') !== null) { |
483 |
// |
484 |
$params = array( |
485 |
'val' => array( |
486 |
'state' => $this->f->get_submitted_post_value('state') |
487 |
), |
488 |
); |
489 |
$update = $this->update_task($params); |
490 |
$message_class = "valid"; |
491 |
$message = $this->msg; |
492 |
if ($update === false) { |
493 |
$this->addToLog($this->msg, DEBUG_MODE); |
494 |
$message_class = "error"; |
495 |
$message = sprintf( |
496 |
'%s %s', |
497 |
__('Impossible de mettre à jour la tâche.'), |
498 |
__('Veuillez contacter votre administrateur.') |
499 |
); |
500 |
} |
501 |
$this->f->displayMessage($message_class, $message); |
502 |
} |
503 |
// |
504 |
if ($this->f->get_submitted_post_value('valid') === 'true' |
505 |
&& $this->f->get_submitted_post_value('external_uid') !== null) { |
506 |
// |
507 |
$inst_lien = $this->f->get_inst__om_dbform(array( |
508 |
"obj" => "lien_id_interne_uid_externe", |
509 |
"idx" => ']', |
510 |
)); |
511 |
$valF = array( |
512 |
'lien_id_interne_uid_externe' => '', |
513 |
'object' => $this->get_lien_objet_by_type($this->getVal('type')), |
514 |
'object_id' => $this->getVal('object_id'), |
515 |
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
516 |
); |
517 |
$add = $inst_lien->ajouter($valF); |
518 |
$message_class = "valid"; |
519 |
$message = $inst_lien->msg; |
520 |
if ($add === false) { |
521 |
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
522 |
$message_class = "error"; |
523 |
$message = sprintf( |
524 |
'%s %s', |
525 |
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
526 |
__('Veuillez contacter votre administrateur.') |
527 |
); |
528 |
} |
529 |
$this->f->displayMessage($message_class, $message); |
530 |
} |
531 |
|
532 |
// |
533 |
if ($this->f->get_submitted_post_value('valid') === null) { |
534 |
// Liste des valeurs à afficher |
535 |
$val = array(); |
536 |
// |
537 |
$val_task = array_combine($this->champs, $this->val); |
538 |
foreach ($val_task as $key => $value) { |
539 |
$val_task[$key] = strip_tags($value); |
540 |
} |
541 |
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
542 |
$val['task'] = $val_task; |
543 |
// |
544 |
if ($this->getVal('type') === 'creation_DA') { |
545 |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
546 |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
547 |
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
548 |
$val_external_uid = array(); |
549 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
550 |
$val['external_uid'] = $val_external_uid; |
551 |
} |
552 |
// |
553 |
if ($this->getVal('type') === 'creation_DI' |
554 |
|| $this->getVal('type') === 'modification_DI' |
555 |
|| $this->getVal('type') === 'depot_DI') { |
556 |
// |
557 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
558 |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction'); |
559 |
$val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']); |
560 |
$architecte = isset($val['donnees_techniques']['architecte']) === true ? $val['donnees_techniques']['architecte'] : null; |
561 |
$val['architecte'] = $this->get_architecte_data($architecte); |
562 |
$val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']); |
563 |
$val_external_uid = array(); |
564 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
565 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
566 |
$val['external_uid'] = $val_external_uid; |
567 |
} |
568 |
// |
569 |
if ($this->getVal('type') === 'qualification_DI') { |
570 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
571 |
$val_external_uid = array(); |
572 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
573 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
574 |
$val['external_uid'] = $val_external_uid; |
575 |
} |
576 |
// |
577 |
if ($this->getVal('type') === 'ajout_piece') { |
578 |
$val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id')); |
579 |
$val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']); |
580 |
$val_external_uid = array(); |
581 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
582 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
583 |
$val_external_uid['document_numerise'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'document_numerise'); |
584 |
$val['external_uid'] = $val_external_uid; |
585 |
} |
586 |
// |
587 |
if ($this->getVal('type') === 'decision_DI') { |
588 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
589 |
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier']); |
590 |
$val_external_uid = array(); |
591 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
592 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
593 |
$val['external_uid'] = $val_external_uid; |
594 |
} |
595 |
|
596 |
// Liste des valeurs affichée en JSON |
597 |
printf(json_encode($val)); |
598 |
} |
599 |
} |
600 |
|
601 |
protected function get_lien_objet_by_type($type) { |
602 |
// |
603 |
$objet = ''; |
604 |
if ($type === 'creation_DA') { |
605 |
$objet = 'dossier_autorisation'; |
606 |
} |
607 |
if ($type === 'creation_DI' |
608 |
|| $type === 'depot_DI' |
609 |
|| $type === 'modification_DI' |
610 |
|| $type === 'qualification_DI' |
611 |
|| $type === 'decision_DI') { |
612 |
// |
613 |
$objet = 'dossier'; |
614 |
} |
615 |
if ($type === 'ajout_piece') { |
616 |
$objet = 'document_numerise'; |
617 |
} |
618 |
return $objet; |
619 |
} |
620 |
} |