13 |
const STATUS_ERROR = 'error'; |
const STATUS_ERROR = 'error'; |
14 |
const STATUS_DEBUG = 'debug'; |
const STATUS_DEBUG = 'debug'; |
15 |
const STATUS_ARCHIVED = 'archived'; |
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 |
|
'envoi_CL', |
36 |
|
'notification_recepisse', |
37 |
|
'notification_instruction', |
38 |
|
'notification_decision', |
39 |
|
'notification_service_consulte', |
40 |
|
'notification_tiers_consulte', |
41 |
|
'notification_depot_demat', |
42 |
|
'notification_commune', |
43 |
|
'lettre_incompletude', |
44 |
|
'lettre_majoration' |
45 |
|
); |
46 |
|
|
47 |
|
/** |
48 |
|
* Liste des types de tâche concernant les services consultés |
49 |
|
*/ |
50 |
|
const TASK_TYPE_SC = array( |
51 |
|
'create_DI_for_consultation', |
52 |
|
'avis_consultation', |
53 |
|
'pec_metier_consultation', |
54 |
|
'create_message', |
55 |
|
'notification_recepisse', |
56 |
|
'notification_instruction', |
57 |
|
'notification_decision', |
58 |
|
'notification_service_consulte', |
59 |
|
'notification_tiers_consulte', |
60 |
|
'notification_depot_demat', |
61 |
|
'prescription', |
62 |
|
); |
63 |
|
|
64 |
|
/** |
65 |
|
* Liste des types de tâche pouvant avoir des documents associés |
66 |
|
*/ |
67 |
|
const TASK_WITH_DOCUMENT = array( |
68 |
|
'add_piece', |
69 |
|
'avis_consultation', |
70 |
|
'pec_metier_consultation' |
71 |
|
); |
72 |
|
|
73 |
|
/** |
74 |
|
* Catégorie de la tâche |
75 |
|
*/ |
76 |
|
var $category = PLATAU; |
77 |
|
|
78 |
/** |
/** |
79 |
* Définition des actions disponibles sur la classe. |
* Définition des actions disponibles sur la classe. |
153 |
if (! isset($val['json_payload']) || empty($val['json_payload'])) { |
if (! isset($val['json_payload']) || empty($val['json_payload'])) { |
154 |
|
|
155 |
// récupère l'objet existant |
// récupère l'objet existant |
156 |
$existing = $this->f->findObjectById(get_class($this), $id); |
$existing = $this->f->findObjectById('task', $id); |
157 |
if (! empty($existing)) { |
if (! empty($existing)) { |
158 |
|
|
159 |
// récupère la payload de l'objet |
// récupère la payload de l'objet |
164 |
} |
} |
165 |
} |
} |
166 |
} |
} |
167 |
|
|
168 |
|
if (array_key_exists('category', $val) === false |
169 |
|
|| $this->valF['category'] === '' |
170 |
|
|| $this->valF['category'] === null) { |
171 |
|
// |
172 |
|
$this->valF['category'] = $this->category; |
173 |
|
} |
174 |
|
|
175 |
|
// Si last_modification_time est vide, la valeur est remplacée par NULL |
176 |
|
// pour eviter d'avoir une erreur de base de données car le champ est au format time. |
177 |
|
if ($val['last_modification_time'] == "") { |
178 |
|
$this->valF['last_modification_time'] = NULL; |
179 |
|
} else { |
180 |
|
$this->valF['last_modification_time'] = $val['last_modification_time']; |
181 |
|
} |
182 |
|
|
183 |
|
// Si creation_time est vide, la valeur est remplacée par NULL |
184 |
|
// pour eviter d'avoir une erreur de base de données car le champ est au format time. |
185 |
|
if ($val['creation_time'] == "") { |
186 |
|
$this->valF['creation_time'] = NULL; |
187 |
|
} else { |
188 |
|
$this->valF['creation_time'] = $val['creation_time']; |
189 |
|
} |
190 |
} |
} |
191 |
|
|
192 |
/** |
/** |
201 |
"object_id", |
"object_id", |
202 |
"dossier", |
"dossier", |
203 |
"stream", |
"stream", |
204 |
|
"creation_date", |
205 |
|
"creation_time", |
206 |
|
"CONCAT_WS(' ', to_char(task.creation_date, 'DD/MM/YYYY'), task.creation_time) AS date_creation", |
207 |
|
'last_modification_date', |
208 |
|
'last_modification_time', |
209 |
|
"CONCAT_WS(' ', to_char(task.last_modification_date, 'DD/MM/YYYY'), task.last_modification_time) AS date_modification", |
210 |
|
"comment", |
211 |
"json_payload", |
"json_payload", |
212 |
"timestamp_log", |
"timestamp_log", |
213 |
|
"timestamp_log AS timestamp_log_hidden", |
214 |
|
"category", |
215 |
); |
); |
216 |
} |
} |
217 |
|
|
221 |
// Récupération du mode de l'action |
// Récupération du mode de l'action |
222 |
$crud = $this->get_action_crud($maj); |
$crud = $this->get_action_crud($maj); |
223 |
|
|
224 |
|
// ALL |
225 |
|
$form->setType("category", "hidden"); |
226 |
|
$form->setType("timestamp_log_hidden", "hidden"); |
227 |
|
|
228 |
// MODE CREER |
// MODE CREER |
229 |
if ($maj == 0 || $crud == 'create') { |
if ($maj == 0 || $crud == 'create') { |
230 |
|
$form->setType("type", "select"); |
231 |
$form->setType("state", "select"); |
$form->setType("state", "select"); |
232 |
$form->setType("stream", "select"); |
$form->setType("stream", "select"); |
233 |
$form->setType("json_payload", "textarea"); |
$form->setType("json_payload", "textarea"); |
234 |
} |
} |
235 |
// MDOE MODIFIER |
// MODE MODIFIER |
236 |
if ($maj == 1 || $crud == 'update') { |
if ($maj == 1 || $crud == 'update') { |
237 |
|
$form->setType("task", "hiddenstatic"); |
238 |
$form->setType("state", "select"); |
$form->setType("state", "select"); |
239 |
$form->setType("stream", "select"); |
$form->setType("stream", "hiddenstatic"); |
240 |
$form->setType("json_payload", "jsonprettyprint"); |
$form->setType("json_payload", "jsonprettyprint"); |
241 |
|
$form->setType("timestamp_log", "jsontotab"); |
242 |
|
$form->setType("type", "hiddenstatic"); |
243 |
|
$form->setType("creation_date", "hidden"); |
244 |
|
$form->setType("creation_time", "hidden"); |
245 |
|
$form->setType("object_id", "hiddenstatic"); |
246 |
|
$form->setType("dossier", "hiddenstatic"); |
247 |
|
$form->setType("date_creation", "hiddenstatic"); |
248 |
|
$form->setType("last_modification_date", "hidden"); |
249 |
|
$form->setType("last_modification_time", "hidden"); |
250 |
|
$form->setType("date_modification", "static"); |
251 |
} |
} |
252 |
// MODE CONSULTER |
// MODE CONSULTER |
253 |
if ($maj == 3 || $crud == 'read') { |
if ($maj == 3 || $crud == 'read') { |
254 |
|
$form->setType("state", "selecthiddenstatic"); |
255 |
|
$form->setType("stream", "selecthiddenstatic"); |
256 |
$form->setType('dossier', 'link'); |
$form->setType('dossier', 'link'); |
257 |
$form->setType('json_payload', 'jsonprettyprint'); |
$form->setType('json_payload', 'jsonprettyprint'); |
258 |
|
$form->setType("type", "selecthiddenstatic"); |
259 |
|
$form->setType("creation_date", "hidden"); |
260 |
|
$form->setType("creation_time", "hidden"); |
261 |
|
$form->setType("date_creation", "static"); |
262 |
|
$form->setType("last_modification_date", "hidden"); |
263 |
|
$form->setType("last_modification_time", "hidden"); |
264 |
|
$form->setType("date_modification", "static"); |
265 |
|
$form->setType("timestamp_log", "jsontotab"); |
266 |
} |
} |
|
|
|
267 |
} |
} |
268 |
|
|
269 |
|
function stateTranslation ($currentState) { |
270 |
|
switch ($currentState){ |
271 |
|
case "draft": |
272 |
|
return __('brouillon'); |
273 |
|
break; |
274 |
|
case "new": |
275 |
|
return __('à traiter'); |
276 |
|
break; |
277 |
|
case "pending": |
278 |
|
return __('en cours'); |
279 |
|
break; |
280 |
|
case "done": |
281 |
|
return __('terminé'); |
282 |
|
break; |
283 |
|
case "archived": |
284 |
|
return __('archivé'); |
285 |
|
break; |
286 |
|
case "error": |
287 |
|
return __('erreur'); |
288 |
|
break; |
289 |
|
case "debug": |
290 |
|
return __('debug'); |
291 |
|
break; |
292 |
|
case "canceled": |
293 |
|
return __('annulé'); |
294 |
|
break; |
295 |
|
} |
296 |
|
} |
297 |
/** |
/** |
298 |
* |
* |
299 |
*/ |
*/ |
300 |
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
301 |
if($maj < 2) { |
if($maj <= 3) { |
|
|
|
302 |
$contenu = array(); |
$contenu = array(); |
303 |
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG') as $key) { |
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG', 'ARCHIVED', 'CANCELED') as $key) { |
304 |
$const_name = 'STATUS_'.$key; |
$const_name = 'STATUS_'.$key; |
305 |
$const_value = constant("self::$const_name"); |
$const_value = constant("self::$const_name"); |
306 |
$contenu[0][] = $const_value; |
$contenu[0][] = $const_value; |
307 |
$contenu[1][] = __($const_value); |
|
308 |
|
|
309 |
|
$contenu[1][] = $this->stateTranslation($const_value); |
310 |
|
|
311 |
} |
} |
312 |
|
|
313 |
$form->setSelect("state", $contenu); |
$form->setSelect("state", $contenu); |
314 |
|
|
315 |
$contenu_stream =array(); |
$contenu_stream =array(); |
316 |
$contenu_stream[0][0]="input"; |
$contenu_stream[0][0]="input"; |
317 |
$contenu_stream[1][0]=_('input'); |
$contenu_stream[1][0]=__('input'); |
318 |
$contenu_stream[0][1]="output"; |
$contenu_stream[0][1]="output"; |
319 |
$contenu_stream[1][1]=_('output'); |
$contenu_stream[1][1]=__('output'); |
320 |
$form->setSelect("stream", $contenu_stream); |
$form->setSelect("stream", $contenu_stream); |
321 |
|
|
322 |
|
$tab_type = array_unique(array_merge(self::TASK_TYPE_SI, self::TASK_TYPE_SC)); |
323 |
|
|
324 |
|
foreach ($tab_type as $type) { |
325 |
|
|
326 |
|
$contenu_type[0][] = $type; |
327 |
|
|
328 |
|
switch ($type) { |
329 |
|
case "creation_DA": |
330 |
|
$value_type = __('Création DA'); |
331 |
|
break; |
332 |
|
case "create_DI": |
333 |
|
$value_type = __('Création demande'); |
334 |
|
break; |
335 |
|
case "creation_DI": |
336 |
|
$value_type = __('Création DI'); |
337 |
|
break; |
338 |
|
case "modification_DA": |
339 |
|
$value_type = __('Modification DA'); |
340 |
|
break; |
341 |
|
case "modification_DI": |
342 |
|
$value_type = __('Modification DI'); |
343 |
|
break; |
344 |
|
case "ajout_piece": |
345 |
|
$value_type = __('Ajout pièce (sortant)'); |
346 |
|
break; |
347 |
|
case "add_piece": |
348 |
|
$value_type = __('Ajout pièce (entrant)'); |
349 |
|
break; |
350 |
|
case "depot_DI": |
351 |
|
$value_type = __('Dépôt DI'); |
352 |
|
break; |
353 |
|
case "qualification_DI": |
354 |
|
$value_type = __('Qualification DI'); |
355 |
|
break; |
356 |
|
case "creation_consultation": |
357 |
|
$value_type = __('Création consultation'); |
358 |
|
break; |
359 |
|
case "decision_DI": |
360 |
|
$value_type = __('Décision DI'); |
361 |
|
break; |
362 |
|
case "envoi_CL": |
363 |
|
$value_type = __('Envoi contrôle de légalité'); |
364 |
|
break; |
365 |
|
case "pec_metier_consultation": |
366 |
|
$value_type = __('PeC consultation'); |
367 |
|
break; |
368 |
|
case "avis_consultation": |
369 |
|
$value_type = __('Avis'); |
370 |
|
break; |
371 |
|
case "prescription": |
372 |
|
$value_type = __('Prescription'); |
373 |
|
break; |
374 |
|
case "create_DI_for_consultation": |
375 |
|
$value_type = __('Création DI pour consultation'); |
376 |
|
break; |
377 |
|
case "create_message": |
378 |
|
$value_type = __('Message'); |
379 |
|
break; |
380 |
|
case "notification_recepisse": |
381 |
|
$value_type = __('Notification récépissé'); |
382 |
|
break; |
383 |
|
case "notification_instruction": |
384 |
|
$value_type = __('Notification instruction'); |
385 |
|
break; |
386 |
|
case "notification_decision": |
387 |
|
$value_type = __('Notification décision'); |
388 |
|
break; |
389 |
|
case "notification_service_consulte": |
390 |
|
$value_type = __('Notification service consulté'); |
391 |
|
break; |
392 |
|
case "notification_tiers_consulte": |
393 |
|
$value_type = __('Notification tiers consulté'); |
394 |
|
break; |
395 |
|
case "completude_DI": |
396 |
|
$value_type = __('complétude DI'); |
397 |
|
break; |
398 |
|
case "incompletude_DI": |
399 |
|
$value_type = __('incomplétude DI'); |
400 |
|
break; |
401 |
|
case "lettre_incompletude": |
402 |
|
$value_type = __('Lettre au pétitionnaire d\'incompletude'); |
403 |
|
break; |
404 |
|
case "lettre_majoration": |
405 |
|
$value_type = __('Lettre au pétitionnaire de majoration'); |
406 |
|
break; |
407 |
|
} |
408 |
|
|
409 |
|
$contenu_type[1][] = $value_type; |
410 |
|
} |
411 |
|
|
412 |
|
$form->setselect('type', $contenu_type); |
413 |
} |
} |
414 |
|
|
415 |
if ($maj == 3) { |
if ($maj == 3) { |
416 |
if ($this->getVal('stream') == 'output') { |
// Récupération du numéro du dossier si il n'est pas renseigné dans la tâche |
417 |
$inst_dossier = $this->f->get_inst__om_dbform(array( |
if ($form->val['dossier'] == '' || $form->val['dossier'] == null) { |
418 |
"obj" => "dossier", |
// Récupération de la payload de la taĉhe. |
419 |
"idx" => $form->val['dossier'], |
// Si la tâche est une tâche input la payload est associée à la tâche. |
420 |
)); |
// Si la tâche est une tâche en output la payload est "calculé" à l'ouverture |
421 |
|
// du formulaire. |
422 |
|
if ($this->getVal('stream') == 'input') { |
423 |
|
$json_payload = json_decode($this->getVal('json_payload'), true); |
424 |
|
} else { |
425 |
|
$json_payload = json_decode($form->val['json_payload'], true); |
426 |
|
} |
427 |
|
// A partir de la payload de la tâche ont récupère les externals uid |
428 |
|
// Si un external uid de DI (dossier) existe ont le récupère et on stocke le numéro |
429 |
|
// pour l'afficher sur le formulaire. |
430 |
|
// Si l'external UID du DI n'existe pas on récupère celui du DA |
431 |
|
$external_uid = ''; |
432 |
|
if (array_key_exists('external_uids', $json_payload) |
433 |
|
&& array_key_exists('dossier', $json_payload['external_uids']) |
434 |
|
) { |
435 |
|
$external_uid = $json_payload['external_uids']['dossier']; |
436 |
|
} elseif (array_key_exists('external_uids', $json_payload) |
437 |
|
&& array_key_exists('demande', $json_payload['external_uids'])) { |
438 |
|
$external_uid = $json_payload['external_uids']['demande']; |
439 |
|
} |
440 |
|
// Recherche l'external uid dans la base de données pour récupèrer le numéro de |
441 |
|
// DI / DA correspondant. On stocke le numéro de dossier dans la propriété val |
442 |
|
// du formulaire pour pouvoir l'afficher |
443 |
|
if ($external_uid != '') { |
444 |
|
$qres = $this->f->get_one_result_from_db_query( |
445 |
|
sprintf( |
446 |
|
'SELECT |
447 |
|
lien_id_interne_uid_externe.dossier |
448 |
|
FROM |
449 |
|
%1$slien_id_interne_uid_externe |
450 |
|
WHERE |
451 |
|
lien_id_interne_uid_externe.external_uid = \'%2$s\'', |
452 |
|
DB_PREFIXE, |
453 |
|
$this->f->db->escapeSimple($external_uid) |
454 |
|
), |
455 |
|
array( |
456 |
|
"origin" => __METHOD__, |
457 |
|
) |
458 |
|
); |
459 |
|
if (! empty($qres["result"])) { |
460 |
|
$form->val['dossier'] = $qres["result"]; |
461 |
|
} |
462 |
|
} |
463 |
|
} |
464 |
|
|
465 |
if($form->val['type'] == "creation_DA"){ |
// Vérifie si le numéro de dossier associé à la tâche existe dans la base. |
466 |
|
// Si c'est le cas ce numéro sera lié au dossier (DI ou DA) correspondant |
467 |
|
// TODO : vérifier la liste des tâches lié à des DA |
468 |
|
$obj_link = ''; |
469 |
|
if ($form->val['type'] == "creation_DA" || $form->val['type'] == "modification_DA") { |
470 |
|
// Vérification que le numéro de DA affiché dans le formulaire existe |
471 |
|
$qres = $this->f->get_one_result_from_db_query( |
472 |
|
sprintf( |
473 |
|
'SELECT |
474 |
|
dossier_autorisation.dossier_autorisation |
475 |
|
FROM |
476 |
|
%1$sdossier_autorisation |
477 |
|
WHERE |
478 |
|
dossier_autorisation.dossier_autorisation = \'%2$s\'', |
479 |
|
DB_PREFIXE, |
480 |
|
$this->f->db->escapeSimple($form->val['dossier']) |
481 |
|
), |
482 |
|
array( |
483 |
|
"origin" => __METHOD__, |
484 |
|
) |
485 |
|
); |
486 |
|
// Si on a un résultat c'est que le dossier existe, il faut afficher le lien |
487 |
|
if (! empty($qres["result"])) { |
488 |
$obj_link = 'dossier_autorisation'; |
$obj_link = 'dossier_autorisation'; |
489 |
} else { |
} |
490 |
|
} else { |
491 |
|
// Vérification que le numéro de DI affiché dans le formulaire existe |
492 |
|
$qres = $this->f->get_one_result_from_db_query( |
493 |
|
sprintf( |
494 |
|
'SELECT |
495 |
|
dossier.dossier |
496 |
|
FROM |
497 |
|
%1$sdossier |
498 |
|
WHERE |
499 |
|
dossier.dossier = \'%2$s\'', |
500 |
|
DB_PREFIXE, |
501 |
|
$this->f->db->escapeSimple($form->val['dossier']) |
502 |
|
), |
503 |
|
array( |
504 |
|
"origin" => __METHOD__, |
505 |
|
) |
506 |
|
); |
507 |
|
// Si on a un résultat c'est que le dossier existe, il faut afficher le lien |
508 |
|
if (! empty($qres["result"])) { |
509 |
$obj_link = 'dossier_instruction'; |
$obj_link = 'dossier_instruction'; |
510 |
} |
} |
|
|
|
|
$params = array(); |
|
|
$params['obj'] = $obj_link; |
|
|
$params['libelle'] = $inst_dossier->getVal('dossier'); |
|
|
$params['title'] = "Consulter le dossier"; |
|
|
$params['idx'] = $form->val['dossier']; |
|
|
$form->setSelect("dossier", $params); |
|
511 |
} |
} |
512 |
|
// Pour afficher le lien vers un dossier ont utilise un champ de type "link". |
513 |
|
// Pour paramétrer ce champs on a besoin de savoir : |
514 |
|
// - quel objet est visé par le lien |
515 |
|
// - le label (libellé) du lien |
516 |
|
// - l'identifiant de l'objet qui sera utilisé dans le lien |
517 |
|
// - le titre associé au lien |
518 |
|
// Pour cela on remplit le champs comme un select et les valeurs du select |
519 |
|
// contiennent les informations nécessaire à l'affichage du champs. |
520 |
|
$params = array( |
521 |
|
'obj' => $obj_link, |
522 |
|
'libelle' => $form->val['dossier'], |
523 |
|
'title' => "Consulter le dossier", |
524 |
|
'idx' => $form->val['dossier'] |
525 |
|
); |
526 |
|
$form->setSelect("dossier", $params); |
527 |
} |
} |
528 |
} |
} |
529 |
|
|
535 |
function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) { |
function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) { |
536 |
// parent::setVal($form, $maj, $validation); |
// parent::setVal($form, $maj, $validation); |
537 |
// |
// |
538 |
if ($this->getVal('stream') == "output") { |
if ($this->getVal('stream') == "output" |
539 |
|
&& ($this->getVal('state') !== self::STATUS_DONE |
540 |
|
|| $this->getVal('json_payload') === "{}")) { |
541 |
|
// |
542 |
$form->setVal('json_payload', $this->view_form_json(true)); |
$form->setVal('json_payload', $this->view_form_json(true)); |
543 |
} else { |
} else { |
544 |
$form->setVal('json_payload', htmlentities($this->getVal('json_payload'))); |
$form->setVal('json_payload', json_encode(json_decode($this->getVal('json_payload'), true), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); |
545 |
|
} |
546 |
|
// Gestion du contenu de l'historique |
547 |
|
if ($this->getVal('timestamp_log') !== '' |
548 |
|
&& $this->getVal('timestamp_log') !== null) { |
549 |
|
// |
550 |
|
$form->setVal('timestamp_log', $this->getVal('timestamp_log')); |
551 |
} |
} |
552 |
} |
} |
553 |
|
|
557 |
// Récupération du mode de l'action |
// Récupération du mode de l'action |
558 |
$crud = $this->get_action_crud($maj); |
$crud = $this->get_action_crud($maj); |
559 |
|
|
560 |
|
$form->setLib('date_creation', __("Date de création")); |
561 |
|
$form->setLib('date_modification', __("Date de dernière modification")); |
562 |
|
$form->setLib('comment', __("commentaire")); |
563 |
|
|
564 |
// MODE different de CREER |
// MODE different de CREER |
565 |
if ($maj != 0 || $crud != 'create') { |
if ($maj != 0 || $crud != 'create') { |
566 |
$form->setLib('json_payload', ''); |
$form->setLib('json_payload', ''); |
567 |
|
$form->setLib("task", __("identifiant")); |
568 |
|
$form->setLib("Task_portal", __("task_portal")); |
569 |
|
$form->setLib("type", __("type")); |
570 |
|
$form->setLib("object_id", __("Réf. interne")); |
571 |
|
$form->setLib("stream", __("flux")); |
572 |
|
$form->setLib("timestamp_log", __("Historique")); |
573 |
} |
} |
574 |
} |
} |
575 |
|
|
629 |
$this->valF['stream'] == 'input')) { |
$this->valF['stream'] == 'input')) { |
630 |
|
|
631 |
// décode la payload JSON |
// décode la payload JSON |
632 |
|
// TODO : COMMENTER |
633 |
$json_payload = json_decode($this->valF['json_payload'], true); |
$json_payload = json_decode($this->valF['json_payload'], true); |
634 |
|
|
635 |
// défini une liste de chemin de clés requises |
// défini une liste de chemin de clés requises |
636 |
$paths = array( |
$paths = array(); |
637 |
'external_uids/dossier' |
if ($this->valF['category'] === PLATAU) { |
638 |
); |
$paths = array( |
639 |
|
'external_uids/dossier' |
640 |
|
); |
641 |
|
} |
642 |
|
|
643 |
// tâche de type création de DI/DA |
// tâche de type création de DI/DA |
644 |
if (isset($this->valF['type']) !== false && $this->valF['type'] == 'create_DI_for_consultation') { |
if (isset($this->valF['type']) !== false && $this->valF['type'] == 'create_DI_for_consultation') { |
656 |
} |
} |
657 |
|
|
658 |
// présence d'un moyen d'identifier la collectivité/le service |
// présence d'un moyen d'identifier la collectivité/le service |
659 |
if (! isset($json_payload['dossier']['acteur']) && |
if (! isset($json_payload['external_uids']['acteur']) && |
660 |
! isset($json_payload['dossier']['om_collectivite'])) { |
! isset($json_payload['dossier']['om_collectivite'])) { |
661 |
$this->correct = false; |
$this->correct = false; |
662 |
$this->addToMessage(sprintf( |
$this->addToMessage(sprintf( |
663 |
__("L'une des clés %s ou %s est obligatoire dans le contenu du champ %s pour une tâche entrante."), |
__("L'une des clés %s ou %s est obligatoire dans le contenu du champ %s pour une tâche entrante."), |
664 |
sprintf('<span class="bold">%s</span>', 'dossier/acteur'), |
sprintf('<span class="bold">%s</span>', 'external_uids/acteur'), |
665 |
sprintf('<span class="bold">%s</span>', 'dossier/om_collectivite'), |
sprintf('<span class="bold">%s</span>', 'dossier/om_collectivite'), |
666 |
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
667 |
)); |
)); |
704 |
return $ret && $this->correct; |
return $ret && $this->correct; |
705 |
} |
} |
706 |
|
|
707 |
protected function task_exists(string $type, string $object_id) { |
/** |
708 |
|
* [task_exists description] |
709 |
|
* @param string $type [description] |
710 |
|
* @param string $object_id [description] |
711 |
|
* @param bool $is_not_done [description] |
712 |
|
* @return [type] [description] |
713 |
|
*/ |
714 |
|
public function task_exists(string $type, string $object_id, string $dossier = null, bool $is_not_done = true) { |
715 |
|
$qres = $this->f->get_one_result_from_db_query( |
716 |
|
sprintf( |
717 |
|
'SELECT |
718 |
|
task |
719 |
|
FROM |
720 |
|
%1$stask |
721 |
|
WHERE |
722 |
|
%2$s |
723 |
|
type = \'%3$s\' |
724 |
|
AND ( |
725 |
|
object_id = \'%4$s\' |
726 |
|
%5$s |
727 |
|
) |
728 |
|
AND state != \'%6$s\'', |
729 |
|
DB_PREFIXE, |
730 |
|
$is_not_done == true ? 'state != \''.self::STATUS_DONE.'\' AND' : '', |
731 |
|
$type, |
732 |
|
$object_id, |
733 |
|
$dossier !== null ? sprintf('OR dossier = \'%s\'', $dossier) : '', |
734 |
|
self::STATUS_CANCELED |
735 |
|
), |
736 |
|
array( |
737 |
|
"origin" => __METHOD__, |
738 |
|
) |
739 |
|
); |
740 |
|
if ($qres["result"] !== null && $qres["result"] !== "") { |
741 |
|
return $qres["result"]; |
742 |
|
} |
743 |
|
return false; |
744 |
|
} |
745 |
|
|
746 |
|
/** |
747 |
|
* Permet la recherche multi-critères des tasks. |
748 |
|
* |
749 |
|
* @param array $search_values Chaque entrée du tableau est une ligne dans le WHERE |
750 |
|
* @return mixed Retourne le résultat de la requête ou false |
751 |
|
*/ |
752 |
|
public function task_exists_multi_search(array $search_values) { |
753 |
$query = sprintf(' |
$query = sprintf(' |
754 |
SELECT task |
SELECT * |
755 |
FROM %1$stask |
FROM %1$stask |
756 |
WHERE state != \'%2$s\' |
%2$s |
757 |
AND type = \'%3$s\' |
%3$s |
758 |
AND object_id = \'%4$s\' |
ORDER BY task ASC |
759 |
', |
', |
760 |
DB_PREFIXE, |
DB_PREFIXE, |
761 |
self::STATUS_DONE, |
empty($search_values) === false ? ' WHERE ' : '', |
762 |
$type, |
implode(' AND ', $search_values) |
763 |
$object_id |
); |
764 |
|
$res = $this->f->get_all_results_from_db_query( |
765 |
|
$query, |
766 |
|
array( |
767 |
|
"origin" => __METHOD__, |
768 |
|
) |
769 |
); |
); |
770 |
$res = $this->f->get_one_result_from_db_query($query); |
if (count($res['result']) > 0) { |
|
if ($res['result'] !== null && $res['result'] !== '') { |
|
771 |
return $res['result']; |
return $res['result']; |
772 |
} |
} |
773 |
return false; |
return false; |
797 |
! empty($json_payload['dossier']['dossier'])) { |
! empty($json_payload['dossier']['dossier'])) { |
798 |
$this->valF["dossier"] = $json_payload['dossier']['dossier']; |
$this->valF["dossier"] = $json_payload['dossier']['dossier']; |
799 |
} |
} |
800 |
|
} |
801 |
|
|
802 |
/** |
// gestion d'une tache de type notification et de category mail |
803 |
* Puisque le dossier n'a potentiellement pas encore été créé |
if (isset($val['type']) |
804 |
* alors il faut ne faut chercher à récupérer le numéro de dossier openADS |
&& (($val['type'] === 'notification_instruction' || $val['type'] === 'notification_decision') |
805 |
* à partir de l'external_uids (en passant par la table de liens) |
&& isset($val['category']) |
806 |
// sinon si la tâche possède une clé external_uids/dossier |
&& $val['category'] === 'mail') |
807 |
elseif(isset($json_payload['external_uids']['dossier']) && |
|| $val['type'] === 'notification_service_consulte' |
808 |
! empty($json_payload['external_uids']['dossier'])) { |
|| $val['type'] === 'notification_tiers_consulte' |
809 |
|
|| $val['type'] === 'notification_depot_demat' |
810 |
|
|| $val['type'] === 'notification_commune' |
811 |
|
) { |
812 |
|
// Récupère la payload de la tache |
813 |
|
$data = array(); |
814 |
|
$data['instruction_notification'] = $this->get_instruction_notification_data( |
815 |
|
$this->valF['category'], |
816 |
|
'with-id', |
817 |
|
array('with-id' => $this->valF['object_id']) |
818 |
|
); |
819 |
|
$data['dossier'] = $this->get_dossier_data($this->valF['dossier']); |
820 |
|
|
821 |
// instancie l'objet lien_id_interne_uid_externe |
// Récupère l'instance de la notification |
822 |
$inst_lien = $this->f->get_inst__om_dbform(array( |
$inst_notif = $this->f->get_inst__om_dbform(array( |
823 |
"obj" => "lien_id_interne_uid_externe", |
"obj" => "instruction_notification", |
824 |
"idx" => ']', |
"idx" => $val['object_id'], |
825 |
|
)); |
826 |
|
// Envoi le mail et met à jour le suivi |
827 |
|
$envoiMail = $inst_notif->send_mail_notification($data, $val['type']); |
828 |
|
// Passage de la tache à done si elle a réussi et à error |
829 |
|
// si l'envoi a échoué |
830 |
|
$this->valF['state'] = 'done'; |
831 |
|
if ($envoiMail === false) { |
832 |
|
$this->valF['state'] = 'error'; |
833 |
|
} |
834 |
|
} |
835 |
|
} |
836 |
|
|
837 |
|
/** |
838 |
|
* TRIGGER - triggermodifier. |
839 |
|
* |
840 |
|
* @param string $id |
841 |
|
* @param null &$dnu1 @deprecated Ne pas utiliser. |
842 |
|
* @param array $val Tableau des valeurs brutes. |
843 |
|
* @param null $dnu2 @deprecated Ne pas utiliser. |
844 |
|
* |
845 |
|
* @return boolean |
846 |
|
*/ |
847 |
|
function triggermodifier($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
848 |
|
parent::triggermodifier($id, $dnu1, $val, $dnu2); |
849 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
850 |
|
|
851 |
|
// Mise à jour des valeurs, notamment du timestamp_log en fonction de plusieurs critères |
852 |
|
$values = array( |
853 |
|
'state' => $this->valF['state'], |
854 |
|
'object_id' => $this->valF['object_id'], |
855 |
|
'comment' => $this->valF['comment'], |
856 |
|
); |
857 |
|
$new_values = $this->set_values_for_update($values); |
858 |
|
if ($new_values === false) { |
859 |
|
$this->addToLog(__METHOD__."(): erreur timestamp log", DEBUG_MODE); |
860 |
|
return false; |
861 |
|
} |
862 |
|
|
863 |
|
// Mise à jour des valeurs |
864 |
|
$this->valF['timestamp_log'] = $new_values['timestamp_log']; |
865 |
|
$this->valF['state'] = $new_values['state']; |
866 |
|
$this->valF['object_id'] = $new_values['object_id']; |
867 |
|
$this->valF['last_modification_date'] = date('Y-m-d'); |
868 |
|
$this->valF['last_modification_time'] = date('H:i:s'); |
869 |
|
if ($val['stream'] === 'output') { |
870 |
|
// Lorsque la task passe d'un état qui n'est pas "done" à l'état "done" |
871 |
|
if ($this->getVal("state") !== self::STATUS_DONE |
872 |
|
&& $this->valF['state'] === self::STATUS_DONE) { |
873 |
|
// |
874 |
|
$this->valF['json_payload'] = $this->view_form_json(true); |
875 |
|
} |
876 |
|
// Lorsque la task passe d'un état "done" à un état qui n'est pas "done" |
877 |
|
if ($this->getVal("state") === self::STATUS_DONE |
878 |
|
&& $this->valF['state'] !== self::STATUS_DONE) { |
879 |
|
// |
880 |
|
$this->valF['json_payload'] = "{}"; |
881 |
|
} |
882 |
|
} |
883 |
|
|
884 |
|
return true; |
885 |
|
} |
886 |
|
|
887 |
|
|
888 |
|
/** |
889 |
|
* Applique nouvelle valeur après traitement. |
890 |
|
* |
891 |
|
* @param array $params Tableau des valeurs en entrées |
892 |
|
* @return array Tableau des valeurs en sorties |
893 |
|
*/ |
894 |
|
public function set_values_for_update($params = array()) { |
895 |
|
|
896 |
|
// Récupération du timestamp_log existant |
897 |
|
$timestamp_log = $this->get_timestamp_log(); |
898 |
|
if ($timestamp_log === false) { |
899 |
|
return false; |
900 |
|
} |
901 |
|
|
902 |
|
// Vérification des object_id précédent en cas de tentative d'appliquer |
903 |
|
// l'état CANCELED sur la tâche |
904 |
|
if (isset($params['state']) === true |
905 |
|
&& $params['state'] === self::STATUS_CANCELED) { |
906 |
|
// Récupération du journal d'activité de la tâche sous forme de tableau |
907 |
|
// trié par ordre décroissant |
908 |
|
$log = $timestamp_log; |
909 |
|
krsort($log); |
910 |
|
// Pour chaque entrée dans le journal d'activité de la tâche : |
911 |
|
// - vérification de la présence de l'object_id précédent |
912 |
|
// - vérification que l'object_id précédent existe toujours dans la base de données |
913 |
|
// - l'object_id est mise à jour avec la valeur de l'object_id précédent |
914 |
|
// - le state n'est pas modifié |
915 |
|
// - sortie du traitement dès que le premier object_id précédent existant est trouvé |
916 |
|
// - si aucun object_id précédent existant n'est trouvé alors ni le state, ni l'object_id n'est modifiés |
917 |
|
foreach ($log as $key => $value) { |
918 |
|
// |
919 |
|
if (isset($value['prev_object_id']) === true |
920 |
|
&& $this->getVal('object_id') !== $value['prev_object_id']) { |
921 |
|
// Récupère la liste des tables potentielles pour un type de tâche |
922 |
|
$tables = $this->get_tables_by_task_type($this->getVal('type'), $this->getVal('stream')); |
923 |
|
foreach ($tables as $table) { |
924 |
|
// Vérifie s'il y a un ou aucun résultat |
925 |
|
$qres = $this->f->get_one_result_from_db_query( |
926 |
|
sprintf( |
927 |
|
'SELECT |
928 |
|
COUNT(%2$s) |
929 |
|
FROM |
930 |
|
%1$s%2$s |
931 |
|
WHERE |
932 |
|
%2$s::CHARACTER VARYING = \'%3$s\'', |
933 |
|
DB_PREFIXE, |
934 |
|
$table, |
935 |
|
$value['prev_object_id'] |
936 |
|
), |
937 |
|
array( |
938 |
|
"origin" => __METHOD__, |
939 |
|
"force_return" => true, |
940 |
|
) |
941 |
|
); |
942 |
|
if ($qres["code"] !== "OK") { |
943 |
|
return $this->end_treatment(__METHOD__, false); |
944 |
|
} |
945 |
|
// Affectation des valeurs et sortie de la boucle |
946 |
|
if ($qres["result"] == '1') { |
947 |
|
$params['object_id'] = $value['prev_object_id']; |
948 |
|
$params['state'] = $this->getVal('state'); |
949 |
|
break; |
950 |
|
} |
951 |
|
} |
952 |
|
// Sortie de la boucle si les valeurs sont affectées |
953 |
|
if ($params['object_id'] !== null |
954 |
|
&& $params['object_id'] === $value['prev_object_id']) { |
955 |
|
// |
956 |
|
break; |
957 |
|
} |
958 |
|
} |
959 |
|
} |
960 |
|
} |
961 |
|
|
962 |
|
// Mise à jour du journal d'activité de la tâche |
963 |
|
array_push($timestamp_log, array( |
964 |
|
'modification_date' => date('Y-m-d H:i:s'), |
965 |
|
'object_id' => $params['object_id'] !== null ? $params['object_id'] : $this->getVal('object_id'), |
966 |
|
'prev_object_id' => $this->getVal('object_id'), |
967 |
|
'state' => $params['state'], |
968 |
|
'prev_state' => $this->getVal('state'), |
969 |
|
'comment' => isset($params['comment']) ? $params['comment'] : $this->getVal('comment'), |
970 |
|
)); |
971 |
|
// |
972 |
|
$timestamp_log = json_encode($timestamp_log); |
973 |
|
|
974 |
|
|
975 |
|
// Les nouvelles valeurs après vérification des critères |
976 |
|
$result = array( |
977 |
|
'timestamp_log' => $timestamp_log, |
978 |
|
'object_id' => $params['object_id'], |
979 |
|
'state' => $params['state'], |
980 |
|
'comment' => $params['comment'], |
981 |
|
); |
982 |
|
return $result; |
983 |
|
} |
984 |
|
|
985 |
|
|
986 |
|
/** |
987 |
|
* TRIGGER - triggermodifierapres. |
988 |
|
* |
989 |
|
* @param string $id |
990 |
|
* @param null &$dnu1 @deprecated Ne pas utiliser. |
991 |
|
* @param array $val Tableau des valeurs brutes. |
992 |
|
* @param null $dnu2 @deprecated Ne pas utiliser. |
993 |
|
* |
994 |
|
* @return boolean |
995 |
|
*/ |
996 |
|
public function triggermodifierapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
997 |
|
parent::triggermodifierapres($id, $dnu1, $val, $dnu2); |
998 |
|
|
999 |
|
// Suivi des notificiations |
1000 |
|
// En cas de changement de l'état de la tâche de notification, alors |
1001 |
|
// le suivi des dates de la notification et de l'instruction, est effectué |
1002 |
|
if (isset($val['category']) === true |
1003 |
|
&& $val['category'] === PORTAL |
1004 |
|
&& isset($val['type']) === true |
1005 |
|
&& ($val['type'] === 'notification_recepisse' |
1006 |
|
|| $val['type'] === 'notification_instruction' |
1007 |
|
|| $val['type'] === 'notification_decision' |
1008 |
|
|| $val['type'] === 'notification_service_consulte' |
1009 |
|
|| $val['type'] === 'notification_tiers_consulte')) { |
1010 |
|
// |
1011 |
|
if (isset($this->valF['state']) === true |
1012 |
|
&& $this->valF['state'] !== $this->getVal('state') |
1013 |
|
&& $this->valF['state'] !== self::STATUS_CANCELED) { |
1014 |
|
// |
1015 |
|
$inst_in = $this->f->get_inst__om_dbform(array( |
1016 |
|
"obj" => "instruction_notification", |
1017 |
|
"idx" => $val['object_id'], |
1018 |
)); |
)); |
1019 |
if(! $dossier = $inst_lien->get_id_dossier_from_external_uid( |
$valF_in = array(); |
1020 |
$json_payload['external_uids']['dossier'])){ |
foreach ($inst_in->champs as $champ) { |
1021 |
$error_msg = sprintf( |
$valF_in[$champ] = $inst_in->getVal($champ); |
1022 |
__("Aucune correspondance de dossier pour l'external_uid.dossier '%s'."), |
} |
1023 |
$json_payload['external_uids']['dossier']); |
// Par défaut la date d'envoi et la date de premier accès sur |
1024 |
$this->addToLog(__METHOD__."() : erreur : $error_msg", DEBUG_MODE); |
// la notification ne sont pas renseignées |
1025 |
$this->addToMessage($error_msg); |
$valF_in['date_envoi'] = null; |
1026 |
$this->correct = false; |
$valF_in['date_premier_acces'] = null; |
1027 |
|
// Lorsque la tâche est correctement traitée |
1028 |
|
if ($this->valF['state'] === self::STATUS_DONE) { |
1029 |
|
// |
1030 |
|
$valF_in['statut'] = __("envoyé"); |
1031 |
|
$valF_in['commentaire'] = __("Notification traitée"); |
1032 |
|
$valF_in['date_envoi'] = date('d/m/Y H:i:s'); |
1033 |
|
// Si l'instruction possède un document lié, alors ses dates |
1034 |
|
// de suivi sont mises à jour |
1035 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
1036 |
|
"obj" => "instruction", |
1037 |
|
"idx" => $inst_in->getVal('instruction'), |
1038 |
|
)); |
1039 |
|
if ($inst_instruction->has_an_edition() === true) { |
1040 |
|
$valF_instruction = array(); |
1041 |
|
foreach ($inst_instruction->champs as $champ) { |
1042 |
|
$valF_instruction[$champ] = $inst_instruction->getVal($champ); |
1043 |
|
} |
1044 |
|
$valF_instruction['date_envoi_rar'] = date('d/m/Y'); |
1045 |
|
$valF_instruction['date_retour_rar'] = date('d/m/Y', strtotime('now + 1 day')); |
1046 |
|
// Action spécifique pour identifier que la modification |
1047 |
|
// est une notification de demandeur |
1048 |
|
$inst_instruction->setParameter('maj', 175); |
1049 |
|
$update_instruction = $inst_instruction->modifier($valF_instruction); |
1050 |
|
if ($update_instruction === false) { |
1051 |
|
$this->addToLog(__METHOD__."(): ".$inst_instruction->msg, DEBUG_MODE); |
1052 |
|
return false; |
1053 |
|
} |
1054 |
|
} |
1055 |
|
} |
1056 |
|
// En cas d'erreur lors du traitement de la task |
1057 |
|
if ($this->valF['state'] === self::STATUS_ERROR) { |
1058 |
|
$valF_in['statut'] = __("échec"); |
1059 |
|
$valF_in['commentaire'] = __("Le traitement de la notification a échoué"); |
1060 |
|
} |
1061 |
|
// Met à jour la notification |
1062 |
|
$inst_in->setParameter('maj', 1); |
1063 |
|
$update_in = $inst_in->modifier($valF_in); |
1064 |
|
if ($update_in === false) { |
1065 |
|
$this->addToLog(__METHOD__."(): ".$inst_in->msg, DEBUG_MODE); |
1066 |
return false; |
return false; |
1067 |
} |
} |
1068 |
$this->valF["dossier"] = $dossier; |
} |
|
}*/ |
|
1069 |
} |
} |
1070 |
|
|
1071 |
|
// Envoi au contrôle de légalité |
1072 |
|
// En cas de changement de l'état de la tâche envoi_CL, alors le suivi |
1073 |
|
// des dates de l'instruction est effectué |
1074 |
|
if ($val['type'] === 'envoi_CL' |
1075 |
|
&& isset($this->valF['state']) === true |
1076 |
|
&& $this->valF['state'] === self::STATUS_DONE) { |
1077 |
|
// |
1078 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
1079 |
|
"obj" => "instruction", |
1080 |
|
"idx" => $this->getVal('object_id'), |
1081 |
|
)); |
1082 |
|
if ($inst_instruction->has_an_edition() === true) { |
1083 |
|
$valF_instruction = array(); |
1084 |
|
foreach ($inst_instruction->champs as $champ) { |
1085 |
|
$valF_instruction[$champ] = $inst_instruction->getVal($champ); |
1086 |
|
} |
1087 |
|
} |
1088 |
|
$valF_instruction['date_envoi_controle_legalite'] = date("Y-m-d"); |
1089 |
|
$inst_instruction->setParameter('maj', 1); |
1090 |
|
$update_instruction = $inst_instruction->modifier($valF_instruction); |
1091 |
|
if ($update_instruction === false) { |
1092 |
|
$this->addToLog(__METHOD__."(): ".$inst_instruction->msg, DEBUG_MODE); |
1093 |
|
return false; |
1094 |
|
} |
1095 |
|
} |
1096 |
|
|
1097 |
|
// |
1098 |
|
return true; |
1099 |
} |
} |
1100 |
|
|
1101 |
/** |
/** |
1110 |
|
|
1111 |
// Vérifie si la task doit être ajoutée en fonction du mode de l'application, |
// Vérifie si la task doit être ajoutée en fonction du mode de l'application, |
1112 |
// seulement pour les tasks output |
// seulement pour les tasks output |
1113 |
$task_types_si = array( |
$task_types_si = self::TASK_TYPE_SI; |
1114 |
'creation_DA', |
$task_types_sc = self::TASK_TYPE_SC; |
|
'creation_DI', |
|
|
'depot_DI', |
|
|
'modification_DI', |
|
|
'qualification_DI', |
|
|
'decision_DI', |
|
|
'incompletude_DI', |
|
|
'completude_DI', |
|
|
'ajout_piece', |
|
|
'add_piece', |
|
|
); |
|
|
$task_types_sc = array( |
|
|
'create_DI_for_consultation', |
|
|
'avis_consultation', |
|
|
'pec_metier_consultation', |
|
|
); |
|
1115 |
$stream = isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output'; |
$stream = isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output'; |
1116 |
if ($stream === 'output' |
if ($stream === 'output' |
1117 |
&& isset($params['val']['type']) === true |
&& isset($params['val']['type']) === true |
1128 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
1129 |
} |
} |
1130 |
|
|
1131 |
$timestamp_log = json_encode(array( |
// |
1132 |
'creation_date' => date('Y-m-d H:i:s'), |
$timestamp_log = json_encode(array()); |
1133 |
)); |
|
1134 |
|
// |
1135 |
|
$category = isset($params['val']['category']) === true ? $params['val']['category'] : $this->category; |
1136 |
|
|
1137 |
// Si la tâche est de type ajout_piece et de stream input alors on ajoute le fichier |
// Si la tâche est de type ajout_piece et de stream input alors on ajoute le fichier |
1138 |
// et on ajoute l'uid dans le champ json_payload avant l'ajout de la tâche |
// et on ajoute l'uid dans le champ json_payload avant l'ajout de la tâche |
1139 |
if (isset($params['val']['type']) |
if (isset($params['val']['type']) |
1140 |
&& $params['val']['type'] == "add_piece" |
&& in_array($params['val']['type'], self::TASK_WITH_DOCUMENT) |
1141 |
&& isset($params['val']['stream']) |
&& isset($params['val']['stream']) |
1142 |
&& $params['val']['stream'] == "input" ) { |
&& $params['val']['stream'] == "input" ) { |
1143 |
// |
// |
1144 |
$json_payload = json_decode($params['val']['json_payload'], true); |
$json_payload = json_decode($params['val']['json_payload'], true); |
1145 |
$document_numerise = $json_payload['document_numerise']; |
if (json_last_error() !== JSON_ERROR_NONE) { |
1146 |
$file_content = base64_decode($document_numerise["file_content"]); |
$this->addToMessage(__("Le contenu JSON de la tâche n'est pas valide.")); |
|
if ($file_content === false){ |
|
|
$this->addToMessage(__("Le contenu du fichier lié à la tâche n'a pas pu etre recupere.")); |
|
1147 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
1148 |
} |
} |
1149 |
$metadata = array( |
if (isset($json_payload['document_numerise']["file_content"]) === true |
1150 |
"filename" => $document_numerise['nom_fichier'], |
&& empty($json_payload['document_numerise']["file_content"]) === false) { |
1151 |
"size" => strlen($file_content), |
// |
1152 |
"mimetype" => $document_numerise['file_content_type'], |
$document_numerise = $json_payload['document_numerise']; |
1153 |
"date_creation" => $document_numerise['date_creation'], |
$file_content = base64_decode($document_numerise["file_content"]); |
1154 |
); |
if ($file_content === false){ |
1155 |
$uid_fichier = $this->f->storage->create($file_content, $metadata, "from_content"); |
$this->addToMessage(__("Le contenu du fichier lié à la tâche n'a pas pu etre recupere.")); |
1156 |
if ($uid_fichier === OP_FAILURE) { |
return $this->end_treatment(__METHOD__, false); |
1157 |
$this->addToMessage(__("Erreur lors de la creation du fichier lié à la tâche.")); |
} |
1158 |
return $this->end_treatment(__METHOD__, false); |
$metadata = array( |
1159 |
|
"filename" => $document_numerise['nom_fichier'], |
1160 |
|
"size" => strlen($file_content), |
1161 |
|
"mimetype" => $document_numerise['file_content_type'], |
1162 |
|
"date_creation" => isset($document_numerise['date_creation']) === true ? $document_numerise['date_creation'] : date("Y-m-d"), |
1163 |
|
); |
1164 |
|
$uid_fichier = $this->f->storage->create($file_content, $metadata, "from_content", "task.uid_fichier"); |
1165 |
|
if ($uid_fichier === OP_FAILURE) { |
1166 |
|
$this->addToMessage(__("Erreur lors de la creation du fichier lié à la tâche.")); |
1167 |
|
return $this->end_treatment(__METHOD__, false); |
1168 |
|
} |
1169 |
|
$json_payload["document_numerise"]["uid"] = $uid_fichier; |
1170 |
|
// Le fichier a été ajouté nous n'avons plus besoin du champ file_content dans la payload |
1171 |
|
unset($json_payload["document_numerise"]["file_content"]); |
1172 |
|
$params['val']['json_payload'] = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
1173 |
} |
} |
|
$json_payload["document_numerise"]["uid"] = $uid_fichier; |
|
|
// Le fichier a été ajouté nous n'avons plus besoin du champ file_content dans la payload |
|
|
unset($json_payload["document_numerise"]["file_content"]); |
|
|
$params['val']['json_payload'] = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
|
1174 |
} |
} |
1175 |
|
|
1176 |
// Mise à jour du DI |
// Valeurs de la tâche |
1177 |
$valF = array( |
$valF = array( |
1178 |
'task' => '', |
'task' => '', |
1179 |
'type' => $params['val']['type'], |
'type' => $params['val']['type'], |
1183 |
'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '', |
'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '', |
1184 |
'stream' => $stream, |
'stream' => $stream, |
1185 |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
1186 |
|
'category' => $category, |
1187 |
|
'creation_date' => date('Y-m-d'), |
1188 |
|
'creation_time' => date('H:i:s'), |
1189 |
|
'last_modification_date' => null, |
1190 |
|
'last_modification_time' => null, |
1191 |
|
'comment' => null, |
1192 |
); |
); |
1193 |
|
|
1194 |
// tâche sortante |
// Gestion de la mise à jour des tâches sortantes |
1195 |
if($valF["stream"] == "output"){ |
$typeNonConcerne = array( |
1196 |
|
'notification_recepisse', |
1197 |
|
'notification_instruction', |
1198 |
|
'notification_decision', |
1199 |
|
'notification_service_consulte', |
1200 |
|
'notification_tiers_consulte' |
1201 |
|
); |
1202 |
|
if ($valF["stream"] == "output" |
1203 |
|
&& ! in_array($valF['type'], $typeNonConcerne)) { |
1204 |
|
// Vérification de l'existance d'une tâche pour l'objet concerné |
1205 |
|
// La vérification diffère en fonction de certains types de tâche |
1206 |
|
$search_values_common = array( |
1207 |
|
sprintf('state != \'%s\'', self::STATUS_CANCELED), |
1208 |
|
sprintf('state != \'%s\'', self::STATUS_DONE), |
1209 |
|
); |
1210 |
|
$search_values_others = array( |
1211 |
|
sprintf('type = \'%s\'', $valF['type']), |
1212 |
|
sprintf('(object_id = \'%s\' OR dossier = \'%s\')', $valF['object_id'], $valF['dossier']), |
1213 |
|
); |
1214 |
|
$search_values_specifics = array( |
1215 |
|
sprintf('object_id = \'%s\'', $valF['object_id']), |
1216 |
|
); |
1217 |
|
|
1218 |
|
// Recherche multi-critères sur les tâches |
1219 |
|
// Si l'object id/dossier à des tâches de type $valF['type'] qui lui est associé |
1220 |
|
// Et que ces tâches ont des statut différents de canceled et done |
1221 |
|
// Alors on récupère ces tâches |
1222 |
|
// Sinon return false |
1223 |
|
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_others)); |
1224 |
|
|
1225 |
// TODO expliquer ce code |
// S'il n'existe pas de tâche de type 'modification DI' pour l'object id/dossier |
|
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
|
1226 |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
1227 |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
// On se réfère à la tâche de type 'creation DI' de l'object id |
1228 |
|
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_specifics, array("type = 'creation_DI'"))); |
1229 |
|
} |
1230 |
|
// S'il n'existe pas de tâche de type 'modification DA' pour l'object id/dossier |
1231 |
|
if ($valF['type'] === 'modification_DA' && $task_exists === false) { |
1232 |
|
// On se réfère à la tâche de type 'creation DA' de l'object id |
1233 |
|
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_specifics, array("type = 'creation_DA'"))); |
1234 |
|
} |
1235 |
|
if ($valF['type'] === 'ajout_piece') { |
1236 |
|
// On se réfère à la tâche de type 'ajout piece' de l'object id |
1237 |
|
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_specifics, array("type = 'ajout_piece'"))); |
1238 |
|
} |
1239 |
|
if ($valF['type'] === 'creation_consultation') { |
1240 |
|
// On se réfère à la tâche de type 'creation consultation' de l'object id |
1241 |
|
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_specifics, array("type = 'creation_consultation'"))); |
1242 |
} |
} |
1243 |
|
// S'il existe une tâche pour l'objet concerné, pas d'ajout de nouvelle |
1244 |
|
// tâche mais mise à jour de l'existante |
1245 |
if ($task_exists !== false) { |
if ($task_exists !== false) { |
1246 |
$inst_task = $this->f->get_inst__om_dbform(array( |
// Plusieurs tâches pourraient exister, elles sont contôler par ordre croissant |
1247 |
"obj" => "task", |
foreach ($task_exists as $task) { |
1248 |
"idx" => $task_exists, |
$inst_task = $this->f->get_inst__om_dbform(array( |
1249 |
)); |
"obj" => "task", |
1250 |
$update_state = $inst_task->getVal('state'); |
"idx" => $task['task'], |
1251 |
if (isset($params['update_val']['state']) === true) { |
)); |
1252 |
$update_state = $params['update_val']['state']; |
$update_state = $inst_task->getVal('state'); |
1253 |
} |
if (isset($params['update_val']['state']) === true) { |
1254 |
$update_params = array( |
$update_state = $params['update_val']['state']; |
1255 |
'val' => array( |
} |
1256 |
'state' => $update_state, |
$object_id = $inst_task->getVal('object_id'); |
1257 |
), |
if (!empty($valF['object_id'])) { |
1258 |
); |
$object_id = $valF['object_id']; |
1259 |
return $inst_task->update_task($update_params); |
} |
1260 |
|
// Pour être mise à jour, la tâche existante ne doit pas être en cours de traitement |
1261 |
|
$task_pending = $inst_task->getVal('state') === self::STATUS_PENDING |
1262 |
|
&& $update_state === self::STATUS_PENDING |
1263 |
|
&& $inst_task->getVal('object_id') !== $object_id; |
1264 |
|
if ($task_pending === false) { |
1265 |
|
$update_params = array( |
1266 |
|
'val' => array( |
1267 |
|
'state' => $update_state, |
1268 |
|
), |
1269 |
|
'object_id' => $object_id, |
1270 |
|
); |
1271 |
|
return $inst_task->update_task($update_params); |
1272 |
|
} |
1273 |
|
} |
1274 |
} |
} |
1275 |
} |
} |
|
|
|
1276 |
$add = $this->ajouter($valF); |
$add = $this->ajouter($valF); |
1277 |
$this->addToLog(__METHOD__."(): retour de l'ajout de tâche: ".var_export($add, true), VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): retour de l'ajout de tâche: ".var_export($add, true), VERBOSE_MODE); |
1278 |
if ($add === false) { |
if ($add === false) { |
1291 |
*/ |
*/ |
1292 |
public function update_task($params = array()) { |
public function update_task($params = array()) { |
1293 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
1294 |
$timestamp_log = $this->get_timestamp_log(); |
|
1295 |
if ($timestamp_log === false) { |
// Mise à jour de la tâche |
|
$this->addToLog(__METHOD__."(): erreur timestamp log", DEBUG_MODE); |
|
|
return $this->end_treatment(__METHOD__, false); |
|
|
} |
|
|
array_push($timestamp_log, array( |
|
|
'modification_date' => date('Y-m-d H:i:s'), |
|
|
'state' => $params['val']['state'], |
|
|
'prev_state' => $this->getVal('state'), |
|
|
)); |
|
|
$timestamp_log = json_encode($timestamp_log); |
|
1296 |
$valF = array( |
$valF = array( |
1297 |
'task' => $this->getVal($this->clePrimaire), |
'task' => $this->getVal($this->clePrimaire), |
1298 |
'type' => $this->getVal('type'), |
'type' => $this->getVal('type'), |
1299 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => '[]', |
1300 |
'state' => $params['val']['state'], |
'state' => $params['val']['state'], |
1301 |
'object_id' => $this->getVal('object_id'), |
'object_id' => isset($params['object_id']) == true ? $params['object_id'] : $this->getVal('object_id'), |
1302 |
'stream' => $this->getVal('stream'), |
'stream' => $this->getVal('stream'), |
1303 |
'dossier' => $this->getVal('dossier'), |
'dossier' => $this->getVal('dossier'), |
1304 |
'json_payload' => $this->getVal('json_payload'), |
'json_payload' => $this->getVal('json_payload'), |
1305 |
|
'category' => $this->getVal('category'), |
1306 |
|
'creation_date' => $this->getVal('creation_date'), |
1307 |
|
'creation_time' => $this->getVal('creation_time'), |
1308 |
|
'last_modification_date' => date('Y-m-d'), |
1309 |
|
'last_modification_time' => date('H:i:s'), |
1310 |
|
'comment' => isset($params['comment']) == true ? $params['comment'] : $this->getVal('comment'), |
1311 |
); |
); |
1312 |
$update = $this->modifier($valF); |
$update = $this->modifier($valF); |
1313 |
if ($update === false) { |
if ($update === false) { |
1356 |
|
|
1357 |
protected function view_tab_json() { |
protected function view_tab_json() { |
1358 |
$where = ''; |
$where = ''; |
1359 |
if ($this->f->get_submitted_get_value('state') !== null |
$category = null; |
1360 |
&& $this->f->get_submitted_get_value('state') !== '') { |
// Liste des paramètres possibles pour la recherche des tâches |
1361 |
// |
$params = array( |
1362 |
$where = sprintf(' WHERE state = \'%s\' ', $this->f->get_submitted_get_value('state')); |
'task', |
1363 |
|
'type', |
1364 |
|
'state', |
1365 |
|
'object_id', |
1366 |
|
'dossier', |
1367 |
|
'stream', |
1368 |
|
'category', |
1369 |
|
'lien_id_interne_uid_externe', |
1370 |
|
'object', |
1371 |
|
'external_uid', |
1372 |
|
); |
1373 |
|
// Pour chaque paramètre possible, vérification de son existance et de sa |
1374 |
|
// valeur pour compléter la requête de recherche |
1375 |
|
foreach ($params as $param) { |
1376 |
|
// |
1377 |
|
if ($this->f->get_submitted_get_value($param) !== null |
1378 |
|
&& $this->f->get_submitted_get_value($param) !== '') { |
1379 |
|
// Condition spécifique au champ 'category' |
1380 |
|
if ($param === 'category') { |
1381 |
|
$category = $this->f->get_submitted_get_value('category'); |
1382 |
|
} |
1383 |
|
// |
1384 |
|
$where_or_and = 'WHERE'; |
1385 |
|
if ($where !== '') { |
1386 |
|
$where_or_and = 'AND'; |
1387 |
|
} |
1388 |
|
$table = 'task'; |
1389 |
|
if ($param === 'lien_id_interne_uid_externe' |
1390 |
|
|| $param === 'object' |
1391 |
|
|| $param === 'external_uid') { |
1392 |
|
// |
1393 |
|
$table = 'lien_id_interne_uid_externe'; |
1394 |
|
} |
1395 |
|
$where .= sprintf(' %s %s.%s = \'%s\' ', $where_or_and, $table, $param, $this->f->get_submitted_get_value($param)); |
1396 |
|
} |
1397 |
} |
} |
1398 |
|
// |
1399 |
$query = sprintf(' |
$query = sprintf(' |
1400 |
SELECT |
SELECT |
1401 |
* |
task.* |
1402 |
FROM %1$stask |
FROM %1$stask |
1403 |
|
LEFT JOIN %1$slien_id_interne_uid_externe |
1404 |
|
ON task.object_id = lien_id_interne_uid_externe.object_id |
1405 |
|
AND task.category = lien_id_interne_uid_externe.category |
1406 |
%2$s |
%2$s |
1407 |
ORDER BY task ASC |
ORDER BY task ASC |
1408 |
', |
', |
1409 |
DB_PREFIXE, |
DB_PREFIXE, |
1410 |
$where |
$where |
1411 |
); |
); |
1412 |
$res = $this->f->get_all_results_from_db_query($query, true); |
$res = $this->f->get_all_results_from_db_query( |
1413 |
|
$query, |
1414 |
|
array( |
1415 |
|
"origin" => __METHOD__, |
1416 |
|
"force_return" => true, |
1417 |
|
) |
1418 |
|
); |
1419 |
if ($res['code'] === 'KO') { |
if ($res['code'] === 'KO') { |
1420 |
return false; |
return false; |
1421 |
} |
} |
1422 |
$list_tasks = array(); |
$list_tasks = array(); |
1423 |
foreach ($res['result'] as $task) { |
foreach ($res['result'] as $task) { |
1424 |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
unset($task['timestamp_log']); |
1425 |
$task['dossier'] = $task['object_id']; |
unset($task['json_payload']); |
1426 |
if ($this->get_lien_objet_by_type($task['type']) === 'document_numerise') { |
if ($task['type'] === 'ajout_piece') { |
1427 |
$val_dn = $this->get_document_numerise_data($task['object_id']); |
$val_dn = $this->get_document_numerise_data($task['object_id']); |
1428 |
$task['dossier'] = $val_dn['dossier']; |
} |
1429 |
|
if ($task['stream'] === 'output') { |
1430 |
|
$task['external_uids'] = array_merge( |
1431 |
|
$this->get_all_external_uids($task['dossier'], array(), $category !== null ? $category : $task['category']), |
1432 |
|
$this->get_all_external_uids($task['object_id'], array(), $category !== null ? $category : $task['category']) |
1433 |
|
); |
1434 |
} |
} |
1435 |
$list_tasks[$task['task']] = $task; |
$list_tasks[$task['task']] = $task; |
1436 |
} |
} |
1437 |
printf(json_encode($list_tasks)); |
echo(json_encode($list_tasks)); |
1438 |
} |
} |
1439 |
|
|
1440 |
protected function get_dossier_data(string $dossier) { |
protected function get_dossier_data(string $dossier) { |
1443 |
"obj" => "dossier", |
"obj" => "dossier", |
1444 |
"idx" => $dossier, |
"idx" => $dossier, |
1445 |
)); |
)); |
1446 |
|
if (empty($inst_di->val) === true) { |
1447 |
|
return $val_di; |
1448 |
|
} |
1449 |
$val_di = $inst_di->get_json_data(); |
$val_di = $inst_di->get_json_data(); |
1450 |
if ($val_di['dossier_instruction_type_code'] === 'T') { |
if ($val_di['dossier_instruction_type_code'] === 'T') { |
1451 |
$val_di['date_decision_transfert'] = $val_di['date_decision']; |
$val_di['date_decision_transfert'] = $val_di['date_decision']; |
1536 |
if (isset($val_dt['tax_ext_pret']) === true |
if (isset($val_dt['tax_ext_pret']) === true |
1537 |
&& $val_dt['tax_ext_pret'] === 'f') { |
&& $val_dt['tax_ext_pret'] === 'f') { |
1538 |
// |
// |
1539 |
$val_dt['tax_su_princ_surf1'] = $val_dt['tax_surf_tot_cstr']; |
$val_dt['tax_su_princ_surf1'] = isset($val_dt['tax_surf_tot_cstr']) === true ? $val_dt['tax_surf_tot_cstr'] : ''; |
1540 |
$val_dt['tax_su_princ_surf_stat1'] = $val_dt['tax_surf_loc_stat']; |
$val_dt['tax_su_princ_surf_stat1'] = isset($val_dt['tax_surf_loc_stat']) === true ? $val_dt['tax_surf_loc_stat'] : ''; |
1541 |
} |
} |
1542 |
if (isset($val_dt['tax_ext_pret']) === true |
if (isset($val_dt['tax_ext_pret']) === true |
1543 |
&& $val_dt['tax_ext_pret'] === 't') { |
&& $val_dt['tax_ext_pret'] === 't') { |
1546 |
if (preg_match('/[pP].*[lL].*[aA].*[iI]/', $val_dt['tax_ext_desc']) === 1 |
if (preg_match('/[pP].*[lL].*[aA].*[iI]/', $val_dt['tax_ext_desc']) === 1 |
1547 |
|| preg_match('/[lL].*[lL].*[tT].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
|| preg_match('/[lL].*[lL].*[tT].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
1548 |
// |
// |
1549 |
$val_dt['tax_su_princ_surf2'] = $val_dt['tax_surf_tot_cstr']; |
$val_dt['tax_su_princ_surf2'] = isset($val_dt['tax_surf_tot_cstr']) === true ? $val_dt['tax_surf_tot_cstr'] : ''; |
1550 |
$val_dt['tax_su_princ_surf_stat2'] = $val_dt['tax_surf_loc_stat']; |
$val_dt['tax_su_princ_surf_stat2'] = isset($val_dt['tax_surf_loc_stat']) === true ? $val_dt['tax_surf_loc_stat'] : ''; |
1551 |
} |
} |
1552 |
// if (preg_match('/[pP].*[tT].*[zZ]/', $val_dt['tax_ext_desc']) === 1) { |
// if (preg_match('/[pP].*[tT].*[zZ]/', $val_dt['tax_ext_desc']) === 1) { |
1553 |
// $val_dt['tax_su_princ_surf4'] = $val_dt['tax_surf_tot_cstr']; |
// $val_dt['tax_su_princ_surf4'] = $val_dt['tax_surf_tot_cstr']; |
1576 |
return $val_dt; |
return $val_dt; |
1577 |
} |
} |
1578 |
|
|
1579 |
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
/** |
1580 |
|
* Récupère la liste des objets distincts existants dans la table des liens |
1581 |
|
* entre identifiants internes et identifiants externes. |
1582 |
|
* |
1583 |
|
* @return array |
1584 |
|
*/ |
1585 |
|
protected function get_list_distinct_objects_external_link() { |
1586 |
|
$query = sprintf(' |
1587 |
|
SELECT |
1588 |
|
DISTINCT(object) |
1589 |
|
FROM %1$slien_id_interne_uid_externe |
1590 |
|
ORDER BY object ASC |
1591 |
|
', |
1592 |
|
DB_PREFIXE |
1593 |
|
); |
1594 |
|
$res = $this->f->get_all_results_from_db_query( |
1595 |
|
$query, |
1596 |
|
array( |
1597 |
|
"origin" => __METHOD__, |
1598 |
|
"force_return" => true, |
1599 |
|
) |
1600 |
|
); |
1601 |
|
if ($res['code'] === 'KO') { |
1602 |
|
return array(); |
1603 |
|
} |
1604 |
|
$result = array(); |
1605 |
|
foreach ($res['result'] as $object) { |
1606 |
|
$result[] = $object['object']; |
1607 |
|
} |
1608 |
|
return $result; |
1609 |
|
} |
1610 |
|
|
1611 |
|
protected function get_external_uid($fk_idx, string $fk_idx_2, $fk_idx_3 = PLATAU, $order_asc_desc = 'DESC') { |
1612 |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
1613 |
"obj" => "lien_id_interne_uid_externe", |
"obj" => "lien_id_interne_uid_externe", |
1614 |
"fk_field" => 'object_id', |
"fk_field" => 'object_id', |
1615 |
"fk_idx" => $fk_idx, |
"fk_idx" => $fk_idx, |
1616 |
"fk_field_2" => 'object', |
"fk_field_2" => 'object', |
1617 |
"fk_idx_2" => $fk_idx_2, |
"fk_idx_2" => $fk_idx_2, |
1618 |
|
"fk_field_3" => 'category', |
1619 |
|
"fk_idx_3" => $fk_idx_3, |
1620 |
|
"order_field" => 'lien_id_interne_uid_externe', |
1621 |
|
"order_asc_desc" => $order_asc_desc, |
1622 |
)); |
)); |
1623 |
return $inst_external_uid->getVal('external_uid'); |
return $inst_external_uid->getVal('external_uid'); |
1624 |
} |
} |
1625 |
|
|
1626 |
protected function get_demandeurs_data(string $dossier) { |
protected function get_all_external_uids($fk_idx, $link_objects = array(), $category=PLATAU) { |
1627 |
|
if (count($link_objects) == 0) { |
1628 |
|
$link_objects = $this->get_list_distinct_objects_external_link(); |
1629 |
|
} |
1630 |
|
$val_external_uid = array(); |
1631 |
|
foreach ($link_objects as $link_object) { |
1632 |
|
$external_uid = $this->get_external_uid($fk_idx, $link_object, $category); |
1633 |
|
if ($external_uid !== '' && $external_uid !== null) { |
1634 |
|
$val_external_uid[$link_object] = $external_uid; |
1635 |
|
} |
1636 |
|
} |
1637 |
|
return $val_external_uid; |
1638 |
|
} |
1639 |
|
|
1640 |
|
protected function get_demandeurs_data($dossier) { |
1641 |
$val_demandeur = array(); |
$val_demandeur = array(); |
1642 |
|
if ($dossier === null) { |
1643 |
|
return $val_demandeur; |
1644 |
|
} |
1645 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
1646 |
"obj" => "dossier", |
"obj" => "dossier", |
1647 |
"idx" => $dossier, |
"idx" => $dossier, |
1672 |
return $val_architecte; |
return $val_architecte; |
1673 |
} |
} |
1674 |
|
|
1675 |
protected function get_instruction_data(string $dossier, $type = 'decision', $extra_params = array()) { |
protected function get_instruction_data($dossier, $type = 'decision', $extra_params = array()) { |
1676 |
$val_instruction = null; |
$val_instruction = null; |
1677 |
|
if ($dossier === null) { |
1678 |
|
return $val_instruction; |
1679 |
|
} |
1680 |
$instruction_with_doc = null; |
$instruction_with_doc = null; |
1681 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
1682 |
"obj" => "dossier", |
"obj" => "dossier", |
1736 |
return $val_instruction; |
return $val_instruction; |
1737 |
} |
} |
1738 |
|
|
1739 |
|
|
1740 |
|
/** |
1741 |
|
* Récupère les informations pour les notifications ayant plusieurs annexe |
1742 |
|
*/ |
1743 |
|
protected function get_instruction_notification_data($category, $type = '', $extra_params = array()) { |
1744 |
|
$val_in = null; |
1745 |
|
|
1746 |
|
$idx = null; |
1747 |
|
if ($type === 'with-id') { |
1748 |
|
$idx = $extra_params['with-id']; |
1749 |
|
} |
1750 |
|
|
1751 |
|
// Récupération du type de notification. Le type est nécessaire pour récupérer |
1752 |
|
// le message et le titre de notification. |
1753 |
|
$typeNotification = $this->getVal('type'); |
1754 |
|
if (isset($this->valF['type'])) { |
1755 |
|
$typeNotification = $this->valF['type']; |
1756 |
|
} |
1757 |
|
|
1758 |
|
// récupére les données à intégrer à la payload |
1759 |
|
$inst_in = $this->f->get_inst__om_dbform(array( |
1760 |
|
"obj" => "instruction_notification", |
1761 |
|
"idx" => $idx, |
1762 |
|
)); |
1763 |
|
if (count($inst_in->val) > 0) { |
1764 |
|
$val_in = $inst_in->get_json_data(); |
1765 |
|
|
1766 |
|
$val_in['parametre_courriel_type_titre'] = ''; |
1767 |
|
$val_in['parametre_courriel_type_message'] = ''; |
1768 |
|
// Récupération du message et du titre |
1769 |
|
if ($category === 'mail') { |
1770 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
1771 |
|
"obj" => "instruction", |
1772 |
|
"idx" => $inst_in->getVal('instruction'), |
1773 |
|
)); |
1774 |
|
$collectivite_id = $inst_instruction->get_dossier_instruction_om_collectivite($inst_instruction->getVal('dossier')); |
1775 |
|
$phrase_type_notification = $this->f->get_notification_parametre_courriel_type($collectivite_id, $typeNotification); |
1776 |
|
$val_in['parametre_courriel_type_titre'] = $phrase_type_notification['parametre_courriel_type_titre']; |
1777 |
|
$val_in['parametre_courriel_type_message'] = $phrase_type_notification['parametre_courriel_type_message']; |
1778 |
|
} |
1779 |
|
|
1780 |
|
// Récupération des liens vers les documents et des id et type des annexes |
1781 |
|
$infoDocNotif = $inst_in->getInfosDocumentsNotif($inst_in->getVal($inst_in->clePrimaire), $category); |
1782 |
|
$cle = $category == PORTAL ? 'path' : 'lien_telechargement_document'; |
1783 |
|
$val_in[$cle] = $infoDocNotif['document']['path']; |
1784 |
|
$val_in['annexes'] = $infoDocNotif['annexes']; |
1785 |
|
} |
1786 |
|
return $val_in; |
1787 |
|
} |
1788 |
|
|
1789 |
|
/** |
1790 |
|
* Récupère les informations concernant la lettre au pétitionnaire. |
1791 |
|
* |
1792 |
|
* @param string identifiant du dossier |
1793 |
|
* @param string type de tâche |
1794 |
|
* @param array paramètre supplémentaire permettant de récupérer les informations |
1795 |
|
* |
1796 |
|
* @return array information concernant la lettre au pétitionnaire |
1797 |
|
*/ |
1798 |
|
protected function get_lettre_petitionnaire_data($dossier, $type, $extra_params = array()) { |
1799 |
|
// Si la date limite de notification n'a pas été dépassé le type de lettre est 1 |
1800 |
|
// Si la date a été dépassé et qu'il s'agit d'une demande de pièce le type est 3 |
1801 |
|
// Si la date a été dépassé et qu'il s'agit d'une prolongation le type est 4 |
1802 |
|
// Le type de document dépend du type de pièce |
1803 |
|
$nomTypeLettre = ''; |
1804 |
|
$nomTypeDocument = ''; |
1805 |
|
if ($type === 'lettre_incompletude') { |
1806 |
|
$nomTypeLettre = '3'; |
1807 |
|
$nomTypeDocument = '4'; |
1808 |
|
} elseif ($type === 'lettre_majoration') { |
1809 |
|
$nomTypeLettre = '4'; |
1810 |
|
$nomTypeDocument = '6'; |
1811 |
|
} |
1812 |
|
|
1813 |
|
$inst_di = $this->f->get_inst__om_dbform(array( |
1814 |
|
"obj" => "dossier", |
1815 |
|
"idx" => $dossier, |
1816 |
|
)); |
1817 |
|
$date_limite_notification = DateTime::createFromFormat('Y-m-d', $inst_di->getVal('date_notification_delai')); |
1818 |
|
$aujourdhui = new DateTime(); |
1819 |
|
if (! $date_limite_notification instanceof DateTime) { |
1820 |
|
$nomTypeLettre = ''; |
1821 |
|
$nomTypeDocument = ''; |
1822 |
|
} elseif ($aujourdhui < $date_limite_notification) { |
1823 |
|
$nomTypeLettre = '1'; |
1824 |
|
$nomTypeDocument = '3'; |
1825 |
|
} |
1826 |
|
|
1827 |
|
return array( |
1828 |
|
'nomEtatLettre' => '3', |
1829 |
|
'nomModaliteNotifMetier' => '4', |
1830 |
|
'nomTypeLettre' => $nomTypeLettre, |
1831 |
|
'nomTypeDocument' => $nomTypeDocument |
1832 |
|
); |
1833 |
|
} |
1834 |
|
|
1835 |
protected function sort_instruction_data(array $values, array $res) { |
protected function sort_instruction_data(array $values, array $res) { |
1836 |
$fields = array( |
$fields = array( |
1837 |
"date_evenement", |
"date_evenement", |
1845 |
"om_fichier_instruction", |
"om_fichier_instruction", |
1846 |
"tacite", |
"tacite", |
1847 |
"lettretype", |
"lettretype", |
1848 |
|
"commentaire", |
1849 |
|
"complement_om_html", |
1850 |
); |
); |
1851 |
foreach ($values as $key => $value) { |
foreach ($values as $key => $value) { |
1852 |
if (in_array($key, $fields) === true) { |
if (in_array($key, $fields) === true) { |
1865 |
return $res; |
return $res; |
1866 |
} |
} |
1867 |
|
|
1868 |
|
/** |
1869 |
|
* Permet de définir si l'instruction passée en paramètre est une instruction |
1870 |
|
* récépissé d'une demande et si la demande en question a générée un dossier d'instruction. |
1871 |
|
* |
1872 |
|
* @param integer $instruction Identifiant de l'instruction |
1873 |
|
* @return boolean |
1874 |
|
*/ |
1875 |
|
protected function is_demande_instruction_recepisse_without_dossier($instruction) { |
1876 |
|
if ($instruction === null) { |
1877 |
|
return false; |
1878 |
|
} |
1879 |
|
$qres = $this->f->get_one_result_from_db_query( |
1880 |
|
sprintf( |
1881 |
|
'SELECT |
1882 |
|
demande_type.dossier_instruction_type |
1883 |
|
FROM |
1884 |
|
%1$sdemande |
1885 |
|
INNER JOIN %1$sdemande_type |
1886 |
|
ON demande.demande_type = demande_type.demande_type |
1887 |
|
WHERE |
1888 |
|
demande.instruction_recepisse = %2$s', |
1889 |
|
DB_PREFIXE, |
1890 |
|
intval($instruction) |
1891 |
|
), |
1892 |
|
array( |
1893 |
|
"origin" => __METHOD__, |
1894 |
|
"force_return" => true, |
1895 |
|
) |
1896 |
|
); |
1897 |
|
if ($qres["code"] !== "OK") { |
1898 |
|
return null; |
1899 |
|
} |
1900 |
|
if ($qres["result"] === "") { |
1901 |
|
return true; |
1902 |
|
} |
1903 |
|
return false; |
1904 |
|
} |
1905 |
|
|
1906 |
protected function get_document_numerise_data(string $dn) { |
protected function get_document_numerise_data(string $dn) { |
1907 |
$val_dn = array(); |
$val_dn = array(); |
1908 |
$inst_dn = $this->f->get_inst__om_dbform(array( |
$inst_dn = $this->f->get_inst__om_dbform(array( |
1942 |
)); |
)); |
1943 |
$ad = $inst_di->getVal('avis_decision'); |
$ad = $inst_di->getVal('avis_decision'); |
1944 |
$val_ad = array(); |
$val_ad = array(); |
1945 |
$inst_ad = $this->f->get_inst__om_dbform(array( |
if ($ad !== null && trim($ad) !== '') { |
1946 |
"obj" => "avis_decision", |
$inst_ad = $this->f->get_inst__om_dbform(array( |
1947 |
"idx" => $ad, |
"obj" => "avis_decision", |
1948 |
)); |
"idx" => $ad, |
1949 |
$val_ad = $inst_ad->get_json_data(); |
)); |
1950 |
$val_ad['txAvis'] = "Voir document joint"; |
$val_ad = $inst_ad->get_json_data(); |
1951 |
|
$val_ad['txAvis'] = "Voir document joint"; |
1952 |
|
if (isset($val_ad['tacite']) === true |
1953 |
|
&& $val_ad['tacite'] === 't') { |
1954 |
|
// |
1955 |
|
$val_ad['txAvis'] = "Sans objet"; |
1956 |
|
} |
1957 |
|
} |
1958 |
return $val_ad; |
return $val_ad; |
1959 |
} |
} |
1960 |
|
|
1970 |
return $val_sa; |
return $val_sa; |
1971 |
} |
} |
1972 |
|
|
1973 |
|
// XXX WIP |
1974 |
|
protected function get_consultation_data(string $consultation) { |
1975 |
|
$val_consultation = array(); |
1976 |
|
$inst_consultation = $this->f->get_inst__om_dbform(array( |
1977 |
|
"obj" => "consultation", |
1978 |
|
"idx" => $consultation, |
1979 |
|
)); |
1980 |
|
$val_consultation = $inst_consultation->get_json_data(); |
1981 |
|
if (isset($val_consultation['fichier']) === true |
1982 |
|
&& $val_consultation['fichier'] !== '') { |
1983 |
|
// |
1984 |
|
$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')); |
1985 |
|
} |
1986 |
|
if (isset($val_consultation['om_fichier_consultation']) === true |
1987 |
|
&& $val_consultation['om_fichier_consultation'] !== '') { |
1988 |
|
// |
1989 |
|
$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')); |
1990 |
|
} |
1991 |
|
return $val_consultation; |
1992 |
|
} |
1993 |
|
|
1994 |
|
// XXX WIP |
1995 |
|
protected function get_service_data(string $service) { |
1996 |
|
$val_service = array(); |
1997 |
|
$inst_service = $this->f->get_inst__om_dbform(array( |
1998 |
|
"obj" => "service", |
1999 |
|
"idx" => $service, |
2000 |
|
)); |
2001 |
|
$val_service = $inst_service->get_json_data(); |
2002 |
|
return $val_service; |
2003 |
|
} |
2004 |
|
|
2005 |
protected function view_form_json($in_field = false) { |
protected function view_form_json($in_field = false) { |
2006 |
// |
// |
2007 |
if ($this->f->get_submitted_post_value('valid') === null) { |
$check_state = isset($this->valF['state']) === true ? $this->valF['state'] : $this->getVal('state'); |
2008 |
|
if ($check_state !== self::STATUS_CANCELED) { |
2009 |
// Liste des valeurs à afficher |
// Liste des valeurs à afficher |
2010 |
$val = array(); |
$val = array(); |
2011 |
// |
// |
2013 |
foreach ($val_task as $key => $value) { |
foreach ($val_task as $key => $value) { |
2014 |
$val_task[$key] = strip_tags($value); |
$val_task[$key] = strip_tags($value); |
2015 |
} |
} |
2016 |
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
|
2017 |
$val['task'] = $val_task; |
// Vérifie pour les tâches dont l'affichage de la payload est calculée si l'objet |
2018 |
// |
// de référence de la tâche existe. |
2019 |
if ($this->getVal('type') === 'creation_DA') { |
$objectRefExist = true; |
2020 |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
if ($val_task['stream'] === 'output' |
2021 |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
&& (empty($val_task['json_payload']) || $val_task['json_payload'] === '{}')) { |
2022 |
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
$objectRefExist = $this->does_referenced_object_exist( |
2023 |
$val_external_uid = array(); |
$val_task['object_id'], |
2024 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
$val_task['type'] |
2025 |
$val['external_uids'] = $val_external_uid; |
); |
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'creation_DI' |
|
|
|| $this->getVal('type') === 'modification_DI' |
|
|
|| $this->getVal('type') === 'depot_DI') { |
|
|
// |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
|
|
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction'); |
|
|
$val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']); |
|
|
$architecte = isset($val['donnees_techniques']['architecte']) === true ? $val['donnees_techniques']['architecte'] : null; |
|
|
$val['architecte'] = $this->get_architecte_data($architecte); |
|
|
$val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'qualification_DI') { |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'ajout_piece') { |
|
|
$val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id')); |
|
|
$val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val_external_uid['document_numerise'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'document_numerise'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'decision_DI') { |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'incompletude_DI') { |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'completude_DI') { |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'pec_metier_consultation') { |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val_external_uid['consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'consultation'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
2026 |
} |
} |
2027 |
// |
|
2028 |
if ($this->getVal('type') === 'avis_consultation') { |
// Si l'objet de référence n'existe pas log le numéro de la tâche concerné et |
2029 |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
// renvoie une payload contenant le message d'erreur. |
2030 |
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
// Sinon constitue la payload du json. |
2031 |
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
if (! $objectRefExist) { |
2032 |
if (isset($val['instruction']['signataire_arrete']) === true) { |
$this->f->addToLog( |
2033 |
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
sprintf( |
2034 |
} |
__('Impossible de récupérer la payload car l\'objet de réference n\'existe pas pour la tâche : %s'), |
2035 |
$val_external_uid = array(); |
$val_task['task'] |
2036 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
), |
2037 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
DEBUG_MODE |
2038 |
$val_external_uid['consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'consultation'); |
); |
2039 |
$val['external_uids'] = $val_external_uid; |
$val = __('Impossible de recuperer la payload car l\'objet de reference n\'existe pas.'); |
2040 |
|
} else { |
2041 |
|
|
2042 |
|
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
2043 |
|
unset($val_task['timestamp_log_hidden']); |
2044 |
|
$val['task'] = $val_task; |
2045 |
|
// |
2046 |
|
if ($this->getVal('type') === 'creation_DA' |
2047 |
|
|| $this->getVal('type') === 'modification_DA') { |
2048 |
|
// |
2049 |
|
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
2050 |
|
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
2051 |
|
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
2052 |
|
$val_external_uid = array(); |
2053 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
2054 |
|
$val['external_uids'] = $val_external_uid; |
2055 |
|
} |
2056 |
|
// |
2057 |
|
if ($this->getVal('type') === 'creation_DI' |
2058 |
|
|| $this->getVal('type') === 'modification_DI' |
2059 |
|
|| $this->getVal('type') === 'depot_DI') { |
2060 |
|
// |
2061 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
2062 |
|
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction'); |
2063 |
|
$val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']); |
2064 |
|
$architecte = isset($val['donnees_techniques']['architecte']) === true ? $val['donnees_techniques']['architecte'] : null; |
2065 |
|
$val['architecte'] = $this->get_architecte_data($architecte); |
2066 |
|
$val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']); |
2067 |
|
$val_external_uid = array(); |
2068 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2069 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2070 |
|
$val['external_uids'] = $val_external_uid; |
2071 |
|
} |
2072 |
|
// |
2073 |
|
if ($this->getVal('type') === 'qualification_DI') { |
2074 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2075 |
|
$val_external_uid = array(); |
2076 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2077 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2078 |
|
$val['external_uids'] = $val_external_uid; |
2079 |
|
} |
2080 |
|
// |
2081 |
|
if ($this->getVal('type') === 'ajout_piece') { |
2082 |
|
$val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id')); |
2083 |
|
$val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']); |
2084 |
|
$val_external_uid = array(); |
2085 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2086 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2087 |
|
$val_external_uid['piece'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'piece'); |
2088 |
|
$val['external_uids'] = $val_external_uid; |
2089 |
|
} |
2090 |
|
// |
2091 |
|
if ($this->getVal('type') === 'decision_DI') { |
2092 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2093 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
2094 |
|
$val['instruction']['final'] = 't'; |
2095 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
2096 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
2097 |
|
} |
2098 |
|
$val_external_uid = array(); |
2099 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2100 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2101 |
|
$val['external_uids'] = $val_external_uid; |
2102 |
|
} |
2103 |
|
// |
2104 |
|
if ($this->getVal('type') === 'incompletude_DI') { |
2105 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2106 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
2107 |
|
$val_external_uid = array(); |
2108 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2109 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2110 |
|
$val['external_uids'] = $val_external_uid; |
2111 |
|
} |
2112 |
|
// |
2113 |
|
if ($this->getVal('type') === 'completude_DI') { |
2114 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2115 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
2116 |
|
$val_external_uid = array(); |
2117 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2118 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2119 |
|
$val['external_uids'] = $val_external_uid; |
2120 |
|
} |
2121 |
|
// |
2122 |
|
if ($this->getVal('type') === 'lettre_incompletude' |
2123 |
|
|| $this->getVal('type') === 'lettre_majoration') { |
2124 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2125 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
2126 |
|
$val['lettre_petitionnaire'] = $this->get_lettre_petitionnaire_data($val['dossier']['dossier'], $this->getVal('type')); |
2127 |
|
$val_external_uid = array(); |
2128 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2129 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2130 |
|
$val['external_uids'] = $val_external_uid; |
2131 |
|
} |
2132 |
|
// |
2133 |
|
if ($this->getVal('type') === 'pec_metier_consultation') { |
2134 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2135 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2136 |
|
$val_external_uid = array(); |
2137 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2138 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2139 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
2140 |
|
$val['external_uids'] = $val_external_uid; |
2141 |
|
} |
2142 |
|
// |
2143 |
|
if ($this->getVal('type') === 'avis_consultation') { |
2144 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2145 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2146 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
2147 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
2148 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
2149 |
|
} |
2150 |
|
$val_external_uid = array(); |
2151 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2152 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2153 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
2154 |
|
$val_external_uid['avis_dossier_consultation'] = $this->get_external_uid($this->getVal('object_id'), 'avis_dossier_consultation'); |
2155 |
|
$val['external_uids'] = $val_external_uid; |
2156 |
|
} |
2157 |
|
// XXX WIP |
2158 |
|
if ($this->getVal('type') === 'creation_consultation') { |
2159 |
|
// |
2160 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2161 |
|
$val['consultation'] = $this->get_consultation_data($this->getVal('object_id')); |
2162 |
|
$val['service'] = $this->get_service_data($val['consultation']['service']); |
2163 |
|
$val_external_uid = array(); |
2164 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2165 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2166 |
|
$val['external_uids'] = $val_external_uid; |
2167 |
|
} |
2168 |
|
// |
2169 |
|
if ($this->getVal('type') === 'envoi_CL') { |
2170 |
|
// |
2171 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2172 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2173 |
|
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($val['dossier']['dossier_autorisation']); |
2174 |
|
$val_external_uid = array(); |
2175 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2176 |
|
$val_external_uid['dossier'] = $this->get_external_uid($this->getVal('dossier'), 'dossier'); |
2177 |
|
$val_external_uid['decision'] = $this->get_external_uid($this->getVal('object_id'), 'instruction'); |
2178 |
|
if ($val_external_uid['decision'] === '') { |
2179 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
2180 |
|
"obj" => "instruction", |
2181 |
|
"idx" => $this->getVal('object_id'), |
2182 |
|
)); |
2183 |
|
$val_external_uid['decision'] = $this->get_external_uid($inst_instruction->get_related_instructions_next('retour_signature'), 'instruction'); |
2184 |
|
} |
2185 |
|
$val['external_uids'] = $val_external_uid; |
2186 |
|
} |
2187 |
|
if ($this->getVal('type') === 'notification_instruction' |
2188 |
|
|| $this->getVal('type') === 'notification_recepisse' |
2189 |
|
|| $this->getVal('type') === 'notification_decision' |
2190 |
|
|| $this->getVal('type') === 'notification_service_consulte' |
2191 |
|
|| $this->getVal('type') === 'notification_tiers_consulte') { |
2192 |
|
// |
2193 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2194 |
|
$dossier_id = isset($val['dossier']['dossier']) === true ? $val['dossier']['dossier'] : null; |
2195 |
|
$val['demandeur'] = $this->get_demandeurs_data($dossier_id); |
2196 |
|
$val['instruction_notification'] = $this->get_instruction_notification_data($this->getVal('category'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2197 |
|
$instruction_id = isset($val['instruction_notification']['instruction']) === true ? $val['instruction_notification']['instruction'] : null; |
2198 |
|
$instruction_annexes = isset($val['instruction_notification']['annexes']) === true ? $val['instruction_notification']['annexes'] : null; |
2199 |
|
$val['instruction'] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $instruction_id)); |
2200 |
|
// Précise qu'il s'agit d'une instruction final si l'instruction est liée à une |
2201 |
|
// demande dont le type ne génère pas de dossier |
2202 |
|
if ($this->is_demande_instruction_recepisse_without_dossier($instruction_id) === true) { |
2203 |
|
$val['instruction']['final'] = 't'; |
2204 |
|
} |
2205 |
|
$val_external_uid = array(); |
2206 |
|
// Affiche l'identifiant externe lié à l'instruction si cette combinaison existe, sinon celui lié au dossier |
2207 |
|
$val_external_uid['demande'] = $this->get_external_uid($instruction_id, 'demande') !== '' ? $this->get_external_uid($instruction_id, 'demande') : $this->get_external_uid($dossier_id, 'demande'); |
2208 |
|
$val_external_uid['demande (instruction)'] = $this->get_external_uid($instruction_id, 'demande', PORTAL, 'ASC'); |
2209 |
|
$val_external_uid['instruction_notification'] = $this->get_external_uid($this->getVal('object_id'), 'instruction_notification', PORTAL); |
2210 |
|
$val['external_uids'] = $val_external_uid; |
2211 |
|
} |
2212 |
|
// |
2213 |
|
if ($this->getVal('type') === 'prescription') { |
2214 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2215 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2216 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
2217 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
2218 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
2219 |
|
} |
2220 |
|
$val_external_uid = array(); |
2221 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2222 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2223 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
2224 |
|
$val_external_uid['prescription'] = $this->get_external_uid($this->getVal('object_id'), 'prescription'); |
2225 |
|
$val['external_uids'] = $val_external_uid; |
2226 |
|
} |
2227 |
} |
} |
2228 |
|
|
2229 |
if ($in_field === true) { |
if ($in_field === true) { |
2230 |
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
2231 |
} else { |
} else { |
2232 |
// Liste des valeurs affichée en JSON |
// Liste des valeurs affichée en JSON |
2233 |
printf(json_encode($val, JSON_UNESCAPED_SLASHES)); |
echo(json_encode($val, JSON_UNESCAPED_SLASHES)); |
2234 |
} |
} |
2235 |
} |
} |
2236 |
} |
} |
2237 |
|
|
2238 |
function post_update_task() { |
function post_update_task() { |
2239 |
// Mise à jour des valeurs |
// Mise à jour des valeurs |
2240 |
// |
|
2241 |
$params = array( |
// Modification de l'état de la tâche |
2242 |
'val' => array( |
if ($this->f->get_submitted_post_value('state') !== null) { |
2243 |
'state' => $this->f->get_submitted_post_value('state') |
$params = array( |
2244 |
), |
'val' => array( |
2245 |
); |
'state' => $this->f->get_submitted_post_value('state') |
2246 |
$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('external_uid') !== null |
|
|
&& $this->f->get_submitted_post_value('external_uid') != "") { |
|
|
$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'), |
|
2247 |
); |
); |
2248 |
$add = $inst_lien->ajouter($valF); |
if ($this->f->get_submitted_post_value('comment') !== null) { |
2249 |
|
$params['comment'] = $this->f->get_submitted_post_value('comment'); |
2250 |
|
} |
2251 |
|
$update = $this->update_task($params); |
2252 |
$message_class = "valid"; |
$message_class = "valid"; |
2253 |
$message = $inst_lien->msg; |
$message = $this->msg; |
2254 |
if ($add === false) { |
if ($update === false) { |
2255 |
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
$this->addToLog($this->msg, DEBUG_MODE); |
2256 |
$message_class = "error"; |
$message_class = "error"; |
2257 |
$message = sprintf( |
$message = sprintf( |
2258 |
'%s %s', |
'%s %s', |
2259 |
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
__('Impossible de mettre à jour la tâche.'), |
2260 |
__('Veuillez contacter votre administrateur.') |
__('Veuillez contacter votre administrateur.') |
2261 |
); |
); |
2262 |
} |
} |
2263 |
$this->f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
2264 |
} |
} |
2265 |
|
|
2266 |
|
// Sauvegarde de l'uid externe retourné |
2267 |
|
if ($this->f->get_submitted_post_value('external_uid') !== null) { |
2268 |
|
// |
2269 |
|
$objects = $this->get_objects_by_task_type($this->getVal('type'), $this->getVal('stream')); |
2270 |
|
foreach ($objects as $object) { |
2271 |
|
$inst_lien = $this->f->get_inst__om_dbform(array( |
2272 |
|
"obj" => "lien_id_interne_uid_externe", |
2273 |
|
"idx" => ']', |
2274 |
|
)); |
2275 |
|
$object_id = $this->getVal('object_id'); |
2276 |
|
$is_exists = $inst_lien->is_exists($object, $object_id, $this->f->get_submitted_post_value('external_uid'), $this->getVal('dossier')); |
2277 |
|
// Dans le cas spécifique de la mise à jour d'une notification |
2278 |
|
// et de la création d'une liaison d'identifiant pour l'objet demande, |
2279 |
|
// l'identifiant de l'objet n'est plus celui de la notification |
2280 |
|
// d'instruction mais celui du dossier d'instruction |
2281 |
|
if ($object === 'demande' |
2282 |
|
&& ($this->getVal('type') === 'notification_recepisse' |
2283 |
|
|| $this->getVal('type') === 'notification_instruction' |
2284 |
|
|| $this->getVal('type') === 'notification_decision' |
2285 |
|
|| $this->getVal('type') === 'notification_service_consulte' |
2286 |
|
|| $this->getVal('type') === 'notification_tiers_consulte')) { |
2287 |
|
// |
2288 |
|
$object_id = $this->getVal('dossier'); |
2289 |
|
// Il ne doit y avoir qu'une liaison entre le numéro du dossier interne et un uid externe de "demande" |
2290 |
|
$is_exists = $inst_lien->is_exists($object, $object_id, null, $this->getVal('dossier')); |
2291 |
|
} |
2292 |
|
if ($is_exists === false) { |
2293 |
|
$valF = array( |
2294 |
|
'lien_id_interne_uid_externe' => '', |
2295 |
|
'object' => $object, |
2296 |
|
'object_id' => $object_id, |
2297 |
|
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
2298 |
|
'dossier' => $this->getVal('dossier'), |
2299 |
|
'category' => $this->getVal('category'), |
2300 |
|
); |
2301 |
|
$add = $inst_lien->ajouter($valF); |
2302 |
|
$message_class = "valid"; |
2303 |
|
$message = $inst_lien->msg; |
2304 |
|
if ($add === false) { |
2305 |
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
2306 |
|
$message_class = "error"; |
2307 |
|
$message = sprintf( |
2308 |
|
'%s %s', |
2309 |
|
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
2310 |
|
__('Veuillez contacter votre administrateur.') |
2311 |
|
); |
2312 |
|
} |
2313 |
|
$this->f->displayMessage($message_class, $message); |
2314 |
|
} |
2315 |
|
} |
2316 |
|
} |
2317 |
} |
} |
2318 |
|
|
2319 |
function post_add_task() { |
function post_add_task() { |
2321 |
$result = $this->add_task(array( |
$result = $this->add_task(array( |
2322 |
'val' => array( |
'val' => array( |
2323 |
'stream' => 'input', |
'stream' => 'input', |
2324 |
'json_payload' => html_entity_decode($this->f->get_submitted_post_value('json_payload')), |
'json_payload' => html_entity_decode($this->f->get_submitted_post_value('json_payload'), ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401), |
2325 |
'type' => $this->f->get_submitted_post_value('type'), |
'type' => $this->f->get_submitted_post_value('type'), |
2326 |
|
'category' => $this->f->get_submitted_post_value('category'), |
2327 |
) |
) |
2328 |
)); |
)); |
2329 |
$message = $this->msg; |
$message = sprintf( |
2330 |
|
__("Tâche %s ajoutée avec succès"), |
2331 |
|
$this->getVal($this->clePrimaire)). |
2332 |
|
'<br/><br/>'. |
2333 |
|
$this->msg; |
2334 |
$message_class = "valid"; |
$message_class = "valid"; |
2335 |
if ($result === false){ |
if ($result === false){ |
2336 |
$this->addToLog($this->msg, DEBUG_MODE); |
$this->addToLog($this->msg, DEBUG_MODE); |
2344 |
$this->f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
2345 |
} |
} |
2346 |
|
|
2347 |
function get_lien_objet_by_type($type) { |
function setLayout(&$form, $maj) { |
2348 |
// |
// |
2349 |
$objet = ''; |
$form->setBloc('json_payload', 'D', '', 'col_6'); |
2350 |
if ($type === 'creation_DA') { |
$fieldset_title_payload = __("json_payload (calculée)"); |
2351 |
$objet = 'dossier_autorisation'; |
if ($this->getVal('json_payload') !== "{}") { |
2352 |
} |
$fieldset_title_payload = __("json_payload"); |
2353 |
if ($type === 'creation_DI' |
} |
2354 |
|| $type === 'create_DI_for_consultation' |
$form->setFieldset('json_payload', 'DF', $fieldset_title_payload, "collapsible, startClosed"); |
2355 |
|| $type === 'depot_DI' |
$form->setBloc('json_payload', 'F'); |
2356 |
|| $type === 'modification_DI' |
$form->setBloc('timestamp_log', 'DF', __("historique"), 'col_9 timestamp_log_jsontotab'); |
2357 |
|| $type === 'qualification_DI') { |
} |
2358 |
// |
|
2359 |
$objet = 'dossier'; |
/** |
2360 |
|
* Récupère le nom de l'objet à mentionner dans la table lien_id_interne_uid_externe |
2361 |
|
* en fonction du type et du stream de la tâche. |
2362 |
|
* |
2363 |
|
* @param string $type Type de la tâche |
2364 |
|
* @param string $stream Stream de la tâche |
2365 |
|
* |
2366 |
|
* @return array |
2367 |
|
*/ |
2368 |
|
function get_objects_by_task_type($type, $stream = 'all') { |
2369 |
|
$objects = array(); |
2370 |
|
if (in_array($type, array('creation_DA', 'modification_DA', )) === true) { |
2371 |
|
$objects = array('dossier_autorisation', ); |
2372 |
|
} |
2373 |
|
if (in_array($type, array('creation_DI', 'depot_DI', 'notification_DI', 'qualification_DI', )) === true) { |
2374 |
|
$objects = array('dossier', ); |
2375 |
|
} |
2376 |
|
if (in_array($type, array('create_DI_for_consultation', )) === true) { |
2377 |
|
$objects = array('dossier', 'dossier_consultation', ); |
2378 |
|
} |
2379 |
|
if (in_array($type, array('create_DI', )) === true |
2380 |
|
&& $stream === 'input') { |
2381 |
|
$objects = array('dossier', 'dossier_autorisation', 'demande', ); |
2382 |
} |
} |
2383 |
if ($type === 'pec_metier_consultation' |
if (in_array($type, array( |
2384 |
|| $type === 'decision_DI' |
'decision_DI', |
2385 |
|| $type === 'avis_consultation' |
'incompletude_DI', |
2386 |
|| $type === 'incompletude_DI' |
'completude_DI', |
2387 |
|| $type === 'completude_DI') { |
'lettre_incompletude', |
2388 |
// |
'lettre_majoration' |
2389 |
$objet = 'instruction'; |
)) === true) { |
2390 |
|
$objects = array('instruction', ); |
2391 |
|
} |
2392 |
|
if (in_array($type, array('envoi_CL', )) === true) { |
2393 |
|
$objects = array('instruction_action_cl', ); |
2394 |
|
} |
2395 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
2396 |
|
&& $stream === 'output') { |
2397 |
|
$objects = array('pec_dossier_consultation', ); |
2398 |
|
} |
2399 |
|
if (in_array($type, array('avis_consultation', )) === true |
2400 |
|
&& $stream === 'output') { |
2401 |
|
$objects = array('avis_dossier_consultation', ); |
2402 |
|
} |
2403 |
|
if (in_array($type, array('prescription', )) === true |
2404 |
|
&& $stream === 'output') { |
2405 |
|
$objects = array('prescription', ); |
2406 |
|
} |
2407 |
|
if (in_array($type, array('ajout_piece', 'add_piece', )) === true) { |
2408 |
|
$objects = array('piece', ); |
2409 |
|
} |
2410 |
|
if (in_array($type, array('creation_consultation', )) === true) { |
2411 |
|
$objects = array('consultation', ); |
2412 |
|
} |
2413 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
2414 |
|
&& $stream === 'input') { |
2415 |
|
$objects = array('pec_metier_consultation', ); |
2416 |
|
} |
2417 |
|
if (in_array($type, array('avis_consultation', )) === true |
2418 |
|
&& $stream === 'input') { |
2419 |
|
$objects = array('avis_consultation', ); |
2420 |
} |
} |
2421 |
if ($type === 'ajout_piece') { |
if (in_array($type, array('create_message', )) === true |
2422 |
$objet = 'document_numerise'; |
&& $stream === 'input') { |
2423 |
|
$objects = array('dossier_message', ); |
2424 |
} |
} |
2425 |
// La tâche entrante se nomme add_piece |
if (in_array( |
2426 |
if ($type === 'add_piece') { |
$type, |
2427 |
$objet = 'piece'; |
array( |
2428 |
|
'notification_recepisse', |
2429 |
|
'notification_instruction', |
2430 |
|
'notification_decision', |
2431 |
|
'notification_service_consulte', |
2432 |
|
'notification_tiers_consulte', |
2433 |
|
) |
2434 |
|
) === true) { |
2435 |
|
$objects = array('instruction_notification', 'demande', ); |
2436 |
} |
} |
2437 |
return $objet; |
return $objects; |
2438 |
} |
} |
2439 |
|
|
2440 |
function setLayout(&$form, $maj) { |
/** |
2441 |
|
* Récupère les tables auxquelles pourrait être rattaché l'objet lié à la tâche, |
2442 |
// Récupération du mode de l'action |
* par rapport à son type. |
2443 |
$crud = $this->get_action_crud($maj); |
* |
2444 |
|
* @param string $type Type de la tâche |
2445 |
|
* @param string $stream input ou output |
2446 |
|
* @return array |
2447 |
|
*/ |
2448 |
|
function get_tables_by_task_type($type, $stream = 'all') { |
2449 |
|
$tables = array(); |
2450 |
|
if (in_array($type, array('creation_DA', 'modification_DA', )) === true) { |
2451 |
|
$tables = array('dossier_autorisation', ); |
2452 |
|
} |
2453 |
|
if (in_array($type, array('creation_DI', 'depot_DI', )) === true) { |
2454 |
|
$tables = array('dossier', ); |
2455 |
|
} |
2456 |
|
if (in_array($type, array('qualification_DI', )) === true) { |
2457 |
|
$tables = array('instruction', 'dossier', ); |
2458 |
|
} |
2459 |
|
if (in_array($type, array('create_DI_for_consultation', )) === true) { |
2460 |
|
$tables = array('dossier', ); |
2461 |
|
} |
2462 |
|
if (in_array($type, array('create_DI', )) === true |
2463 |
|
&& $stream === 'input') { |
2464 |
|
$tables = array('dossier', 'dossier_autorisation', 'demande', ); |
2465 |
|
} |
2466 |
|
if (in_array($type, array( |
2467 |
|
'decision_DI', |
2468 |
|
'incompletude_DI', |
2469 |
|
'completude_DI', |
2470 |
|
'lettre_incompletude', |
2471 |
|
'lettre_majoration' |
2472 |
|
)) === true) { |
2473 |
|
$tables = array('instruction', ); |
2474 |
|
} |
2475 |
|
if (in_array($type, array('envoi_CL', )) === true) { |
2476 |
|
$objects = array('instruction', ); |
2477 |
|
} |
2478 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
2479 |
|
&& $stream === 'output') { |
2480 |
|
$tables = array('instruction', ); |
2481 |
|
} |
2482 |
|
if (in_array($type, array('avis_consultation', )) === true |
2483 |
|
&& $stream === 'output') { |
2484 |
|
$tables = array('instruction', ); |
2485 |
|
} |
2486 |
|
if (in_array($type, array('prescription', )) === true |
2487 |
|
&& $stream === 'output') { |
2488 |
|
$tables = array('instruction', ); |
2489 |
|
} |
2490 |
|
if (in_array($type, array('ajout_piece', 'add_piece', )) === true) { |
2491 |
|
$tables = array('document_numerise', ); |
2492 |
|
} |
2493 |
|
if (in_array($type, array('creation_consultation', )) === true) { |
2494 |
|
$tables = array('consultation', ); |
2495 |
|
} |
2496 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
2497 |
|
&& $stream === 'input') { |
2498 |
|
$tables = array('consultation', ); |
2499 |
|
} |
2500 |
|
if (in_array($type, array('avis_consultation', )) === true |
2501 |
|
&& $stream === 'input') { |
2502 |
|
$tables = array('consultation', ); |
2503 |
|
} |
2504 |
|
if (in_array($type, array('create_message', )) === true |
2505 |
|
&& $stream === 'input') { |
2506 |
|
$tables = array('dossier_message', ); |
2507 |
|
} |
2508 |
|
if (in_array( |
2509 |
|
$type, |
2510 |
|
array( |
2511 |
|
'notification_recepisse', |
2512 |
|
'notification_instruction', |
2513 |
|
'notification_decision', |
2514 |
|
'notification_service_consulte', |
2515 |
|
'notification_tiers_consulte' |
2516 |
|
) |
2517 |
|
) === true) { |
2518 |
|
$tables = array('instruction_notification', ); |
2519 |
|
} |
2520 |
|
return $tables; |
2521 |
|
} |
2522 |
|
|
2523 |
// MODE different de CREER |
/** |
2524 |
if ($maj != 0 || $crud != 'create') { |
* Vérifie si l'objet référencé par la tâche existe en base de données. |
2525 |
$form->setBloc('json_payload', 'D', '', 'col_6'); |
* |
2526 |
$form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed"); |
* Récupère la liste des tables de référence associé à la tâche à partir |
2527 |
$form->setBloc('json_payload', 'F'); |
* du type de tâche et de son flux (input ou output). |
2528 |
|
* Pour chaque table potentiellement référencé par la tâche on essaye d'instancier |
2529 |
|
* l'objet correspondant à partir de l'identifiant de l'objet de référence de la tâche. |
2530 |
|
* Si l'élément instancié existe renvoie true sinon renvoie false. |
2531 |
|
* |
2532 |
|
* @param string|integer $taskObjectId : identifiant de l'objet de référence de la tâche |
2533 |
|
* @param string $taskType : type de la tâche |
2534 |
|
* @param string $taskStream : flux entrant (output - valeur par défaut) ou sortant (input) |
2535 |
|
* @return boolean |
2536 |
|
*/ |
2537 |
|
protected function does_referenced_object_exist($taskObjectId, string $taskType, string $taskStream = 'output') { |
2538 |
|
$refTables = $this->get_tables_by_task_type($taskType, $taskStream); |
2539 |
|
if (empty($refTables) === true) { |
2540 |
|
$this->f->addToLog( |
2541 |
|
sprintf( |
2542 |
|
__("Impossible de vérifier si l'objet de référence existe, car le type de task '%s' n'a pas de correspondance avec une table dans la méthode %s."), |
2543 |
|
$taskType, |
2544 |
|
"get_tables_by_task_type()" |
2545 |
|
), |
2546 |
|
DEBUG_MODE |
2547 |
|
); |
2548 |
|
return true; |
2549 |
} |
} |
2550 |
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
foreach ($refTables as $table) { |
2551 |
|
$inst = $this->f->get_inst__om_dbform(array( |
2552 |
|
'obj' => $table, |
2553 |
|
'idx' => $taskObjectId |
2554 |
|
)); |
2555 |
|
if ($inst->exists() === true) { |
2556 |
|
return true; |
2557 |
|
} |
2558 |
|
} |
2559 |
|
return false; |
2560 |
} |
} |
2561 |
|
|
2562 |
} |
} |