21 |
); |
); |
22 |
} |
} |
23 |
|
|
24 |
|
public function setvalF($val = array()) { |
25 |
|
parent::setvalF($val); |
26 |
|
// |
27 |
|
if (array_key_exists('timestamp_log', $val) === true) { |
28 |
|
$this->valF['timestamp_log'] = str_replace("'", '"', $val['timestamp_log']); |
29 |
|
} |
30 |
|
} |
31 |
|
|
32 |
|
/** |
33 |
|
* |
34 |
|
* @return array |
35 |
|
*/ |
36 |
|
function get_var_sql_forminc__champs() { |
37 |
|
return array( |
38 |
|
"task", |
39 |
|
"type", |
40 |
|
"state", |
41 |
|
"object_id", |
42 |
|
"dossier", |
43 |
|
"json_payload", |
44 |
|
"timestamp_log", |
45 |
|
); |
46 |
|
} |
47 |
|
|
48 |
|
function setType(&$form, $maj) { |
49 |
|
parent::setType($form, $maj); |
50 |
|
// Récupération du mode de l'action |
51 |
|
$crud = $this->get_action_crud($maj); |
52 |
|
|
53 |
|
if ($maj < 2) { |
54 |
|
$form->setType("state", "select"); |
55 |
|
$form->setType("json_payload", "textarea"); |
56 |
|
} |
57 |
|
if ($maj == 3){ |
58 |
|
$form->setType('dossier', 'link'); |
59 |
|
$form->setType('json_payload', 'jsonprettyprint'); |
60 |
|
} |
61 |
|
|
62 |
|
} |
63 |
|
|
64 |
|
/** |
65 |
|
* |
66 |
|
*/ |
67 |
|
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
68 |
|
if($maj < 2) { |
69 |
|
$contenu=array(); |
70 |
|
|
71 |
|
$contenu[0][0]="draft"; |
72 |
|
$contenu[1][0]=_('draft'); |
73 |
|
$contenu[0][1]="new"; |
74 |
|
$contenu[1][1]=_('new'); |
75 |
|
$contenu[0][2]="pending"; |
76 |
|
$contenu[1][2]=_('pending'); |
77 |
|
$contenu[0][3]="done"; |
78 |
|
$contenu[1][3]=_('done'); |
79 |
|
$contenu[0][4]="archived"; |
80 |
|
$contenu[1][4]=_('archived'); |
81 |
|
$contenu[0][5]="error"; |
82 |
|
$contenu[1][5]=_('error'); |
83 |
|
$contenu[0][6]="debug"; |
84 |
|
$contenu[1][6]=_('debug'); |
85 |
|
|
86 |
|
$form->setSelect("state", $contenu); |
87 |
|
} |
88 |
|
|
89 |
|
if ($maj == 3) { |
90 |
|
$inst_dossier = $this->f->get_inst__om_dbform(array( |
91 |
|
"obj" => "dossier", |
92 |
|
"idx" => $form->val['dossier'], |
93 |
|
)); |
94 |
|
|
95 |
|
if($form->val['type'] == "creation_DA"){ |
96 |
|
$obj_link = 'dossier_autorisation'; |
97 |
|
} else { |
98 |
|
$obj_link = 'dossier_instruction'; |
99 |
|
} |
100 |
|
|
101 |
|
$params = array(); |
102 |
|
$params['obj'] = $obj_link; |
103 |
|
$params['libelle'] = $inst_dossier->getVal('dossier'); |
104 |
|
$params['title'] = "Consulter le dossier"; |
105 |
|
$params['idx'] = $form->val['dossier']; |
106 |
|
$form->setSelect("dossier", $params); |
107 |
|
} |
108 |
|
} |
109 |
|
|
110 |
|
/** |
111 |
|
* SETTER_FORM - setVal (setVal). |
112 |
|
* |
113 |
|
* @return void |
114 |
|
*/ |
115 |
|
function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) { |
116 |
|
// parent::setVal($form, $maj, $validation); |
117 |
|
// |
118 |
|
$form->setVal('json_payload', $this->view_form_json(true)); |
119 |
|
} |
120 |
|
|
121 |
|
public function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
122 |
|
parent::verifier($val, $dnu1, $dnu2); |
123 |
|
// |
124 |
|
if (array_key_exists('timestamp_log', $this->valF) === true |
125 |
|
&& is_array(json_decode($this->valF['timestamp_log'], true)) === false) { |
126 |
|
// |
127 |
|
$this->correct = false; |
128 |
|
$this->addToMessage(sprintf( |
129 |
|
__("Le champ %s doit être dans un format JSON valide."), |
130 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('timestamp_log')) |
131 |
|
)); |
132 |
|
} |
133 |
|
} |
134 |
|
|
135 |
protected function task_exists(string $type, string $object_id) { |
protected function task_exists(string $type, string $object_id) { |
136 |
$query = sprintf(' |
$query = sprintf(' |
137 |
SELECT task |
SELECT task |
171 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
172 |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : 'new', |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : 'new', |
173 |
'object_id' => $params['val']['object_id'], |
'object_id' => $params['val']['object_id'], |
174 |
|
'dossier' => $params['val']['dossier'], |
175 |
); |
); |
176 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
177 |
|
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
178 |
|
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
179 |
|
} |
180 |
if ($task_exists !== false) { |
if ($task_exists !== false) { |
181 |
$inst_task = $this->f->get_inst__om_dbform(array( |
$inst_task = $this->f->get_inst__om_dbform(array( |
182 |
"obj" => "task", |
"obj" => "task", |
227 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
228 |
'state' => $params['val']['state'], |
'state' => $params['val']['state'], |
229 |
'object_id' => $this->getVal('object_id'), |
'object_id' => $this->getVal('object_id'), |
230 |
|
'dossier' => $this->getVal('dossier'), |
231 |
); |
); |
232 |
$update = $this->modifier($valF); |
$update = $this->modifier($valF); |
233 |
if ($update === false) { |
if ($update === false) { |
286 |
* |
* |
287 |
FROM %1$stask |
FROM %1$stask |
288 |
%2$s |
%2$s |
289 |
|
ORDER BY task ASC |
290 |
', |
', |
291 |
DB_PREFIXE, |
DB_PREFIXE, |
292 |
$where |
$where |
298 |
$list_tasks = array(); |
$list_tasks = array(); |
299 |
foreach ($res['result'] as $task) { |
foreach ($res['result'] as $task) { |
300 |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
301 |
|
$task['dossier'] = $task['object_id']; |
302 |
|
if ($this->get_lien_objet_by_type($task['type']) === 'document_numerise') { |
303 |
|
$val_dn = $this->get_document_numerise_data($task['object_id']); |
304 |
|
$task['dossier'] = $val_dn['dossier']; |
305 |
|
} |
306 |
$list_tasks[$task['task']] = $task; |
$list_tasks[$task['task']] = $task; |
307 |
} |
} |
308 |
printf(json_encode($list_tasks)); |
printf(json_encode($list_tasks)); |
392 |
$particular_case = false; |
$particular_case = false; |
393 |
$fields_tab_crea_loc_hab = $inst_dt->get_fields_tab_crea_loc_hab(); |
$fields_tab_crea_loc_hab = $inst_dt->get_fields_tab_crea_loc_hab(); |
394 |
foreach ($fields_tab_crea_loc_hab as $field) { |
foreach ($fields_tab_crea_loc_hab as $field) { |
395 |
if (isset($field) === false |
if (isset($val_dt[$field]) === false |
396 |
|| (isset($field) === true |
|| (isset($val_dt[$field]) === true |
397 |
&& $field !== null |
&& ($val_dt[$field] === null |
398 |
&& $field !== '')) { |
|| $val_dt[$field] === ''))) { |
399 |
// |
// |
400 |
$particular_case = true; |
$particular_case = true; |
401 |
} |
} |
487 |
return $val_architecte; |
return $val_architecte; |
488 |
} |
} |
489 |
|
|
490 |
protected function get_instruction_data(string $dossier) { |
protected function get_instruction_data(string $dossier, $type = 'decision') { |
491 |
$val_instruction = null; |
$val_instruction = null; |
492 |
$instruction_with_doc = null; |
$instruction_with_doc = null; |
493 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
494 |
"obj" => "dossier", |
"obj" => "dossier", |
495 |
"idx" => $dossier, |
"idx" => $dossier, |
496 |
)); |
)); |
497 |
|
$idx = null; |
498 |
|
if ($type === 'decision') { |
499 |
|
$idx = $inst_di->get_last_instruction_decision(); |
500 |
|
} |
501 |
|
if ($type === 'incompletude') { |
502 |
|
$idx = $inst_di->get_last_instruction_incompletude(); |
503 |
|
} |
504 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
505 |
"obj" => "instruction", |
"obj" => "instruction", |
506 |
"idx" => $inst_di->get_last_instruction_decision(), |
"idx" => $idx, |
507 |
)); |
)); |
508 |
if (count($inst_instruction->val) > 0) { |
if (count($inst_instruction->val) > 0) { |
509 |
$val_instruction = array(); |
$val_instruction = array(); |
538 |
} |
} |
539 |
if ($instruction_with_doc !== null) { |
if ($instruction_with_doc !== null) { |
540 |
// |
// |
541 |
$val_instruction['path'] = sprintf('%s/%s&snippet=%s&obj=%s&champ=%s&id=%s', $_SERVER['HTTP_HOST'], 'openads/app/index.php?module=form', 'file', 'instruction', 'om_fichier_instruction', $instruction_with_doc); |
$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); |
542 |
} |
} |
543 |
} |
} |
544 |
return $val_instruction; |
return $val_instruction; |
555 |
"signataire_arrete", |
"signataire_arrete", |
556 |
"om_fichier_instruction", |
"om_fichier_instruction", |
557 |
"tacite", |
"tacite", |
558 |
|
"lettretype", |
559 |
); |
); |
560 |
foreach ($values as $key => $value) { |
foreach ($values as $key => $value) { |
561 |
if (in_array($key, $fields) === true) { |
if (in_array($key, $fields) === true) { |
581 |
"idx" => $dn, |
"idx" => $dn, |
582 |
)); |
)); |
583 |
$val_dn = $inst_dn->get_json_data(); |
$val_dn = $inst_dn->get_json_data(); |
584 |
$val_dn['path'] = sprintf('%s/%s&snippet=%s&obj=%s&champ=%s&id=%s', $_SERVER['HTTP_HOST'], 'openads/app/index.php?module=form', 'file', 'document_numerise', 'uid', $this->getVal('object_id')); |
$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')); |
585 |
// Correspond à la nomenclature Plat'AU NATURE_PIECE |
// Correspond à la nomenclature Plat'AU NATURE_PIECE |
586 |
$val_dn['nature'] = 'Initiale'; |
$val_dn['nature'] = $val_dn['document_numerise_nature_libelle']; |
587 |
return $val_dn; |
return $val_dn; |
588 |
} |
} |
589 |
|
|
606 |
return $val_dp; |
return $val_dp; |
607 |
} |
} |
608 |
|
|
609 |
protected function view_form_json() { |
protected function view_form_json($in_field = false) { |
610 |
// Mise à jour des valeurs |
// Mise à jour des valeurs |
611 |
if ($this->f->get_submitted_post_value('valid') === 'true' |
if ($this->f->get_submitted_post_value('valid') === 'true' |
612 |
&& $this->f->get_submitted_post_value('state') !== null) { |
&& $this->f->get_submitted_post_value('state') !== null) { |
722 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
723 |
$val['external_uid'] = $val_external_uid; |
$val['external_uid'] = $val_external_uid; |
724 |
} |
} |
725 |
|
// |
726 |
|
if ($this->getVal('type') === 'incompletude_DI') { |
727 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
728 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'incompletude'); |
729 |
|
$val_external_uid = array(); |
730 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
731 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
732 |
|
$val['external_uid'] = $val_external_uid; |
733 |
|
} |
734 |
|
// |
735 |
|
if ($this->getVal('type') === 'completude_DI') { |
736 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
737 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'completude'); |
738 |
|
$val_external_uid = array(); |
739 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
740 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
741 |
|
$val['external_uid'] = $val_external_uid; |
742 |
|
} |
743 |
|
|
744 |
// Liste des valeurs affichée en JSON |
if ($in_field === true) { |
745 |
printf(json_encode($val)); |
return json_encode($val, JSON_PRETTY_PRINT ,JSON_UNESCAPED_SLASHES); |
746 |
|
} else { |
747 |
|
// Liste des valeurs affichée en JSON |
748 |
|
printf(json_encode($val, JSON_UNESCAPED_SLASHES)); |
749 |
|
} |
750 |
} |
} |
751 |
} |
} |
752 |
|
|
760 |
|| $type === 'depot_DI' |
|| $type === 'depot_DI' |
761 |
|| $type === 'modification_DI' |
|| $type === 'modification_DI' |
762 |
|| $type === 'qualification_DI' |
|| $type === 'qualification_DI' |
763 |
|| $type === 'decision_DI') { |
|| $type === 'decision_DI' |
764 |
|
|| $type === 'incompletude_DI' |
765 |
|
|| $type === 'completude_DI') { |
766 |
// |
// |
767 |
$objet = 'dossier'; |
$objet = 'dossier'; |
768 |
} |
} |
771 |
} |
} |
772 |
return $objet; |
return $objet; |
773 |
} |
} |
774 |
|
|
775 |
|
function setLayout(&$form, $maj) { |
776 |
|
$form->setBloc('json_payload', 'D', '', 'col_6'); |
777 |
|
$form->setFieldset('json_payload', 'DF', _("json_payload"), "collapsible, startClosed"); |
778 |
|
$form->setBloc('json_payload', 'F'); |
779 |
|
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
780 |
|
} |
781 |
|
|
782 |
} |
} |