36 |
'notification_recepisse', |
'notification_recepisse', |
37 |
'notification_instruction', |
'notification_instruction', |
38 |
'notification_decision', |
'notification_decision', |
39 |
|
'notification_service_consulte', |
40 |
|
'notification_tiers_consulte', |
41 |
); |
); |
42 |
|
|
43 |
/** |
/** |
51 |
'notification_recepisse', |
'notification_recepisse', |
52 |
'notification_instruction', |
'notification_instruction', |
53 |
'notification_decision', |
'notification_decision', |
54 |
|
'notification_service_consulte', |
55 |
|
'notification_tiers_consulte', |
56 |
'prescription', |
'prescription', |
57 |
); |
); |
58 |
|
|
452 |
*/ |
*/ |
453 |
public function task_exists_multi_search(array $search_values) { |
public function task_exists_multi_search(array $search_values) { |
454 |
$query = sprintf(' |
$query = sprintf(' |
455 |
SELECT task |
SELECT * |
456 |
FROM %1$stask |
FROM %1$stask |
457 |
%2$s |
%2$s |
458 |
%3$s |
%3$s |
496 |
|
|
497 |
// gestion d'une tache de type notification et de category mail |
// gestion d'une tache de type notification et de category mail |
498 |
if (isset($val['type']) |
if (isset($val['type']) |
499 |
&& (//$val['type'] === 'notification_recepisse' |
&& ((//$val['type'] === 'notification_recepisse' |
500 |
$val['type'] === 'notification_instruction' |
$val['type'] === 'notification_instruction' |
501 |
|| $val['type'] === 'notification_decision') |
|| $val['type'] === 'notification_decision') |
502 |
&& isset($val['category']) |
&& isset($val['category']) |
503 |
&& $val['category'] === 'mail') { |
&& $val['category'] === 'mail') |
504 |
|
|| $val['type'] === 'notification_service_consulte' |
505 |
|
|| $val['type'] === 'notification_tiers_consulte' |
506 |
|
) { |
507 |
// Récupère la payload de la tache |
// Récupère la payload de la tache |
508 |
$data = array(); |
$data = array(); |
509 |
$data['instruction_notification'] = $this->get_instruction_notification_data( |
// TODO : pour l'instant la gestion des notifs des demandeurs a été séparée |
510 |
$this->valF['category'], |
// de celle des autres type de notif afin de ne pas risquer de casser l'existant |
511 |
'with-id', |
// et pour des contraintes de temps. A optimiser plus tard |
512 |
array('with-id' => $this->valF['object_id']) |
if ($val['type'] === 'notification_service_consulte' |
513 |
); |
|| $val['type'] === 'notification_tiers_consulte') { |
514 |
|
$data['instruction_notification'] = $this->get_instruction_notification_data_annexe_multiple( |
515 |
|
$this->valF['category'], |
516 |
|
'with-id', |
517 |
|
array('with-id' => $this->valF['object_id']) |
518 |
|
); |
519 |
|
} else { |
520 |
|
$data['instruction_notification'] = $this->get_instruction_notification_data( |
521 |
|
$this->valF['category'], |
522 |
|
'with-id', |
523 |
|
array('with-id' => $this->valF['object_id']) |
524 |
|
); |
525 |
|
} |
526 |
$data['dossier'] = $this->get_dossier_data($this->valF['dossier']); |
$data['dossier'] = $this->get_dossier_data($this->valF['dossier']); |
527 |
|
|
528 |
// Récupère l'instance de la notification |
// Récupère l'instance de la notification |
531 |
"idx" => $val['object_id'], |
"idx" => $val['object_id'], |
532 |
)); |
)); |
533 |
// Envoi le mail et met à jour le suivi |
// Envoi le mail et met à jour le suivi |
534 |
$envoiMail = $inst_notif->send_mail_notification_demandeur($data); |
$envoiMail = $inst_notif->send_mail_notification($data, $val['type']); |
535 |
// Passage de la tache à done si elle a réussi et à error |
// Passage de la tache à done si elle a réussi et à error |
536 |
// si l'envoi a échoué |
// si l'envoi a échoué |
537 |
$this->valF['state'] = 'done'; |
$this->valF['state'] = 'done'; |
562 |
&& isset($val['type']) === true |
&& isset($val['type']) === true |
563 |
&& ($val['type'] === 'notification_recepisse' |
&& ($val['type'] === 'notification_recepisse' |
564 |
|| $val['type'] === 'notification_instruction' |
|| $val['type'] === 'notification_instruction' |
565 |
|| $val['type'] === 'notification_decision')) { |
|| $val['type'] === 'notification_decision' |
566 |
|
|| $val['type'] === 'notification_service_consulte' |
567 |
|
|| $val['type'] === 'notification_tiers_consulte')) { |
568 |
// |
// |
569 |
if (isset($this->valF['state']) === true |
if (isset($this->valF['state']) === true |
570 |
&& $this->valF['state'] !== $this->getVal('state') |
&& $this->valF['state'] !== $this->getVal('state') |
745 |
); |
); |
746 |
|
|
747 |
// tâche sortante |
// tâche sortante |
748 |
|
$typeNonConcerne = array( |
749 |
|
'notification_recepisse', |
750 |
|
'notification_instruction', |
751 |
|
'notification_decision', |
752 |
|
'notification_service_consulte', |
753 |
|
'notification_tiers_consulte' |
754 |
|
); |
755 |
if ($valF["stream"] == "output" |
if ($valF["stream"] == "output" |
756 |
&& $valF['type'] !== 'notification_recepisse' |
&& ! in_array($valF['type'], $typeNonConcerne)) { |
|
&& $valF['type'] !== 'notification_instruction' |
|
|
&& $valF['type'] !== 'notification_decision') { |
|
|
|
|
757 |
// TODO expliquer ce code |
// TODO expliquer ce code |
758 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id'], $valF['dossier']); |
$task_exists = $this->task_exists($valF['type'], $valF['object_id'], $valF['dossier']); |
759 |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
836 |
$query = sprintf(' |
$query = sprintf(' |
837 |
SELECT COUNT(%2$s) |
SELECT COUNT(%2$s) |
838 |
FROM %1$s%2$s |
FROM %1$s%2$s |
839 |
WHERE %2$s = \'%3$s\' |
WHERE %2$s::CHARACTER VARYING = \'%3$s\' |
840 |
', |
', |
841 |
DB_PREFIXE, |
DB_PREFIXE, |
842 |
$table, |
$table, |
1311 |
return $val_in; |
return $val_in; |
1312 |
} |
} |
1313 |
|
|
1314 |
|
/** |
1315 |
|
* Récupère les informations pour les notifications ayant plusieurs annexe |
1316 |
|
*/ |
1317 |
|
protected function get_instruction_notification_data_annexe_multiple($category, $type = '', $extra_params = array()) { |
1318 |
|
$val_in = null; |
1319 |
|
|
1320 |
|
$idx = null; |
1321 |
|
if ($type === 'with-id') { |
1322 |
|
$idx = $extra_params['with-id']; |
1323 |
|
} |
1324 |
|
|
1325 |
|
// récupére les données à intégrer à la payload |
1326 |
|
$inst_in = $this->f->get_inst__om_dbform(array( |
1327 |
|
"obj" => "instruction_notification", |
1328 |
|
"idx" => $idx, |
1329 |
|
)); |
1330 |
|
if (count($inst_in->val) > 0) { |
1331 |
|
$val_in = $inst_in->get_json_data(); |
1332 |
|
|
1333 |
|
$val_in['parametre_courriel_type_titre'] = ''; |
1334 |
|
$val_in['parametre_courriel_type_message'] = ''; |
1335 |
|
// Récupération du message et du titre |
1336 |
|
if ($category === 'mail') { |
1337 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
1338 |
|
"obj" => "instruction", |
1339 |
|
"idx" => $inst_in->getVal('instruction'), |
1340 |
|
)); |
1341 |
|
$collectivite_id = $inst_instruction->get_dossier_instruction_om_collectivite($inst_instruction->getVal('dossier')); |
1342 |
|
$phrase_type_notification = array(); |
1343 |
|
$phrase_type_notification = $this->f->get_notification_parametre_courriel_type($collectivite_id); |
1344 |
|
$val_in['parametre_courriel_type_titre'] = $phrase_type_notification['parametre_courriel_type_titre']; |
1345 |
|
$val_in['parametre_courriel_type_message'] = $phrase_type_notification['parametre_courriel_type_message']; |
1346 |
|
} |
1347 |
|
|
1348 |
|
// Récupération des liens vers les documents et de l'id de l'instruction |
1349 |
|
// de l'annexe |
1350 |
|
$infoDocNotif = $inst_in->getInfosDocumentsNotifAnnexeMultiple($inst_in->getVal($inst_in->clePrimaire)); |
1351 |
|
$val_in['lien_telechargement_document'] = $infoDocNotif['document']['lien']; |
1352 |
|
$val_in['annexes'] = $infoDocNotif['annexes']; |
1353 |
|
} |
1354 |
|
|
1355 |
|
return $val_in; |
1356 |
|
} |
1357 |
|
|
1358 |
protected function sort_instruction_data(array $values, array $res) { |
protected function sort_instruction_data(array $values, array $res) { |
1359 |
$fields = array( |
$fields = array( |
1360 |
"date_evenement", |
"date_evenement", |
1689 |
$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'); |
$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'); |
1690 |
$val['external_uids'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1691 |
} |
} |
1692 |
|
if ($this->getVal('type') === 'notification_service_consulte' |
1693 |
|
|| $this->getVal('type') === 'notification_tiers_consulte') { |
1694 |
|
// |
1695 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1696 |
|
$dossier_id = isset($val['dossier']['dossier']) === true ? $val['dossier']['dossier'] : null; |
1697 |
|
$val['demandeur'] = $this->get_demandeurs_data($dossier_id); |
1698 |
|
$val['instruction_notification'] = $this->get_instruction_notification_data_annexe_multiple($this->getVal('category'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1699 |
|
$instruction_id = isset($val['instruction_notification']['instruction']) === true ? $val['instruction_notification']['instruction'] : null; |
1700 |
|
$instruction_annexes = isset($val['instruction_notification']['annexes']) === true ? $val['instruction_notification']['annexes'] : null; |
1701 |
|
$val['instruction'] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $instruction_id)); |
1702 |
|
// Précise qu'il s'agit d'une instruction final si l'instruction est liée à une |
1703 |
|
// demande dont le type ne génère pas de dossier |
1704 |
|
if ($this->is_demande_instruction_recepisse_without_dossier($instruction_id) === true) { |
1705 |
|
$val['instruction']['final'] = 't'; |
1706 |
|
} |
1707 |
|
// |
1708 |
|
if (is_array($instruction_annexes) && $instruction_annexes != array()) { |
1709 |
|
$val['instruction_annexe'] = array(); |
1710 |
|
$numAnnexe = 0; |
1711 |
|
foreach ($instruction_annexes as $annexe) { |
1712 |
|
if ($annexe['document_type'] === 'instruction') { |
1713 |
|
$val['instruction_annexe']['annexe_'.$numAnnexe++] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $annexe['document_id'])); |
1714 |
|
} elseif ($annexe['document_type'] === 'consultation') { |
1715 |
|
$val['instruction_annexe']['annexe_'.$numAnnexe++] = $this->get_consultation_data($annexe['document_id']); |
1716 |
|
} |
1717 |
|
} |
1718 |
|
} |
1719 |
|
$val_external_uid = array(); |
1720 |
|
// Affiche l'identifiant externe lié à l'instruction si cette combinaison existe, sinon celui lié au dossier |
1721 |
|
$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'); |
1722 |
|
$val['external_uids'] = $val_external_uid; |
1723 |
|
} |
1724 |
// |
// |
1725 |
if ($this->getVal('type') === 'prescription') { |
if ($this->getVal('type') === 'prescription') { |
1726 |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1787 |
if ($object === 'demande' |
if ($object === 'demande' |
1788 |
&& ($this->getVal('type') === 'notification_recepisse' |
&& ($this->getVal('type') === 'notification_recepisse' |
1789 |
|| $this->getVal('type') === 'notification_instruction' |
|| $this->getVal('type') === 'notification_instruction' |
1790 |
|| $this->getVal('type') === 'notification_decision')) { |
|| $this->getVal('type') === 'notification_decision' |
1791 |
|
|| $this->getVal('type') === 'notification_service_consulte' |
1792 |
|
|| $this->getVal('type') === 'notification_tiers_consulte')) { |
1793 |
// |
// |
1794 |
$object_id = $this->getVal('dossier'); |
$object_id = $this->getVal('dossier'); |
1795 |
} |
} |
1863 |
} |
} |
1864 |
|
|
1865 |
/** |
/** |
1866 |
* [get_objects_by_task_type description] |
* Récupère le nom de l'objet à mentionner dans la table lien_id_interne_uid_externe |
1867 |
* @param [type] $type [description] |
* en fonction du type et du stream de la tâche. |
1868 |
* @return [type] [description] |
* |
1869 |
|
* @param string $type Type de la tâche |
1870 |
|
* @param string $stream Stream de la tâche |
1871 |
|
* |
1872 |
|
* @return array |
1873 |
*/ |
*/ |
1874 |
function get_objects_by_task_type($type, $stream = 'all') { |
function get_objects_by_task_type($type, $stream = 'all') { |
1875 |
$objects = array(); |
$objects = array(); |
1886 |
&& $stream === 'input') { |
&& $stream === 'input') { |
1887 |
$objects = array('dossier', 'dossier_autorisation', 'demande', ); |
$objects = array('dossier', 'dossier_autorisation', 'demande', ); |
1888 |
} |
} |
1889 |
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', 'envoi_CL', )) === true) { |
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
1890 |
$objects = array('instruction', ); |
$objects = array('instruction', ); |
1891 |
} |
} |
1892 |
|
if (in_array($type, array('envoi_CL', )) === true) { |
1893 |
|
$objects = array('instruction_action_cl', ); |
1894 |
|
} |
1895 |
if (in_array($type, array('pec_metier_consultation', )) === true |
if (in_array($type, array('pec_metier_consultation', )) === true |
1896 |
&& $stream === 'output') { |
&& $stream === 'output') { |
1897 |
$objects = array('pec_dossier_consultation', ); |
$objects = array('pec_dossier_consultation', ); |
1922 |
&& $stream === 'input') { |
&& $stream === 'input') { |
1923 |
$objects = array('dossier_message', ); |
$objects = array('dossier_message', ); |
1924 |
} |
} |
1925 |
if (in_array($type, array('notification_recepisse', 'notification_instruction', 'notification_decision' )) === true) { |
if (in_array( |
1926 |
|
$type, |
1927 |
|
array( |
1928 |
|
'notification_recepisse', |
1929 |
|
'notification_instruction', |
1930 |
|
'notification_decision', |
1931 |
|
'notification_service_consulte', |
1932 |
|
'notification_tiers_consulte', |
1933 |
|
) |
1934 |
|
) === true) { |
1935 |
$objects = array('instruction_notification', 'demande', ); |
$objects = array('instruction_notification', 'demande', ); |
1936 |
} |
} |
1937 |
return $objects; |
return $objects; |
1954 |
$tables = array('dossier', ); |
$tables = array('dossier', ); |
1955 |
} |
} |
1956 |
if (in_array($type, array('qualification_DI', )) === true) { |
if (in_array($type, array('qualification_DI', )) === true) { |
1957 |
$tables = array('instruction', ); |
$tables = array('instruction', 'dossier', ); |
1958 |
} |
} |
1959 |
if (in_array($type, array('create_DI_for_consultation', )) === true) { |
if (in_array($type, array('create_DI_for_consultation', )) === true) { |
1960 |
$tables = array('dossier', ); |
$tables = array('dossier', ); |
1996 |
&& $stream === 'input') { |
&& $stream === 'input') { |
1997 |
$tables = array('dossier_message', ); |
$tables = array('dossier_message', ); |
1998 |
} |
} |
1999 |
if (in_array($type, array('notification_recepisse', 'notification_instruction', 'notification_decision' )) === true) { |
if (in_array( |
2000 |
|
$type, |
2001 |
|
array( |
2002 |
|
'notification_recepisse', |
2003 |
|
'notification_instruction', |
2004 |
|
'notification_decision', |
2005 |
|
'notification_service_consulte', |
2006 |
|
'notification_tiers_consulte' |
2007 |
|
) |
2008 |
|
) === true) { |
2009 |
$tables = array('instruction_notification', ); |
$tables = array('instruction_notification', ); |
2010 |
} |
} |
2011 |
return $tables; |
return $tables; |