1 |
<?php |
<?php |
2 |
//$Id$ |
//$Id$ |
3 |
//gen openMairie le 14/04/2020 14:11 |
//gen openMairie le 14/04/2020 14:11 |
4 |
|
|
5 |
require_once "../gen/obj/task.class.php"; |
require_once "../gen/obj/task.class.php"; |
19 |
"view" => "view_json_data", |
"view" => "view_json_data", |
20 |
"permission_suffix" => "consulter", |
"permission_suffix" => "consulter", |
21 |
); |
); |
22 |
|
$this->class_actions[997] = array( |
23 |
|
"identifier" => "json_data", |
24 |
|
"view" => "post_update_task", |
25 |
|
"permission_suffix" => "modifier", |
26 |
|
); |
27 |
|
$this->class_actions[996] = array( |
28 |
|
"identifier" => "json_data", |
29 |
|
"view" => "post_add_task", |
30 |
|
"permission_suffix" => "ajouter", |
31 |
|
); |
32 |
|
} |
33 |
|
|
34 |
|
public function setvalF($val = array()) { |
35 |
|
parent::setvalF($val); |
36 |
|
// |
37 |
|
if (array_key_exists('timestamp_log', $val) === true) { |
38 |
|
$this->valF['timestamp_log'] = str_replace("'", '"', $val['timestamp_log']); |
39 |
|
} |
40 |
|
} |
41 |
|
|
42 |
|
/** |
43 |
|
* |
44 |
|
* @return array |
45 |
|
*/ |
46 |
|
function get_var_sql_forminc__champs() { |
47 |
|
return array( |
48 |
|
"task", |
49 |
|
"type", |
50 |
|
"state", |
51 |
|
"object_id", |
52 |
|
"dossier", |
53 |
|
"stream", |
54 |
|
"json_payload", |
55 |
|
"timestamp_log", |
56 |
|
); |
57 |
|
} |
58 |
|
|
59 |
|
function setType(&$form, $maj) { |
60 |
|
parent::setType($form, $maj); |
61 |
|
// Récupération du mode de l'action |
62 |
|
$crud = $this->get_action_crud($maj); |
63 |
|
|
64 |
|
if ($maj < 2) { |
65 |
|
$form->setType("state", "select"); |
66 |
|
$form->setType("stream", "select"); |
67 |
|
$form->setType("json_payload", "jsonprettyprint"); |
68 |
|
} |
69 |
|
if ($maj == 3){ |
70 |
|
$form->setType('dossier', 'link'); |
71 |
|
$form->setType('json_payload', 'jsonprettyprint'); |
72 |
|
} |
73 |
|
|
74 |
|
} |
75 |
|
|
76 |
|
/** |
77 |
|
* |
78 |
|
*/ |
79 |
|
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
80 |
|
if($maj < 2) { |
81 |
|
$contenu=array(); |
82 |
|
|
83 |
|
$contenu[0][0]="draft"; |
84 |
|
$contenu[1][0]=_('draft'); |
85 |
|
$contenu[0][1]="new"; |
86 |
|
$contenu[1][1]=_('new'); |
87 |
|
$contenu[0][2]="pending"; |
88 |
|
$contenu[1][2]=_('pending'); |
89 |
|
$contenu[0][3]="done"; |
90 |
|
$contenu[1][3]=_('done'); |
91 |
|
$contenu[0][4]="archived"; |
92 |
|
$contenu[1][4]=_('archived'); |
93 |
|
$contenu[0][5]="error"; |
94 |
|
$contenu[1][5]=_('error'); |
95 |
|
$contenu[0][6]="debug"; |
96 |
|
$contenu[1][6]=_('debug'); |
97 |
|
|
98 |
|
$form->setSelect("state", $contenu); |
99 |
|
|
100 |
|
$contenu_stream =array(); |
101 |
|
$contenu_stream[0][0]="input"; |
102 |
|
$contenu_stream[1][0]=_('input'); |
103 |
|
$contenu_stream[0][1]="output"; |
104 |
|
$contenu_stream[1][1]=_('output'); |
105 |
|
$form->setSelect("stream", $contenu_stream); |
106 |
|
|
107 |
|
} |
108 |
|
|
109 |
|
if ($maj == 3) { |
110 |
|
if ($this->getVal('stream') == 'output') { |
111 |
|
$inst_dossier = $this->f->get_inst__om_dbform(array( |
112 |
|
"obj" => "dossier", |
113 |
|
"idx" => $form->val['dossier'], |
114 |
|
)); |
115 |
|
|
116 |
|
if($form->val['type'] == "creation_DA"){ |
117 |
|
$obj_link = 'dossier_autorisation'; |
118 |
|
} else { |
119 |
|
$obj_link = 'dossier_instruction'; |
120 |
|
} |
121 |
|
|
122 |
|
$params = array(); |
123 |
|
$params['obj'] = $obj_link; |
124 |
|
$params['libelle'] = $inst_dossier->getVal('dossier'); |
125 |
|
$params['title'] = "Consulter le dossier"; |
126 |
|
$params['idx'] = $form->val['dossier']; |
127 |
|
$form->setSelect("dossier", $params); |
128 |
|
} |
129 |
|
} |
130 |
|
} |
131 |
|
|
132 |
|
/** |
133 |
|
* SETTER_FORM - setVal (setVal). |
134 |
|
* |
135 |
|
* @return void |
136 |
|
*/ |
137 |
|
function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) { |
138 |
|
// parent::setVal($form, $maj, $validation); |
139 |
|
// |
140 |
|
if ($this->getVal('stream') == "output") { |
141 |
|
$form->setVal('json_payload', $this->view_form_json(true)); |
142 |
|
} else { |
143 |
|
$form->setVal('json_payload', htmlentities($this->getVal('json_payload'))); |
144 |
|
} |
145 |
|
} |
146 |
|
|
147 |
|
function setLib(&$form, $maj) { |
148 |
|
parent::setLib($form, $maj); |
149 |
|
$form->setLib('json_payload', ''); |
150 |
|
} |
151 |
|
|
152 |
|
public function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
153 |
|
$ret = parent::verifier($val, $dnu1, $dnu2); |
154 |
|
|
155 |
|
if (array_key_exists('timestamp_log', $this->valF) === true |
156 |
|
&& is_array(json_decode($this->valF['timestamp_log'], true)) === false) { |
157 |
|
// |
158 |
|
$this->correct = false; |
159 |
|
$this->addToMessage(sprintf( |
160 |
|
__("Le champ %s doit être dans un format JSON valide."), |
161 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('timestamp_log')) |
162 |
|
)); |
163 |
|
} |
164 |
|
|
165 |
|
// une tâche entrante doit avoir un type et une payload non-vide |
166 |
|
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
167 |
|
if (isset($this->valF['type']) === false) { |
168 |
|
$this->correct = false; |
169 |
|
$this->addToMessage(sprintf( |
170 |
|
__("Le champ %s est obligatoire pour une tâche entrante."), |
171 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('type')) |
172 |
|
)); |
173 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
174 |
|
} |
175 |
|
if (isset($this->valF['json_payload']) === false) { |
176 |
|
$this->correct = false; |
177 |
|
$this->addToMessage(sprintf( |
178 |
|
__("Le champ %s est obligatoire pour une tâche entrante."), |
179 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
180 |
|
)); |
181 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
182 |
|
} |
183 |
|
} |
184 |
|
|
185 |
|
// le JSON doit être décodable |
186 |
|
if (isset($this->valF['json_payload']) && ! empty($this->valF['json_payload']) && ( |
187 |
|
is_array(json_decode($this->valF['json_payload'], true)) === false |
188 |
|
|| json_last_error() !== JSON_ERROR_NONE)) { |
189 |
|
$this->correct = false; |
190 |
|
$this->addToMessage(sprintf( |
191 |
|
__("Le champ %s doit être dans un format JSON valide (erreur: %s)."), |
192 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload'), |
193 |
|
json_last_error() !== JSON_ERROR_NONE ? json_last_error_msg() : __('invalide')) |
194 |
|
)); |
195 |
|
$this->addToLog(__METHOD__.'(): erreur JSON: '.$this->msg, DEBUG_MODE); |
196 |
|
} |
197 |
|
|
198 |
|
// une tâche entrante doit avoir une payload avec les clés requises |
199 |
|
elseif (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
200 |
|
|
201 |
|
// décode la payload JSON |
202 |
|
$json_payload = json_decode($this->valF['json_payload'], true); |
203 |
|
|
204 |
|
// défini une liste de chemin de clés requises |
205 |
|
$paths = array( |
206 |
|
'external_uids/dossier' |
207 |
|
); |
208 |
|
|
209 |
|
// tâche de type création de DI/DA |
210 |
|
if (isset($this->valF['type']) !== false && $this->valF['type'] == 'create_DI_for_consultation') { |
211 |
|
|
212 |
|
$paths = array_merge($paths, array( |
213 |
|
'dossier/dossier', |
214 |
|
'dossier/dossier_autorisation_type_detaille_code', |
215 |
|
'dossier/date_demande', |
216 |
|
'dossier/depot_electronique', |
217 |
|
)); |
218 |
|
|
219 |
|
// si l'option commune est activée (mode MC) |
220 |
|
if ($this->f->is_option_dossier_commune_enabled()) { |
221 |
|
$paths[] = 'dossier/insee'; |
222 |
|
} |
223 |
|
|
224 |
|
// présence d'un moyen d'identifier la collectivité/le service |
225 |
|
if (! isset($json_payload['dossier']['acteur']) && |
226 |
|
! isset($json_payload['dossier']['om_collectivite'])) { |
227 |
|
$this->correct = false; |
228 |
|
$this->addToMessage(sprintf( |
229 |
|
__("L'une des clés %s ou %s est obligatoire dans le contenu du champ %s pour une tâche entrante."), |
230 |
|
sprintf('<span class="bold">%s</span>', 'dossier/acteur'), |
231 |
|
sprintf('<span class="bold">%s</span>', 'dossier/om_collectivite'), |
232 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
233 |
|
)); |
234 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
235 |
|
} |
236 |
|
} |
237 |
|
|
238 |
|
// pas d'erreur déjà trouvée |
239 |
|
if($this->correct) { |
240 |
|
|
241 |
|
// pour chaque chemin |
242 |
|
foreach($paths as $path) { |
243 |
|
|
244 |
|
// décompose le chemin |
245 |
|
$tokens = explode('/', $path); |
246 |
|
$cur_depth = $json_payload; |
247 |
|
|
248 |
|
// descend au et à mesure dans l'arborescence du chemin |
249 |
|
foreach($tokens as $token) { |
250 |
|
|
251 |
|
// en vérifiant que chaque élément du chemin est défini et non-nul |
252 |
|
if (isset($cur_depth[$token]) === false) { |
253 |
|
|
254 |
|
// sinon on produit une erreur |
255 |
|
$this->correct = false; |
256 |
|
$this->addToMessage(sprintf( |
257 |
|
__("La clé %s est obligatoire dans le contenu du champ %s pour une tâche entrante."), |
258 |
|
sprintf('<span class="bold">%s</span>', $path), |
259 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
260 |
|
)); |
261 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
262 |
|
break 2; |
263 |
|
} |
264 |
|
$cur_depth = $cur_depth[$token]; |
265 |
|
} |
266 |
|
} |
267 |
|
} |
268 |
|
} |
269 |
|
|
270 |
|
return $ret && $this->correct; |
271 |
} |
} |
272 |
|
|
273 |
protected function task_exists(string $type, string $object_id) { |
protected function task_exists(string $type, string $object_id) { |
291 |
} |
} |
292 |
|
|
293 |
/** |
/** |
294 |
|
* TRIGGER - triggerajouter. |
295 |
|
* |
296 |
|
* @param string $id |
297 |
|
* @param null &$dnu1 @deprecated Ne pas utiliser. |
298 |
|
* @param array $val Tableau des valeurs brutes. |
299 |
|
* @param null $dnu2 @deprecated Ne pas utiliser. |
300 |
|
* |
301 |
|
* @return boolean |
302 |
|
*/ |
303 |
|
function triggerajouter($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
304 |
|
|
305 |
|
// tâche entrante |
306 |
|
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
307 |
|
|
308 |
|
// décode la paylod JSON pour extraire les données métiers à ajouter |
309 |
|
// en tant que métadonnées de la tâche |
310 |
|
$json_payload = json_decode($this->valF['json_payload'], true); |
311 |
|
|
312 |
|
// si la tâche possède déjà une clé dossier |
313 |
|
if (isset($json_payload['dossier']['dossier']) && |
314 |
|
! empty($json_payload['dossier']['dossier'])) { |
315 |
|
$this->valF["dossier"] = $json_payload['dossier']['dossier']; |
316 |
|
} |
317 |
|
|
318 |
|
// sinon si la tâche possède une clé external_uids/dossier |
319 |
|
elseif(isset($json_payload['external_uids']['dossier']) && |
320 |
|
! empty($json_payload['external_uids']['dossier'])) { |
321 |
|
|
322 |
|
// instancie l'objet lien_id_interne_uid_externe |
323 |
|
$inst_lien = $this->f->get_inst__om_dbform(array( |
324 |
|
"obj" => "lien_id_interne_uid_externe", |
325 |
|
"idx" => ']', |
326 |
|
)); |
327 |
|
if(! $dossier = $inst_lien->get_id_dossier_from_external_uid( |
328 |
|
$json_payload['external_uids']['dossier'])){ |
329 |
|
$error_msg = sprintf( |
330 |
|
__("Aucune correspondance de dossier pour l'external_uid.dossier '%s'."), |
331 |
|
$json_payload['external_uids']['dossier']); |
332 |
|
$this->addToLog(__METHOD__."() : erreur : $error_msg", DEBUG_MODE); |
333 |
|
$this->addToMessage($error_msg); |
334 |
|
$this->correct = false; |
335 |
|
return false; |
336 |
|
} |
337 |
|
$this->valF["dossier"] = $dossier; |
338 |
|
} |
339 |
|
} |
340 |
|
} |
341 |
|
|
342 |
|
/** |
343 |
* TREATMENT - add_task |
* TREATMENT - add_task |
344 |
* Ajoute un enregistrement. |
* Ajoute un enregistrement. |
345 |
* |
* |
351 |
$timestamp_log = json_encode(array( |
$timestamp_log = json_encode(array( |
352 |
'creation_date' => date('Y-m-d H:i:s'), |
'creation_date' => date('Y-m-d H:i:s'), |
353 |
)); |
)); |
354 |
|
|
355 |
|
// Si la tâche est de type ajout_piece et de stream input alors on ajoute le fichier |
356 |
|
// et on ajoute l'uid dans le champ json_payload avant l'ajout de la tâche |
357 |
|
if (isset($params['val']['type']) |
358 |
|
&& $params['val']['type'] == "add_piece" |
359 |
|
&& isset($params['val']['stream']) |
360 |
|
&& $params['val']['stream'] == "input" ) { |
361 |
|
// |
362 |
|
$json_payload = json_decode($params['val']['json_payload'], true); |
363 |
|
$document_numerise = $json_payload['document_numerise']; |
364 |
|
$file_content = base64_decode($document_numerise["file_content"]); |
365 |
|
if ($file_content === false){ |
366 |
|
$this->addToMessage(__("Le contenu du fichier lié à la tâche n'a pas pu etre recupere.")); |
367 |
|
return $this->end_treatment(__METHOD__, false); |
368 |
|
} |
369 |
|
$metadata = array( |
370 |
|
"filename" => $document_numerise['nom_fichier'], |
371 |
|
"size" => strlen($file_content), |
372 |
|
"mimetype" => $document_numerise['file_content_type'], |
373 |
|
"date_creation" => $document_numerise['date_creation'], |
374 |
|
); |
375 |
|
$uid_fichier = $this->f->storage->create($file_content, $metadata, "from_content"); |
376 |
|
if ($uid_fichier === OP_FAILURE) { |
377 |
|
$this->addToMessage(__("Erreur lors de la creation du fichier lié à la tâche.")); |
378 |
|
return $this->end_treatment(__METHOD__, false); |
379 |
|
} |
380 |
|
$json_payload["document_numerise"]["uid"] = $uid_fichier; |
381 |
|
// Le fichier a été ajouté nous n'avons plus besoin du champ file_content dans la payload |
382 |
|
unset($json_payload["document_numerise"]["file_content"]); |
383 |
|
$params['val']['json_payload'] = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
384 |
|
} |
385 |
|
|
386 |
// Mise à jour du DI |
// Mise à jour du DI |
387 |
$valF = array( |
$valF = array( |
388 |
'task' => '', |
'task' => '', |
389 |
'type' => $params['val']['type'], |
'type' => $params['val']['type'], |
390 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
391 |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : 'new', |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : 'new', |
392 |
'object_id' => $params['val']['object_id'], |
'object_id' => isset($params['val']['object_id']) ? $params['val']['object_id'] : '', |
393 |
|
'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '', |
394 |
|
'stream' => isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output', |
395 |
|
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
396 |
); |
); |
397 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
|
398 |
if ($task_exists !== false) { |
// tâche sortante |
399 |
$inst_task = $this->f->get_inst__om_dbform(array( |
if($valF["stream"] == "output"){ |
400 |
"obj" => "task", |
|
401 |
"idx" => $task_exists, |
// TODO expliquer ce code |
402 |
)); |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
403 |
$update_state = $inst_task->getVal('state'); |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
404 |
if (isset($params['update_val']['state']) === true) { |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
405 |
$update_state = $params['update_val']['state']; |
} |
406 |
} |
if ($task_exists !== false) { |
407 |
$update_params = array( |
$inst_task = $this->f->get_inst__om_dbform(array( |
408 |
'val' => array( |
"obj" => "task", |
409 |
'state' => $update_state, |
"idx" => $task_exists, |
410 |
), |
)); |
411 |
); |
$update_state = $inst_task->getVal('state'); |
412 |
return $inst_task->update_task($update_params); |
if (isset($params['update_val']['state']) === true) { |
413 |
|
$update_state = $params['update_val']['state']; |
414 |
|
} |
415 |
|
$update_params = array( |
416 |
|
'val' => array( |
417 |
|
'state' => $update_state, |
418 |
|
), |
419 |
|
); |
420 |
|
return $inst_task->update_task($update_params); |
421 |
|
} |
422 |
} |
} |
423 |
|
|
424 |
$add = $this->ajouter($valF); |
$add = $this->ajouter($valF); |
425 |
|
$this->addToLog(__METHOD__."(): retour de l'ajout de tâche: ".var_export($add, true), VERBOSE_MODE); |
426 |
if ($add === false) { |
if ($add === false) { |
427 |
$this->addToLog($this->msg, DEBUG_MODE); |
$this->addToLog(__METHOD__."(): ".$this->msg, DEBUG_MODE); |
428 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
429 |
} |
} |
430 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
456 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
457 |
'state' => $params['val']['state'], |
'state' => $params['val']['state'], |
458 |
'object_id' => $this->getVal('object_id'), |
'object_id' => $this->getVal('object_id'), |
459 |
|
'stream' => $this->getVal('stream'), |
460 |
|
'dossier' => $this->getVal('dossier'), |
461 |
|
'json_payload' => $this->getVal('json_payload'), |
462 |
); |
); |
463 |
$update = $this->modifier($valF); |
$update = $this->modifier($valF); |
464 |
if ($update === false) { |
if ($update === false) { |
471 |
/** |
/** |
472 |
* Récupère le journal d'horodatage dans le champ timestamp_log de |
* Récupère le journal d'horodatage dans le champ timestamp_log de |
473 |
* l'enregistrement instancié. |
* l'enregistrement instancié. |
474 |
* |
* |
475 |
* @param array $params Tableau des paramètres |
* @param array $params Tableau des paramètres |
476 |
* @return array sinon false en cas d'erreur |
* @return array sinon false en cas d'erreur |
477 |
*/ |
*/ |
517 |
* |
* |
518 |
FROM %1$stask |
FROM %1$stask |
519 |
%2$s |
%2$s |
520 |
|
ORDER BY task ASC |
521 |
', |
', |
522 |
DB_PREFIXE, |
DB_PREFIXE, |
523 |
$where |
$where |
529 |
$list_tasks = array(); |
$list_tasks = array(); |
530 |
foreach ($res['result'] as $task) { |
foreach ($res['result'] as $task) { |
531 |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
532 |
|
$task['dossier'] = $task['object_id']; |
533 |
|
if ($this->get_lien_objet_by_type($task['type']) === 'document_numerise') { |
534 |
|
$val_dn = $this->get_document_numerise_data($task['object_id']); |
535 |
|
$task['dossier'] = $val_dn['dossier']; |
536 |
|
} |
537 |
$list_tasks[$task['task']] = $task; |
$list_tasks[$task['task']] = $task; |
538 |
} |
} |
539 |
printf(json_encode($list_tasks)); |
printf(json_encode($list_tasks)); |
623 |
$particular_case = false; |
$particular_case = false; |
624 |
$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(); |
625 |
foreach ($fields_tab_crea_loc_hab as $field) { |
foreach ($fields_tab_crea_loc_hab as $field) { |
626 |
if (isset($field) === false |
if (isset($val_dt[$field]) === false |
627 |
|| (isset($field) === true |
|| (isset($val_dt[$field]) === true |
628 |
&& $field !== null |
&& ($val_dt[$field] === null |
629 |
&& $field !== '')) { |
|| $val_dt[$field] === ''))) { |
630 |
// |
// |
631 |
$particular_case = true; |
$particular_case = true; |
632 |
} |
} |
718 |
return $val_architecte; |
return $val_architecte; |
719 |
} |
} |
720 |
|
|
721 |
protected function get_instruction_data(string $dossier) { |
protected function get_instruction_data(string $dossier, $type = 'decision') { |
722 |
$val_instruction = null; |
$val_instruction = null; |
723 |
$instruction_with_doc = null; |
$instruction_with_doc = null; |
724 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
725 |
"obj" => "dossier", |
"obj" => "dossier", |
726 |
"idx" => $dossier, |
"idx" => $dossier, |
727 |
)); |
)); |
728 |
|
$idx = null; |
729 |
|
if ($type === 'decision') { |
730 |
|
$idx = $inst_di->get_last_instruction_decision(); |
731 |
|
} |
732 |
|
if ($type === 'incompletude') { |
733 |
|
$idx = $inst_di->get_last_instruction_incompletude(); |
734 |
|
} |
735 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
736 |
"obj" => "instruction", |
"obj" => "instruction", |
737 |
"idx" => $inst_di->get_last_instruction_decision(), |
"idx" => $idx, |
738 |
)); |
)); |
739 |
if (count($inst_instruction->val) > 0) { |
if (count($inst_instruction->val) > 0) { |
740 |
$val_instruction = array(); |
$val_instruction = array(); |
769 |
} |
} |
770 |
if ($instruction_with_doc !== null) { |
if ($instruction_with_doc !== null) { |
771 |
// |
// |
772 |
$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); |
773 |
} |
} |
774 |
} |
} |
775 |
return $val_instruction; |
return $val_instruction; |
786 |
"signataire_arrete", |
"signataire_arrete", |
787 |
"om_fichier_instruction", |
"om_fichier_instruction", |
788 |
"tacite", |
"tacite", |
789 |
|
"lettretype", |
790 |
); |
); |
791 |
foreach ($values as $key => $value) { |
foreach ($values as $key => $value) { |
792 |
if (in_array($key, $fields) === true) { |
if (in_array($key, $fields) === true) { |
812 |
"idx" => $dn, |
"idx" => $dn, |
813 |
)); |
)); |
814 |
$val_dn = $inst_dn->get_json_data(); |
$val_dn = $inst_dn->get_json_data(); |
815 |
$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')); |
816 |
// Correspond à la nomenclature Plat'AU NATURE_PIECE |
// Correspond à la nomenclature Plat'AU NATURE_PIECE |
817 |
$val_dn['nature'] = 'Initiale'; |
$val_dn['nature'] = $val_dn['document_numerise_nature_libelle']; |
818 |
return $val_dn; |
return $val_dn; |
819 |
} |
} |
820 |
|
|
837 |
return $val_dp; |
return $val_dp; |
838 |
} |
} |
839 |
|
|
840 |
protected function view_form_json() { |
protected function view_form_json($in_field = false) { |
|
// Mise à jour des valeurs |
|
|
if ($this->f->get_submitted_post_value('valid') === 'true' |
|
|
&& $this->f->get_submitted_post_value('state') !== null) { |
|
|
// |
|
|
$params = array( |
|
|
'val' => array( |
|
|
'state' => $this->f->get_submitted_post_value('state') |
|
|
), |
|
|
); |
|
|
$update = $this->update_task($params); |
|
|
$message_class = "valid"; |
|
|
$message = $this->msg; |
|
|
if ($update === false) { |
|
|
$this->addToLog($this->msg, DEBUG_MODE); |
|
|
$message_class = "error"; |
|
|
$message = sprintf( |
|
|
'%s %s', |
|
|
__('Impossible de mettre à jour la tâche.'), |
|
|
__('Veuillez contacter votre administrateur.') |
|
|
); |
|
|
} |
|
|
$this->f->displayMessage($message_class, $message); |
|
|
} |
|
|
// |
|
|
if ($this->f->get_submitted_post_value('valid') === 'true' |
|
|
&& $this->f->get_submitted_post_value('external_uid') !== null) { |
|
|
// |
|
|
$inst_lien = $this->f->get_inst__om_dbform(array( |
|
|
"obj" => "lien_id_interne_uid_externe", |
|
|
"idx" => ']', |
|
|
)); |
|
|
$valF = array( |
|
|
'lien_id_interne_uid_externe' => '', |
|
|
'object' => $this->get_lien_objet_by_type($this->getVal('type')), |
|
|
'object_id' => $this->getVal('object_id'), |
|
|
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
|
|
); |
|
|
$add = $inst_lien->ajouter($valF); |
|
|
$message_class = "valid"; |
|
|
$message = $inst_lien->msg; |
|
|
if ($add === false) { |
|
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
|
|
$message_class = "error"; |
|
|
$message = sprintf( |
|
|
'%s %s', |
|
|
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
|
|
__('Veuillez contacter votre administrateur.') |
|
|
); |
|
|
} |
|
|
$this->f->displayMessage($message_class, $message); |
|
|
} |
|
|
|
|
841 |
// |
// |
842 |
if ($this->f->get_submitted_post_value('valid') === null) { |
if ($this->f->get_submitted_post_value('valid') === null) { |
843 |
// Liste des valeurs à afficher |
// Liste des valeurs à afficher |
856 |
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
857 |
$val_external_uid = array(); |
$val_external_uid = array(); |
858 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
859 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
860 |
} |
} |
861 |
// |
// |
862 |
if ($this->getVal('type') === 'creation_DI' |
if ($this->getVal('type') === 'creation_DI' |
872 |
$val_external_uid = array(); |
$val_external_uid = array(); |
873 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
874 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
875 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
876 |
} |
} |
877 |
// |
// |
878 |
if ($this->getVal('type') === 'qualification_DI') { |
if ($this->getVal('type') === 'qualification_DI') { |
880 |
$val_external_uid = array(); |
$val_external_uid = array(); |
881 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
882 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
883 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
884 |
} |
} |
885 |
// |
// |
886 |
if ($this->getVal('type') === 'ajout_piece') { |
if ($this->getVal('type') === 'ajout_piece') { |
890 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
891 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
892 |
$val_external_uid['document_numerise'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'document_numerise'); |
$val_external_uid['document_numerise'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'document_numerise'); |
893 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
894 |
} |
} |
895 |
// |
// |
896 |
if ($this->getVal('type') === 'decision_DI') { |
if ($this->getVal('type') === 'decision_DI') { |
899 |
$val_external_uid = array(); |
$val_external_uid = array(); |
900 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
901 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
902 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
903 |
|
} |
904 |
|
// |
905 |
|
if ($this->getVal('type') === 'incompletude_DI') { |
906 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
907 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'incompletude'); |
908 |
|
$val_external_uid = array(); |
909 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
910 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
911 |
|
$val['external_uids'] = $val_external_uid; |
912 |
|
} |
913 |
|
// |
914 |
|
if ($this->getVal('type') === 'completude_DI') { |
915 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
916 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'completude'); |
917 |
|
$val_external_uid = array(); |
918 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
919 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
920 |
|
$val['external_uids'] = $val_external_uid; |
921 |
} |
} |
922 |
|
|
923 |
// Liste des valeurs affichée en JSON |
if ($in_field === true) { |
924 |
printf(json_encode($val)); |
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
925 |
|
} else { |
926 |
|
// Liste des valeurs affichée en JSON |
927 |
|
printf(json_encode($val, JSON_UNESCAPED_SLASHES)); |
928 |
|
} |
929 |
} |
} |
930 |
} |
} |
931 |
|
|
932 |
protected function get_lien_objet_by_type($type) { |
function post_update_task() { |
933 |
|
// Mise à jour des valeurs |
934 |
|
// |
935 |
|
$params = array( |
936 |
|
'val' => array( |
937 |
|
'state' => $this->f->get_submitted_post_value('state') |
938 |
|
), |
939 |
|
); |
940 |
|
$update = $this->update_task($params); |
941 |
|
$message_class = "valid"; |
942 |
|
$message = $this->msg; |
943 |
|
if ($update === false) { |
944 |
|
$this->addToLog($this->msg, DEBUG_MODE); |
945 |
|
$message_class = "error"; |
946 |
|
$message = sprintf( |
947 |
|
'%s %s', |
948 |
|
__('Impossible de mettre à jour la tâche.'), |
949 |
|
__('Veuillez contacter votre administrateur.') |
950 |
|
); |
951 |
|
} |
952 |
|
$this->f->displayMessage($message_class, $message); |
953 |
|
// |
954 |
|
$inst_lien = $this->f->get_inst__om_dbform(array( |
955 |
|
"obj" => "lien_id_interne_uid_externe", |
956 |
|
"idx" => ']', |
957 |
|
)); |
958 |
|
$valF = array( |
959 |
|
'lien_id_interne_uid_externe' => '', |
960 |
|
'object' => $this->get_lien_objet_by_type($this->getVal('type')), |
961 |
|
'object_id' => $this->getVal('object_id'), |
962 |
|
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
963 |
|
); |
964 |
|
$add = $inst_lien->ajouter($valF); |
965 |
|
$message_class = "valid"; |
966 |
|
$message = $inst_lien->msg; |
967 |
|
if ($add === false) { |
968 |
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
969 |
|
$message_class = "error"; |
970 |
|
$message = sprintf( |
971 |
|
'%s %s', |
972 |
|
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
973 |
|
__('Veuillez contacter votre administrateur.') |
974 |
|
); |
975 |
|
} |
976 |
|
$this->f->displayMessage($message_class, $message); |
977 |
|
} |
978 |
|
|
979 |
|
function post_add_task() { |
980 |
|
// TODO Tester de remplacer la ligne de json_payload par un $_POST |
981 |
|
$result = $this->add_task(array( |
982 |
|
'val' => array( |
983 |
|
'stream' => 'input', |
984 |
|
'json_payload' => html_entity_decode($this->f->get_submitted_post_value('json_payload')), |
985 |
|
'type' => $this->f->get_submitted_post_value('type'), |
986 |
|
) |
987 |
|
)); |
988 |
|
$message = $this->msg; |
989 |
|
$message_class = "valid"; |
990 |
|
if ($result === false){ |
991 |
|
$this->addToLog($this->msg, DEBUG_MODE); |
992 |
|
$message_class = "error"; |
993 |
|
$message = sprintf( |
994 |
|
'%s %s', |
995 |
|
__('Impossible d\'ajouter la tâche.'), |
996 |
|
__('Veuillez contacter votre administrateur.') |
997 |
|
); |
998 |
|
} |
999 |
|
$this->f->displayMessage($message_class, $message); |
1000 |
|
} |
1001 |
|
|
1002 |
|
function get_lien_objet_by_type($type) { |
1003 |
// |
// |
1004 |
$objet = ''; |
$objet = ''; |
1005 |
if ($type === 'creation_DA') { |
if ($type === 'creation_DA') { |
1006 |
$objet = 'dossier_autorisation'; |
$objet = 'dossier_autorisation'; |
1007 |
} |
} |
1008 |
if ($type === 'creation_DI' |
if ($type === 'creation_DI' |
1009 |
|
|| $type === 'create_DI_for_consultation' |
1010 |
|| $type === 'depot_DI' |
|| $type === 'depot_DI' |
1011 |
|| $type === 'modification_DI' |
|| $type === 'modification_DI' |
1012 |
|| $type === 'qualification_DI' |
|| $type === 'qualification_DI' |
1013 |
|| $type === 'decision_DI') { |
|| $type === 'decision_DI' |
1014 |
|
|| $type === 'incompletude_DI' |
1015 |
|
|| $type === 'completude_DI') { |
1016 |
// |
// |
1017 |
$objet = 'dossier'; |
$objet = 'dossier'; |
1018 |
} |
} |
1019 |
if ($type === 'ajout_piece') { |
if ($type === 'ajout_piece') { |
1020 |
$objet = 'document_numerise'; |
$objet = 'document_numerise'; |
1021 |
} |
} |
1022 |
|
// La tâche entrante se nomme add_piece |
1023 |
|
if ($type === 'add_piece') { |
1024 |
|
$objet = 'piece'; |
1025 |
|
} |
1026 |
return $objet; |
return $objet; |
1027 |
} |
} |
1028 |
|
|
1029 |
|
function setLayout(&$form, $maj) { |
1030 |
|
$form->setBloc('json_payload', 'D', '', 'col_6'); |
1031 |
|
$form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed"); |
1032 |
|
$form->setBloc('json_payload', 'F'); |
1033 |
|
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
1034 |
|
} |
1035 |
|
|
1036 |
} |
} |