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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9589 - (hide annotations)
Tue Oct 13 13:35:19 2020 UTC (4 years, 3 months ago) by gmalvolti
Original Path: branches/4.14.0-develop_demat/obj/task.class.php
File size: 31183 byte(s)
* Ajout du lien dirigeant vers le dossier d'instruction lors de la consultation de la task
* Le champ timestamp_log est maintenant en dernier

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

Properties

Name Value
svn:executable *

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26