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 |
* |
* |
27 |
"view" => "view_json_data", |
"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()) { |
public function setvalF($val = array()) { |
58 |
"state", |
"state", |
59 |
"object_id", |
"object_id", |
60 |
"dossier", |
"dossier", |
61 |
|
"stream", |
62 |
"json_payload", |
"json_payload", |
63 |
"timestamp_log", |
"timestamp_log", |
64 |
); |
); |
71 |
|
|
72 |
if ($maj < 2) { |
if ($maj < 2) { |
73 |
$form->setType("state", "select"); |
$form->setType("state", "select"); |
74 |
$form->setType("json_payload", "textarea"); |
$form->setType("stream", "select"); |
75 |
|
$form->setType("json_payload", "jsonprettyprint"); |
76 |
} |
} |
77 |
if ($maj == 3){ |
if ($maj == 3){ |
78 |
$form->setType('dossier', 'link'); |
$form->setType('dossier', 'link'); |
86 |
*/ |
*/ |
87 |
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
88 |
if($maj < 2) { |
if($maj < 2) { |
|
$contenu=array(); |
|
89 |
|
|
90 |
$contenu[0][0]="draft"; |
$contenu = array(); |
91 |
$contenu[1][0]=_('draft'); |
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG') as $key) { |
92 |
$contenu[0][1]="new"; |
$const_name = 'STATUS_'.$key; |
93 |
$contenu[1][1]=_('new'); |
$const_value = constant("self::$const_name"); |
94 |
$contenu[0][2]="pending"; |
$contenu[0][] = $const_value; |
95 |
$contenu[1][2]=_('pending'); |
$contenu[1][] = __($const_value); |
96 |
$contenu[0][3]="done"; |
} |
|
$contenu[1][3]=_('done'); |
|
|
$contenu[0][4]="archived"; |
|
|
$contenu[1][4]=_('archived'); |
|
|
$contenu[0][5]="error"; |
|
|
$contenu[1][5]=_('error'); |
|
|
$contenu[0][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 |
|
$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) { |
public function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
153 |
parent::verifier($val, $dnu1, $dnu2); |
$ret = parent::verifier($val, $dnu1, $dnu2); |
154 |
// |
|
155 |
if (array_key_exists('timestamp_log', $this->valF) === true |
if (array_key_exists('timestamp_log', $this->valF) === true |
156 |
&& is_array(json_decode($this->valF['timestamp_log'], true)) === false) { |
&& is_array(json_decode($this->valF['timestamp_log'], true)) === false) { |
157 |
// |
// |
161 |
sprintf('<span class="bold">%s</span>', $this->getLibFromField('timestamp_log')) |
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) { |
279 |
AND object_id = \'%4$s\' |
AND object_id = \'%4$s\' |
280 |
', |
', |
281 |
DB_PREFIXE, |
DB_PREFIXE, |
282 |
'done', |
self::STATUS_DONE, |
283 |
$type, |
$type, |
284 |
$object_id |
$object_id |
285 |
); |
); |
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'] : self::STATUS_NEW, |
392 |
'object_id' => $params['val']['object_id'], |
'object_id' => isset($params['val']['object_id']) ? $params['val']['object_id'] : '', |
393 |
'dossier' => $params['val']['dossier'], |
'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '', |
394 |
); |
'stream' => isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output', |
395 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
396 |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
); |
397 |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
|
398 |
} |
// tâche sortante |
399 |
if ($task_exists !== false) { |
if($valF["stream"] == "output"){ |
400 |
$inst_task = $this->f->get_inst__om_dbform(array( |
|
401 |
"obj" => "task", |
// TODO expliquer ce code |
402 |
"idx" => $task_exists, |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
403 |
)); |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
404 |
$update_state = $inst_task->getVal('state'); |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
405 |
if (isset($params['update_val']['state']) === true) { |
} |
406 |
$update_state = $params['update_val']['state']; |
if ($task_exists !== false) { |
407 |
} |
$inst_task = $this->f->get_inst__om_dbform(array( |
408 |
$update_params = array( |
"obj" => "task", |
409 |
'val' => array( |
"idx" => $task_exists, |
410 |
'state' => $update_state, |
)); |
411 |
), |
$update_state = $inst_task->getVal('state'); |
412 |
); |
if (isset($params['update_val']['state']) === true) { |
413 |
return $inst_task->update_task($update_params); |
$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'), |
'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 |
*/ |
*/ |
838 |
} |
} |
839 |
|
|
840 |
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); |
|
|
} |
|
|
|
|
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') { |
if ($this->getVal('type') === 'incompletude_DI') { |
908 |
$val_external_uid = array(); |
$val_external_uid = array(); |
909 |
$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'); |
910 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
911 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
912 |
} |
} |
913 |
// |
// |
914 |
if ($this->getVal('type') === 'completude_DI') { |
if ($this->getVal('type') === 'completude_DI') { |
917 |
$val_external_uid = array(); |
$val_external_uid = array(); |
918 |
$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'); |
919 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
920 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
921 |
} |
} |
922 |
|
|
923 |
if ($in_field === true) { |
if ($in_field === true) { |
924 |
return json_encode($val, JSON_PRETTY_PRINT ,JSON_UNESCAPED_SLASHES); |
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
925 |
} else { |
} else { |
926 |
// Liste des valeurs affichée en JSON |
// Liste des valeurs affichée en JSON |
927 |
printf(json_encode($val, JSON_UNESCAPED_SLASHES)); |
printf(json_encode($val, JSON_UNESCAPED_SLASHES)); |
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' |
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) { |
function setLayout(&$form, $maj) { |
1030 |
$form->setBloc('json_payload', 'D', '', 'col_6'); |
$form->setBloc('json_payload', 'D', '', 'col_6'); |
1031 |
$form->setFieldset('json_payload', 'DF', _("json_payload"), "collapsible, startClosed"); |
$form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed"); |
1032 |
$form->setBloc('json_payload', 'F'); |
$form->setBloc('json_payload', 'F'); |
1033 |
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
1034 |
} |
} |