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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9950 - (show annotations)
Wed Feb 24 09:38:47 2021 UTC (3 years, 11 months ago) by softime
Original Path: branches/4.14.0-develop/obj/task.class.php
File size: 53688 byte(s)
* Fusion de la branche de développement 4.14.0-develop_save_uid dans la branche d'intégration 4.14.0-develop

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 const STATUS_DRAFT = 'draft';
10 const STATUS_NEW = 'new';
11 const STATUS_PENDING = 'pending';
12 const STATUS_DONE = 'done';
13 const STATUS_ERROR = 'error';
14 const STATUS_DEBUG = 'debug';
15 const STATUS_ARCHIVED = 'archived';
16
17 /**
18 * Définition des actions disponibles sur la classe.
19 *
20 * @return void
21 */
22 public function init_class_actions() {
23 parent::init_class_actions();
24 //
25 $this->class_actions[998] = array(
26 "identifier" => "json_data",
27 "view" => "view_json_data",
28 "permission_suffix" => "consulter",
29 );
30 $this->class_actions[997] = array(
31 "identifier" => "json_data",
32 "view" => "post_update_task",
33 "permission_suffix" => "modifier",
34 );
35 $this->class_actions[996] = array(
36 "identifier" => "json_data",
37 "view" => "post_add_task",
38 "permission_suffix" => "ajouter",
39 );
40 }
41
42 public function setvalF($val = array()) {
43
44 // // les guillets doubles sont remplacés automatiquement par des simples
45 // // dans core/om_formulaire.clasS.php::recupererPostvar()
46 // // voir le ticket https://dev.atreal.fr/projets/openmairie/tracker/209
47 // // ceci est un hack sale temporaire en attendant résolution du ticket
48 // foreach(array('json_payload', 'timestamp_log') as $key) {
49 // if (isset($val[$key]) && ! empty($val[$key]) &&
50 // isset($_POST[$key]) && ! empty($_POST[$key])) {
51 // $submited_payload = $_POST[$key];
52 // if (! empty($submited_payload)) {
53 // $new_payload = str_replace("'", '"', $val[$key]);
54 // if ($new_payload == $submited_payload ||
55 // strpos($submited_payload, '"') === false) {
56 // $val[$key] = $new_payload;
57 // }
58 // else {
59 // $error_msg = sprintf(
60 // __("La convertion des guillemets de la payload JSON '%s' ".
61 // "n'est pas idempotente (courante: %s, postée: %s, convertie: %s)"),
62 // $key, var_export($val[$key], true), var_export($submited_payload, true),
63 // var_export($new_payload, true));
64 // $this->correct = false;
65 // $this->addToMessage($error_msg);
66 // $this->addToLog(__METHOD__."() erreur : $error_msg", DEBUG_MODE);
67 // return false;
68 // }
69 // }
70 // }
71 // }
72
73 parent::setvalF($val);
74
75 // XXX Ancien code : permet de ne pas avoir d'erreru lors de la modification d'une task
76 if (array_key_exists('timestamp_log', $val) === true) {
77 $this->valF['timestamp_log'] = str_replace("'", '"', $val['timestamp_log']);
78 }
79
80 // récupération de l'ID de l'objet existant
81 $id = property_exists($this, 'id') ? $this->id : null;
82 if(isset($val[$this->clePrimaire])) {
83 $id = $val[$this->clePrimaire];
84 } elseif(isset($this->valF[$this->clePrimaire])) {
85 $id = $this->valF[$this->clePrimaire];
86 }
87
88 // MODE MODIFIER
89 if (! empty($id)) {
90
91 // si aucune payload n'est fourni (devrait toujours être le cas)
92 if (! isset($val['json_payload']) || empty($val['json_payload'])) {
93
94 // récupère l'objet existant
95 $existing = $this->f->findObjectById(get_class($this), $id);
96 if (! empty($existing)) {
97
98 // récupère la payload de l'objet
99 $val['json_payload'] = $existing->getVal('json_payload');
100 $this->valF['json_payload'] = $existing->getVal('json_payload');
101 $this->f->addToLog(__METHOD__."() récupère la payload de la tâche existante ".
102 "'$id': ".$existing->getVal('json_payload'), EXTRA_VERBOSE_MODE);
103 }
104 }
105 }
106 }
107
108 /**
109 *
110 * @return array
111 */
112 function get_var_sql_forminc__champs() {
113 return array(
114 "task",
115 "type",
116 "state",
117 "object_id",
118 "dossier",
119 "stream",
120 "json_payload",
121 "timestamp_log",
122 );
123 }
124
125 function setType(&$form, $maj) {
126 parent::setType($form, $maj);
127
128 // Récupération du mode de l'action
129 $crud = $this->get_action_crud($maj);
130
131 // MODE CREER
132 if ($maj == 0 || $crud == 'create') {
133 $form->setType("state", "select");
134 $form->setType("stream", "select");
135 $form->setType("json_payload", "textarea");
136 }
137 // MDOE MODIFIER
138 if ($maj == 1 || $crud == 'update') {
139 $form->setType("state", "select");
140 $form->setType("stream", "select");
141 $form->setType("json_payload", "jsonprettyprint");
142 }
143 // MODE CONSULTER
144 if ($maj == 3 || $crud == 'read') {
145 $form->setType('dossier', 'link');
146 $form->setType('json_payload', 'jsonprettyprint');
147 }
148
149 }
150
151 /**
152 *
153 */
154 function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) {
155 if($maj < 2) {
156
157 $contenu = array();
158 foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG') as $key) {
159 $const_name = 'STATUS_'.$key;
160 $const_value = constant("self::$const_name");
161 $contenu[0][] = $const_value;
162 $contenu[1][] = __($const_value);
163 }
164
165 $form->setSelect("state", $contenu);
166
167 $contenu_stream =array();
168 $contenu_stream[0][0]="input";
169 $contenu_stream[1][0]=_('input');
170 $contenu_stream[0][1]="output";
171 $contenu_stream[1][1]=_('output');
172 $form->setSelect("stream", $contenu_stream);
173
174 }
175
176 if ($maj == 3) {
177 if ($this->getVal('stream') == 'output') {
178 $inst_dossier = $this->f->get_inst__om_dbform(array(
179 "obj" => "dossier",
180 "idx" => $form->val['dossier'],
181 ));
182
183 if($form->val['type'] == "creation_DA"){
184 $obj_link = 'dossier_autorisation';
185 } else {
186 $obj_link = 'dossier_instruction';
187 }
188
189 $params = array();
190 $params['obj'] = $obj_link;
191 $params['libelle'] = $inst_dossier->getVal('dossier');
192 $params['title'] = "Consulter le dossier";
193 $params['idx'] = $form->val['dossier'];
194 $form->setSelect("dossier", $params);
195 }
196 }
197 }
198
199 /**
200 * SETTER_FORM - setVal (setVal).
201 *
202 * @return void
203 */
204 function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) {
205 // parent::setVal($form, $maj, $validation);
206 //
207 if ($this->getVal('stream') == "output") {
208 $form->setVal('json_payload', $this->view_form_json(true));
209 } else {
210 $form->setVal('json_payload', htmlentities($this->getVal('json_payload')));
211 }
212 }
213
214 function setLib(&$form, $maj) {
215 parent::setLib($form, $maj);
216
217 // Récupération du mode de l'action
218 $crud = $this->get_action_crud($maj);
219
220 // MODE different de CREER
221 if ($maj != 0 || $crud != 'create') {
222 $form->setLib('json_payload', '');
223 }
224 }
225
226 public function verifier($val = array(), &$dnu1 = null, $dnu2 = null) {
227 $ret = parent::verifier($val, $dnu1, $dnu2);
228
229 // une tâche entrante doit avoir un type et une payload non-vide
230 if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') {
231 if (isset($this->valF['type']) === false) {
232 $this->correct = false;
233 $this->addToMessage(sprintf(
234 __("Le champ %s est obligatoire pour une tâche entrante."),
235 sprintf('<span class="bold">%s</span>', $this->getLibFromField('type'))
236 ));
237 $this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE);
238 }
239 if (isset($this->valF['json_payload']) === false) {
240 $this->correct = false;
241 $this->addToMessage(sprintf(
242 __("Le champ %s est obligatoire pour une tâche entrante."),
243 sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload'))
244 ));
245 $this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE);
246 }
247 }
248
249 // les JSONs doivent être décodables
250 foreach(array('json_payload', 'timestamp_log') as $key) {
251 if (isset($this->valF[$key]) && ! empty($this->valF[$key]) && (
252 is_array(json_decode($this->valF[$key], true)) === false
253 || json_last_error() !== JSON_ERROR_NONE)) {
254 $this->correct = false;
255 $champ_text = sprintf('<span class="bold">%s</span>', $this->getLibFromField($key));
256 $this->addToMessage(sprintf(
257 __("Le champ %s doit être dans un format JSON valide (erreur: %s).".
258 "<p>%s valF:</br><pre>%s</pre></p>".
259 "<p>%s val:</br><pre>%s</pre></p>".
260 "<p>%s POST:</br><pre>%s</pre></p>".
261 "<p>%s submitted POST value:</br><pre>%s</pre></p>"),
262 $champ_text,
263 json_last_error() !== JSON_ERROR_NONE ? json_last_error_msg() : __('invalide'),
264 $champ_text,
265 $this->valF[$key],
266 $champ_text,
267 $val[$key],
268 $champ_text,
269 isset($_POST[$key]) ? $_POST[$key] : '',
270 $champ_text,
271 $this->f->get_submitted_post_value($key)
272 ));
273 $this->addToLog(__METHOD__.'(): erreur JSON: '.$this->msg, DEBUG_MODE);
274 }
275 }
276
277 // une tâche entrante doit avoir une payload avec les clés requises
278 if ($this->correct && (isset($this->valF['stream']) === false ||
279 $this->valF['stream'] == 'input')) {
280
281 // décode la payload JSON
282 $json_payload = json_decode($this->valF['json_payload'], true);
283
284 // défini une liste de chemin de clés requises
285 $paths = array(
286 'external_uids/dossier'
287 );
288
289 // tâche de type création de DI/DA
290 if (isset($this->valF['type']) !== false && $this->valF['type'] == 'create_DI_for_consultation') {
291
292 $paths = array_merge($paths, array(
293 'dossier/dossier',
294 'dossier/dossier_autorisation_type_detaille_code',
295 'dossier/date_demande',
296 'dossier/depot_electronique',
297 ));
298
299 // si l'option commune est activée (mode MC)
300 if ($this->f->is_option_dossier_commune_enabled()) {
301 $paths[] = 'dossier/insee';
302 }
303
304 // présence d'un moyen d'identifier la collectivité/le service
305 if (! isset($json_payload['dossier']['acteur']) &&
306 ! isset($json_payload['dossier']['om_collectivite'])) {
307 $this->correct = false;
308 $this->addToMessage(sprintf(
309 __("L'une des clés %s ou %s est obligatoire dans le contenu du champ %s pour une tâche entrante."),
310 sprintf('<span class="bold">%s</span>', 'dossier/acteur'),
311 sprintf('<span class="bold">%s</span>', 'dossier/om_collectivite'),
312 sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload'))
313 ));
314 $this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE);
315 }
316 }
317
318 // pas d'erreur déjà trouvée
319 if($this->correct) {
320
321 // pour chaque chemin
322 foreach($paths as $path) {
323
324 // décompose le chemin
325 $tokens = explode('/', $path);
326 $cur_depth = $json_payload;
327
328 // descend au et à mesure dans l'arborescence du chemin
329 foreach($tokens as $token) {
330
331 // en vérifiant que chaque élément du chemin est défini et non-nul
332 if (isset($cur_depth[$token]) === false) {
333
334 // sinon on produit une erreur
335 $this->correct = false;
336 $this->addToMessage(sprintf(
337 __("La clé %s est obligatoire dans le contenu du champ %s pour une tâche entrante."),
338 sprintf('<span class="bold">%s</span>', $path),
339 sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload'))
340 ));
341 $this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE);
342 break 2;
343 }
344 $cur_depth = $cur_depth[$token];
345 }
346 }
347 }
348 }
349
350 return $ret && $this->correct;
351 }
352
353 protected function task_exists(string $type, string $object_id) {
354 $query = sprintf('
355 SELECT task
356 FROM %1$stask
357 WHERE state != \'%2$s\'
358 AND type = \'%3$s\'
359 AND object_id = \'%4$s\'
360 ',
361 DB_PREFIXE,
362 self::STATUS_DONE,
363 $type,
364 $object_id
365 );
366 $res = $this->f->get_one_result_from_db_query($query);
367 if ($res['result'] !== null && $res['result'] !== '') {
368 return $res['result'];
369 }
370 return false;
371 }
372
373 /**
374 * TRIGGER - triggerajouter.
375 *
376 * @param string $id
377 * @param null &$dnu1 @deprecated Ne pas utiliser.
378 * @param array $val Tableau des valeurs brutes.
379 * @param null $dnu2 @deprecated Ne pas utiliser.
380 *
381 * @return boolean
382 */
383 function triggerajouter($id, &$dnu1 = null, $val = array(), $dnu2 = null) {
384
385 // tâche entrante
386 if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') {
387
388 // décode la paylod JSON pour extraire les données métiers à ajouter
389 // en tant que métadonnées de la tâche
390 $json_payload = json_decode($this->valF['json_payload'], true);
391
392 // si la tâche possède déjà une clé dossier
393 if (isset($json_payload['dossier']['dossier']) &&
394 ! empty($json_payload['dossier']['dossier'])) {
395 $this->valF["dossier"] = $json_payload['dossier']['dossier'];
396 }
397 }
398 }
399
400 /**
401 * TREATMENT - add_task
402 * Ajoute un enregistrement.
403 *
404 * @param array $params Tableau des paramètres
405 * @return boolean
406 */
407 public function add_task($params = array()) {
408 $this->begin_treatment(__METHOD__);
409
410 // Vérifie si la task doit être ajoutée en fonction du mode de l'application,
411 // seulement pour les tasks output
412 $task_types_si = array(
413 'creation_DA',
414 'creation_DI',
415 'depot_DI',
416 'modification_DI',
417 'qualification_DI',
418 'decision_DI',
419 'incompletude_DI',
420 'completude_DI',
421 'ajout_piece',
422 'add_piece',
423 );
424 $task_types_sc = array(
425 'create_DI_for_consultation',
426 'avis_consultation',
427 'pec_metier_consultation',
428 );
429 $stream = isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output';
430 if ($stream === 'output'
431 && isset($params['val']['type']) === true
432 && $this->f->is_option_mode_service_consulte_enabled() === true
433 && in_array($params['val']['type'], $task_types_sc) === false) {
434 //
435 return $this->end_treatment(__METHOD__, true);
436 }
437 if ($stream === 'output'
438 && isset($params['val']['type']) === true
439 && $this->f->is_option_mode_service_consulte_enabled() === false
440 && in_array($params['val']['type'], $task_types_si) === false) {
441 //
442 return $this->end_treatment(__METHOD__, true);
443 }
444
445 $timestamp_log = json_encode(array(
446 'creation_date' => date('Y-m-d H:i:s'),
447 ));
448
449 // Si la tâche est de type ajout_piece et de stream input alors on ajoute le fichier
450 // et on ajoute l'uid dans le champ json_payload avant l'ajout de la tâche
451 if (isset($params['val']['type'])
452 && $params['val']['type'] == "add_piece"
453 && isset($params['val']['stream'])
454 && $params['val']['stream'] == "input" ) {
455 //
456 $json_payload = json_decode($params['val']['json_payload'], true);
457 $document_numerise = $json_payload['document_numerise'];
458 $file_content = base64_decode($document_numerise["file_content"]);
459 if ($file_content === false){
460 $this->addToMessage(__("Le contenu du fichier lié à la tâche n'a pas pu etre recupere."));
461 return $this->end_treatment(__METHOD__, false);
462 }
463 $metadata = array(
464 "filename" => $document_numerise['nom_fichier'],
465 "size" => strlen($file_content),
466 "mimetype" => $document_numerise['file_content_type'],
467 "date_creation" => $document_numerise['date_creation'],
468 );
469 $uid_fichier = $this->f->storage->create($file_content, $metadata, "from_content");
470 if ($uid_fichier === OP_FAILURE) {
471 $this->addToMessage(__("Erreur lors de la creation du fichier lié à la tâche."));
472 return $this->end_treatment(__METHOD__, false);
473 }
474 $json_payload["document_numerise"]["uid"] = $uid_fichier;
475 // Le fichier a été ajouté nous n'avons plus besoin du champ file_content dans la payload
476 unset($json_payload["document_numerise"]["file_content"]);
477 $params['val']['json_payload'] = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
478 }
479
480 // Mise à jour du DI
481 $valF = array(
482 'task' => '',
483 'type' => $params['val']['type'],
484 'timestamp_log' => $timestamp_log,
485 'state' => isset($params['val']['state']) === true ? $params['val']['state'] : self::STATUS_NEW,
486 'object_id' => isset($params['val']['object_id']) ? $params['val']['object_id'] : '',
487 'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '',
488 'stream' => $stream,
489 'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}',
490 );
491
492 // tâche sortante
493 if($valF["stream"] == "output"){
494
495 // TODO expliquer ce code
496 $task_exists = $this->task_exists($valF['type'], $valF['object_id']);
497 if ($valF['type'] === 'modification_DI' && $task_exists === false) {
498 $task_exists = $this->task_exists('creation_DI', $valF['object_id']);
499 }
500 if ($task_exists !== false) {
501 $inst_task = $this->f->get_inst__om_dbform(array(
502 "obj" => "task",
503 "idx" => $task_exists,
504 ));
505 $update_state = $inst_task->getVal('state');
506 if (isset($params['update_val']['state']) === true) {
507 $update_state = $params['update_val']['state'];
508 }
509 $update_params = array(
510 'val' => array(
511 'state' => $update_state,
512 ),
513 );
514 return $inst_task->update_task($update_params);
515 }
516 }
517
518 $add = $this->ajouter($valF);
519 $this->addToLog(__METHOD__."(): retour de l'ajout de tâche: ".var_export($add, true), VERBOSE_MODE);
520 if ($add === false) {
521 $this->addToLog(__METHOD__."(): ".$this->msg, DEBUG_MODE);
522 return $this->end_treatment(__METHOD__, false);
523 }
524 return $this->end_treatment(__METHOD__, true);
525 }
526
527 /**
528 * TREATMENT - update_task
529 * Met à jour l'enregistrement instancié.
530 *
531 * @param array $params Tableau des paramètres
532 * @return boolean
533 */
534 public function update_task($params = array()) {
535 $this->begin_treatment(__METHOD__);
536 $timestamp_log = $this->get_timestamp_log();
537 if ($timestamp_log === false) {
538 $this->addToLog(__METHOD__."(): erreur timestamp log", DEBUG_MODE);
539 return $this->end_treatment(__METHOD__, false);
540 }
541 array_push($timestamp_log, array(
542 'modification_date' => date('Y-m-d H:i:s'),
543 'state' => $params['val']['state'],
544 'prev_state' => $this->getVal('state'),
545 ));
546 $timestamp_log = json_encode($timestamp_log);
547 $valF = array(
548 'task' => $this->getVal($this->clePrimaire),
549 'type' => $this->getVal('type'),
550 'timestamp_log' => $timestamp_log,
551 'state' => $params['val']['state'],
552 'object_id' => $this->getVal('object_id'),
553 'stream' => $this->getVal('stream'),
554 'dossier' => $this->getVal('dossier'),
555 'json_payload' => $this->getVal('json_payload'),
556 );
557 $update = $this->modifier($valF);
558 if ($update === false) {
559 $this->addToLog($this->msg, DEBUG_MODE);
560 return $this->end_treatment(__METHOD__, false);
561 }
562 return $this->end_treatment(__METHOD__, true);
563 }
564
565 /**
566 * Récupère le journal d'horodatage dans le champ timestamp_log de
567 * l'enregistrement instancié.
568 *
569 * @param array $params Tableau des paramètres
570 * @return array sinon false en cas d'erreur
571 */
572 protected function get_timestamp_log($params = array()) {
573 $val = $this->getVal('timestamp_log');
574 if ($val === '') {
575 $val = json_encode(array());
576 }
577 if($this->isJson($val) === false) {
578 return false;
579 }
580 return json_decode($val, true);
581 }
582
583 /**
584 * VIEW - view_json_data
585 * Affiche l'enregistrement dans le format JSON.
586 *
587 * @return void
588 */
589 public function view_json_data() {
590 $this->checkAccessibility();
591 $this->f->disableLog();
592 if ($this->getParameter('idx') !== ']'
593 && $this->getParameter('idx') !== '0') {
594 //
595 $this->view_form_json();
596 }
597 else {
598 $this->view_tab_json();
599 }
600 }
601
602 protected function view_tab_json() {
603 $where = '';
604 if ($this->f->get_submitted_get_value('state') !== null
605 && $this->f->get_submitted_get_value('state') !== '') {
606 //
607 $where = sprintf(' WHERE state = \'%s\' ', $this->f->get_submitted_get_value('state'));
608 }
609 $query = sprintf('
610 SELECT
611 *
612 FROM %1$stask
613 %2$s
614 ORDER BY task ASC
615 ',
616 DB_PREFIXE,
617 $where
618 );
619 $res = $this->f->get_all_results_from_db_query($query, true);
620 if ($res['code'] === 'KO') {
621 return false;
622 }
623 $list_tasks = array();
624 foreach ($res['result'] as $task) {
625 $task['timestamp_log'] = json_decode($task['timestamp_log'], true);
626 $task['dossier'] = $task['dossier'];
627 if ($task['type'] === 'ajout_piece') {
628 $val_dn = $this->get_document_numerise_data($task['object_id']);
629 }
630 if ($task['stream'] === 'output') {
631 $task['external_uids'] = $this->get_all_external_uids($task['dossier']);
632 }
633 $list_tasks[$task['task']] = $task;
634 }
635 printf(json_encode($list_tasks));
636 }
637
638 protected function get_dossier_data(string $dossier) {
639 $val_di = array();
640 $inst_di = $this->f->get_inst__om_dbform(array(
641 "obj" => "dossier",
642 "idx" => $dossier,
643 ));
644 $val_di = $inst_di->get_json_data();
645 if ($val_di['dossier_instruction_type_code'] === 'T') {
646 $val_di['date_decision_transfert'] = $val_di['date_decision'];
647 }
648 unset($val_di['initial_dt']);
649 unset($val_di['log_instructions']);
650 return $val_di;
651 }
652
653 protected function get_dossier_autorisation_data(string $da) {
654 $val_da = array();
655 $inst_da = $this->f->get_inst__om_dbform(array(
656 "obj" => "dossier_autorisation",
657 "idx" => $da,
658 ));
659 $val_da = $inst_da->get_json_data();
660 return $val_da;
661 }
662
663 protected function get_donnees_techniques_data(string $fk_idx, string $fk_field) {
664 $val_dt = array();
665 $inst_dt = $this->f->get_inst__by_other_idx(array(
666 "obj" => "donnees_techniques",
667 "fk_field" => $fk_field,
668 "fk_idx" => $fk_idx,
669 ));
670 $val_dt = array(
671 'donnees_techniques' => $inst_dt->getVal($inst_dt->clePrimaire),
672 'cerfa' => $inst_dt->getVal('cerfa'),
673 );
674 $val_dt = array_merge($val_dt, $inst_dt->get_donnees_techniques_applicables());
675 if (isset($val_dt['am_exist_date']) === true) {
676 $val_dt['am_exist_date_num'] = '';
677 if (is_numeric($val_dt['am_exist_date']) === true) {
678 $val_dt['am_exist_date_num'] = $val_dt['am_exist_date'];
679 }
680 }
681 // Correspond à la nomenclature de Plat'AU STATUT_INFO
682 $val_dt['tax_statut_info'] = 'Déclaré';
683 //
684 if ($inst_dt->is_tab_surf_ssdest_enabled() === true) {
685 $fields_tab_surf_dest = $inst_dt->get_fields_tab_surf_dest();
686 foreach ($fields_tab_surf_dest as $field) {
687 if (isset($val_dt[$field]) === true) {
688 unset($val_dt[$field]);
689 }
690 }
691 } else {
692 $fields_tab_surf_ssdest = $inst_dt->get_fields_tab_surf_ssdest();
693 foreach ($fields_tab_surf_ssdest as $field) {
694 if (isset($val_dt[$field]) === true) {
695 unset($val_dt[$field]);
696 }
697 }
698 }
699 // Correspond à la nouvelle ligne CERFA v7 dans le DENSI imposition 1.2.3
700 if (isset($val_dt['tax_su_non_habit_surf2']) === true
701 && isset($val_dt['tax_su_non_habit_surf3']) === true
702 && (($val_dt['tax_su_non_habit_surf2'] !== null
703 && $val_dt['tax_su_non_habit_surf2'] !== '')
704 || ($val_dt['tax_su_non_habit_surf3'] !== null
705 && $val_dt['tax_su_non_habit_surf3'] !== ''))) {
706 //
707 $val_dt['tax_su_non_habit_surf8'] = intval($val_dt['tax_su_non_habit_surf2']) + intval($val_dt['tax_su_non_habit_surf3']);
708 }
709 if (isset($val_dt['tax_su_non_habit_surf_stat2']) === true
710 && isset($val_dt['tax_su_non_habit_surf_stat3']) === true
711 && (($val_dt['tax_su_non_habit_surf_stat2'] !== null
712 && $val_dt['tax_su_non_habit_surf_stat2'] !== '')
713 || ($val_dt['tax_su_non_habit_surf_stat3'] !== null
714 && $val_dt['tax_su_non_habit_surf_stat3'] !== ''))) {
715 //
716 $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']);
717 }
718 // Cas particulier d'un projet réduit à l'extension d'une habitation existante
719 $particular_case = false;
720 $fields_tab_crea_loc_hab = $inst_dt->get_fields_tab_crea_loc_hab();
721 foreach ($fields_tab_crea_loc_hab as $field) {
722 if (isset($val_dt[$field]) === false
723 || (isset($val_dt[$field]) === true
724 && ($val_dt[$field] === null
725 || $val_dt[$field] === ''))) {
726 //
727 $particular_case = true;
728 }
729 }
730 if ($particular_case === true) {
731 if (isset($val_dt['tax_ext_pret']) === true
732 && $val_dt['tax_ext_pret'] === 'f') {
733 //
734 $val_dt['tax_su_princ_surf1'] = $val_dt['tax_surf_tot_cstr'];
735 $val_dt['tax_su_princ_surf_stat1'] = $val_dt['tax_surf_loc_stat'];
736 }
737 if (isset($val_dt['tax_ext_pret']) === true
738 && $val_dt['tax_ext_pret'] === 't') {
739 //
740 if (isset($val_dt['tax_ext_desc']) === true) {
741 if (preg_match('/[pP].*[lL].*[aA].*[iI]/', $val_dt['tax_ext_desc']) === 1
742 || preg_match('/[lL].*[lL].*[tT].*[sS]/', $val_dt['tax_ext_desc']) === 1) {
743 //
744 $val_dt['tax_su_princ_surf2'] = $val_dt['tax_surf_tot_cstr'];
745 $val_dt['tax_su_princ_surf_stat2'] = $val_dt['tax_surf_loc_stat'];
746 }
747 // if (preg_match('/[pP].*[tT].*[zZ]/', $val_dt['tax_ext_desc']) === 1) {
748 // $val_dt['tax_su_princ_surf4'] = $val_dt['tax_surf_tot_cstr'];
749 // $val_dt['tax_su_princ_surf_stat4'] = $val_dt['tax_surf_loc_stat'];
750 // }
751 // if (preg_match('/[pP].*[lL].*[uU].*[sS]/', $val_dt['tax_ext_desc']) === 1
752 // || preg_match('/[lL].*[eE].*[sS]/', $val_dt['tax_ext_desc']) === 1
753 // || preg_match('/[pP].*[sS].*[lL].*[aA]/', $val_dt['tax_ext_desc']) === 1
754 // || preg_match('/[pP].*[lL].*[sS]/', $val_dt['tax_ext_desc']) === 1
755 // || preg_match('/[lL].*[lL].*[sS]/', $val_dt['tax_ext_desc']) === 1) {
756 // //
757 // $val_dt['tax_su_princ_surf3'] = $val_dt['tax_surf_tot_cstr'];
758 // $val_dt['tax_su_princ_surf_stat3'] = $val_dt['tax_surf_loc_stat'];
759 // }
760 }
761 }
762 }
763 // Cas particulier de la surface taxable démolie
764 if (isset($val_dt['tax_surf_tot_demo']) === true
765 && isset($val_dt['tax_surf_tax_demo']) === true
766 && ($val_dt['tax_surf_tot_demo'] === null
767 || $val_dt['tax_surf_tot_demo'] === '')) {
768 //
769 $val_dt['tax_surf_tot_demo'] = $val_dt['tax_surf_tax_demo'];
770 }
771 return $val_dt;
772 }
773
774 protected function get_external_uid($fk_idx, string $fk_idx_2) {
775 $inst_external_uid = $this->f->get_inst__by_other_idx(array(
776 "obj" => "lien_id_interne_uid_externe",
777 "fk_field" => 'object_id',
778 "fk_idx" => $fk_idx,
779 "fk_field_2" => 'object',
780 "fk_idx_2" => $fk_idx_2,
781 ));
782 return $inst_external_uid->getVal('external_uid');
783 }
784
785 protected function get_all_external_uids($fk_idx) {
786 $link_objects = array(
787 'dossier_autorisation',
788 'dossier',
789 'consultation',
790 'document_numerise',
791 );
792 $val_external_uid = array();
793 foreach ($link_objects as $link_object) {
794 $external_uid = $this->get_external_uid($fk_idx, $link_object);
795 if ($external_uid !== '' && $external_uid !== null) {
796 $val_external_uid[$link_object] = $external_uid;
797 }
798 }
799 return $val_external_uid;
800 }
801
802 protected function get_demandeurs_data(string $dossier) {
803 $val_demandeur = array();
804 $inst_di = $this->f->get_inst__om_dbform(array(
805 "obj" => "dossier",
806 "idx" => $dossier,
807 ));
808 $list_demandeurs = $inst_di->get_demandeurs();
809 foreach ($list_demandeurs as $demandeur) {
810 $inst_demandeur = $this->f->get_inst__om_dbform(array(
811 "obj" => "demandeur",
812 "idx" => $demandeur['demandeur'],
813 ));
814 $val_demandeur[$demandeur['demandeur']] = $inst_demandeur->get_json_data();
815 $val_demandeur[$demandeur['demandeur']]['petitionnaire_principal'] = $demandeur['petitionnaire_principal'];
816 }
817 return $val_demandeur;
818 }
819
820 protected function get_architecte_data($architecte = null) {
821 $val_architecte = null;
822 if ($architecte !== null
823 && $architecte !== '') {
824 //
825 $inst_architecte = $this->f->get_inst__om_dbform(array(
826 "obj" => "architecte",
827 "idx" => $architecte,
828 ));
829 $val_architecte = $inst_architecte->get_json_data();
830 }
831 return $val_architecte;
832 }
833
834 protected function get_instruction_data(string $dossier, $type = 'decision', $extra_params = array()) {
835 $val_instruction = null;
836 $instruction_with_doc = null;
837 $inst_di = $this->f->get_inst__om_dbform(array(
838 "obj" => "dossier",
839 "idx" => $dossier,
840 ));
841 $idx = null;
842 if ($type === 'decision') {
843 $idx = $inst_di->get_last_instruction_decision();
844 }
845 if ($type === 'incompletude') {
846 $idx = $inst_di->get_last_instruction_incompletude();
847 }
848 // XXX Permet de récupérer l'instruction par son identifiant
849 if ($type === 'with-id') {
850 $idx = $extra_params['with-id'];
851 }
852 $inst_instruction = $this->f->get_inst__om_dbform(array(
853 "obj" => "instruction",
854 "idx" => $idx,
855 ));
856 if (count($inst_instruction->val) > 0) {
857 $val_instruction = array();
858 $instruction_data = $inst_instruction->get_json_data();
859 $val_instruction = $this->sort_instruction_data($instruction_data, $val_instruction);
860 if ($instruction_data['om_fichier_instruction'] !== null
861 && $instruction_data['om_fichier_instruction'] !== '') {
862 //
863 $instruction_with_doc = $inst_instruction->getVal($inst_instruction->clePrimaire);
864 }
865 $inst_ev = $this->f->get_inst__om_dbform(array(
866 "obj" => "evenement",
867 "idx" => $inst_instruction->getVal('evenement'),
868 ));
869 if ($inst_ev->getVal('retour') === 't') {
870 $instructions_related = $inst_instruction->get_related_instructions();
871 foreach ($instructions_related as $instruction) {
872 if ($instruction !== null && $instruction !== '') {
873 $inst_related_instruction = $this->f->get_inst__om_dbform(array(
874 "obj" => "instruction",
875 "idx" => $instruction,
876 ));
877 $instruction_data = $inst_related_instruction->get_json_data();
878 $val_instruction = $this->sort_instruction_data($instruction_data, $val_instruction);
879 if ($instruction_data['om_fichier_instruction'] !== null
880 && $instruction_data['om_fichier_instruction'] !== '') {
881 //
882 $instruction_with_doc = $inst_related_instruction->getVal($inst_related_instruction->clePrimaire);
883 }
884 }
885 }
886 }
887 if ($instruction_with_doc !== null) {
888 //
889 $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);
890 }
891 }
892 return $val_instruction;
893 }
894
895 protected function sort_instruction_data(array $values, array $res) {
896 $fields = array(
897 "date_evenement",
898 "date_envoi_signature",
899 "date_retour_signature",
900 "date_envoi_rar",
901 "date_retour_rar",
902 "date_envoi_controle_legalite",
903 "date_retour_controle_legalite",
904 "signataire_arrete",
905 "om_fichier_instruction",
906 "tacite",
907 "lettretype",
908 );
909 foreach ($values as $key => $value) {
910 if (in_array($key, $fields) === true) {
911 if (array_key_exists($key, $res) === false
912 && $value !== null
913 && $value !== '') {
914 //
915 $res[$key] = $value;
916 } elseif ($key === 'tacite'
917 && $value === 't') {
918 //
919 $res[$key] = $value;
920 }
921 }
922 }
923 return $res;
924 }
925
926 protected function get_document_numerise_data(string $dn) {
927 $val_dn = array();
928 $inst_dn = $this->f->get_inst__om_dbform(array(
929 "obj" => "document_numerise",
930 "idx" => $dn,
931 ));
932 $val_dn = $inst_dn->get_json_data();
933 $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'));
934 // Correspond à la nomenclature Plat'AU NATURE_PIECE
935 $val_dn['nature'] = $val_dn['document_numerise_nature_libelle'];
936 return $val_dn;
937 }
938
939 protected function get_parcelles_data(string $object, string $idx) {
940 $val_dp = array();
941 $inst_di = $this->f->get_inst__om_dbform(array(
942 "obj" => $object,
943 "idx" => $idx,
944 ));
945 $list_parcelles = $inst_di->get_parcelles();
946 $no_ordre = 1;
947 foreach ($list_parcelles as $parcelle) {
948 $val_dp[$parcelle[$object.'_parcelle']] = array(
949 $object.'_parcelle' => $parcelle[$object.'_parcelle'],
950 'libelle' => $parcelle['libelle'],
951 'no_ordre' => $no_ordre,
952 );
953 $no_ordre++;
954 }
955 return $val_dp;
956 }
957
958 protected function get_avis_decision_data(string $dossier) {
959 $inst_di = $this->f->get_inst__om_dbform(array(
960 "obj" => "dossier",
961 "idx" => $dossier,
962 ));
963 $ad = $inst_di->getVal('avis_decision');
964 $val_ad = array();
965 $inst_ad = $this->f->get_inst__om_dbform(array(
966 "obj" => "avis_decision",
967 "idx" => $ad,
968 ));
969 $val_ad = $inst_ad->get_json_data();
970 $val_ad['txAvis'] = "Voir document joint";
971 if (isset($val_ad['tacite']) === true
972 && $val_ad['tacite'] === 't') {
973 //
974 $val_ad['txAvis'] = "Sans objet";
975 }
976 return $val_ad;
977 }
978
979 protected function get_signataire_arrete_data(string $sa) {
980 $inst_sa = $this->f->get_inst__om_dbform(array(
981 "obj" => "signataire_arrete",
982 "idx" => $sa,
983 ));
984 $val_sa = array_combine($inst_sa->champs, $inst_sa->val);
985 foreach ($val_sa as $key => $value) {
986 $val_sa[$key] = strip_tags($value);
987 }
988 return $val_sa;
989 }
990
991 protected function view_form_json($in_field = false) {
992 //
993 if ($this->f->get_submitted_post_value('valid') === null) {
994 // Liste des valeurs à afficher
995 $val = array();
996 //
997 $val_task = array_combine($this->champs, $this->val);
998 foreach ($val_task as $key => $value) {
999 $val_task[$key] = strip_tags($value);
1000 }
1001 $val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true);
1002 $val['task'] = $val_task;
1003 //
1004 if ($this->getVal('type') === 'creation_DA') {
1005 $val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id'));
1006 $val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation');
1007 $val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']);
1008 $val_external_uid = array();
1009 $val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation');
1010 $val['external_uids'] = $val_external_uid;
1011 }
1012 //
1013 if ($this->getVal('type') === 'creation_DI'
1014 || $this->getVal('type') === 'modification_DI'
1015 || $this->getVal('type') === 'depot_DI') {
1016 //
1017 $val['dossier'] = $this->get_dossier_data($this->getVal('object_id'));
1018 $val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction');
1019 $val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']);
1020 $architecte = isset($val['donnees_techniques']['architecte']) === true ? $val['donnees_techniques']['architecte'] : null;
1021 $val['architecte'] = $this->get_architecte_data($architecte);
1022 $val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']);
1023 $val_external_uid = array();
1024 $val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation');
1025 $val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier');
1026 $val['external_uids'] = $val_external_uid;
1027 }
1028 //
1029 if ($this->getVal('type') === 'qualification_DI') {
1030 $val['dossier'] = $this->get_dossier_data($this->getVal('object_id'));
1031 $val_external_uid = array();
1032 $val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation');
1033 $val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier');
1034 $val['external_uids'] = $val_external_uid;
1035 }
1036 //
1037 if ($this->getVal('type') === 'ajout_piece') {
1038 $val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id'));
1039 $val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']);
1040 $val_external_uid = array();
1041 $val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation');
1042 $val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier');
1043 $val_external_uid['document_numerise'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'document_numerise');
1044 $val['external_uids'] = $val_external_uid;
1045 }
1046 //
1047 if ($this->getVal('type') === 'decision_DI') {
1048 $val['dossier'] = $this->get_dossier_data($this->getVal('dossier'));
1049 $val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id')));
1050 $val_external_uid = array();
1051 $val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation');
1052 $val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier');
1053 $val['external_uids'] = $val_external_uid;
1054 }
1055 //
1056 if ($this->getVal('type') === 'incompletude_DI') {
1057 $val['dossier'] = $this->get_dossier_data($this->getVal('dossier'));
1058 $val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id')));
1059 $val_external_uid = array();
1060 $val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation');
1061 $val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier');
1062 $val['external_uids'] = $val_external_uid;
1063 }
1064 //
1065 if ($this->getVal('type') === 'completude_DI') {
1066 $val['dossier'] = $this->get_dossier_data($this->getVal('dossier'));
1067 $val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id')));
1068 $val_external_uid = array();
1069 $val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation');
1070 $val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier');
1071 $val['external_uids'] = $val_external_uid;
1072 }
1073 //
1074 if ($this->getVal('type') === 'pec_metier_consultation') {
1075 $val['dossier'] = $this->get_dossier_data($this->getVal('dossier'));
1076 $val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id')));
1077 $val_external_uid = array();
1078 $val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation');
1079 $val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier');
1080 $val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation');
1081 $val['external_uids'] = $val_external_uid;
1082 }
1083 //
1084 if ($this->getVal('type') === 'avis_consultation') {
1085 $val['dossier'] = $this->get_dossier_data($this->getVal('dossier'));
1086 $val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id')));
1087 $val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier'));
1088 if (isset($val['instruction']['signataire_arrete']) === true) {
1089 $val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']);
1090 }
1091 $val_external_uid = array();
1092 $val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation');
1093 $val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier');
1094 $val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation');
1095 $val['external_uids'] = $val_external_uid;
1096 }
1097
1098 if ($in_field === true) {
1099 return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
1100 } else {
1101 // Liste des valeurs affichée en JSON
1102 printf(json_encode($val, JSON_UNESCAPED_SLASHES));
1103 }
1104 }
1105 }
1106
1107 function post_update_task() {
1108 // Mise à jour des valeurs
1109 //
1110 $params = array(
1111 'val' => array(
1112 'state' => $this->f->get_submitted_post_value('state')
1113 ),
1114 );
1115 $update = $this->update_task($params);
1116 $message_class = "valid";
1117 $message = $this->msg;
1118 if ($update === false) {
1119 $this->addToLog($this->msg, DEBUG_MODE);
1120 $message_class = "error";
1121 $message = sprintf(
1122 '%s %s',
1123 __('Impossible de mettre à jour la tâche.'),
1124 __('Veuillez contacter votre administrateur.')
1125 );
1126 }
1127 $this->f->displayMessage($message_class, $message);
1128
1129 // Sauvegarde des uid externes retournés s'ils ne le sont pas encore
1130 if (is_array($this->f->get_submitted_post_value('external_uids')) === true) {
1131 //
1132 foreach ($this->f->get_submitted_post_value('external_uids') as $object => $external_uid) {
1133 //
1134 if (in_array($object, $this->get_objects_by_task_type($this->getVal('type'))) === true) {
1135 //
1136 $inst_lien = $this->f->get_inst__om_dbform(array(
1137 "obj" => "lien_id_interne_uid_externe",
1138 "idx" => ']',
1139 ));
1140 if ($inst_lien->is_exists($object, $document_numerise_id, $external_uid, $attachment_values['dossier']) === false) {
1141 //
1142 $valF = array(
1143 'lien_id_interne_uid_externe' => '',
1144 'object' => $object,
1145 'object_id' => $this->getVal('object_id'),
1146 'external_uid' => $external_uid,
1147 'dossier' => $this->getVal('dossier'),
1148 );
1149 $add = $inst_lien->ajouter($valF);
1150 $message_class = "valid";
1151 $message = $inst_lien->msg;
1152 if ($add === false) {
1153 $this->addToLog($inst_lien->msg, DEBUG_MODE);
1154 $message_class = "error";
1155 $message = sprintf(
1156 '%s %s',
1157 __("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."),
1158 __('Veuillez contacter votre administrateur.')
1159 );
1160 }
1161 $this->f->displayMessage($message_class, $message);
1162 }
1163 }
1164 }
1165 }
1166 }
1167
1168 function post_add_task() {
1169 // TODO Tester de remplacer la ligne de json_payload par un $_POST
1170 $result = $this->add_task(array(
1171 'val' => array(
1172 'stream' => 'input',
1173 'json_payload' => html_entity_decode($this->f->get_submitted_post_value('json_payload')),
1174 'type' => $this->f->get_submitted_post_value('type'),
1175 )
1176 ));
1177 $message = $this->msg;
1178 $message_class = "valid";
1179 if ($result === false){
1180 $this->addToLog($this->msg, DEBUG_MODE);
1181 $message_class = "error";
1182 $message = sprintf(
1183 '%s %s',
1184 __('Impossible d\'ajouter la tâche.'),
1185 __('Veuillez contacter votre administrateur.')
1186 );
1187 }
1188 $this->f->displayMessage($message_class, $message);
1189 }
1190
1191 function setLayout(&$form, $maj) {
1192
1193 // Récupération du mode de l'action
1194 $crud = $this->get_action_crud($maj);
1195
1196 // MODE different de CREER
1197 if ($maj != 0 || $crud != 'create') {
1198 $form->setBloc('json_payload', 'D', '', 'col_6');
1199 $form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed");
1200 $form->setBloc('json_payload', 'F');
1201 }
1202 $form->setBloc('timestamp_log', 'DF', '', 'col_9');
1203 }
1204
1205 /**
1206 * [get_objects_by_task_type description]
1207 * @param [type] $type [description]
1208 * @return [type] [description]
1209 */
1210 function get_objects_by_task_type($type) {
1211 $objects = array();
1212 if (in_array($type, array('creation_DA', )) === true) {
1213 $objects = array('dossier_autorisation', );
1214 }
1215 if (in_array($type, array('creation_DI', 'depot_DI', 'notification_DI', 'qualification_DI', )) === true) {
1216 $objects = array('dossier', );
1217 }
1218 if (in_array($type, array('create_DI_for_consultation', )) === true) {
1219 $objects = array('dossier', 'dossier_consultation', );
1220 }
1221 if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) {
1222 $objects = array('instruction', );
1223 }
1224 if (in_array($type, array('pec_metier_consultation', )) === true) {
1225 $objects = array('pec_dossier_consultation', );
1226 }
1227 if (in_array($type, array('avis_consultation', )) === true) {
1228 $objects = array('avis_dossier_consultation', );
1229 }
1230 if (in_array($type, array('ajout_piece', 'add_piece', )) === true) {
1231 $objects = array('piece', );
1232 }
1233 return $objects;
1234 }
1235
1236 }

Properties

Name Value
svn:executable *

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26