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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9955 - (show annotations)
Wed Feb 24 11:25:33 2021 UTC (3 years, 11 months ago) by mbideau
Original Path: branches/4.14.0-develop/obj/task.class.php
File size: 54072 byte(s)
Fusion de la branche de développement '4.14.0-develop_fix_tests' dans la branche d'intégration '4.14.0-develop_demat'
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['external_uids']['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>', 'external_uids/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 if (json_last_error() !== JSON_ERROR_NONE) {
458 $this->addToMessage(__("Le contenu JSON de la tâche n'est pas valide."));
459 return $this->end_treatment(__METHOD__, false);
460 }
461 $document_numerise = $json_payload['document_numerise'];
462 $file_content = base64_decode($document_numerise["file_content"]);
463 if ($file_content === false){
464 $this->addToMessage(__("Le contenu du fichier lié à la tâche n'a pas pu etre recupere."));
465 return $this->end_treatment(__METHOD__, false);
466 }
467 $metadata = array(
468 "filename" => $document_numerise['nom_fichier'],
469 "size" => strlen($file_content),
470 "mimetype" => $document_numerise['file_content_type'],
471 "date_creation" => $document_numerise['date_creation'],
472 );
473 $uid_fichier = $this->f->storage->create($file_content, $metadata, "from_content");
474 if ($uid_fichier === OP_FAILURE) {
475 $this->addToMessage(__("Erreur lors de la creation du fichier lié à la tâche."));
476 return $this->end_treatment(__METHOD__, false);
477 }
478 $json_payload["document_numerise"]["uid"] = $uid_fichier;
479 // Le fichier a été ajouté nous n'avons plus besoin du champ file_content dans la payload
480 unset($json_payload["document_numerise"]["file_content"]);
481 $params['val']['json_payload'] = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
482 }
483
484 // Mise à jour du DI
485 $valF = array(
486 'task' => '',
487 'type' => $params['val']['type'],
488 'timestamp_log' => $timestamp_log,
489 'state' => isset($params['val']['state']) === true ? $params['val']['state'] : self::STATUS_NEW,
490 'object_id' => isset($params['val']['object_id']) ? $params['val']['object_id'] : '',
491 'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '',
492 'stream' => $stream,
493 'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}',
494 );
495
496 // tâche sortante
497 if($valF["stream"] == "output"){
498
499 // TODO expliquer ce code
500 $task_exists = $this->task_exists($valF['type'], $valF['object_id']);
501 if ($valF['type'] === 'modification_DI' && $task_exists === false) {
502 $task_exists = $this->task_exists('creation_DI', $valF['object_id']);
503 }
504 if ($task_exists !== false) {
505 $inst_task = $this->f->get_inst__om_dbform(array(
506 "obj" => "task",
507 "idx" => $task_exists,
508 ));
509 $update_state = $inst_task->getVal('state');
510 if (isset($params['update_val']['state']) === true) {
511 $update_state = $params['update_val']['state'];
512 }
513 $update_params = array(
514 'val' => array(
515 'state' => $update_state,
516 ),
517 );
518 return $inst_task->update_task($update_params);
519 }
520 }
521
522 $add = $this->ajouter($valF);
523 $this->addToLog(__METHOD__."(): retour de l'ajout de tâche: ".var_export($add, true), VERBOSE_MODE);
524 if ($add === false) {
525 $this->addToLog(__METHOD__."(): ".$this->msg, DEBUG_MODE);
526 return $this->end_treatment(__METHOD__, false);
527 }
528 return $this->end_treatment(__METHOD__, true);
529 }
530
531 /**
532 * TREATMENT - update_task
533 * Met à jour l'enregistrement instancié.
534 *
535 * @param array $params Tableau des paramètres
536 * @return boolean
537 */
538 public function update_task($params = array()) {
539 $this->begin_treatment(__METHOD__);
540 $timestamp_log = $this->get_timestamp_log();
541 if ($timestamp_log === false) {
542 $this->addToLog(__METHOD__."(): erreur timestamp log", DEBUG_MODE);
543 return $this->end_treatment(__METHOD__, false);
544 }
545 array_push($timestamp_log, array(
546 'modification_date' => date('Y-m-d H:i:s'),
547 'state' => $params['val']['state'],
548 'prev_state' => $this->getVal('state'),
549 ));
550 $timestamp_log = json_encode($timestamp_log);
551 $valF = array(
552 'task' => $this->getVal($this->clePrimaire),
553 'type' => $this->getVal('type'),
554 'timestamp_log' => $timestamp_log,
555 'state' => $params['val']['state'],
556 'object_id' => $this->getVal('object_id'),
557 'stream' => $this->getVal('stream'),
558 'dossier' => $this->getVal('dossier'),
559 'json_payload' => $this->getVal('json_payload'),
560 );
561 $update = $this->modifier($valF);
562 if ($update === false) {
563 $this->addToLog($this->msg, DEBUG_MODE);
564 return $this->end_treatment(__METHOD__, false);
565 }
566 return $this->end_treatment(__METHOD__, true);
567 }
568
569 /**
570 * Récupère le journal d'horodatage dans le champ timestamp_log de
571 * l'enregistrement instancié.
572 *
573 * @param array $params Tableau des paramètres
574 * @return array sinon false en cas d'erreur
575 */
576 protected function get_timestamp_log($params = array()) {
577 $val = $this->getVal('timestamp_log');
578 if ($val === '') {
579 $val = json_encode(array());
580 }
581 if($this->isJson($val) === false) {
582 return false;
583 }
584 return json_decode($val, true);
585 }
586
587 /**
588 * VIEW - view_json_data
589 * Affiche l'enregistrement dans le format JSON.
590 *
591 * @return void
592 */
593 public function view_json_data() {
594 $this->checkAccessibility();
595 $this->f->disableLog();
596 if ($this->getParameter('idx') !== ']'
597 && $this->getParameter('idx') !== '0') {
598 //
599 $this->view_form_json();
600 }
601 else {
602 $this->view_tab_json();
603 }
604 }
605
606 protected function view_tab_json() {
607 $where = '';
608 if ($this->f->get_submitted_get_value('state') !== null
609 && $this->f->get_submitted_get_value('state') !== '') {
610 //
611 $where = sprintf(' WHERE state = \'%s\' ', $this->f->get_submitted_get_value('state'));
612 }
613 $query = sprintf('
614 SELECT
615 *
616 FROM %1$stask
617 %2$s
618 ORDER BY task ASC
619 ',
620 DB_PREFIXE,
621 $where
622 );
623 $res = $this->f->get_all_results_from_db_query($query, true);
624 if ($res['code'] === 'KO') {
625 return false;
626 }
627 $list_tasks = array();
628 foreach ($res['result'] as $task) {
629 $task['timestamp_log'] = json_decode($task['timestamp_log'], true);
630 $task['dossier'] = $task['dossier'];
631 if ($task['type'] === 'ajout_piece') {
632 $val_dn = $this->get_document_numerise_data($task['object_id']);
633 }
634 if ($task['stream'] === 'output') {
635 $task['external_uids'] = $this->get_all_external_uids($task['dossier']);
636 }
637 $list_tasks[$task['task']] = $task;
638 }
639 printf(json_encode($list_tasks));
640 }
641
642 protected function get_dossier_data(string $dossier) {
643 $val_di = array();
644 $inst_di = $this->f->get_inst__om_dbform(array(
645 "obj" => "dossier",
646 "idx" => $dossier,
647 ));
648 $val_di = $inst_di->get_json_data();
649 if ($val_di['dossier_instruction_type_code'] === 'T') {
650 $val_di['date_decision_transfert'] = $val_di['date_decision'];
651 }
652 unset($val_di['initial_dt']);
653 unset($val_di['log_instructions']);
654 return $val_di;
655 }
656
657 protected function get_dossier_autorisation_data(string $da) {
658 $val_da = array();
659 $inst_da = $this->f->get_inst__om_dbform(array(
660 "obj" => "dossier_autorisation",
661 "idx" => $da,
662 ));
663 $val_da = $inst_da->get_json_data();
664 return $val_da;
665 }
666
667 protected function get_donnees_techniques_data(string $fk_idx, string $fk_field) {
668 $val_dt = array();
669 $inst_dt = $this->f->get_inst__by_other_idx(array(
670 "obj" => "donnees_techniques",
671 "fk_field" => $fk_field,
672 "fk_idx" => $fk_idx,
673 ));
674 $val_dt = array(
675 'donnees_techniques' => $inst_dt->getVal($inst_dt->clePrimaire),
676 'cerfa' => $inst_dt->getVal('cerfa'),
677 );
678 $val_dt = array_merge($val_dt, $inst_dt->get_donnees_techniques_applicables());
679 if (isset($val_dt['am_exist_date']) === true) {
680 $val_dt['am_exist_date_num'] = '';
681 if (is_numeric($val_dt['am_exist_date']) === true) {
682 $val_dt['am_exist_date_num'] = $val_dt['am_exist_date'];
683 }
684 }
685 // Correspond à la nomenclature de Plat'AU STATUT_INFO
686 $val_dt['tax_statut_info'] = 'Déclaré';
687 //
688 if ($inst_dt->is_tab_surf_ssdest_enabled() === true) {
689 $fields_tab_surf_dest = $inst_dt->get_fields_tab_surf_dest();
690 foreach ($fields_tab_surf_dest as $field) {
691 if (isset($val_dt[$field]) === true) {
692 unset($val_dt[$field]);
693 }
694 }
695 } else {
696 $fields_tab_surf_ssdest = $inst_dt->get_fields_tab_surf_ssdest();
697 foreach ($fields_tab_surf_ssdest as $field) {
698 if (isset($val_dt[$field]) === true) {
699 unset($val_dt[$field]);
700 }
701 }
702 }
703 // Correspond à la nouvelle ligne CERFA v7 dans le DENSI imposition 1.2.3
704 if (isset($val_dt['tax_su_non_habit_surf2']) === true
705 && isset($val_dt['tax_su_non_habit_surf3']) === true
706 && (($val_dt['tax_su_non_habit_surf2'] !== null
707 && $val_dt['tax_su_non_habit_surf2'] !== '')
708 || ($val_dt['tax_su_non_habit_surf3'] !== null
709 && $val_dt['tax_su_non_habit_surf3'] !== ''))) {
710 //
711 $val_dt['tax_su_non_habit_surf8'] = intval($val_dt['tax_su_non_habit_surf2']) + intval($val_dt['tax_su_non_habit_surf3']);
712 }
713 if (isset($val_dt['tax_su_non_habit_surf_stat2']) === true
714 && isset($val_dt['tax_su_non_habit_surf_stat3']) === true
715 && (($val_dt['tax_su_non_habit_surf_stat2'] !== null
716 && $val_dt['tax_su_non_habit_surf_stat2'] !== '')
717 || ($val_dt['tax_su_non_habit_surf_stat3'] !== null
718 && $val_dt['tax_su_non_habit_surf_stat3'] !== ''))) {
719 //
720 $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']);
721 }
722 // Cas particulier d'un projet réduit à l'extension d'une habitation existante
723 $particular_case = false;
724 $fields_tab_crea_loc_hab = $inst_dt->get_fields_tab_crea_loc_hab();
725 foreach ($fields_tab_crea_loc_hab as $field) {
726 if (isset($val_dt[$field]) === false
727 || (isset($val_dt[$field]) === true
728 && ($val_dt[$field] === null
729 || $val_dt[$field] === ''))) {
730 //
731 $particular_case = true;
732 }
733 }
734 if ($particular_case === true) {
735 if (isset($val_dt['tax_ext_pret']) === true
736 && $val_dt['tax_ext_pret'] === 'f') {
737 //
738 $val_dt['tax_su_princ_surf1'] = $val_dt['tax_surf_tot_cstr'];
739 $val_dt['tax_su_princ_surf_stat1'] = $val_dt['tax_surf_loc_stat'];
740 }
741 if (isset($val_dt['tax_ext_pret']) === true
742 && $val_dt['tax_ext_pret'] === 't') {
743 //
744 if (isset($val_dt['tax_ext_desc']) === true) {
745 if (preg_match('/[pP].*[lL].*[aA].*[iI]/', $val_dt['tax_ext_desc']) === 1
746 || preg_match('/[lL].*[lL].*[tT].*[sS]/', $val_dt['tax_ext_desc']) === 1) {
747 //
748 $val_dt['tax_su_princ_surf2'] = $val_dt['tax_surf_tot_cstr'];
749 $val_dt['tax_su_princ_surf_stat2'] = $val_dt['tax_surf_loc_stat'];
750 }
751 // if (preg_match('/[pP].*[tT].*[zZ]/', $val_dt['tax_ext_desc']) === 1) {
752 // $val_dt['tax_su_princ_surf4'] = $val_dt['tax_surf_tot_cstr'];
753 // $val_dt['tax_su_princ_surf_stat4'] = $val_dt['tax_surf_loc_stat'];
754 // }
755 // if (preg_match('/[pP].*[lL].*[uU].*[sS]/', $val_dt['tax_ext_desc']) === 1
756 // || preg_match('/[lL].*[eE].*[sS]/', $val_dt['tax_ext_desc']) === 1
757 // || preg_match('/[pP].*[sS].*[lL].*[aA]/', $val_dt['tax_ext_desc']) === 1
758 // || preg_match('/[pP].*[lL].*[sS]/', $val_dt['tax_ext_desc']) === 1
759 // || preg_match('/[lL].*[lL].*[sS]/', $val_dt['tax_ext_desc']) === 1) {
760 // //
761 // $val_dt['tax_su_princ_surf3'] = $val_dt['tax_surf_tot_cstr'];
762 // $val_dt['tax_su_princ_surf_stat3'] = $val_dt['tax_surf_loc_stat'];
763 // }
764 }
765 }
766 }
767 // Cas particulier de la surface taxable démolie
768 if (isset($val_dt['tax_surf_tot_demo']) === true
769 && isset($val_dt['tax_surf_tax_demo']) === true
770 && ($val_dt['tax_surf_tot_demo'] === null
771 || $val_dt['tax_surf_tot_demo'] === '')) {
772 //
773 $val_dt['tax_surf_tot_demo'] = $val_dt['tax_surf_tax_demo'];
774 }
775 return $val_dt;
776 }
777
778 protected function get_external_uid($fk_idx, string $fk_idx_2) {
779 $inst_external_uid = $this->f->get_inst__by_other_idx(array(
780 "obj" => "lien_id_interne_uid_externe",
781 "fk_field" => 'object_id',
782 "fk_idx" => $fk_idx,
783 "fk_field_2" => 'object',
784 "fk_idx_2" => $fk_idx_2,
785 ));
786 return $inst_external_uid->getVal('external_uid');
787 }
788
789 protected function get_all_external_uids($fk_idx) {
790 $link_objects = array(
791 'dossier_autorisation',
792 'dossier',
793 'consultation',
794 'document_numerise',
795 );
796 $val_external_uid = array();
797 foreach ($link_objects as $link_object) {
798 $external_uid = $this->get_external_uid($fk_idx, $link_object);
799 if ($external_uid !== '' && $external_uid !== null) {
800 $val_external_uid[$link_object] = $external_uid;
801 }
802 }
803 return $val_external_uid;
804 }
805
806 protected function get_demandeurs_data(string $dossier) {
807 $val_demandeur = array();
808 $inst_di = $this->f->get_inst__om_dbform(array(
809 "obj" => "dossier",
810 "idx" => $dossier,
811 ));
812 $list_demandeurs = $inst_di->get_demandeurs();
813 foreach ($list_demandeurs as $demandeur) {
814 $inst_demandeur = $this->f->get_inst__om_dbform(array(
815 "obj" => "demandeur",
816 "idx" => $demandeur['demandeur'],
817 ));
818 $val_demandeur[$demandeur['demandeur']] = $inst_demandeur->get_json_data();
819 $val_demandeur[$demandeur['demandeur']]['petitionnaire_principal'] = $demandeur['petitionnaire_principal'];
820 }
821 return $val_demandeur;
822 }
823
824 protected function get_architecte_data($architecte = null) {
825 $val_architecte = null;
826 if ($architecte !== null
827 && $architecte !== '') {
828 //
829 $inst_architecte = $this->f->get_inst__om_dbform(array(
830 "obj" => "architecte",
831 "idx" => $architecte,
832 ));
833 $val_architecte = $inst_architecte->get_json_data();
834 }
835 return $val_architecte;
836 }
837
838 protected function get_instruction_data(string $dossier, $type = 'decision', $extra_params = array()) {
839 $val_instruction = null;
840 $instruction_with_doc = null;
841 $inst_di = $this->f->get_inst__om_dbform(array(
842 "obj" => "dossier",
843 "idx" => $dossier,
844 ));
845 $idx = null;
846 if ($type === 'decision') {
847 $idx = $inst_di->get_last_instruction_decision();
848 }
849 if ($type === 'incompletude') {
850 $idx = $inst_di->get_last_instruction_incompletude();
851 }
852 // XXX Permet de récupérer l'instruction par son identifiant
853 if ($type === 'with-id') {
854 $idx = $extra_params['with-id'];
855 }
856 $inst_instruction = $this->f->get_inst__om_dbform(array(
857 "obj" => "instruction",
858 "idx" => $idx,
859 ));
860 if (count($inst_instruction->val) > 0) {
861 $val_instruction = array();
862 $instruction_data = $inst_instruction->get_json_data();
863 $val_instruction = $this->sort_instruction_data($instruction_data, $val_instruction);
864 if ($instruction_data['om_fichier_instruction'] !== null
865 && $instruction_data['om_fichier_instruction'] !== '') {
866 //
867 $instruction_with_doc = $inst_instruction->getVal($inst_instruction->clePrimaire);
868 }
869 $inst_ev = $this->f->get_inst__om_dbform(array(
870 "obj" => "evenement",
871 "idx" => $inst_instruction->getVal('evenement'),
872 ));
873 if ($inst_ev->getVal('retour') === 't') {
874 $instructions_related = $inst_instruction->get_related_instructions();
875 foreach ($instructions_related as $instruction) {
876 if ($instruction !== null && $instruction !== '') {
877 $inst_related_instruction = $this->f->get_inst__om_dbform(array(
878 "obj" => "instruction",
879 "idx" => $instruction,
880 ));
881 $instruction_data = $inst_related_instruction->get_json_data();
882 $val_instruction = $this->sort_instruction_data($instruction_data, $val_instruction);
883 if ($instruction_data['om_fichier_instruction'] !== null
884 && $instruction_data['om_fichier_instruction'] !== '') {
885 //
886 $instruction_with_doc = $inst_related_instruction->getVal($inst_related_instruction->clePrimaire);
887 }
888 }
889 }
890 }
891 if ($instruction_with_doc !== null) {
892 //
893 $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);
894 }
895 }
896 return $val_instruction;
897 }
898
899 protected function sort_instruction_data(array $values, array $res) {
900 $fields = array(
901 "date_evenement",
902 "date_envoi_signature",
903 "date_retour_signature",
904 "date_envoi_rar",
905 "date_retour_rar",
906 "date_envoi_controle_legalite",
907 "date_retour_controle_legalite",
908 "signataire_arrete",
909 "om_fichier_instruction",
910 "tacite",
911 "lettretype",
912 );
913 foreach ($values as $key => $value) {
914 if (in_array($key, $fields) === true) {
915 if (array_key_exists($key, $res) === false
916 && $value !== null
917 && $value !== '') {
918 //
919 $res[$key] = $value;
920 } elseif ($key === 'tacite'
921 && $value === 't') {
922 //
923 $res[$key] = $value;
924 }
925 }
926 }
927 return $res;
928 }
929
930 protected function get_document_numerise_data(string $dn) {
931 $val_dn = array();
932 $inst_dn = $this->f->get_inst__om_dbform(array(
933 "obj" => "document_numerise",
934 "idx" => $dn,
935 ));
936 $val_dn = $inst_dn->get_json_data();
937 $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'));
938 // Correspond à la nomenclature Plat'AU NATURE_PIECE
939 $val_dn['nature'] = $val_dn['document_numerise_nature_libelle'];
940 return $val_dn;
941 }
942
943 protected function get_parcelles_data(string $object, string $idx) {
944 $val_dp = array();
945 $inst_di = $this->f->get_inst__om_dbform(array(
946 "obj" => $object,
947 "idx" => $idx,
948 ));
949 $list_parcelles = $inst_di->get_parcelles();
950 $no_ordre = 1;
951 foreach ($list_parcelles as $parcelle) {
952 $val_dp[$parcelle[$object.'_parcelle']] = array(
953 $object.'_parcelle' => $parcelle[$object.'_parcelle'],
954 'libelle' => $parcelle['libelle'],
955 'no_ordre' => $no_ordre,
956 );
957 $no_ordre++;
958 }
959 return $val_dp;
960 }
961
962 protected function get_avis_decision_data(string $dossier) {
963 $inst_di = $this->f->get_inst__om_dbform(array(
964 "obj" => "dossier",
965 "idx" => $dossier,
966 ));
967 $ad = $inst_di->getVal('avis_decision');
968 $val_ad = array();
969 $inst_ad = $this->f->get_inst__om_dbform(array(
970 "obj" => "avis_decision",
971 "idx" => $ad,
972 ));
973 $val_ad = $inst_ad->get_json_data();
974 $val_ad['txAvis'] = "Voir document joint";
975 if (isset($val_ad['tacite']) === true
976 && $val_ad['tacite'] === 't') {
977 //
978 $val_ad['txAvis'] = "Sans objet";
979 }
980 return $val_ad;
981 }
982
983 protected function get_signataire_arrete_data(string $sa) {
984 $inst_sa = $this->f->get_inst__om_dbform(array(
985 "obj" => "signataire_arrete",
986 "idx" => $sa,
987 ));
988 $val_sa = array_combine($inst_sa->champs, $inst_sa->val);
989 foreach ($val_sa as $key => $value) {
990 $val_sa[$key] = strip_tags($value);
991 }
992 return $val_sa;
993 }
994
995 protected function view_form_json($in_field = false) {
996 //
997 if ($this->f->get_submitted_post_value('valid') === null) {
998 // Liste des valeurs à afficher
999 $val = array();
1000 //
1001 $val_task = array_combine($this->champs, $this->val);
1002 foreach ($val_task as $key => $value) {
1003 $val_task[$key] = strip_tags($value);
1004 }
1005 $val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true);
1006 $val['task'] = $val_task;
1007 //
1008 if ($this->getVal('type') === 'creation_DA') {
1009 $val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id'));
1010 $val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation');
1011 $val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']);
1012 $val_external_uid = array();
1013 $val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation');
1014 $val['external_uids'] = $val_external_uid;
1015 }
1016 //
1017 if ($this->getVal('type') === 'creation_DI'
1018 || $this->getVal('type') === 'modification_DI'
1019 || $this->getVal('type') === 'depot_DI') {
1020 //
1021 $val['dossier'] = $this->get_dossier_data($this->getVal('object_id'));
1022 $val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction');
1023 $val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']);
1024 $architecte = isset($val['donnees_techniques']['architecte']) === true ? $val['donnees_techniques']['architecte'] : null;
1025 $val['architecte'] = $this->get_architecte_data($architecte);
1026 $val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']);
1027 $val_external_uid = array();
1028 $val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation');
1029 $val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier');
1030 $val['external_uids'] = $val_external_uid;
1031 }
1032 //
1033 if ($this->getVal('type') === 'qualification_DI') {
1034 $val['dossier'] = $this->get_dossier_data($this->getVal('object_id'));
1035 $val_external_uid = array();
1036 $val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation');
1037 $val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier');
1038 $val['external_uids'] = $val_external_uid;
1039 }
1040 //
1041 if ($this->getVal('type') === 'ajout_piece') {
1042 $val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id'));
1043 $val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']);
1044 $val_external_uid = array();
1045 $val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation');
1046 $val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier');
1047 $val_external_uid['document_numerise'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'document_numerise');
1048 $val['external_uids'] = $val_external_uid;
1049 }
1050 //
1051 if ($this->getVal('type') === 'decision_DI') {
1052 $val['dossier'] = $this->get_dossier_data($this->getVal('dossier'));
1053 $val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id')));
1054 $val_external_uid = array();
1055 $val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation');
1056 $val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier');
1057 $val['external_uids'] = $val_external_uid;
1058 }
1059 //
1060 if ($this->getVal('type') === 'incompletude_DI') {
1061 $val['dossier'] = $this->get_dossier_data($this->getVal('dossier'));
1062 $val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id')));
1063 $val_external_uid = array();
1064 $val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation');
1065 $val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier');
1066 $val['external_uids'] = $val_external_uid;
1067 }
1068 //
1069 if ($this->getVal('type') === 'completude_DI') {
1070 $val['dossier'] = $this->get_dossier_data($this->getVal('dossier'));
1071 $val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id')));
1072 $val_external_uid = array();
1073 $val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation');
1074 $val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier');
1075 $val['external_uids'] = $val_external_uid;
1076 }
1077 //
1078 if ($this->getVal('type') === 'pec_metier_consultation') {
1079 $val['dossier'] = $this->get_dossier_data($this->getVal('dossier'));
1080 $val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id')));
1081 $val_external_uid = array();
1082 $val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation');
1083 $val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier');
1084 $val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation');
1085 $val['external_uids'] = $val_external_uid;
1086 }
1087 //
1088 if ($this->getVal('type') === 'avis_consultation') {
1089 $val['dossier'] = $this->get_dossier_data($this->getVal('dossier'));
1090 $val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id')));
1091 $val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier'));
1092 if (isset($val['instruction']['signataire_arrete']) === true) {
1093 $val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']);
1094 }
1095 $val_external_uid = array();
1096 $val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation');
1097 $val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier');
1098 $val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation');
1099 $val['external_uids'] = $val_external_uid;
1100 }
1101
1102 if ($in_field === true) {
1103 return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
1104 } else {
1105 // Liste des valeurs affichée en JSON
1106 printf(json_encode($val, JSON_UNESCAPED_SLASHES));
1107 }
1108 }
1109 }
1110
1111 function post_update_task() {
1112 // Mise à jour des valeurs
1113 //
1114 $params = array(
1115 'val' => array(
1116 'state' => $this->f->get_submitted_post_value('state')
1117 ),
1118 );
1119 $update = $this->update_task($params);
1120 $message_class = "valid";
1121 $message = $this->msg;
1122 if ($update === false) {
1123 $this->addToLog($this->msg, DEBUG_MODE);
1124 $message_class = "error";
1125 $message = sprintf(
1126 '%s %s',
1127 __('Impossible de mettre à jour la tâche.'),
1128 __('Veuillez contacter votre administrateur.')
1129 );
1130 }
1131 $this->f->displayMessage($message_class, $message);
1132
1133 // Sauvegarde des uid externes retournés s'ils ne le sont pas encore
1134 if (is_array($this->f->get_submitted_post_value('external_uids')) === true) {
1135 //
1136 foreach ($this->f->get_submitted_post_value('external_uids') as $object => $external_uid) {
1137 //
1138 if (in_array($object, $this->get_objects_by_task_type($this->getVal('type'))) === true) {
1139 //
1140 $inst_lien = $this->f->get_inst__om_dbform(array(
1141 "obj" => "lien_id_interne_uid_externe",
1142 "idx" => ']',
1143 ));
1144 if ($inst_lien->is_exists($object, $document_numerise_id, $external_uid, $attachment_values['dossier']) === false) {
1145 //
1146 $valF = array(
1147 'lien_id_interne_uid_externe' => '',
1148 'object' => $object,
1149 'object_id' => $this->getVal('object_id'),
1150 'external_uid' => $external_uid,
1151 'dossier' => $this->getVal('dossier'),
1152 );
1153 $add = $inst_lien->ajouter($valF);
1154 $message_class = "valid";
1155 $message = $inst_lien->msg;
1156 if ($add === false) {
1157 $this->addToLog($inst_lien->msg, DEBUG_MODE);
1158 $message_class = "error";
1159 $message = sprintf(
1160 '%s %s',
1161 __("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."),
1162 __('Veuillez contacter votre administrateur.')
1163 );
1164 }
1165 $this->f->displayMessage($message_class, $message);
1166 }
1167 }
1168 }
1169 }
1170 }
1171
1172 function post_add_task() {
1173 // TODO Tester de remplacer la ligne de json_payload par un $_POST
1174 $result = $this->add_task(array(
1175 'val' => array(
1176 'stream' => 'input',
1177 'json_payload' => html_entity_decode($this->f->get_submitted_post_value('json_payload')),
1178 'type' => $this->f->get_submitted_post_value('type'),
1179 )
1180 ));
1181 $message = sprintf(
1182 __("Tâche %s ajoutée avec succès"),
1183 $this->getVal($this->clePrimaire)).
1184 '<br/><br/>'.
1185 $this->msg;
1186 $message_class = "valid";
1187 if ($result === false){
1188 $this->addToLog($this->msg, DEBUG_MODE);
1189 $message_class = "error";
1190 $message = sprintf(
1191 '%s %s',
1192 __('Impossible d\'ajouter la tâche.'),
1193 __('Veuillez contacter votre administrateur.')
1194 );
1195 }
1196 $this->f->displayMessage($message_class, $message);
1197 }
1198
1199 function setLayout(&$form, $maj) {
1200
1201 // Récupération du mode de l'action
1202 $crud = $this->get_action_crud($maj);
1203
1204 // MODE different de CREER
1205 if ($maj != 0 || $crud != 'create') {
1206 $form->setBloc('json_payload', 'D', '', 'col_6');
1207 $form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed");
1208 $form->setBloc('json_payload', 'F');
1209 }
1210 $form->setBloc('timestamp_log', 'DF', '', 'col_9');
1211 }
1212
1213 /**
1214 * [get_objects_by_task_type description]
1215 * @param [type] $type [description]
1216 * @return [type] [description]
1217 */
1218 function get_objects_by_task_type($type) {
1219 $objects = array();
1220 if (in_array($type, array('creation_DA', )) === true) {
1221 $objects = array('dossier_autorisation', );
1222 }
1223 if (in_array($type, array('creation_DI', 'depot_DI', 'notification_DI', 'qualification_DI', )) === true) {
1224 $objects = array('dossier', );
1225 }
1226 if (in_array($type, array('create_DI_for_consultation', )) === true) {
1227 $objects = array('dossier', 'dossier_consultation', );
1228 }
1229 if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) {
1230 $objects = array('instruction', );
1231 }
1232 if (in_array($type, array('pec_metier_consultation', )) === true) {
1233 $objects = array('pec_dossier_consultation', );
1234 }
1235 if (in_array($type, array('avis_consultation', )) === true) {
1236 $objects = array('avis_dossier_consultation', );
1237 }
1238 if (in_array($type, array('ajout_piece', 'add_piece', )) === true) {
1239 $objects = array('piece', );
1240 }
1241 return $objects;
1242 }
1243
1244 }

Properties

Name Value
svn:executable *

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26