/[openfoncier]/trunk/obj/task.class.php
ViewVC logotype

Contents of /trunk/obj/task.class.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9593 - (show annotations)
Wed Oct 14 09:20:06 2020 UTC (4 years, 3 months ago) by gmalvolti
Original Path: branches/4.14.0-develop_demat/obj/task.class.php
File size: 31234 byte(s)
* Correction de la mise à jour du champ dossier lors de la mise à jour de la task
* Correction de l'affichage du listing pour prendre en compte toutes les tasks, pas seulement les task liées à dossier_instruction

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

Properties

Name Value
svn:executable *

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26