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 |
|
'json_payload' => '{}', |
176 |
); |
); |
177 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
178 |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
228 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
229 |
'state' => $params['val']['state'], |
'state' => $params['val']['state'], |
230 |
'object_id' => $this->getVal('object_id'), |
'object_id' => $this->getVal('object_id'), |
231 |
|
'dossier' => $this->getVal('dossier'), |
232 |
|
'json_payload' => $this->getVal('json_payload'), |
233 |
); |
); |
234 |
$update = $this->modifier($valF); |
$update = $this->modifier($valF); |
235 |
if ($update === false) { |
if ($update === false) { |
288 |
* |
* |
289 |
FROM %1$stask |
FROM %1$stask |
290 |
%2$s |
%2$s |
291 |
|
ORDER BY task ASC |
292 |
', |
', |
293 |
DB_PREFIXE, |
DB_PREFIXE, |
294 |
$where |
$where |
300 |
$list_tasks = array(); |
$list_tasks = array(); |
301 |
foreach ($res['result'] as $task) { |
foreach ($res['result'] as $task) { |
302 |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
303 |
|
$task['dossier'] = $task['object_id']; |
304 |
|
if ($this->get_lien_objet_by_type($task['type']) === 'document_numerise') { |
305 |
|
$val_dn = $this->get_document_numerise_data($task['object_id']); |
306 |
|
$task['dossier'] = $val_dn['dossier']; |
307 |
|
} |
308 |
$list_tasks[$task['task']] = $task; |
$list_tasks[$task['task']] = $task; |
309 |
} |
} |
310 |
printf(json_encode($list_tasks)); |
printf(json_encode($list_tasks)); |
557 |
"signataire_arrete", |
"signataire_arrete", |
558 |
"om_fichier_instruction", |
"om_fichier_instruction", |
559 |
"tacite", |
"tacite", |
560 |
|
"lettretype", |
561 |
); |
); |
562 |
foreach ($values as $key => $value) { |
foreach ($values as $key => $value) { |
563 |
if (in_array($key, $fields) === true) { |
if (in_array($key, $fields) === true) { |
608 |
return $val_dp; |
return $val_dp; |
609 |
} |
} |
610 |
|
|
611 |
protected function view_form_json() { |
protected function view_form_json($in_field = false) { |
612 |
// Mise à jour des valeurs |
// Mise à jour des valeurs |
613 |
if ($this->f->get_submitted_post_value('valid') === 'true' |
if ($this->f->get_submitted_post_value('valid') === 'true' |
614 |
&& $this->f->get_submitted_post_value('state') !== null) { |
&& $this->f->get_submitted_post_value('state') !== null) { |
743 |
$val['external_uid'] = $val_external_uid; |
$val['external_uid'] = $val_external_uid; |
744 |
} |
} |
745 |
|
|
746 |
// Liste des valeurs affichée en JSON |
if ($in_field === true) { |
747 |
printf(json_encode($val, JSON_UNESCAPED_SLASHES)); |
return json_encode($val, JSON_PRETTY_PRINT ,JSON_UNESCAPED_SLASHES); |
748 |
|
} else { |
749 |
|
// Liste des valeurs affichée en JSON |
750 |
|
printf(json_encode($val, JSON_UNESCAPED_SLASHES)); |
751 |
|
} |
752 |
} |
} |
753 |
} |
} |
754 |
|
|
773 |
} |
} |
774 |
return $objet; |
return $objet; |
775 |
} |
} |
776 |
|
|
777 |
|
function setLayout(&$form, $maj) { |
778 |
|
$form->setBloc('json_payload', 'D', '', 'col_6'); |
779 |
|
$form->setFieldset('json_payload', 'DF', _("json_payload"), "collapsible, startClosed"); |
780 |
|
$form->setBloc('json_payload', 'F'); |
781 |
|
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
782 |
|
} |
783 |
|
|
784 |
} |
} |