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"; |
6 |
|
|
7 |
class task extends task_gen { |
class task extends task_gen { |
8 |
|
|
9 |
|
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 |
/** |
/** |
18 |
* Définition des actions disponibles sur la classe. |
* Définition des actions disponibles sur la classe. |
19 |
* |
* |
23 |
parent::init_class_actions(); |
parent::init_class_actions(); |
24 |
// |
// |
25 |
$this->class_actions[998] = array( |
$this->class_actions[998] = array( |
26 |
"identifier" => "view_json", |
"identifier" => "json_data", |
27 |
"view" => "view_json", |
"view" => "view_json_data", |
28 |
"permission_suffix" => "consulter", |
"permission_suffix" => "consulter", |
29 |
); |
); |
30 |
|
$this->class_actions[997] = array( |
31 |
|
"identifier" => "json_data", |
32 |
|
"view" => "post_update_task", |
33 |
|
"permission_suffix" => "modifier", |
34 |
|
); |
35 |
|
$this->class_actions[996] = array( |
36 |
|
"identifier" => "json_data", |
37 |
|
"view" => "post_add_task", |
38 |
|
"permission_suffix" => "ajouter", |
39 |
|
); |
40 |
|
} |
41 |
|
|
42 |
|
public function setvalF($val = array()) { |
43 |
|
parent::setvalF($val); |
44 |
|
// |
45 |
|
if (array_key_exists('timestamp_log', $val) === true) { |
46 |
|
$this->valF['timestamp_log'] = str_replace("'", '"', $val['timestamp_log']); |
47 |
|
} |
48 |
|
} |
49 |
|
|
50 |
|
/** |
51 |
|
* |
52 |
|
* @return array |
53 |
|
*/ |
54 |
|
function get_var_sql_forminc__champs() { |
55 |
|
return array( |
56 |
|
"task", |
57 |
|
"type", |
58 |
|
"state", |
59 |
|
"object_id", |
60 |
|
"dossier", |
61 |
|
"stream", |
62 |
|
"json_payload", |
63 |
|
"timestamp_log", |
64 |
|
); |
65 |
|
} |
66 |
|
|
67 |
|
function setType(&$form, $maj) { |
68 |
|
parent::setType($form, $maj); |
69 |
|
// Récupération du mode de l'action |
70 |
|
$crud = $this->get_action_crud($maj); |
71 |
|
|
72 |
|
if ($maj < 2) { |
73 |
|
$form->setType("state", "select"); |
74 |
|
$form->setType("stream", "select"); |
75 |
|
$form->setType("json_payload", "jsonprettyprint"); |
76 |
|
} |
77 |
|
if ($maj == 3){ |
78 |
|
$form->setType('dossier', 'link'); |
79 |
|
$form->setType('json_payload', 'jsonprettyprint'); |
80 |
|
} |
81 |
|
|
82 |
|
} |
83 |
|
|
84 |
|
/** |
85 |
|
* |
86 |
|
*/ |
87 |
|
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
88 |
|
if($maj < 2) { |
89 |
|
|
90 |
|
$contenu = array(); |
91 |
|
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG') as $key) { |
92 |
|
$const_name = 'STATUS_'.$key; |
93 |
|
$const_value = constant("self::$const_name"); |
94 |
|
$contenu[0][] = $const_value; |
95 |
|
$contenu[1][] = __($const_value); |
96 |
|
} |
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) { |
274 |
|
$query = sprintf(' |
275 |
|
SELECT task |
276 |
|
FROM %1$stask |
277 |
|
WHERE state != \'%2$s\' |
278 |
|
AND type = \'%3$s\' |
279 |
|
AND object_id = \'%4$s\' |
280 |
|
', |
281 |
|
DB_PREFIXE, |
282 |
|
self::STATUS_DONE, |
283 |
|
$type, |
284 |
|
$object_id |
285 |
|
); |
286 |
|
$res = $this->f->get_one_result_from_db_query($query); |
287 |
|
if ($res['result'] !== null && $res['result'] !== '') { |
288 |
|
return $res['result']; |
289 |
|
} |
290 |
|
return false; |
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 |
/** |
/** |
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' => 'draft', |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : self::STATUS_NEW, |
392 |
'id' => $params['val']['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 |
|
|
398 |
|
// tâche sortante |
399 |
|
if($valF["stream"] == "output"){ |
400 |
|
|
401 |
|
// TODO expliquer ce code |
402 |
|
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
403 |
|
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
404 |
|
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
405 |
|
} |
406 |
|
if ($task_exists !== false) { |
407 |
|
$inst_task = $this->f->get_inst__om_dbform(array( |
408 |
|
"obj" => "task", |
409 |
|
"idx" => $task_exists, |
410 |
|
)); |
411 |
|
$update_state = $inst_task->getVal('state'); |
412 |
|
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); |
455 |
'type' => $this->getVal('type'), |
'type' => $this->getVal('type'), |
456 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
457 |
'state' => $params['val']['state'], |
'state' => $params['val']['state'], |
458 |
'id' => $this->getVal('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 |
*/ |
*/ |
487 |
} |
} |
488 |
|
|
489 |
/** |
/** |
490 |
* VIEW - view_json |
* VIEW - view_json_data |
491 |
* Affiche l'enregistrement dans le format JSON. |
* Affiche l'enregistrement dans le format JSON. |
492 |
* |
* |
493 |
* @return void |
* @return void |
494 |
*/ |
*/ |
495 |
public function view_json() { |
public function view_json_data() { |
496 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
497 |
$val = array_combine($this->champs, $this->val); |
$this->f->disableLog(); |
498 |
printf(json_encode($val)); |
if ($this->getParameter('idx') !== ']' |
499 |
if ($this->f->get_submitted_post_value('valid') === 'true' |
&& $this->getParameter('idx') !== '0') { |
500 |
&& $this->f->get_submitted_post_value('state') !== null) { |
// |
501 |
// |
$this->view_form_json(); |
502 |
$params = array( |
} |
503 |
'val' => array( |
else { |
504 |
'state' => $this->f->get_submitted_post_value('state') |
$this->view_tab_json(); |
505 |
), |
} |
506 |
); |
} |
507 |
$update = $this->update_task($params); |
|
508 |
$message_class = "valid"; |
protected function view_tab_json() { |
509 |
$message = $this->msg; |
$where = ''; |
510 |
if ($update === false) { |
if ($this->f->get_submitted_get_value('state') !== null |
511 |
$this->addToLog($this->msg, DEBUG_MODE); |
&& $this->f->get_submitted_get_value('state') !== '') { |
512 |
$message_class = "error"; |
// |
513 |
$message = sprintf( |
$where = sprintf(' WHERE state = \'%s\' ', $this->f->get_submitted_get_value('state')); |
514 |
'%s %s', |
} |
515 |
__('Impossible de mettre à jour la tâche.'), |
$query = sprintf(' |
516 |
__('Veuillez contacter votre administrateur.') |
SELECT |
517 |
); |
* |
518 |
|
FROM %1$stask |
519 |
|
%2$s |
520 |
|
ORDER BY task ASC |
521 |
|
', |
522 |
|
DB_PREFIXE, |
523 |
|
$where |
524 |
|
); |
525 |
|
$res = $this->f->get_all_results_from_db_query($query, true); |
526 |
|
if ($res['code'] === 'KO') { |
527 |
|
return false; |
528 |
|
} |
529 |
|
$list_tasks = array(); |
530 |
|
foreach ($res['result'] as $task) { |
531 |
|
$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; |
538 |
|
} |
539 |
|
printf(json_encode($list_tasks)); |
540 |
|
} |
541 |
|
|
542 |
|
protected function get_dossier_data(string $dossier) { |
543 |
|
$val_di = array(); |
544 |
|
$inst_di = $this->f->get_inst__om_dbform(array( |
545 |
|
"obj" => "dossier", |
546 |
|
"idx" => $dossier, |
547 |
|
)); |
548 |
|
$val_di = $inst_di->get_json_data(); |
549 |
|
if ($val_di['dossier_instruction_type_code'] === 'T') { |
550 |
|
$val_di['date_decision_transfert'] = $val_di['date_decision']; |
551 |
|
} |
552 |
|
unset($val_di['initial_dt']); |
553 |
|
unset($val_di['log_instructions']); |
554 |
|
return $val_di; |
555 |
|
} |
556 |
|
|
557 |
|
protected function get_dossier_autorisation_data(string $da) { |
558 |
|
$val_da = array(); |
559 |
|
$inst_da = $this->f->get_inst__om_dbform(array( |
560 |
|
"obj" => "dossier_autorisation", |
561 |
|
"idx" => $da, |
562 |
|
)); |
563 |
|
$val_da = $inst_da->get_json_data(); |
564 |
|
return $val_da; |
565 |
|
} |
566 |
|
|
567 |
|
protected function get_donnees_techniques_data(string $fk_idx, string $fk_field) { |
568 |
|
$val_dt = array(); |
569 |
|
$inst_dt = $this->f->get_inst__by_other_idx(array( |
570 |
|
"obj" => "donnees_techniques", |
571 |
|
"fk_field" => $fk_field, |
572 |
|
"fk_idx" => $fk_idx, |
573 |
|
)); |
574 |
|
$val_dt = array( |
575 |
|
'donnees_techniques' => $inst_dt->getVal($inst_dt->clePrimaire), |
576 |
|
'cerfa' => $inst_dt->getVal('cerfa'), |
577 |
|
); |
578 |
|
$val_dt = array_merge($val_dt, $inst_dt->get_donnees_techniques_applicables()); |
579 |
|
if (isset($val_dt['am_exist_date']) === true) { |
580 |
|
$val_dt['am_exist_date_num'] = ''; |
581 |
|
if (is_numeric($val_dt['am_exist_date']) === true) { |
582 |
|
$val_dt['am_exist_date_num'] = $val_dt['am_exist_date']; |
583 |
|
} |
584 |
|
} |
585 |
|
// Correspond à la nomenclature de Plat'AU STATUT_INFO |
586 |
|
$val_dt['tax_statut_info'] = 'Déclaré'; |
587 |
|
// |
588 |
|
if ($inst_dt->is_tab_surf_ssdest_enabled() === true) { |
589 |
|
$fields_tab_surf_dest = $inst_dt->get_fields_tab_surf_dest(); |
590 |
|
foreach ($fields_tab_surf_dest as $field) { |
591 |
|
if (isset($val_dt[$field]) === true) { |
592 |
|
unset($val_dt[$field]); |
593 |
|
} |
594 |
|
} |
595 |
|
} else { |
596 |
|
$fields_tab_surf_ssdest = $inst_dt->get_fields_tab_surf_ssdest(); |
597 |
|
foreach ($fields_tab_surf_ssdest as $field) { |
598 |
|
if (isset($val_dt[$field]) === true) { |
599 |
|
unset($val_dt[$field]); |
600 |
|
} |
601 |
|
} |
602 |
|
} |
603 |
|
// Correspond à la nouvelle ligne CERFA v7 dans le DENSI imposition 1.2.3 |
604 |
|
if (isset($val_dt['tax_su_non_habit_surf2']) === true |
605 |
|
&& isset($val_dt['tax_su_non_habit_surf3']) === true |
606 |
|
&& (($val_dt['tax_su_non_habit_surf2'] !== null |
607 |
|
&& $val_dt['tax_su_non_habit_surf2'] !== '') |
608 |
|
|| ($val_dt['tax_su_non_habit_surf3'] !== null |
609 |
|
&& $val_dt['tax_su_non_habit_surf3'] !== ''))) { |
610 |
|
// |
611 |
|
$val_dt['tax_su_non_habit_surf8'] = intval($val_dt['tax_su_non_habit_surf2']) + intval($val_dt['tax_su_non_habit_surf3']); |
612 |
|
} |
613 |
|
if (isset($val_dt['tax_su_non_habit_surf_stat2']) === true |
614 |
|
&& isset($val_dt['tax_su_non_habit_surf_stat3']) === true |
615 |
|
&& (($val_dt['tax_su_non_habit_surf_stat2'] !== null |
616 |
|
&& $val_dt['tax_su_non_habit_surf_stat2'] !== '') |
617 |
|
|| ($val_dt['tax_su_non_habit_surf_stat3'] !== null |
618 |
|
&& $val_dt['tax_su_non_habit_surf_stat3'] !== ''))) { |
619 |
|
// |
620 |
|
$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']); |
621 |
|
} |
622 |
|
// Cas particulier d'un projet réduit à l'extension d'une habitation existante |
623 |
|
$particular_case = false; |
624 |
|
$fields_tab_crea_loc_hab = $inst_dt->get_fields_tab_crea_loc_hab(); |
625 |
|
foreach ($fields_tab_crea_loc_hab as $field) { |
626 |
|
if (isset($val_dt[$field]) === false |
627 |
|
|| (isset($val_dt[$field]) === true |
628 |
|
&& ($val_dt[$field] === null |
629 |
|
|| $val_dt[$field] === ''))) { |
630 |
|
// |
631 |
|
$particular_case = true; |
632 |
|
} |
633 |
|
} |
634 |
|
if ($particular_case === true) { |
635 |
|
if (isset($val_dt['tax_ext_pret']) === true |
636 |
|
&& $val_dt['tax_ext_pret'] === 'f') { |
637 |
|
// |
638 |
|
$val_dt['tax_su_princ_surf1'] = $val_dt['tax_surf_tot_cstr']; |
639 |
|
$val_dt['tax_su_princ_surf_stat1'] = $val_dt['tax_surf_loc_stat']; |
640 |
|
} |
641 |
|
if (isset($val_dt['tax_ext_pret']) === true |
642 |
|
&& $val_dt['tax_ext_pret'] === 't') { |
643 |
|
// |
644 |
|
if (isset($val_dt['tax_ext_desc']) === true) { |
645 |
|
if (preg_match('/[pP].*[lL].*[aA].*[iI]/', $val_dt['tax_ext_desc']) === 1 |
646 |
|
|| preg_match('/[lL].*[lL].*[tT].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
647 |
|
// |
648 |
|
$val_dt['tax_su_princ_surf2'] = $val_dt['tax_surf_tot_cstr']; |
649 |
|
$val_dt['tax_su_princ_surf_stat2'] = $val_dt['tax_surf_loc_stat']; |
650 |
|
} |
651 |
|
// if (preg_match('/[pP].*[tT].*[zZ]/', $val_dt['tax_ext_desc']) === 1) { |
652 |
|
// $val_dt['tax_su_princ_surf4'] = $val_dt['tax_surf_tot_cstr']; |
653 |
|
// $val_dt['tax_su_princ_surf_stat4'] = $val_dt['tax_surf_loc_stat']; |
654 |
|
// } |
655 |
|
// if (preg_match('/[pP].*[lL].*[uU].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
656 |
|
// || preg_match('/[lL].*[eE].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
657 |
|
// || preg_match('/[pP].*[sS].*[lL].*[aA]/', $val_dt['tax_ext_desc']) === 1 |
658 |
|
// || preg_match('/[pP].*[lL].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
659 |
|
// || preg_match('/[lL].*[lL].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
660 |
|
// // |
661 |
|
// $val_dt['tax_su_princ_surf3'] = $val_dt['tax_surf_tot_cstr']; |
662 |
|
// $val_dt['tax_su_princ_surf_stat3'] = $val_dt['tax_surf_loc_stat']; |
663 |
|
// } |
664 |
|
} |
665 |
|
} |
666 |
|
} |
667 |
|
// Cas particulier de la surface taxable démolie |
668 |
|
if (isset($val_dt['tax_surf_tot_demo']) === true |
669 |
|
&& isset($val_dt['tax_surf_tax_demo']) === true |
670 |
|
&& ($val_dt['tax_surf_tot_demo'] === null |
671 |
|
|| $val_dt['tax_surf_tot_demo'] === '')) { |
672 |
|
// |
673 |
|
$val_dt['tax_surf_tot_demo'] = $val_dt['tax_surf_tax_demo']; |
674 |
|
} |
675 |
|
return $val_dt; |
676 |
|
} |
677 |
|
|
678 |
|
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
679 |
|
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
680 |
|
"obj" => "lien_id_interne_uid_externe", |
681 |
|
"fk_field" => 'object_id', |
682 |
|
"fk_idx" => $fk_idx, |
683 |
|
"fk_field_2" => 'object', |
684 |
|
"fk_idx_2" => $fk_idx_2, |
685 |
|
)); |
686 |
|
return $inst_external_uid->getVal('external_uid'); |
687 |
|
} |
688 |
|
|
689 |
|
protected function get_demandeurs_data(string $dossier) { |
690 |
|
$val_demandeur = array(); |
691 |
|
$inst_di = $this->f->get_inst__om_dbform(array( |
692 |
|
"obj" => "dossier", |
693 |
|
"idx" => $dossier, |
694 |
|
)); |
695 |
|
$list_demandeurs = $inst_di->get_demandeurs(); |
696 |
|
foreach ($list_demandeurs as $demandeur) { |
697 |
|
$inst_demandeur = $this->f->get_inst__om_dbform(array( |
698 |
|
"obj" => "demandeur", |
699 |
|
"idx" => $demandeur['demandeur'], |
700 |
|
)); |
701 |
|
$val_demandeur[$demandeur['demandeur']] = $inst_demandeur->get_json_data(); |
702 |
|
$val_demandeur[$demandeur['demandeur']]['petitionnaire_principal'] = $demandeur['petitionnaire_principal']; |
703 |
|
} |
704 |
|
return $val_demandeur; |
705 |
|
} |
706 |
|
|
707 |
|
protected function get_architecte_data($architecte = null) { |
708 |
|
$val_architecte = null; |
709 |
|
if ($architecte !== null |
710 |
|
&& $architecte !== '') { |
711 |
|
// |
712 |
|
$inst_architecte = $this->f->get_inst__om_dbform(array( |
713 |
|
"obj" => "architecte", |
714 |
|
"idx" => $architecte, |
715 |
|
)); |
716 |
|
$val_architecte = $inst_architecte->get_json_data(); |
717 |
|
} |
718 |
|
return $val_architecte; |
719 |
|
} |
720 |
|
|
721 |
|
protected function get_instruction_data(string $dossier, $type = 'decision') { |
722 |
|
$val_instruction = null; |
723 |
|
$instruction_with_doc = null; |
724 |
|
$inst_di = $this->f->get_inst__om_dbform(array( |
725 |
|
"obj" => "dossier", |
726 |
|
"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( |
736 |
|
"obj" => "instruction", |
737 |
|
"idx" => $idx, |
738 |
|
)); |
739 |
|
if (count($inst_instruction->val) > 0) { |
740 |
|
$val_instruction = array(); |
741 |
|
$instruction_data = $inst_instruction->get_json_data(); |
742 |
|
$val_instruction = $this->sort_instruction_data($instruction_data, $val_instruction); |
743 |
|
if ($instruction_data['om_fichier_instruction'] !== null |
744 |
|
&& $instruction_data['om_fichier_instruction'] !== '') { |
745 |
|
// |
746 |
|
$instruction_with_doc = $inst_instruction->getVal($inst_instruction->clePrimaire); |
747 |
|
} |
748 |
|
$inst_ev = $this->f->get_inst__om_dbform(array( |
749 |
|
"obj" => "evenement", |
750 |
|
"idx" => $inst_instruction->getVal('evenement'), |
751 |
|
)); |
752 |
|
if ($inst_ev->getVal('retour') === 't') { |
753 |
|
$instructions_related = $inst_instruction->get_related_instructions(); |
754 |
|
foreach ($instructions_related as $instruction) { |
755 |
|
if ($instruction !== null && $instruction !== '') { |
756 |
|
$inst_related_instruction = $this->f->get_inst__om_dbform(array( |
757 |
|
"obj" => "instruction", |
758 |
|
"idx" => $instruction, |
759 |
|
)); |
760 |
|
$instruction_data = $inst_related_instruction->get_json_data(); |
761 |
|
$val_instruction = $this->sort_instruction_data($instruction_data, $val_instruction); |
762 |
|
if ($instruction_data['om_fichier_instruction'] !== null |
763 |
|
&& $instruction_data['om_fichier_instruction'] !== '') { |
764 |
|
// |
765 |
|
$instruction_with_doc = $inst_related_instruction->getVal($inst_related_instruction->clePrimaire); |
766 |
|
} |
767 |
|
} |
768 |
|
} |
769 |
|
} |
770 |
|
if ($instruction_with_doc !== null) { |
771 |
|
// |
772 |
|
$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; |
776 |
|
} |
777 |
|
|
778 |
|
protected function sort_instruction_data(array $values, array $res) { |
779 |
|
$fields = array( |
780 |
|
"date_envoi_signature", |
781 |
|
"date_retour_signature", |
782 |
|
"date_envoi_rar", |
783 |
|
"date_retour_rar", |
784 |
|
"date_envoi_controle_legalite", |
785 |
|
"date_retour_controle_legalite", |
786 |
|
"signataire_arrete", |
787 |
|
"om_fichier_instruction", |
788 |
|
"tacite", |
789 |
|
"lettretype", |
790 |
|
); |
791 |
|
foreach ($values as $key => $value) { |
792 |
|
if (in_array($key, $fields) === true) { |
793 |
|
if (array_key_exists($key, $res) === false |
794 |
|
&& $value !== null |
795 |
|
&& $value !== '') { |
796 |
|
// |
797 |
|
$res[$key] = $value; |
798 |
|
} elseif ($key === 'tacite' |
799 |
|
&& $value === 't') { |
800 |
|
// |
801 |
|
$res[$key] = $value; |
802 |
|
} |
803 |
|
} |
804 |
|
} |
805 |
|
return $res; |
806 |
|
} |
807 |
|
|
808 |
|
protected function get_document_numerise_data(string $dn) { |
809 |
|
$val_dn = array(); |
810 |
|
$inst_dn = $this->f->get_inst__om_dbform(array( |
811 |
|
"obj" => "document_numerise", |
812 |
|
"idx" => $dn, |
813 |
|
)); |
814 |
|
$val_dn = $inst_dn->get_json_data(); |
815 |
|
$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 |
817 |
|
$val_dn['nature'] = $val_dn['document_numerise_nature_libelle']; |
818 |
|
return $val_dn; |
819 |
|
} |
820 |
|
|
821 |
|
protected function get_parcelles_data(string $object, string $idx) { |
822 |
|
$val_dp = array(); |
823 |
|
$inst_di = $this->f->get_inst__om_dbform(array( |
824 |
|
"obj" => $object, |
825 |
|
"idx" => $idx, |
826 |
|
)); |
827 |
|
$list_parcelles = $inst_di->get_parcelles(); |
828 |
|
$no_ordre = 1; |
829 |
|
foreach ($list_parcelles as $parcelle) { |
830 |
|
$val_dp[$parcelle[$object.'_parcelle']] = array( |
831 |
|
$object.'_parcelle' => $parcelle[$object.'_parcelle'], |
832 |
|
'libelle' => $parcelle['libelle'], |
833 |
|
'no_ordre' => $no_ordre, |
834 |
|
); |
835 |
|
$no_ordre++; |
836 |
|
} |
837 |
|
return $val_dp; |
838 |
|
} |
839 |
|
|
840 |
|
protected function view_form_json($in_field = false) { |
841 |
|
// |
842 |
|
if ($this->f->get_submitted_post_value('valid') === null) { |
843 |
|
// Liste des valeurs à afficher |
844 |
|
$val = array(); |
845 |
|
// |
846 |
|
$val_task = array_combine($this->champs, $this->val); |
847 |
|
foreach ($val_task as $key => $value) { |
848 |
|
$val_task[$key] = strip_tags($value); |
849 |
|
} |
850 |
|
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
851 |
|
$val['task'] = $val_task; |
852 |
|
// |
853 |
|
if ($this->getVal('type') === 'creation_DA') { |
854 |
|
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
855 |
|
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
856 |
|
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
857 |
|
$val_external_uid = array(); |
858 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
859 |
|
$val['external_uids'] = $val_external_uid; |
860 |
|
} |
861 |
|
// |
862 |
|
if ($this->getVal('type') === 'creation_DI' |
863 |
|
|| $this->getVal('type') === 'modification_DI' |
864 |
|
|| $this->getVal('type') === 'depot_DI') { |
865 |
|
// |
866 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
867 |
|
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction'); |
868 |
|
$val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']); |
869 |
|
$architecte = isset($val['donnees_techniques']['architecte']) === true ? $val['donnees_techniques']['architecte'] : null; |
870 |
|
$val['architecte'] = $this->get_architecte_data($architecte); |
871 |
|
$val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']); |
872 |
|
$val_external_uid = array(); |
873 |
|
$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'); |
875 |
|
$val['external_uids'] = $val_external_uid; |
876 |
|
} |
877 |
|
// |
878 |
|
if ($this->getVal('type') === 'qualification_DI') { |
879 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
880 |
|
$val_external_uid = array(); |
881 |
|
$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'); |
883 |
|
$val['external_uids'] = $val_external_uid; |
884 |
|
} |
885 |
|
// |
886 |
|
if ($this->getVal('type') === 'ajout_piece') { |
887 |
|
$val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id')); |
888 |
|
$val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']); |
889 |
|
$val_external_uid = array(); |
890 |
|
$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'); |
892 |
|
$val_external_uid['document_numerise'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'document_numerise'); |
893 |
|
$val['external_uids'] = $val_external_uid; |
894 |
|
} |
895 |
|
// |
896 |
|
if ($this->getVal('type') === 'decision_DI') { |
897 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
898 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier']); |
899 |
|
$val_external_uid = array(); |
900 |
|
$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'); |
902 |
|
$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 |
|
if ($in_field === true) { |
924 |
|
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 |
} |
} |
|
$this->f->displayMessage($message_class, $message); |
|
929 |
} |
} |
930 |
} |
} |
931 |
|
|
932 |
|
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 = ''; |
1005 |
|
if ($type === 'creation_DA') { |
1006 |
|
$objet = 'dossier_autorisation'; |
1007 |
|
} |
1008 |
|
if ($type === 'creation_DI' |
1009 |
|
|| $type === 'create_DI_for_consultation' |
1010 |
|
|| $type === 'depot_DI' |
1011 |
|
|| $type === 'modification_DI' |
1012 |
|
|| $type === 'qualification_DI' |
1013 |
|
|| $type === 'decision_DI' |
1014 |
|
|| $type === 'incompletude_DI' |
1015 |
|
|| $type === 'completude_DI') { |
1016 |
|
// |
1017 |
|
$objet = 'dossier'; |
1018 |
|
} |
1019 |
|
if ($type === 'ajout_piece') { |
1020 |
|
$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; |
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 |
} |
} |