32 |
'creation_consultation', |
'creation_consultation', |
33 |
'modification_DA', |
'modification_DA', |
34 |
'create_DI', |
'create_DI', |
35 |
|
'envoi_CL', |
36 |
'notification_recepisse', |
'notification_recepisse', |
37 |
'notification_instruction', |
'notification_instruction', |
38 |
'notification_decision', |
'notification_decision', |
39 |
|
'notification_service_consulte', |
40 |
|
'notification_tiers_consulte', |
41 |
|
'notification_depot_demat', |
42 |
|
'notification_commune' |
43 |
); |
); |
44 |
|
|
45 |
/** |
/** |
53 |
'notification_recepisse', |
'notification_recepisse', |
54 |
'notification_instruction', |
'notification_instruction', |
55 |
'notification_decision', |
'notification_decision', |
56 |
|
'notification_service_consulte', |
57 |
|
'notification_tiers_consulte', |
58 |
|
'notification_depot_demat', |
59 |
'prescription', |
'prescription', |
60 |
); |
); |
61 |
|
|
62 |
/** |
/** |
63 |
* Catégorie de la tâche |
* Catégorie de la tâche |
64 |
*/ |
*/ |
65 |
var $category = 'platau'; |
var $category = PLATAU; |
66 |
|
|
67 |
/** |
/** |
68 |
* Définition des actions disponibles sur la classe. |
* Définition des actions disponibles sur la classe. |
160 |
// |
// |
161 |
$this->valF['category'] = $this->category; |
$this->valF['category'] = $this->category; |
162 |
} |
} |
163 |
|
|
164 |
|
// Si last_modification_time est vide, la valeur est remplacée par NULL |
165 |
|
// pour eviter d'avoir une erreur de base de données car le champ est au format time. |
166 |
|
if ($val['last_modification_time'] == "") { |
167 |
|
$this->valF['last_modification_time'] = NULL; |
168 |
|
} else { |
169 |
|
$this->valF['last_modification_time'] = $val['last_modification_time']; |
170 |
|
} |
171 |
|
|
172 |
|
// Si creation_time est vide, la valeur est remplacée par NULL |
173 |
|
// pour eviter d'avoir une erreur de base de données car le champ est au format time. |
174 |
|
if ($val['creation_time'] == "") { |
175 |
|
$this->valF['creation_time'] = NULL; |
176 |
|
} else { |
177 |
|
$this->valF['creation_time'] = $val['creation_time']; |
178 |
|
} |
179 |
} |
} |
180 |
|
|
181 |
/** |
/** |
190 |
"object_id", |
"object_id", |
191 |
"dossier", |
"dossier", |
192 |
"stream", |
"stream", |
193 |
|
"creation_date", |
194 |
|
"creation_time", |
195 |
|
"CONCAT_WS(' ', to_char(task.creation_date, 'DD/MM/YYYY'), task.creation_time) AS date_creation", |
196 |
|
'last_modification_date', |
197 |
|
'last_modification_time', |
198 |
|
"CONCAT_WS(' ', to_char(task.last_modification_date, 'DD/MM/YYYY'), task.last_modification_time) AS date_modification", |
199 |
|
"comment", |
200 |
"json_payload", |
"json_payload", |
201 |
"timestamp_log", |
"timestamp_log", |
202 |
|
"timestamp_log AS timestamp_log_hidden", |
203 |
"category", |
"category", |
204 |
); |
); |
205 |
} |
} |
212 |
|
|
213 |
// ALL |
// ALL |
214 |
$form->setType("category", "hidden"); |
$form->setType("category", "hidden"); |
215 |
|
$form->setType("timestamp_log_hidden", "hidden"); |
216 |
|
|
217 |
// MODE CREER |
// MODE CREER |
218 |
if ($maj == 0 || $crud == 'create') { |
if ($maj == 0 || $crud == 'create') { |
219 |
|
$form->setType("type", "select"); |
220 |
$form->setType("state", "select"); |
$form->setType("state", "select"); |
221 |
$form->setType("stream", "select"); |
$form->setType("stream", "select"); |
222 |
$form->setType("json_payload", "textarea"); |
$form->setType("json_payload", "textarea"); |
223 |
} |
} |
224 |
// MDOE MODIFIER |
// MODE MODIFIER |
225 |
if ($maj == 1 || $crud == 'update') { |
if ($maj == 1 || $crud == 'update') { |
226 |
|
$form->setType("task", "hiddenstatic"); |
227 |
$form->setType("state", "select"); |
$form->setType("state", "select"); |
228 |
$form->setType("stream", "select"); |
$form->setType("stream", "hiddenstatic"); |
229 |
$form->setType("json_payload", "jsonprettyprint"); |
$form->setType("json_payload", "jsonprettyprint"); |
230 |
|
$form->setType("timestamp_log", "jsontotab"); |
231 |
|
$form->setType("type", "hiddenstatic"); |
232 |
|
$form->setType("creation_date", "hidden"); |
233 |
|
$form->setType("creation_time", "hidden"); |
234 |
|
$form->setType("object_id", "hiddenstatic"); |
235 |
|
$form->setType("dossier", "hiddenstatic"); |
236 |
|
$form->setType("date_creation", "hiddenstatic"); |
237 |
|
$form->setType("last_modification_date", "hidden"); |
238 |
|
$form->setType("last_modification_time", "hidden"); |
239 |
|
$form->setType("date_modification", "static"); |
240 |
} |
} |
241 |
// MODE CONSULTER |
// MODE CONSULTER |
242 |
if ($maj == 3 || $crud == 'read') { |
if ($maj == 3 || $crud == 'read') { |
243 |
|
$form->setType("state", "selecthiddenstatic"); |
244 |
|
$form->setType("stream", "selecthiddenstatic"); |
245 |
$form->setType('dossier', 'link'); |
$form->setType('dossier', 'link'); |
246 |
$form->setType('json_payload', 'jsonprettyprint'); |
$form->setType('json_payload', 'jsonprettyprint'); |
247 |
|
$form->setType("type", "selecthiddenstatic"); |
248 |
|
$form->setType("creation_date", "hidden"); |
249 |
|
$form->setType("creation_time", "hidden"); |
250 |
|
$form->setType("date_creation", "static"); |
251 |
|
$form->setType("last_modification_date", "hidden"); |
252 |
|
$form->setType("last_modification_time", "hidden"); |
253 |
|
$form->setType("date_modification", "static"); |
254 |
|
$form->setType("timestamp_log", "jsontotab"); |
255 |
} |
} |
|
|
|
256 |
} |
} |
257 |
|
|
258 |
|
function stateTranslation ($currentState) { |
259 |
|
switch ($currentState){ |
260 |
|
case "draft": |
261 |
|
return __('brouillon'); |
262 |
|
break; |
263 |
|
case "new": |
264 |
|
return __('à traiter'); |
265 |
|
break; |
266 |
|
case "pending": |
267 |
|
return __('en cours'); |
268 |
|
break; |
269 |
|
case "done": |
270 |
|
return __('terminé'); |
271 |
|
break; |
272 |
|
case "archived": |
273 |
|
return __('archivé'); |
274 |
|
break; |
275 |
|
case "error": |
276 |
|
return __('erreur'); |
277 |
|
break; |
278 |
|
case "debug": |
279 |
|
return __('debug'); |
280 |
|
break; |
281 |
|
case "canceled": |
282 |
|
return __('annulé'); |
283 |
|
break; |
284 |
|
} |
285 |
|
} |
286 |
/** |
/** |
287 |
* |
* |
288 |
*/ |
*/ |
289 |
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
290 |
if($maj < 2) { |
if($maj <= 3) { |
|
|
|
291 |
$contenu = array(); |
$contenu = array(); |
292 |
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG', 'ARCHIVED', 'CANCELED') as $key) { |
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG', 'ARCHIVED', 'CANCELED') as $key) { |
293 |
$const_name = 'STATUS_'.$key; |
$const_name = 'STATUS_'.$key; |
294 |
$const_value = constant("self::$const_name"); |
$const_value = constant("self::$const_name"); |
295 |
$contenu[0][] = $const_value; |
$contenu[0][] = $const_value; |
296 |
$contenu[1][] = __($const_value); |
|
297 |
|
|
298 |
|
$contenu[1][] = $this->stateTranslation($const_value); |
299 |
|
|
300 |
} |
} |
301 |
|
|
302 |
$form->setSelect("state", $contenu); |
$form->setSelect("state", $contenu); |
303 |
|
|
304 |
$contenu_stream =array(); |
$contenu_stream =array(); |
305 |
$contenu_stream[0][0]="input"; |
$contenu_stream[0][0]="input"; |
306 |
$contenu_stream[1][0]=_('input'); |
$contenu_stream[1][0]=__('input'); |
307 |
$contenu_stream[0][1]="output"; |
$contenu_stream[0][1]="output"; |
308 |
$contenu_stream[1][1]=_('output'); |
$contenu_stream[1][1]=__('output'); |
309 |
$form->setSelect("stream", $contenu_stream); |
$form->setSelect("stream", $contenu_stream); |
310 |
|
|
311 |
|
$tab_type = array_unique(array_merge(self::TASK_TYPE_SI, self::TASK_TYPE_SC)); |
312 |
|
|
313 |
|
foreach ($tab_type as $type) { |
314 |
|
|
315 |
|
$contenu_type[0][] = $type; |
316 |
|
|
317 |
|
switch ($type) { |
318 |
|
case "creation_DA": |
319 |
|
$value_type = __('Création DA'); |
320 |
|
break; |
321 |
|
case "create_DI": |
322 |
|
$value_type = __('Création demande'); |
323 |
|
break; |
324 |
|
case "creation_DI": |
325 |
|
$value_type = __('Création DI'); |
326 |
|
break; |
327 |
|
case "modification_DA": |
328 |
|
$value_type = __('Modification DA'); |
329 |
|
break; |
330 |
|
case "modification_DI": |
331 |
|
$value_type = __('Modification DI'); |
332 |
|
break; |
333 |
|
case "ajout_piece": |
334 |
|
$value_type = __('Ajout pièce (sortant)'); |
335 |
|
break; |
336 |
|
case "add_piece": |
337 |
|
$value_type = __('Ajout pièce (entrant)'); |
338 |
|
break; |
339 |
|
case "depot_DI": |
340 |
|
$value_type = __('Dépôt DI'); |
341 |
|
break; |
342 |
|
case "qualification_DI": |
343 |
|
$value_type = __('Qualification DI'); |
344 |
|
break; |
345 |
|
case "creation_consultation": |
346 |
|
$value_type = __('Création consultation'); |
347 |
|
break; |
348 |
|
case "decision_DI": |
349 |
|
$value_type = __('Décision DI'); |
350 |
|
break; |
351 |
|
case "envoi_CL": |
352 |
|
$value_type = __('Envoi contrôle de légalité'); |
353 |
|
break; |
354 |
|
case "pec_metier_consultation": |
355 |
|
$value_type = __('PeC consultation'); |
356 |
|
break; |
357 |
|
case "avis_consultation": |
358 |
|
$value_type = __('Avis'); |
359 |
|
break; |
360 |
|
case "prescription": |
361 |
|
$value_type = __('Prescription'); |
362 |
|
break; |
363 |
|
case "create_DI_for_consultation": |
364 |
|
$value_type = __('Création DI pour consultation'); |
365 |
|
break; |
366 |
|
case "create_message": |
367 |
|
$value_type = __('Message'); |
368 |
|
break; |
369 |
|
case "notification_recepisse": |
370 |
|
$value_type = __('Notification récépissé'); |
371 |
|
break; |
372 |
|
case "notification_instruction": |
373 |
|
$value_type = __('Notification instruction'); |
374 |
|
break; |
375 |
|
case "notification_decision": |
376 |
|
$value_type = __('Notification décision'); |
377 |
|
break; |
378 |
|
case "notification_service_consulte": |
379 |
|
$value_type = __('Notification service consulté'); |
380 |
|
break; |
381 |
|
case "notification_tiers_consulte": |
382 |
|
$value_type = __('Notification tiers consulté'); |
383 |
|
break; |
384 |
|
case "completude_DI": |
385 |
|
$value_type = __('complétude DI'); |
386 |
|
break; |
387 |
|
case "incompletude_DI": |
388 |
|
$value_type = __('incomplétude DI'); |
389 |
|
break; |
390 |
|
} |
391 |
|
|
392 |
|
$contenu_type[1][] = $value_type; |
393 |
|
} |
394 |
|
|
395 |
|
$form->setselect('type', $contenu_type); |
396 |
} |
} |
397 |
|
|
398 |
if ($maj == 3) { |
if ($maj == 3) { |
399 |
if ($this->getVal('stream') == 'output') { |
// Récupération du numéro du dossier si il n'est pas renseigné dans la tâche |
400 |
$inst_dossier = $this->f->get_inst__om_dbform(array( |
if ($form->val['dossier'] == '' || $form->val['dossier'] == null) { |
401 |
"obj" => "dossier", |
// Récupération de la payload de la taĉhe. |
402 |
"idx" => $form->val['dossier'], |
// Si la tâche est une tâche input la payload est associée à la tâche. |
403 |
)); |
// Si la tâche est une tâche en output la payload est "calculé" à l'ouverture |
404 |
|
// du formulaire. |
405 |
|
if ($this->getVal('stream') == 'input') { |
406 |
|
$json_payload = json_decode($this->getVal('json_payload'), true); |
407 |
|
} else { |
408 |
|
$json_payload = json_decode($form->val['json_payload'], true); |
409 |
|
} |
410 |
|
// A partir de la payload de la tâche ont récupère les externals uid |
411 |
|
// Si un external uid de DI (dossier) existe ont le récupère et on stocke le numéro |
412 |
|
// pour l'afficher sur le formulaire. |
413 |
|
// Si l'external UID du DI n'existe pas on récupère celui du DA |
414 |
|
$external_uid = ''; |
415 |
|
if (array_key_exists('external_uids', $json_payload) |
416 |
|
&& array_key_exists('dossier', $json_payload['external_uids']) |
417 |
|
) { |
418 |
|
$external_uid = $json_payload['external_uids']['dossier']; |
419 |
|
} elseif (array_key_exists('external_uids', $json_payload) |
420 |
|
&& array_key_exists('dossier', $json_payload['external_uids'])) { |
421 |
|
$external_uid = $json_payload['external_uids']['dossier']; |
422 |
|
} |
423 |
|
// Recherche l'external uid dans la base de données pour récupèrer le numéro de |
424 |
|
// DI / DA correspondant. On stocke le numéro de dossier dans la propriété val |
425 |
|
// du formulaire pour pouvoir l'afficher |
426 |
|
if ($external_uid != '') { |
427 |
|
$qres = $this->f->get_one_result_from_db_query( |
428 |
|
sprintf( |
429 |
|
'SELECT |
430 |
|
lien_id_interne_uid_externe.dossier |
431 |
|
FROM |
432 |
|
%1$slien_id_interne_uid_externe |
433 |
|
WHERE |
434 |
|
lien_id_interne_uid_externe.external_uid = \'%2$s\'', |
435 |
|
DB_PREFIXE, |
436 |
|
$this->f->db->escapeSimple($external_uid) |
437 |
|
), |
438 |
|
array( |
439 |
|
"origin" => __METHOD__, |
440 |
|
) |
441 |
|
); |
442 |
|
if (! empty($qres["result"])) { |
443 |
|
$form->val['dossier'] = $qres["result"]; |
444 |
|
} |
445 |
|
} |
446 |
|
} |
447 |
|
|
448 |
if($form->val['type'] == "creation_DA" |
// Vérifie si le numéro de dossier associé à la tâche existe dans la base. |
449 |
|| $form->val['type'] == "modification_DA"){ |
// Si c'est le cas ce numéro sera lié au dossier (DI ou DA) correspondant |
450 |
// |
// TODO : vérifier la liste des tâches lié à des DA |
451 |
|
$obj_link = ''; |
452 |
|
if ($form->val['type'] == "creation_DA" || $form->val['type'] == "modification_DA") { |
453 |
|
// Vérification que le numéro de DA affiché dans le formulaire existe |
454 |
|
$qres = $this->f->get_one_result_from_db_query( |
455 |
|
sprintf( |
456 |
|
'SELECT |
457 |
|
dossier_autorisation.dossier_autorisation |
458 |
|
FROM |
459 |
|
%1$sdossier_autorisation |
460 |
|
WHERE |
461 |
|
dossier_autorisation.dossier_autorisation = \'%2$s\'', |
462 |
|
DB_PREFIXE, |
463 |
|
$this->f->db->escapeSimple($form->val['dossier']) |
464 |
|
), |
465 |
|
array( |
466 |
|
"origin" => __METHOD__, |
467 |
|
) |
468 |
|
); |
469 |
|
// Si on a un résultat c'est que le dossier existe, il faut afficher le lien |
470 |
|
if (! empty($qres["result"])) { |
471 |
$obj_link = 'dossier_autorisation'; |
$obj_link = 'dossier_autorisation'; |
472 |
} else { |
} |
473 |
|
} else { |
474 |
|
// Vérification que le numéro de DI affiché dans le formulaire existe |
475 |
|
$qres = $this->f->get_one_result_from_db_query( |
476 |
|
sprintf( |
477 |
|
'SELECT |
478 |
|
dossier.dossier |
479 |
|
FROM |
480 |
|
%1$sdossier |
481 |
|
WHERE |
482 |
|
dossier.dossier = \'%2$s\'', |
483 |
|
DB_PREFIXE, |
484 |
|
$this->f->db->escapeSimple($form->val['dossier']) |
485 |
|
), |
486 |
|
array( |
487 |
|
"origin" => __METHOD__, |
488 |
|
) |
489 |
|
); |
490 |
|
// Si on a un résultat c'est que le dossier existe, il faut afficher le lien |
491 |
|
if (! empty($qres["result"])) { |
492 |
$obj_link = 'dossier_instruction'; |
$obj_link = 'dossier_instruction'; |
493 |
} |
} |
|
|
|
|
$params = array(); |
|
|
$params['obj'] = $obj_link; |
|
|
$params['libelle'] = $inst_dossier->getVal('dossier'); |
|
|
$params['title'] = "Consulter le dossier"; |
|
|
$params['idx'] = $form->val['dossier']; |
|
|
$form->setSelect("dossier", $params); |
|
494 |
} |
} |
495 |
|
// Pour afficher le lien vers un dossier ont utilise un champ de type "link". |
496 |
|
// Pour paramétrer ce champs on a besoin de savoir : |
497 |
|
// - quel objet est visé par le lien |
498 |
|
// - le label (libellé) du lien |
499 |
|
// - l'identifiant de l'objet qui sera utilisé dans le lien |
500 |
|
// - le titre associé au lien |
501 |
|
// Pour cela on remplit le champs comme un select et les valeurs du select |
502 |
|
// contiennent les informations nécessaire à l'affichage du champs. |
503 |
|
$params = array( |
504 |
|
'obj' => $obj_link, |
505 |
|
'libelle' => $form->val['dossier'], |
506 |
|
'title' => "Consulter le dossier", |
507 |
|
'idx' => $form->val['dossier'] |
508 |
|
); |
509 |
|
$form->setSelect("dossier", $params); |
510 |
} |
} |
511 |
} |
} |
512 |
|
|
518 |
function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) { |
function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) { |
519 |
// parent::setVal($form, $maj, $validation); |
// parent::setVal($form, $maj, $validation); |
520 |
// |
// |
521 |
if ($this->getVal('stream') == "output") { |
if ($this->getVal('stream') == "output" |
522 |
|
&& $this->getVal('state') !== self::STATUS_DONE) { |
523 |
|
// |
524 |
$form->setVal('json_payload', $this->view_form_json(true)); |
$form->setVal('json_payload', $this->view_form_json(true)); |
525 |
} else { |
} else { |
526 |
$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)); |
527 |
} |
} |
528 |
} |
} |
529 |
|
|
533 |
// Récupération du mode de l'action |
// Récupération du mode de l'action |
534 |
$crud = $this->get_action_crud($maj); |
$crud = $this->get_action_crud($maj); |
535 |
|
|
536 |
|
$form->setLib('date_creation', __("Date de création")); |
537 |
|
$form->setLib('date_modification', __("Date de dernière modification")); |
538 |
|
$form->setLib('comment', __("commentaire")); |
539 |
|
|
540 |
// MODE different de CREER |
// MODE different de CREER |
541 |
if ($maj != 0 || $crud != 'create') { |
if ($maj != 0 || $crud != 'create') { |
542 |
$form->setLib('json_payload', ''); |
$form->setLib('json_payload', ''); |
543 |
|
$form->setLib("task", __("identifiant")); |
544 |
|
$form->setLib("Task_portal", __("task_portal")); |
545 |
|
$form->setLib("type", __("type")); |
546 |
|
$form->setLib("object_id", __("Réf. interne")); |
547 |
|
$form->setLib("stream", __("flux")); |
548 |
|
$form->setLib("timestamp_log", __("Historique")); |
549 |
} |
} |
550 |
} |
} |
551 |
|
|
605 |
$this->valF['stream'] == 'input')) { |
$this->valF['stream'] == 'input')) { |
606 |
|
|
607 |
// décode la payload JSON |
// décode la payload JSON |
608 |
|
// TODO : COMMENTER |
609 |
$json_payload = json_decode($this->valF['json_payload'], true); |
$json_payload = json_decode($this->valF['json_payload'], true); |
610 |
|
|
611 |
// défini une liste de chemin de clés requises |
// défini une liste de chemin de clés requises |
612 |
$paths = array(); |
$paths = array(); |
613 |
if ($this->valF['category'] === 'platau') { |
if ($this->valF['category'] === PLATAU) { |
614 |
$paths = array( |
$paths = array( |
615 |
'external_uids/dossier' |
'external_uids/dossier' |
616 |
); |
); |
688 |
* @return [type] [description] |
* @return [type] [description] |
689 |
*/ |
*/ |
690 |
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) { |
691 |
$query = sprintf(' |
$qres = $this->f->get_one_result_from_db_query( |
692 |
SELECT task |
sprintf( |
693 |
FROM %1$stask |
'SELECT |
694 |
WHERE %2$s |
task |
695 |
type = \'%3$s\' |
FROM |
696 |
AND (object_id = \'%4$s\' |
%1$stask |
697 |
%5$s) |
WHERE |
698 |
AND state != \'%6$s\' |
%2$s |
699 |
', |
type = \'%3$s\' |
700 |
DB_PREFIXE, |
AND ( |
701 |
$is_not_done == true ? 'state != \''.self::STATUS_DONE.'\' AND' : '', |
object_id = \'%4$s\' |
702 |
$type, |
%5$s |
703 |
$object_id, |
) |
704 |
$dossier !== null ? sprintf('OR dossier = \'%s\'', $dossier) : '', |
AND state != \'%6$s\'', |
705 |
self::STATUS_CANCELED |
DB_PREFIXE, |
706 |
|
$is_not_done == true ? 'state != \''.self::STATUS_DONE.'\' AND' : '', |
707 |
|
$type, |
708 |
|
$object_id, |
709 |
|
$dossier !== null ? sprintf('OR dossier = \'%s\'', $dossier) : '', |
710 |
|
self::STATUS_CANCELED |
711 |
|
), |
712 |
|
array( |
713 |
|
"origin" => __METHOD__, |
714 |
|
) |
715 |
); |
); |
716 |
$res = $this->f->get_one_result_from_db_query($query); |
if ($qres["result"] !== null && $qres["result"] !== "") { |
717 |
if ($res['result'] !== null && $res['result'] !== '') { |
return $qres["result"]; |
|
return $res['result']; |
|
718 |
} |
} |
719 |
return false; |
return false; |
720 |
} |
} |
727 |
*/ |
*/ |
728 |
public function task_exists_multi_search(array $search_values) { |
public function task_exists_multi_search(array $search_values) { |
729 |
$query = sprintf(' |
$query = sprintf(' |
730 |
SELECT task |
SELECT * |
731 |
FROM %1$stask |
FROM %1$stask |
732 |
%2$s |
%2$s |
733 |
%3$s |
%3$s |
736 |
empty($search_values) === false ? ' WHERE ' : '', |
empty($search_values) === false ? ' WHERE ' : '', |
737 |
implode(' AND ', $search_values) |
implode(' AND ', $search_values) |
738 |
); |
); |
739 |
$res = $this->f->get_all_results_from_db_query($query); |
$res = $this->f->get_all_results_from_db_query( |
740 |
|
$query, |
741 |
|
array( |
742 |
|
"origin" => __METHOD__, |
743 |
|
) |
744 |
|
); |
745 |
if (count($res['result']) > 0) { |
if (count($res['result']) > 0) { |
746 |
return $res['result']; |
return $res['result']; |
747 |
} |
} |
776 |
|
|
777 |
// gestion d'une tache de type notification et de category mail |
// gestion d'une tache de type notification et de category mail |
778 |
if (isset($val['type']) |
if (isset($val['type']) |
779 |
&& (//$val['type'] === 'notification_recepisse' |
&& (($val['type'] === 'notification_instruction' || $val['type'] === 'notification_decision') |
780 |
$val['type'] === 'notification_instruction' |
&& isset($val['category']) |
781 |
|| $val['type'] === 'notification_decision') |
&& $val['category'] === 'mail') |
782 |
&& isset($val['category']) |
|| $val['type'] === 'notification_service_consulte' |
783 |
&& $val['category'] === 'mail') { |
|| $val['type'] === 'notification_tiers_consulte' |
784 |
|
|| $val['type'] === 'notification_depot_demat' |
785 |
|
|| $val['type'] === 'notification_commune' |
786 |
|
) { |
787 |
// Récupère la payload de la tache |
// Récupère la payload de la tache |
788 |
$data = array(); |
$data = array(); |
789 |
$data['instruction_notification'] = $this->get_instruction_notification_data( |
$data['instruction_notification'] = $this->get_instruction_notification_data( |
799 |
"idx" => $val['object_id'], |
"idx" => $val['object_id'], |
800 |
)); |
)); |
801 |
// Envoi le mail et met à jour le suivi |
// Envoi le mail et met à jour le suivi |
802 |
$envoiMail = $inst_notif->send_mail_notification_demandeur($data); |
$envoiMail = $inst_notif->send_mail_notification($data, $val['type']); |
803 |
// Passage de la tache à done si elle a réussi et à error |
// Passage de la tache à done si elle a réussi et à error |
804 |
// si l'envoi a échoué |
// si l'envoi a échoué |
805 |
$this->valF['state'] = 'done'; |
$this->valF['state'] = 'done'; |
810 |
} |
} |
811 |
|
|
812 |
/** |
/** |
813 |
|
* TRIGGER - triggermodifier. |
814 |
|
* |
815 |
|
* @param string $id |
816 |
|
* @param null &$dnu1 @deprecated Ne pas utiliser. |
817 |
|
* @param array $val Tableau des valeurs brutes. |
818 |
|
* @param null $dnu2 @deprecated Ne pas utiliser. |
819 |
|
* |
820 |
|
* @return boolean |
821 |
|
*/ |
822 |
|
function triggermodifier($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
823 |
|
parent::triggermodifier($id, $dnu1, $val, $dnu2); |
824 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
825 |
|
|
826 |
|
// Mise à jour des valeurs, notamment du timestamp_log en fonction de plusieurs critères |
827 |
|
$values = array( |
828 |
|
'state' => $this->valF['state'], |
829 |
|
'object_id' => $this->valF['object_id'], |
830 |
|
'comment' => $this->valF['comment'], |
831 |
|
); |
832 |
|
$new_values = $this->set_values_for_update($values); |
833 |
|
if ($new_values === false) { |
834 |
|
$this->addToLog(__METHOD__."(): erreur timestamp log", DEBUG_MODE); |
835 |
|
return false; |
836 |
|
} |
837 |
|
|
838 |
|
// Mise à jour des valeurs |
839 |
|
$this->valF['timestamp_log'] = $new_values['timestamp_log']; |
840 |
|
$this->valF['state'] = $new_values['state']; |
841 |
|
$this->valF['object_id'] = $new_values['object_id']; |
842 |
|
$this->valF['last_modification_date'] = date('Y-m-d'); |
843 |
|
$this->valF['last_modification_time'] = date('H:i:s'); |
844 |
|
if ($val['stream'] === 'output') { |
845 |
|
$this->valF['json_payload'] = "{}"; |
846 |
|
if ($this->getVal("state") !== self::STATUS_DONE |
847 |
|
&& $this->valF['state'] === self::STATUS_DONE) { |
848 |
|
// |
849 |
|
$this->valF['json_payload'] = $this->view_form_json(true); |
850 |
|
} |
851 |
|
} |
852 |
|
|
853 |
|
return true; |
854 |
|
} |
855 |
|
|
856 |
|
|
857 |
|
/** |
858 |
|
* Applique nouvelle valeur après traitement. |
859 |
|
* |
860 |
|
* @param array $params Tableau des valeurs en entrées |
861 |
|
* @return array Tableau des valeurs en sorties |
862 |
|
*/ |
863 |
|
public function set_values_for_update($params = array()) { |
864 |
|
|
865 |
|
// Récupération du timestamp_log existant |
866 |
|
$timestamp_log = $this->get_timestamp_log(); |
867 |
|
if ($timestamp_log === false) { |
868 |
|
return false; |
869 |
|
} |
870 |
|
|
871 |
|
// Vérification des object_id précédent en cas de tentative d'appliquer |
872 |
|
// l'état CANCELED sur la tâche |
873 |
|
if (isset($params['state']) === true |
874 |
|
&& $params['state'] === self::STATUS_CANCELED) { |
875 |
|
// Récupération du journal d'activité de la tâche sous forme de tableau |
876 |
|
// trié par ordre décroissant |
877 |
|
$log = $timestamp_log; |
878 |
|
krsort($log); |
879 |
|
// Pour chaque entrée dans le journal d'activité de la tâche : |
880 |
|
// - vérification de la présence de l'object_id précédent |
881 |
|
// - vérification que l'object_id précédent existe toujours dans la base de données |
882 |
|
// - l'object_id est mise à jour avec la valeur de l'object_id précédent |
883 |
|
// - le state n'est pas modifié |
884 |
|
// - sortie du traitement dès que le premier object_id précédent existant est trouvé |
885 |
|
// - si aucun object_id précédent existant n'est trouvé alors ni le state, ni l'object_id n'est modifiés |
886 |
|
foreach ($log as $key => $value) { |
887 |
|
// |
888 |
|
if (isset($value['prev_object_id']) === true |
889 |
|
&& $this->getVal('object_id') !== $value['prev_object_id']) { |
890 |
|
// Récupère la liste des tables potentielles pour un type de tâche |
891 |
|
$tables = $this->get_tables_by_task_type($this->getVal('type'), $this->getVal('stream')); |
892 |
|
foreach ($tables as $table) { |
893 |
|
// Vérifie s'il y a un ou aucun résultat |
894 |
|
$qres = $this->f->get_one_result_from_db_query( |
895 |
|
sprintf( |
896 |
|
'SELECT |
897 |
|
COUNT(%2$s) |
898 |
|
FROM |
899 |
|
%1$s%2$s |
900 |
|
WHERE |
901 |
|
%2$s::CHARACTER VARYING = \'%3$s\'', |
902 |
|
DB_PREFIXE, |
903 |
|
$table, |
904 |
|
$value['prev_object_id'] |
905 |
|
), |
906 |
|
array( |
907 |
|
"origin" => __METHOD__, |
908 |
|
"force_return" => true, |
909 |
|
) |
910 |
|
); |
911 |
|
if ($qres["code"] !== "OK") { |
912 |
|
return $this->end_treatment(__METHOD__, false); |
913 |
|
} |
914 |
|
// Affectation des valeurs et sortie de la boucle |
915 |
|
if ($qres["result"] == '1') { |
916 |
|
$params['object_id'] = $value['prev_object_id']; |
917 |
|
$params['state'] = $this->getVal('state'); |
918 |
|
break; |
919 |
|
} |
920 |
|
} |
921 |
|
// Sortie de la boucle si les valeurs sont affectées |
922 |
|
if ($params['object_id'] !== null |
923 |
|
&& $params['object_id'] === $value['prev_object_id']) { |
924 |
|
// |
925 |
|
break; |
926 |
|
} |
927 |
|
} |
928 |
|
} |
929 |
|
} |
930 |
|
|
931 |
|
// Mise à jour du journal d'activité de la tâche |
932 |
|
array_push($timestamp_log, array( |
933 |
|
'modification_date' => date('Y-m-d H:i:s'), |
934 |
|
'object_id' => $params['object_id'] !== null ? $params['object_id'] : $this->getVal('object_id'), |
935 |
|
'prev_object_id' => $this->getVal('object_id'), |
936 |
|
'state' => $params['state'], |
937 |
|
'prev_state' => $this->getVal('state'), |
938 |
|
'comment' => isset($params['comment']) ? $params['comment'] : $this->getVal('comment'), |
939 |
|
)); |
940 |
|
// |
941 |
|
$timestamp_log = json_encode($timestamp_log); |
942 |
|
|
943 |
|
|
944 |
|
// Les nouvelles valeurs après vérification des critères |
945 |
|
$result = array( |
946 |
|
'timestamp_log' => $timestamp_log, |
947 |
|
'object_id' => $params['object_id'], |
948 |
|
'state' => $params['state'], |
949 |
|
'comment' => $params['comment'], |
950 |
|
); |
951 |
|
return $result; |
952 |
|
} |
953 |
|
|
954 |
|
|
955 |
|
/** |
956 |
* TRIGGER - triggermodifierapres. |
* TRIGGER - triggermodifierapres. |
957 |
* |
* |
958 |
* @param string $id |
* @param string $id |
966 |
parent::triggermodifierapres($id, $dnu1, $val, $dnu2); |
parent::triggermodifierapres($id, $dnu1, $val, $dnu2); |
967 |
|
|
968 |
// Suivi des notificiations |
// Suivi des notificiations |
969 |
|
// En cas de changement de l'état de la tâche de notification, alors |
970 |
|
// le suivi des dates de la notification et de l'instruction, est effectué |
971 |
if (isset($val['category']) === true |
if (isset($val['category']) === true |
972 |
&& $val['category'] === 'portal' |
&& $val['category'] === PORTAL |
973 |
&& isset($val['type']) === true |
&& isset($val['type']) === true |
974 |
&& ($val['type'] === 'notification_recepisse' |
&& ($val['type'] === 'notification_recepisse' |
975 |
|| $val['type'] === 'notification_instruction' |
|| $val['type'] === 'notification_instruction' |
976 |
|| $val['type'] === 'notification_decision')) { |
|| $val['type'] === 'notification_decision' |
977 |
|
|| $val['type'] === 'notification_service_consulte' |
978 |
|
|| $val['type'] === 'notification_tiers_consulte')) { |
979 |
// |
// |
980 |
if (isset($this->valF['state']) === true |
if (isset($this->valF['state']) === true |
981 |
&& $this->valF['state'] !== $this->getVal('state')) { |
&& $this->valF['state'] !== $this->getVal('state') |
982 |
|
&& $this->valF['state'] !== self::STATUS_CANCELED) { |
983 |
// |
// |
984 |
$inst_in = $this->f->get_inst__om_dbform(array( |
$inst_in = $this->f->get_inst__om_dbform(array( |
985 |
"obj" => "instruction_notification", |
"obj" => "instruction_notification", |
989 |
foreach ($inst_in->champs as $champ) { |
foreach ($inst_in->champs as $champ) { |
990 |
$valF_in[$champ] = $inst_in->getVal($champ); |
$valF_in[$champ] = $inst_in->getVal($champ); |
991 |
} |
} |
992 |
|
// Par défaut la date d'envoi et la date de premier accès sur |
993 |
|
// la notification ne sont pas renseignées |
994 |
$valF_in['date_envoi'] = null; |
$valF_in['date_envoi'] = null; |
995 |
$valF_in['date_premier_acces'] = null; |
$valF_in['date_premier_acces'] = null; |
996 |
// |
// Lorsque la tâche est correctement traitée |
997 |
if ($this->valF['state'] === self::STATUS_DONE) { |
if ($this->valF['state'] === self::STATUS_DONE) { |
998 |
// |
// |
999 |
$valF_in['statut'] = __("envoyé"); |
$valF_in['statut'] = __("envoyé"); |
1000 |
$valF_in['commentaire'] = __("Notification traitée"); |
$valF_in['commentaire'] = __("Notification traitée"); |
1001 |
$valF_in['date_envoi'] = date('d/m/Y H:i:s'); |
$valF_in['date_envoi'] = date('d/m/Y H:i:s'); |
1002 |
// |
// Si l'instruction possède un document lié, alors ses dates |
1003 |
|
// de suivi sont mises à jour |
1004 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
1005 |
"obj" => "instruction", |
"obj" => "instruction", |
1006 |
"idx" => $inst_in->getVal('instruction'), |
"idx" => $inst_in->getVal('instruction'), |
1012 |
} |
} |
1013 |
$valF_instruction['date_envoi_rar'] = date('d/m/Y'); |
$valF_instruction['date_envoi_rar'] = date('d/m/Y'); |
1014 |
$valF_instruction['date_retour_rar'] = date('d/m/Y', strtotime('now + 1 day')); |
$valF_instruction['date_retour_rar'] = date('d/m/Y', strtotime('now + 1 day')); |
1015 |
$inst_instruction->setParameter('maj', 1); |
// Action spécifique pour identifier que la modification |
1016 |
|
// est une nootification de demandeur |
1017 |
|
$inst_instruction->setParameter('maj', 175); |
1018 |
$update_instruction = $inst_instruction->modifier($valF_instruction); |
$update_instruction = $inst_instruction->modifier($valF_instruction); |
1019 |
if ($update_instruction === false) { |
if ($update_instruction === false) { |
1020 |
$this->addToLog(__METHOD__."(): ".$inst_instruction->msg, DEBUG_MODE); |
$this->addToLog(__METHOD__."(): ".$inst_instruction->msg, DEBUG_MODE); |
1022 |
} |
} |
1023 |
} |
} |
1024 |
} |
} |
1025 |
|
// En cas d'erreur lors du traitement de la task |
1026 |
if ($this->valF['state'] === self::STATUS_ERROR) { |
if ($this->valF['state'] === self::STATUS_ERROR) { |
1027 |
$valF_in['statut'] = __("échec"); |
$valF_in['statut'] = __("échec"); |
1028 |
$valF_in['commentaire'] = __("Le traitement de la notification a échoué"); |
$valF_in['commentaire'] = __("Le traitement de la notification a échoué"); |
1029 |
} |
} |
1030 |
|
// Met à jour la notification |
1031 |
$inst_in->setParameter('maj', 1); |
$inst_in->setParameter('maj', 1); |
1032 |
$update_in = $inst_in->modifier($valF_in); |
$update_in = $inst_in->modifier($valF_in); |
1033 |
if ($update_in === false) { |
if ($update_in === false) { |
1037 |
} |
} |
1038 |
} |
} |
1039 |
|
|
1040 |
|
// Envoi au contrôle de légalité |
1041 |
|
// En cas de changement de l'état de la tâche envoi_CL, alors le suivi |
1042 |
|
// des dates de l'instruction est effectué |
1043 |
|
if ($val['type'] === 'envoi_CL' |
1044 |
|
&& isset($this->valF['state']) === true |
1045 |
|
&& $this->valF['state'] === self::STATUS_DONE) { |
1046 |
|
// |
1047 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
1048 |
|
"obj" => "instruction", |
1049 |
|
"idx" => $this->getVal('object_id'), |
1050 |
|
)); |
1051 |
|
if ($inst_instruction->has_an_edition() === true) { |
1052 |
|
$valF_instruction = array(); |
1053 |
|
foreach ($inst_instruction->champs as $champ) { |
1054 |
|
$valF_instruction[$champ] = $inst_instruction->getVal($champ); |
1055 |
|
} |
1056 |
|
} |
1057 |
|
$valF_instruction['date_envoi_controle_legalite'] = date("Y-m-d"); |
1058 |
|
$inst_instruction->setParameter('maj', 1); |
1059 |
|
$update_instruction = $inst_instruction->modifier($valF_instruction); |
1060 |
|
if ($update_instruction === false) { |
1061 |
|
$this->addToLog(__METHOD__."(): ".$inst_instruction->msg, DEBUG_MODE); |
1062 |
|
return false; |
1063 |
|
} |
1064 |
|
} |
1065 |
|
|
1066 |
// |
// |
1067 |
return true; |
return true; |
1068 |
} |
} |
1098 |
} |
} |
1099 |
|
|
1100 |
// |
// |
1101 |
$timestamp_log = json_encode(array( |
$timestamp_log = json_encode(array()); |
|
'creation_date' => date('Y-m-d H:i:s'), |
|
|
)); |
|
1102 |
|
|
1103 |
// |
// |
1104 |
$category = isset($params['val']['category']) === true ? $params['val']['category'] : $this->category; |
$category = isset($params['val']['category']) === true ? $params['val']['category'] : $this->category; |
1115 |
$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.")); |
1116 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
1117 |
} |
} |
1118 |
if (isset($json_payload['document_numerise']) === true |
if (isset($json_payload['document_numerise']["file_content"]) === true |
1119 |
&& empty($json_payload['document_numerise']) === false) { |
&& empty($json_payload['document_numerise']["file_content"]) === false) { |
1120 |
// |
// |
1121 |
$document_numerise = $json_payload['document_numerise']; |
$document_numerise = $json_payload['document_numerise']; |
1122 |
$file_content = base64_decode($document_numerise["file_content"]); |
$file_content = base64_decode($document_numerise["file_content"]); |
1153 |
'stream' => $stream, |
'stream' => $stream, |
1154 |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
1155 |
'category' => $category, |
'category' => $category, |
1156 |
|
'creation_date' => date('Y-m-d'), |
1157 |
|
'creation_time' => date('H:i:s'), |
1158 |
|
'last_modification_date' => null, |
1159 |
|
'last_modification_time' => null, |
1160 |
|
'comment' => null, |
1161 |
); |
); |
1162 |
|
|
1163 |
// tâche sortante |
// tâche sortante |
1164 |
|
$typeNonConcerne = array( |
1165 |
|
'notification_recepisse', |
1166 |
|
'notification_instruction', |
1167 |
|
'notification_decision', |
1168 |
|
'notification_service_consulte', |
1169 |
|
'notification_tiers_consulte' |
1170 |
|
); |
1171 |
if ($valF["stream"] == "output" |
if ($valF["stream"] == "output" |
1172 |
&& $valF['type'] !== 'notification_recepisse' |
&& ! in_array($valF['type'], $typeNonConcerne)) { |
|
&& $valF['type'] !== 'notification_instruction' |
|
|
&& $valF['type'] !== 'notification_decision') { |
|
|
|
|
1173 |
// TODO expliquer ce code |
// TODO expliquer ce code |
1174 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id'], $valF['dossier']); |
$task_exists = $this->task_exists($valF['type'], $valF['object_id'], $valF['dossier']); |
1175 |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
1197 |
'val' => array( |
'val' => array( |
1198 |
'state' => $update_state, |
'state' => $update_state, |
1199 |
), |
), |
1200 |
|
'object_id' => $valF['object_id'], |
1201 |
); |
); |
1202 |
return $inst_task->update_task($update_params); |
return $inst_task->update_task($update_params); |
1203 |
} |
} |
1220 |
*/ |
*/ |
1221 |
public function update_task($params = array()) { |
public function update_task($params = array()) { |
1222 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
1223 |
$timestamp_log = $this->get_timestamp_log(); |
|
1224 |
if ($timestamp_log === false) { |
// Mise à jour de la tâche |
|
$this->addToLog(__METHOD__."(): erreur timestamp log", DEBUG_MODE); |
|
|
return $this->end_treatment(__METHOD__, false); |
|
|
} |
|
|
array_push($timestamp_log, array( |
|
|
'modification_date' => date('Y-m-d H:i:s'), |
|
|
'state' => $params['val']['state'], |
|
|
'prev_state' => $this->getVal('state'), |
|
|
)); |
|
|
$timestamp_log = json_encode($timestamp_log); |
|
1225 |
$valF = array( |
$valF = array( |
1226 |
'task' => $this->getVal($this->clePrimaire), |
'task' => $this->getVal($this->clePrimaire), |
1227 |
'type' => $this->getVal('type'), |
'type' => $this->getVal('type'), |
1228 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => '[]', |
1229 |
'state' => $params['val']['state'], |
'state' => $params['val']['state'], |
1230 |
'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'), |
1231 |
'stream' => $this->getVal('stream'), |
'stream' => $this->getVal('stream'), |
1232 |
'dossier' => $this->getVal('dossier'), |
'dossier' => $this->getVal('dossier'), |
1233 |
'json_payload' => $this->getVal('json_payload'), |
'json_payload' => $this->getVal('json_payload'), |
1234 |
'category' => $this->getVal('category'), |
'category' => $this->getVal('category'), |
1235 |
|
'creation_date' => $this->getVal('creation_date'), |
1236 |
|
'creation_time' => $this->getVal('creation_time'), |
1237 |
|
'last_modification_date' => date('Y-m-d'), |
1238 |
|
'last_modification_time' => date('H:i:s'), |
1239 |
|
'comment' => $this->getVal('comment'), |
1240 |
); |
); |
1241 |
$update = $this->modifier($valF); |
$update = $this->modifier($valF); |
1242 |
if ($update === false) { |
if ($update === false) { |
1285 |
|
|
1286 |
protected function view_tab_json() { |
protected function view_tab_json() { |
1287 |
$where = ''; |
$where = ''; |
1288 |
if ($this->f->get_submitted_get_value('state') !== null |
$category = null; |
1289 |
&& $this->f->get_submitted_get_value('state') !== '') { |
// Liste des paramètres possibles pour la recherche des tâches |
1290 |
// |
$params = array( |
1291 |
$where_or_and = 'WHERE'; |
'task', |
1292 |
if ($where !== '') { |
'type', |
1293 |
$where_or_and = 'AND'; |
'state', |
1294 |
} |
'object_id', |
1295 |
$where .= sprintf(' %s state = \'%s\' ', $where_or_and, $this->f->get_submitted_get_value('state')); |
'dossier', |
1296 |
} |
'stream', |
1297 |
if ($this->f->get_submitted_get_value('category') !== null |
'category', |
1298 |
&& $this->f->get_submitted_get_value('category') !== '') { |
'lien_id_interne_uid_externe', |
1299 |
// |
'object', |
1300 |
$where_or_and = 'WHERE'; |
'external_uid', |
1301 |
if ($where !== '') { |
); |
1302 |
$where_or_and = 'AND'; |
// Pour chaque paramètre possible, vérification de son existance et de sa |
1303 |
|
// valeur pour compléter la requête de recherche |
1304 |
|
foreach ($params as $param) { |
1305 |
|
// |
1306 |
|
if ($this->f->get_submitted_get_value($param) !== null |
1307 |
|
&& $this->f->get_submitted_get_value($param) !== '') { |
1308 |
|
// Condition spécifique au champ 'category' |
1309 |
|
if ($param === 'category') { |
1310 |
|
$category = $this->f->get_submitted_get_value('category'); |
1311 |
|
} |
1312 |
|
// |
1313 |
|
$where_or_and = 'WHERE'; |
1314 |
|
if ($where !== '') { |
1315 |
|
$where_or_and = 'AND'; |
1316 |
|
} |
1317 |
|
$table = 'task'; |
1318 |
|
if ($param === 'lien_id_interne_uid_externe' |
1319 |
|
|| $param === 'object' |
1320 |
|
|| $param === 'external_uid') { |
1321 |
|
// |
1322 |
|
$table = 'lien_id_interne_uid_externe'; |
1323 |
|
} |
1324 |
|
$where .= sprintf(' %s %s.%s = \'%s\' ', $where_or_and, $table, $param, $this->f->get_submitted_get_value($param)); |
1325 |
} |
} |
|
$where .= sprintf(' %s category = \'%s\' ', $where_or_and, $this->f->get_submitted_get_value('category')); |
|
1326 |
} |
} |
1327 |
|
// |
1328 |
$query = sprintf(' |
$query = sprintf(' |
1329 |
SELECT |
SELECT |
1330 |
* |
task.* |
1331 |
FROM %1$stask |
FROM %1$stask |
1332 |
|
LEFT JOIN %1$slien_id_interne_uid_externe |
1333 |
|
ON task.object_id = lien_id_interne_uid_externe.object_id |
1334 |
|
AND task.category = lien_id_interne_uid_externe.category |
1335 |
%2$s |
%2$s |
1336 |
ORDER BY task ASC |
ORDER BY task ASC |
1337 |
', |
', |
1338 |
DB_PREFIXE, |
DB_PREFIXE, |
1339 |
$where |
$where |
1340 |
); |
); |
1341 |
$res = $this->f->get_all_results_from_db_query($query, true); |
$res = $this->f->get_all_results_from_db_query( |
1342 |
|
$query, |
1343 |
|
array( |
1344 |
|
"origin" => __METHOD__, |
1345 |
|
"force_return" => true, |
1346 |
|
) |
1347 |
|
); |
1348 |
if ($res['code'] === 'KO') { |
if ($res['code'] === 'KO') { |
1349 |
return false; |
return false; |
1350 |
} |
} |
1351 |
$list_tasks = array(); |
$list_tasks = array(); |
1352 |
foreach ($res['result'] as $task) { |
foreach ($res['result'] as $task) { |
1353 |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
unset($task['timestamp_log']); |
1354 |
$task['dossier'] = $task['dossier']; |
unset($task['json_payload']); |
1355 |
if ($task['type'] === 'ajout_piece') { |
if ($task['type'] === 'ajout_piece') { |
1356 |
$val_dn = $this->get_document_numerise_data($task['object_id']); |
$val_dn = $this->get_document_numerise_data($task['object_id']); |
1357 |
} |
} |
1358 |
if ($task['stream'] === 'output') { |
if ($task['stream'] === 'output') { |
1359 |
$task['external_uids'] = $this->get_all_external_uids($task['dossier']); |
$task['external_uids'] = array_merge( |
1360 |
|
$this->get_all_external_uids($task['dossier'], array(), $category !== null ? $category : $task['category']), |
1361 |
|
$this->get_all_external_uids($task['object_id'], array(), $category !== null ? $category : $task['category']) |
1362 |
|
); |
1363 |
} |
} |
1364 |
$list_tasks[$task['task']] = $task; |
$list_tasks[$task['task']] = $task; |
1365 |
} |
} |
1366 |
printf(json_encode($list_tasks)); |
echo(json_encode($list_tasks)); |
1367 |
} |
} |
1368 |
|
|
1369 |
protected function get_dossier_data(string $dossier) { |
protected function get_dossier_data(string $dossier) { |
1372 |
"obj" => "dossier", |
"obj" => "dossier", |
1373 |
"idx" => $dossier, |
"idx" => $dossier, |
1374 |
)); |
)); |
1375 |
|
if (empty($inst_di->val) === true) { |
1376 |
|
return $val_di; |
1377 |
|
} |
1378 |
$val_di = $inst_di->get_json_data(); |
$val_di = $inst_di->get_json_data(); |
1379 |
if ($val_di['dossier_instruction_type_code'] === 'T') { |
if ($val_di['dossier_instruction_type_code'] === 'T') { |
1380 |
$val_di['date_decision_transfert'] = $val_di['date_decision']; |
$val_di['date_decision_transfert'] = $val_di['date_decision']; |
1520 |
', |
', |
1521 |
DB_PREFIXE |
DB_PREFIXE |
1522 |
); |
); |
1523 |
$res = $this->f->get_all_results_from_db_query($query, true); |
$res = $this->f->get_all_results_from_db_query( |
1524 |
|
$query, |
1525 |
|
array( |
1526 |
|
"origin" => __METHOD__, |
1527 |
|
"force_return" => true, |
1528 |
|
) |
1529 |
|
); |
1530 |
if ($res['code'] === 'KO') { |
if ($res['code'] === 'KO') { |
1531 |
return array(); |
return array(); |
1532 |
} |
} |
1537 |
return $result; |
return $result; |
1538 |
} |
} |
1539 |
|
|
1540 |
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') { |
1541 |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
1542 |
"obj" => "lien_id_interne_uid_externe", |
"obj" => "lien_id_interne_uid_externe", |
1543 |
"fk_field" => 'object_id', |
"fk_field" => 'object_id', |
1544 |
"fk_idx" => $fk_idx, |
"fk_idx" => $fk_idx, |
1545 |
"fk_field_2" => 'object', |
"fk_field_2" => 'object', |
1546 |
"fk_idx_2" => $fk_idx_2, |
"fk_idx_2" => $fk_idx_2, |
1547 |
|
"fk_field_3" => 'category', |
1548 |
|
"fk_idx_3" => $fk_idx_3, |
1549 |
|
"order_field" => 'lien_id_interne_uid_externe', |
1550 |
|
"order_asc_desc" => $order_asc_desc, |
1551 |
)); |
)); |
1552 |
return $inst_external_uid->getVal('external_uid'); |
return $inst_external_uid->getVal('external_uid'); |
1553 |
} |
} |
1554 |
|
|
1555 |
protected function get_all_external_uids($fk_idx, $link_objects = array()) { |
protected function get_all_external_uids($fk_idx, $link_objects = array(), $category=PLATAU) { |
1556 |
if (count($link_objects) == 0) { |
if (count($link_objects) == 0) { |
1557 |
$link_objects = $this->get_list_distinct_objects_external_link(); |
$link_objects = $this->get_list_distinct_objects_external_link(); |
1558 |
} |
} |
1559 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1560 |
foreach ($link_objects as $link_object) { |
foreach ($link_objects as $link_object) { |
1561 |
$external_uid = $this->get_external_uid($fk_idx, $link_object); |
$external_uid = $this->get_external_uid($fk_idx, $link_object, $category); |
1562 |
if ($external_uid !== '' && $external_uid !== null) { |
if ($external_uid !== '' && $external_uid !== null) { |
1563 |
$val_external_uid[$link_object] = $external_uid; |
$val_external_uid[$link_object] = $external_uid; |
1564 |
} |
} |
1566 |
return $val_external_uid; |
return $val_external_uid; |
1567 |
} |
} |
1568 |
|
|
1569 |
protected function get_demandeurs_data(string $dossier) { |
protected function get_demandeurs_data($dossier) { |
1570 |
$val_demandeur = array(); |
$val_demandeur = array(); |
1571 |
|
if ($dossier === null) { |
1572 |
|
return $val_demandeur; |
1573 |
|
} |
1574 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
1575 |
"obj" => "dossier", |
"obj" => "dossier", |
1576 |
"idx" => $dossier, |
"idx" => $dossier, |
1601 |
return $val_architecte; |
return $val_architecte; |
1602 |
} |
} |
1603 |
|
|
1604 |
protected function get_instruction_data(string $dossier, $type = 'decision', $extra_params = array()) { |
protected function get_instruction_data($dossier, $type = 'decision', $extra_params = array()) { |
1605 |
$val_instruction = null; |
$val_instruction = null; |
1606 |
|
if ($dossier === null) { |
1607 |
|
return $val_instruction; |
1608 |
|
} |
1609 |
$instruction_with_doc = null; |
$instruction_with_doc = null; |
1610 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
1611 |
"obj" => "dossier", |
"obj" => "dossier", |
1665 |
return $val_instruction; |
return $val_instruction; |
1666 |
} |
} |
1667 |
|
|
1668 |
|
|
1669 |
/** |
/** |
1670 |
* Récupère les informations |
* Récupère les informations pour les notifications ayant plusieurs annexe |
1671 |
*/ |
*/ |
1672 |
protected function get_instruction_notification_data($category, $type = '', $extra_params = array()) { |
protected function get_instruction_notification_data($category, $type = '', $extra_params = array()) { |
1673 |
$val_in = array(); |
$val_in = null; |
1674 |
|
|
1675 |
$idx = null; |
$idx = null; |
1676 |
if ($type === 'with-id') { |
if ($type === 'with-id') { |
1677 |
$idx = $extra_params['with-id']; |
$idx = $extra_params['with-id']; |
1678 |
} |
} |
1679 |
|
|
1680 |
|
// Récupération du type de notification. Le type est nécessaire pour récupérer |
1681 |
|
// le message et le titre de notification. |
1682 |
|
$typeNotification = $this->getVal('type'); |
1683 |
|
if (isset($this->valF['type'])) { |
1684 |
|
$typeNotification = $this->valF['type']; |
1685 |
|
} |
1686 |
|
|
1687 |
// récupére les données à intégrer à la payload |
// récupére les données à intégrer à la payload |
1688 |
$inst_in = $this->f->get_inst__om_dbform(array( |
$inst_in = $this->f->get_inst__om_dbform(array( |
1689 |
"obj" => "instruction_notification", |
"obj" => "instruction_notification", |
1690 |
"idx" => $idx, |
"idx" => $idx, |
1691 |
)); |
)); |
1692 |
$val_in = $inst_in->get_json_data(); |
if (count($inst_in->val) > 0) { |
1693 |
|
$val_in = $inst_in->get_json_data(); |
|
$val_in['parametre_courriel_type_titre'] = ''; |
|
|
$val_in['parametre_courriel_type_message'] = ''; |
|
|
// Récupération du message et du titre |
|
|
if ($category === 'mail') { |
|
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
|
|
"obj" => "instruction", |
|
|
"idx" => $inst_in->getVal('instruction'), |
|
|
)); |
|
|
$collectivite_id = $inst_instruction->get_dossier_instruction_om_collectivite($inst_instruction->getVal('dossier')); |
|
|
$phrase_type_notification = array(); |
|
|
$phrase_type_notification = $this->f->get_notification_parametre_courriel_type($collectivite_id); |
|
|
$val_in['parametre_courriel_type_titre'] = $phrase_type_notification['parametre_courriel_type_titre']; |
|
|
$val_in['parametre_courriel_type_message'] = $phrase_type_notification['parametre_courriel_type_message']; |
|
|
} |
|
1694 |
|
|
1695 |
// Récupération des liens vers les documents et de l'id de l'instruction |
$val_in['parametre_courriel_type_titre'] = ''; |
1696 |
// de l'annexe |
$val_in['parametre_courriel_type_message'] = ''; |
1697 |
$infoDocNotif = $inst_in->getInfosDocumentsNotif($inst_in->getVal($inst_in->clePrimaire)); |
// Récupération du message et du titre |
1698 |
$val_in['lien_telechargement_document'] = $infoDocNotif['document']['lien']; |
if ($category === 'mail') { |
1699 |
$val_in['lien_telechargement_annexe'] = $infoDocNotif['annexe']['lien']; |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
1700 |
$val_in['instruction_annexe'] = $infoDocNotif['annexe']['id_instruction']; |
"obj" => "instruction", |
1701 |
|
"idx" => $inst_in->getVal('instruction'), |
1702 |
|
)); |
1703 |
|
$collectivite_id = $inst_instruction->get_dossier_instruction_om_collectivite($inst_instruction->getVal('dossier')); |
1704 |
|
$phrase_type_notification = $this->f->get_notification_parametre_courriel_type($collectivite_id, $typeNotification); |
1705 |
|
$val_in['parametre_courriel_type_titre'] = $phrase_type_notification['parametre_courriel_type_titre']; |
1706 |
|
$val_in['parametre_courriel_type_message'] = $phrase_type_notification['parametre_courriel_type_message']; |
1707 |
|
} |
1708 |
|
|
1709 |
|
// Récupération des liens vers les documents et des id et type des annexes |
1710 |
|
$infoDocNotif = $inst_in->getInfosDocumentsNotif($inst_in->getVal($inst_in->clePrimaire), $category); |
1711 |
|
$cle = $category == PORTAL ? 'path' : 'lien_telechargement_document'; |
1712 |
|
$val_in[$cle] = $infoDocNotif['document']['path']; |
1713 |
|
$val_in['annexes'] = $infoDocNotif['annexes']; |
1714 |
|
} |
1715 |
return $val_in; |
return $val_in; |
1716 |
} |
} |
1717 |
|
|
1756 |
* @return boolean |
* @return boolean |
1757 |
*/ |
*/ |
1758 |
protected function is_demande_instruction_recepisse_without_dossier($instruction) { |
protected function is_demande_instruction_recepisse_without_dossier($instruction) { |
1759 |
$query = sprintf(' |
if ($instruction === null) { |
1760 |
SELECT demande_type.dossier_instruction_type |
return false; |
1761 |
FROM %1$sdemande |
} |
1762 |
INNER JOIN %1$sdemande_type ON demande.demande_type = demande_type.demande_type |
$qres = $this->f->get_one_result_from_db_query( |
1763 |
WHERE demande.instruction_recepisse = %2$s |
sprintf( |
1764 |
', |
'SELECT |
1765 |
DB_PREFIXE, |
demande_type.dossier_instruction_type |
1766 |
$instruction |
FROM |
1767 |
); |
%1$sdemande |
1768 |
$res = $this->f->get_one_result_from_db_query( |
INNER JOIN %1$sdemande_type |
1769 |
$query, |
ON demande.demande_type = demande_type.demande_type |
1770 |
true |
WHERE |
1771 |
|
demande.instruction_recepisse = %2$s', |
1772 |
|
DB_PREFIXE, |
1773 |
|
intval($instruction) |
1774 |
|
), |
1775 |
|
array( |
1776 |
|
"origin" => __METHOD__, |
1777 |
|
"force_return" => true, |
1778 |
|
) |
1779 |
); |
); |
1780 |
if ($res['code'] === 'KO') { |
if ($qres["code"] !== "OK") { |
1781 |
return null; |
return null; |
1782 |
} |
} |
1783 |
if ($res['result'] === '') { |
if ($qres["result"] === "") { |
1784 |
return true; |
return true; |
1785 |
} |
} |
1786 |
return false; |
return false; |
1897 |
$val_task[$key] = strip_tags($value); |
$val_task[$key] = strip_tags($value); |
1898 |
} |
} |
1899 |
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
1900 |
|
unset($val_task['timestamp_log_hidden']); |
1901 |
$val['task'] = $val_task; |
$val['task'] = $val_task; |
1902 |
// |
// |
1903 |
if ($this->getVal('type') === 'creation_DA' |
if ($this->getVal('type') === 'creation_DA' |
1941 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1942 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1943 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1944 |
$val_external_uid['document_numerise'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'document_numerise'); |
$val_external_uid['piece'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'piece'); |
1945 |
$val['external_uids'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1946 |
} |
} |
1947 |
// |
// |
1997 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1998 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1999 |
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
2000 |
|
$val_external_uid['avis_dossier_consultation'] = $this->get_external_uid($this->getVal('object_id'), 'avis_dossier_consultation'); |
2001 |
$val['external_uids'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
2002 |
} |
} |
2003 |
// XXX WIP |
// XXX WIP |
2012 |
$val['external_uids'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
2013 |
} |
} |
2014 |
// |
// |
2015 |
|
if ($this->getVal('type') === 'envoi_CL') { |
2016 |
|
// |
2017 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2018 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2019 |
|
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($val['dossier']['dossier_autorisation']); |
2020 |
|
$val_external_uid = array(); |
2021 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2022 |
|
$val_external_uid['dossier'] = $this->get_external_uid($this->getVal('dossier'), 'dossier'); |
2023 |
|
$val_external_uid['decision'] = $this->get_external_uid($this->getVal('object_id'), 'instruction'); |
2024 |
|
if ($val_external_uid['decision'] === '') { |
2025 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
2026 |
|
"obj" => "instruction", |
2027 |
|
"idx" => $this->getVal('object_id'), |
2028 |
|
)); |
2029 |
|
$val_external_uid['decision'] = $this->get_external_uid($inst_instruction->get_related_instructions_next('retour_signature'), 'instruction'); |
2030 |
|
} |
2031 |
|
$val['external_uids'] = $val_external_uid; |
2032 |
|
} |
2033 |
if ($this->getVal('type') === 'notification_instruction' |
if ($this->getVal('type') === 'notification_instruction' |
2034 |
|| $this->getVal('type') === 'notification_recepisse' |
|| $this->getVal('type') === 'notification_recepisse' |
2035 |
|| $this->getVal('type') === 'notification_decision') { |
|| $this->getVal('type') === 'notification_decision' |
2036 |
|
|| $this->getVal('type') === 'notification_service_consulte' |
2037 |
|
|| $this->getVal('type') === 'notification_tiers_consulte') { |
2038 |
// |
// |
2039 |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2040 |
$val['demandeur'] = $this->get_demandeurs_data($this->getVal('dossier')); |
$dossier_id = isset($val['dossier']['dossier']) === true ? $val['dossier']['dossier'] : null; |
2041 |
|
$val['demandeur'] = $this->get_demandeurs_data($dossier_id); |
2042 |
$val['instruction_notification'] = $this->get_instruction_notification_data($this->getVal('category'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
$val['instruction_notification'] = $this->get_instruction_notification_data($this->getVal('category'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2043 |
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $val['instruction_notification']['instruction'])); |
$instruction_id = isset($val['instruction_notification']['instruction']) === true ? $val['instruction_notification']['instruction'] : null; |
2044 |
|
$instruction_annexes = isset($val['instruction_notification']['annexes']) === true ? $val['instruction_notification']['annexes'] : null; |
2045 |
|
$val['instruction'] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $instruction_id)); |
2046 |
// Précise qu'il s'agit d'une instruction final si l'instruction est liée à une |
// Précise qu'il s'agit d'une instruction final si l'instruction est liée à une |
2047 |
// demande dont le type ne génère pas de dossier |
// demande dont le type ne génère pas de dossier |
2048 |
if ($this->is_demande_instruction_recepisse_without_dossier($val['instruction_notification']['instruction']) === true) { |
if ($this->is_demande_instruction_recepisse_without_dossier($instruction_id) === true) { |
2049 |
$val['instruction']['final'] = 't'; |
$val['instruction']['final'] = 't'; |
2050 |
} |
} |
|
// |
|
|
if ($val['instruction_notification']['instruction_annexe'] != '') { |
|
|
$val['instruction_annexe'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $val['instruction_notification']['instruction_annexe'])); |
|
|
} |
|
2051 |
$val_external_uid = array(); |
$val_external_uid = array(); |
2052 |
// Affiche l'identifiant externe lié à l'instruction si cette combinaison existe, sinon celui lié au dossier |
// Affiche l'identifiant externe lié à l'instruction si cette combinaison existe, sinon celui lié au dossier |
2053 |
$val_external_uid['demande'] = $this->get_external_uid($val['instruction_notification']['instruction'], 'demande') !== '' ? $this->get_external_uid($val['instruction_notification']['instruction'], 'demande') : $this->get_external_uid($val['dossier']['dossier'], 'demande'); |
$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'); |
2054 |
|
$val_external_uid['demande (instruction)'] = $this->get_external_uid($instruction_id, 'demande', PORTAL, 'ASC'); |
2055 |
|
$val_external_uid['instruction_notification'] = $this->get_external_uid($this->getVal('object_id'), 'instruction_notification', PORTAL); |
2056 |
$val['external_uids'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
2057 |
} |
} |
2058 |
// |
// |
2067 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2068 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2069 |
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
2070 |
|
$val_external_uid['prescription'] = $this->get_external_uid($this->getVal('object_id'), 'prescription'); |
2071 |
$val['external_uids'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
2072 |
} |
} |
2073 |
|
|
2114 |
"obj" => "lien_id_interne_uid_externe", |
"obj" => "lien_id_interne_uid_externe", |
2115 |
"idx" => ']', |
"idx" => ']', |
2116 |
)); |
)); |
2117 |
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'); |
2118 |
|
$is_exists = $inst_lien->is_exists($object, $object_id, $this->f->get_submitted_post_value('external_uid'), $this->getVal('dossier')); |
2119 |
|
// Dans le cas spécifique de la mise à jour d'une notification |
2120 |
|
// et de la création d'une liaison d'identifiant pour l'objet demande, |
2121 |
|
// l'identifiant de l'objet n'est plus celui de la notification |
2122 |
|
// d'instruction mais celui du dossier d'instruction |
2123 |
|
if ($object === 'demande' |
2124 |
|
&& ($this->getVal('type') === 'notification_recepisse' |
2125 |
|
|| $this->getVal('type') === 'notification_instruction' |
2126 |
|
|| $this->getVal('type') === 'notification_decision' |
2127 |
|
|| $this->getVal('type') === 'notification_service_consulte' |
2128 |
|
|| $this->getVal('type') === 'notification_tiers_consulte')) { |
2129 |
|
// |
2130 |
|
$object_id = $this->getVal('dossier'); |
2131 |
|
// Il ne doit y avoir qu'une liaison entre le numéro du dossier interne et un uid externe de "demande" |
2132 |
|
$is_exists = $inst_lien->is_exists($object, $object_id, null, $this->getVal('dossier')); |
2133 |
|
} |
2134 |
|
if ($is_exists === false) { |
2135 |
$valF = array( |
$valF = array( |
2136 |
'lien_id_interne_uid_externe' => '', |
'lien_id_interne_uid_externe' => '', |
2137 |
'object' => $object, |
'object' => $object, |
2138 |
'object_id' => $this->getVal('object_id'), |
'object_id' => $object_id, |
2139 |
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
2140 |
'dossier' => $this->getVal('dossier'), |
'dossier' => $this->getVal('dossier'), |
2141 |
'category' => $this->getVal('category'), |
'category' => $this->getVal('category'), |
2187 |
} |
} |
2188 |
|
|
2189 |
function setLayout(&$form, $maj) { |
function setLayout(&$form, $maj) { |
2190 |
|
// |
2191 |
// Récupération du mode de l'action |
$form->setBloc('json_payload', 'D', '', 'col_6'); |
2192 |
$crud = $this->get_action_crud($maj); |
$form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed"); |
2193 |
|
$form->setBloc('json_payload', 'F'); |
2194 |
// MODE different de CREER |
$form->setBloc('timestamp_log', 'DF', __("historique"), 'col_9 timestamp_log_jsontotab'); |
|
if ($maj != 0 || $crud != 'create') { |
|
|
$form->setBloc('json_payload', 'D', '', 'col_6'); |
|
|
$form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed"); |
|
|
$form->setBloc('json_payload', 'F'); |
|
|
} |
|
|
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
|
2195 |
} |
} |
2196 |
|
|
2197 |
/** |
/** |
2198 |
* [get_objects_by_task_type description] |
* Récupère le nom de l'objet à mentionner dans la table lien_id_interne_uid_externe |
2199 |
* @param [type] $type [description] |
* en fonction du type et du stream de la tâche. |
2200 |
* @return [type] [description] |
* |
2201 |
|
* @param string $type Type de la tâche |
2202 |
|
* @param string $stream Stream de la tâche |
2203 |
|
* |
2204 |
|
* @return array |
2205 |
*/ |
*/ |
2206 |
function get_objects_by_task_type($type, $stream = 'all') { |
function get_objects_by_task_type($type, $stream = 'all') { |
2207 |
$objects = array(); |
$objects = array(); |
2221 |
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
2222 |
$objects = array('instruction', ); |
$objects = array('instruction', ); |
2223 |
} |
} |
2224 |
|
if (in_array($type, array('envoi_CL', )) === true) { |
2225 |
|
$objects = array('instruction_action_cl', ); |
2226 |
|
} |
2227 |
if (in_array($type, array('pec_metier_consultation', )) === true |
if (in_array($type, array('pec_metier_consultation', )) === true |
2228 |
&& $stream === 'output') { |
&& $stream === 'output') { |
2229 |
$objects = array('pec_dossier_consultation', ); |
$objects = array('pec_dossier_consultation', ); |
2254 |
&& $stream === 'input') { |
&& $stream === 'input') { |
2255 |
$objects = array('dossier_message', ); |
$objects = array('dossier_message', ); |
2256 |
} |
} |
2257 |
if (in_array($type, array('notification_recepisse', 'notification_instruction', 'notification_decision' )) === true) { |
if (in_array( |
2258 |
$objects = array('instruction_notification', ); |
$type, |
2259 |
|
array( |
2260 |
|
'notification_recepisse', |
2261 |
|
'notification_instruction', |
2262 |
|
'notification_decision', |
2263 |
|
'notification_service_consulte', |
2264 |
|
'notification_tiers_consulte', |
2265 |
|
) |
2266 |
|
) === true) { |
2267 |
|
$objects = array('instruction_notification', 'demande', ); |
2268 |
} |
} |
2269 |
return $objects; |
return $objects; |
2270 |
} |
} |
2271 |
|
|
2272 |
|
/** |
2273 |
|
* Récupère les tables auxquelles pourrait être rattaché l'objet lié à la tâche, |
2274 |
|
* par rapport à son type. |
2275 |
|
* |
2276 |
|
* @param string $type Type de la tâche |
2277 |
|
* @param string $stream input ou output |
2278 |
|
* @return array |
2279 |
|
*/ |
2280 |
|
function get_tables_by_task_type($type, $stream = 'all') { |
2281 |
|
$tables = array(); |
2282 |
|
if (in_array($type, array('creation_DA', 'modification_DA', )) === true) { |
2283 |
|
$tables = array('dossier_autorisation', ); |
2284 |
|
} |
2285 |
|
if (in_array($type, array('creation_DI', 'depot_DI', )) === true) { |
2286 |
|
$tables = array('dossier', ); |
2287 |
|
} |
2288 |
|
if (in_array($type, array('qualification_DI', )) === true) { |
2289 |
|
$tables = array('instruction', 'dossier', ); |
2290 |
|
} |
2291 |
|
if (in_array($type, array('create_DI_for_consultation', )) === true) { |
2292 |
|
$tables = array('dossier', ); |
2293 |
|
} |
2294 |
|
if (in_array($type, array('create_DI', )) === true |
2295 |
|
&& $stream === 'input') { |
2296 |
|
$tables = array('dossier', 'dossier_autorisation', 'demande', ); |
2297 |
|
} |
2298 |
|
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
2299 |
|
$tables = array('instruction', ); |
2300 |
|
} |
2301 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
2302 |
|
&& $stream === 'output') { |
2303 |
|
$tables = array('instruction', ); |
2304 |
|
} |
2305 |
|
if (in_array($type, array('avis_consultation', )) === true |
2306 |
|
&& $stream === 'output') { |
2307 |
|
$tables = array('instruction', ); |
2308 |
|
} |
2309 |
|
if (in_array($type, array('prescription', )) === true |
2310 |
|
&& $stream === 'output') { |
2311 |
|
$tables = array('instruction', ); |
2312 |
|
} |
2313 |
|
if (in_array($type, array('ajout_piece', 'add_piece', )) === true) { |
2314 |
|
$tables = array('document_numerise', ); |
2315 |
|
} |
2316 |
|
if (in_array($type, array('creation_consultation', )) === true) { |
2317 |
|
$tables = array('consultation', ); |
2318 |
|
} |
2319 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
2320 |
|
&& $stream === 'input') { |
2321 |
|
$tables = array('consultation', ); |
2322 |
|
} |
2323 |
|
if (in_array($type, array('avis_consultation', )) === true |
2324 |
|
&& $stream === 'input') { |
2325 |
|
$tables = array('consultation', ); |
2326 |
|
} |
2327 |
|
if (in_array($type, array('create_message', )) === true |
2328 |
|
&& $stream === 'input') { |
2329 |
|
$tables = array('dossier_message', ); |
2330 |
|
} |
2331 |
|
if (in_array( |
2332 |
|
$type, |
2333 |
|
array( |
2334 |
|
'notification_recepisse', |
2335 |
|
'notification_instruction', |
2336 |
|
'notification_decision', |
2337 |
|
'notification_service_consulte', |
2338 |
|
'notification_tiers_consulte' |
2339 |
|
) |
2340 |
|
) === true) { |
2341 |
|
$tables = array('instruction_notification', ); |
2342 |
|
} |
2343 |
|
return $tables; |
2344 |
|
} |
2345 |
|
|
2346 |
} |
} |