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 |
|
const STATUS_CANCELED = 'canceled'; |
17 |
|
|
18 |
|
/** |
19 |
|
* Liste des types de tâche concernant les services instructeurs |
20 |
|
*/ |
21 |
|
const TASK_TYPE_SI = array( |
22 |
|
'creation_DA', |
23 |
|
'creation_DI', |
24 |
|
'depot_DI', |
25 |
|
'modification_DI', |
26 |
|
'qualification_DI', |
27 |
|
'decision_DI', |
28 |
|
'incompletude_DI', |
29 |
|
'completude_DI', |
30 |
|
'ajout_piece', |
31 |
|
'add_piece', |
32 |
|
'creation_consultation', |
33 |
|
'modification_DA', |
34 |
|
'create_DI', |
35 |
|
'notification_recepisse', |
36 |
|
'notification_instruction', |
37 |
|
'notification_decision', |
38 |
|
); |
39 |
|
|
40 |
|
/** |
41 |
|
* Liste des types de tâche concernant les services consultés |
42 |
|
*/ |
43 |
|
const TASK_TYPE_SC = array( |
44 |
|
'create_DI_for_consultation', |
45 |
|
'avis_consultation', |
46 |
|
'pec_metier_consultation', |
47 |
|
'create_message', |
48 |
|
'notification_recepisse', |
49 |
|
'notification_instruction', |
50 |
|
'notification_decision', |
51 |
|
'prescription', |
52 |
|
); |
53 |
|
|
54 |
|
/** |
55 |
|
* Catégorie de la tâche |
56 |
|
*/ |
57 |
|
var $category = 'platau'; |
58 |
|
|
59 |
/** |
/** |
60 |
* Définition des actions disponibles sur la classe. |
* Définition des actions disponibles sur la classe. |
61 |
* |
* |
69 |
"view" => "view_json_data", |
"view" => "view_json_data", |
70 |
"permission_suffix" => "consulter", |
"permission_suffix" => "consulter", |
71 |
); |
); |
72 |
|
$this->class_actions[997] = array( |
73 |
|
"identifier" => "json_data", |
74 |
|
"view" => "post_update_task", |
75 |
|
"permission_suffix" => "modifier", |
76 |
|
); |
77 |
|
$this->class_actions[996] = array( |
78 |
|
"identifier" => "json_data", |
79 |
|
"view" => "post_add_task", |
80 |
|
"permission_suffix" => "ajouter", |
81 |
|
); |
82 |
|
} |
83 |
|
|
84 |
|
public function setvalF($val = array()) { |
85 |
|
|
86 |
|
// // les guillets doubles sont remplacés automatiquement par des simples |
87 |
|
// // dans core/om_formulaire.clasS.php::recupererPostvar() |
88 |
|
// // voir le ticket https://dev.atreal.fr/projets/openmairie/tracker/209 |
89 |
|
// // ceci est un hack sale temporaire en attendant résolution du ticket |
90 |
|
// foreach(array('json_payload', 'timestamp_log') as $key) { |
91 |
|
// if (isset($val[$key]) && ! empty($val[$key]) && |
92 |
|
// isset($_POST[$key]) && ! empty($_POST[$key])) { |
93 |
|
// $submited_payload = $_POST[$key]; |
94 |
|
// if (! empty($submited_payload)) { |
95 |
|
// $new_payload = str_replace("'", '"', $val[$key]); |
96 |
|
// if ($new_payload == $submited_payload || |
97 |
|
// strpos($submited_payload, '"') === false) { |
98 |
|
// $val[$key] = $new_payload; |
99 |
|
// } |
100 |
|
// else { |
101 |
|
// $error_msg = sprintf( |
102 |
|
// __("La convertion des guillemets de la payload JSON '%s' ". |
103 |
|
// "n'est pas idempotente (courante: %s, postée: %s, convertie: %s)"), |
104 |
|
// $key, var_export($val[$key], true), var_export($submited_payload, true), |
105 |
|
// var_export($new_payload, true)); |
106 |
|
// $this->correct = false; |
107 |
|
// $this->addToMessage($error_msg); |
108 |
|
// $this->addToLog(__METHOD__."() erreur : $error_msg", DEBUG_MODE); |
109 |
|
// return false; |
110 |
|
// } |
111 |
|
// } |
112 |
|
// } |
113 |
|
// } |
114 |
|
|
115 |
|
parent::setvalF($val); |
116 |
|
|
117 |
|
// XXX Ancien code : permet de ne pas avoir d'erreru lors de la modification d'une task |
118 |
|
if (array_key_exists('timestamp_log', $val) === true) { |
119 |
|
$this->valF['timestamp_log'] = str_replace("'", '"', $val['timestamp_log']); |
120 |
|
} |
121 |
|
|
122 |
|
// récupération de l'ID de l'objet existant |
123 |
|
$id = property_exists($this, 'id') ? $this->id : null; |
124 |
|
if(isset($val[$this->clePrimaire])) { |
125 |
|
$id = $val[$this->clePrimaire]; |
126 |
|
} elseif(isset($this->valF[$this->clePrimaire])) { |
127 |
|
$id = $this->valF[$this->clePrimaire]; |
128 |
|
} |
129 |
|
|
130 |
|
// MODE MODIFIER |
131 |
|
if (! empty($id)) { |
132 |
|
|
133 |
|
// si aucune payload n'est fourni (devrait toujours être le cas) |
134 |
|
if (! isset($val['json_payload']) || empty($val['json_payload'])) { |
135 |
|
|
136 |
|
// récupère l'objet existant |
137 |
|
$existing = $this->f->findObjectById('task', $id); |
138 |
|
if (! empty($existing)) { |
139 |
|
|
140 |
|
// récupère la payload de l'objet |
141 |
|
$val['json_payload'] = $existing->getVal('json_payload'); |
142 |
|
$this->valF['json_payload'] = $existing->getVal('json_payload'); |
143 |
|
$this->f->addToLog(__METHOD__."() récupère la payload de la tâche existante ". |
144 |
|
"'$id': ".$existing->getVal('json_payload'), EXTRA_VERBOSE_MODE); |
145 |
|
} |
146 |
|
} |
147 |
|
} |
148 |
|
|
149 |
|
if (array_key_exists('category', $val) === false |
150 |
|
|| $this->valF['category'] === '' |
151 |
|
|| $this->valF['category'] === null) { |
152 |
|
// |
153 |
|
$this->valF['category'] = $this->category; |
154 |
|
} |
155 |
|
} |
156 |
|
|
157 |
|
/** |
158 |
|
* |
159 |
|
* @return array |
160 |
|
*/ |
161 |
|
function get_var_sql_forminc__champs() { |
162 |
|
return array( |
163 |
|
"task", |
164 |
|
"type", |
165 |
|
"state", |
166 |
|
"object_id", |
167 |
|
"dossier", |
168 |
|
"stream", |
169 |
|
"json_payload", |
170 |
|
"timestamp_log", |
171 |
|
"category", |
172 |
|
); |
173 |
|
} |
174 |
|
|
175 |
|
function setType(&$form, $maj) { |
176 |
|
parent::setType($form, $maj); |
177 |
|
|
178 |
|
// Récupération du mode de l'action |
179 |
|
$crud = $this->get_action_crud($maj); |
180 |
|
|
181 |
|
// ALL |
182 |
|
$form->setType("category", "hidden"); |
183 |
|
|
184 |
|
// MODE CREER |
185 |
|
if ($maj == 0 || $crud == 'create') { |
186 |
|
$form->setType("state", "select"); |
187 |
|
$form->setType("stream", "select"); |
188 |
|
$form->setType("json_payload", "textarea"); |
189 |
|
} |
190 |
|
// MDOE MODIFIER |
191 |
|
if ($maj == 1 || $crud == 'update') { |
192 |
|
$form->setType("state", "select"); |
193 |
|
$form->setType("stream", "select"); |
194 |
|
$form->setType("json_payload", "jsonprettyprint"); |
195 |
|
} |
196 |
|
// MODE CONSULTER |
197 |
|
if ($maj == 3 || $crud == 'read') { |
198 |
|
$form->setType('dossier', 'link'); |
199 |
|
$form->setType('json_payload', 'jsonprettyprint'); |
200 |
|
} |
201 |
|
|
202 |
|
} |
203 |
|
|
204 |
|
/** |
205 |
|
* |
206 |
|
*/ |
207 |
|
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
208 |
|
if($maj < 2) { |
209 |
|
|
210 |
|
$contenu = array(); |
211 |
|
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG', 'ARCHIVED', 'CANCELED') as $key) { |
212 |
|
$const_name = 'STATUS_'.$key; |
213 |
|
$const_value = constant("self::$const_name"); |
214 |
|
$contenu[0][] = $const_value; |
215 |
|
$contenu[1][] = __($const_value); |
216 |
|
} |
217 |
|
|
218 |
|
$form->setSelect("state", $contenu); |
219 |
|
|
220 |
|
$contenu_stream =array(); |
221 |
|
$contenu_stream[0][0]="input"; |
222 |
|
$contenu_stream[1][0]=_('input'); |
223 |
|
$contenu_stream[0][1]="output"; |
224 |
|
$contenu_stream[1][1]=_('output'); |
225 |
|
$form->setSelect("stream", $contenu_stream); |
226 |
|
|
227 |
|
} |
228 |
|
|
229 |
|
if ($maj == 3) { |
230 |
|
if ($this->getVal('stream') == 'output') { |
231 |
|
$inst_dossier = $this->f->get_inst__om_dbform(array( |
232 |
|
"obj" => "dossier", |
233 |
|
"idx" => $form->val['dossier'], |
234 |
|
)); |
235 |
|
|
236 |
|
if($form->val['type'] == "creation_DA" |
237 |
|
|| $form->val['type'] == "modification_DA"){ |
238 |
|
// |
239 |
|
$obj_link = 'dossier_autorisation'; |
240 |
|
} else { |
241 |
|
$obj_link = 'dossier_instruction'; |
242 |
|
} |
243 |
|
|
244 |
|
$params = array(); |
245 |
|
$params['obj'] = $obj_link; |
246 |
|
$params['libelle'] = $inst_dossier->getVal('dossier'); |
247 |
|
$params['title'] = "Consulter le dossier"; |
248 |
|
$params['idx'] = $form->val['dossier']; |
249 |
|
$form->setSelect("dossier", $params); |
250 |
|
} |
251 |
|
} |
252 |
|
} |
253 |
|
|
254 |
|
/** |
255 |
|
* SETTER_FORM - setVal (setVal). |
256 |
|
* |
257 |
|
* @return void |
258 |
|
*/ |
259 |
|
function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) { |
260 |
|
// parent::setVal($form, $maj, $validation); |
261 |
|
// |
262 |
|
if ($this->getVal('stream') == "output") { |
263 |
|
$form->setVal('json_payload', $this->view_form_json(true)); |
264 |
|
} else { |
265 |
|
$form->setVal('json_payload', htmlentities($this->getVal('json_payload'))); |
266 |
|
} |
267 |
|
} |
268 |
|
|
269 |
|
function setLib(&$form, $maj) { |
270 |
|
parent::setLib($form, $maj); |
271 |
|
|
272 |
|
// Récupération du mode de l'action |
273 |
|
$crud = $this->get_action_crud($maj); |
274 |
|
|
275 |
|
// MODE different de CREER |
276 |
|
if ($maj != 0 || $crud != 'create') { |
277 |
|
$form->setLib('json_payload', ''); |
278 |
|
} |
279 |
|
} |
280 |
|
|
281 |
|
public function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
282 |
|
$ret = parent::verifier($val, $dnu1, $dnu2); |
283 |
|
|
284 |
|
// une tâche entrante doit avoir un type et une payload non-vide |
285 |
|
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
286 |
|
if (isset($this->valF['type']) === false) { |
287 |
|
$this->correct = false; |
288 |
|
$this->addToMessage(sprintf( |
289 |
|
__("Le champ %s est obligatoire pour une tâche entrante."), |
290 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('type')) |
291 |
|
)); |
292 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
293 |
|
} |
294 |
|
if (isset($this->valF['json_payload']) === false) { |
295 |
|
$this->correct = false; |
296 |
|
$this->addToMessage(sprintf( |
297 |
|
__("Le champ %s est obligatoire pour une tâche entrante."), |
298 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
299 |
|
)); |
300 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
301 |
|
} |
302 |
|
} |
303 |
|
|
304 |
|
// les JSONs doivent être décodables |
305 |
|
foreach(array('json_payload', 'timestamp_log') as $key) { |
306 |
|
if (isset($this->valF[$key]) && ! empty($this->valF[$key]) && ( |
307 |
|
is_array(json_decode($this->valF[$key], true)) === false |
308 |
|
|| json_last_error() !== JSON_ERROR_NONE)) { |
309 |
|
$this->correct = false; |
310 |
|
$champ_text = sprintf('<span class="bold">%s</span>', $this->getLibFromField($key)); |
311 |
|
$this->addToMessage(sprintf( |
312 |
|
__("Le champ %s doit être dans un format JSON valide (erreur: %s).". |
313 |
|
"<p>%s valF:</br><pre>%s</pre></p>". |
314 |
|
"<p>%s val:</br><pre>%s</pre></p>". |
315 |
|
"<p>%s POST:</br><pre>%s</pre></p>". |
316 |
|
"<p>%s submitted POST value:</br><pre>%s</pre></p>"), |
317 |
|
$champ_text, |
318 |
|
json_last_error() !== JSON_ERROR_NONE ? json_last_error_msg() : __('invalide'), |
319 |
|
$champ_text, |
320 |
|
$this->valF[$key], |
321 |
|
$champ_text, |
322 |
|
$val[$key], |
323 |
|
$champ_text, |
324 |
|
isset($_POST[$key]) ? $_POST[$key] : '', |
325 |
|
$champ_text, |
326 |
|
$this->f->get_submitted_post_value($key) |
327 |
|
)); |
328 |
|
$this->addToLog(__METHOD__.'(): erreur JSON: '.$this->msg, DEBUG_MODE); |
329 |
|
} |
330 |
|
} |
331 |
|
|
332 |
|
// une tâche entrante doit avoir une payload avec les clés requises |
333 |
|
if ($this->correct && (isset($this->valF['stream']) === false || |
334 |
|
$this->valF['stream'] == 'input')) { |
335 |
|
|
336 |
|
// décode la payload JSON |
337 |
|
$json_payload = json_decode($this->valF['json_payload'], true); |
338 |
|
|
339 |
|
// défini une liste de chemin de clés requises |
340 |
|
$paths = array(); |
341 |
|
if ($this->valF['category'] === 'platau') { |
342 |
|
$paths = array( |
343 |
|
'external_uids/dossier' |
344 |
|
); |
345 |
|
} |
346 |
|
|
347 |
|
// tâche de type création de DI/DA |
348 |
|
if (isset($this->valF['type']) !== false && $this->valF['type'] == 'create_DI_for_consultation') { |
349 |
|
|
350 |
|
$paths = array_merge($paths, array( |
351 |
|
'dossier/dossier', |
352 |
|
'dossier/dossier_autorisation_type_detaille_code', |
353 |
|
'dossier/date_demande', |
354 |
|
'dossier/depot_electronique', |
355 |
|
)); |
356 |
|
|
357 |
|
// si l'option commune est activée (mode MC) |
358 |
|
if ($this->f->is_option_dossier_commune_enabled()) { |
359 |
|
$paths[] = 'dossier/insee'; |
360 |
|
} |
361 |
|
|
362 |
|
// présence d'un moyen d'identifier la collectivité/le service |
363 |
|
if (! isset($json_payload['external_uids']['acteur']) && |
364 |
|
! isset($json_payload['dossier']['om_collectivite'])) { |
365 |
|
$this->correct = false; |
366 |
|
$this->addToMessage(sprintf( |
367 |
|
__("L'une des clés %s ou %s est obligatoire dans le contenu du champ %s pour une tâche entrante."), |
368 |
|
sprintf('<span class="bold">%s</span>', 'external_uids/acteur'), |
369 |
|
sprintf('<span class="bold">%s</span>', 'dossier/om_collectivite'), |
370 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
371 |
|
)); |
372 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
373 |
|
} |
374 |
|
} |
375 |
|
|
376 |
|
// pas d'erreur déjà trouvée |
377 |
|
if($this->correct) { |
378 |
|
|
379 |
|
// pour chaque chemin |
380 |
|
foreach($paths as $path) { |
381 |
|
|
382 |
|
// décompose le chemin |
383 |
|
$tokens = explode('/', $path); |
384 |
|
$cur_depth = $json_payload; |
385 |
|
|
386 |
|
// descend au et à mesure dans l'arborescence du chemin |
387 |
|
foreach($tokens as $token) { |
388 |
|
|
389 |
|
// en vérifiant que chaque élément du chemin est défini et non-nul |
390 |
|
if (isset($cur_depth[$token]) === false) { |
391 |
|
|
392 |
|
// sinon on produit une erreur |
393 |
|
$this->correct = false; |
394 |
|
$this->addToMessage(sprintf( |
395 |
|
__("La clé %s est obligatoire dans le contenu du champ %s pour une tâche entrante."), |
396 |
|
sprintf('<span class="bold">%s</span>', $path), |
397 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
398 |
|
)); |
399 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
400 |
|
break 2; |
401 |
|
} |
402 |
|
$cur_depth = $cur_depth[$token]; |
403 |
|
} |
404 |
|
} |
405 |
|
} |
406 |
|
} |
407 |
|
|
408 |
|
return $ret && $this->correct; |
409 |
} |
} |
410 |
|
|
411 |
protected function task_exists(string $type, string $object_id) { |
/** |
412 |
|
* [task_exists description] |
413 |
|
* @param string $type [description] |
414 |
|
* @param string $object_id [description] |
415 |
|
* @param bool $is_not_done [description] |
416 |
|
* @return [type] [description] |
417 |
|
*/ |
418 |
|
public function task_exists(string $type, string $object_id, string $dossier = null, bool $is_not_done = true) { |
419 |
$query = sprintf(' |
$query = sprintf(' |
420 |
SELECT task |
SELECT task |
421 |
FROM %1$stask |
FROM %1$stask |
422 |
WHERE state != \'%2$s\' |
WHERE %2$s |
423 |
AND type = \'%3$s\' |
type = \'%3$s\' |
424 |
AND object_id = \'%4$s\' |
AND (object_id = \'%4$s\' |
425 |
|
%5$s) |
426 |
', |
', |
427 |
DB_PREFIXE, |
DB_PREFIXE, |
428 |
'done', |
$is_not_done == true ? 'state != \''.self::STATUS_DONE.'\' AND' : '', |
429 |
$type, |
$type, |
430 |
$object_id |
$object_id, |
431 |
|
$dossier !== null ? sprintf('OR dossier = \'%s\'', $dossier) : '' |
432 |
); |
); |
433 |
$res = $this->f->get_one_result_from_db_query($query); |
$res = $this->f->get_one_result_from_db_query($query); |
434 |
if ($res['result'] !== null && $res['result'] !== '') { |
if ($res['result'] !== null && $res['result'] !== '') { |
438 |
} |
} |
439 |
|
|
440 |
/** |
/** |
441 |
|
* TRIGGER - triggerajouter. |
442 |
|
* |
443 |
|
* @param string $id |
444 |
|
* @param null &$dnu1 @deprecated Ne pas utiliser. |
445 |
|
* @param array $val Tableau des valeurs brutes. |
446 |
|
* @param null $dnu2 @deprecated Ne pas utiliser. |
447 |
|
* |
448 |
|
* @return boolean |
449 |
|
*/ |
450 |
|
function triggerajouter($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
451 |
|
|
452 |
|
// tâche entrante |
453 |
|
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
454 |
|
|
455 |
|
// décode la paylod JSON pour extraire les données métiers à ajouter |
456 |
|
// en tant que métadonnées de la tâche |
457 |
|
$json_payload = json_decode($this->valF['json_payload'], true); |
458 |
|
|
459 |
|
// si la tâche possède déjà une clé dossier |
460 |
|
if (isset($json_payload['dossier']['dossier']) && |
461 |
|
! empty($json_payload['dossier']['dossier'])) { |
462 |
|
$this->valF["dossier"] = $json_payload['dossier']['dossier']; |
463 |
|
} |
464 |
|
} |
465 |
|
|
466 |
|
// gestion d'une tache de type notification et de category mail |
467 |
|
if (isset($val['type']) |
468 |
|
&& (//$val['type'] === 'notification_recepisse' |
469 |
|
$val['type'] === 'notification_instruction' |
470 |
|
|| $val['type'] === 'notification_decision') |
471 |
|
&& isset($val['category']) |
472 |
|
&& $val['category'] === 'mail') { |
473 |
|
// Récupère la payload de la tache |
474 |
|
$data = array(); |
475 |
|
$data['instruction_notification'] = $this->get_instruction_notification_data( |
476 |
|
$this->valF['category'], |
477 |
|
'with-id', |
478 |
|
array('with-id' => $this->valF['object_id']) |
479 |
|
); |
480 |
|
$data['dossier'] = $this->get_dossier_data($this->valF['dossier']); |
481 |
|
|
482 |
|
// Récupère l'instance de la notification |
483 |
|
$inst_notif = $this->f->get_inst__om_dbform(array( |
484 |
|
"obj" => "instruction_notification", |
485 |
|
"idx" => $val['object_id'], |
486 |
|
)); |
487 |
|
// Envoi le mail et met à jour le suivi |
488 |
|
$envoiMail = $inst_notif->send_mail_notification_demandeur($data); |
489 |
|
// Passage de la tache à done si elle a réussi et à error |
490 |
|
// si l'envoi a échoué |
491 |
|
$this->valF['state'] = 'done'; |
492 |
|
if ($envoiMail === false) { |
493 |
|
$this->valF['state'] = 'error'; |
494 |
|
} |
495 |
|
} |
496 |
|
} |
497 |
|
|
498 |
|
/** |
499 |
|
* TRIGGER - triggermodifierapres. |
500 |
|
* |
501 |
|
* @param string $id |
502 |
|
* @param null &$dnu1 @deprecated Ne pas utiliser. |
503 |
|
* @param array $val Tableau des valeurs brutes. |
504 |
|
* @param null $dnu2 @deprecated Ne pas utiliser. |
505 |
|
* |
506 |
|
* @return boolean |
507 |
|
*/ |
508 |
|
public function triggermodifierapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
509 |
|
parent::triggermodifierapres($id, $dnu1, $val, $dnu2); |
510 |
|
|
511 |
|
// Suivi des notificiations |
512 |
|
if (isset($val['category']) === true |
513 |
|
&& $val['category'] === 'portal' |
514 |
|
&& isset($val['type']) === true |
515 |
|
&& ($val['type'] === 'notification_recepisse' |
516 |
|
|| $val['type'] === 'notification_instruction' |
517 |
|
|| $val['type'] === 'notification_decision')) { |
518 |
|
// |
519 |
|
if (isset($this->valF['state']) === true |
520 |
|
&& $this->valF['state'] !== $this->getVal('state')) { |
521 |
|
// |
522 |
|
$inst_in = $this->f->get_inst__om_dbform(array( |
523 |
|
"obj" => "instruction_notification", |
524 |
|
"idx" => $val['object_id'], |
525 |
|
)); |
526 |
|
$valF_in = array(); |
527 |
|
foreach ($inst_in->champs as $champ) { |
528 |
|
$valF_in[$champ] = $inst_in->getVal($champ); |
529 |
|
} |
530 |
|
$valF_in['date_envoi'] = null; |
531 |
|
$valF_in['date_premier_acces'] = null; |
532 |
|
// |
533 |
|
if ($this->valF['state'] === self::STATUS_DONE) { |
534 |
|
// |
535 |
|
$valF_in['statut'] = __("envoyé"); |
536 |
|
$valF_in['commentaire'] = __("Notification traitée"); |
537 |
|
$valF_in['date_envoi'] = date('d/m/Y H:i:s'); |
538 |
|
// |
539 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
540 |
|
"obj" => "instruction", |
541 |
|
"idx" => $inst_in->getVal('instruction'), |
542 |
|
)); |
543 |
|
if ($inst_instruction->has_an_edition() === true) { |
544 |
|
$valF_instruction = array(); |
545 |
|
foreach ($inst_instruction->champs as $champ) { |
546 |
|
$valF_instruction[$champ] = $inst_instruction->getVal($champ); |
547 |
|
} |
548 |
|
$valF_instruction['date_envoi_rar'] = date('d/m/Y'); |
549 |
|
$valF_instruction['date_retour_rar'] = date('d/m/Y', strtotime('now + 1 day')); |
550 |
|
$inst_instruction->setParameter('maj', 1); |
551 |
|
$update_instruction = $inst_instruction->modifier($valF_instruction); |
552 |
|
if ($update_instruction === false) { |
553 |
|
$this->addToLog(__METHOD__."(): ".$inst_instruction->msg, DEBUG_MODE); |
554 |
|
return false; |
555 |
|
} |
556 |
|
} |
557 |
|
} |
558 |
|
if ($this->valF['state'] === self::STATUS_ERROR) { |
559 |
|
$valF_in['statut'] = __("échec"); |
560 |
|
$valF_in['commentaire'] = __("Le traitement de la notification a échoué"); |
561 |
|
} |
562 |
|
$inst_in->setParameter('maj', 1); |
563 |
|
$update_in = $inst_in->modifier($valF_in); |
564 |
|
if ($update_in === false) { |
565 |
|
$this->addToLog(__METHOD__."(): ".$inst_in->msg, DEBUG_MODE); |
566 |
|
return false; |
567 |
|
} |
568 |
|
} |
569 |
|
} |
570 |
|
|
571 |
|
// |
572 |
|
return true; |
573 |
|
} |
574 |
|
|
575 |
|
/** |
576 |
* TREATMENT - add_task |
* TREATMENT - add_task |
577 |
* Ajoute un enregistrement. |
* Ajoute un enregistrement. |
578 |
* |
* |
581 |
*/ |
*/ |
582 |
public function add_task($params = array()) { |
public function add_task($params = array()) { |
583 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
584 |
|
|
585 |
|
// Vérifie si la task doit être ajoutée en fonction du mode de l'application, |
586 |
|
// seulement pour les tasks output |
587 |
|
$task_types_si = self::TASK_TYPE_SI; |
588 |
|
$task_types_sc = self::TASK_TYPE_SC; |
589 |
|
$stream = isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output'; |
590 |
|
if ($stream === 'output' |
591 |
|
&& isset($params['val']['type']) === true |
592 |
|
&& $this->f->is_option_mode_service_consulte_enabled() === true |
593 |
|
&& in_array($params['val']['type'], $task_types_sc) === false) { |
594 |
|
// |
595 |
|
return $this->end_treatment(__METHOD__, true); |
596 |
|
} |
597 |
|
if ($stream === 'output' |
598 |
|
&& isset($params['val']['type']) === true |
599 |
|
&& $this->f->is_option_mode_service_consulte_enabled() === false |
600 |
|
&& in_array($params['val']['type'], $task_types_si) === false) { |
601 |
|
// |
602 |
|
return $this->end_treatment(__METHOD__, true); |
603 |
|
} |
604 |
|
|
605 |
|
// |
606 |
$timestamp_log = json_encode(array( |
$timestamp_log = json_encode(array( |
607 |
'creation_date' => date('Y-m-d H:i:s'), |
'creation_date' => date('Y-m-d H:i:s'), |
608 |
)); |
)); |
609 |
|
|
610 |
|
// |
611 |
|
$category = isset($params['val']['category']) === true ? $params['val']['category'] : $this->category; |
612 |
|
|
613 |
|
// Si la tâche est de type ajout_piece et de stream input alors on ajoute le fichier |
614 |
|
// et on ajoute l'uid dans le champ json_payload avant l'ajout de la tâche |
615 |
|
if (isset($params['val']['type']) |
616 |
|
&& ($params['val']['type'] == "add_piece" || $params['val']['type'] == "avis_consultation") |
617 |
|
&& isset($params['val']['stream']) |
618 |
|
&& $params['val']['stream'] == "input" ) { |
619 |
|
// |
620 |
|
$json_payload = json_decode($params['val']['json_payload'], true); |
621 |
|
if (json_last_error() !== JSON_ERROR_NONE) { |
622 |
|
$this->addToMessage(__("Le contenu JSON de la tâche n'est pas valide.")); |
623 |
|
return $this->end_treatment(__METHOD__, false); |
624 |
|
} |
625 |
|
if (isset($json_payload['document_numerise']) === true |
626 |
|
&& empty($json_payload['document_numerise']) === false) { |
627 |
|
// |
628 |
|
$document_numerise = $json_payload['document_numerise']; |
629 |
|
$file_content = base64_decode($document_numerise["file_content"]); |
630 |
|
if ($file_content === false){ |
631 |
|
$this->addToMessage(__("Le contenu du fichier lié à la tâche n'a pas pu etre recupere.")); |
632 |
|
return $this->end_treatment(__METHOD__, false); |
633 |
|
} |
634 |
|
$metadata = array( |
635 |
|
"filename" => $document_numerise['nom_fichier'], |
636 |
|
"size" => strlen($file_content), |
637 |
|
"mimetype" => $document_numerise['file_content_type'], |
638 |
|
"date_creation" => isset($document_numerise['date_creation']) === true ? $document_numerise['date_creation'] : date("Y-m-d"), |
639 |
|
); |
640 |
|
$uid_fichier = $this->f->storage->create($file_content, $metadata, "from_content", "task.uid_fichier"); |
641 |
|
if ($uid_fichier === OP_FAILURE) { |
642 |
|
$this->addToMessage(__("Erreur lors de la creation du fichier lié à la tâche.")); |
643 |
|
return $this->end_treatment(__METHOD__, false); |
644 |
|
} |
645 |
|
$json_payload["document_numerise"]["uid"] = $uid_fichier; |
646 |
|
// Le fichier a été ajouté nous n'avons plus besoin du champ file_content dans la payload |
647 |
|
unset($json_payload["document_numerise"]["file_content"]); |
648 |
|
$params['val']['json_payload'] = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
649 |
|
} |
650 |
|
} |
651 |
|
|
652 |
// Mise à jour du DI |
// Mise à jour du DI |
653 |
$valF = array( |
$valF = array( |
654 |
'task' => '', |
'task' => '', |
655 |
'type' => $params['val']['type'], |
'type' => $params['val']['type'], |
656 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
657 |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : 'new', |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : self::STATUS_NEW, |
658 |
'object_id' => $params['val']['object_id'], |
'object_id' => isset($params['val']['object_id']) ? $params['val']['object_id'] : '', |
659 |
|
'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '', |
660 |
|
'stream' => $stream, |
661 |
|
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
662 |
|
'category' => $category, |
663 |
); |
); |
664 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
|
665 |
if ($task_exists !== false) { |
// tâche sortante |
666 |
$inst_task = $this->f->get_inst__om_dbform(array( |
if ($valF["stream"] == "output" |
667 |
"obj" => "task", |
&& $valF['type'] !== 'notification_recepisse' |
668 |
"idx" => $task_exists, |
&& $valF['type'] !== 'notification_instruction' |
669 |
)); |
&& $valF['type'] !== 'notification_decision') { |
670 |
$update_state = $inst_task->getVal('state'); |
|
671 |
if (isset($params['update_val']['state']) === true) { |
// TODO expliquer ce code |
672 |
$update_state = $params['update_val']['state']; |
$task_exists = $this->task_exists($valF['type'], $valF['object_id'], $valF['dossier']); |
673 |
|
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
674 |
|
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
675 |
|
} |
676 |
|
if ($valF['type'] === 'modification_DA' && $task_exists === false) { |
677 |
|
$task_exists = $this->task_exists('creation_DA', $valF['object_id']); |
678 |
|
} |
679 |
|
if ($valF['type'] === 'ajout_piece') { |
680 |
|
$task_exists = $this->task_exists('ajout_piece', $valF['object_id']); |
681 |
|
} |
682 |
|
if ($valF['type'] === 'creation_consultation') { |
683 |
|
$task_exists = $this->task_exists('creation_consultation', $valF['object_id']); |
684 |
|
} |
685 |
|
if ($task_exists !== false) { |
686 |
|
$inst_task = $this->f->get_inst__om_dbform(array( |
687 |
|
"obj" => "task", |
688 |
|
"idx" => $task_exists, |
689 |
|
)); |
690 |
|
$update_state = $inst_task->getVal('state'); |
691 |
|
if (isset($params['update_val']['state']) === true) { |
692 |
|
$update_state = $params['update_val']['state']; |
693 |
|
} |
694 |
|
$update_params = array( |
695 |
|
'val' => array( |
696 |
|
'state' => $update_state, |
697 |
|
), |
698 |
|
); |
699 |
|
return $inst_task->update_task($update_params); |
700 |
} |
} |
|
$update_params = array( |
|
|
'val' => array( |
|
|
'state' => $update_state, |
|
|
), |
|
|
); |
|
|
return $inst_task->update_task($update_params); |
|
701 |
} |
} |
702 |
$add = $this->ajouter($valF); |
$add = $this->ajouter($valF); |
703 |
|
$this->addToLog(__METHOD__."(): retour de l'ajout de tâche: ".var_export($add, true), VERBOSE_MODE); |
704 |
if ($add === false) { |
if ($add === false) { |
705 |
$this->addToLog($this->msg, DEBUG_MODE); |
$this->addToLog(__METHOD__."(): ".$this->msg, DEBUG_MODE); |
706 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
707 |
} |
} |
708 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
719 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
720 |
$timestamp_log = $this->get_timestamp_log(); |
$timestamp_log = $this->get_timestamp_log(); |
721 |
if ($timestamp_log === false) { |
if ($timestamp_log === false) { |
722 |
$this->addToLog(__('XXX'), DEBUG_MODE); |
$this->addToLog(__METHOD__."(): erreur timestamp log", DEBUG_MODE); |
723 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
724 |
} |
} |
725 |
array_push($timestamp_log, array( |
array_push($timestamp_log, array( |
733 |
'type' => $this->getVal('type'), |
'type' => $this->getVal('type'), |
734 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
735 |
'state' => $params['val']['state'], |
'state' => $params['val']['state'], |
736 |
'object_id' => $this->getVal('object_id'), |
'object_id' => isset($params['object_id']) == true && $this->getVal('type') == 'create_DI' ? $params['object_id'] : $this->getVal('object_id'), |
737 |
|
'stream' => $this->getVal('stream'), |
738 |
|
'dossier' => $this->getVal('dossier'), |
739 |
|
'json_payload' => $this->getVal('json_payload'), |
740 |
|
'category' => $this->getVal('category'), |
741 |
); |
); |
742 |
$update = $this->modifier($valF); |
$update = $this->modifier($valF); |
743 |
if ($update === false) { |
if ($update === false) { |
750 |
/** |
/** |
751 |
* 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 |
752 |
* l'enregistrement instancié. |
* l'enregistrement instancié. |
753 |
* |
* |
754 |
* @param array $params Tableau des paramètres |
* @param array $params Tableau des paramètres |
755 |
* @return array sinon false en cas d'erreur |
* @return array sinon false en cas d'erreur |
756 |
*/ |
*/ |
789 |
if ($this->f->get_submitted_get_value('state') !== null |
if ($this->f->get_submitted_get_value('state') !== null |
790 |
&& $this->f->get_submitted_get_value('state') !== '') { |
&& $this->f->get_submitted_get_value('state') !== '') { |
791 |
// |
// |
792 |
$where = sprintf(' WHERE state = \'%s\' ', $this->f->get_submitted_get_value('state')); |
$where_or_and = 'WHERE'; |
793 |
|
if ($where !== '') { |
794 |
|
$where_or_and = 'AND'; |
795 |
|
} |
796 |
|
$where .= sprintf(' %s state = \'%s\' ', $where_or_and, $this->f->get_submitted_get_value('state')); |
797 |
|
} |
798 |
|
if ($this->f->get_submitted_get_value('category') !== null |
799 |
|
&& $this->f->get_submitted_get_value('category') !== '') { |
800 |
|
// |
801 |
|
$where_or_and = 'WHERE'; |
802 |
|
if ($where !== '') { |
803 |
|
$where_or_and = 'AND'; |
804 |
|
} |
805 |
|
$where .= sprintf(' %s category = \'%s\' ', $where_or_and, $this->f->get_submitted_get_value('category')); |
806 |
} |
} |
807 |
$query = sprintf(' |
$query = sprintf(' |
808 |
SELECT |
SELECT |
809 |
* |
* |
810 |
FROM %1$stask |
FROM %1$stask |
811 |
%2$s |
%2$s |
812 |
|
ORDER BY task ASC |
813 |
', |
', |
814 |
DB_PREFIXE, |
DB_PREFIXE, |
815 |
$where |
$where |
821 |
$list_tasks = array(); |
$list_tasks = array(); |
822 |
foreach ($res['result'] as $task) { |
foreach ($res['result'] as $task) { |
823 |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
824 |
|
$task['dossier'] = $task['dossier']; |
825 |
|
if ($task['type'] === 'ajout_piece') { |
826 |
|
$val_dn = $this->get_document_numerise_data($task['object_id']); |
827 |
|
} |
828 |
|
if ($task['stream'] === 'output') { |
829 |
|
$task['external_uids'] = $this->get_all_external_uids($task['dossier']); |
830 |
|
} |
831 |
$list_tasks[$task['task']] = $task; |
$list_tasks[$task['task']] = $task; |
832 |
} |
} |
833 |
printf(json_encode($list_tasks)); |
printf(json_encode($list_tasks)); |
917 |
$particular_case = false; |
$particular_case = false; |
918 |
$fields_tab_crea_loc_hab = $inst_dt->get_fields_tab_crea_loc_hab(); |
$fields_tab_crea_loc_hab = $inst_dt->get_fields_tab_crea_loc_hab(); |
919 |
foreach ($fields_tab_crea_loc_hab as $field) { |
foreach ($fields_tab_crea_loc_hab as $field) { |
920 |
if (isset($field) === false |
if (isset($val_dt[$field]) === false |
921 |
|| (isset($field) === true |
|| (isset($val_dt[$field]) === true |
922 |
&& $field !== null |
&& ($val_dt[$field] === null |
923 |
&& $field !== '')) { |
|| $val_dt[$field] === ''))) { |
924 |
// |
// |
925 |
$particular_case = true; |
$particular_case = true; |
926 |
} |
} |
969 |
return $val_dt; |
return $val_dt; |
970 |
} |
} |
971 |
|
|
972 |
|
/** |
973 |
|
* Récupère la liste des objets distincts existants dans la table des liens |
974 |
|
* entre identifiants internes et identifiants externes. |
975 |
|
* |
976 |
|
* @return array |
977 |
|
*/ |
978 |
|
protected function get_list_distinct_objects_external_link() { |
979 |
|
$query = sprintf(' |
980 |
|
SELECT |
981 |
|
DISTINCT(object) |
982 |
|
FROM %1$slien_id_interne_uid_externe |
983 |
|
ORDER BY object ASC |
984 |
|
', |
985 |
|
DB_PREFIXE |
986 |
|
); |
987 |
|
$res = $this->f->get_all_results_from_db_query($query, true); |
988 |
|
if ($res['code'] === 'KO') { |
989 |
|
return array(); |
990 |
|
} |
991 |
|
$result = array(); |
992 |
|
foreach ($res['result'] as $object) { |
993 |
|
$result[] = $object['object']; |
994 |
|
} |
995 |
|
return $result; |
996 |
|
} |
997 |
|
|
998 |
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
999 |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
1000 |
"obj" => "lien_id_interne_uid_externe", |
"obj" => "lien_id_interne_uid_externe", |
1006 |
return $inst_external_uid->getVal('external_uid'); |
return $inst_external_uid->getVal('external_uid'); |
1007 |
} |
} |
1008 |
|
|
1009 |
|
protected function get_all_external_uids($fk_idx, $link_objects = array()) { |
1010 |
|
if (count($link_objects) == 0) { |
1011 |
|
$link_objects = $this->get_list_distinct_objects_external_link(); |
1012 |
|
} |
1013 |
|
$val_external_uid = array(); |
1014 |
|
foreach ($link_objects as $link_object) { |
1015 |
|
$external_uid = $this->get_external_uid($fk_idx, $link_object); |
1016 |
|
if ($external_uid !== '' && $external_uid !== null) { |
1017 |
|
$val_external_uid[$link_object] = $external_uid; |
1018 |
|
} |
1019 |
|
} |
1020 |
|
return $val_external_uid; |
1021 |
|
} |
1022 |
|
|
1023 |
protected function get_demandeurs_data(string $dossier) { |
protected function get_demandeurs_data(string $dossier) { |
1024 |
$val_demandeur = array(); |
$val_demandeur = array(); |
1025 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
1052 |
return $val_architecte; |
return $val_architecte; |
1053 |
} |
} |
1054 |
|
|
1055 |
protected function get_instruction_data(string $dossier) { |
protected function get_instruction_data(string $dossier, $type = 'decision', $extra_params = array()) { |
1056 |
$val_instruction = null; |
$val_instruction = null; |
1057 |
$instruction_with_doc = null; |
$instruction_with_doc = null; |
1058 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
1059 |
"obj" => "dossier", |
"obj" => "dossier", |
1060 |
"idx" => $dossier, |
"idx" => $dossier, |
1061 |
)); |
)); |
1062 |
|
$idx = null; |
1063 |
|
if ($type === 'decision') { |
1064 |
|
$idx = $inst_di->get_last_instruction_decision(); |
1065 |
|
} |
1066 |
|
if ($type === 'incompletude') { |
1067 |
|
$idx = $inst_di->get_last_instruction_incompletude(); |
1068 |
|
} |
1069 |
|
// XXX Permet de récupérer l'instruction par son identifiant |
1070 |
|
if ($type === 'with-id') { |
1071 |
|
$idx = $extra_params['with-id']; |
1072 |
|
} |
1073 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
1074 |
"obj" => "instruction", |
"obj" => "instruction", |
1075 |
"idx" => $inst_di->get_last_instruction_decision(), |
"idx" => $idx, |
1076 |
)); |
)); |
1077 |
if (count($inst_instruction->val) > 0) { |
if (count($inst_instruction->val) > 0) { |
1078 |
$val_instruction = array(); |
$val_instruction = array(); |
1107 |
} |
} |
1108 |
if ($instruction_with_doc !== null) { |
if ($instruction_with_doc !== null) { |
1109 |
// |
// |
1110 |
$val_instruction['path'] = sprintf('%s/%s&snippet=%s&obj=%s&champ=%s&id=%s', $_SERVER['HTTP_HOST'], 'openads/app/index.php?module=form', 'file', 'instruction', 'om_fichier_instruction', $instruction_with_doc); |
$val_instruction['path'] = sprintf('%s&snippet=%s&obj=%s&champ=%s&id=%s', 'app/index.php?module=form', 'file', 'instruction', 'om_fichier_instruction', $instruction_with_doc); |
1111 |
} |
} |
1112 |
} |
} |
1113 |
return $val_instruction; |
return $val_instruction; |
1114 |
} |
} |
1115 |
|
|
1116 |
|
/** |
1117 |
|
* Récupère les informations |
1118 |
|
*/ |
1119 |
|
protected function get_instruction_notification_data($category, $type = '', $extra_params = array()) { |
1120 |
|
$val_in = array(); |
1121 |
|
|
1122 |
|
$idx = null; |
1123 |
|
if ($type === 'with-id') { |
1124 |
|
$idx = $extra_params['with-id']; |
1125 |
|
} |
1126 |
|
|
1127 |
|
// récupére les données à intégrer à la payload |
1128 |
|
$inst_in = $this->f->get_inst__om_dbform(array( |
1129 |
|
"obj" => "instruction_notification", |
1130 |
|
"idx" => $idx, |
1131 |
|
)); |
1132 |
|
$val_in = $inst_in->get_json_data(); |
1133 |
|
|
1134 |
|
// Récupération du message et du titre |
1135 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
1136 |
|
"obj" => "instruction", |
1137 |
|
"idx" => $inst_in->getVal('instruction'), |
1138 |
|
)); |
1139 |
|
$collectivite_id = $inst_instruction->get_dossier_instruction_om_collectivite($inst_instruction->getVal('dossier')); |
1140 |
|
$phrase_type_notification = array(); |
1141 |
|
$phrase_type_notification = $this->f->get_notification_parametre_courriel_type($collectivite_id); |
1142 |
|
// |
1143 |
|
$val_in['parametre_courriel_type_titre'] = $phrase_type_notification['parametre_courriel_type_titre']; |
1144 |
|
$val_in['parametre_courriel_type_message'] = $phrase_type_notification['parametre_courriel_type_message']; |
1145 |
|
|
1146 |
|
// Récupération des liens vers les documents et de l'id de l'instruction |
1147 |
|
// de l'annexe |
1148 |
|
$infoDocNotif = $inst_in->getInfosDocumentsNotif($inst_in->getVal($inst_in->clePrimaire)); |
1149 |
|
$val_in['lien_telechargement_document'] = $infoDocNotif['document']['lien']; |
1150 |
|
$val_in['lien_telechargement_annexe'] = $infoDocNotif['annexe']['lien']; |
1151 |
|
$val_in['instruction_annexe'] = $infoDocNotif['annexe']['id_instruction']; |
1152 |
|
|
1153 |
|
return $val_in; |
1154 |
|
} |
1155 |
|
|
1156 |
protected function sort_instruction_data(array $values, array $res) { |
protected function sort_instruction_data(array $values, array $res) { |
1157 |
$fields = array( |
$fields = array( |
1158 |
|
"date_evenement", |
1159 |
"date_envoi_signature", |
"date_envoi_signature", |
1160 |
"date_retour_signature", |
"date_retour_signature", |
1161 |
"date_envoi_rar", |
"date_envoi_rar", |
1165 |
"signataire_arrete", |
"signataire_arrete", |
1166 |
"om_fichier_instruction", |
"om_fichier_instruction", |
1167 |
"tacite", |
"tacite", |
1168 |
|
"lettretype", |
1169 |
|
"commentaire", |
1170 |
|
"complement_om_html", |
1171 |
); |
); |
1172 |
foreach ($values as $key => $value) { |
foreach ($values as $key => $value) { |
1173 |
if (in_array($key, $fields) === true) { |
if (in_array($key, $fields) === true) { |
1193 |
"idx" => $dn, |
"idx" => $dn, |
1194 |
)); |
)); |
1195 |
$val_dn = $inst_dn->get_json_data(); |
$val_dn = $inst_dn->get_json_data(); |
1196 |
$val_dn['path'] = sprintf('%s/%s&snippet=%s&obj=%s&champ=%s&id=%s', $_SERVER['HTTP_HOST'], 'openads/app/index.php?module=form', 'file', 'document_numerise', 'uid', $this->getVal('object_id')); |
$val_dn['path'] = sprintf('%s&snippet=%s&obj=%s&champ=%s&id=%s', 'app/index.php?module=form', 'file', 'document_numerise', 'uid', $this->getVal('object_id')); |
1197 |
// Correspond à la nomenclature Plat'AU NATURE_PIECE |
// Correspond à la nomenclature Plat'AU NATURE_PIECE |
1198 |
$val_dn['nature'] = 'Initiale'; |
$val_dn['nature'] = $val_dn['document_numerise_nature_libelle']; |
1199 |
return $val_dn; |
return $val_dn; |
1200 |
} |
} |
1201 |
|
|
1218 |
return $val_dp; |
return $val_dp; |
1219 |
} |
} |
1220 |
|
|
1221 |
protected function view_form_json() { |
protected function get_avis_decision_data(string $dossier) { |
1222 |
// Mise à jour des valeurs |
$inst_di = $this->f->get_inst__om_dbform(array( |
1223 |
if ($this->f->get_submitted_post_value('valid') === 'true' |
"obj" => "dossier", |
1224 |
&& $this->f->get_submitted_post_value('state') !== null) { |
"idx" => $dossier, |
1225 |
// |
)); |
1226 |
$params = array( |
$ad = $inst_di->getVal('avis_decision'); |
1227 |
'val' => array( |
$val_ad = array(); |
1228 |
'state' => $this->f->get_submitted_post_value('state') |
if ($ad !== null) { |
1229 |
), |
$inst_ad = $this->f->get_inst__om_dbform(array( |
1230 |
); |
"obj" => "avis_decision", |
1231 |
$update = $this->update_task($params); |
"idx" => $ad, |
1232 |
$message_class = "valid"; |
)); |
1233 |
$message = $this->msg; |
$val_ad = $inst_ad->get_json_data(); |
1234 |
if ($update === false) { |
$val_ad['txAvis'] = "Voir document joint"; |
1235 |
$this->addToLog($this->msg, DEBUG_MODE); |
if (isset($val_ad['tacite']) === true |
1236 |
$message_class = "error"; |
&& $val_ad['tacite'] === 't') { |
1237 |
$message = sprintf( |
// |
1238 |
'%s %s', |
$val_ad['txAvis'] = "Sans objet"; |
|
__('Impossible de mettre à jour la tâche.'), |
|
|
__('Veuillez contacter votre administrateur.') |
|
|
); |
|
1239 |
} |
} |
|
$this->f->displayMessage($message_class, $message); |
|
1240 |
} |
} |
1241 |
// |
return $val_ad; |
1242 |
if ($this->f->get_submitted_post_value('valid') === 'true' |
} |
1243 |
&& $this->f->get_submitted_post_value('external_uid') !== null) { |
|
1244 |
|
protected function get_signataire_arrete_data(string $sa) { |
1245 |
|
$inst_sa = $this->f->get_inst__om_dbform(array( |
1246 |
|
"obj" => "signataire_arrete", |
1247 |
|
"idx" => $sa, |
1248 |
|
)); |
1249 |
|
$val_sa = array_combine($inst_sa->champs, $inst_sa->val); |
1250 |
|
foreach ($val_sa as $key => $value) { |
1251 |
|
$val_sa[$key] = strip_tags($value); |
1252 |
|
} |
1253 |
|
return $val_sa; |
1254 |
|
} |
1255 |
|
|
1256 |
|
// XXX WIP |
1257 |
|
protected function get_consultation_data(string $consultation) { |
1258 |
|
$val_consultation = array(); |
1259 |
|
$inst_consultation = $this->f->get_inst__om_dbform(array( |
1260 |
|
"obj" => "consultation", |
1261 |
|
"idx" => $consultation, |
1262 |
|
)); |
1263 |
|
$val_consultation = $inst_consultation->get_json_data(); |
1264 |
|
if (isset($val_consultation['fichier']) === true |
1265 |
|
&& $val_consultation['fichier'] !== '') { |
1266 |
// |
// |
1267 |
$inst_lien = $this->f->get_inst__om_dbform(array( |
$val_consultation['path_fichier'] = sprintf('%s&snippet=%s&obj=%s&champ=%s&id=%s', 'app/index.php?module=form', 'file', 'consultation', 'fichier', $this->getVal('object_id')); |
1268 |
"obj" => "lien_id_interne_uid_externe", |
} |
1269 |
"idx" => ']', |
if (isset($val_consultation['om_fichier_consultation']) === true |
1270 |
)); |
&& $val_consultation['om_fichier_consultation'] !== '') { |
1271 |
$valF = array( |
// |
1272 |
'lien_id_interne_uid_externe' => '', |
$val_consultation['path_om_fichier_consultation'] = sprintf('%s&snippet=%s&obj=%s&champ=%s&id=%s', 'app/index.php?module=form', 'file', 'consultation', 'om_fichier_consultation', $this->getVal('object_id')); |
|
'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); |
|
1273 |
} |
} |
1274 |
|
return $val_consultation; |
1275 |
|
} |
1276 |
|
|
1277 |
|
// XXX WIP |
1278 |
|
protected function get_service_data(string $service) { |
1279 |
|
$val_service = array(); |
1280 |
|
$inst_service = $this->f->get_inst__om_dbform(array( |
1281 |
|
"obj" => "service", |
1282 |
|
"idx" => $service, |
1283 |
|
)); |
1284 |
|
$val_service = $inst_service->get_json_data(); |
1285 |
|
return $val_service; |
1286 |
|
} |
1287 |
|
|
1288 |
|
protected function view_form_json($in_field = false) { |
1289 |
// |
// |
1290 |
if ($this->f->get_submitted_post_value('valid') === null) { |
if ($this->f->get_submitted_post_value('valid') === null |
1291 |
|
&& $this->getVal('state') !== self::STATUS_CANCELED) { |
1292 |
// Liste des valeurs à afficher |
// Liste des valeurs à afficher |
1293 |
$val = array(); |
$val = array(); |
1294 |
// |
// |
1299 |
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
1300 |
$val['task'] = $val_task; |
$val['task'] = $val_task; |
1301 |
// |
// |
1302 |
if ($this->getVal('type') === 'creation_DA') { |
if ($this->getVal('type') === 'creation_DA' |
1303 |
|
|| $this->getVal('type') === 'modification_DA') { |
1304 |
|
// |
1305 |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
1306 |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
1307 |
$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']); |
1308 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1309 |
$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'); |
1310 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1311 |
} |
} |
1312 |
// |
// |
1313 |
if ($this->getVal('type') === 'creation_DI' |
if ($this->getVal('type') === 'creation_DI' |
1323 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1324 |
$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'); |
1325 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1326 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1327 |
} |
} |
1328 |
// |
// |
1329 |
if ($this->getVal('type') === 'qualification_DI') { |
if ($this->getVal('type') === 'qualification_DI') { |
1330 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1331 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1332 |
$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'); |
1333 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1334 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1335 |
} |
} |
1336 |
// |
// |
1337 |
if ($this->getVal('type') === 'ajout_piece') { |
if ($this->getVal('type') === 'ajout_piece') { |
1341 |
$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'); |
1342 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1343 |
$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'); |
1344 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1345 |
} |
} |
1346 |
// |
// |
1347 |
if ($this->getVal('type') === 'decision_DI') { |
if ($this->getVal('type') === 'decision_DI') { |
1348 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1349 |
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier']); |
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
1350 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
1351 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
1352 |
|
} |
1353 |
|
$val_external_uid = array(); |
1354 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1355 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1356 |
|
$val['external_uids'] = $val_external_uid; |
1357 |
|
} |
1358 |
|
// |
1359 |
|
if ($this->getVal('type') === 'incompletude_DI') { |
1360 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1361 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
1362 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1363 |
$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'); |
1364 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1365 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1366 |
|
} |
1367 |
|
// |
1368 |
|
if ($this->getVal('type') === 'completude_DI') { |
1369 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1370 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
1371 |
|
$val_external_uid = array(); |
1372 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1373 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1374 |
|
$val['external_uids'] = $val_external_uid; |
1375 |
|
} |
1376 |
|
// |
1377 |
|
if ($this->getVal('type') === 'pec_metier_consultation') { |
1378 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1379 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1380 |
|
$val_external_uid = array(); |
1381 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1382 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1383 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
1384 |
|
$val['external_uids'] = $val_external_uid; |
1385 |
|
} |
1386 |
|
// |
1387 |
|
if ($this->getVal('type') === 'avis_consultation') { |
1388 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1389 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1390 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
1391 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
1392 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
1393 |
|
} |
1394 |
|
$val_external_uid = array(); |
1395 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1396 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1397 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
1398 |
|
$val['external_uids'] = $val_external_uid; |
1399 |
|
} |
1400 |
|
// XXX WIP |
1401 |
|
if ($this->getVal('type') === 'creation_consultation') { |
1402 |
|
// |
1403 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1404 |
|
$val['consultation'] = $this->get_consultation_data($this->getVal('object_id')); |
1405 |
|
$val['service'] = $this->get_service_data($val['consultation']['service']); |
1406 |
|
$val_external_uid = array(); |
1407 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1408 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1409 |
|
$val['external_uids'] = $val_external_uid; |
1410 |
|
} |
1411 |
|
// |
1412 |
|
if ($this->getVal('type') === 'notification_instruction' |
1413 |
|
|| $this->getVal('type') === 'notification_recepisse' |
1414 |
|
|| $this->getVal('type') === 'notification_decision') { |
1415 |
|
// |
1416 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1417 |
|
$val['demandeur'] = $this->get_demandeurs_data($this->getVal('dossier')); |
1418 |
|
$val['instruction_notification'] = $this->get_instruction_notification_data($this->getVal('category'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1419 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $val['instruction_notification']['instruction'])); |
1420 |
|
if ($val['instruction_notification']['instruction_annexe'] != '') { |
1421 |
|
$val['instruction_annexe'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $val['instruction_notification']['instruction_annexe'])); |
1422 |
|
} |
1423 |
|
$val_external_uid = array(); |
1424 |
|
$val_external_uid['demande'] = $this->get_external_uid($val['dossier']['dossier'], 'demande'); |
1425 |
|
$val['external_uids'] = $val_external_uid; |
1426 |
|
} |
1427 |
|
// |
1428 |
|
if ($this->getVal('type') === 'prescription') { |
1429 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1430 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1431 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
1432 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
1433 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
1434 |
|
} |
1435 |
|
$val_external_uid = array(); |
1436 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1437 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1438 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
1439 |
|
$val['external_uids'] = $val_external_uid; |
1440 |
} |
} |
1441 |
|
|
1442 |
// Liste des valeurs affichée en JSON |
if ($in_field === true) { |
1443 |
printf(json_encode($val)); |
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
1444 |
|
} else { |
1445 |
|
// Liste des valeurs affichée en JSON |
1446 |
|
printf(json_encode($val, JSON_UNESCAPED_SLASHES)); |
1447 |
|
} |
1448 |
} |
} |
1449 |
} |
} |
1450 |
|
|
1451 |
protected function get_lien_objet_by_type($type) { |
function post_update_task() { |
1452 |
// |
// Mise à jour des valeurs |
1453 |
$objet = ''; |
|
1454 |
if ($type === 'creation_DA') { |
// Modification de l'état de la tâche |
1455 |
$objet = 'dossier_autorisation'; |
if ($this->f->get_submitted_post_value('state') !== null) { |
1456 |
} |
$params = array( |
1457 |
if ($type === 'creation_DI' |
'val' => array( |
1458 |
|| $type === 'depot_DI' |
'state' => $this->f->get_submitted_post_value('state') |
1459 |
|| $type === 'modification_DI' |
), |
1460 |
|| $type === 'qualification_DI' |
); |
1461 |
|| $type === 'decision_DI') { |
$update = $this->update_task($params); |
1462 |
|
$message_class = "valid"; |
1463 |
|
$message = $this->msg; |
1464 |
|
if ($update === false) { |
1465 |
|
$this->addToLog($this->msg, DEBUG_MODE); |
1466 |
|
$message_class = "error"; |
1467 |
|
$message = sprintf( |
1468 |
|
'%s %s', |
1469 |
|
__('Impossible de mettre à jour la tâche.'), |
1470 |
|
__('Veuillez contacter votre administrateur.') |
1471 |
|
); |
1472 |
|
} |
1473 |
|
$this->f->displayMessage($message_class, $message); |
1474 |
|
} |
1475 |
|
|
1476 |
|
// Sauvegarde de l'uid externe retourné |
1477 |
|
if ($this->f->get_submitted_post_value('external_uid') !== null) { |
1478 |
// |
// |
1479 |
$objet = 'dossier'; |
$objects = $this->get_objects_by_task_type($this->getVal('type'), $this->getVal('stream')); |
1480 |
|
foreach ($objects as $object) { |
1481 |
|
$inst_lien = $this->f->get_inst__om_dbform(array( |
1482 |
|
"obj" => "lien_id_interne_uid_externe", |
1483 |
|
"idx" => ']', |
1484 |
|
)); |
1485 |
|
if ($inst_lien->is_exists($object, $this->getVal('object_id'), $this->f->get_submitted_post_value('external_uid'), $this->getVal('dossier')) === false) { |
1486 |
|
$valF = array( |
1487 |
|
'lien_id_interne_uid_externe' => '', |
1488 |
|
'object' => $object, |
1489 |
|
'object_id' => $this->getVal('object_id'), |
1490 |
|
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
1491 |
|
'dossier' => $this->getVal('dossier'), |
1492 |
|
'category' => $this->getVal('category'), |
1493 |
|
); |
1494 |
|
$add = $inst_lien->ajouter($valF); |
1495 |
|
$message_class = "valid"; |
1496 |
|
$message = $inst_lien->msg; |
1497 |
|
if ($add === false) { |
1498 |
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
1499 |
|
$message_class = "error"; |
1500 |
|
$message = sprintf( |
1501 |
|
'%s %s', |
1502 |
|
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
1503 |
|
__('Veuillez contacter votre administrateur.') |
1504 |
|
); |
1505 |
|
} |
1506 |
|
$this->f->displayMessage($message_class, $message); |
1507 |
|
} |
1508 |
|
} |
1509 |
|
} |
1510 |
|
} |
1511 |
|
|
1512 |
|
function post_add_task() { |
1513 |
|
// TODO Tester de remplacer la ligne de json_payload par un $_POST |
1514 |
|
$result = $this->add_task(array( |
1515 |
|
'val' => array( |
1516 |
|
'stream' => 'input', |
1517 |
|
'json_payload' => html_entity_decode($this->f->get_submitted_post_value('json_payload')), |
1518 |
|
'type' => $this->f->get_submitted_post_value('type'), |
1519 |
|
'category' => $this->f->get_submitted_post_value('category'), |
1520 |
|
) |
1521 |
|
)); |
1522 |
|
$message = sprintf( |
1523 |
|
__("Tâche %s ajoutée avec succès"), |
1524 |
|
$this->getVal($this->clePrimaire)). |
1525 |
|
'<br/><br/>'. |
1526 |
|
$this->msg; |
1527 |
|
$message_class = "valid"; |
1528 |
|
if ($result === false){ |
1529 |
|
$this->addToLog($this->msg, DEBUG_MODE); |
1530 |
|
$message_class = "error"; |
1531 |
|
$message = sprintf( |
1532 |
|
'%s %s', |
1533 |
|
__('Impossible d\'ajouter la tâche.'), |
1534 |
|
__('Veuillez contacter votre administrateur.') |
1535 |
|
); |
1536 |
|
} |
1537 |
|
$this->f->displayMessage($message_class, $message); |
1538 |
|
} |
1539 |
|
|
1540 |
|
function setLayout(&$form, $maj) { |
1541 |
|
|
1542 |
|
// Récupération du mode de l'action |
1543 |
|
$crud = $this->get_action_crud($maj); |
1544 |
|
|
1545 |
|
// MODE different de CREER |
1546 |
|
if ($maj != 0 || $crud != 'create') { |
1547 |
|
$form->setBloc('json_payload', 'D', '', 'col_6'); |
1548 |
|
$form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed"); |
1549 |
|
$form->setBloc('json_payload', 'F'); |
1550 |
|
} |
1551 |
|
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
1552 |
|
} |
1553 |
|
|
1554 |
|
/** |
1555 |
|
* [get_objects_by_task_type description] |
1556 |
|
* @param [type] $type [description] |
1557 |
|
* @return [type] [description] |
1558 |
|
*/ |
1559 |
|
function get_objects_by_task_type($type, $stream = 'all') { |
1560 |
|
$objects = array(); |
1561 |
|
if (in_array($type, array('creation_DA', 'modification_DA', )) === true) { |
1562 |
|
$objects = array('dossier_autorisation', ); |
1563 |
|
} |
1564 |
|
if (in_array($type, array('creation_DI', 'depot_DI', 'notification_DI', 'qualification_DI', )) === true) { |
1565 |
|
$objects = array('dossier', ); |
1566 |
|
} |
1567 |
|
if (in_array($type, array('create_DI_for_consultation', )) === true) { |
1568 |
|
$objects = array('dossier', 'dossier_consultation', ); |
1569 |
} |
} |
1570 |
if ($type === 'ajout_piece') { |
if (in_array($type, array('create_DI', )) === true |
1571 |
$objet = 'document_numerise'; |
&& $stream === 'input') { |
1572 |
|
$objects = array('dossier', 'dossier_autorisation', 'demande', ); |
1573 |
} |
} |
1574 |
return $objet; |
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
1575 |
|
$objects = array('instruction', ); |
1576 |
|
} |
1577 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
1578 |
|
&& $stream === 'output') { |
1579 |
|
$objects = array('pec_dossier_consultation', ); |
1580 |
|
} |
1581 |
|
if (in_array($type, array('avis_consultation', )) === true |
1582 |
|
&& $stream === 'output') { |
1583 |
|
$objects = array('avis_dossier_consultation', ); |
1584 |
|
} |
1585 |
|
if (in_array($type, array('prescription', )) === true |
1586 |
|
&& $stream === 'output') { |
1587 |
|
$objects = array('prescription', ); |
1588 |
|
} |
1589 |
|
if (in_array($type, array('ajout_piece', 'add_piece', )) === true) { |
1590 |
|
$objects = array('piece', ); |
1591 |
|
} |
1592 |
|
if (in_array($type, array('creation_consultation', )) === true) { |
1593 |
|
$objects = array('consultation', ); |
1594 |
|
} |
1595 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
1596 |
|
&& $stream === 'input') { |
1597 |
|
$objects = array('pec_metier_consultation', ); |
1598 |
|
} |
1599 |
|
if (in_array($type, array('avis_consultation', )) === true |
1600 |
|
&& $stream === 'input') { |
1601 |
|
$objects = array('avis_consultation', ); |
1602 |
|
} |
1603 |
|
if (in_array($type, array('create_message', )) === true |
1604 |
|
&& $stream === 'input') { |
1605 |
|
$objects = array('dossier_message', ); |
1606 |
|
} |
1607 |
|
if (in_array($type, array('notification_recepisse', 'notification_instruction', 'notification_decision' )) === true) { |
1608 |
|
$objects = array('instruction_notification', ); |
1609 |
|
} |
1610 |
|
return $objects; |
1611 |
} |
} |
1612 |
|
|
1613 |
} |
} |