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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9842 - (hide annotations)
Mon Jan 11 09:35:55 2021 UTC (4 years ago) by softime
Original Path: branches/4.14.0-develop/obj/task.class.php
File size: 49591 byte(s)
* Correction UI pour modifier PeC sur événement retour
* Correction rempalcement ' par " dans setValF de task
1 softime 9293 <?php
2 mbroquet 9776 //$Id$
3 softime 9293 //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 mbideau 9799 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 softime 9293 /**
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 softime 9330 "identifier" => "json_data",
27     "view" => "view_json_data",
28 softime 9293 "permission_suffix" => "consulter",
29     );
30 gmalvolti 9721 $this->class_actions[997] = array(
31     "identifier" => "json_data",
32 gmalvolti 9765 "view" => "post_update_task",
33 gmalvolti 9721 "permission_suffix" => "modifier",
34     );
35     $this->class_actions[996] = array(
36     "identifier" => "json_data",
37 gmalvolti 9765 "view" => "post_add_task",
38 gmalvolti 9721 "permission_suffix" => "ajouter",
39     );
40 softime 9293 }
41    
42 softime 9482 public function setvalF($val = array()) {
43 mbideau 9813
44 softime 9842 // // 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 mbideau 9813
73 softime 9482 parent::setvalF($val);
74 mbideau 9813
75 softime 9842 // 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 mbideau 9813 // 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 softime 9482 }
87 mbideau 9813
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 softime 9482 }
107    
108 gmalvolti 9589 /**
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 gmalvolti 9721 "stream",
120 gmalvolti 9604 "json_payload",
121 gmalvolti 9589 "timestamp_log",
122     );
123     }
124    
125 gmalvolti 9585 function setType(&$form, $maj) {
126     parent::setType($form, $maj);
127 mbideau 9813
128 gmalvolti 9585 // Récupération du mode de l'action
129     $crud = $this->get_action_crud($maj);
130    
131 mbideau 9813 // MODE CREER
132     if ($maj == 0 || $crud == 'create') {
133 gmalvolti 9585 $form->setType("state", "select");
134 gmalvolti 9721 $form->setType("stream", "select");
135 mbideau 9813 $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 gmalvolti 9721 $form->setType("json_payload", "jsonprettyprint");
142 gmalvolti 9585 }
143 mbideau 9813 // MODE CONSULTER
144     if ($maj == 3 || $crud == 'read') {
145 gmalvolti 9589 $form->setType('dossier', 'link');
146 gmalvolti 9604 $form->setType('json_payload', 'jsonprettyprint');
147 gmalvolti 9589 }
148    
149 gmalvolti 9585 }
150    
151     /**
152     *
153     */
154     function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) {
155     if($maj < 2) {
156    
157 mbideau 9799 $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 gmalvolti 9585
165     $form->setSelect("state", $contenu);
166 gmalvolti 9721
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 gmalvolti 9585 }
175 gmalvolti 9589
176     if ($maj == 3) {
177 gmalvolti 9721 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 mbroquet 9776
183 gmalvolti 9721 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 gmalvolti 9594 }
196 gmalvolti 9589 }
197 gmalvolti 9585 }
198    
199 gmalvolti 9604 /**
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 gmalvolti 9721 if ($this->getVal('stream') == "output") {
208     $form->setVal('json_payload', $this->view_form_json(true));
209 gmalvolti 9728 } else {
210 mbideau 9798 $form->setVal('json_payload', htmlentities($this->getVal('json_payload')));
211 gmalvolti 9721 }
212 gmalvolti 9604 }
213    
214 gmalvolti 9746 function setLib(&$form, $maj) {
215     parent::setLib($form, $maj);
216 mbideau 9813
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 gmalvolti 9746 }
225    
226 softime 9482 public function verifier($val = array(), &$dnu1 = null, $dnu2 = null) {
227 gmalvolti 9765 $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 mbideau 9813 // 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 gmalvolti 9765 }
276    
277     // une tâche entrante doit avoir une payload avec les clés requises
278 mbideau 9813 if ($this->correct && (isset($this->valF['stream']) === false ||
279     $this->valF['stream'] == 'input')) {
280 gmalvolti 9765
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 mbideau 9798 'external_uids/dossier'
287 gmalvolti 9765 );
288    
289     // tâche de type création de DI/DA
290 mbroquet 9776 if (isset($this->valF['type']) !== false && $this->valF['type'] == 'create_DI_for_consultation') {
291 gmalvolti 9765
292     $paths = array_merge($paths, array(
293 mbideau 9798 'dossier/dossier',
294 mbideau 9773 'dossier/dossier_autorisation_type_detaille_code',
295 gmalvolti 9765 '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 softime 9482 }
352    
353 softime 9395 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 mbideau 9799 self::STATUS_DONE,
363 softime 9395 $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 softime 9293 /**
374 gmalvolti 9765 * 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 mbideau 9798
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 mbideau 9813 /**
399     * Puisque le dossier n'a potentiellement pas encore été créé
400     * alors il faut ne faut chercher à récupérer le numéro de dossier openADS
401     * à partir de l'external_uids (en passant par la table de liens)
402 mbideau 9798 // sinon si la tâche possède une clé external_uids/dossier
403     elseif(isset($json_payload['external_uids']['dossier']) &&
404     ! empty($json_payload['external_uids']['dossier'])) {
405    
406     // instancie l'objet lien_id_interne_uid_externe
407     $inst_lien = $this->f->get_inst__om_dbform(array(
408     "obj" => "lien_id_interne_uid_externe",
409     "idx" => ']',
410     ));
411     if(! $dossier = $inst_lien->get_id_dossier_from_external_uid(
412     $json_payload['external_uids']['dossier'])){
413     $error_msg = sprintf(
414     __("Aucune correspondance de dossier pour l'external_uid.dossier '%s'."),
415     $json_payload['external_uids']['dossier']);
416     $this->addToLog(__METHOD__."() : erreur : $error_msg", DEBUG_MODE);
417     $this->addToMessage($error_msg);
418     $this->correct = false;
419     return false;
420     }
421     $this->valF["dossier"] = $dossier;
422 mbideau 9813 }*/
423 gmalvolti 9765 }
424     }
425    
426     /**
427 softime 9293 * TREATMENT - add_task
428     * Ajoute un enregistrement.
429     *
430     * @param array $params Tableau des paramètres
431     * @return boolean
432     */
433     public function add_task($params = array()) {
434     $this->begin_treatment(__METHOD__);
435     $timestamp_log = json_encode(array(
436     'creation_date' => date('Y-m-d H:i:s'),
437     ));
438 gmalvolti 9751
439     // Si la tâche est de type ajout_piece et de stream input alors on ajoute le fichier
440     // et on ajoute l'uid dans le champ json_payload avant l'ajout de la tâche
441 mbroquet 9776 if (isset($params['val']['type'])
442 mbideau 9798 && $params['val']['type'] == "add_piece"
443 gmalvolti 9751 && isset($params['val']['stream'])
444     && $params['val']['stream'] == "input" ) {
445     //
446     $json_payload = json_decode($params['val']['json_payload'], true);
447     $document_numerise = $json_payload['document_numerise'];
448     $file_content = base64_decode($document_numerise["file_content"]);
449     if ($file_content === false){
450     $this->addToMessage(__("Le contenu du fichier lié à la tâche n'a pas pu etre recupere."));
451     return $this->end_treatment(__METHOD__, false);
452     }
453     $metadata = array(
454     "filename" => $document_numerise['nom_fichier'],
455     "size" => strlen($file_content),
456     "mimetype" => $document_numerise['file_content_type'],
457     "date_creation" => $document_numerise['date_creation'],
458     );
459     $uid_fichier = $this->f->storage->create($file_content, $metadata, "from_content");
460     if ($uid_fichier === OP_FAILURE) {
461     $this->addToMessage(__("Erreur lors de la creation du fichier lié à la tâche."));
462     return $this->end_treatment(__METHOD__, false);
463     }
464     $json_payload["document_numerise"]["uid"] = $uid_fichier;
465 mbideau 9798 // Le fichier a été ajouté nous n'avons plus besoin du champ file_content dans la payload
466     unset($json_payload["document_numerise"]["file_content"]);
467 gmalvolti 9751 $params['val']['json_payload'] = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
468     }
469    
470 softime 9293 // Mise à jour du DI
471     $valF = array(
472     'task' => '',
473     'type' => $params['val']['type'],
474     'timestamp_log' => $timestamp_log,
475 mbideau 9799 'state' => isset($params['val']['state']) === true ? $params['val']['state'] : self::STATUS_NEW,
476 gmalvolti 9765 'object_id' => isset($params['val']['object_id']) ? $params['val']['object_id'] : '',
477     'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '',
478 gmalvolti 9721 'stream' => isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output',
479     'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}',
480 softime 9293 );
481 gmalvolti 9765
482     // tâche sortante
483     if($valF["stream"] == "output"){
484    
485     // TODO expliquer ce code
486 gmalvolti 9746 $task_exists = $this->task_exists($valF['type'], $valF['object_id']);
487     if ($valF['type'] === 'modification_DI' && $task_exists === false) {
488     $task_exists = $this->task_exists('creation_DI', $valF['object_id']);
489 softime 9414 }
490 gmalvolti 9746 if ($task_exists !== false) {
491     $inst_task = $this->f->get_inst__om_dbform(array(
492     "obj" => "task",
493     "idx" => $task_exists,
494     ));
495     $update_state = $inst_task->getVal('state');
496     if (isset($params['update_val']['state']) === true) {
497     $update_state = $params['update_val']['state'];
498     }
499     $update_params = array(
500     'val' => array(
501     'state' => $update_state,
502     ),
503     );
504     return $inst_task->update_task($update_params);
505     }
506 softime 9395 }
507 gmalvolti 9765
508 softime 9293 $add = $this->ajouter($valF);
509 mbideau 9785 $this->addToLog(__METHOD__."(): retour de l'ajout de tâche: ".var_export($add, true), VERBOSE_MODE);
510 softime 9293 if ($add === false) {
511 gmalvolti 9765 $this->addToLog(__METHOD__."(): ".$this->msg, DEBUG_MODE);
512 softime 9293 return $this->end_treatment(__METHOD__, false);
513     }
514     return $this->end_treatment(__METHOD__, true);
515     }
516    
517     /**
518     * TREATMENT - update_task
519     * Met à jour l'enregistrement instancié.
520     *
521     * @param array $params Tableau des paramètres
522     * @return boolean
523     */
524     public function update_task($params = array()) {
525     $this->begin_treatment(__METHOD__);
526     $timestamp_log = $this->get_timestamp_log();
527     if ($timestamp_log === false) {
528 mbideau 9813 $this->addToLog(__METHOD__."(): erreur timestamp log", DEBUG_MODE);
529 softime 9293 return $this->end_treatment(__METHOD__, false);
530     }
531     array_push($timestamp_log, array(
532     'modification_date' => date('Y-m-d H:i:s'),
533     'state' => $params['val']['state'],
534     'prev_state' => $this->getVal('state'),
535     ));
536     $timestamp_log = json_encode($timestamp_log);
537     $valF = array(
538     'task' => $this->getVal($this->clePrimaire),
539     'type' => $this->getVal('type'),
540     'timestamp_log' => $timestamp_log,
541     'state' => $params['val']['state'],
542 softime 9389 'object_id' => $this->getVal('object_id'),
543 gmalvolti 9721 'stream' => $this->getVal('stream'),
544 gmalvolti 9593 'dossier' => $this->getVal('dossier'),
545 gmalvolti 9667 'json_payload' => $this->getVal('json_payload'),
546 softime 9293 );
547     $update = $this->modifier($valF);
548     if ($update === false) {
549     $this->addToLog($this->msg, DEBUG_MODE);
550     return $this->end_treatment(__METHOD__, false);
551     }
552     return $this->end_treatment(__METHOD__, true);
553     }
554    
555     /**
556     * Récupère le journal d'horodatage dans le champ timestamp_log de
557     * l'enregistrement instancié.
558 mbroquet 9776 *
559 softime 9293 * @param array $params Tableau des paramètres
560     * @return array sinon false en cas d'erreur
561     */
562     protected function get_timestamp_log($params = array()) {
563     $val = $this->getVal('timestamp_log');
564     if ($val === '') {
565     $val = json_encode(array());
566     }
567     if($this->isJson($val) === false) {
568     return false;
569     }
570     return json_decode($val, true);
571     }
572    
573     /**
574 softime 9330 * VIEW - view_json_data
575 softime 9293 * Affiche l'enregistrement dans le format JSON.
576     *
577     * @return void
578     */
579 softime 9330 public function view_json_data() {
580 softime 9293 $this->checkAccessibility();
581 softime 9330 $this->f->disableLog();
582 softime 9298 if ($this->getParameter('idx') !== ']'
583     && $this->getParameter('idx') !== '0') {
584     //
585     $this->view_form_json();
586     }
587     else {
588     $this->view_tab_json();
589     }
590     }
591    
592     protected function view_tab_json() {
593 softime 9304 $where = '';
594     if ($this->f->get_submitted_get_value('state') !== null
595     && $this->f->get_submitted_get_value('state') !== '') {
596     //
597     $where = sprintf(' WHERE state = \'%s\' ', $this->f->get_submitted_get_value('state'));
598     }
599 softime 9298 $query = sprintf('
600     SELECT
601     *
602     FROM %1$stask
603 softime 9304 %2$s
604 softime 9481 ORDER BY task ASC
605 softime 9298 ',
606 softime 9304 DB_PREFIXE,
607     $where
608 softime 9298 );
609     $res = $this->f->get_all_results_from_db_query($query, true);
610     if ($res['code'] === 'KO') {
611     return false;
612     }
613     $list_tasks = array();
614     foreach ($res['result'] as $task) {
615 softime 9404 $task['timestamp_log'] = json_decode($task['timestamp_log'], true);
616 softime 9490 $task['dossier'] = $task['object_id'];
617     if ($this->get_lien_objet_by_type($task['type']) === 'document_numerise') {
618     $val_dn = $this->get_document_numerise_data($task['object_id']);
619     $task['dossier'] = $val_dn['dossier'];
620     }
621 softime 9298 $list_tasks[$task['task']] = $task;
622     }
623     printf(json_encode($list_tasks));
624     }
625    
626 softime 9395 protected function get_dossier_data(string $dossier) {
627     $val_di = array();
628     $inst_di = $this->f->get_inst__om_dbform(array(
629     "obj" => "dossier",
630     "idx" => $dossier,
631     ));
632 softime 9404 $val_di = $inst_di->get_json_data();
633 softime 9396 if ($val_di['dossier_instruction_type_code'] === 'T') {
634     $val_di['date_decision_transfert'] = $val_di['date_decision'];
635     }
636 softime 9395 unset($val_di['initial_dt']);
637     unset($val_di['log_instructions']);
638     return $val_di;
639     }
640    
641     protected function get_dossier_autorisation_data(string $da) {
642     $val_da = array();
643     $inst_da = $this->f->get_inst__om_dbform(array(
644     "obj" => "dossier_autorisation",
645     "idx" => $da,
646     ));
647 softime 9404 $val_da = $inst_da->get_json_data();
648 softime 9395 return $val_da;
649     }
650    
651     protected function get_donnees_techniques_data(string $fk_idx, string $fk_field) {
652     $val_dt = array();
653     $inst_dt = $this->f->get_inst__by_other_idx(array(
654     "obj" => "donnees_techniques",
655     "fk_field" => $fk_field,
656     "fk_idx" => $fk_idx,
657     ));
658     $val_dt = array(
659     'donnees_techniques' => $inst_dt->getVal($inst_dt->clePrimaire),
660     'cerfa' => $inst_dt->getVal('cerfa'),
661     );
662     $val_dt = array_merge($val_dt, $inst_dt->get_donnees_techniques_applicables());
663 softime 9396 if (isset($val_dt['am_exist_date']) === true) {
664     $val_dt['am_exist_date_num'] = '';
665     if (is_numeric($val_dt['am_exist_date']) === true) {
666     $val_dt['am_exist_date_num'] = $val_dt['am_exist_date'];
667     }
668     }
669 softime 9403 // Correspond à la nomenclature de Plat'AU STATUT_INFO
670     $val_dt['tax_statut_info'] = 'Déclaré';
671 softime 9407 //
672     if ($inst_dt->is_tab_surf_ssdest_enabled() === true) {
673     $fields_tab_surf_dest = $inst_dt->get_fields_tab_surf_dest();
674     foreach ($fields_tab_surf_dest as $field) {
675     if (isset($val_dt[$field]) === true) {
676     unset($val_dt[$field]);
677     }
678     }
679     } else {
680     $fields_tab_surf_ssdest = $inst_dt->get_fields_tab_surf_ssdest();
681     foreach ($fields_tab_surf_ssdest as $field) {
682     if (isset($val_dt[$field]) === true) {
683     unset($val_dt[$field]);
684     }
685     }
686     }
687 softime 9409 // Correspond à la nouvelle ligne CERFA v7 dans le DENSI imposition 1.2.3
688 softime 9408 if (isset($val_dt['tax_su_non_habit_surf2']) === true
689 softime 9412 && isset($val_dt['tax_su_non_habit_surf3']) === true
690     && (($val_dt['tax_su_non_habit_surf2'] !== null
691     && $val_dt['tax_su_non_habit_surf2'] !== '')
692     || ($val_dt['tax_su_non_habit_surf3'] !== null
693     && $val_dt['tax_su_non_habit_surf3'] !== ''))) {
694 softime 9408 //
695     $val_dt['tax_su_non_habit_surf8'] = intval($val_dt['tax_su_non_habit_surf2']) + intval($val_dt['tax_su_non_habit_surf3']);
696     }
697     if (isset($val_dt['tax_su_non_habit_surf_stat2']) === true
698 softime 9412 && isset($val_dt['tax_su_non_habit_surf_stat3']) === true
699     && (($val_dt['tax_su_non_habit_surf_stat2'] !== null
700     && $val_dt['tax_su_non_habit_surf_stat2'] !== '')
701     || ($val_dt['tax_su_non_habit_surf_stat3'] !== null
702     && $val_dt['tax_su_non_habit_surf_stat3'] !== ''))) {
703 softime 9408 //
704     $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']);
705     }
706 softime 9409 // Cas particulier d'un projet réduit à l'extension d'une habitation existante
707     $particular_case = false;
708     $fields_tab_crea_loc_hab = $inst_dt->get_fields_tab_crea_loc_hab();
709     foreach ($fields_tab_crea_loc_hab as $field) {
710 softime 9438 if (isset($val_dt[$field]) === false
711     || (isset($val_dt[$field]) === true
712     && ($val_dt[$field] === null
713     || $val_dt[$field] === ''))) {
714 softime 9409 //
715     $particular_case = true;
716     }
717     }
718     if ($particular_case === true) {
719     if (isset($val_dt['tax_ext_pret']) === true
720     && $val_dt['tax_ext_pret'] === 'f') {
721     //
722     $val_dt['tax_su_princ_surf1'] = $val_dt['tax_surf_tot_cstr'];
723     $val_dt['tax_su_princ_surf_stat1'] = $val_dt['tax_surf_loc_stat'];
724     }
725     if (isset($val_dt['tax_ext_pret']) === true
726     && $val_dt['tax_ext_pret'] === 't') {
727     //
728     if (isset($val_dt['tax_ext_desc']) === true) {
729     if (preg_match('/[pP].*[lL].*[aA].*[iI]/', $val_dt['tax_ext_desc']) === 1
730     || preg_match('/[lL].*[lL].*[tT].*[sS]/', $val_dt['tax_ext_desc']) === 1) {
731     //
732     $val_dt['tax_su_princ_surf2'] = $val_dt['tax_surf_tot_cstr'];
733     $val_dt['tax_su_princ_surf_stat2'] = $val_dt['tax_surf_loc_stat'];
734     }
735     // if (preg_match('/[pP].*[tT].*[zZ]/', $val_dt['tax_ext_desc']) === 1) {
736     // $val_dt['tax_su_princ_surf4'] = $val_dt['tax_surf_tot_cstr'];
737     // $val_dt['tax_su_princ_surf_stat4'] = $val_dt['tax_surf_loc_stat'];
738     // }
739     // if (preg_match('/[pP].*[lL].*[uU].*[sS]/', $val_dt['tax_ext_desc']) === 1
740     // || preg_match('/[lL].*[eE].*[sS]/', $val_dt['tax_ext_desc']) === 1
741     // || preg_match('/[pP].*[sS].*[lL].*[aA]/', $val_dt['tax_ext_desc']) === 1
742     // || preg_match('/[pP].*[lL].*[sS]/', $val_dt['tax_ext_desc']) === 1
743     // || preg_match('/[lL].*[lL].*[sS]/', $val_dt['tax_ext_desc']) === 1) {
744     // //
745     // $val_dt['tax_su_princ_surf3'] = $val_dt['tax_surf_tot_cstr'];
746     // $val_dt['tax_su_princ_surf_stat3'] = $val_dt['tax_surf_loc_stat'];
747     // }
748     }
749     }
750     }
751     // Cas particulier de la surface taxable démolie
752     if (isset($val_dt['tax_surf_tot_demo']) === true
753     && isset($val_dt['tax_surf_tax_demo']) === true
754     && ($val_dt['tax_surf_tot_demo'] === null
755     || $val_dt['tax_surf_tot_demo'] === '')) {
756     //
757     $val_dt['tax_surf_tot_demo'] = $val_dt['tax_surf_tax_demo'];
758     }
759 softime 9395 return $val_dt;
760     }
761    
762     protected function get_external_uid($fk_idx, string $fk_idx_2) {
763 softime 9404 $inst_external_uid = $this->f->get_inst__by_other_idx(array(
764 softime 9395 "obj" => "lien_id_interne_uid_externe",
765     "fk_field" => 'object_id',
766     "fk_idx" => $fk_idx,
767     "fk_field_2" => 'object',
768     "fk_idx_2" => $fk_idx_2,
769     ));
770 softime 9404 return $inst_external_uid->getVal('external_uid');
771 softime 9395 }
772    
773     protected function get_demandeurs_data(string $dossier) {
774     $val_demandeur = array();
775     $inst_di = $this->f->get_inst__om_dbform(array(
776     "obj" => "dossier",
777     "idx" => $dossier,
778     ));
779     $list_demandeurs = $inst_di->get_demandeurs();
780     foreach ($list_demandeurs as $demandeur) {
781     $inst_demandeur = $this->f->get_inst__om_dbform(array(
782     "obj" => "demandeur",
783     "idx" => $demandeur['demandeur'],
784 softime 9334 ));
785 softime 9404 $val_demandeur[$demandeur['demandeur']] = $inst_demandeur->get_json_data();
786 softime 9395 $val_demandeur[$demandeur['demandeur']]['petitionnaire_principal'] = $demandeur['petitionnaire_principal'];
787 softime 9334 }
788 softime 9395 return $val_demandeur;
789     }
790    
791     protected function get_architecte_data($architecte = null) {
792 softime 9408 $val_architecte = null;
793 softime 9395 if ($architecte !== null
794     && $architecte !== '') {
795 softime 9334 //
796 softime 9395 $inst_architecte = $this->f->get_inst__om_dbform(array(
797     "obj" => "architecte",
798     "idx" => $architecte,
799 softime 9334 ));
800 softime 9404 $val_architecte = $inst_architecte->get_json_data();
801 softime 9334 }
802 softime 9395 return $val_architecte;
803     }
804 softime 9334
805 softime 9838 protected function get_instruction_data(string $dossier, $type = 'decision', $extra_params = array()) {
806 softime 9414 $val_instruction = null;
807 softime 9416 $instruction_with_doc = null;
808 softime 9395 $inst_di = $this->f->get_inst__om_dbform(array(
809     "obj" => "dossier",
810     "idx" => $dossier,
811     ));
812 softime 9457 $idx = null;
813     if ($type === 'decision') {
814     $idx = $inst_di->get_last_instruction_decision();
815     }
816     if ($type === 'incompletude') {
817     $idx = $inst_di->get_last_instruction_incompletude();
818     }
819 softime 9838 // XXX Permet de récupérer l'instruction par son identifiant
820     if ($type === 'with-id') {
821     $idx = $extra_params['with-id'];
822     }
823 softime 9395 $inst_instruction = $this->f->get_inst__om_dbform(array(
824     "obj" => "instruction",
825 softime 9457 "idx" => $idx,
826 softime 9395 ));
827     if (count($inst_instruction->val) > 0) {
828 softime 9416 $val_instruction = array();
829     $instruction_data = $inst_instruction->get_json_data();
830     $val_instruction = $this->sort_instruction_data($instruction_data, $val_instruction);
831     if ($instruction_data['om_fichier_instruction'] !== null
832     && $instruction_data['om_fichier_instruction'] !== '') {
833     //
834     $instruction_with_doc = $inst_instruction->getVal($inst_instruction->clePrimaire);
835     }
836 softime 9414 $inst_ev = $this->f->get_inst__om_dbform(array(
837     "obj" => "evenement",
838     "idx" => $inst_instruction->getVal('evenement'),
839     ));
840     if ($inst_ev->getVal('retour') === 't') {
841     $instructions_related = $inst_instruction->get_related_instructions();
842     foreach ($instructions_related as $instruction) {
843 softime 9416 if ($instruction !== null && $instruction !== '') {
844     $inst_related_instruction = $this->f->get_inst__om_dbform(array(
845     "obj" => "instruction",
846     "idx" => $instruction,
847     ));
848     $instruction_data = $inst_related_instruction->get_json_data();
849     $val_instruction = $this->sort_instruction_data($instruction_data, $val_instruction);
850     if ($instruction_data['om_fichier_instruction'] !== null
851     && $instruction_data['om_fichier_instruction'] !== '') {
852     //
853     $instruction_with_doc = $inst_related_instruction->getVal($inst_related_instruction->clePrimaire);
854     }
855     }
856 softime 9414 }
857     }
858 softime 9416 if ($instruction_with_doc !== null) {
859     //
860 softime 9480 $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);
861 softime 9416 }
862 softime 9384 }
863 softime 9395 return $val_instruction;
864     }
865 softime 9334
866 softime 9416 protected function sort_instruction_data(array $values, array $res) {
867     $fields = array(
868 softime 9838 "date_evenement",
869 softime 9416 "date_envoi_signature",
870     "date_retour_signature",
871     "date_envoi_rar",
872     "date_retour_rar",
873     "date_envoi_controle_legalite",
874     "date_retour_controle_legalite",
875     "signataire_arrete",
876     "om_fichier_instruction",
877     "tacite",
878 softime 9623 "lettretype",
879 softime 9416 );
880     foreach ($values as $key => $value) {
881     if (in_array($key, $fields) === true) {
882     if (array_key_exists($key, $res) === false
883     && $value !== null
884     && $value !== '') {
885     //
886     $res[$key] = $value;
887     } elseif ($key === 'tacite'
888     && $value === 't') {
889     //
890     $res[$key] = $value;
891     }
892     }
893     }
894     return $res;
895     }
896    
897 softime 9395 protected function get_document_numerise_data(string $dn) {
898     $val_dn = array();
899     $inst_dn = $this->f->get_inst__om_dbform(array(
900     "obj" => "document_numerise",
901     "idx" => $dn,
902     ));
903 softime 9404 $val_dn = $inst_dn->get_json_data();
904 softime 9480 $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'));
905 softime 9403 // Correspond à la nomenclature Plat'AU NATURE_PIECE
906 softime 9457 $val_dn['nature'] = $val_dn['document_numerise_nature_libelle'];
907 softime 9395 return $val_dn;
908     }
909    
910 softime 9396 protected function get_parcelles_data(string $object, string $idx) {
911     $val_dp = array();
912     $inst_di = $this->f->get_inst__om_dbform(array(
913     "obj" => $object,
914     "idx" => $idx,
915     ));
916     $list_parcelles = $inst_di->get_parcelles();
917     $no_ordre = 1;
918     foreach ($list_parcelles as $parcelle) {
919     $val_dp[$parcelle[$object.'_parcelle']] = array(
920     $object.'_parcelle' => $parcelle[$object.'_parcelle'],
921     'libelle' => $parcelle['libelle'],
922     'no_ordre' => $no_ordre,
923     );
924     $no_ordre++;
925     }
926     return $val_dp;
927     }
928    
929 gmalvolti 9604 protected function view_form_json($in_field = false) {
930 softime 9395 //
931 softime 9402 if ($this->f->get_submitted_post_value('valid') === null) {
932     // Liste des valeurs à afficher
933     $val = array();
934 softime 9395 //
935 softime 9402 $val_task = array_combine($this->champs, $this->val);
936 softime 9405 foreach ($val_task as $key => $value) {
937     $val_task[$key] = strip_tags($value);
938     }
939 softime 9404 $val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true);
940 softime 9402 $val['task'] = $val_task;
941     //
942     if ($this->getVal('type') === 'creation_DA') {
943     $val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id'));
944     $val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation');
945     $val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']);
946     $val_external_uid = array();
947     $val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation');
948 gmalvolti 9751 $val['external_uids'] = $val_external_uid;
949 softime 9402 }
950     //
951     if ($this->getVal('type') === 'creation_DI'
952 softime 9417 || $this->getVal('type') === 'modification_DI'
953     || $this->getVal('type') === 'depot_DI') {
954 softime 9402 //
955     $val['dossier'] = $this->get_dossier_data($this->getVal('object_id'));
956     $val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction');
957     $val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']);
958 softime 9403 $architecte = isset($val['donnees_techniques']['architecte']) === true ? $val['donnees_techniques']['architecte'] : null;
959     $val['architecte'] = $this->get_architecte_data($architecte);
960 softime 9402 $val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']);
961     $val_external_uid = array();
962     $val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation');
963     $val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier');
964 gmalvolti 9751 $val['external_uids'] = $val_external_uid;
965 softime 9402 }
966     //
967     if ($this->getVal('type') === 'qualification_DI') {
968     $val['dossier'] = $this->get_dossier_data($this->getVal('object_id'));
969     $val_external_uid = array();
970     $val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation');
971     $val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier');
972 gmalvolti 9751 $val['external_uids'] = $val_external_uid;
973 softime 9402 }
974     //
975     if ($this->getVal('type') === 'ajout_piece') {
976     $val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id'));
977     $val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']);
978     $val_external_uid = array();
979     $val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation');
980     $val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier');
981     $val_external_uid['document_numerise'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'document_numerise');
982 gmalvolti 9751 $val['external_uids'] = $val_external_uid;
983 softime 9402 }
984 softime 9414 //
985     if ($this->getVal('type') === 'decision_DI') {
986     $val['dossier'] = $this->get_dossier_data($this->getVal('object_id'));
987     $val['instruction'] = $this->get_instruction_data($val['dossier']['dossier']);
988     $val_external_uid = array();
989     $val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation');
990     $val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier');
991 gmalvolti 9751 $val['external_uids'] = $val_external_uid;
992 softime 9414 }
993 softime 9457 //
994     if ($this->getVal('type') === 'incompletude_DI') {
995     $val['dossier'] = $this->get_dossier_data($this->getVal('object_id'));
996     $val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'incompletude');
997     $val_external_uid = array();
998     $val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation');
999     $val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier');
1000 gmalvolti 9751 $val['external_uids'] = $val_external_uid;
1001 softime 9457 }
1002 softime 9479 //
1003 softime 9458 if ($this->getVal('type') === 'completude_DI') {
1004     $val['dossier'] = $this->get_dossier_data($this->getVal('object_id'));
1005     $val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'completude');
1006     $val_external_uid = array();
1007     $val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation');
1008     $val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier');
1009 gmalvolti 9751 $val['external_uids'] = $val_external_uid;
1010 softime 9458 }
1011 softime 9838 //
1012     if ($this->getVal('type') === 'pec_metier_consultation') {
1013     $val['dossier'] = $this->get_dossier_data($this->getVal('dossier'));
1014     $val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id')));
1015     $val_external_uid = array();
1016     $val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation');
1017     $val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier');
1018     $val_external_uid['consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'consultation');
1019     $val['external_uids'] = $val_external_uid;
1020     }
1021 softime 9402
1022 gmalvolti 9604 if ($in_field === true) {
1023 gmalvolti 9746 return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
1024 gmalvolti 9604 } else {
1025     // Liste des valeurs affichée en JSON
1026     printf(json_encode($val, JSON_UNESCAPED_SLASHES));
1027     }
1028 softime 9395 }
1029 softime 9293 }
1030 softime 9385
1031 gmalvolti 9765 function post_update_task() {
1032 gmalvolti 9721 // Mise à jour des valeurs
1033     //
1034     $params = array(
1035     'val' => array(
1036     'state' => $this->f->get_submitted_post_value('state')
1037     ),
1038     );
1039     $update = $this->update_task($params);
1040     $message_class = "valid";
1041     $message = $this->msg;
1042     if ($update === false) {
1043     $this->addToLog($this->msg, DEBUG_MODE);
1044     $message_class = "error";
1045     $message = sprintf(
1046     '%s %s',
1047     __('Impossible de mettre à jour la tâche.'),
1048     __('Veuillez contacter votre administrateur.')
1049     );
1050     }
1051     $this->f->displayMessage($message_class, $message);
1052     //
1053 gmalvolti 9840 if ($this->f->get_submitted_post_value('external_uid') !== null
1054     && $this->f->get_submitted_post_value('external_uid') != "") {
1055     $inst_lien = $this->f->get_inst__om_dbform(array(
1056     "obj" => "lien_id_interne_uid_externe",
1057     "idx" => ']',
1058     ));
1059     $valF = array(
1060     'lien_id_interne_uid_externe' => '',
1061     'object' => $this->get_lien_objet_by_type($this->getVal('type')),
1062     'object_id' => $this->getVal('object_id'),
1063     'external_uid' => $this->f->get_submitted_post_value('external_uid'),
1064 gmalvolti 9721 );
1065 gmalvolti 9840 $add = $inst_lien->ajouter($valF);
1066     $message_class = "valid";
1067     $message = $inst_lien->msg;
1068     if ($add === false) {
1069     $this->addToLog($inst_lien->msg, DEBUG_MODE);
1070     $message_class = "error";
1071     $message = sprintf(
1072     '%s %s',
1073     __("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."),
1074     __('Veuillez contacter votre administrateur.')
1075     );
1076     }
1077     $this->f->displayMessage($message_class, $message);
1078 gmalvolti 9721 }
1079     }
1080    
1081 gmalvolti 9765 function post_add_task() {
1082 mbroquet 9776 // TODO Tester de remplacer la ligne de json_payload par un $_POST
1083 gmalvolti 9765 $result = $this->add_task(array(
1084     'val' => array(
1085     'stream' => 'input',
1086     'json_payload' => html_entity_decode($this->f->get_submitted_post_value('json_payload')),
1087     'type' => $this->f->get_submitted_post_value('type'),
1088     )
1089     ));
1090 gmalvolti 9751 $message = $this->msg;
1091     $message_class = "valid";
1092     if ($result === false){
1093     $this->addToLog($this->msg, DEBUG_MODE);
1094     $message_class = "error";
1095     $message = sprintf(
1096     '%s %s',
1097     __('Impossible d\'ajouter la tâche.'),
1098     __('Veuillez contacter votre administrateur.')
1099 gmalvolti 9746 );
1100     }
1101 gmalvolti 9751 $this->f->displayMessage($message_class, $message);
1102 gmalvolti 9721 }
1103    
1104 gmalvolti 9765 function get_lien_objet_by_type($type) {
1105 softime 9385 //
1106     $objet = '';
1107     if ($type === 'creation_DA') {
1108     $objet = 'dossier_autorisation';
1109     }
1110 softime 9414 if ($type === 'creation_DI'
1111 mbroquet 9776 || $type === 'create_DI_for_consultation'
1112 softime 9417 || $type === 'depot_DI'
1113 softime 9414 || $type === 'modification_DI'
1114     || $type === 'qualification_DI'
1115 softime 9457 || $type === 'decision_DI'
1116 softime 9458 || $type === 'incompletude_DI'
1117 softime 9838 || $type === 'completude_DI'
1118     || $type === 'pec_metier_consultation') {
1119 softime 9414 //
1120 softime 9385 $objet = 'dossier';
1121     }
1122     if ($type === 'ajout_piece') {
1123     $objet = 'document_numerise';
1124     }
1125 mbideau 9798 // La tâche entrante se nomme add_piece
1126     if ($type === 'add_piece') {
1127     $objet = 'piece';
1128     }
1129 softime 9385 return $objet;
1130     }
1131 gmalvolti 9604
1132     function setLayout(&$form, $maj) {
1133 mbideau 9813
1134     // Récupération du mode de l'action
1135     $crud = $this->get_action_crud($maj);
1136    
1137     // MODE different de CREER
1138     if ($maj != 0 || $crud != 'create') {
1139     $form->setBloc('json_payload', 'D', '', 'col_6');
1140     $form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed");
1141     $form->setBloc('json_payload', 'F');
1142     }
1143 gmalvolti 9604 $form->setBloc('timestamp_log', 'DF', '', 'col_9');
1144     }
1145    
1146 softime 9293 }

Properties

Name Value
svn:executable *

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26