4 |
|
|
5 |
require_once "../gen/obj/task.class.php"; |
require_once "../gen/obj/task.class.php"; |
6 |
|
|
7 |
|
|
8 |
class task extends task_gen { |
class task extends task_gen { |
9 |
|
|
10 |
const STATUS_DRAFT = 'draft'; |
const STATUS_DRAFT = 'draft'; |
15 |
const STATUS_DEBUG = 'debug'; |
const STATUS_DEBUG = 'debug'; |
16 |
const STATUS_ARCHIVED = 'archived'; |
const STATUS_ARCHIVED = 'archived'; |
17 |
const STATUS_CANCELED = 'canceled'; |
const STATUS_CANCELED = 'canceled'; |
18 |
|
const STATUS_INVALID = 'invalid'; |
19 |
|
|
20 |
|
/** |
21 |
|
* Définie le code platau correspondant aux documents de type consultation |
22 |
|
* |
23 |
|
* @var integer |
24 |
|
*/ |
25 |
|
const CODE_PLATAU_CONSULTATION = 7; |
26 |
|
|
27 |
/** |
/** |
28 |
* Liste des types de tâche concernant les services instructeurs |
* Liste des types de tâche concernant les services instructeurs |
37 |
'incompletude_DI', |
'incompletude_DI', |
38 |
'completude_DI', |
'completude_DI', |
39 |
'ajout_piece', |
'ajout_piece', |
40 |
|
'modification_piece', |
41 |
|
'suppression_piece', |
42 |
'add_piece', |
'add_piece', |
43 |
'creation_consultation', |
'creation_consultation', |
44 |
'modification_DA', |
'modification_DA', |
45 |
'create_DI', |
'create_DI', |
46 |
|
'envoi_CL', |
47 |
'notification_recepisse', |
'notification_recepisse', |
48 |
'notification_instruction', |
'notification_instruction', |
49 |
'notification_decision', |
'notification_decision', |
50 |
|
'notification_service_consulte', |
51 |
|
'notification_tiers_consulte', |
52 |
|
'notification_depot_demat', |
53 |
|
'notification_commune', |
54 |
|
'notification_signataire', |
55 |
|
'lettre_incompletude', |
56 |
|
'lettre_majoration', |
57 |
|
'ajout_documents_specifiques' |
58 |
); |
); |
59 |
|
|
60 |
/** |
/** |
68 |
'notification_recepisse', |
'notification_recepisse', |
69 |
'notification_instruction', |
'notification_instruction', |
70 |
'notification_decision', |
'notification_decision', |
71 |
|
'notification_service_consulte', |
72 |
|
'notification_tiers_consulte', |
73 |
|
'notification_depot_demat', |
74 |
|
'prescription', |
75 |
|
'ajout_documents_specifiques' |
76 |
|
); |
77 |
|
|
78 |
|
/** |
79 |
|
* Liste des types de tâche pouvant avoir des documents associés |
80 |
|
*/ |
81 |
|
const TASK_WITH_DOCUMENT = array( |
82 |
|
'add_piece', |
83 |
|
'avis_consultation', |
84 |
|
'pec_metier_consultation', |
85 |
|
'ajout_documents_specifiques' |
86 |
); |
); |
87 |
|
|
88 |
/** |
/** |
89 |
|
* Préfixe pour identifier les codes de suivi |
90 |
|
* @var string |
91 |
|
*/ |
92 |
|
const CS_PREFIX = 'code-suivi://'; |
93 |
|
|
94 |
|
/** |
95 |
* Catégorie de la tâche |
* Catégorie de la tâche |
96 |
*/ |
*/ |
97 |
var $category = 'platau'; |
var $category = PLATAU; |
98 |
|
|
99 |
/** |
/** |
100 |
* Définition des actions disponibles sur la classe. |
* Définition des actions disponibles sur la classe. |
192 |
// |
// |
193 |
$this->valF['category'] = $this->category; |
$this->valF['category'] = $this->category; |
194 |
} |
} |
195 |
|
|
196 |
|
// Si last_modification_time est vide, la valeur est remplacée par NULL |
197 |
|
// pour eviter d'avoir une erreur de base de données car le champ est au format time. |
198 |
|
if ($val['last_modification_time'] == "") { |
199 |
|
$this->valF['last_modification_time'] = NULL; |
200 |
|
} else { |
201 |
|
$this->valF['last_modification_time'] = $val['last_modification_time']; |
202 |
|
} |
203 |
|
|
204 |
|
// Si creation_time est vide, la valeur est remplacée par NULL |
205 |
|
// pour eviter d'avoir une erreur de base de données car le champ est au format time. |
206 |
|
if ($val['creation_time'] == "") { |
207 |
|
$this->valF['creation_time'] = NULL; |
208 |
|
} else { |
209 |
|
$this->valF['creation_time'] = $val['creation_time']; |
210 |
|
} |
211 |
} |
} |
212 |
|
|
213 |
/** |
/** |
222 |
"object_id", |
"object_id", |
223 |
"dossier", |
"dossier", |
224 |
"stream", |
"stream", |
225 |
|
"creation_date", |
226 |
|
"creation_time", |
227 |
|
"CONCAT_WS(' ', to_char(task.creation_date, 'DD/MM/YYYY'), task.creation_time) AS date_creation", |
228 |
|
'last_modification_date', |
229 |
|
'last_modification_time', |
230 |
|
"CONCAT_WS(' ', to_char(task.last_modification_date, 'DD/MM/YYYY'), task.last_modification_time) AS date_modification", |
231 |
|
"comment", |
232 |
"json_payload", |
"json_payload", |
233 |
"timestamp_log", |
"timestamp_log", |
234 |
|
"timestamp_log AS timestamp_log_hidden", |
235 |
"category", |
"category", |
236 |
); |
); |
237 |
} |
} |
244 |
|
|
245 |
// ALL |
// ALL |
246 |
$form->setType("category", "hidden"); |
$form->setType("category", "hidden"); |
247 |
|
$form->setType("timestamp_log_hidden", "hidden"); |
248 |
|
|
249 |
// MODE CREER |
// MODE CREER |
250 |
if ($maj == 0 || $crud == 'create') { |
if ($maj == 0 || $crud == 'create') { |
251 |
|
$form->setType("type", "select"); |
252 |
$form->setType("state", "select"); |
$form->setType("state", "select"); |
253 |
$form->setType("stream", "select"); |
$form->setType("stream", "select"); |
254 |
$form->setType("json_payload", "textarea"); |
$form->setType("json_payload", "textarea"); |
255 |
} |
} |
256 |
// MDOE MODIFIER |
// MODE MODIFIER |
257 |
if ($maj == 1 || $crud == 'update') { |
if ($maj == 1 || $crud == 'update') { |
258 |
|
$form->setType("task", "hiddenstatic"); |
259 |
$form->setType("state", "select"); |
$form->setType("state", "select"); |
260 |
$form->setType("stream", "select"); |
$form->setType("stream", "hiddenstatic"); |
261 |
$form->setType("json_payload", "jsonprettyprint"); |
$form->setType("json_payload", "jsonprettyprint"); |
262 |
|
$form->setType("timestamp_log", "jsontotab"); |
263 |
|
$form->setType("type", "hiddenstatic"); |
264 |
|
$form->setType("creation_date", "hidden"); |
265 |
|
$form->setType("creation_time", "hidden"); |
266 |
|
$form->setType("object_id", "hiddenstatic"); |
267 |
|
$form->setType("dossier", "hiddenstatic"); |
268 |
|
$form->setType("date_creation", "hiddenstatic"); |
269 |
|
$form->setType("last_modification_date", "hidden"); |
270 |
|
$form->setType("last_modification_time", "hidden"); |
271 |
|
$form->setType("date_modification", "static"); |
272 |
} |
} |
273 |
// MODE CONSULTER |
// MODE CONSULTER |
274 |
if ($maj == 3 || $crud == 'read') { |
if ($maj == 3 || $crud == 'read') { |
275 |
|
$form->setType("state", "selecthiddenstatic"); |
276 |
|
$form->setType("stream", "selecthiddenstatic"); |
277 |
$form->setType('dossier', 'link'); |
$form->setType('dossier', 'link'); |
278 |
$form->setType('json_payload', 'jsonprettyprint'); |
$form->setType('json_payload', 'jsonprettyprint'); |
279 |
|
$form->setType("type", "selecthiddenstatic"); |
280 |
|
$form->setType("creation_date", "hidden"); |
281 |
|
$form->setType("creation_time", "hidden"); |
282 |
|
$form->setType("date_creation", "static"); |
283 |
|
$form->setType("last_modification_date", "hidden"); |
284 |
|
$form->setType("last_modification_time", "hidden"); |
285 |
|
$form->setType("date_modification", "static"); |
286 |
|
$form->setType("timestamp_log", "jsontotab"); |
287 |
} |
} |
288 |
|
} |
289 |
|
|
290 |
|
function stateTranslation ($currentState) { |
291 |
|
switch ($currentState){ |
292 |
|
case self::STATUS_DRAFT: |
293 |
|
return __('brouillon'); |
294 |
|
break; |
295 |
|
case self::STATUS_NEW: |
296 |
|
return __('à traiter'); |
297 |
|
break; |
298 |
|
case self::STATUS_PENDING: |
299 |
|
return __('en cours'); |
300 |
|
break; |
301 |
|
case self::STATUS_DONE: |
302 |
|
return __('terminé'); |
303 |
|
break; |
304 |
|
case self::STATUS_ARCHIVED: |
305 |
|
return __('archivé'); |
306 |
|
break; |
307 |
|
case self::STATUS_ERROR: |
308 |
|
return __('erreur'); |
309 |
|
break; |
310 |
|
case self::STATUS_DEBUG: |
311 |
|
return __('debug'); |
312 |
|
break; |
313 |
|
case self::STATUS_CANCELED: |
314 |
|
return __('annulé'); |
315 |
|
break; |
316 |
|
case self::STATUS_INVALID: |
317 |
|
return __('invalide'); |
318 |
|
break; |
319 |
|
} |
320 |
} |
} |
321 |
|
|
322 |
/** |
/** |
323 |
* |
* |
324 |
*/ |
*/ |
325 |
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
326 |
if($maj < 2) { |
if($maj <= 3) { |
|
|
|
327 |
$contenu = array(); |
$contenu = array(); |
328 |
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG', 'ARCHIVED', 'CANCELED') as $key) { |
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG', 'ARCHIVED', 'CANCELED', 'INVALID') as $key) { |
329 |
$const_name = 'STATUS_'.$key; |
$const_name = 'STATUS_'.$key; |
330 |
$const_value = constant("self::$const_name"); |
$const_value = constant("self::$const_name"); |
331 |
$contenu[0][] = $const_value; |
$contenu[0][] = $const_value; |
332 |
$contenu[1][] = __($const_value); |
|
333 |
|
|
334 |
|
$contenu[1][] = $this->stateTranslation($const_value); |
335 |
|
|
336 |
} |
} |
337 |
|
|
338 |
$form->setSelect("state", $contenu); |
$form->setSelect("state", $contenu); |
339 |
|
|
340 |
$contenu_stream =array(); |
$contenu_stream =array(); |
341 |
$contenu_stream[0][0]="input"; |
$contenu_stream[0][0]="input"; |
342 |
$contenu_stream[1][0]=_('input'); |
$contenu_stream[1][0]=__('input'); |
343 |
$contenu_stream[0][1]="output"; |
$contenu_stream[0][1]="output"; |
344 |
$contenu_stream[1][1]=_('output'); |
$contenu_stream[1][1]=__('output'); |
345 |
$form->setSelect("stream", $contenu_stream); |
$form->setSelect("stream", $contenu_stream); |
346 |
|
|
347 |
|
$tab_type = array_unique(array_merge(self::TASK_TYPE_SI, self::TASK_TYPE_SC)); |
348 |
|
|
349 |
|
foreach ($tab_type as $type) { |
350 |
|
|
351 |
|
$contenu_type[0][] = $type; |
352 |
|
|
353 |
|
switch ($type) { |
354 |
|
case "creation_DA": |
355 |
|
$value_type = __('Création DA'); |
356 |
|
break; |
357 |
|
case "create_DI": |
358 |
|
$value_type = __('Création demande'); |
359 |
|
break; |
360 |
|
case "creation_DI": |
361 |
|
$value_type = __('Création DI'); |
362 |
|
break; |
363 |
|
case "modification_DA": |
364 |
|
$value_type = __('Modification DA'); |
365 |
|
break; |
366 |
|
case "modification_DI": |
367 |
|
$value_type = __('Modification DI'); |
368 |
|
break; |
369 |
|
case "ajout_piece": |
370 |
|
$value_type = __('Ajout pièce (sortant)'); |
371 |
|
break; |
372 |
|
case "add_piece": |
373 |
|
$value_type = __('Ajout pièce (entrant)'); |
374 |
|
break; |
375 |
|
case "modification_piece": |
376 |
|
$value_type = __('Modification pièce (sortant)'); |
377 |
|
break; |
378 |
|
case "suppression_piece": |
379 |
|
$value_type = __('Suppression pièce (sortant)'); |
380 |
|
break; |
381 |
|
case "depot_DI": |
382 |
|
$value_type = __('Dépôt DI'); |
383 |
|
break; |
384 |
|
case "qualification_DI": |
385 |
|
$value_type = __('Qualification DI'); |
386 |
|
break; |
387 |
|
case "creation_consultation": |
388 |
|
$value_type = __('Création consultation'); |
389 |
|
break; |
390 |
|
case "decision_DI": |
391 |
|
$value_type = __('Décision DI'); |
392 |
|
break; |
393 |
|
case "envoi_CL": |
394 |
|
$value_type = __('Envoi contrôle de légalité'); |
395 |
|
break; |
396 |
|
case "pec_metier_consultation": |
397 |
|
$value_type = __('PeC consultation'); |
398 |
|
break; |
399 |
|
case "avis_consultation": |
400 |
|
$value_type = __('Avis'); |
401 |
|
break; |
402 |
|
case "prescription": |
403 |
|
$value_type = __('Prescription'); |
404 |
|
break; |
405 |
|
case "create_DI_for_consultation": |
406 |
|
$value_type = __('Création DI pour consultation'); |
407 |
|
break; |
408 |
|
case "create_message": |
409 |
|
$value_type = __('Message'); |
410 |
|
break; |
411 |
|
case "notification_recepisse": |
412 |
|
$value_type = __('Notification récépissé'); |
413 |
|
break; |
414 |
|
case "notification_instruction": |
415 |
|
$value_type = __('Notification instruction'); |
416 |
|
break; |
417 |
|
case "notification_decision": |
418 |
|
$value_type = __('Notification décision'); |
419 |
|
break; |
420 |
|
case "notification_service_consulte": |
421 |
|
$value_type = __('Notification service consulté'); |
422 |
|
break; |
423 |
|
case "notification_tiers_consulte": |
424 |
|
$value_type = __('Notification tiers consulté'); |
425 |
|
break; |
426 |
|
case "notification_signataire": |
427 |
|
$value_type = __('Notification signataire'); |
428 |
|
break; |
429 |
|
case "completude_DI": |
430 |
|
$value_type = __('complétude DI'); |
431 |
|
break; |
432 |
|
case "incompletude_DI": |
433 |
|
$value_type = __('incomplétude DI'); |
434 |
|
break; |
435 |
|
case "lettre_incompletude": |
436 |
|
$value_type = __('Lettre au pétitionnaire d\'incompletude'); |
437 |
|
break; |
438 |
|
case "lettre_majoration": |
439 |
|
$value_type = __('Lettre au pétitionnaire de majoration'); |
440 |
|
break; |
441 |
|
case "ajout_documents_specifiques": |
442 |
|
$value_type = __('Ajout Document Spécifique'); |
443 |
|
break; |
444 |
|
} |
445 |
|
|
446 |
|
$contenu_type[1][] = $value_type; |
447 |
|
} |
448 |
|
|
449 |
|
$form->setselect('type', $contenu_type); |
450 |
} |
} |
451 |
|
|
452 |
if ($maj == 3) { |
if ($maj == 3) { |
453 |
if ($this->getVal('stream') == 'output') { |
$dossier = $form->val['dossier']; |
454 |
$inst_dossier = $this->f->get_inst__om_dbform(array( |
// Récupération du numéro du dossier si il n'est pas renseigné dans la tâche |
|
"obj" => "dossier", |
|
|
"idx" => $form->val['dossier'], |
|
|
)); |
|
455 |
|
|
456 |
if($form->val['type'] == "creation_DA" |
if ($dossier == '' || $dossier == null) { |
457 |
|| $form->val['type'] == "modification_DA"){ |
// Récupération de la payload de la taĉhe. |
458 |
// |
// Si la tâche est une tâche input la payload est associée à la tâche. |
459 |
$obj_link = 'dossier_autorisation'; |
// Si la tâche est une tâche en output la payload est "calculé" à l'ouverture |
460 |
|
// du formulaire. |
461 |
|
if ($this->getVal('stream') == 'input') { |
462 |
|
$json_payload = json_decode($this->getVal('json_payload'), true); |
463 |
} else { |
} else { |
464 |
$obj_link = 'dossier_instruction'; |
$json_payload = json_decode($form->val['json_payload'], true); |
465 |
|
} |
466 |
|
// A partir de la payload de la tâche ont récupère les externals uid |
467 |
|
// Si un external uid de DI (dossier) existe ont le récupère et on stocke le numéro |
468 |
|
// pour l'afficher sur le formulaire. |
469 |
|
// Si l'external UID du DI n'existe pas on récupère celui du DA |
470 |
|
$external_uid = ''; |
471 |
|
if (array_key_exists('external_uids', $json_payload) |
472 |
|
&& array_key_exists('dossier', $json_payload['external_uids']) |
473 |
|
) { |
474 |
|
$external_uid = $json_payload['external_uids']['dossier']; |
475 |
|
} elseif (array_key_exists('external_uids', $json_payload) |
476 |
|
&& array_key_exists('demande', $json_payload['external_uids'])) { |
477 |
|
$external_uid = $json_payload['external_uids']['demande']; |
478 |
} |
} |
479 |
|
// Recherche l'external uid dans la base de données pour récupèrer le numéro de |
480 |
|
// DI / DA correspondant. On stocke le numéro de dossier dans la propriété val |
481 |
|
// du formulaire pour pouvoir l'afficher |
482 |
|
if ($external_uid != '') { |
483 |
|
$qres = $this->f->get_one_result_from_db_query( |
484 |
|
sprintf( |
485 |
|
'SELECT |
486 |
|
lien_id_interne_uid_externe.dossier |
487 |
|
FROM |
488 |
|
%1$slien_id_interne_uid_externe |
489 |
|
WHERE |
490 |
|
lien_id_interne_uid_externe.external_uid = \'%2$s\'', |
491 |
|
DB_PREFIXE, |
492 |
|
$this->f->db->escapeSimple($external_uid) |
493 |
|
), |
494 |
|
array( |
495 |
|
"origin" => __METHOD__, |
496 |
|
) |
497 |
|
); |
498 |
|
if (! empty($qres["result"])) { |
499 |
|
$dossier = $qres["result"]; |
500 |
|
} |
501 |
|
} |
502 |
|
} |
503 |
|
|
504 |
$params = array(); |
// Vérifie si le numéro de dossier associé à la tâche existe dans la base. |
505 |
$params['obj'] = $obj_link; |
// Si c'est le cas ce numéro sera lié au dossier (DI ou DA) correspondant |
506 |
$params['libelle'] = $inst_dossier->getVal('dossier'); |
// TODO : vérifier la liste des tâches lié à des DA |
507 |
$params['title'] = "Consulter le dossier"; |
$obj_link = ''; |
508 |
$params['idx'] = $form->val['dossier']; |
if ($form->val['type'] == "creation_DA" || $form->val['type'] == "modification_DA") { |
509 |
$form->setSelect("dossier", $params); |
// Vérification que le numéro de DA affiché dans le formulaire existe |
510 |
|
$qres = $this->f->get_one_result_from_db_query( |
511 |
|
sprintf( |
512 |
|
'SELECT |
513 |
|
dossier_autorisation.dossier_autorisation |
514 |
|
FROM |
515 |
|
%1$sdossier_autorisation |
516 |
|
WHERE |
517 |
|
dossier_autorisation.dossier_autorisation = \'%2$s\'', |
518 |
|
DB_PREFIXE, |
519 |
|
$this->f->db->escapeSimple($form->val['dossier']) |
520 |
|
), |
521 |
|
array( |
522 |
|
"origin" => __METHOD__, |
523 |
|
) |
524 |
|
); |
525 |
|
// Si on a un résultat c'est que le dossier existe, il faut afficher le lien |
526 |
|
if (! empty($qres["result"])) { |
527 |
|
$obj_link = 'dossier_autorisation'; |
528 |
|
} |
529 |
|
} else { |
530 |
|
// Vérification que le numéro de DI affiché dans le formulaire existe |
531 |
|
$sql = sprintf( |
532 |
|
'SELECT |
533 |
|
dossier.dossier, |
534 |
|
dossier.dossier_parent |
535 |
|
FROM |
536 |
|
%1$sdossier |
537 |
|
WHERE |
538 |
|
dossier.dossier = \'%2$s\'', |
539 |
|
DB_PREFIXE, |
540 |
|
$this->f->db->escapeSimple($dossier) |
541 |
|
); |
542 |
|
$qres = $this->f->get_all_results_from_db_query( |
543 |
|
$sql, |
544 |
|
array( |
545 |
|
"origin" => __METHOD__, |
546 |
|
) |
547 |
|
); |
548 |
|
// Si on a un résultat c'est que le dossier existe, il faut afficher le lien |
549 |
|
if (! empty($qres['result']) && $qres['row_count'] > 0) { |
550 |
|
$obj_link = 'dossier_instruction'; |
551 |
|
if (! empty($qres['result'][0]['dossier_parent'])) { |
552 |
|
$dossier = $qres['result'][0]['dossier_parent']; |
553 |
|
} |
554 |
|
} |
555 |
} |
} |
556 |
|
// Pour afficher le lien vers un dossier ont utilise un champ de type "link". |
557 |
|
// Pour paramétrer ce champs on a besoin de savoir : |
558 |
|
// - quel objet est visé par le lien |
559 |
|
// - le label (libellé) du lien |
560 |
|
// - l'identifiant de l'objet qui sera utilisé dans le lien |
561 |
|
// - le titre associé au lien |
562 |
|
// Pour cela on remplit le champs comme un select et les valeurs du select |
563 |
|
// contiennent les informations nécessaire à l'affichage du champs. |
564 |
|
$params = array( |
565 |
|
'obj' => $obj_link, |
566 |
|
'libelle' => $dossier, |
567 |
|
'title' => "Consulter le dossier", |
568 |
|
'idx' => $dossier |
569 |
|
); |
570 |
|
$form->setSelect("dossier", $params); |
571 |
} |
} |
572 |
} |
} |
573 |
|
|
579 |
function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) { |
function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) { |
580 |
// parent::setVal($form, $maj, $validation); |
// parent::setVal($form, $maj, $validation); |
581 |
// |
// |
582 |
if ($this->getVal('stream') == "output") { |
if ($this->getVal('stream') == "output" |
583 |
|
&& $this->getVal('type') !== 'suppression_piece' |
584 |
|
&& ($this->getVal('state') !== self::STATUS_DONE |
585 |
|
|| $this->getVal('json_payload') === "{}")) { |
586 |
|
// |
587 |
$form->setVal('json_payload', $this->view_form_json(true)); |
$form->setVal('json_payload', $this->view_form_json(true)); |
588 |
} else { |
} else { |
589 |
$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)); |
590 |
|
} |
591 |
|
// Gestion du contenu de l'historique |
592 |
|
if ($this->getVal('timestamp_log') !== '' |
593 |
|
&& $this->getVal('timestamp_log') !== null) { |
594 |
|
// |
595 |
|
$form->setVal('timestamp_log', $this->getVal('timestamp_log')); |
596 |
} |
} |
597 |
} |
} |
598 |
|
|
602 |
// Récupération du mode de l'action |
// Récupération du mode de l'action |
603 |
$crud = $this->get_action_crud($maj); |
$crud = $this->get_action_crud($maj); |
604 |
|
|
605 |
|
$form->setLib('date_creation', __("Date de création")); |
606 |
|
$form->setLib('date_modification', __("Date de dernière modification")); |
607 |
|
$form->setLib('comment', __("commentaire")); |
608 |
|
|
609 |
// MODE different de CREER |
// MODE different de CREER |
610 |
if ($maj != 0 || $crud != 'create') { |
if ($maj != 0 || $crud != 'create') { |
611 |
$form->setLib('json_payload', ''); |
$form->setLib('json_payload', ''); |
612 |
|
$form->setLib("task", __("identifiant")); |
613 |
|
$form->setLib("Task_portal", __("task_portal")); |
614 |
|
$form->setLib("type", __("type")); |
615 |
|
$form->setLib("object_id", __("Réf. interne")); |
616 |
|
$form->setLib("stream", __("flux")); |
617 |
|
$form->setLib("timestamp_log", __("Historique")); |
618 |
} |
} |
619 |
} |
} |
620 |
|
|
621 |
public function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
public function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
622 |
$ret = parent::verifier($val, $dnu1, $dnu2); |
$ret = parent::verifier($val, $dnu1, $dnu2); |
623 |
|
|
624 |
|
$allowed_state = array( |
625 |
|
self::STATUS_DRAFT, |
626 |
|
self::STATUS_NEW, |
627 |
|
self::STATUS_PENDING, |
628 |
|
self::STATUS_DONE, |
629 |
|
self::STATUS_ERROR, |
630 |
|
self::STATUS_DEBUG, |
631 |
|
self::STATUS_ARCHIVED, |
632 |
|
self::STATUS_CANCELED, |
633 |
|
self::STATUS_INVALID); |
634 |
|
|
635 |
|
$task_id = $this->getVal($this->clePrimaire); |
636 |
|
$task_id_text = sprintf(__("la tâche '%s'"), $task_id); |
637 |
|
if (empty($task_id) || $task_id === ']') { |
638 |
|
$task_id_text = __("la nouvelle tâche"); |
639 |
|
} |
640 |
|
|
641 |
|
if (! isset($this->valF['state']) || empty($this->valF['state'])) { |
642 |
|
$this->correct = false; |
643 |
|
$err_msg = sprintf( |
644 |
|
__("Champ '%s' obligatoire pour %s"), |
645 |
|
'state', $task_id_text); |
646 |
|
$this->addToMessage($err_msg); |
647 |
|
$this->addToLog(__METHOD__.'(): '.$err_msg, DEBUG_MODE); |
648 |
|
} |
649 |
|
elseif (! in_array($this->valF['state'], $allowed_state)) { |
650 |
|
$this->correct = false; |
651 |
|
$err_msg = sprintf( |
652 |
|
__("Champ '%s' invalide (%s) pour %s"), |
653 |
|
'state', var_export($this->valF['state'], true), $task_id_text); |
654 |
|
$this->addToMessage($err_msg); |
655 |
|
$this->addToLog(__METHOD__.'(): '.$err_msg, DEBUG_MODE); |
656 |
|
} |
657 |
|
|
658 |
// une tâche entrante doit avoir un type et une payload non-vide |
// une tâche entrante doit avoir un type et une payload non-vide |
659 |
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
660 |
if (isset($this->valF['type']) === false) { |
if (isset($this->valF['type']) === false) { |
708 |
$this->valF['stream'] == 'input')) { |
$this->valF['stream'] == 'input')) { |
709 |
|
|
710 |
// décode la payload JSON |
// décode la payload JSON |
711 |
|
// TODO : COMMENTER |
712 |
$json_payload = json_decode($this->valF['json_payload'], true); |
$json_payload = json_decode($this->valF['json_payload'], true); |
713 |
|
|
714 |
// défini une liste de chemin de clés requises |
// défini une liste de chemin de clés requises |
715 |
$paths = array(); |
$paths = array(); |
716 |
if ($this->valF['category'] === 'platau') { |
if ($this->valF['category'] === PLATAU) { |
717 |
$paths = array( |
$paths = array( |
718 |
'external_uids/dossier' |
'external_uids/dossier' |
719 |
); |
); |
789 |
* @param string $object_id [description] |
* @param string $object_id [description] |
790 |
* @param bool $is_not_done [description] |
* @param bool $is_not_done [description] |
791 |
* @return [type] [description] |
* @return [type] [description] |
792 |
|
* |
793 |
|
* Cette méthode est déprécier, car elle cause des cas illogique avec PENDING qui ne compte pas dans le is_not_done. |
794 |
|
* L'utilisation de task_exists_multi_search() est à privilegier pour éviter les problèmes et les risques |
795 |
*/ |
*/ |
796 |
public function task_exists(string $type, string $object_id, string $dossier = null, bool $is_not_done = true) { |
public function task_exists(string $type, string $object_id, string $dossier = null, bool $is_not_done = true) { |
797 |
|
$qres = $this->f->get_one_result_from_db_query( |
798 |
|
sprintf( |
799 |
|
'SELECT |
800 |
|
task |
801 |
|
FROM |
802 |
|
%1$stask |
803 |
|
WHERE |
804 |
|
%2$s |
805 |
|
type = \'%3$s\' |
806 |
|
AND ( |
807 |
|
object_id = \'%4$s\' |
808 |
|
%5$s |
809 |
|
) |
810 |
|
AND state != \'%6$s\'', |
811 |
|
DB_PREFIXE, |
812 |
|
$is_not_done == true ? 'state != \''.self::STATUS_DONE.'\' AND' : '', |
813 |
|
$type, |
814 |
|
$object_id, |
815 |
|
$dossier !== null ? sprintf('OR dossier = \'%s\'', $dossier) : '', |
816 |
|
self::STATUS_CANCELED |
817 |
|
), |
818 |
|
array( |
819 |
|
"origin" => __METHOD__, |
820 |
|
) |
821 |
|
); |
822 |
|
if (! empty($qres["result"])) { |
823 |
|
return $qres["result"]; |
824 |
|
} |
825 |
|
return false; |
826 |
|
} |
827 |
|
|
828 |
|
/** |
829 |
|
* Permet la recherche multi-critères des tasks. |
830 |
|
* |
831 |
|
* @param array $search_values Chaque entrée du tableau est une ligne dans le WHERE |
832 |
|
* @return mixed Retourne le résultat de la requête ou false |
833 |
|
*/ |
834 |
|
public function task_exists_multi_search(array $search_values) { |
835 |
$query = sprintf(' |
$query = sprintf(' |
836 |
SELECT task |
SELECT task, state |
837 |
FROM %1$stask |
FROM %1$stask |
838 |
WHERE %2$s |
%2$s |
839 |
type = \'%3$s\' |
%3$s |
840 |
AND (object_id = \'%4$s\' |
ORDER BY task ASC |
|
%5$s) |
|
841 |
', |
', |
842 |
DB_PREFIXE, |
DB_PREFIXE, |
843 |
$is_not_done == true ? 'state != \''.self::STATUS_DONE.'\' AND' : '', |
empty($search_values) === false ? ' WHERE ' : '', |
844 |
$type, |
implode(' AND ', $search_values) |
845 |
$object_id, |
); |
846 |
$dossier !== null ? sprintf('OR dossier = \'%s\'', $dossier) : '' |
$res = $this->f->get_all_results_from_db_query( |
847 |
|
$query, |
848 |
|
array( |
849 |
|
"origin" => __METHOD__, |
850 |
|
) |
851 |
); |
); |
852 |
$res = $this->f->get_one_result_from_db_query($query); |
if (count($res['result']) > 0) { |
|
if ($res['result'] !== null && $res['result'] !== '') { |
|
853 |
return $res['result']; |
return $res['result']; |
854 |
} |
} |
855 |
return false; |
return false; |
866 |
* @return boolean |
* @return boolean |
867 |
*/ |
*/ |
868 |
function triggerajouter($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
function triggerajouter($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
869 |
|
$parent_res = parent::triggerajouter($id, $dnu1, $val); |
870 |
|
if ($parent_res === false) return $parent_res; |
871 |
|
|
872 |
// tâche entrante |
// tâche entrante |
873 |
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
884 |
} |
} |
885 |
|
|
886 |
// gestion d'une tache de type notification et de category mail |
// gestion d'une tache de type notification et de category mail |
887 |
if (isset($val['type']) && $val['type'] === 'notification_instruction' |
if (isset($val['type']) |
888 |
&& isset($val['category']) && $val['category'] === 'mail') { |
&& (($val['type'] === 'notification_instruction' || $val['type'] === 'notification_decision') |
889 |
|
&& isset($val['category']) |
890 |
|
&& $val['category'] === 'mail') |
891 |
|
|| $val['type'] === 'notification_service_consulte' |
892 |
|
|| $val['type'] === 'notification_tiers_consulte' |
893 |
|
|| $val['type'] === 'notification_depot_demat' |
894 |
|
|| $val['type'] === 'notification_commune' |
895 |
|
|| $val['type'] === 'notification_signataire' |
896 |
|
) { |
897 |
|
// Récupère la payload de la tache |
898 |
|
$data = array(); |
899 |
|
$data['instruction_notification'] = $this->get_instruction_notification_data( |
900 |
|
$this->valF['category'], |
901 |
|
'with-id', |
902 |
|
array('with-id' => $this->valF['object_id']) |
903 |
|
); |
904 |
|
$data['dossier'] = $this->get_dossier_data($this->valF['dossier']); |
905 |
|
|
906 |
// Récupère l'instance de la notification |
// Récupère l'instance de la notification |
907 |
$inst_notif = $this->f->get_inst__om_dbform(array( |
$inst_notif = $this->f->get_inst__om_dbform(array( |
908 |
"obj" => "instruction_notification", |
"obj" => "instruction_notification", |
909 |
"idx" => $val['object_id'], |
"idx" => $val['object_id'], |
910 |
)); |
)); |
911 |
// Envoi le mail et met à jour le suivi |
// Envoi le mail et met à jour le suivi |
912 |
$envoiMail = $inst_notif->send_mail_notification_demandeur(); |
$envoiMail = $inst_notif->send_mail_notification($data, $val['type']); |
913 |
// Passage de la tache à done si elle a réussi et à error |
// Passage de la tache à done si elle a réussi et à error |
914 |
// si l'envoi a échoué |
// si l'envoi a échoué |
915 |
$this->valF['state'] = 'done'; |
$this->valF['state'] = self::STATUS_DONE; |
916 |
if ($envoiMail === false) { |
if ($envoiMail === false) { |
917 |
$this->valF['state'] = 'error'; |
$this->valF['state'] = self::STATUS_ERROR; |
918 |
|
} |
919 |
|
} |
920 |
|
} |
921 |
|
|
922 |
|
/** |
923 |
|
* TRIGGER - triggermodifier. |
924 |
|
* |
925 |
|
* @param string $id |
926 |
|
* @param null &$dnu1 @deprecated Ne pas utiliser. |
927 |
|
* @param array $val Tableau des valeurs brutes. |
928 |
|
* @param null $dnu2 @deprecated Ne pas utiliser. |
929 |
|
* |
930 |
|
* @return boolean |
931 |
|
*/ |
932 |
|
function triggermodifier($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
933 |
|
parent::triggermodifier($id, $dnu1, $val, $dnu2); |
934 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
935 |
|
|
936 |
|
// Mise à jour des valeurs, notamment du timestamp_log en fonction de plusieurs critères |
937 |
|
$values = array( |
938 |
|
'state' => $this->valF['state'], |
939 |
|
'object_id' => $this->valF['object_id'], |
940 |
|
'comment' => $this->valF['comment'], |
941 |
|
); |
942 |
|
$new_values = $this->set_values_for_update($values); |
943 |
|
if ($new_values === false) { |
944 |
|
$this->addToLog(__METHOD__."(): erreur timestamp log", DEBUG_MODE); |
945 |
|
return false; |
946 |
|
} |
947 |
|
|
948 |
|
// Mise à jour des valeurs |
949 |
|
$this->valF['timestamp_log'] = $new_values['timestamp_log']; |
950 |
|
$this->valF['state'] = $new_values['state']; |
951 |
|
$this->valF['object_id'] = $new_values['object_id']; |
952 |
|
$this->valF['last_modification_date'] = date('Y-m-d'); |
953 |
|
$this->valF['last_modification_time'] = date('H:i:s'); |
954 |
|
if ($val['stream'] === 'output' |
955 |
|
&& $val['type'] !== 'suppression_piece') { |
956 |
|
// Lorsque la task passe d'un état qui n'est pas "done" à l'état "done" |
957 |
|
if ($this->getVal("state") !== self::STATUS_DONE |
958 |
|
&& $this->valF['state'] === self::STATUS_DONE) { |
959 |
|
// |
960 |
|
$this->valF['json_payload'] = $this->view_form_json(true); |
961 |
|
} |
962 |
|
// Lorsque la task passe d'un état "done" à un état qui n'est pas "done" |
963 |
|
if ($this->getVal("state") === self::STATUS_DONE |
964 |
|
&& $this->valF['state'] !== self::STATUS_DONE) { |
965 |
|
// |
966 |
|
$this->valF['json_payload'] = "{}"; |
967 |
} |
} |
968 |
} |
} |
969 |
|
|
970 |
|
return true; |
971 |
} |
} |
972 |
|
|
973 |
|
|
974 |
|
/** |
975 |
|
* Applique nouvelle valeur après traitement. |
976 |
|
* |
977 |
|
* @param array $params Tableau des valeurs en entrées |
978 |
|
* @return array Tableau des valeurs en sorties |
979 |
|
*/ |
980 |
|
public function set_values_for_update($params = array()) { |
981 |
|
|
982 |
|
// Récupération du timestamp_log existant |
983 |
|
$timestamp_log = $this->get_timestamp_log(); |
984 |
|
if ($timestamp_log === false) { |
985 |
|
return false; |
986 |
|
} |
987 |
|
|
988 |
|
// Vérification des object_id précédent en cas de tentative d'appliquer |
989 |
|
// l'état CANCELED sur la tâche |
990 |
|
if (isset($params['state']) === true |
991 |
|
&& $params['state'] === self::STATUS_CANCELED) { |
992 |
|
// Récupération du journal d'activité de la tâche sous forme de tableau |
993 |
|
// trié par ordre décroissant |
994 |
|
$log = $timestamp_log; |
995 |
|
krsort($log); |
996 |
|
// Pour chaque entrée dans le journal d'activité de la tâche : |
997 |
|
// - vérification de la présence de l'object_id précédent |
998 |
|
// - vérification que l'object_id précédent existe toujours dans la base de données |
999 |
|
// - l'object_id est mise à jour avec la valeur de l'object_id précédent |
1000 |
|
// - le state n'est pas modifié |
1001 |
|
// - sortie du traitement dès que le premier object_id précédent existant est trouvé |
1002 |
|
// - si aucun object_id précédent existant n'est trouvé alors ni le state, ni l'object_id n'est modifiés |
1003 |
|
foreach ($log as $key => $value) { |
1004 |
|
// |
1005 |
|
if (isset($value['prev_object_id']) === true |
1006 |
|
&& $this->getVal('object_id') !== $value['prev_object_id']) { |
1007 |
|
// Récupère la liste des tables potentielles pour un type de tâche |
1008 |
|
$tables = $this->get_tables_by_task_type($this->getVal('type'), $this->getVal('stream')); |
1009 |
|
foreach ($tables as $table) { |
1010 |
|
// Vérifie s'il y a un ou aucun résultat |
1011 |
|
$qres = $this->f->get_one_result_from_db_query( |
1012 |
|
sprintf( |
1013 |
|
'SELECT |
1014 |
|
COUNT(%2$s) |
1015 |
|
FROM |
1016 |
|
%1$s%2$s |
1017 |
|
WHERE |
1018 |
|
%2$s::CHARACTER VARYING = \'%3$s\'', |
1019 |
|
DB_PREFIXE, |
1020 |
|
$table, |
1021 |
|
$value['prev_object_id'] |
1022 |
|
), |
1023 |
|
array( |
1024 |
|
"origin" => __METHOD__, |
1025 |
|
"force_return" => true, |
1026 |
|
) |
1027 |
|
); |
1028 |
|
if ($qres["code"] !== "OK") { |
1029 |
|
return $this->end_treatment(__METHOD__, false); |
1030 |
|
} |
1031 |
|
// Affectation des valeurs et sortie de la boucle |
1032 |
|
if ($qres["result"] == '1') { |
1033 |
|
$params['object_id'] = $value['prev_object_id']; |
1034 |
|
$params['state'] = $this->getVal('state'); |
1035 |
|
break; |
1036 |
|
} |
1037 |
|
} |
1038 |
|
// Sortie de la boucle si les valeurs sont affectées |
1039 |
|
if ($params['object_id'] !== null |
1040 |
|
&& $params['object_id'] === $value['prev_object_id']) { |
1041 |
|
// |
1042 |
|
break; |
1043 |
|
} |
1044 |
|
} |
1045 |
|
} |
1046 |
|
} |
1047 |
|
|
1048 |
|
// Mise à jour du journal d'activité de la tâche |
1049 |
|
array_push($timestamp_log, array( |
1050 |
|
'modification_date' => date('Y-m-d H:i:s'), |
1051 |
|
'object_id' => $params['object_id'] !== null ? $params['object_id'] : $this->getVal('object_id'), |
1052 |
|
'prev_object_id' => $this->getVal('object_id'), |
1053 |
|
'state' => $params['state'], |
1054 |
|
'prev_state' => $this->getVal('state'), |
1055 |
|
'comment' => isset($params['comment']) ? $params['comment'] : $this->getVal('comment'), |
1056 |
|
)); |
1057 |
|
// |
1058 |
|
$timestamp_log = json_encode($timestamp_log); |
1059 |
|
|
1060 |
|
|
1061 |
|
// Les nouvelles valeurs après vérification des critères |
1062 |
|
$result = array( |
1063 |
|
'timestamp_log' => $timestamp_log, |
1064 |
|
'object_id' => $params['object_id'], |
1065 |
|
'state' => $params['state'], |
1066 |
|
'comment' => $params['comment'], |
1067 |
|
); |
1068 |
|
return $result; |
1069 |
|
} |
1070 |
|
|
1071 |
|
|
1072 |
/** |
/** |
1073 |
* TRIGGER - triggermodifierapres. |
* TRIGGER - triggermodifierapres. |
1074 |
* |
* |
1083 |
parent::triggermodifierapres($id, $dnu1, $val, $dnu2); |
parent::triggermodifierapres($id, $dnu1, $val, $dnu2); |
1084 |
|
|
1085 |
// Suivi des notificiations |
// Suivi des notificiations |
1086 |
|
// En cas de changement de l'état de la tâche de notification, alors |
1087 |
|
// le suivi des dates de la notification et de l'instruction, est effectué |
1088 |
if (isset($val['category']) === true |
if (isset($val['category']) === true |
1089 |
&& $val['category'] === 'portal' |
&& $val['category'] === PORTAL |
1090 |
&& isset($val['type']) === true |
&& isset($val['type']) === true |
1091 |
&& ($val['type'] === 'notification_recepisse' |
&& ($val['type'] === 'notification_recepisse' |
1092 |
|| $val['type'] === 'notification_instruction' |
|| $val['type'] === 'notification_instruction' |
1093 |
|| $val['type'] === 'notification_decision')) { |
|| $val['type'] === 'notification_decision' |
1094 |
|
|| $val['type'] === 'notification_service_consulte' |
1095 |
|
|| $val['type'] === 'notification_tiers_consulte')) { |
1096 |
// |
// |
1097 |
if (isset($this->valF['state']) === true |
if (isset($this->valF['state']) === true |
1098 |
&& $this->valF['state'] !== $this->getVal('state')) { |
&& $this->valF['state'] !== $this->getVal('state') |
1099 |
|
&& $this->valF['state'] !== self::STATUS_CANCELED) { |
1100 |
// |
// |
1101 |
$inst_in = $this->f->get_inst__om_dbform(array( |
$inst_in = $this->f->get_inst__om_dbform(array( |
1102 |
"obj" => "instruction_notification", |
"obj" => "instruction_notification", |
1103 |
"idx" => $val['object_id'], |
"idx" => $val['object_id'], |
1104 |
)); |
)); |
1105 |
$valF = array(); |
$valF_in = array(); |
1106 |
foreach ($inst_in->champs as $champ) { |
foreach ($inst_in->champs as $champ) { |
1107 |
$valF[$champ] = $inst_in->getVal($champ); |
$valF_in[$champ] = $inst_in->getVal($champ); |
1108 |
} |
} |
1109 |
// Pas de date sur le suivi des notifications depuis un portail |
// Par défaut la date d'envoi et la date de premier accès sur |
1110 |
$valF['date_envoi'] = null; |
// la notification ne sont pas renseignées |
1111 |
$valF['date_premier_acces'] = null; |
$valF_in['date_envoi'] = null; |
1112 |
|
$valF_in['date_premier_acces'] = null; |
1113 |
|
// Lorsque la tâche est correctement traitée |
1114 |
if ($this->valF['state'] === self::STATUS_DONE) { |
if ($this->valF['state'] === self::STATUS_DONE) { |
1115 |
$valF['statut'] = __("envoyé"); |
// |
1116 |
$valF['commentaire'] = __("Notification traitée"); |
$valF_in['statut'] = __("envoyé"); |
1117 |
|
$valF_in['commentaire'] = __("Notification traitée"); |
1118 |
|
$valF_in['date_envoi'] = date('d/m/Y H:i:s'); |
1119 |
|
// Si l'instruction possède un document lié, alors ses dates |
1120 |
|
// de suivi sont mises à jour |
1121 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
1122 |
|
"obj" => "instruction", |
1123 |
|
"idx" => $inst_in->getVal('instruction'), |
1124 |
|
)); |
1125 |
|
if ($inst_instruction->has_an_edition() === true) { |
1126 |
|
$valF_instruction = array(); |
1127 |
|
foreach ($inst_instruction->champs as $champ) { |
1128 |
|
$valF_instruction[$champ] = $inst_instruction->getVal($champ); |
1129 |
|
} |
1130 |
|
$valF_instruction['date_envoi_rar'] = date('d/m/Y'); |
1131 |
|
$valF_instruction['date_retour_rar'] = date('d/m/Y', strtotime('now + 1 day')); |
1132 |
|
// Action spécifique pour identifier que la modification |
1133 |
|
// est une notification de demandeur |
1134 |
|
$inst_instruction->setParameter('maj', 175); |
1135 |
|
$update_instruction = $inst_instruction->modifier($valF_instruction); |
1136 |
|
if ($update_instruction === false) { |
1137 |
|
$this->addToLog(__METHOD__."(): ".$inst_instruction->msg, DEBUG_MODE); |
1138 |
|
return false; |
1139 |
|
} |
1140 |
|
} |
1141 |
} |
} |
1142 |
|
// En cas d'erreur lors du traitement de la task |
1143 |
if ($this->valF['state'] === self::STATUS_ERROR) { |
if ($this->valF['state'] === self::STATUS_ERROR) { |
1144 |
$valF['statut'] = __("échec"); |
$valF_in['statut'] = __("échec"); |
1145 |
$valF['commentaire'] = __("Le traitement de la notification a échoué"); |
$valF_in['commentaire'] = __("Le traitement de la notification a échoué"); |
1146 |
} |
} |
1147 |
|
// Met à jour la notification |
1148 |
$inst_in->setParameter('maj', 1); |
$inst_in->setParameter('maj', 1); |
1149 |
$update = $inst_in->modifier($valF); |
$update_in = $inst_in->modifier($valF_in); |
1150 |
if ($update === false) { |
if ($update_in === false) { |
1151 |
$this->addToLog(__METHOD__."(): ".$inst_in->msg, DEBUG_MODE); |
$this->addToLog(__METHOD__."(): ".$inst_in->msg, DEBUG_MODE); |
1152 |
return false; |
return false; |
1153 |
} |
} |
1154 |
} |
} |
1155 |
} |
} |
1156 |
|
|
1157 |
|
// Envoi au contrôle de légalité |
1158 |
|
// En cas de changement de l'état de la tâche envoi_CL, alors le suivi |
1159 |
|
// des dates de l'instruction est effectué |
1160 |
|
if ($val['type'] === 'envoi_CL' |
1161 |
|
&& isset($this->valF['state']) === true |
1162 |
|
&& $this->valF['state'] === self::STATUS_DONE) { |
1163 |
|
// |
1164 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
1165 |
|
"obj" => "instruction", |
1166 |
|
"idx" => $this->getVal('object_id'), |
1167 |
|
)); |
1168 |
|
$valF_instruction = array(); |
1169 |
|
foreach ($inst_instruction->champs as $champ) { |
1170 |
|
$valF_instruction[$champ] = $inst_instruction->getVal($champ); |
1171 |
|
} |
1172 |
|
// On met à jour la date d'envoi au CL seulement si l'instruction a une édition liée |
1173 |
|
$valF_instruction['date_envoi_controle_legalite'] = date("Y-m-d"); |
1174 |
|
$inst_instruction->setParameter('maj', 1); |
1175 |
|
$update_instruction = $inst_instruction->modifier($valF_instruction); |
1176 |
|
if ($update_instruction === false) { |
1177 |
|
$this->addToLog(__METHOD__."(): ".$inst_instruction->msg, DEBUG_MODE); |
1178 |
|
return false; |
1179 |
|
} |
1180 |
|
} |
1181 |
|
|
1182 |
// |
// |
1183 |
return true; |
return true; |
1184 |
} |
} |
1214 |
} |
} |
1215 |
|
|
1216 |
// |
// |
1217 |
$timestamp_log = json_encode(array( |
$timestamp_log = json_encode(array()); |
|
'creation_date' => date('Y-m-d H:i:s'), |
|
|
)); |
|
1218 |
|
|
1219 |
// |
// |
1220 |
$category = isset($params['val']['category']) === true ? $params['val']['category'] : $this->category; |
$category = isset($params['val']['category']) === true ? $params['val']['category'] : $this->category; |
1222 |
// 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 |
1223 |
// 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 |
1224 |
if (isset($params['val']['type']) |
if (isset($params['val']['type']) |
1225 |
&& ($params['val']['type'] == "add_piece" || $params['val']['type'] == "avis_consultation") |
&& in_array($params['val']['type'], self::TASK_WITH_DOCUMENT) |
1226 |
&& isset($params['val']['stream']) |
&& isset($params['val']['stream']) |
1227 |
&& $params['val']['stream'] == "input" ) { |
&& $params['val']['stream'] == "input" ) { |
1228 |
// |
// |
1231 |
$this->addToMessage(__("Le contenu JSON de la tâche n'est pas valide.")); |
$this->addToMessage(__("Le contenu JSON de la tâche n'est pas valide.")); |
1232 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
1233 |
} |
} |
1234 |
if (isset($json_payload['document_numerise']) === true |
if (isset($json_payload['document_numerise']["file_content"]) === true |
1235 |
&& empty($json_payload['document_numerise']) === false) { |
&& empty($json_payload['document_numerise']["file_content"]) === false) { |
1236 |
// |
// |
1237 |
$document_numerise = $json_payload['document_numerise']; |
$document_numerise = $json_payload['document_numerise']; |
1238 |
$file_content = base64_decode($document_numerise["file_content"]); |
$file_content = base64_decode($document_numerise["file_content"]); |
1258 |
} |
} |
1259 |
} |
} |
1260 |
|
|
1261 |
// Mise à jour du DI |
if (isset($params['val']['state'])) { |
1262 |
|
$allowed_state = array( |
1263 |
|
self::STATUS_DRAFT, |
1264 |
|
self::STATUS_NEW, |
1265 |
|
self::STATUS_PENDING, |
1266 |
|
self::STATUS_DONE, |
1267 |
|
self::STATUS_ERROR, |
1268 |
|
self::STATUS_DEBUG, |
1269 |
|
self::STATUS_ARCHIVED, |
1270 |
|
self::STATUS_CANCELED, |
1271 |
|
self::STATUS_INVALID); |
1272 |
|
|
1273 |
|
if (empty($params['val']['state'])) { |
1274 |
|
throw new InvalidArgumentException( |
1275 |
|
"État ('state') vide pour la nouvelle tâche"); |
1276 |
|
} |
1277 |
|
elseif (! in_array($params['val']['state'], $allowed_state)) { |
1278 |
|
throw new InvalidArgumentException( |
1279 |
|
"État ('state') invalide (".var_export($params['val']['state'], true). |
1280 |
|
") pour la nouvelle tâche"); |
1281 |
|
} |
1282 |
|
} |
1283 |
|
|
1284 |
|
// Valeurs de la tâche |
1285 |
$valF = array( |
$valF = array( |
1286 |
'task' => '', |
'task' => '', |
1287 |
'type' => $params['val']['type'], |
'type' => $params['val']['type'], |
1292 |
'stream' => $stream, |
'stream' => $stream, |
1293 |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
1294 |
'category' => $category, |
'category' => $category, |
1295 |
|
'creation_date' => date('Y-m-d'), |
1296 |
|
'creation_time' => date('H:i:s'), |
1297 |
|
'last_modification_date' => null, |
1298 |
|
'last_modification_time' => null, |
1299 |
|
'comment' => null, |
1300 |
); |
); |
1301 |
|
|
1302 |
// tâche sortante |
// Gestion de la mise à jour des tâches sortantes |
1303 |
|
$typeNonConcerne = array( |
1304 |
|
'notification_recepisse', |
1305 |
|
'notification_instruction', |
1306 |
|
'notification_decision', |
1307 |
|
'notification_service_consulte', |
1308 |
|
'notification_tiers_consulte', |
1309 |
|
'notification_depot_demat', |
1310 |
|
'notification_commune', |
1311 |
|
'notification_signataire', |
1312 |
|
); |
1313 |
if ($valF["stream"] == "output" |
if ($valF["stream"] == "output" |
1314 |
&& $valF['type'] !== 'notification_recepisse' |
&& ! in_array($valF['type'], $typeNonConcerne)) { |
1315 |
&& $valF['type'] !== 'notification_instruction' |
// Vérification de l'existance d'une tâche pour l'objet concerné |
1316 |
&& $valF['type'] !== 'notification_decision') { |
// La vérification diffère en fonction de certains types de tâche |
1317 |
|
$search_values_common = array( |
1318 |
// TODO expliquer ce code |
sprintf('state != \'%s\'', self::STATUS_CANCELED), |
1319 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id'], $valF['dossier']); |
sprintf('state != \'%s\'', self::STATUS_DONE), |
1320 |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
); |
1321 |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
$search_values_others = array( |
1322 |
} |
sprintf('type = \'%s\'', $valF['type']), |
1323 |
if ($valF['type'] === 'modification_DA' && $task_exists === false) { |
sprintf('(object_id = \'%s\' OR dossier = \'%s\')', $valF['object_id'], $valF['dossier']), |
1324 |
$task_exists = $this->task_exists('creation_DA', $valF['object_id']); |
); |
1325 |
} |
$search_values_specifics = array( |
1326 |
if ($valF['type'] === 'ajout_piece') { |
sprintf('object_id = \'%s\'', $valF['object_id']), |
1327 |
$task_exists = $this->task_exists('ajout_piece', $valF['object_id']); |
); |
1328 |
|
|
1329 |
|
// Recherche multi-critères sur les tâches |
1330 |
|
// Si l'object id/dossier à des tâches de type $valF['type'] qui lui est associé |
1331 |
|
// Et que ces tâches ont des statut différents de canceled et done |
1332 |
|
// Alors on récupère ces tâches |
1333 |
|
// Sinon return false |
1334 |
|
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_others)); |
1335 |
|
|
1336 |
|
// Vérifie si une tâche existe déjà pour les types de tâches ayant un fonctionnement particulier. |
1337 |
|
// Il existe 2 cas : |
1338 |
|
// - Aucune tâche déjà existante n'a été récupérées mais on veut faire une vérification supplémentaire |
1339 |
|
// - Les tâches pour lesquelles on fait une vérification supplémentaire qu'une correspondance ait été |
1340 |
|
// trouvée ou pas |
1341 |
|
// Une tâche ne pouvant avoir qu'un seul type si elle est trouvée, il n'est pas nécessaire de |
1342 |
|
// vérifier les autres |
1343 |
|
$is_type_voulu_traite = false; |
1344 |
|
// Cas 1 : Aucune tâche déjà existante n'a été récupérées mais effectue une vérification supplémentaire |
1345 |
|
$cas_specifiques_tache_non_existante = array( |
1346 |
|
'modification_DI' => array("type = 'creation_DI'"), |
1347 |
|
'modification_DA' => array("type = 'creation_DA'") |
1348 |
|
); |
1349 |
|
foreach ($cas_specifiques_tache_non_existante as $type_task => $conditions_specifiques) { |
1350 |
|
// S'il n'existe pas de tâche de type voulu pour l'object id/dossier |
1351 |
|
if ($valF['type'] === $type_task && $task_exists === false) { |
1352 |
|
// On se réfère à la tâche de type 'ajout piece' de l'object id |
1353 |
|
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_specifics, $conditions_specifiques)); |
1354 |
|
$is_type_voulu_traite = true; |
1355 |
|
break; |
1356 |
|
} |
1357 |
} |
} |
1358 |
if ($valF['type'] === 'creation_consultation') { |
|
1359 |
$task_exists = $this->task_exists('creation_consultation', $valF['object_id']); |
// Cas 2 : Vérification supplémentaire qu'une correspondance ait été trouvé ou pas |
1360 |
|
if (! $is_type_voulu_traite) { |
1361 |
|
$cas_specifiques = array( |
1362 |
|
'ajout_piece', |
1363 |
|
'modification_piece', |
1364 |
|
'suppression_piece', |
1365 |
|
'creation_consultation', |
1366 |
|
'ajout_documents_specifiques', |
1367 |
|
); |
1368 |
|
foreach ($cas_specifiques as $type_task) { |
1369 |
|
if ($valF['type'] === $type_task) { |
1370 |
|
// On se réfère à la tâche de type 'ajout piece' de l'object id |
1371 |
|
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_specifics, array("type = '$type_task'"))); |
1372 |
|
break; |
1373 |
|
} |
1374 |
|
} |
1375 |
} |
} |
1376 |
|
|
1377 |
|
// S'il existe une tâche pour l'objet concerné, pas d'ajout de nouvelle |
1378 |
|
// tâche mais mise à jour de l'existante |
1379 |
if ($task_exists !== false) { |
if ($task_exists !== false) { |
1380 |
$inst_task = $this->f->get_inst__om_dbform(array( |
// Plusieurs tâches pourraient exister, elles sont contôler par ordre croissant |
1381 |
"obj" => "task", |
foreach ($task_exists as $task) { |
1382 |
"idx" => $task_exists, |
$inst_task = $this->f->get_inst__om_dbform(array( |
1383 |
)); |
"obj" => "task", |
1384 |
$update_state = $inst_task->getVal('state'); |
"idx" => $task['task'], |
1385 |
if (isset($params['update_val']['state']) === true) { |
)); |
1386 |
$update_state = $params['update_val']['state']; |
$update_state = $inst_task->getVal('state'); |
1387 |
} |
if (isset($params['update_val']['state']) === true) { |
1388 |
$update_params = array( |
$update_state = $params['update_val']['state']; |
1389 |
'val' => array( |
} |
1390 |
'state' => $update_state, |
$object_id = $inst_task->getVal('object_id'); |
1391 |
), |
if (!empty($valF['object_id'])) { |
1392 |
); |
$object_id = $valF['object_id']; |
1393 |
return $inst_task->update_task($update_params); |
} |
1394 |
|
// Pour être mise à jour, la tâche existante ne doit pas être en cours de traitement |
1395 |
|
$task_pending = $inst_task->getVal('state') === self::STATUS_PENDING |
1396 |
|
&& $update_state === self::STATUS_PENDING |
1397 |
|
&& $inst_task->getVal('object_id') !== $object_id; |
1398 |
|
if ($task_pending === false) { |
1399 |
|
$update_params = array( |
1400 |
|
'val' => array( |
1401 |
|
'state' => $update_state, |
1402 |
|
), |
1403 |
|
'object_id' => $object_id, |
1404 |
|
); |
1405 |
|
return $inst_task->update_task($update_params); |
1406 |
|
} |
1407 |
|
} |
1408 |
} |
} |
1409 |
} |
} |
1410 |
$add = $this->ajouter($valF); |
$add = $this->ajouter($valF); |
1411 |
$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); |
1412 |
|
|
1413 |
|
// Création de la payload JSON dans le cas ou nous avons un suppression d'objet |
1414 |
|
if ($stream === 'output' |
1415 |
|
&& $add === true |
1416 |
|
&& isset($valF['type']) === true |
1417 |
|
&& strpos($valF['type'], 'suppression_piece') !== false |
1418 |
|
) { |
1419 |
|
$inst_task_empty = $this->f->get_inst__om_dbform(array( |
1420 |
|
"obj" => "task", |
1421 |
|
"idx" => 0, |
1422 |
|
)); |
1423 |
|
// Vérification de l'éxistence d'une tache de suppression de pièce |
1424 |
|
$task_exists = $inst_task_empty->task_exists('suppression_piece', $valF['object_id']); |
1425 |
|
$valF['task'] = $task_exists; |
1426 |
|
$inst_task = $this->f->get_inst__om_dbform(array( |
1427 |
|
"obj" => "task", |
1428 |
|
"idx" => $task_exists, |
1429 |
|
)); |
1430 |
|
$valF['json_payload'] = $inst_task->view_form_json(true); |
1431 |
|
$update = $this->modifier($valF); |
1432 |
|
if ($update === false) { |
1433 |
|
$this->addToLog(__METHOD__."(): ".$this->msg, DEBUG_MODE); |
1434 |
|
return $this->end_treatment(__METHOD__, false); |
1435 |
|
} |
1436 |
|
} |
1437 |
|
|
1438 |
if ($add === false) { |
if ($add === false) { |
1439 |
$this->addToLog(__METHOD__."(): ".$this->msg, DEBUG_MODE); |
$this->addToLog(__METHOD__."(): ".$this->msg, DEBUG_MODE); |
1440 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
1451 |
*/ |
*/ |
1452 |
public function update_task($params = array()) { |
public function update_task($params = array()) { |
1453 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
1454 |
$timestamp_log = $this->get_timestamp_log(); |
|
1455 |
if ($timestamp_log === false) { |
$allowed_state = array( |
1456 |
$this->addToLog(__METHOD__."(): erreur timestamp log", DEBUG_MODE); |
self::STATUS_DRAFT, |
1457 |
return $this->end_treatment(__METHOD__, false); |
self::STATUS_NEW, |
1458 |
|
self::STATUS_PENDING, |
1459 |
|
self::STATUS_DONE, |
1460 |
|
self::STATUS_ERROR, |
1461 |
|
self::STATUS_DEBUG, |
1462 |
|
self::STATUS_ARCHIVED, |
1463 |
|
self::STATUS_CANCELED, |
1464 |
|
self::STATUS_INVALID); |
1465 |
|
|
1466 |
|
$task_id = $this->getVal($this->clePrimaire); |
1467 |
|
|
1468 |
|
if (! isset($params['val']['state']) || empty($params['val']['state'])) { |
1469 |
|
throw new InvalidArgumentException( |
1470 |
|
"État ('state') non spécifié ou vide pour la tâche '$task_id'"); |
1471 |
|
} |
1472 |
|
elseif (! in_array($params['val']['state'], $allowed_state)) { |
1473 |
|
throw new InvalidArgumentException( |
1474 |
|
"État ('state') invalide (".var_export($params['val']['state'], true). |
1475 |
|
") pour la tâche '$task_id'"); |
1476 |
} |
} |
1477 |
array_push($timestamp_log, array( |
|
1478 |
'modification_date' => date('Y-m-d H:i:s'), |
// Mise à jour de la tâche |
|
'state' => $params['val']['state'], |
|
|
'prev_state' => $this->getVal('state'), |
|
|
)); |
|
|
$timestamp_log = json_encode($timestamp_log); |
|
1479 |
$valF = array( |
$valF = array( |
1480 |
'task' => $this->getVal($this->clePrimaire), |
'task' => $task_id, |
1481 |
'type' => $this->getVal('type'), |
'type' => $this->getVal('type'), |
1482 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => '[]', |
1483 |
'state' => $params['val']['state'], |
'state' => $params['val']['state'], |
1484 |
'object_id' => isset($params['object_id']) == true && $this->getVal('type') == 'create_DI' ? $params['object_id'] : $this->getVal('object_id'), |
'object_id' => isset($params['object_id']) == true ? $params['object_id'] : $this->getVal('object_id'), |
1485 |
'stream' => $this->getVal('stream'), |
'stream' => $this->getVal('stream'), |
1486 |
'dossier' => $this->getVal('dossier'), |
'dossier' => $this->getVal('dossier'), |
1487 |
'json_payload' => $this->getVal('json_payload'), |
'json_payload' => $this->getVal('json_payload'), |
1488 |
'category' => $this->getVal('category'), |
'category' => $this->getVal('category'), |
1489 |
|
'creation_date' => $this->getVal('creation_date'), |
1490 |
|
'creation_time' => $this->getVal('creation_time'), |
1491 |
|
'last_modification_date' => date('Y-m-d'), |
1492 |
|
'last_modification_time' => date('H:i:s'), |
1493 |
|
'comment' => isset($params['comment']) == true ? $params['comment'] : $this->getVal('comment'), |
1494 |
); |
); |
1495 |
$update = $this->modifier($valF); |
$update = $this->modifier($valF); |
1496 |
if ($update === false) { |
if ($update === false) { |
1501 |
} |
} |
1502 |
|
|
1503 |
/** |
/** |
1504 |
|
* A partir des éléments fournis en paramètre compose une url permettant |
1505 |
|
* d'accéder à un document. |
1506 |
|
* |
1507 |
|
* @param string $nom_objet : nom de l'objet d'appartenance du document |
1508 |
|
* @param string $champ : champ contenant l'uid du document |
1509 |
|
* @param string|integer $id_objet : id de l'objet d'appartenance du document |
1510 |
|
* |
1511 |
|
* @return string url d'accès au document |
1512 |
|
*/ |
1513 |
|
function compose_url_acces_document(string $nom_objet, string $champ, $id_objet) { |
1514 |
|
return sprintf( |
1515 |
|
'app/index.php?module=form&snippet=file&obj=%s&champ=%s&id=%s', |
1516 |
|
$nom_objet, |
1517 |
|
$champ, |
1518 |
|
$id_objet |
1519 |
|
); |
1520 |
|
} |
1521 |
|
|
1522 |
|
/** |
1523 |
* Récupère le journal d'horodatage dans le champ timestamp_log de |
* Récupère le journal d'horodatage dans le champ timestamp_log de |
1524 |
* l'enregistrement instancié. |
* l'enregistrement instancié. |
1525 |
* |
* |
1547 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
1548 |
$this->f->disableLog(); |
$this->f->disableLog(); |
1549 |
if ($this->getParameter('idx') !== ']' |
if ($this->getParameter('idx') !== ']' |
1550 |
&& $this->getParameter('idx') !== '0') { |
&& $this->getParameter('idx') !== '0' |
1551 |
// |
) { |
1552 |
$this->view_form_json(); |
if ($this->getVal('json_payload') !== "{}") { |
1553 |
|
// On prend la Payload en BDD |
1554 |
|
echo( |
1555 |
|
json_encode( |
1556 |
|
json_decode($this->getVal('json_payload'), true), |
1557 |
|
JSON_UNESCAPED_SLASHES |
1558 |
|
) |
1559 |
|
); |
1560 |
|
} else { |
1561 |
|
// On Calcule la payload JSON |
1562 |
|
$this->view_form_json(); |
1563 |
|
} |
1564 |
} |
} |
1565 |
else { |
else { |
1566 |
$this->view_tab_json(); |
$this->view_tab_json(); |
1569 |
|
|
1570 |
protected function view_tab_json() { |
protected function view_tab_json() { |
1571 |
$where = ''; |
$where = ''; |
1572 |
if ($this->f->get_submitted_get_value('state') !== null |
$category = null; |
1573 |
&& $this->f->get_submitted_get_value('state') !== '') { |
// Liste des paramètres possibles pour la recherche des tâches |
1574 |
// |
$params = array( |
1575 |
$where_or_and = 'WHERE'; |
'task', |
1576 |
if ($where !== '') { |
'type', |
1577 |
$where_or_and = 'AND'; |
'state', |
1578 |
} |
'object_id', |
1579 |
$where .= sprintf(' %s state = \'%s\' ', $where_or_and, $this->f->get_submitted_get_value('state')); |
'dossier', |
1580 |
} |
'stream', |
1581 |
if ($this->f->get_submitted_get_value('category') !== null |
'category', |
1582 |
&& $this->f->get_submitted_get_value('category') !== '') { |
'lien_id_interne_uid_externe', |
1583 |
// |
'object', |
1584 |
$where_or_and = 'WHERE'; |
'external_uid', |
1585 |
if ($where !== '') { |
); |
1586 |
$where_or_and = 'AND'; |
// Pour chaque paramètre possible, vérification de son existance et de sa |
1587 |
|
// valeur pour compléter la requête de recherche |
1588 |
|
foreach ($params as $param) { |
1589 |
|
// |
1590 |
|
if ($this->f->get_submitted_get_value($param) !== null |
1591 |
|
&& $this->f->get_submitted_get_value($param) !== '') { |
1592 |
|
// Condition spécifique au champ 'category' |
1593 |
|
if ($param === 'category') { |
1594 |
|
$category = $this->f->get_submitted_get_value('category'); |
1595 |
|
} |
1596 |
|
// |
1597 |
|
$where_or_and = 'WHERE'; |
1598 |
|
if ($where !== '') { |
1599 |
|
$where_or_and = 'AND'; |
1600 |
|
} |
1601 |
|
$table = 'task'; |
1602 |
|
if ($param === 'lien_id_interne_uid_externe' |
1603 |
|
|| $param === 'object' |
1604 |
|
|| $param === 'external_uid') { |
1605 |
|
// |
1606 |
|
$table = 'lien_id_interne_uid_externe'; |
1607 |
|
} |
1608 |
|
$where .= sprintf(' %s %s.%s = \'%s\' ', $where_or_and, $table, $param, $this->f->get_submitted_get_value($param)); |
1609 |
} |
} |
|
$where .= sprintf(' %s category = \'%s\' ', $where_or_and, $this->f->get_submitted_get_value('category')); |
|
1610 |
} |
} |
1611 |
|
// |
1612 |
$query = sprintf(' |
$query = sprintf(' |
1613 |
SELECT |
SELECT |
1614 |
* |
DISTINCT (task.task), |
1615 |
|
task.type, |
1616 |
|
task.object_id, |
1617 |
|
task.dossier, |
1618 |
|
task.stream, |
1619 |
|
task.category, |
1620 |
|
task.creation_date, |
1621 |
|
task.creation_time, |
1622 |
|
task.last_modification_date, |
1623 |
|
task.last_modification_time, |
1624 |
|
task.comment |
1625 |
FROM %1$stask |
FROM %1$stask |
1626 |
|
LEFT JOIN %1$slien_id_interne_uid_externe |
1627 |
|
ON task.object_id = lien_id_interne_uid_externe.object_id |
1628 |
|
AND task.category = lien_id_interne_uid_externe.category |
1629 |
%2$s |
%2$s |
1630 |
ORDER BY task ASC |
ORDER BY task ASC |
1631 |
', |
', |
1632 |
DB_PREFIXE, |
DB_PREFIXE, |
1633 |
$where |
$where |
1634 |
); |
); |
1635 |
$res = $this->f->get_all_results_from_db_query($query, true); |
$res = $this->f->get_all_results_from_db_query( |
1636 |
|
$query, |
1637 |
|
array( |
1638 |
|
"origin" => __METHOD__, |
1639 |
|
"force_return" => true, |
1640 |
|
) |
1641 |
|
); |
1642 |
if ($res['code'] === 'KO') { |
if ($res['code'] === 'KO') { |
1643 |
return false; |
return false; |
1644 |
} |
} |
1645 |
$list_tasks = array(); |
$list_tasks = array(); |
1646 |
foreach ($res['result'] as $task) { |
foreach ($res['result'] as $task) { |
|
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
|
|
$task['dossier'] = $task['dossier']; |
|
|
if ($task['type'] === 'ajout_piece') { |
|
|
$val_dn = $this->get_document_numerise_data($task['object_id']); |
|
|
} |
|
1647 |
if ($task['stream'] === 'output') { |
if ($task['stream'] === 'output') { |
1648 |
$task['external_uids'] = $this->get_all_external_uids($task['dossier']); |
$task['external_uids'] = array_merge( |
1649 |
|
$this->get_all_external_uids($task['dossier'], array(), $category !== null ? $category : $task['category']), |
1650 |
|
$this->get_all_external_uids($task['object_id'], array(), $category !== null ? $category : $task['category']) |
1651 |
|
); |
1652 |
} |
} |
1653 |
$list_tasks[$task['task']] = $task; |
$list_tasks[$task['task']] = $task; |
1654 |
} |
} |
1655 |
printf(json_encode($list_tasks)); |
echo(json_encode($list_tasks)); |
1656 |
} |
} |
1657 |
|
|
1658 |
protected function get_dossier_data(string $dossier) { |
protected function get_dossier_data(string $dossier) { |
1661 |
"obj" => "dossier", |
"obj" => "dossier", |
1662 |
"idx" => $dossier, |
"idx" => $dossier, |
1663 |
)); |
)); |
1664 |
|
if (empty($inst_di->val) === true) { |
1665 |
|
return $val_di; |
1666 |
|
} |
1667 |
$val_di = $inst_di->get_json_data(); |
$val_di = $inst_di->get_json_data(); |
1668 |
if ($val_di['dossier_instruction_type_code'] === 'T') { |
if ($val_di['dossier_instruction_type_code'] === 'T') { |
1669 |
$val_di['date_decision_transfert'] = $val_di['date_decision']; |
$val_di['date_decision_transfert'] = $val_di['date_decision']; |
1754 |
if (isset($val_dt['tax_ext_pret']) === true |
if (isset($val_dt['tax_ext_pret']) === true |
1755 |
&& $val_dt['tax_ext_pret'] === 'f') { |
&& $val_dt['tax_ext_pret'] === 'f') { |
1756 |
// |
// |
1757 |
$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'] : ''; |
1758 |
$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'] : ''; |
1759 |
} |
} |
1760 |
if (isset($val_dt['tax_ext_pret']) === true |
if (isset($val_dt['tax_ext_pret']) === true |
1761 |
&& $val_dt['tax_ext_pret'] === 't') { |
&& $val_dt['tax_ext_pret'] === 't') { |
1764 |
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 |
1765 |
|| preg_match('/[lL].*[lL].*[tT].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
|| preg_match('/[lL].*[lL].*[tT].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
1766 |
// |
// |
1767 |
$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'] : ''; |
1768 |
$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'] : ''; |
1769 |
} |
} |
1770 |
// if (preg_match('/[pP].*[tT].*[zZ]/', $val_dt['tax_ext_desc']) === 1) { |
// if (preg_match('/[pP].*[tT].*[zZ]/', $val_dt['tax_ext_desc']) === 1) { |
1771 |
// $val_dt['tax_su_princ_surf4'] = $val_dt['tax_surf_tot_cstr']; |
// $val_dt['tax_su_princ_surf4'] = $val_dt['tax_surf_tot_cstr']; |
1809 |
', |
', |
1810 |
DB_PREFIXE |
DB_PREFIXE |
1811 |
); |
); |
1812 |
$res = $this->f->get_all_results_from_db_query($query, true); |
$res = $this->f->get_all_results_from_db_query( |
1813 |
|
$query, |
1814 |
|
array( |
1815 |
|
"origin" => __METHOD__, |
1816 |
|
"force_return" => true, |
1817 |
|
) |
1818 |
|
); |
1819 |
if ($res['code'] === 'KO') { |
if ($res['code'] === 'KO') { |
1820 |
return array(); |
return array(); |
1821 |
} |
} |
1826 |
return $result; |
return $result; |
1827 |
} |
} |
1828 |
|
|
1829 |
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
protected function get_external_uid($fk_idx, string $fk_idx_2, $fk_idx_3 = PLATAU, $order_asc_desc = 'DESC') { |
1830 |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
1831 |
"obj" => "lien_id_interne_uid_externe", |
"obj" => "lien_id_interne_uid_externe", |
1832 |
"fk_field" => 'object_id', |
"fk_field" => 'object_id', |
1833 |
"fk_idx" => $fk_idx, |
"fk_idx" => $fk_idx, |
1834 |
"fk_field_2" => 'object', |
"fk_field_2" => 'object', |
1835 |
"fk_idx_2" => $fk_idx_2, |
"fk_idx_2" => $fk_idx_2, |
1836 |
|
"fk_field_3" => 'category', |
1837 |
|
"fk_idx_3" => $fk_idx_3, |
1838 |
|
"order_field" => 'lien_id_interne_uid_externe', |
1839 |
|
"order_asc_desc" => $order_asc_desc, |
1840 |
)); |
)); |
1841 |
return $inst_external_uid->getVal('external_uid'); |
return $inst_external_uid->getVal('external_uid'); |
1842 |
} |
} |
1843 |
|
|
1844 |
protected function get_all_external_uids($fk_idx, $link_objects = array()) { |
protected function get_all_external_uids($fk_idx, $link_objects = array(), $category=PLATAU) { |
1845 |
if (count($link_objects) == 0) { |
if (count($link_objects) == 0) { |
1846 |
$link_objects = $this->get_list_distinct_objects_external_link(); |
$link_objects = $this->get_list_distinct_objects_external_link(); |
1847 |
} |
} |
1848 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1849 |
foreach ($link_objects as $link_object) { |
foreach ($link_objects as $link_object) { |
1850 |
$external_uid = $this->get_external_uid($fk_idx, $link_object); |
$external_uid = $this->get_external_uid($fk_idx, $link_object, $category); |
1851 |
if ($external_uid !== '' && $external_uid !== null) { |
if ($external_uid !== '' && $external_uid !== null) { |
1852 |
$val_external_uid[$link_object] = $external_uid; |
$val_external_uid[$link_object] = $external_uid; |
1853 |
} |
} |
1855 |
return $val_external_uid; |
return $val_external_uid; |
1856 |
} |
} |
1857 |
|
|
1858 |
protected function get_demandeurs_data(string $dossier) { |
protected function get_demandeurs_data($dossier) { |
1859 |
$val_demandeur = array(); |
$val_demandeur = array(); |
1860 |
|
if ($dossier === null) { |
1861 |
|
return $val_demandeur; |
1862 |
|
} |
1863 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
1864 |
"obj" => "dossier", |
"obj" => "dossier", |
1865 |
"idx" => $dossier, |
"idx" => $dossier, |
1890 |
return $val_architecte; |
return $val_architecte; |
1891 |
} |
} |
1892 |
|
|
1893 |
protected function get_instruction_data(string $dossier, $type = 'decision', $extra_params = array()) { |
protected function get_instruction_data($dossier, $type = 'decision', $extra_params = array()) { |
1894 |
$val_instruction = null; |
$val_instruction = null; |
1895 |
|
if ($dossier === null) { |
1896 |
|
return $val_instruction; |
1897 |
|
} |
1898 |
$instruction_with_doc = null; |
$instruction_with_doc = null; |
1899 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
1900 |
"obj" => "dossier", |
"obj" => "dossier", |
1915 |
"obj" => "instruction", |
"obj" => "instruction", |
1916 |
"idx" => $idx, |
"idx" => $idx, |
1917 |
)); |
)); |
1918 |
|
$id_instruction = $inst_instruction->getVal($inst_instruction->clePrimaire); |
1919 |
if (count($inst_instruction->val) > 0) { |
if (count($inst_instruction->val) > 0) { |
1920 |
$val_instruction = array(); |
$val_instruction = array(); |
1921 |
$instruction_data = $inst_instruction->get_json_data(); |
$instruction_data = $inst_instruction->get_json_data(); |
1923 |
if ($instruction_data['om_fichier_instruction'] !== null |
if ($instruction_data['om_fichier_instruction'] !== null |
1924 |
&& $instruction_data['om_fichier_instruction'] !== '') { |
&& $instruction_data['om_fichier_instruction'] !== '') { |
1925 |
// |
// |
1926 |
$instruction_with_doc = $inst_instruction->getVal($inst_instruction->clePrimaire); |
$instruction_with_doc = $id_instruction; |
1927 |
} |
} |
1928 |
$inst_ev = $this->f->get_inst__om_dbform(array( |
$inst_ev = $this->f->get_inst__om_dbform(array( |
1929 |
"obj" => "evenement", |
"obj" => "evenement", |
1949 |
} |
} |
1950 |
if ($instruction_with_doc !== null) { |
if ($instruction_with_doc !== null) { |
1951 |
// |
// |
1952 |
$val_instruction['path'] = sprintf('%s&snippet=%s&obj=%s&champ=%s&id=%s', 'app/index.php?module=form', 'file', 'instruction', 'om_fichier_instruction', $instruction_with_doc); |
$val_instruction['path'] = $this->compose_url_acces_document('instruction', 'om_fichier_instruction', $instruction_with_doc); |
1953 |
|
} |
1954 |
|
// Si il y a des annexes compatibles avec l'instruction elles sont ajoutées à la payload |
1955 |
|
if (! empty($annexes = $this->ajouter_annexes_a_la_payload($id_instruction, true))) { |
1956 |
|
$val_instruction['annexes'] = $annexes; |
1957 |
} |
} |
1958 |
} |
} |
1959 |
return $val_instruction; |
return $val_instruction; |
1960 |
} |
} |
1961 |
|
|
1962 |
|
|
1963 |
/** |
/** |
1964 |
* Récupère les informations |
* Récupère les informations pour les notifications ayant plusieurs annexe |
1965 |
*/ |
*/ |
1966 |
protected function get_instruction_notification_data($category, $type = '', $extra_params = array()) { |
protected function get_instruction_notification_data($category, $type = '', $extra_params = array()) { |
1967 |
$val_in = array(); |
$val_in = null; |
1968 |
|
|
1969 |
$idx = null; |
$idx = null; |
1970 |
if ($type === 'with-id') { |
if ($type === 'with-id') { |
1971 |
$idx = $extra_params['with-id']; |
$idx = $extra_params['with-id']; |
1972 |
} |
} |
1973 |
|
|
1974 |
|
// Récupération du type de notification. Le type est nécessaire pour récupérer |
1975 |
|
// le message et le titre de notification. |
1976 |
|
$typeNotification = $this->getVal('type'); |
1977 |
|
if (isset($this->valF['type'])) { |
1978 |
|
$typeNotification = $this->valF['type']; |
1979 |
|
} |
1980 |
|
|
1981 |
// récupére les données à intégrer à la payload |
// récupére les données à intégrer à la payload |
1982 |
$inst_in = $this->f->get_inst__om_dbform(array( |
$inst_in = $this->f->get_inst__om_dbform(array( |
1983 |
"obj" => "instruction_notification", |
"obj" => "instruction_notification", |
1984 |
"idx" => $idx, |
"idx" => $idx, |
1985 |
)); |
)); |
1986 |
$val_in = $inst_in->get_json_data(); |
if (count($inst_in->val) > 0) { |
1987 |
|
$val_in = $inst_in->get_json_data(); |
1988 |
|
|
1989 |
// Récupération du message et du titre |
$val_in['parametre_courriel_type_titre'] = ''; |
1990 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
$val_in['parametre_courriel_type_message'] = ''; |
1991 |
"obj" => "instruction", |
// Récupération du message et du titre |
1992 |
"idx" => $inst_in->getVal('instruction'), |
if ($category === 'mail') { |
1993 |
)); |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
1994 |
$collectivite_id = $inst_instruction->get_dossier_instruction_om_collectivite($inst_instruction->getVal('dossier')); |
"obj" => "instruction", |
1995 |
$phrase_type_notification = array(); |
"idx" => $inst_in->getVal('instruction'), |
1996 |
$phrase_type_notification = $this->f->get_notification_parametre_courriel_type($collectivite_id); |
)); |
1997 |
// |
$collectivite_id = $inst_instruction->get_dossier_instruction_om_collectivite($inst_instruction->getVal('dossier')); |
1998 |
$val_in['parametre_courriel_type_titre'] = $phrase_type_notification['parametre_courriel_type_titre']; |
$phrase_type_notification = $this->f->get_notification_parametre_courriel_type($collectivite_id, $typeNotification); |
1999 |
$val_in['parametre_courriel_type_message'] = $phrase_type_notification['parametre_courriel_type_message']; |
$val_in['parametre_courriel_type_titre'] = $phrase_type_notification['parametre_courriel_type_titre']; |
2000 |
|
$val_in['parametre_courriel_type_message'] = $phrase_type_notification['parametre_courriel_type_message']; |
2001 |
|
} |
2002 |
|
|
2003 |
|
if ($typeNotification == 'notification_signataire') { |
2004 |
|
$val_in['lien_page_signature'] = $inst_in->getLienPageSignature($inst_instruction); |
2005 |
|
} |
2006 |
|
else { |
2007 |
|
// Récupération des liens vers les documents et des id et type des annexes |
2008 |
|
$infoDocNotif = $inst_in->getInfosDocumentsNotif($inst_in->getVal($inst_in->clePrimaire), $category); |
2009 |
|
$cle = $category == PORTAL ? 'path' : 'lien_telechargement_document'; |
2010 |
|
$val_in[$cle] = $infoDocNotif['document']['path']; |
2011 |
|
$val_in['annexes'] = $infoDocNotif['annexes']; |
2012 |
|
} |
2013 |
|
} |
2014 |
return $val_in; |
return $val_in; |
2015 |
} |
} |
2016 |
|
|
2017 |
|
/** |
2018 |
|
* Récupère les informations concernant la lettre au pétitionnaire. |
2019 |
|
* |
2020 |
|
* @param string identifiant du dossier |
2021 |
|
* @param string type de tâche |
2022 |
|
* @param array paramètre supplémentaire permettant de récupérer les informations |
2023 |
|
* |
2024 |
|
* @return array information concernant la lettre au pétitionnaire |
2025 |
|
*/ |
2026 |
|
protected function get_lettre_petitionnaire_data($dossier, $type, $extra_params = array()) { |
2027 |
|
// Si la date limite de notification n'a pas été dépassé le type de lettre est 1 |
2028 |
|
// Si la date a été dépassé et qu'il s'agit d'une demande de pièce le type est 3 |
2029 |
|
// Si la date a été dépassé et qu'il s'agit d'une prolongation le type est 4 |
2030 |
|
// Le type de document dépend du type de pièce |
2031 |
|
$nomTypeLettre = ''; |
2032 |
|
$nomTypeDocument = ''; |
2033 |
|
if ($type === 'lettre_incompletude') { |
2034 |
|
$nomTypeLettre = '3'; |
2035 |
|
$nomTypeDocument = '4'; |
2036 |
|
} elseif ($type === 'lettre_majoration') { |
2037 |
|
$nomTypeLettre = '4'; |
2038 |
|
$nomTypeDocument = '6'; |
2039 |
|
} |
2040 |
|
|
2041 |
|
$inst_di = $this->f->get_inst__om_dbform(array( |
2042 |
|
"obj" => "dossier", |
2043 |
|
"idx" => $dossier, |
2044 |
|
)); |
2045 |
|
$date_limite_notification = DateTime::createFromFormat('Y-m-d', $inst_di->getVal('date_notification_delai')); |
2046 |
|
$aujourdhui = new DateTime(); |
2047 |
|
if (! $date_limite_notification instanceof DateTime) { |
2048 |
|
$nomTypeLettre = ''; |
2049 |
|
$nomTypeDocument = ''; |
2050 |
|
} elseif ($aujourdhui < $date_limite_notification) { |
2051 |
|
$nomTypeLettre = '1'; |
2052 |
|
$nomTypeDocument = '3'; |
2053 |
|
} |
2054 |
|
|
2055 |
|
return array( |
2056 |
|
'nomEtatLettre' => '3', |
2057 |
|
'nomModaliteNotifMetier' => '4', |
2058 |
|
'nomTypeLettre' => $nomTypeLettre, |
2059 |
|
'nomTypeDocument' => $nomTypeDocument |
2060 |
|
); |
2061 |
|
} |
2062 |
|
|
2063 |
protected function sort_instruction_data(array $values, array $res) { |
protected function sort_instruction_data(array $values, array $res) { |
2064 |
$fields = array( |
$fields = array( |
2065 |
|
"instruction", |
2066 |
"date_evenement", |
"date_evenement", |
2067 |
"date_envoi_signature", |
"date_envoi_signature", |
2068 |
"date_retour_signature", |
"date_retour_signature", |
2074 |
"om_fichier_instruction", |
"om_fichier_instruction", |
2075 |
"tacite", |
"tacite", |
2076 |
"lettretype", |
"lettretype", |
2077 |
"commentaire" |
"commentaire", |
2078 |
|
"complement_om_html", |
2079 |
); |
); |
2080 |
foreach ($values as $key => $value) { |
foreach ($values as $key => $value) { |
2081 |
if (in_array($key, $fields) === true) { |
if (in_array($key, $fields) === true) { |
2091 |
} |
} |
2092 |
} |
} |
2093 |
} |
} |
2094 |
|
|
2095 |
|
if (! empty($values['document_type_instruction'])){ |
2096 |
|
// Gestion du type de document : |
2097 |
|
$document_type = $this->f->get_inst__om_dbform(array( |
2098 |
|
"obj" => "document_type", |
2099 |
|
"idx" => $values['document_type_instruction'], |
2100 |
|
)); |
2101 |
|
if (count($document_type->val) > 0) { |
2102 |
|
$res['document_type'] = $document_type->getVal('code'); |
2103 |
|
} |
2104 |
|
} |
2105 |
return $res; |
return $res; |
2106 |
} |
} |
2107 |
|
|
2108 |
|
/** |
2109 |
|
* Permet de définir si l'instruction passée en paramètre est une instruction |
2110 |
|
* récépissé d'une demande et si la demande en question a générée un dossier d'instruction. |
2111 |
|
* |
2112 |
|
* @param integer $instruction Identifiant de l'instruction |
2113 |
|
* @return boolean |
2114 |
|
*/ |
2115 |
|
protected function is_demande_instruction_recepisse_without_dossier($instruction) { |
2116 |
|
if ($instruction === null) { |
2117 |
|
return false; |
2118 |
|
} |
2119 |
|
$qres = $this->f->get_one_result_from_db_query( |
2120 |
|
sprintf( |
2121 |
|
'SELECT |
2122 |
|
demande_type.dossier_instruction_type |
2123 |
|
FROM |
2124 |
|
%1$sdemande |
2125 |
|
INNER JOIN %1$sdemande_type |
2126 |
|
ON demande.demande_type = demande_type.demande_type |
2127 |
|
WHERE |
2128 |
|
demande.instruction_recepisse = %2$d', |
2129 |
|
DB_PREFIXE, |
2130 |
|
intval($instruction) |
2131 |
|
), |
2132 |
|
array( |
2133 |
|
"origin" => __METHOD__, |
2134 |
|
"force_return" => true, |
2135 |
|
) |
2136 |
|
); |
2137 |
|
if ($qres["code"] !== "OK") { |
2138 |
|
return null; |
2139 |
|
} |
2140 |
|
if ($qres["result"] === "") { |
2141 |
|
return true; |
2142 |
|
} |
2143 |
|
return false; |
2144 |
|
} |
2145 |
|
|
2146 |
protected function get_document_numerise_data(string $dn) { |
protected function get_document_numerise_data(string $dn) { |
2147 |
$val_dn = array(); |
$val_dn = array(); |
2148 |
$inst_dn = $this->f->get_inst__om_dbform(array( |
$qres = $this->f->get_all_results_from_db_query( |
2149 |
"obj" => "document_numerise", |
sprintf( |
2150 |
"idx" => $dn, |
'SELECT |
2151 |
)); |
document_numerise.document_numerise, |
2152 |
$val_dn = $inst_dn->get_json_data(); |
document_numerise.uid, |
2153 |
$val_dn['path'] = sprintf('%s&snippet=%s&obj=%s&champ=%s&id=%s', 'app/index.php?module=form', 'file', 'document_numerise', 'uid', $this->getVal('object_id')); |
document_numerise.dossier, |
2154 |
// Correspond à la nomenclature Plat'AU NATURE_PIECE |
document_numerise.nom_fichier, |
2155 |
$val_dn['nature'] = $val_dn['document_numerise_nature_libelle']; |
document_numerise.date_creation, |
2156 |
|
document_numerise.document_numerise_type, |
2157 |
|
document_numerise.uid_dossier_final, |
2158 |
|
document_numerise.document_numerise_nature, |
2159 |
|
document_numerise.uid_thumbnail, |
2160 |
|
document_numerise.description_type, |
2161 |
|
document_numerise.document_travail, |
2162 |
|
document_numerise_type.code AS document_numerise_type_code, |
2163 |
|
document_numerise_type.libelle AS document_numerise_type_libelle, |
2164 |
|
document_numerise_nature.code AS document_numerise_nature_code, |
2165 |
|
document_numerise_nature.libelle AS document_numerise_nature_libelle, |
2166 |
|
document_numerise_nature.libelle AS nature |
2167 |
|
FROM |
2168 |
|
%1$sdocument_numerise |
2169 |
|
LEFT JOIN %1$sdocument_numerise_type |
2170 |
|
ON document_numerise.document_numerise_type = document_numerise_type.document_numerise_type |
2171 |
|
LEFT JOIN %1$sdocument_numerise_nature |
2172 |
|
ON document_numerise.document_numerise_nature = document_numerise_nature.document_numerise_nature |
2173 |
|
WHERE |
2174 |
|
document_numerise.document_numerise = %2$d', |
2175 |
|
DB_PREFIXE, |
2176 |
|
intval($dn) |
2177 |
|
), |
2178 |
|
array( |
2179 |
|
"origin" => __METHOD__, |
2180 |
|
) |
2181 |
|
); |
2182 |
|
if ($qres["result"] !== null |
2183 |
|
&& $qres["result"] !== "" |
2184 |
|
&& count($qres["result"]) > 0) { |
2185 |
|
// |
2186 |
|
$val_dn = $qres["result"][0]; |
2187 |
|
} |
2188 |
|
$val_dn['path'] = $this->compose_url_acces_document('document_numerise', 'uid', $this->getVal('object_id')); |
2189 |
return $val_dn; |
return $val_dn; |
2190 |
} |
} |
2191 |
|
|
2215 |
)); |
)); |
2216 |
$ad = $inst_di->getVal('avis_decision'); |
$ad = $inst_di->getVal('avis_decision'); |
2217 |
$val_ad = array(); |
$val_ad = array(); |
2218 |
if ($ad !== null) { |
if ($ad !== null && trim($ad) !== '') { |
2219 |
$inst_ad = $this->f->get_inst__om_dbform(array( |
$inst_ad = $this->f->get_inst__om_dbform(array( |
2220 |
"obj" => "avis_decision", |
"obj" => "avis_decision", |
2221 |
"idx" => $ad, |
"idx" => $ad, |
2254 |
if (isset($val_consultation['fichier']) === true |
if (isset($val_consultation['fichier']) === true |
2255 |
&& $val_consultation['fichier'] !== '') { |
&& $val_consultation['fichier'] !== '') { |
2256 |
// |
// |
2257 |
$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')); |
$val_consultation['path_fichier'] = $this->compose_url_acces_document('consultation', 'fichier', $this->getVal('object_id')); |
2258 |
} |
} |
2259 |
if (isset($val_consultation['om_fichier_consultation']) === true |
if (isset($val_consultation['om_fichier_consultation']) === true |
2260 |
&& $val_consultation['om_fichier_consultation'] !== '') { |
&& $val_consultation['om_fichier_consultation'] !== '') { |
2261 |
// |
// |
2262 |
$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')); |
$val_consultation['path_om_fichier_consultation'] = $this->compose_url_acces_document('consultation', 'om_fichier_consultation', $this->getVal('object_id')); |
2263 |
} |
} |
2264 |
return $val_consultation; |
return $val_consultation; |
2265 |
} |
} |
2275 |
return $val_service; |
return $val_service; |
2276 |
} |
} |
2277 |
|
|
2278 |
protected function view_form_json($in_field = false) { |
/** |
2279 |
|
* Recupere le numéro du dossier ou le numéro du dossier parent s'il existe, |
2280 |
|
* @param string $dossier : le numéro du dossier |
2281 |
|
* |
2282 |
|
* @return string $dossier | $dossier_parent |
2283 |
|
*/ |
2284 |
|
protected function get_id_dossier_parent(string $dossier){ |
2285 |
|
$query = sprintf(' |
2286 |
|
SELECT |
2287 |
|
dossier.dossier_parent |
2288 |
|
FROM |
2289 |
|
%1$sdossier |
2290 |
|
WHERE |
2291 |
|
dossier.dossier = \'%2$s\' |
2292 |
|
ORDER BY |
2293 |
|
dossier.dossier', |
2294 |
|
DB_PREFIXE, |
2295 |
|
$dossier |
2296 |
|
); |
2297 |
|
|
2298 |
|
$res = $this->f->get_all_results_from_db_query( |
2299 |
|
$query, |
2300 |
|
array( |
2301 |
|
"origin" => __METHOD__, |
2302 |
|
// "force_return" => true, |
2303 |
|
) |
2304 |
|
); |
2305 |
|
if ($res['code'] === 'KO') { |
2306 |
|
return false; |
2307 |
|
} |
2308 |
|
if ( isset($res['result'][0]["dossier_parent"]) |
2309 |
|
&& ! empty($res['result'][0]["dossier_parent"] ) |
2310 |
|
) { |
2311 |
|
return $res['result'][0]["dossier_parent"]; |
2312 |
|
} |
2313 |
|
return $dossier; |
2314 |
|
|
2315 |
|
} |
2316 |
|
|
2317 |
|
/** |
2318 |
|
* Renvoie un tableau, contenant les informations nécessaire à l'ajout des annexes |
2319 |
|
* à une payload. |
2320 |
|
* |
2321 |
|
* Récupère la liste des annexes paramétrées dans la table parametrage_annexe |
2322 |
|
* pour l'instruction voulu. A partir de cette liste, construit un tableau avec |
2323 |
|
* une entrée par annexe. Chaque entrées contiens les informations suivantes : |
2324 |
|
* - path : url d'accès au fichier |
2325 |
|
* - document_type : code du document dans plat'au |
2326 |
|
* - document_id : uid du document |
2327 |
|
* |
2328 |
|
* @param int $instruction_id : identifiant de l'instruction dont ont doit récuperer les annexes |
2329 |
|
* @param bool $document_platau_uniquement : limite les annexes renvoyées a celles typées pour platau |
2330 |
|
* |
2331 |
|
* @return array $annexes |
2332 |
|
*/ |
2333 |
|
protected function ajouter_annexes_a_la_payload(int $instruction_id, bool $document_platau_uniquement = false) { |
2334 |
|
$annexes = array(); |
2335 |
|
$annexes_a_lier = $this->f->recuperer_documents_a_annexe($instruction_id, $document_platau_uniquement); |
2336 |
|
foreach ($annexes_a_lier as $annexe_info) { |
2337 |
|
$objet = $annexe_info['objet']; |
2338 |
|
$id_objet = $annexe_info['id']; |
2339 |
|
// Récupère l'objet identifié en tant qu'annexe. Si l'objet n'est pas |
2340 |
|
// récupéré on passe à l'itération suivante |
2341 |
|
if (empty($inst_objet = $this->f->findObjectById($objet, $id_objet, true))) { |
2342 |
|
$this->f->addToLog(__METHOD__."() : L'objet *$objet* d'identifiant *$id_objet* n'a pas pu être instancié, son document ne peut pas être ajouté aux annexes."); |
2343 |
|
continue; |
2344 |
|
} |
2345 |
|
|
2346 |
|
// Détermine le champ contenant l'uid et le type de document |
2347 |
|
switch ($objet) { |
2348 |
|
case 'document_numerise': |
2349 |
|
$champ_uid = 'uid'; |
2350 |
|
/* TODO : Gestion du document_type |
2351 |
|
$document_numerise_type = $this->f->get_inst__om_dbform(array( |
2352 |
|
"obj" => 'document_numerise_type', |
2353 |
|
"idx" => $inst_objet->getVal('document_numerise_type'), |
2354 |
|
)); |
2355 |
|
$document_numerise_type_categorie = $this->f->get_inst__om_dbform(array( |
2356 |
|
"obj" => 'document_numerise_type_categorie', |
2357 |
|
"idx" => $document_numerise_type->getVal('document_numerise_type_categorie'), |
2358 |
|
)); |
2359 |
|
$annexe['document_type'] = |
2360 |
|
*/ |
2361 |
|
$document_type = ''; |
2362 |
|
break; |
2363 |
|
case 'instruction': |
2364 |
|
$champ_uid = 'om_fichier_instruction'; |
2365 |
|
$inst_document_type = $this->f->findObjectById('document_type', $inst_objet->getVal('document_type_instruction')); |
2366 |
|
$document_type = $inst_document_type->getVal('code'); |
2367 |
|
break; |
2368 |
|
case 'consultation': |
2369 |
|
$champ_uid = 'fichier'; |
2370 |
|
// Gestion du document_type, Code platau de la consultation |
2371 |
|
$document_type = self::CODE_PLATAU_CONSULTATION; |
2372 |
|
break; |
2373 |
|
default : |
2374 |
|
// Si le type de document n'est pas géré on passe au document suivant. |
2375 |
|
// Ajoute une ligne dans les logs pour comprendre pourquoi le document n'apparaît pas. |
2376 |
|
$this->f->addToLog( |
2377 |
|
__METHOD__. |
2378 |
|
"() : L'ajout d'annexe lié aux *$objet* n'est pas implémenté. |
2379 |
|
Le document de *$objet* et d'identifiant *$id_objet* n'a pas été ajouté aux annexes.", |
2380 |
|
DEBUG_MODE |
2381 |
|
); |
2382 |
|
continue 2; |
2383 |
|
} |
2384 |
|
|
2385 |
|
$annexes[] = array( |
2386 |
|
'path' => $this->compose_url_acces_document($objet, $champ_uid, $id_objet), |
2387 |
|
'document_type' => $document_type, |
2388 |
|
'document_id' => $inst_objet->getVal($champ_uid) |
2389 |
|
); |
2390 |
|
} |
2391 |
|
return $annexes; |
2392 |
|
} |
2393 |
|
|
2394 |
|
/** |
2395 |
|
* Fonction de récupération des UID externes en fonction des besoins. |
2396 |
|
* - Factorisation du code |
2397 |
|
* |
2398 |
|
* @param array $val : Tableau des valeurs du flux. |
2399 |
|
* @param array $elements default array() : liste des élément à ajouter au tableau des UID_externes |
2400 |
|
* @param array $val_external_uid default array() : tableau des UIDs externes du flux |
2401 |
|
* |
2402 |
|
* @return array $val_external_uid |
2403 |
|
* |
2404 |
|
*/ |
2405 |
|
protected function val_external_uid(array $val, array $elements = array(), array $val_external_uid = array()) { |
2406 |
|
|
2407 |
|
if (in_array('dossier_autorisation', $elements)) { |
2408 |
|
if (empty($val['dossier_autorisation']['dossier_autorisation'])) { |
2409 |
|
$dossier_autorisation = $val['dossier']['dossier_autorisation']; |
2410 |
|
} else { |
2411 |
|
$dossier_autorisation = $val['dossier_autorisation']['dossier_autorisation']; |
2412 |
|
} |
2413 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($dossier_autorisation, 'dossier_autorisation'); |
2414 |
|
} |
2415 |
|
|
2416 |
|
if (in_array('dossier', $elements)) { |
2417 |
|
$val_external_uid['dossier'] = $this->get_external_uid( |
2418 |
|
$this->get_id_dossier_parent($val['dossier']['dossier']), |
2419 |
|
'dossier' |
2420 |
|
); |
2421 |
|
} |
2422 |
|
|
2423 |
|
if (in_array('piece', $elements)) { |
2424 |
|
$val_external_uid['piece'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'piece'); |
2425 |
|
} |
2426 |
|
if (in_array('dossier_consultation', $elements)) { |
2427 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid( |
2428 |
|
$this->get_id_dossier_parent($val['dossier']['dossier']), |
2429 |
|
'dossier_consultation' |
2430 |
|
); |
2431 |
|
} |
2432 |
|
if (in_array('prescription', $elements)) { |
2433 |
|
$val_external_uid['prescription'] = $this->get_external_uid($this->getVal('object_id'), 'prescription'); |
2434 |
|
} |
2435 |
|
if (in_array('avis_dossier_consultation', $elements)) { |
2436 |
|
$val_external_uid['avis_dossier_consultation'] = $this->get_external_uid( |
2437 |
|
$this->getVal('object_id'), 'avis_dossier_consultation'); |
2438 |
|
} |
2439 |
|
if (in_array('decision', $elements)) { |
2440 |
|
$val_external_uid['decision'] = $this->get_external_uid($this->getVal('object_id'), 'instruction'); |
2441 |
|
if ($val_external_uid['decision'] === '') { |
2442 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
2443 |
|
"obj" => "instruction", |
2444 |
|
"idx" => $this->getVal('object_id'), |
2445 |
|
)); |
2446 |
|
$val_external_uid['decision'] = $this->get_external_uid($inst_instruction->get_related_instructions_next('retour_signature'), 'instruction'); |
2447 |
|
} |
2448 |
|
} |
2449 |
|
if (in_array('instruction_notification', $elements)) { |
2450 |
|
$val_external_uid['instruction_notification'] = $this->get_external_uid($this->getVal('object_id'), 'instruction_notification', PORTAL); |
2451 |
|
} |
2452 |
|
return $val_external_uid; |
2453 |
|
} |
2454 |
|
|
2455 |
|
/** |
2456 |
|
* |
2457 |
|
* |
2458 |
|
*/ |
2459 |
|
protected function view_form_json(bool $in_field = false) { |
2460 |
// |
// |
2461 |
if ($this->f->get_submitted_post_value('valid') === null |
$check_state = isset($this->valF['state']) === true ? $this->valF['state'] : $this->getVal('state'); |
2462 |
&& $this->getVal('state') !== self::STATUS_CANCELED) { |
if ($check_state !== self::STATUS_CANCELED) { |
2463 |
|
|
2464 |
|
$data = array('in_field' => $in_field); |
2465 |
|
$this->f->module_manager->run_hooks('view_form_json_pre', $this, $data); |
2466 |
|
|
2467 |
// Liste des valeurs à afficher |
// Liste des valeurs à afficher |
2468 |
$val = array(); |
$val = array(); |
2469 |
|
|
2470 |
// |
// |
2471 |
$val_task = array_combine($this->champs, $this->val); |
$val_task = array_combine($this->champs, $this->val); |
2472 |
foreach ($val_task as $key => $value) { |
foreach ($val_task as $key => $value) { |
2473 |
$val_task[$key] = strip_tags($value); |
$val_task[$key] = strip_tags($value); |
2474 |
} |
} |
2475 |
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
|
2476 |
$val['task'] = $val_task; |
// Vérifie pour les tâches dont l'affichage de la payload est calculée si l'objet |
2477 |
// |
// de référence de la tâche existe. |
2478 |
if ($this->getVal('type') === 'creation_DA' |
$objectRefExist = true; |
2479 |
|| $this->getVal('type') === 'modification_DA') { |
if ($val_task['stream'] === 'output' |
2480 |
// |
&& (empty($val_task['json_payload']) || $val_task['json_payload'] === '{}')) { |
2481 |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
$objectRefExist = $this->does_referenced_object_exist( |
2482 |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
$val_task['object_id'], |
2483 |
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
$val_task['type'] |
2484 |
$val_external_uid = array(); |
); |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$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('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') === '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['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'avis_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['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
|
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
|
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
|
|
} |
|
|
$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['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// XXX WIP |
|
|
if ($this->getVal('type') === 'creation_consultation') { |
|
|
// |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val['consultation'] = $this->get_consultation_data($this->getVal('object_id')); |
|
|
$val['service'] = $this->get_service_data($val['consultation']['service']); |
|
|
$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; |
|
2485 |
} |
} |
2486 |
// |
|
2487 |
if ($this->getVal('type') === 'notification_instruction' |
// Si l'objet de référence n'existe pas log le numéro de la tâche concerné et |
2488 |
|| $this->getVal('type') === 'notification_recepisse' |
// renvoie une payload contenant le message d'erreur. |
2489 |
|| $this->getVal('type') === 'notification_decision') { |
// Sinon constitue la payload du json. |
2490 |
// |
if (! $objectRefExist) { |
2491 |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
$this->f->addToLog( |
2492 |
$val['demandeur'] = $this->get_demandeurs_data($this->getVal('dossier')); |
sprintf( |
2493 |
$val['instruction_notification'] = $this->get_instruction_notification_data($this->getVal('category'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
__('Impossible de récupérer la payload car l\'objet de réference n\'existe pas pour la tâche : %s'), |
2494 |
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $val['instruction_notification']['instruction'])); |
$val_task['task'] |
2495 |
$val_external_uid = array(); |
), |
2496 |
$val_external_uid['demande'] = $this->get_external_uid($val['dossier']['dossier'], 'demande'); |
DEBUG_MODE |
2497 |
$val['external_uids'] = $val_external_uid; |
); |
2498 |
|
$val = __('Impossible de recuperer la payload car l\'objet de reference n\'existe pas.'); |
2499 |
|
} else { |
2500 |
|
|
2501 |
|
// L'historique n'est pas nécessaire dans l'affichage en JSON |
2502 |
|
if ($in_field === true) { |
2503 |
|
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
2504 |
|
} else { |
2505 |
|
unset($val_task['timestamp_log']); |
2506 |
|
} |
2507 |
|
unset($val_task['timestamp_log_hidden']); |
2508 |
|
$val['task'] = $val_task; |
2509 |
|
// |
2510 |
|
if ($this->getVal('type') === 'creation_DA' |
2511 |
|
|| $this->getVal('type') === 'modification_DA') { |
2512 |
|
// |
2513 |
|
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
2514 |
|
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
2515 |
|
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
2516 |
|
// Recupération des UID externes |
2517 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation')); |
2518 |
|
} |
2519 |
|
// |
2520 |
|
if ($this->getVal('type') === 'creation_DI' |
2521 |
|
|| $this->getVal('type') === 'modification_DI' |
2522 |
|
|| $this->getVal('type') === 'depot_DI') { |
2523 |
|
// |
2524 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
2525 |
|
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction'); |
2526 |
|
$val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']); |
2527 |
|
$architecte = isset($val['donnees_techniques']['architecte']) === true ? $val['donnees_techniques']['architecte'] : null; |
2528 |
|
$val['architecte'] = $this->get_architecte_data($architecte); |
2529 |
|
$val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']); |
2530 |
|
// Recupération des UID externes |
2531 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier')); |
2532 |
|
} |
2533 |
|
// |
2534 |
|
if ($this->getVal('type') === 'qualification_DI') { |
2535 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2536 |
|
// Recupération des UID externes |
2537 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier')); |
2538 |
|
} |
2539 |
|
// |
2540 |
|
if ($this->getVal('type') === 'ajout_piece') { |
2541 |
|
$val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id')); |
2542 |
|
$val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']); |
2543 |
|
// Recupération des UID externes |
2544 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier', 'piece')); |
2545 |
|
} |
2546 |
|
// |
2547 |
|
if ($this->getVal('type') === 'modification_piece') { |
2548 |
|
$val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id')); |
2549 |
|
$val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']); |
2550 |
|
// Recupération des UID externes |
2551 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier', 'piece')); |
2552 |
|
} |
2553 |
|
// |
2554 |
|
if ($this->getVal('type') === 'suppression_piece') { |
2555 |
|
$val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id')); |
2556 |
|
$val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']); |
2557 |
|
// Recupération des UID externes |
2558 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier', 'piece')); |
2559 |
|
} |
2560 |
|
// |
2561 |
|
if ($this->getVal('type') === 'decision_DI') { |
2562 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2563 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
2564 |
|
$val['instruction']['final'] = 't'; |
2565 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
2566 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
2567 |
|
} |
2568 |
|
// Recupération des UID externes |
2569 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier')); |
2570 |
|
} |
2571 |
|
// |
2572 |
|
if ($this->getVal('type') === 'incompletude_DI') { |
2573 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2574 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
2575 |
|
// Recupération des UID externes |
2576 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier')); |
2577 |
|
} |
2578 |
|
// |
2579 |
|
if ($this->getVal('type') === 'completude_DI') { |
2580 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2581 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
2582 |
|
// Recupération des UID externes |
2583 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier')); |
2584 |
|
} |
2585 |
|
// |
2586 |
|
if ($this->getVal('type') === 'lettre_incompletude' |
2587 |
|
|| $this->getVal('type') === 'lettre_majoration') { |
2588 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2589 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
2590 |
|
$val['lettre_petitionnaire'] = $this->get_lettre_petitionnaire_data($val['dossier']['dossier'], $this->getVal('type')); |
2591 |
|
// Recupération des UID externes |
2592 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier')); |
2593 |
|
} |
2594 |
|
// |
2595 |
|
if ($this->getVal('type') === 'pec_metier_consultation') { |
2596 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2597 |
|
$val['instruction'] = $this->get_instruction_data( |
2598 |
|
$this->getVal('dossier'), |
2599 |
|
'with-id', |
2600 |
|
array('with-id' => $this->getVal('object_id')) |
2601 |
|
); |
2602 |
|
// Recupération des UID externes |
2603 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier', 'dossier_consultation')); |
2604 |
|
} |
2605 |
|
// |
2606 |
|
if ($this->getVal('type') === 'avis_consultation') { |
2607 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2608 |
|
$val['instruction'] = $this->get_instruction_data( |
2609 |
|
$this->getVal('dossier'), |
2610 |
|
'with-id', |
2611 |
|
array('with-id' => $this->getVal('object_id')) |
2612 |
|
); |
2613 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
2614 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
2615 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
2616 |
|
} |
2617 |
|
// Recupération des UID externes |
2618 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier', 'dossier_consultation', 'avis_dossier_consultation')); |
2619 |
|
} |
2620 |
|
// |
2621 |
|
if ($this->getVal('type') === 'creation_consultation') { |
2622 |
|
// |
2623 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2624 |
|
$val['consultation'] = $this->get_consultation_data($this->getVal('object_id')); |
2625 |
|
$val['service'] = $this->get_service_data($val['consultation']['service']); |
2626 |
|
// Recupération des UID externes |
2627 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier')); |
2628 |
|
} |
2629 |
|
// |
2630 |
|
if ($this->getVal('type') === 'envoi_CL') { |
2631 |
|
// |
2632 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2633 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2634 |
|
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($val['dossier']['dossier_autorisation']); |
2635 |
|
// Recupération des UID externes |
2636 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier', 'decision')); |
2637 |
|
} |
2638 |
|
if ($this->getVal('type') === 'notification_instruction' |
2639 |
|
|| $this->getVal('type') === 'notification_recepisse' |
2640 |
|
|| $this->getVal('type') === 'notification_decision' |
2641 |
|
|| $this->getVal('type') === 'notification_service_consulte' |
2642 |
|
|| $this->getVal('type') === 'notification_tiers_consulte' |
2643 |
|
|| $this->getVal('type') === 'notification_signataire') { |
2644 |
|
// |
2645 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2646 |
|
$dossier_id = isset($val['dossier']['dossier']) === true ? $val['dossier']['dossier'] : null; |
2647 |
|
$val['demandeur'] = $this->get_demandeurs_data($dossier_id); |
2648 |
|
$val['instruction_notification'] = $this->get_instruction_notification_data($this->getVal('category'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2649 |
|
$instruction_id = isset($val['instruction_notification']['instruction']) === true ? $val['instruction_notification']['instruction'] : null; |
2650 |
|
$val['instruction'] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $instruction_id)); |
2651 |
|
// Précise qu'il s'agit d'une instruction final si l'instruction est liée à une |
2652 |
|
// demande dont le type ne génère pas de dossier |
2653 |
|
if ($this->is_demande_instruction_recepisse_without_dossier($instruction_id) === true) { |
2654 |
|
$val['instruction']['final'] = 't'; |
2655 |
|
} |
2656 |
|
// Recupération des UID externes |
2657 |
|
$val_external_uid = array(); |
2658 |
|
// Affiche l'identifiant externe lié à l'instruction si cette combinaison existe, sinon celui lié au dossier |
2659 |
|
$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'); |
2660 |
|
$val_external_uid['demande (instruction)'] = $this->get_external_uid($instruction_id, 'demande', PORTAL, 'ASC'); |
2661 |
|
$val['external_uids'] = $this->val_external_uid($val, array('demande', 'demande (instruction)', 'instruction_notification'), $val_external_uid ); |
2662 |
|
} |
2663 |
|
// |
2664 |
|
if ($this->getVal('type') === 'prescription') { |
2665 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2666 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2667 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
2668 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
2669 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
2670 |
|
} |
2671 |
|
// Recupération des UID externes |
2672 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier', 'dossier_consultation', 'prescription')); |
2673 |
|
} |
2674 |
|
// |
2675 |
|
if ($this->getVal('type') === 'ajout_documents_specifiques') { |
2676 |
|
// Data blocs |
2677 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2678 |
|
$val['instruction'] = $this->get_instruction_data( |
2679 |
|
$this->getVal('dossier'), |
2680 |
|
'with-id', |
2681 |
|
array('with-id' => $this->getVal('object_id')) |
2682 |
|
); |
2683 |
|
// Recupération des UID externes |
2684 |
|
$val['external_uids'] = $this->val_external_uid($val, array('dossier_autorisation', 'dossier', 'dossier_consultation')); |
2685 |
|
} |
2686 |
} |
} |
2687 |
|
|
2688 |
|
$data = array('in_field' => $in_field, 'val' => &$val); |
2689 |
|
$this->f->module_manager->run_hooks('view_form_json_post', $this, $data); |
2690 |
|
|
2691 |
if ($in_field === true) { |
if ($in_field === true) { |
2692 |
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
2693 |
} else { |
} else { |
2694 |
// Liste des valeurs affichée en JSON |
// Liste des valeurs affichée en JSON |
2695 |
printf(json_encode($val, JSON_UNESCAPED_SLASHES)); |
echo(json_encode($val, JSON_UNESCAPED_SLASHES)); |
2696 |
} |
} |
2697 |
} |
} |
2698 |
} |
} |
2707 |
'state' => $this->f->get_submitted_post_value('state') |
'state' => $this->f->get_submitted_post_value('state') |
2708 |
), |
), |
2709 |
); |
); |
2710 |
|
if ($this->f->get_submitted_post_value('comment') !== null) { |
2711 |
|
$params['comment'] = $this->f->get_submitted_post_value('comment'); |
2712 |
|
} |
2713 |
$update = $this->update_task($params); |
$update = $this->update_task($params); |
2714 |
$message_class = "valid"; |
$message_class = "valid"; |
2715 |
$message = $this->msg; |
$message = $this->msg; |
2726 |
} |
} |
2727 |
|
|
2728 |
// Sauvegarde de l'uid externe retourné |
// Sauvegarde de l'uid externe retourné |
2729 |
if ($this->f->get_submitted_post_value('external_uid') !== null) { |
$external_uid = $this->f->get_submitted_post_value('external_uid'); |
2730 |
|
if ($external_uid !== null) { |
2731 |
// |
// |
2732 |
$objects = $this->get_objects_by_task_type($this->getVal('type'), $this->getVal('stream')); |
$objects = $this->get_objects_by_task_type($this->getVal('type'), $this->getVal('stream')); |
2733 |
|
// Si l'identifiant externe contient le préfixe pour identifier les codes de suivi, |
2734 |
|
// le seul objet concerné sera celui du code de suivi |
2735 |
|
if (strpos($external_uid, self::CS_PREFIX) !== false) { |
2736 |
|
$objects = array('code-suivi', ); |
2737 |
|
$external_uid = str_replace(self::CS_PREFIX, '', $external_uid); |
2738 |
|
} |
2739 |
foreach ($objects as $object) { |
foreach ($objects as $object) { |
2740 |
$inst_lien = $this->f->get_inst__om_dbform(array( |
$inst_lien = $this->f->get_inst__om_dbform(array( |
2741 |
"obj" => "lien_id_interne_uid_externe", |
"obj" => "lien_id_interne_uid_externe", |
2742 |
"idx" => ']', |
"idx" => ']', |
2743 |
)); |
)); |
2744 |
if ($inst_lien->is_exists($object, $this->getVal('object_id'), $this->f->get_submitted_post_value('external_uid'), $this->getVal('dossier')) === false) { |
$object_id = $this->getVal('object_id'); |
2745 |
|
$is_exists = $inst_lien->is_exists($object, $object_id, $external_uid, $this->getVal('dossier')); |
2746 |
|
// Dans le cas spécifique de la mise à jour d'une notification |
2747 |
|
// et de la création d'une liaison d'identifiant pour l'objet demande, |
2748 |
|
// l'identifiant de l'objet n'est plus celui de la notification |
2749 |
|
// d'instruction mais celui du dossier d'instruction |
2750 |
|
if ($object === 'demande' |
2751 |
|
&& ($this->getVal('type') === 'notification_recepisse' |
2752 |
|
|| $this->getVal('type') === 'notification_instruction' |
2753 |
|
|| $this->getVal('type') === 'notification_decision' |
2754 |
|
|| $this->getVal('type') === 'notification_service_consulte' |
2755 |
|
|| $this->getVal('type') === 'notification_tiers_consulte' |
2756 |
|
|| $this->getVal('type') === 'notification_signataire')) { |
2757 |
|
// |
2758 |
|
$object_id = $this->getVal('dossier'); |
2759 |
|
// Il ne doit y avoir qu'une liaison entre le numéro du dossier interne et un uid externe de "demande" |
2760 |
|
$is_exists = $inst_lien->is_exists($object, $object_id, null, $this->getVal('dossier')); |
2761 |
|
} |
2762 |
|
if ($is_exists === false) { |
2763 |
$valF = array( |
$valF = array( |
2764 |
'lien_id_interne_uid_externe' => '', |
'lien_id_interne_uid_externe' => '', |
2765 |
'object' => $object, |
'object' => $object, |
2766 |
'object_id' => $this->getVal('object_id'), |
'object_id' => $object_id, |
2767 |
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
'external_uid' => $external_uid, |
2768 |
'dossier' => $this->getVal('dossier'), |
'dossier' => $this->getVal('dossier'), |
2769 |
'category' => $this->getVal('category'), |
'category' => $this->getVal('category'), |
2770 |
); |
); |
2791 |
$result = $this->add_task(array( |
$result = $this->add_task(array( |
2792 |
'val' => array( |
'val' => array( |
2793 |
'stream' => 'input', |
'stream' => 'input', |
2794 |
'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), |
2795 |
'type' => $this->f->get_submitted_post_value('type'), |
'type' => $this->f->get_submitted_post_value('type'), |
2796 |
'category' => $this->f->get_submitted_post_value('category'), |
'category' => $this->f->get_submitted_post_value('category'), |
2797 |
) |
) |
2815 |
} |
} |
2816 |
|
|
2817 |
function setLayout(&$form, $maj) { |
function setLayout(&$form, $maj) { |
2818 |
|
// |
2819 |
// Récupération du mode de l'action |
$form->setBloc('json_payload', 'D', '', 'col_6'); |
2820 |
$crud = $this->get_action_crud($maj); |
$fieldset_title_payload = __("json_payload (calculée)"); |
2821 |
|
if ($this->getVal('json_payload') !== "{}") { |
2822 |
// MODE different de CREER |
$fieldset_title_payload = __("json_payload"); |
2823 |
if ($maj != 0 || $crud != 'create') { |
} |
2824 |
$form->setBloc('json_payload', 'D', '', 'col_6'); |
$form->setFieldset('json_payload', 'DF', $fieldset_title_payload, "collapsible, startClosed"); |
2825 |
$form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed"); |
$form->setBloc('json_payload', 'F'); |
2826 |
$form->setBloc('json_payload', 'F'); |
$form->setBloc('timestamp_log', 'DF', __("historique"), 'col_9 timestamp_log_jsontotab'); |
|
} |
|
|
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
|
2827 |
} |
} |
2828 |
|
|
2829 |
/** |
/** |
2830 |
* [get_objects_by_task_type description] |
* Récupère le nom de l'objet à mentionner dans la table lien_id_interne_uid_externe |
2831 |
* @param [type] $type [description] |
* en fonction du type et du stream de la tâche. |
2832 |
* @return [type] [description] |
* |
2833 |
|
* @param string $type Type de la tâche |
2834 |
|
* @param string $stream Stream de la tâche |
2835 |
|
* |
2836 |
|
* @return array |
2837 |
*/ |
*/ |
2838 |
function get_objects_by_task_type($type, $stream = 'all') { |
function get_objects_by_task_type($type, $stream = 'all') { |
2839 |
$objects = array(); |
$objects = array(); |
2850 |
&& $stream === 'input') { |
&& $stream === 'input') { |
2851 |
$objects = array('dossier', 'dossier_autorisation', 'demande', ); |
$objects = array('dossier', 'dossier_autorisation', 'demande', ); |
2852 |
} |
} |
2853 |
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
if (in_array($type, array( |
2854 |
|
'decision_DI', |
2855 |
|
'incompletude_DI', |
2856 |
|
'completude_DI', |
2857 |
|
'lettre_incompletude', |
2858 |
|
'lettre_majoration' |
2859 |
|
)) === true) { |
2860 |
$objects = array('instruction', ); |
$objects = array('instruction', ); |
2861 |
} |
} |
2862 |
|
if (in_array($type, array('envoi_CL', )) === true) { |
2863 |
|
$objects = array('instruction_action_cl', ); |
2864 |
|
} |
2865 |
if (in_array($type, array('pec_metier_consultation', )) === true |
if (in_array($type, array('pec_metier_consultation', )) === true |
2866 |
&& $stream === 'output') { |
&& $stream === 'output') { |
2867 |
$objects = array('pec_dossier_consultation', ); |
$objects = array('pec_dossier_consultation', ); |
2870 |
&& $stream === 'output') { |
&& $stream === 'output') { |
2871 |
$objects = array('avis_dossier_consultation', ); |
$objects = array('avis_dossier_consultation', ); |
2872 |
} |
} |
2873 |
if (in_array($type, array('ajout_piece', 'add_piece', )) === true) { |
if (in_array($type, array('prescription', )) === true |
2874 |
|
&& $stream === 'output') { |
2875 |
|
$objects = array('prescription', ); |
2876 |
|
} |
2877 |
|
if (in_array($type, array('ajout_piece', 'add_piece', 'modification_piece', 'suppression_piece', )) === true) { |
2878 |
$objects = array('piece', ); |
$objects = array('piece', ); |
2879 |
} |
} |
2880 |
if (in_array($type, array('creation_consultation', )) === true) { |
if (in_array($type, array('creation_consultation', )) === true) { |
2881 |
$objects = array('consultation', ); |
$objects = array('consultation', ); |
2882 |
} |
} |
2883 |
|
if (in_array($type, array('ajout_documents_specifiques', )) === true |
2884 |
|
&& $stream === 'output') { |
2885 |
|
$objects = array('dossier', 'instruction', 'instruction_notification',); |
2886 |
|
} |
2887 |
if (in_array($type, array('pec_metier_consultation', )) === true |
if (in_array($type, array('pec_metier_consultation', )) === true |
2888 |
&& $stream === 'input') { |
&& $stream === 'input') { |
2889 |
$objects = array('pec_metier_consultation', ); |
$objects = array('pec_metier_consultation', ); |
2896 |
&& $stream === 'input') { |
&& $stream === 'input') { |
2897 |
$objects = array('dossier_message', ); |
$objects = array('dossier_message', ); |
2898 |
} |
} |
2899 |
if (in_array($type, array('notification_recepisse', 'notification_instruction', 'notification_decision' )) === true) { |
if (in_array( |
2900 |
$objects = array('instruction_notification', ); |
$type, |
2901 |
|
array( |
2902 |
|
'notification_recepisse', |
2903 |
|
'notification_instruction', |
2904 |
|
'notification_decision', |
2905 |
|
'notification_service_consulte', |
2906 |
|
'notification_tiers_consulte', |
2907 |
|
'notification_signataire', |
2908 |
|
) |
2909 |
|
) === true) { |
2910 |
|
$objects = array('instruction_notification', 'demande', ); |
2911 |
} |
} |
2912 |
return $objects; |
return $objects; |
2913 |
} |
} |
2914 |
|
|
2915 |
|
/** |
2916 |
|
* Récupère les tables auxquelles pourrait être rattaché l'objet lié à la tâche, |
2917 |
|
* par rapport à son type. |
2918 |
|
* |
2919 |
|
* @param string $type Type de la tâche |
2920 |
|
* @param string $stream input ou output |
2921 |
|
* @return array |
2922 |
|
*/ |
2923 |
|
function get_tables_by_task_type($type, $stream = 'all') { |
2924 |
|
$tables = array(); |
2925 |
|
if (in_array($type, array('creation_DA', 'modification_DA', )) === true) { |
2926 |
|
$tables = array('dossier_autorisation', ); |
2927 |
|
} |
2928 |
|
if (in_array($type, array('creation_DI', 'depot_DI', 'modification_DI',)) === true) { |
2929 |
|
$tables = array('dossier', ); |
2930 |
|
} |
2931 |
|
if (in_array($type, array('qualification_DI', )) === true) { |
2932 |
|
$tables = array('instruction', 'dossier', ); |
2933 |
|
} |
2934 |
|
if (in_array($type, array('create_DI_for_consultation', )) === true) { |
2935 |
|
$tables = array('dossier', ); |
2936 |
|
} |
2937 |
|
if (in_array($type, array('create_DI', )) === true |
2938 |
|
&& $stream === 'input') { |
2939 |
|
$tables = array('dossier', 'dossier_autorisation', 'demande', ); |
2940 |
|
} |
2941 |
|
if (in_array($type, array( |
2942 |
|
'decision_DI', |
2943 |
|
'incompletude_DI', |
2944 |
|
'completude_DI', |
2945 |
|
'lettre_incompletude', |
2946 |
|
'lettre_majoration' |
2947 |
|
)) === true) { |
2948 |
|
$tables = array('instruction', ); |
2949 |
|
} |
2950 |
|
if (in_array($type, array('ajout_documents_specifiques', )) === true |
2951 |
|
&& in_array($stream, array('output', 'all', )) === true ) { |
2952 |
|
$tables = array('instruction', 'dossier', ); |
2953 |
|
} |
2954 |
|
if (in_array($type, array('envoi_CL', )) === true) { |
2955 |
|
$tables = array('instruction', ); |
2956 |
|
} |
2957 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
2958 |
|
&& $stream === 'output') { |
2959 |
|
$tables = array('dossier', 'instruction', 'instruction_notification', ); |
2960 |
|
} |
2961 |
|
if (in_array($type, array('avis_consultation', )) === true |
2962 |
|
&& $stream === 'output') { |
2963 |
|
$tables = array('instruction', ); |
2964 |
|
} |
2965 |
|
if (in_array($type, array('prescription', )) === true |
2966 |
|
&& $stream === 'output') { |
2967 |
|
$tables = array('instruction', ); |
2968 |
|
} |
2969 |
|
if (in_array($type, array('ajout_piece', 'add_piece', 'modification_piece', 'suppression_piece', )) === true) { |
2970 |
|
$tables = array('document_numerise', ); |
2971 |
|
} |
2972 |
|
if (in_array($type, array('creation_consultation', )) === true) { |
2973 |
|
$tables = array('consultation', ); |
2974 |
|
} |
2975 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
2976 |
|
&& $stream === 'input') { |
2977 |
|
$tables = array('consultation', ); |
2978 |
|
} |
2979 |
|
if (in_array($type, array('avis_consultation', )) === true |
2980 |
|
&& $stream === 'input') { |
2981 |
|
$tables = array('consultation', ); |
2982 |
|
} |
2983 |
|
if (in_array($type, array('create_message', )) === true |
2984 |
|
&& $stream === 'input') { |
2985 |
|
$tables = array('dossier_message', ); |
2986 |
|
} |
2987 |
|
if (in_array( |
2988 |
|
$type, |
2989 |
|
array( |
2990 |
|
'notification_recepisse', |
2991 |
|
'notification_instruction', |
2992 |
|
'notification_decision', |
2993 |
|
'notification_service_consulte', |
2994 |
|
'notification_tiers_consulte', |
2995 |
|
'notification_signataire' |
2996 |
|
) |
2997 |
|
) === true) { |
2998 |
|
$tables = array('instruction_notification', ); |
2999 |
|
} |
3000 |
|
return $tables; |
3001 |
|
} |
3002 |
|
|
3003 |
|
/** |
3004 |
|
* Vérifie si l'objet référencé par la tâche existe en base de données. |
3005 |
|
* |
3006 |
|
* Récupère la liste des tables de référence associé à la tâche à partir |
3007 |
|
* du type de tâche et de son flux (input ou output). |
3008 |
|
* Pour chaque table potentiellement référencé par la tâche on essaye d'instancier |
3009 |
|
* l'objet correspondant à partir de l'identifiant de l'objet de référence de la tâche. |
3010 |
|
* Si l'élément instancié existe renvoie true sinon renvoie false. |
3011 |
|
* |
3012 |
|
* @param string|integer $taskObjectId : identifiant de l'objet de référence de la tâche |
3013 |
|
* @param string $taskType : type de la tâche |
3014 |
|
* @param string $taskStream : flux entrant (output - valeur par défaut) ou sortant (input) |
3015 |
|
* @return boolean |
3016 |
|
*/ |
3017 |
|
protected function does_referenced_object_exist($taskObjectId, string $taskType, string $taskStream = 'output') { |
3018 |
|
$refTables = $this->get_tables_by_task_type($taskType, $taskStream); |
3019 |
|
if (empty($refTables) === true) { |
3020 |
|
$this->f->addToLog( |
3021 |
|
sprintf( |
3022 |
|
__("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."), |
3023 |
|
$taskType, |
3024 |
|
"get_tables_by_task_type()" |
3025 |
|
), |
3026 |
|
DEBUG_MODE |
3027 |
|
); |
3028 |
|
return true; |
3029 |
|
} |
3030 |
|
foreach ($refTables as $table) { |
3031 |
|
$inst = $this->f->get_inst__om_dbform(array( |
3032 |
|
'obj' => $table, |
3033 |
|
'idx' => $taskObjectId |
3034 |
|
)); |
3035 |
|
if ($inst->exists() === true) { |
3036 |
|
return true; |
3037 |
|
} |
3038 |
|
} |
3039 |
|
return false; |
3040 |
|
} |
3041 |
|
|
3042 |
} |
} |