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()) { |
public function setvalF($val = array()) { |
50 |
"state", |
"state", |
51 |
"object_id", |
"object_id", |
52 |
"dossier", |
"dossier", |
53 |
|
"stream", |
54 |
"json_payload", |
"json_payload", |
55 |
"timestamp_log", |
"timestamp_log", |
56 |
); |
); |
63 |
|
|
64 |
if ($maj < 2) { |
if ($maj < 2) { |
65 |
$form->setType("state", "select"); |
$form->setType("state", "select"); |
66 |
$form->setType("json_payload", "textarea"); |
$form->setType("stream", "select"); |
67 |
|
$form->setType("json_payload", "jsonprettyprint"); |
68 |
} |
} |
69 |
if ($maj == 3){ |
if ($maj == 3){ |
70 |
$form->setType('dossier', 'link'); |
$form->setType('dossier', 'link'); |
96 |
$contenu[1][6]=_('debug'); |
$contenu[1][6]=_('debug'); |
97 |
|
|
98 |
$form->setSelect("state", $contenu); |
$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) { |
if ($maj == 3) { |
110 |
$inst_dossier = $this->f->get_inst__om_dbform(array( |
if ($this->getVal('stream') == 'output') { |
111 |
"obj" => "dossier", |
$inst_dossier = $this->f->get_inst__om_dbform(array( |
112 |
"idx" => $form->val['dossier'], |
"obj" => "dossier", |
113 |
)); |
"idx" => $form->val['dossier'], |
114 |
|
)); |
115 |
if($form->val['type'] == "creation_DA"){ |
|
116 |
$obj_link = 'dossier_autorisation'; |
if($form->val['type'] == "creation_DA"){ |
117 |
} else { |
$obj_link = 'dossier_autorisation'; |
118 |
$obj_link = 'dossier_instruction'; |
} else { |
119 |
} |
$obj_link = 'dossier_instruction'; |
120 |
|
} |
121 |
|
|
122 |
$params = array(); |
$params = array(); |
123 |
$params['obj'] = $obj_link; |
$params['obj'] = $obj_link; |
124 |
$params['libelle'] = $inst_dossier->getVal('dossier'); |
$params['libelle'] = $inst_dossier->getVal('dossier'); |
125 |
$params['title'] = "Consulter le dossier"; |
$params['title'] = "Consulter le dossier"; |
126 |
$params['idx'] = $form->val['dossier']; |
$params['idx'] = $form->val['dossier']; |
127 |
$form->setSelect("dossier", $params); |
$form->setSelect("dossier", $params); |
128 |
|
} |
129 |
} |
} |
130 |
} |
} |
131 |
|
|
137 |
function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) { |
function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) { |
138 |
// parent::setVal($form, $maj, $validation); |
// parent::setVal($form, $maj, $validation); |
139 |
// |
// |
140 |
$form->setVal('json_payload', $this->view_form_json(true)); |
if ($this->getVal('stream') == "output") { |
141 |
|
$form->setVal('json_payload', $this->view_form_json(true)); |
142 |
|
} else { |
143 |
|
if ($this->getVal('type') == 'ajout_piece'){ |
144 |
|
// On modifie la valeur du champ "file_content" afin de tronquer le base64 |
145 |
|
$json_payload = json_decode($this->getVal("json_payload"), true); |
146 |
|
$json_payload["document_numerise"]["file_content"] = substr($json_payload["document_numerise"]["file_content"], 0, 64)."[...]"; |
147 |
|
$json_payload_result = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); |
148 |
|
$form->setVal('json_payload', htmlentities($json_payload_result)); |
149 |
|
} else { |
150 |
|
// |
151 |
|
$form->setVal('json_payload', htmlentities($this->getVal('json_payload'))); |
152 |
|
} |
153 |
|
} |
154 |
|
} |
155 |
|
|
156 |
|
function setLib(&$form, $maj) { |
157 |
|
parent::setLib($form, $maj); |
158 |
|
$form->setLib('json_payload', ''); |
159 |
} |
} |
160 |
|
|
161 |
public function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
public function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
162 |
parent::verifier($val, $dnu1, $dnu2); |
$ret = parent::verifier($val, $dnu1, $dnu2); |
163 |
// |
|
164 |
if (array_key_exists('timestamp_log', $this->valF) === true |
if (array_key_exists('timestamp_log', $this->valF) === true |
165 |
&& is_array(json_decode($this->valF['timestamp_log'], true)) === false) { |
&& is_array(json_decode($this->valF['timestamp_log'], true)) === false) { |
166 |
// |
// |
170 |
sprintf('<span class="bold">%s</span>', $this->getLibFromField('timestamp_log')) |
sprintf('<span class="bold">%s</span>', $this->getLibFromField('timestamp_log')) |
171 |
)); |
)); |
172 |
} |
} |
173 |
|
|
174 |
|
// une tâche entrante doit avoir un type et une payload non-vide |
175 |
|
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
176 |
|
if (isset($this->valF['type']) === false) { |
177 |
|
$this->correct = false; |
178 |
|
$this->addToMessage(sprintf( |
179 |
|
__("Le champ %s est obligatoire pour une tâche entrante."), |
180 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('type')) |
181 |
|
)); |
182 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
183 |
|
} |
184 |
|
if (isset($this->valF['json_payload']) === false) { |
185 |
|
$this->correct = false; |
186 |
|
$this->addToMessage(sprintf( |
187 |
|
__("Le champ %s est obligatoire pour une tâche entrante."), |
188 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
189 |
|
)); |
190 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
191 |
|
} |
192 |
|
} |
193 |
|
|
194 |
|
// le JSON doit être décodable |
195 |
|
if (isset($this->valF['json_payload']) && ! empty($this->valF['json_payload']) && ( |
196 |
|
is_array(json_decode($this->valF['json_payload'], true)) === false |
197 |
|
|| json_last_error() !== JSON_ERROR_NONE)) { |
198 |
|
$this->correct = false; |
199 |
|
$this->addToMessage(sprintf( |
200 |
|
__("Le champ %s doit être dans un format JSON valide (erreur: %s)."), |
201 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload'), |
202 |
|
json_last_error() !== JSON_ERROR_NONE ? json_last_error_msg() : __('invalide')) |
203 |
|
)); |
204 |
|
$this->addToLog(__METHOD__.'(): erreur JSON: '.$this->msg, DEBUG_MODE); |
205 |
|
} |
206 |
|
|
207 |
|
// une tâche entrante doit avoir une payload avec les clés requises |
208 |
|
elseif (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
209 |
|
|
210 |
|
// décode la payload JSON |
211 |
|
$json_payload = json_decode($this->valF['json_payload'], true); |
212 |
|
|
213 |
|
// défini une liste de chemin de clés requises |
214 |
|
$paths = array( |
215 |
|
'dossier/dossier' |
216 |
|
); |
217 |
|
|
218 |
|
// tâche de type création de DI/DA |
219 |
|
if (isset($this->valF['type']) !== false && $this->valF['type'] == 'create_DI_for_consultation') { |
220 |
|
|
221 |
|
$paths = array_merge($paths, array( |
222 |
|
'dossier/dossier_autorisation_type_detaille_code', |
223 |
|
'dossier/date_demande', |
224 |
|
'dossier/depot_electronique', |
225 |
|
)); |
226 |
|
|
227 |
|
// si l'option commune est activée (mode MC) |
228 |
|
if ($this->f->is_option_dossier_commune_enabled()) { |
229 |
|
$paths[] = 'dossier/insee'; |
230 |
|
} |
231 |
|
|
232 |
|
// présence d'un moyen d'identifier la collectivité/le service |
233 |
|
if (! isset($json_payload['dossier']['acteur']) && |
234 |
|
! isset($json_payload['dossier']['om_collectivite'])) { |
235 |
|
$this->correct = false; |
236 |
|
$this->addToMessage(sprintf( |
237 |
|
__("L'une des clés %s ou %s est obligatoire dans le contenu du champ %s pour une tâche entrante."), |
238 |
|
sprintf('<span class="bold">%s</span>', 'dossier/acteur'), |
239 |
|
sprintf('<span class="bold">%s</span>', 'dossier/om_collectivite'), |
240 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
241 |
|
)); |
242 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
243 |
|
} |
244 |
|
} |
245 |
|
|
246 |
|
// pas d'erreur déjà trouvée |
247 |
|
if($this->correct) { |
248 |
|
|
249 |
|
// pour chaque chemin |
250 |
|
foreach($paths as $path) { |
251 |
|
|
252 |
|
// décompose le chemin |
253 |
|
$tokens = explode('/', $path); |
254 |
|
$cur_depth = $json_payload; |
255 |
|
|
256 |
|
// descend au et à mesure dans l'arborescence du chemin |
257 |
|
foreach($tokens as $token) { |
258 |
|
|
259 |
|
// en vérifiant que chaque élément du chemin est défini et non-nul |
260 |
|
if (isset($cur_depth[$token]) === false) { |
261 |
|
|
262 |
|
// sinon on produit une erreur |
263 |
|
$this->correct = false; |
264 |
|
$this->addToMessage(sprintf( |
265 |
|
__("La clé %s est obligatoire dans le contenu du champ %s pour une tâche entrante."), |
266 |
|
sprintf('<span class="bold">%s</span>', $path), |
267 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
268 |
|
)); |
269 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
270 |
|
break 2; |
271 |
|
} |
272 |
|
$cur_depth = $cur_depth[$token]; |
273 |
|
} |
274 |
|
} |
275 |
|
} |
276 |
|
} |
277 |
|
|
278 |
|
return $ret && $this->correct; |
279 |
} |
} |
280 |
|
|
281 |
protected function task_exists(string $type, string $object_id) { |
protected function task_exists(string $type, string $object_id) { |
299 |
} |
} |
300 |
|
|
301 |
/** |
/** |
302 |
|
* TRIGGER - triggerajouter. |
303 |
|
* |
304 |
|
* @param string $id |
305 |
|
* @param null &$dnu1 @deprecated Ne pas utiliser. |
306 |
|
* @param array $val Tableau des valeurs brutes. |
307 |
|
* @param null $dnu2 @deprecated Ne pas utiliser. |
308 |
|
* |
309 |
|
* @return boolean |
310 |
|
*/ |
311 |
|
function triggerajouter($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
312 |
|
|
313 |
|
// tâche entrante |
314 |
|
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
315 |
|
|
316 |
|
// décode la paylod JSON pour extraire les données métiers à ajouter |
317 |
|
// en tant que métadonnées de la tâche |
318 |
|
$json_payload = json_decode($this->valF['json_payload'], true); |
319 |
|
$this->valF["dossier"] = $json_payload['dossier']['dossier']; |
320 |
|
} |
321 |
|
} |
322 |
|
|
323 |
|
/** |
324 |
* TREATMENT - add_task |
* TREATMENT - add_task |
325 |
* Ajoute un enregistrement. |
* Ajoute un enregistrement. |
326 |
* |
* |
332 |
$timestamp_log = json_encode(array( |
$timestamp_log = json_encode(array( |
333 |
'creation_date' => date('Y-m-d H:i:s'), |
'creation_date' => date('Y-m-d H:i:s'), |
334 |
)); |
)); |
335 |
|
|
336 |
|
// Si la tâche est de type ajout_piece et de stream input alors on ajoute le fichier |
337 |
|
// et on ajoute l'uid dans le champ json_payload avant l'ajout de la tâche |
338 |
|
if (isset($params['val']['type']) |
339 |
|
&& $params['val']['type'] == "ajout_piece" |
340 |
|
&& isset($params['val']['stream']) |
341 |
|
&& $params['val']['stream'] == "input" ) { |
342 |
|
// |
343 |
|
$json_payload = json_decode($params['val']['json_payload'], true); |
344 |
|
$document_numerise = $json_payload['document_numerise']; |
345 |
|
$file_content = base64_decode($document_numerise["file_content"]); |
346 |
|
if ($file_content === false){ |
347 |
|
$this->addToMessage(__("Le contenu du fichier lié à la tâche n'a pas pu etre recupere.")); |
348 |
|
return $this->end_treatment(__METHOD__, false); |
349 |
|
} |
350 |
|
$metadata = array( |
351 |
|
"filename" => $document_numerise['nom_fichier'], |
352 |
|
"size" => strlen($file_content), |
353 |
|
"mimetype" => $document_numerise['file_content_type'], |
354 |
|
"date_creation" => $document_numerise['date_creation'], |
355 |
|
); |
356 |
|
$uid_fichier = $this->f->storage->create($file_content, $metadata, "from_content"); |
357 |
|
if ($uid_fichier === OP_FAILURE) { |
358 |
|
$this->addToMessage(__("Erreur lors de la creation du fichier lié à la tâche.")); |
359 |
|
return $this->end_treatment(__METHOD__, false); |
360 |
|
} |
361 |
|
$json_payload["document_numerise"]["uid"] = $uid_fichier; |
362 |
|
$params['val']['json_payload'] = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
363 |
|
} |
364 |
|
|
365 |
// Mise à jour du DI |
// Mise à jour du DI |
366 |
$valF = array( |
$valF = array( |
367 |
'task' => '', |
'task' => '', |
368 |
'type' => $params['val']['type'], |
'type' => $params['val']['type'], |
369 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
370 |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : 'new', |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : 'new', |
371 |
'object_id' => $params['val']['object_id'], |
'object_id' => isset($params['val']['object_id']) ? $params['val']['object_id'] : '', |
372 |
'dossier' => $params['val']['dossier'], |
'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '', |
373 |
'json_payload' => '{}', |
'stream' => isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output', |
374 |
); |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
375 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
); |
376 |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
|
377 |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
// tâche sortante |
378 |
} |
if($valF["stream"] == "output"){ |
379 |
if ($task_exists !== false) { |
|
380 |
$inst_task = $this->f->get_inst__om_dbform(array( |
// TODO expliquer ce code |
381 |
"obj" => "task", |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
382 |
"idx" => $task_exists, |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
383 |
)); |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
384 |
$update_state = $inst_task->getVal('state'); |
} |
385 |
if (isset($params['update_val']['state']) === true) { |
if ($task_exists !== false) { |
386 |
$update_state = $params['update_val']['state']; |
$inst_task = $this->f->get_inst__om_dbform(array( |
387 |
} |
"obj" => "task", |
388 |
$update_params = array( |
"idx" => $task_exists, |
389 |
'val' => array( |
)); |
390 |
'state' => $update_state, |
$update_state = $inst_task->getVal('state'); |
391 |
), |
if (isset($params['update_val']['state']) === true) { |
392 |
); |
$update_state = $params['update_val']['state']; |
393 |
return $inst_task->update_task($update_params); |
} |
394 |
|
$update_params = array( |
395 |
|
'val' => array( |
396 |
|
'state' => $update_state, |
397 |
|
), |
398 |
|
); |
399 |
|
return $inst_task->update_task($update_params); |
400 |
|
} |
401 |
} |
} |
402 |
|
|
403 |
$add = $this->ajouter($valF); |
$add = $this->ajouter($valF); |
404 |
|
$this->addToLog(__METHOD__."(): retour de l'ajout de tâche: ".var_export($add, true), DEBUG_MODE); |
405 |
if ($add === false) { |
if ($add === false) { |
406 |
$this->addToLog($this->msg, DEBUG_MODE); |
$this->addToLog(__METHOD__."(): ".$this->msg, DEBUG_MODE); |
407 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
408 |
} |
} |
409 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
435 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
436 |
'state' => $params['val']['state'], |
'state' => $params['val']['state'], |
437 |
'object_id' => $this->getVal('object_id'), |
'object_id' => $this->getVal('object_id'), |
438 |
|
'stream' => $this->getVal('stream'), |
439 |
'dossier' => $this->getVal('dossier'), |
'dossier' => $this->getVal('dossier'), |
440 |
'json_payload' => $this->getVal('json_payload'), |
'json_payload' => $this->getVal('json_payload'), |
441 |
); |
); |
450 |
/** |
/** |
451 |
* 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 |
452 |
* l'enregistrement instancié. |
* l'enregistrement instancié. |
453 |
* |
* |
454 |
* @param array $params Tableau des paramètres |
* @param array $params Tableau des paramètres |
455 |
* @return array sinon false en cas d'erreur |
* @return array sinon false en cas d'erreur |
456 |
*/ |
*/ |
817 |
} |
} |
818 |
|
|
819 |
protected function view_form_json($in_field = false) { |
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); |
|
|
} |
|
|
|
|
820 |
// |
// |
821 |
if ($this->f->get_submitted_post_value('valid') === null) { |
if ($this->f->get_submitted_post_value('valid') === null) { |
822 |
// Liste des valeurs à afficher |
// Liste des valeurs à afficher |
835 |
$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']); |
836 |
$val_external_uid = array(); |
$val_external_uid = array(); |
837 |
$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'); |
838 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
839 |
} |
} |
840 |
// |
// |
841 |
if ($this->getVal('type') === 'creation_DI' |
if ($this->getVal('type') === 'creation_DI' |
851 |
$val_external_uid = array(); |
$val_external_uid = array(); |
852 |
$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'); |
853 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
854 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
855 |
} |
} |
856 |
// |
// |
857 |
if ($this->getVal('type') === 'qualification_DI') { |
if ($this->getVal('type') === 'qualification_DI') { |
859 |
$val_external_uid = array(); |
$val_external_uid = array(); |
860 |
$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'); |
861 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
862 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
863 |
} |
} |
864 |
// |
// |
865 |
if ($this->getVal('type') === 'ajout_piece') { |
if ($this->getVal('type') === 'ajout_piece') { |
869 |
$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'); |
870 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
871 |
$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'); |
872 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
873 |
} |
} |
874 |
// |
// |
875 |
if ($this->getVal('type') === 'decision_DI') { |
if ($this->getVal('type') === 'decision_DI') { |
878 |
$val_external_uid = array(); |
$val_external_uid = array(); |
879 |
$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'); |
880 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
881 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
882 |
} |
} |
883 |
// |
// |
884 |
if ($this->getVal('type') === 'incompletude_DI') { |
if ($this->getVal('type') === 'incompletude_DI') { |
887 |
$val_external_uid = array(); |
$val_external_uid = array(); |
888 |
$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'); |
889 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
890 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
891 |
} |
} |
892 |
// |
// |
893 |
if ($this->getVal('type') === 'completude_DI') { |
if ($this->getVal('type') === 'completude_DI') { |
896 |
$val_external_uid = array(); |
$val_external_uid = array(); |
897 |
$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'); |
898 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
899 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
900 |
} |
} |
901 |
|
|
902 |
if ($in_field === true) { |
if ($in_field === true) { |
903 |
return json_encode($val, JSON_PRETTY_PRINT ,JSON_UNESCAPED_SLASHES); |
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
904 |
} else { |
} else { |
905 |
// Liste des valeurs affichée en JSON |
// Liste des valeurs affichée en JSON |
906 |
printf(json_encode($val, JSON_UNESCAPED_SLASHES)); |
printf(json_encode($val, JSON_UNESCAPED_SLASHES)); |
908 |
} |
} |
909 |
} |
} |
910 |
|
|
911 |
protected function get_lien_objet_by_type($type) { |
function post_update_task() { |
912 |
|
// Mise à jour des valeurs |
913 |
|
// |
914 |
|
$params = array( |
915 |
|
'val' => array( |
916 |
|
'state' => $this->f->get_submitted_post_value('state') |
917 |
|
), |
918 |
|
); |
919 |
|
$update = $this->update_task($params); |
920 |
|
$message_class = "valid"; |
921 |
|
$message = $this->msg; |
922 |
|
if ($update === false) { |
923 |
|
$this->addToLog($this->msg, DEBUG_MODE); |
924 |
|
$message_class = "error"; |
925 |
|
$message = sprintf( |
926 |
|
'%s %s', |
927 |
|
__('Impossible de mettre à jour la tâche.'), |
928 |
|
__('Veuillez contacter votre administrateur.') |
929 |
|
); |
930 |
|
} |
931 |
|
$this->f->displayMessage($message_class, $message); |
932 |
|
// |
933 |
|
$inst_lien = $this->f->get_inst__om_dbform(array( |
934 |
|
"obj" => "lien_id_interne_uid_externe", |
935 |
|
"idx" => ']', |
936 |
|
)); |
937 |
|
$valF = array( |
938 |
|
'lien_id_interne_uid_externe' => '', |
939 |
|
'object' => $this->get_lien_objet_by_type($this->getVal('type')), |
940 |
|
'object_id' => $this->getVal('object_id'), |
941 |
|
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
942 |
|
); |
943 |
|
$add = $inst_lien->ajouter($valF); |
944 |
|
$message_class = "valid"; |
945 |
|
$message = $inst_lien->msg; |
946 |
|
if ($add === false) { |
947 |
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
948 |
|
$message_class = "error"; |
949 |
|
$message = sprintf( |
950 |
|
'%s %s', |
951 |
|
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
952 |
|
__('Veuillez contacter votre administrateur.') |
953 |
|
); |
954 |
|
} |
955 |
|
$this->f->displayMessage($message_class, $message); |
956 |
|
} |
957 |
|
|
958 |
|
function post_add_task() { |
959 |
|
// TODO Tester de remplacer la ligne de json_payload par un $_POST |
960 |
|
$result = $this->add_task(array( |
961 |
|
'val' => array( |
962 |
|
'stream' => 'input', |
963 |
|
'json_payload' => html_entity_decode($this->f->get_submitted_post_value('json_payload')), |
964 |
|
'type' => $this->f->get_submitted_post_value('type'), |
965 |
|
) |
966 |
|
)); |
967 |
|
$message = $this->msg; |
968 |
|
$message_class = "valid"; |
969 |
|
if ($result === false){ |
970 |
|
$this->addToLog($this->msg, DEBUG_MODE); |
971 |
|
$message_class = "error"; |
972 |
|
$message = sprintf( |
973 |
|
'%s %s', |
974 |
|
__('Impossible d\'ajouter la tâche.'), |
975 |
|
__('Veuillez contacter votre administrateur.') |
976 |
|
); |
977 |
|
} |
978 |
|
$this->f->displayMessage($message_class, $message); |
979 |
|
} |
980 |
|
|
981 |
|
function get_lien_objet_by_type($type) { |
982 |
// |
// |
983 |
$objet = ''; |
$objet = ''; |
984 |
if ($type === 'creation_DA') { |
if ($type === 'creation_DA') { |
985 |
$objet = 'dossier_autorisation'; |
$objet = 'dossier_autorisation'; |
986 |
} |
} |
987 |
if ($type === 'creation_DI' |
if ($type === 'creation_DI' |
988 |
|
|| $type === 'create_DI_for_consultation' |
989 |
|| $type === 'depot_DI' |
|| $type === 'depot_DI' |
990 |
|| $type === 'modification_DI' |
|| $type === 'modification_DI' |
991 |
|| $type === 'qualification_DI' |
|| $type === 'qualification_DI' |
1003 |
|
|
1004 |
function setLayout(&$form, $maj) { |
function setLayout(&$form, $maj) { |
1005 |
$form->setBloc('json_payload', 'D', '', 'col_6'); |
$form->setBloc('json_payload', 'D', '', 'col_6'); |
1006 |
$form->setFieldset('json_payload', 'DF', _("json_payload"), "collapsible, startClosed"); |
$form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed"); |
1007 |
$form->setBloc('json_payload', 'F'); |
$form->setBloc('json_payload', 'F'); |
1008 |
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
1009 |
} |
} |