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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9625 - (show annotations)
Fri Oct 23 16:23:23 2020 UTC (4 years, 3 months ago) by softime
Original Path: branches/4.14.0-develop_demat/obj/task.class.php
File size: 32427 byte(s)
* Correction champ json_payload

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

Properties

Name Value
svn:executable *

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26