107 |
*/ |
*/ |
108 |
var $di_reopened = null; |
var $di_reopened = null; |
109 |
|
|
110 |
|
/** |
111 |
|
* Méthode appelée par le module_manager lors de la récupération des modules de cet objet. |
112 |
|
* Permet d'ajouer des modules en plus de ceux récupérer par défaut par le module_manager. |
113 |
|
* |
114 |
|
* @return array Liste de modules supplémentaires pour cet objet |
115 |
|
*/ |
116 |
|
public function get_modules_append() { |
117 |
|
$modules = array(); |
118 |
|
|
119 |
|
// si on est dans le cadre de l'affichage d'une nouvelle instruction |
120 |
|
$action = $this->f->get_submitted_get_value('action'); |
121 |
|
if ($action == '0') { |
122 |
|
|
123 |
|
// si on est sur un dossier d'instruction |
124 |
|
if ($this->f->contexte_dossier_instruction()) { |
125 |
|
$idx = $this->f->get_submitted_get_value('idxformulaire'); |
126 |
|
if (! empty($idx)) { |
127 |
|
|
128 |
|
// ajoute les modules des évènements possible sur le dossier courant |
129 |
|
$evenements_data = $this->get_var_sql_forminc__sql_evenement(); |
130 |
|
$evenements_ids = array_map(function($item) { return $item['evenement']; }, $evenements_data); |
131 |
|
$this->f->log(__METHOD__, 'evenements: '.implode(',', $evenements_ids)); |
132 |
|
$modules = $this->f->module_manager->get_modules_for_object_name_and_ids( |
133 |
|
'evenement', $evenements_ids, $this, false); |
134 |
|
} |
135 |
|
} |
136 |
|
} |
137 |
|
return $modules; |
138 |
|
} |
139 |
|
|
140 |
// {{{ Gestion de la confidentialité des données spécifiques |
// {{{ Gestion de la confidentialité des données spécifiques |
141 |
|
|
142 |
/** |
/** |
217 |
"is_unfinalizable_without_bypass", |
"is_unfinalizable_without_bypass", |
218 |
"can_user_access_dossier_contexte_modification", |
"can_user_access_dossier_contexte_modification", |
219 |
"is_not_sent_for_signature", |
"is_not_sent_for_signature", |
220 |
|
"is_not_signed", |
221 |
), |
), |
222 |
); |
); |
223 |
|
|
318 |
"crud" => "update", |
"crud" => "update", |
319 |
); |
); |
320 |
|
|
321 |
|
// ACTION - 176 - add_by_evenement_retour_after_notification_task |
322 |
|
// Action à utiliser lors de l'ajout des instructions par événement suivant |
323 |
|
// suite à une notification par tâche (donc notification dématerialisée) |
324 |
|
$this->class_actions[176] = array( |
325 |
|
"identifier" => "add_by_evenement_retour_after_notification_task", |
326 |
|
"view" => "formulaire", |
327 |
|
"permission_suffix" => "ajouter", |
328 |
|
"crud" => "create", |
329 |
|
); |
330 |
|
|
331 |
// ACTION - 180 - pdf_lettre_rar |
// ACTION - 180 - pdf_lettre_rar |
332 |
// Génère PDF sur bordereaux de lettres AR |
// Génère PDF sur bordereaux de lettres AR |
333 |
$this->class_actions[180] = array( |
$this->class_actions[180] = array( |
504 |
"permission_suffix" => "tab", |
"permission_suffix" => "tab", |
505 |
); |
); |
506 |
|
|
507 |
|
// |
508 |
|
$this->class_actions[405] = array( |
509 |
|
"identifier" => "telecharger_editions", |
510 |
|
"view" => "view_telecharger_editions", |
511 |
|
"permission_suffix" => "om_fichier_instruction_telecharger", |
512 |
|
); |
513 |
|
|
514 |
// ACTION - 410 - Notifier les pétitionnaires (mail ou autre) |
// ACTION - 410 - Notifier les pétitionnaires (mail ou autre) |
515 |
$this->class_actions[410] = array( |
$this->class_actions[410] = array( |
516 |
"identifier" => "overlay_notification_manuelle", |
"identifier" => "overlay_notification_manuelle", |
539 |
"is_notifiable_by_task_manual", |
"is_notifiable_by_task_manual", |
540 |
"is_portail_notification_sans_annexe" |
"is_portail_notification_sans_annexe" |
541 |
), |
), |
542 |
"method" => "notifier_demandeur_principal", |
"method" => "notifier_demandeur_principal_via_portal", |
543 |
|
"permission_suffix" => "modifier", |
544 |
|
); |
545 |
|
|
546 |
|
// ACTION - 412 - Vérifie le dépassement de la date limite de notification |
547 |
|
$this->class_actions[412] = array( |
548 |
|
"identifier" => "is_date_limite_notification_dossier_depasse", |
549 |
|
"view" => "is_date_limite_notification_dossier_depasse", |
550 |
"permission_suffix" => "modifier", |
"permission_suffix" => "modifier", |
551 |
); |
); |
552 |
|
|
622 |
"om_final_instruction_utilisateur", |
"om_final_instruction_utilisateur", |
623 |
"date_finalisation_courrier", |
"date_finalisation_courrier", |
624 |
"date_envoi_signature", |
"date_envoi_signature", |
625 |
|
"date_retour_signature", |
626 |
"date_envoi_rar", |
"date_envoi_rar", |
|
"date_envoi_controle_legalite", |
|
627 |
|
|
|
"date_retour_signature", |
|
628 |
"date_retour_rar", |
"date_retour_rar", |
629 |
|
"date_envoi_controle_legalite", |
630 |
"date_retour_controle_legalite", |
"date_retour_controle_legalite", |
631 |
|
|
632 |
"numero_arrete", |
"numero_arrete", |
731 |
|
|
732 |
"'' as preview_edition", |
"'' as preview_edition", |
733 |
"envoye_cl_platau", |
"envoye_cl_platau", |
734 |
"'' as log_instruction" |
"'' as log_instruction", |
735 |
|
"parapheur_lien_page_signature" |
736 |
); |
); |
737 |
} |
} |
738 |
|
|
880 |
return false; |
return false; |
881 |
} |
} |
882 |
|
|
883 |
|
/** |
884 |
|
* CONDITION - is_signed |
885 |
|
* |
886 |
|
* Vérifie que l'instruction n'a pas été signée |
887 |
|
* |
888 |
|
* @return boolean |
889 |
|
*/ |
890 |
|
function is_not_signed() { |
891 |
|
// Contrôle si l'utilisateur possède un bypass |
892 |
|
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_definaliser_apres_signature"); |
893 |
|
if ($bypass == true) { |
894 |
|
return true; |
895 |
|
} |
896 |
|
|
897 |
|
return !$this->is_signed(); |
898 |
|
} |
899 |
|
|
900 |
|
|
901 |
/** |
/** |
902 |
* is_sent_to_cl |
* is_sent_to_cl |
925 |
function is_portail_notification_sans_annexe() { |
function is_portail_notification_sans_annexe() { |
926 |
$collectiviteDi = $this->get_dossier_instruction_om_collectivite(); |
$collectiviteDi = $this->get_dossier_instruction_om_collectivite(); |
927 |
$ev = $this->get_inst_evenement($this->getVal('evenement')); |
$ev = $this->get_inst_evenement($this->getVal('evenement')); |
928 |
if (($this->f->get_param_option_notification($collectiviteDi) === null || |
if ($this->f->get_param_option_notification($collectiviteDi) === PORTAL |
|
$this->f->get_param_option_notification($collectiviteDi) === PORTAL) |
|
929 |
&& $ev->getVal('notification') != 'notification_manuelle_annexe' |
&& $ev->getVal('notification') != 'notification_manuelle_annexe' |
930 |
&& $ev->getVal('notification') != 'notification_manuelle_annexe_signature_requise' |
&& $ev->getVal('notification') != 'notification_manuelle_annexe_signature_requise' |
931 |
) { |
) { |
1229 |
} |
} |
1230 |
|
|
1231 |
/** |
/** |
1232 |
* Cette méthode permet de récupérer le dossier d'autorisation d'un dossier |
* Cette méthode instancie le dossier à partir de l'identifiant passé |
1233 |
|
* en paramètre et renvoie l'identifiant du dossier d'autorisation (DA) |
1234 |
|
* associé au dossier. |
1235 |
|
* Si l'identifiant du dossier n'est pas fourni alors cette méthode |
1236 |
|
* renverra NULL |
1237 |
|
* |
1238 |
|
* @param string identifiant du dossier |
1239 |
|
* @return null|string null ou identifiant du DA |
1240 |
*/ |
*/ |
1241 |
function getNumDemandeAutorFromDossier($id) { |
function getNumDemandeAutorFromDossier($id) { |
|
// |
|
1242 |
if (!isset($id)) { |
if (!isset($id)) { |
1243 |
return NULL; |
return NULL; |
1244 |
} |
} |
|
// |
|
|
$sql = "select dossier_autorisation from ".DB_PREFIXE."dossier "; |
|
|
$sql .= " where dossier='".$id."'"; |
|
|
// |
|
|
$dossier_autorisation = $this->f->db->getone($sql); |
|
|
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
|
|
$this->f->isDatabaseError($dossier_autorisation); |
|
|
// |
|
|
return $dossier_autorisation; |
|
|
} |
|
1245 |
|
|
1246 |
// }}} |
$dossier = $this->f->get_inst__om_dbform(array( |
1247 |
|
'obj' => 'dossier', |
1248 |
|
'idx' => $id, |
1249 |
|
)); |
1250 |
|
|
1251 |
|
return $dossier->getVal('dossier_autorisation'); |
1252 |
|
} |
1253 |
|
|
1254 |
|
|
1255 |
function setType(&$form, $maj) { |
function setType(&$form, $maj) { |
1256 |
|
$data = array('form' => &$form, 'maj' => &$maj); |
1257 |
|
$this->f->module_manager->run_hooks('setType_pre', $this, $data); |
1258 |
|
|
1259 |
// Récupération du mode de l'action |
// Récupération du mode de l'action |
1260 |
$crud = $this->get_action_crud($maj); |
$crud = $this->get_action_crud($maj); |
1261 |
// Récupère la collectivité du dossier d'instruction |
// Récupère la collectivité du dossier d'instruction |
1474 |
&& $maj == 3) { |
&& $maj == 3) { |
1475 |
$form->setType("date_envoi_controle_legalite", "hiddenstatic"); |
$form->setType("date_envoi_controle_legalite", "hiddenstatic"); |
1476 |
} |
} |
1477 |
|
$data = array('form' => &$form, 'maj' => &$maj); |
1478 |
|
$this->f->module_manager->run_hooks('setType_post', $this, $data); |
1479 |
} |
} |
1480 |
|
|
1481 |
function setOnchange(&$form,$maj){ |
function setOnchange(&$form,$maj){ |
1482 |
|
$this->f->log(__METHOD__, 'BEGIN'); |
1483 |
|
$data = array('form' => &$form, 'maj' => &$maj); |
1484 |
|
$this->f->module_manager->run_hooks('setOnchange_pre', $this, $data); |
1485 |
|
|
1486 |
parent::setOnchange($form,$maj); |
parent::setOnchange($form,$maj); |
1487 |
|
|
1488 |
// MODE AJOUTER |
// MODE AJOUTER |
1493 |
manage_instruction_evenement_commentaire(this.value, '".addslashes($this->getParameter('idxformulaire'))."');" |
manage_instruction_evenement_commentaire(this.value, '".addslashes($this->getParameter('idxformulaire'))."');" |
1494 |
); |
); |
1495 |
} |
} |
1496 |
|
|
1497 |
|
$data = array('form' => &$form, 'maj' => &$maj); |
1498 |
|
$this->f->module_manager->run_hooks('setOnchange_post', $this, $data); |
1499 |
|
$this->f->log(__METHOD__, 'END'); |
1500 |
} |
} |
1501 |
|
|
1502 |
function evenement_has_an_edition($evenement_id) { |
function evenement_has_an_edition($evenement_id) { |
1721 |
} |
} |
1722 |
|
|
1723 |
/** |
/** |
1724 |
|
* Renvoie sous la forme d'un tableau la liste des événements pouvant être ajoutés au dossier |
1725 |
|
* dont l'identifiant a été passé en paramètre dans l'url. |
1726 |
|
* |
1727 |
|
* @return array |
1728 |
|
*/ |
1729 |
|
function get_var_sql_forminc__sql_evenement() { |
1730 |
|
// Récupération du numéro de dossier |
1731 |
|
$dossier = $this->getParameter("idxformulaire") ?? $_GET['idxformulaire']; |
1732 |
|
$this->f->log(__METHOD__, 'dossier: '.var_export($dossier, true)); |
1733 |
|
// Si changement de décision par instructeur commune |
1734 |
|
$filter = ''; |
1735 |
|
if ($this->f->isUserInstructeur() === true |
1736 |
|
// TODO faire autrement car ça instancier le dossier et donc charge ses modules ! |
1737 |
|
&& $this->getDivisionFromDossier($dossier) != $_SESSION["division"] |
1738 |
|
&& $this->isInstrCanChangeDecision($dossier) === true) { |
1739 |
|
$filter = "AND evenement.type IN ('arrete', 'changement_decision')"; |
1740 |
|
} |
1741 |
|
// Récupération du libellé, de l'identifiant des évènement et d'un booléen permettant |
1742 |
|
// de déterminer si il s'agit d'évènements suggérés. |
1743 |
|
$qres = $this->f->get_all_results_from_db_query( |
1744 |
|
sprintf( |
1745 |
|
'SELECT |
1746 |
|
DISTINCT(evenement.evenement), |
1747 |
|
evenement.libelle, |
1748 |
|
-- Si l evenement est suggérés alors il sera lié à la table des événements suggérés du dossier |
1749 |
|
CASE WHEN evenement_suggere_dossier.evenement IS NULL |
1750 |
|
THEN FALSE |
1751 |
|
ELSE TRUE |
1752 |
|
END AS is_suggested |
1753 |
|
FROM |
1754 |
|
-- Jointures permettant de récupérer la liste des évènements compatibles avec le dossier |
1755 |
|
-- selon le type de dossier et l état du dossier. |
1756 |
|
%1$sevenement |
1757 |
|
JOIN %1$slien_dossier_instruction_type_evenement |
1758 |
|
ON evenement.evenement = lien_dossier_instruction_type_evenement.evenement |
1759 |
|
JOIN %1$stransition |
1760 |
|
ON evenement.evenement = transition.evenement |
1761 |
|
JOIN %1$sdossier |
1762 |
|
ON lien_dossier_instruction_type_evenement.dossier_instruction_type = dossier.dossier_instruction_type |
1763 |
|
AND transition.etat = dossier.etat |
1764 |
|
-- Jointures avec une sous requêtes servant à récupérer la liste des évènements suggérés du dossier. |
1765 |
|
LEFT JOIN ( |
1766 |
|
SELECT |
1767 |
|
lien_sig_contrainte_evenement.evenement, |
1768 |
|
dossier.dossier |
1769 |
|
FROM |
1770 |
|
%1$slien_sig_contrainte_evenement |
1771 |
|
JOIN %1$ssig_contrainte |
1772 |
|
ON lien_sig_contrainte_evenement.sig_contrainte = sig_contrainte.sig_contrainte |
1773 |
|
JOIN %1$slien_sig_contrainte_dossier_instruction_type |
1774 |
|
ON sig_contrainte.sig_contrainte = lien_sig_contrainte_dossier_instruction_type.sig_contrainte |
1775 |
|
JOIN %1$slien_sig_contrainte_om_collectivite |
1776 |
|
ON sig_contrainte.sig_contrainte = lien_sig_contrainte_om_collectivite.sig_contrainte |
1777 |
|
JOIN %1$scontrainte |
1778 |
|
ON sig_contrainte.libelle = contrainte.libelle |
1779 |
|
JOIN %1$sdossier_contrainte |
1780 |
|
ON contrainte.contrainte = dossier_contrainte.contrainte |
1781 |
|
JOIN %1$sdossier |
1782 |
|
ON dossier_contrainte.dossier = dossier.dossier |
1783 |
|
AND lien_sig_contrainte_dossier_instruction_type.dossier_instruction_type = dossier.dossier_instruction_type |
1784 |
|
JOIN %1$som_collectivite |
1785 |
|
ON lien_sig_contrainte_om_collectivite.om_collectivite = om_collectivite.om_collectivite |
1786 |
|
AND (dossier.om_collectivite = om_collectivite.om_collectivite |
1787 |
|
OR om_collectivite.niveau = \'2\') |
1788 |
|
) AS evenement_suggere_dossier |
1789 |
|
ON evenement.evenement = evenement_suggere_dossier.evenement |
1790 |
|
AND dossier.dossier = evenement_suggere_dossier.dossier |
1791 |
|
WHERE |
1792 |
|
dossier.dossier = \'%2$s\' |
1793 |
|
%3$s |
1794 |
|
ORDER BY |
1795 |
|
is_suggested DESC, |
1796 |
|
evenement.libelle', |
1797 |
|
DB_PREFIXE, |
1798 |
|
$this->f->db->escapeSimple($dossier), |
1799 |
|
$filter |
1800 |
|
), |
1801 |
|
array( |
1802 |
|
"origin" => __METHOD__ |
1803 |
|
) |
1804 |
|
); |
1805 |
|
return $qres['result']; |
1806 |
|
} |
1807 |
|
|
1808 |
|
/** |
1809 |
|
* Récupère un tableau contenant des évènements de la forme : |
1810 |
|
* $events = array( |
1811 |
|
* 1 => array( |
1812 |
|
* 'libelle' => 'evenement_libelle', |
1813 |
|
* 'evenement' => 'identifiant_evenement', |
1814 |
|
* 'is_suggested' => true/false -> booleen indiquant si c'est un événement suggéré |
1815 |
|
* )) |
1816 |
|
* Et le transforme pour pouvoir l'utiliser pour le remplissage d'un select de formulaire. |
1817 |
|
* |
1818 |
|
* Le format de sorti est le suivant : |
1819 |
|
* $select = array( |
1820 |
|
* 0 => array( -> liste des id des événements |
1821 |
|
* '0' => '', |
1822 |
|
* '1' => array( |
1823 |
|
* '0' => array(), -> liste des id des événements suggérés |
1824 |
|
* '1' => array(), -> liste des libelles des événements suggérés |
1825 |
|
* ), |
1826 |
|
* ..., |
1827 |
|
* n => 'id_evenement_n' |
1828 |
|
* ), |
1829 |
|
* 1 => array( |
1830 |
|
* '0' => '__('choisir')." ".__('evenement')', |
1831 |
|
* '1' => '💡 Suggestions', |
1832 |
|
* ..., |
1833 |
|
* 'n' => 'libelle_evenement_n', |
1834 |
|
* ) |
1835 |
|
* ) |
1836 |
|
* |
1837 |
|
* @param array tableau des événements |
1838 |
|
* @return array |
1839 |
|
*/ |
1840 |
|
protected function convert_events_array_to_select_format($events) { |
1841 |
|
// Remplissage du tableau du select en incluant le groupe des instructions suggérées. |
1842 |
|
$contenu = array( |
1843 |
|
0 => array("",), |
1844 |
|
1 => array(__('choisir')." ".__('evenement'),) |
1845 |
|
); |
1846 |
|
|
1847 |
|
if (! empty($events)) { |
1848 |
|
// S'il y a des évènements suggérés extraction de ces événements et mise en place du groupe |
1849 |
|
$suggested_event_group = array_filter($events, function($a) { |
1850 |
|
return $a['is_suggested'] === 't'; |
1851 |
|
}); |
1852 |
|
if (! empty($suggested_event_group)) { |
1853 |
|
// Prépare les données qui permettront d'afficher le groupe des événements |
1854 |
|
// suggérés. |
1855 |
|
$values = array(); |
1856 |
|
$labels = array(); |
1857 |
|
foreach ($suggested_event_group as $index => $suggested_event) { |
1858 |
|
$values[] = $suggested_event['evenement']; |
1859 |
|
$labels[] = $suggested_event['libelle']; |
1860 |
|
// Supprime les évènements suggérés de la liste des évènements |
1861 |
|
unset($events[$index]); |
1862 |
|
} |
1863 |
|
// Remplissage du select pour le groupe |
1864 |
|
$contenu[0][] = array($values, $labels); |
1865 |
|
$contenu[1][] = __('💡 Suggestions'); |
1866 |
|
} |
1867 |
|
|
1868 |
|
// Remplissage du select |
1869 |
|
foreach ($events as $event) { |
1870 |
|
$contenu[0][] = $event['evenement']; |
1871 |
|
$contenu[1][] = $event['libelle']; |
1872 |
|
} |
1873 |
|
} |
1874 |
|
return $contenu; |
1875 |
|
} |
1876 |
|
|
1877 |
|
/** |
1878 |
* SETTER_FORM - setSelect. |
* SETTER_FORM - setSelect. |
1879 |
* |
* |
1880 |
* @return void |
* @return void |
1952 |
* événements disponibles. |
* événements disponibles. |
1953 |
*/ |
*/ |
1954 |
if ($maj == 0) { |
if ($maj == 0) { |
1955 |
// Récupération des événements par une jointure entre la table dossier |
$evenements = $this->get_var_sql_forminc__sql_evenement(); |
1956 |
// et la table transition et la table evenement et la table |
$form->setSelect("evenement", $this->convert_events_array_to_select_format($evenements)); |
|
// lien_dossier_instruction_type_evenement en fonction de l'identifiant |
|
|
// du dossier d'instruction en cours |
|
|
$sql = "SELECT |
|
|
evenement.evenement, |
|
|
evenement.libelle as lib |
|
|
FROM ".DB_PREFIXE."dossier |
|
|
INNER JOIN ".DB_PREFIXE."lien_dossier_instruction_type_evenement |
|
|
ON dossier.dossier_instruction_type=lien_dossier_instruction_type_evenement.dossier_instruction_type |
|
|
INNER JOIN ".DB_PREFIXE."evenement |
|
|
ON evenement.evenement=lien_dossier_instruction_type_evenement.evenement |
|
|
INNER JOIN ".DB_PREFIXE."transition |
|
|
ON evenement.evenement = transition.evenement |
|
|
AND dossier.etat=transition.etat |
|
|
WHERE dossier.dossier='".$this->getParameter("idxformulaire")."' "; |
|
|
|
|
|
// Si changement de décision par instructeur commune |
|
|
if($this->f->isUserInstructeur() === true |
|
|
&& $this->getDivisionFromDossier($this->getParameter("idxformulaire")) != $_SESSION["division"] |
|
|
&& $this->isInstrCanChangeDecision($this->getParameter("idxformulaire")) === true) { |
|
|
$sql .= "AND evenement.type IN ('arrete', 'changement_decision') "; |
|
|
} |
|
|
$sql .= "ORDER BY evenement.libelle, evenement.action"; |
|
|
$res = $this->f->db->query($sql); |
|
|
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
|
|
$this->f->isDatabaseError($res); |
|
|
// Remplissage du tableau du select |
|
|
$contenu = array( |
|
|
0 => array("",), |
|
|
1 => array(_('choisir')." "._('evenement'),) |
|
|
); |
|
|
while ($row=& $res->fetchRow()) { |
|
|
$contenu[0][] = $row[0]; |
|
|
$contenu[1][] = $row[1]; |
|
|
} |
|
|
$form->setSelect("evenement", $contenu); |
|
|
|
|
1957 |
} else { |
} else { |
1958 |
$sql = "SELECT |
// Instanciation de l'événement pour récupérer son libellé |
1959 |
evenement.libelle as lib |
$evenement = $this->f->get_inst__om_dbform(array( |
1960 |
FROM ".DB_PREFIXE."evenement |
"obj" => "evenement", |
1961 |
WHERE evenement.evenement=".$this->getVal("evenement").""; |
"idx" => $this->getVal("evenement"), |
1962 |
$res = $this->f->db->getone($sql); |
)); |
1963 |
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
|
|
$this->f->isDatabaseError($res); |
|
|
// |
|
1964 |
$contenu = array( |
$contenu = array( |
1965 |
0 => array($this->getVal("evenement"),), |
0 => array($this->getVal("evenement"),), |
1966 |
1 => array($res,) |
1 => array($evenement->getVal('libelle'),) |
1967 |
); |
); |
1968 |
$form->setSelect("evenement", $contenu); |
$form->setSelect("evenement", $contenu); |
1969 |
} |
} |
2011 |
|
|
2012 |
|
|
2013 |
if ($maj == 401) { |
if ($maj == 401) { |
2014 |
$file = $this->f->storage->get($this->getVal('om_fichier_instruction')); |
$idx = $this->getParameter("idx"); |
2015 |
|
$dossier = $this->getParameter("idxformulaire"); |
2016 |
|
if ( strpos($idx, 'STORAGE_') !== FALSE) { |
2017 |
|
$idx = substr($idx, 8); |
2018 |
|
$model = 'storage'; |
2019 |
|
$champ = 'uid'; |
2020 |
|
$object = $this->f->get_inst__om_dbform(array( |
2021 |
|
"obj" => $model, |
2022 |
|
"idx" => $idx, |
2023 |
|
)); |
2024 |
|
|
2025 |
|
$file = $this->f->storage->get($object->getVal($champ)); |
2026 |
|
$label = $file['metadata']['filename']; |
2027 |
|
$href =sprintf( |
2028 |
|
'../app/index.php?module=form&snippet=file&obj=storage&champ=uid&id=%1$s', |
2029 |
|
$idx |
2030 |
|
); |
2031 |
|
$this->addToLog(__METHOD__."(): file['metadata']['filename'] = ".$file['metadata']['filename']." ", DEBUG_MODE); |
2032 |
|
$this->val['preview_edition'] = ''; |
2033 |
|
}else{ |
2034 |
|
$label ='instruction_'.$this->getVal($this->clePrimaire); |
2035 |
|
$href =sprintf( |
2036 |
|
'../app/index.php?module=form&snippet=file&obj=instruction&champ=om_fichier_instruction&id=%1$s', |
2037 |
|
$this->getVal($this->clePrimaire) |
2038 |
|
); |
2039 |
|
$file = $this->f->storage->get($this->getVal('om_fichier_instruction')); |
2040 |
|
} |
2041 |
|
|
2042 |
$form->setSelect('preview_edition', array( |
$form->setSelect('preview_edition', array( |
2043 |
'base64' => base64_encode($file['file_content']), |
'base64' => base64_encode($file['file_content']), |
2044 |
'mimetype' => $file['metadata']['mimetype'], |
'mimetype' => $file['metadata']['mimetype'], |
2045 |
'label' => 'instruction_'.$this->getVal($this->clePrimaire), |
'label' => $label, |
2046 |
'href' => sprintf( |
'href' => $href |
|
'../app/index.php?module=form&snippet=file&obj=instruction&champ=om_fichier_instruction&id=%1$s', |
|
|
$this->getVal($this->clePrimaire) |
|
|
) |
|
2047 |
)); |
)); |
2048 |
} |
} |
2049 |
} |
} |
2055 |
|
|
2056 |
$id = $this->getVal($this->clePrimaire); |
$id = $this->getVal($this->clePrimaire); |
2057 |
|
|
|
|
|
2058 |
//Requête de vérification que cet événement d'instruction n'est pas lié |
//Requête de vérification que cet événement d'instruction n'est pas lié |
2059 |
//à la création d'un dossier d'instruction |
//à la création d'un dossier d'instruction |
2060 |
$sql = "SELECT demande_type.dossier_instruction_type |
$qres = $this->f->get_one_result_from_db_query( |
2061 |
FROM ".DB_PREFIXE."demande_type |
sprintf( |
2062 |
LEFT JOIN ".DB_PREFIXE."demande |
'SELECT |
2063 |
ON demande.demande_type = demande_type.demande_type |
demande_type.dossier_instruction_type |
2064 |
WHERE demande.instruction_recepisse = ".$id; |
FROM |
2065 |
$res = $this->f->db->getone($sql); |
%1$sdemande_type |
2066 |
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
LEFT JOIN %1$sdemande |
2067 |
$this->f->isDatabaseError($res); |
ON demande.demande_type = demande_type.demande_type |
2068 |
|
WHERE |
2069 |
|
demande.instruction_recepisse = \'%2$d\'', |
2070 |
|
DB_PREFIXE, |
2071 |
|
intval($id) |
2072 |
|
), |
2073 |
|
array( |
2074 |
|
"origin" => __METHOD__, |
2075 |
|
) |
2076 |
|
); |
2077 |
|
|
2078 |
// Aucune clé secondaire n'a été trouvée ou c'est un événement sans |
// Aucune clé secondaire n'a été trouvée ou c'est un événement sans |
2079 |
//création de dossier d'instruction, l'événement d'instruction peut être |
//création de dossier d'instruction, l'événement d'instruction peut être |
2080 |
//supprimé |
//supprimé |
2081 |
if ( $this->correct !== false || $res == null || $res == ""){ |
if ( $this->correct !== false || $qres['result'] == null || $qres['result'] == ""){ |
|
|
|
2082 |
// Requête de vérification que cet événement d'instruction est lié |
// Requête de vérification que cet événement d'instruction est lié |
2083 |
// à une demande |
// à une demande |
2084 |
$sql = "SELECT demande |
$qres = $this->f->get_one_result_from_db_query( |
2085 |
FROM ".DB_PREFIXE."demande |
sprintf( |
2086 |
WHERE instruction_recepisse = ".$id; |
'SELECT |
2087 |
$res = $this->f->db->getone($sql); |
demande |
2088 |
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
FROM |
2089 |
$this->f->isDatabaseError($res); |
%1$sdemande |
2090 |
|
WHERE |
2091 |
|
instruction_recepisse = \'%2$d\'', |
2092 |
|
DB_PREFIXE, |
2093 |
|
intval($id) |
2094 |
|
), |
2095 |
|
array( |
2096 |
|
"origin" => __METHOD__, |
2097 |
|
) |
2098 |
|
); |
2099 |
|
|
2100 |
//Si c'est un événement d'instruction lié à une demande |
//Si c'est un événement d'instruction lié à une demande |
2101 |
if ($res != null || $res != ""){ |
if ($qres['result'] != null || $qres['result'] != ""){ |
2102 |
$demande = $this->f->get_inst__om_dbform(array( |
$demande = $this->f->get_inst__om_dbform(array( |
2103 |
"obj" => "demande", |
"obj" => "demande", |
2104 |
"idx" => $res, |
"idx" => $qres['result'], |
2105 |
)); |
)); |
2106 |
|
|
2107 |
//On met à jour la demande en supprimant la liaison vers |
//On met à jour la demande en supprimant la liaison vers |
2108 |
//l'événement d'instruction |
//l'événement d'instruction |
2109 |
$demande->setParameter("maj", 1); |
$demande->setParameter("maj", 1); |
2110 |
$valF = array(); |
$valF = array(); |
2120 |
* Vérification que l'élément supprimé est le dernier pour pouvoir |
* Vérification que l'élément supprimé est le dernier pour pouvoir |
2121 |
* remodifier les données de manière itérative. |
* remodifier les données de manière itérative. |
2122 |
*/ |
*/ |
2123 |
// Initialisation |
$qres = $this->f->get_one_result_from_db_query( |
2124 |
$dernierevenement = ""; |
sprintf( |
2125 |
// Récupération du dernier élément de la table d'instruction qui |
'SELECT |
2126 |
// concerne le dossier en cours |
max(instruction) |
2127 |
$sql = "SELECT max(instruction) |
FROM |
2128 |
FROM ".DB_PREFIXE."instruction |
%1$sinstruction |
2129 |
WHERE dossier ='".$this->getParameter("idxformulaire")."'"; |
WHERE |
2130 |
$dernierevenement = $this->f->db->getone($sql); |
dossier = \'%2$s\'', |
2131 |
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
DB_PREFIXE, |
2132 |
$this->f->isDatabaseError($dernierevenement); |
$this->f->db->escapeSimple($this->getParameter("idxformulaire")) |
2133 |
|
), |
2134 |
|
array( |
2135 |
|
"origin" => __METHOD__, |
2136 |
|
) |
2137 |
|
); |
2138 |
|
|
2139 |
// Si on se trouve effectivement sur le dernier evenement d'instruction |
// Si on se trouve effectivement sur le dernier evenement d'instruction |
2140 |
if ($dernierevenement == $id) { |
// alors on valide la suppression sinon on l'annule |
2141 |
|
$this->correct = false; |
2142 |
|
$message = __("Seul le dernier evenement d'instruction peut etre supprime."); |
2143 |
|
if ($qres['result'] == $id) { |
2144 |
// Alors on valide la suppression |
// Alors on valide la suppression |
2145 |
$this->correct = true; |
$this->correct = true; |
2146 |
$this->addToMessage(_('Destruction_chronologique')); |
$message = __('Destruction_chronologique'); |
|
} else { |
|
|
// Alors on annule la suppression |
|
|
$this->correct = false; |
|
|
$this->addToMessage(_("Seul le dernier evenement d'instruction peut etre supprime.")); |
|
2147 |
} |
} |
2148 |
|
$this->addToMessage($message); |
2149 |
} |
} |
2150 |
} |
} |
2151 |
|
|
2163 |
if($this->valF[$champ] != "" AND !$this->f->user_is_admin) { |
if($this->valF[$champ] != "" AND !$this->f->user_is_admin) { |
2164 |
// si l'utilisateur n'est pas un admin |
// si l'utilisateur n'est pas un admin |
2165 |
if($this->getVal($champ) != "" AND $this->getVal($champ) != $this->valF[$champ]) { |
if($this->getVal($champ) != "" AND $this->getVal($champ) != $this->valF[$champ]) { |
2166 |
$this->correct = false; |
|
2167 |
$this->addToMessage(_("Les dates de suivis ne peuvent etre modifiees")); |
// si le champ concerné est 'date_envoi_signature' |
2168 |
|
// et que le statut du parapheur est 'expired' |
2169 |
|
// alors on autorise le changement de la date |
2170 |
|
// pour tous les autres cas, on ne peut modifier la date |
2171 |
|
if ($champ !== 'date_envoi_signature' || $this->getVal('statut_signature') !== 'expired') { |
2172 |
|
$this->correct = false; |
2173 |
|
$this->addToMessage(_("Les dates de suivis ne peuvent etre modifiees")); |
2174 |
|
} |
2175 |
} |
} |
2176 |
} |
} |
2177 |
} |
} |
2186 |
* @return void |
* @return void |
2187 |
*/ |
*/ |
2188 |
function setValsousformulaire(&$form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire, &$dnu1 = null, $dnu2 = null) { |
function setValsousformulaire(&$form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire, &$dnu1 = null, $dnu2 = null) { |
2189 |
|
$data = array('form' => &$form, 'maj' => &$maj, 'validation' => &$validation, 'idxformulaire' => &$idxformulaire, 'retourformulaire' => &$retourformulaire, 'typeformulaire' => &$typeformulaire); |
2190 |
|
$this->f->module_manager->run_hooks('setValsousformulaire_pre', $this, $data); |
2191 |
|
|
2192 |
// parent::setValsousformulaire($form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire); |
// parent::setValsousformulaire($form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire); |
2193 |
// |
// |
2194 |
$this->retourformulaire = $retourformulaire; |
$this->retourformulaire = $retourformulaire; |
2208 |
} |
} |
2209 |
// |
// |
2210 |
$this->set_form_default_values($form, $maj, $validation); |
$this->set_form_default_values($form, $maj, $validation); |
2211 |
|
|
2212 |
|
$data = array('form' => &$form, 'maj' => &$maj, 'validation' => &$validation, 'idxformulaire' => &$idxformulaire, 'retourformulaire' => &$retourformulaire, 'typeformulaire' => &$typeformulaire); |
2213 |
|
$this->f->module_manager->run_hooks('setValsousformulaire_post', $this, $data); |
2214 |
} |
} |
2215 |
|
|
2216 |
/** |
/** |
2219 |
* @return void |
* @return void |
2220 |
*/ |
*/ |
2221 |
function set_form_default_values(&$form, $maj, $validation) { |
function set_form_default_values(&$form, $maj, $validation) { |
2222 |
// |
$data = array('form' => &$form, 'maj' => &$maj, 'validation' => &$validation); |
2223 |
|
$this->f->module_manager->run_hooks('set_form_default_values_pre', $this, $data); |
2224 |
|
|
2225 |
if ($maj == 0) { |
if ($maj == 0) { |
2226 |
// si contexte DI |
// si contexte DI |
2227 |
if ($this->getParameter("retourformulaire") == "dossier" |
if ($this->getParameter("retourformulaire") == "dossier" |
2239 |
} else { |
} else { |
2240 |
$sql = $this->get_var_sql_forminc__sql("signataire_arrete_defaut"); |
$sql = $this->get_var_sql_forminc__sql("signataire_arrete_defaut"); |
2241 |
} |
} |
2242 |
$res = $this->f->db->query($sql); |
|
2243 |
$this->f->addToLog(__METHOD__."(): db->query(\"".$sql."\")", VERBOSE_MODE); |
$qres = $this->f->get_all_results_from_db_query($sql, array( |
2244 |
$this->f->isDatabaseError($res); |
"origin" => __METHOD__)); |
2245 |
$row = $res->fetchrow(DB_FETCHMODE_ASSOC); |
$row = array_shift($qres['result']); |
2246 |
if (isset($row["signataire_arrete"]) |
if (isset($row["signataire_arrete"]) |
2247 |
&& is_numeric($row["signataire_arrete"])) { |
&& is_numeric($row["signataire_arrete"])) { |
2248 |
// |
// |
2259 |
$form->setVal("bible3", "bible(3)"); |
$form->setVal("bible3", "bible(3)"); |
2260 |
$form->setVal("bible4", "bible(4)"); |
$form->setVal("bible4", "bible(4)"); |
2261 |
} |
} |
2262 |
// |
// TODO à faire autrement car ça génère une requête à chaque fois, plus l'instanciation du dossier d'instruction et donc de ses modules ! |
2263 |
$collectivite_di = $this->get_dossier_instruction_om_collectivite(); |
$collectivite_di = $this->get_dossier_instruction_om_collectivite(); |
2264 |
if ($maj == 1 |
if ($maj == 1 |
2265 |
&& $this->f->is_option_preview_pdf_enabled($collectivite_di) === true |
&& $this->f->is_option_preview_pdf_enabled($collectivite_di) === true |
2291 |
if ($this->can_display_notification_commune()) { |
if ($this->can_display_notification_commune()) { |
2292 |
$form->setVal("suivi_notification_commune", $this->get_json_suivi_notification(array('notification_depot_demat', 'notification_commune'))); |
$form->setVal("suivi_notification_commune", $this->get_json_suivi_notification(array('notification_depot_demat', 'notification_commune'))); |
2293 |
} |
} |
2294 |
|
if ($this->getVal('flag_edition_integrale') == 't') { |
2295 |
|
$message = __("Aucun contenu à afficher."); |
2296 |
|
if (empty($this->getVal('titre_om_htmletat'))) { |
2297 |
|
$form->setVal("titre_om_htmletat", $message); |
2298 |
|
} |
2299 |
|
if (empty($this->getVal('corps_om_htmletatex'))) { |
2300 |
|
$form->setVal("corps_om_htmletatex", $message); |
2301 |
|
} |
2302 |
|
} |
2303 |
} |
} |
2304 |
|
$data = array('form' => &$form, 'maj' => &$maj, 'validation' => &$validation); |
2305 |
|
$this->f->module_manager->run_hooks('set_form_default_values_post', $this, $data); |
2306 |
} |
} |
2307 |
|
|
2308 |
function setLayout(&$form, $maj){ |
function setLayout(&$form, $maj){ |
2309 |
// En consultation, pour les dossiers qui n'ont pas été transmis par le portail |
$data = array('form' => &$form, 'maj' => &$maj); |
2310 |
// citoyen, si la notification des demandeurs est activée sur l'évenement |
$this->f->module_manager->run_hooks('setLayout_pre', $this, $data); |
2311 |
// d'instruction et que le paramétrage du demandeur principal n'est pas |
|
|
// correct alors un message a destination de l'instructeur est affiché. |
|
|
if ($maj == 3) { |
|
|
// Si le dossier n'a pas été déposé sur le portail citoyen (ou si |
|
|
// la requête permettant de savoir le type de demande à échouée) et si |
|
|
// la notification se fait par mail vérifie si il y a des erreurs de |
|
|
// paramétrage et si c'est le cas on affiche un message d'information |
|
|
$collectivite = $this->get_dossier_instruction_om_collectivite($this->getVal('dossier')); |
|
|
$categorieNotif = $this->f->get_param_option_notification($collectivite); |
|
|
if (($this->dossier_depose_sur_portail() == null || |
|
|
! $this->dossier_depose_sur_portail()) && |
|
|
(! empty($categorieNotif) || |
|
|
$categorieNotif == 'mail')) { |
|
|
$erreurParam = $this->get_info_notification_fail(); |
|
|
// Récupération de l'évenement d'instruction |
|
|
$instEV = $this->get_inst_evenement(); |
|
|
if (! empty($instEV->getVal('notification')) && $erreurParam != array()) { |
|
|
$class = 'text-info ui-state-highlight ui-state-info'; |
|
|
$message = __("Attention l'envoi de notification automatique n'est pas possible."); |
|
|
$this->f->display_panel_information( |
|
|
$class, |
|
|
$message, |
|
|
$erreurParam, |
|
|
__('Veuillez corriger les informations suivantes.'), |
|
|
'erreur_param_notif' |
|
|
); |
|
|
} |
|
|
} |
|
|
} |
|
2312 |
$form->setBloc('evenement','D',"","sousform-instruction-action-".$maj); |
$form->setBloc('evenement','D',"","sousform-instruction-action-".$maj); |
2313 |
|
|
2314 |
$form->setFieldset('evenement','D',_('Evenement')); |
$form->setFieldset('evenement','D',_('Evenement')); |
2315 |
$form->setFieldset('om_final_instruction_utilisateur','F',''); |
$form->setFieldset('om_final_instruction_utilisateur','F',''); |
2316 |
|
|
2317 |
$form->setBloc('om_final_instruction_utilisateur','F'); |
$form->setBloc('om_final_instruction_utilisateur','F'); |
2318 |
|
// Idem que pour le layout de la synthèse des DI, on est obligé de "casser" le setBloc en utilisant que la fin |
2319 |
|
// afin de bypasser le fait de ne pas avoir le form-content et le portlet dans le meme container |
2320 |
|
$form->setBloc('om_final_instruction_utilisateur','F'); |
2321 |
|
$form->setBloc('parapheur_lien_page_signature','D'); |
2322 |
|
|
2323 |
$form->setBloc('date_finalisation_courrier','D',"",""); |
$form->setBloc('date_finalisation_courrier','D',"",""); |
2324 |
|
|
2325 |
$form->setFieldset('date_finalisation_courrier','D',_('Dates')); |
$form->setFieldset('date_finalisation_courrier','D',_('Dates'),"instruction--suivi-dates"); |
2326 |
$form->setBloc('date_finalisation_courrier','D',"","col_6"); |
$form->setBloc('date_finalisation_courrier','D'); |
2327 |
$form->setBloc('date_envoi_controle_legalite','F'); |
$form->setBloc('date_envoi_rar','F'); |
2328 |
|
|
2329 |
$form->setBloc('date_retour_signature','D',"","col_6"); |
$form->setBloc('date_retour_rar','D'); |
2330 |
$form->setBloc('date_retour_controle_legalite','F'); |
$form->setBloc('date_retour_controle_legalite','F'); |
2331 |
$form->setFieldset('date_retour_controle_legalite','F',''); |
$form->setFieldset('date_retour_controle_legalite','F',''); |
2332 |
|
|
2407 |
$form->setFieldset('corps_om_htmletatex','DF',_('Corps')); |
$form->setFieldset('corps_om_htmletatex','DF',_('Corps')); |
2408 |
$form->setBloc('corps_om_htmletatex','F'); |
$form->setBloc('corps_om_htmletatex','F'); |
2409 |
} |
} |
2410 |
|
$data = array('form' => &$form, 'maj' => &$maj); |
2411 |
|
$this->f->module_manager->run_hooks('setLayout_post', $this, $data); |
2412 |
} |
} |
2413 |
|
|
2414 |
function setLib(&$form, $maj) { |
function setLib(&$form, $maj) { |
2415 |
|
$data = array('form' => &$form, 'maj' => &$maj); |
2416 |
|
$this->f->module_manager->run_hooks('setLib_pre', $this, $data); |
2417 |
// |
// |
2418 |
parent::setLib($form, $maj); |
parent::setLib($form, $maj); |
2419 |
// |
// |
2462 |
$form->setLib('date_evenement', sprintf($help_text_template, _('date_evenement'), $help_text)); |
$form->setLib('date_evenement', sprintf($help_text_template, _('date_evenement'), $help_text)); |
2463 |
$form->setLib('signataire_arrete', sprintf($help_text_template, _('signataire_arrete'), $help_text)); |
$form->setLib('signataire_arrete', sprintf($help_text_template, _('signataire_arrete'), $help_text)); |
2464 |
} |
} |
2465 |
|
$data = array('form' => &$form, 'maj' => &$maj); |
2466 |
|
$this->f->module_manager->run_hooks('setLib_post', $this, $data); |
2467 |
|
} |
2468 |
|
|
2469 |
|
/** |
2470 |
|
* Surcharge om_dbform::set_form_specificity() |
2471 |
|
* |
2472 |
|
* Traitements spécifiques lié à l'affichage des formulaires. |
2473 |
|
* Les traitements gérés ici sont les suivants : |
2474 |
|
* - Affichage d'un message d'erreur si la lettretype de l'évènement n'a pas |
2475 |
|
* pu être récupérée. |
2476 |
|
* - Affichage d'un message d'information à l'attention de l'utilisateur si |
2477 |
|
* la notification est activée mais qu'elle n'est pas possible à cause du |
2478 |
|
* paramètrage. |
2479 |
|
* |
2480 |
|
* @param formulaire $form Instance formulaire. |
2481 |
|
* @param string $maj |
2482 |
|
* |
2483 |
|
* @return void |
2484 |
|
*/ |
2485 |
|
function set_form_specificity(&$form, $maj) { |
2486 |
|
parent::set_form_specificity($form, $maj); |
2487 |
|
|
2488 |
|
// En consultation, vérifie si une lettretype est associée à l'instruction et a pu être récupérée. |
2489 |
|
// Si ce n'est pas le cas affiche un message d'erreur. |
2490 |
|
if ((! empty($maj) && $maj == 3)) { |
2491 |
|
if (! empty($this->getVal('lettretype'))) { |
2492 |
|
|
2493 |
|
$om_edition = $this->f->get_inst__om_edition(); |
2494 |
|
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
2495 |
|
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
2496 |
|
$edition = $om_edition->get_edition_from_collectivite('om_lettretype', $this->getVal("lettretype"), $collectivite['om_collectivite_idx']); |
2497 |
|
|
2498 |
|
if (empty($edition)) { |
2499 |
|
$this->display_error_message(__("Erreur de paramétrage, le modèle de document n'a pas pu être récupéré. Contactez votre administrateur.")); |
2500 |
|
} |
2501 |
|
} |
2502 |
|
} |
2503 |
|
|
2504 |
|
$this->display_notification_info($maj); |
2505 |
|
} |
2506 |
|
|
2507 |
|
/** |
2508 |
|
* En consultation, pour les dossiers qui n'ont pas été transmis par le portail |
2509 |
|
* citoyen, si la notification des demandeurs est activée sur l'évenement |
2510 |
|
* d'instruction et que le paramétrage du demandeur principal n'est pas |
2511 |
|
* correct alors un message a destination de l'instructeur est affiché. |
2512 |
|
* |
2513 |
|
* @param string $maj |
2514 |
|
* |
2515 |
|
* @return void |
2516 |
|
*/ |
2517 |
|
public function display_notification_info($maj) { |
2518 |
|
if ((! empty($maj) && $maj == 3)) { |
2519 |
|
// Si le dossier n'a pas été déposé sur le portail citoyen (ou si |
2520 |
|
// la requête permettant de savoir le type de demande à échouée) et si |
2521 |
|
// la notification se fait par mail vérifie si il y a des erreurs de |
2522 |
|
// paramétrage et si c'est le cas on affiche un message d'information |
2523 |
|
if ($this->dossier_depose_sur_portail() == null || ! $this->dossier_depose_sur_portail()) { |
2524 |
|
$erreurParam = $this->get_info_notification_fail(); |
2525 |
|
// Récupération de l'évenement d'instruction |
2526 |
|
$instEV = $this->get_inst_evenement(); |
2527 |
|
if (! empty($instEV->getVal('notification')) && $erreurParam != array()) { |
2528 |
|
$class = 'text-info ui-state-highlight ui-state-info'; |
2529 |
|
$message = __("La notification n'est pas possible."); |
2530 |
|
$this->f->display_panel_information( |
2531 |
|
$class, |
2532 |
|
$message, |
2533 |
|
$erreurParam, |
2534 |
|
__('Les données suivantes doivent être modifiées'), |
2535 |
|
'erreur_param_notif' |
2536 |
|
); |
2537 |
|
} |
2538 |
|
} |
2539 |
|
} |
2540 |
|
} |
2541 |
|
|
2542 |
|
/** |
2543 |
|
* Méthode permettant d'afficher des messages d'erreur sur les formulaires. |
2544 |
|
*/ |
2545 |
|
public function display_error_message($msg) { |
2546 |
|
$this->correct = false; |
2547 |
|
$this->msg = $msg; |
2548 |
} |
} |
2549 |
|
|
2550 |
/** |
/** |
2551 |
* TRIGGER - triggerajouter. |
* TRIGGER - triggerajouter. |
2552 |
|
* Réalise différents traitements avant d'ajouter l'instruction en base. |
2553 |
|
* |
2554 |
|
* Les traitements réalisés sont les suivant : |
2555 |
|
* - TODO : documenter les traietements existant |
2556 |
|
* - Intégre les bibles pré-chargé aux compléments de l'instruction. |
2557 |
|
* Ce traitement n'est déclenché que si l'on est pas en rédaction libre, et que l'évènement a une lettretype. |
2558 |
* |
* |
2559 |
* @return boolean |
* @return boolean |
2560 |
*/ |
*/ |
2561 |
function triggerajouter($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
function triggerajouter($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
2562 |
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
2563 |
|
$data = array('val' => &$val, 'id' => $id); |
2564 |
|
$this->f->module_manager->run_hooks('triggerajouter_pre', $this, $data); |
2565 |
/** |
/** |
2566 |
* Le code suivant permet de récupérer des valeurs des tables evenement |
* Le code suivant permet de récupérer des valeurs des tables evenement |
2567 |
* et dossier pour les stocker dans l'instruction : |
* et dossier pour les stocker dans l'instruction : |
2597 |
* - avis_decision |
* - avis_decision |
2598 |
*/ |
*/ |
2599 |
// Récupération de tous les paramètres de l'événement sélectionné |
// Récupération de tous les paramètres de l'événement sélectionné |
2600 |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
// TODO : remplacer cette requête par l'instanciation de l'événement |
2601 |
WHERE evenement=".$this->valF['evenement']; |
$qres = $this->f->get_all_results_from_db_query( |
2602 |
$res = $this->f->db->query($sql); |
sprintf( |
2603 |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
'SELECT |
2604 |
$this->f->isDatabaseError($res); |
* |
2605 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
FROM |
2606 |
|
%1$sevenement |
2607 |
|
WHERE |
2608 |
|
evenement = %2$d', |
2609 |
|
DB_PREFIXE, |
2610 |
|
intval($this->valF['evenement']) |
2611 |
|
), |
2612 |
|
array( |
2613 |
|
"origin" => __METHOD__, |
2614 |
|
) |
2615 |
|
); |
2616 |
|
foreach ($qres['result'] as $row) { |
2617 |
// Récupération de l'identifiant de l'action |
// Récupération de l'identifiant de l'action |
2618 |
// si une action est paramétrée dans l'événement |
// si une action est paramétrée dans l'événement |
2619 |
$this->valF['action'] = NULL; |
$this->valF['action'] = NULL; |
2654 |
} |
} |
2655 |
} |
} |
2656 |
// Récupération de toutes les valeurs du dossier d'instruction en cours |
// Récupération de toutes les valeurs du dossier d'instruction en cours |
2657 |
$sql = "SELECT * FROM ".DB_PREFIXE."dossier |
// TODO : remplacer cette requête par l'instanciation de l'objet |
2658 |
WHERE dossier='".$this->valF['dossier']."'"; |
$qres = $this->f->get_all_results_from_db_query( |
2659 |
$res = $this->f->db->query($sql); |
sprintf( |
2660 |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
'SELECT |
2661 |
$this->f->isDatabaseError($res); |
* |
2662 |
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
FROM |
2663 |
|
%1$sdossier |
2664 |
|
WHERE |
2665 |
|
dossier = \'%2$s\'', |
2666 |
|
DB_PREFIXE, |
2667 |
|
$this->f->db->escapeSimple($this->valF['dossier']) |
2668 |
|
), |
2669 |
|
array( |
2670 |
|
"origin" => __METHOD__, |
2671 |
|
) |
2672 |
|
); |
2673 |
|
$row = array_shift($qres['result']); |
2674 |
$this->updateArchiveData($row); |
$this->updateArchiveData($row); |
2675 |
|
|
2676 |
// Récupération de la duree de validite du dossier d'autorisation |
// Récupération de la duree de validite du dossier d'autorisation |
2677 |
$sql = "SELECT duree_validite_parametrage |
$qres = $this->f->get_one_result_from_db_query( |
2678 |
FROM ".DB_PREFIXE."dossier_autorisation_type_detaille |
sprintf( |
2679 |
LEFT JOIN ".DB_PREFIXE."dossier_autorisation |
'SELECT |
2680 |
ON dossier_autorisation.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
duree_validite_parametrage |
2681 |
LEFT JOIN ".DB_PREFIXE."dossier |
FROM |
2682 |
ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
%1$sdossier_autorisation_type_detaille |
2683 |
WHERE dossier.dossier='".$this->valF['dossier']."'"; |
LEFT JOIN %1$sdossier_autorisation |
2684 |
$duree_validite_parametrage = $this->f->db->getone($sql); |
ON dossier_autorisation.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
2685 |
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
LEFT JOIN %1$sdossier |
2686 |
$this->f->isDatabaseError($duree_validite_parametrage); |
ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
2687 |
if ($duree_validite_parametrage != '') { |
WHERE |
2688 |
$this->valF['duree_validite_parametrage']= $duree_validite_parametrage; |
dossier.dossier = \'%2$s\'', |
2689 |
|
DB_PREFIXE, |
2690 |
|
$this->f->db->escapeSimple($this->valF['dossier']) |
2691 |
|
), |
2692 |
|
array( |
2693 |
|
"origin" => __METHOD__, |
2694 |
|
) |
2695 |
|
); |
2696 |
|
|
2697 |
|
if ($qres['result'] != '') { |
2698 |
|
$this->valF['duree_validite_parametrage'] = $qres['result']; |
2699 |
} |
} |
2700 |
|
|
2701 |
// Identifiant du type de courrier |
// Identifiant du type de courrier |
2703 |
$idCourrier = str_pad($this->valF["instruction"], 10, "0", STR_PAD_LEFT); |
$idCourrier = str_pad($this->valF["instruction"], 10, "0", STR_PAD_LEFT); |
2704 |
// Code barres |
// Code barres |
2705 |
$this->valF["code_barres"] = $idTypeCourrier . $idCourrier; |
$this->valF["code_barres"] = $idTypeCourrier . $idCourrier; |
2706 |
|
|
2707 |
|
// Set dans la propriété valF les valeurs des compléments pour qu'ils soient enregistrés |
2708 |
|
// à l'ajout de l'instruction. |
2709 |
|
// Le traitement n'est réalisé que si il y a une lettretype et qu'on est pas en rédaction libre |
2710 |
|
if (! empty($this->valF['lettretype'])) { |
2711 |
|
$this->set_precharge_complement($this->valF['evenement'], $this->valF['dossier']); |
2712 |
|
} |
2713 |
|
|
2714 |
|
$res = true; |
2715 |
|
$data = array('val' => &$val, 'id' => $id, 'result' => &$res); |
2716 |
|
$this->f->module_manager->run_hooks('triggerajouter_post', $this, $data); |
2717 |
|
return $res; |
2718 |
} |
} |
2719 |
|
|
2720 |
|
/** |
2721 |
|
* Récupère pour chaque champ complementX_om_html le complément correspondant |
2722 |
|
* et set l'entrée correspondante de valF avec. |
2723 |
|
* |
2724 |
|
* Problème potentiel : Le nombre de complément se base sur le champs complement ayant |
2725 |
|
* l'indice le plus grand visible dans get_var_sql_forminc__champs(). |
2726 |
|
* Dans cette fonction on fait donc 15 itérations. Changer le nombre de complément |
2727 |
|
* aura donc un impact sur cette méthode. |
2728 |
|
* |
2729 |
|
* @param string dossier : identifiant du dossier de l'instruction |
2730 |
|
* @param int evenement : identifiant de l'évènement d'instruction |
2731 |
|
* |
2732 |
|
* @return void |
2733 |
|
*/ |
2734 |
|
public function set_precharge_complement($evenement, $dossier) { |
2735 |
|
// Récupération des bibles et chargement dans les compléments |
2736 |
|
for ($i = 1; $i <= 15; $i++) { |
2737 |
|
// Constitution de l'id du champs. |
2738 |
|
// Pour l'indice 1, l'id est complement_om_html, l'indice n'est pas visible dans ce cas. |
2739 |
|
$field = "complement".($i === 1 ? '' : $i)."_om_html"; |
2740 |
|
// Récupération des compléments correspondant en fonction de l'évènement |
2741 |
|
// et du dossier puis insertion dans la champs voulu |
2742 |
|
$this->valF[$field] = $this->getBible($evenement, $dossier, $i, 'precharge'); |
2743 |
|
} |
2744 |
|
} |
2745 |
|
|
2746 |
|
|
2747 |
|
|
2748 |
/** |
/** |
2749 |
* Test si une restriction est valide. |
* Test si une restriction est valide. |
2931 |
if(empty($evenement) || !is_numeric($evenement)) { |
if(empty($evenement) || !is_numeric($evenement)) { |
2932 |
return ""; |
return ""; |
2933 |
} |
} |
2934 |
$sql = "SELECT retour |
|
2935 |
FROM ".DB_PREFIXE."evenement |
$evenement = $this->f->get_inst__om_dbform(array( |
2936 |
WHERE evenement = ".$evenement; |
"obj" => "evenement", |
2937 |
$retour = $this->f->db->getone($sql); |
"idx" => $evenement, |
2938 |
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
)); |
2939 |
$this->f->isDatabaseError($retour); |
|
2940 |
if ($retour == 't') { |
return $evenement->getVal('retour') == 't'; |
|
return true; |
|
|
} else { |
|
|
return false; |
|
|
} |
|
2941 |
} |
} |
2942 |
|
|
2943 |
/** |
/** |
2952 |
return ""; |
return ""; |
2953 |
} |
} |
2954 |
//Récupère la restriction |
//Récupère la restriction |
2955 |
$sql= "SELECT |
$evenement = $this->f->get_inst__om_dbform(array( |
2956 |
restriction |
"obj" => "evenement", |
2957 |
FROM |
"idx" => $evenement, |
2958 |
".DB_PREFIXE."evenement |
)); |
2959 |
WHERE |
|
2960 |
evenement =".$evenement; |
return $evenement->getVal('restriction'); |
|
|
|
|
$restriction = $this->f->db->getone($sql); |
|
|
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
|
|
$this->f->isDatabaseError($restriction); |
|
|
return $restriction; |
|
2961 |
} |
} |
2962 |
|
|
2963 |
/** |
/** |
2988 |
|
|
2989 |
|
|
2990 |
/** |
/** |
2991 |
|
* Calcul une regle à partir des données de l'url et affiche son |
2992 |
|
* résultat au format json |
2993 |
|
*/ |
2994 |
|
public function is_date_limite_notification_dossier_depasse() { |
2995 |
|
// Récupération de la date limite |
2996 |
|
$dossier = $this->f->get_inst__om_dbform(array( |
2997 |
|
'obj' => 'dossier', |
2998 |
|
'idx' => $this->getVal('dossier') |
2999 |
|
)); |
3000 |
|
$date_limite = $dossier->getVal('incomplet_notifie') !== 't' ? |
3001 |
|
$dossier->getVal('date_limite') : |
3002 |
|
$dossier->getVal('date_limite_incompletude'); |
3003 |
|
// Ajout d'un jour à la date limite (reglementaire lors de la notification |
3004 |
|
// par demat) |
3005 |
|
$date_limite = $this->f->mois_date($date_limite, "1", "+", "jour"); |
3006 |
|
// Compare la date limite à j+1 et la date du jour |
3007 |
|
// La date du jour est récupérée via la fonction date pour pouvoir comparer |
3008 |
|
// des timestamps de début de journée |
3009 |
|
echo strtotime($date_limite) < strtotime(date("Y-m-d")) ? 'True' : 'False'; |
3010 |
|
} |
3011 |
|
|
3012 |
|
/** |
3013 |
* Calcul des règle d'action selon leur type. |
* Calcul des règle d'action selon leur type. |
3014 |
* |
* |
3015 |
* Types de règle : |
* Types de règle : |
3030 |
|
|
3031 |
// Supprime tous les espaces de la chaîne de caractère |
// Supprime tous les espaces de la chaîne de caractère |
3032 |
$rule = str_replace(' ', '', $rule); |
$rule = str_replace(' ', '', $rule); |
3033 |
|
// On force les minuscules |
3034 |
|
$rule = strtolower($rule); |
3035 |
// Coupe la chaîne au niveau de l'opérateur |
// Coupe la chaîne au niveau de l'opérateur |
3036 |
$operands = explode ("+", $rule); |
$operands = explode ("+", $rule); |
3037 |
// Nombre d'opérande |
// Nombre d'opérande |
3063 |
"regle_date_ait", |
"regle_date_ait", |
3064 |
"regle_date_transmission_parquet", |
"regle_date_transmission_parquet", |
3065 |
"regle_date_affichage", |
"regle_date_affichage", |
3066 |
|
"duree_validite", |
3067 |
|
"duree_validite_parametrage", |
3068 |
); |
); |
3069 |
// Tableau des champs de type numérique |
// Tableau des champs de type numérique |
3070 |
$rule_type_numeric = array( |
$rule_type_numeric = array( |
3071 |
|
); |
3072 |
|
// Tableau des champs de type text |
3073 |
|
$rule_type_time_delai = array( |
3074 |
"regle_delai", |
"regle_delai", |
3075 |
"regle_delai_incompletude", |
"regle_delai_incompletude", |
3076 |
); |
); |
3123 |
$type = "specific"; |
$type = "specific"; |
3124 |
} |
} |
3125 |
if (in_array($rule_name, $rule_type_technical_data) === true) { |
if (in_array($rule_name, $rule_type_technical_data) === true) { |
3126 |
$type = 'text'; |
$type = 'technical_text'; |
3127 |
} |
} |
3128 |
if (in_array($rule_name, $rule_type_simple) === true) { |
if (in_array($rule_name, $rule_type_simple) === true) { |
3129 |
$type = 'simple'; |
$type = 'simple'; |
3130 |
} |
} |
3131 |
|
if (in_array($rule_name, $rule_type_time_delai) === true) { |
3132 |
|
$type = "time_delai"; |
3133 |
|
} |
3134 |
|
|
3135 |
// Si c'est un type spécifique ou booléen alors il n'a qu'un opérande |
// Si c'est un type spécifique ou booléen alors il n'a qu'un opérande |
3136 |
// Récupère directement la valeur de l'opérande |
// Récupère directement la valeur de l'opérande |
3140 |
} |
} |
3141 |
|
|
3142 |
// Initialisation des variables |
// Initialisation des variables |
|
$key_date = 0; |
|
3143 |
$total_numeric = 0; |
$total_numeric = 0; |
3144 |
$res_text = ''; |
$res_text = ''; |
3145 |
|
$final_date = 0; |
3146 |
|
|
3147 |
// Pour chaque opérande |
// Pour chaque opérande |
3148 |
foreach ($operands as $key => $operand) { |
foreach ($operands as $key => $operand) { |
|
|
|
3149 |
// Si c'est une règle de type date |
// Si c'est une règle de type date |
3150 |
if ($type == 'date') { |
if ($type == 'date') { |
3151 |
// Vérifie si au moins une des opérandes est une date |
if (is_numeric($operand) === false){ |
3152 |
if (is_numeric($operand) === false |
$rule_value = $this->get_value_for_rule($operand); |
3153 |
&& $this->get_value_for_rule($operand) !== null |
if ( |
3154 |
&& $this->f->check_date($this->get_value_for_rule($operand)) == true) { |
$rule_value !== null |
3155 |
// Récupère la position de la date |
&& ( |
3156 |
$key_date = $key; |
strpos($operand, 'mois') !== false |
3157 |
|
|| strpos($operand, 'jour') !== false |
3158 |
|
) |
3159 |
|
){ |
3160 |
|
$rule_value = $operand; |
3161 |
|
} |
3162 |
|
if ($rule_value !== null){ |
3163 |
|
// Vérifie si l'opérande est une date |
3164 |
|
if ($this->f->check_date($rule_value) == true) { |
3165 |
|
// Affecte la date |
3166 |
|
$final_date = $rule_value; |
3167 |
|
}else{ |
3168 |
|
// Gère les opérandes |
3169 |
|
preg_match_all('/(\d+) *([a-zA-Z]*)/', $rule_value, $matches, PREG_OFFSET_CAPTURE); |
3170 |
|
|
3171 |
|
// Ajoute l'opérande au total |
3172 |
|
foreach ($matches[1] as $matche_key => $matche_value) { |
3173 |
|
$timelength = $matches[1][$matche_key][0]; |
3174 |
|
$timetype = 'mois'; |
3175 |
|
if ( $matches[2][$matche_key][0] != ''){ |
3176 |
|
$timetype = $matches[2][$matche_key][0]; |
3177 |
|
} |
3178 |
|
// Ajout au calcul de la date |
3179 |
|
$final_date = $this->f->mois_date( |
3180 |
|
$final_date, |
3181 |
|
$timelength, |
3182 |
|
"+", |
3183 |
|
$timetype |
3184 |
|
); |
3185 |
|
} |
3186 |
|
} |
3187 |
|
} |
3188 |
} |
} |
3189 |
// Les autres opérandes doivent être que des numériques |
// Les autres opérandes doivent être que des numériques |
3190 |
if (is_numeric($operand) == true) { |
if (is_numeric($operand) == true) { |
3191 |
// Ajoute l'opérande au total |
// Ajoute l'opérande au total |
3192 |
$total_numeric += $operand; |
// Ajout au calcul de la date |
3193 |
} |
$final_date = $this->f->mois_date($final_date, |
3194 |
if (is_numeric($operand) === false |
$operand, "+"); |
|
&& $this->get_value_for_rule($operand) !== null |
|
|
&& is_numeric($this->get_value_for_rule($operand)) == true) { |
|
|
// Ajoute l'opérande au total |
|
|
$total_numeric += $this->get_value_for_rule($operand); |
|
3195 |
} |
} |
3196 |
} |
} |
3197 |
|
|
3211 |
} |
} |
3212 |
|
|
3213 |
// Si c'est une règle de type text |
// Si c'est une règle de type text |
3214 |
if ($type === 'text') { |
if ($type === 'text' || $type === 'technical_text') { |
3215 |
// Concatène toutes les chaînes de caractère |
// Concatène toutes les chaînes de caractère |
3216 |
$res_text .= $this->get_value_for_rule($operand); |
$res_text .= $this->get_value_for_rule($operand); |
3217 |
} |
} |
3218 |
|
|
3219 |
|
// Si c'est une règle de type time_delai |
3220 |
|
if ($type === 'time_delai') { |
3221 |
|
$rule_value = $this->get_value_for_rule($operand); |
3222 |
|
if ( strlen($res_text) != 0) { |
3223 |
|
$res_text .= "+"; |
3224 |
|
} |
3225 |
|
if ($rule_value != null && $rule_value != ''){ |
3226 |
|
// Supprime tous les espaces de la chaîne de caractère |
3227 |
|
// Concatène toutes les chaînes de caractère |
3228 |
|
$res_text .= $rule_value; |
3229 |
|
} else { |
3230 |
|
$res_text .= $operand; |
3231 |
|
} |
3232 |
|
} |
3233 |
|
|
3234 |
} |
} |
3235 |
|
|
3236 |
// Résultat pour une règle de type date |
// Résultat pour une règle de type date |
3237 |
if ($type == 'date') { |
if ($type == 'date') { |
3238 |
// Retourne le calcul de la date |
// Retourne la date |
3239 |
return $this->f->mois_date($this->valF[$operands[$key_date]], |
return $final_date; |
|
$total_numeric, "+"); |
|
3240 |
} |
} |
3241 |
|
|
3242 |
// Résultat pour une règle de type numérique |
// Résultat pour une règle de type numérique |
3246 |
} |
} |
3247 |
|
|
3248 |
// Résultat pour une règle de type text |
// Résultat pour une règle de type text |
3249 |
if ($type === 'text') { |
if (in_array($type, array('text', 'technical_text')) === true) { |
3250 |
// Retourne la chaîne de caractère |
// Retourne la chaîne de caractère |
3251 |
return $res_text; |
return $res_text; |
3252 |
} |
} |
3253 |
|
|
3254 |
|
// Résultat pour une règle de type text |
3255 |
|
if (in_array($type, array('time_delai')) === true) { |
3256 |
|
// Traitement de la valeur à afficher |
3257 |
|
$res_text = str_replace(' ', '', $res_text); |
3258 |
|
$res_text = preg_replace('/(\d+)/', '$1 ', $res_text); |
3259 |
|
$res_text = preg_replace('/(\+)/', ' $1 ', $res_text); |
3260 |
|
$res_text = trim(preg_replace('/\s\s+/', ' ', strtolower($res_text))); |
3261 |
|
return $res_text; |
3262 |
|
} |
3263 |
|
|
3264 |
if ($type === 'simple' || $type === 'bool') { |
if ($type === 'simple' || $type === 'bool') { |
3265 |
// Retourne la valeur du champs rule |
// Retourne la valeur du champs rule |
3266 |
return $rule; |
return $rule; |
3322 |
* @return string L'identifiant des données techniques liées du dossier |
* @return string L'identifiant des données techniques liées du dossier |
3323 |
*/ |
*/ |
3324 |
function getDonneesTechniques() { |
function getDonneesTechniques() { |
3325 |
|
|
3326 |
|
$qres = $this->f->get_one_result_from_db_query( |
3327 |
|
sprintf( |
3328 |
|
'SELECT |
3329 |
|
donnees_techniques |
3330 |
|
FROM |
3331 |
|
%1$sdonnees_techniques |
3332 |
|
WHERE |
3333 |
|
dossier_instruction = \'%2$s\'', |
3334 |
|
DB_PREFIXE, |
3335 |
|
$this->f->db->escapeSimple($this->valF["dossier"]) |
3336 |
|
), |
3337 |
|
array( |
3338 |
|
"origin" => __METHOD__, |
3339 |
|
) |
3340 |
|
); |
3341 |
|
|
3342 |
$donnees_techniques = ''; |
return $qres['result']; |
|
|
|
|
$sql = "SELECT donnees_techniques |
|
|
FROM ".DB_PREFIXE."donnees_techniques |
|
|
WHERE dossier_instruction ='".$this->valF["dossier"]."'"; |
|
|
$donnees_techniques = $this->f->db->getone($sql); |
|
|
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
|
|
$this->f->isDatabaseError($donnees_techniques); |
|
|
return $donnees_techniques; |
|
3343 |
} |
} |
3344 |
|
|
3345 |
/** |
/** |
3354 |
*/ |
*/ |
3355 |
function triggerajouterapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
function triggerajouterapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
3356 |
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
3357 |
|
$data = array('val' => &$val, 'id' => $id); |
3358 |
|
$this->f->module_manager->run_hooks('triggerajouterapres_pre', $this, $data); |
3359 |
|
|
3360 |
// On a besoin de l'instance du dossier lié à l'événement d'instruction |
// On a besoin de l'instance du dossier lié à l'événement d'instruction |
3361 |
$inst_di = $this->get_inst_dossier($this->valF['dossier']); |
$inst_di = $this->get_inst_dossier($this->valF['dossier']); |
3380 |
$valF_dt = array(); |
$valF_dt = array(); |
3381 |
// |
// |
3382 |
// Récupération des paramètres de l'action |
// Récupération des paramètres de l'action |
3383 |
$sql = "SELECT * FROM ".DB_PREFIXE."action |
// TODO : remplacer cette requête par l'instanciation de l'action |
3384 |
WHERE action='".$this->valF['action']."'"; |
$qres = $this->f->get_all_results_from_db_query( |
3385 |
$res = $this->f->db->query($sql); |
sprintf( |
3386 |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
'SELECT |
3387 |
$this->f->isDatabaseError($res); |
* |
3388 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
FROM |
3389 |
|
%1$saction |
3390 |
|
WHERE |
3391 |
|
action = \'%2$s\'', |
3392 |
|
DB_PREFIXE, |
3393 |
|
$this->f->db->escapeSimple($this->valF['action']) |
3394 |
|
), |
3395 |
|
array( |
3396 |
|
"origin" => __METHOD__ |
3397 |
|
) |
3398 |
|
); |
3399 |
|
foreach ($qres['result'] as $row) { |
3400 |
|
|
3401 |
// pour chacune des regles, on applique la regle |
// pour chacune des regles, on applique la regle |
3402 |
if ($row['regle_delai'] != '') { |
if ($row['regle_delai'] != '') { |
3778 |
|
|
3779 |
// Récupération de la liste des demandeurs à notifier et de la catégorie |
// Récupération de la liste des demandeurs à notifier et de la catégorie |
3780 |
$categorie = $this->f->get_param_option_notification($collectivite_di); |
$categorie = $this->f->get_param_option_notification($collectivite_di); |
3781 |
$isPortal = $categorie == null || $categorie == '' || $categorie == PORTAL ? true : false; |
$isPortal = $categorie === PORTAL; |
3782 |
$demandeursANotifie = $this->get_demandeurs_notifiable( |
$demandeursANotifie = $this->get_demandeurs_notifiable( |
3783 |
$this->valF['dossier'], |
$this->valF['dossier'], |
3784 |
$isPortal |
$isPortal |
3991 |
/** |
/** |
3992 |
* Historisation de la vie du DI. |
* Historisation de la vie du DI. |
3993 |
*/ |
*/ |
3994 |
// |
|
3995 |
return $this->add_log_to_dossier($id, array_merge($val, $this->valF)); |
$res = $this->add_log_to_dossier($id, array_merge($val, $this->valF)); |
3996 |
|
|
3997 |
|
$data = array('val' => &$val, 'id' => $id, 'result' => &$res); |
3998 |
|
$this->f->module_manager->run_hooks('triggerajouterapres_post', $this, $data); |
3999 |
|
return $res; |
4000 |
} |
} |
4001 |
|
|
4002 |
/** |
/** |
4003 |
* Cette méthode vérifie si toutes les conditions de l'envoi de la notification |
* Cette méthode vérifie si toutes les conditions de l'envoi de la notification |
4004 |
* sont remplies. |
* sont remplies. |
4005 |
* Les conditions vérifiées sont les suivantes : |
* Les conditions vérifiées sont les suivantes : |
4006 |
|
* - L'option de notification *option_notification* doit être définie |
4007 |
* - Le petitionnaire principal doit accepter les notifications |
* - Le petitionnaire principal doit accepter les notifications |
4008 |
* - Le pétitionnaire principal doit avoir une adresse mail renseignée |
* - Le pétitionnaire principal doit avoir une adresse mail renseignée |
4009 |
* - Le pétitionnaire principal doit avoir une adresse mail correcte |
* - Le pétitionnaire principal doit avoir une adresse mail correcte |
4022 |
} |
} |
4023 |
// Tableau contenant la liste des messages d'erreur |
// Tableau contenant la liste des messages d'erreur |
4024 |
$errorMessage = array(); |
$errorMessage = array(); |
4025 |
|
// Récupère l'option de notification |
4026 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite($dossier); |
4027 |
|
$option_notification = $this->f->get_param_option_notification($collectivite_di); |
4028 |
|
if ($option_notification !== PORTAL && $option_notification !== 'mail') { |
4029 |
|
$errorMessage[] = __("L'option de notification option_notification doit obligatoirement être définie."); |
4030 |
|
} |
4031 |
// Récupère les informations du demandeurs principal |
// Récupère les informations du demandeurs principal |
4032 |
$infoPetitionnaire = $this->get_info_petitionnaire_principal_dossier($dossier); |
$infoPetitionnaire = $this->get_info_petitionnaire_principal_dossier($dossier); |
4033 |
// Vérifie si le pétitionnaire principal à bien la case "accepte les notification" cochée |
// Vérifie si le pétitionnaire principal à bien la case "accepte les notification" cochée |
4088 |
ORDER BY |
ORDER BY |
4089 |
demande ASC |
demande ASC |
4090 |
LIMIT 1 |
LIMIT 1 |
4091 |
) as demande ON dossier.dossier = demande.dossier_instruction |
) AS demande |
4092 |
|
ON dossier.dossier = demande.dossier_instruction |
4093 |
WHERE |
WHERE |
4094 |
dossier.dossier = \'%2$s\' |
dossier.dossier = \'%2$s\' |
4095 |
AND demande.source_depot = \'portal\'', |
AND demande.source_depot = \'portal\'', |
4182 |
} |
} |
4183 |
|
|
4184 |
/** |
/** |
4185 |
* Crée une instance et une tache de notification pour le demandeur |
* Crée une instance de notification et une tache notification_instruction de catégorie portal |
4186 |
* principal. |
* pour le demandeur principal. |
4187 |
* |
* |
4188 |
* @return boolean true si le traitement à réussi |
* @return boolean true si le traitement à réussi |
4189 |
*/ |
*/ |
4190 |
protected function notifier_demandeur_principal() { |
protected function notifier_demandeur_principal_via_portal() { |
4191 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
4192 |
$message = ''; |
$message = ''; |
4193 |
// Récupération des informations concernant le demandeur |
// Récupération des informations concernant le demandeur |
4212 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
4213 |
} |
} |
4214 |
// Création de la tâche en lui donnant l'id de la notification |
// Création de la tâche en lui donnant l'id de la notification |
4215 |
$notification_by_task = $this->notification_by_task($idNotification, $dossier); |
$notification_by_task = $this->notification_by_task($idNotification, $dossier, PORTAL); |
4216 |
if ($notification_by_task === false) { |
if ($notification_by_task === false) { |
4217 |
$this->addToMessage( |
$this->addToMessage( |
4218 |
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
4227 |
} |
} |
4228 |
|
|
4229 |
public function notification_by_task($object_id, $dossier, $category = null, $type = null) { |
public function notification_by_task($object_id, $dossier, $category = null, $type = null) { |
|
// Par défaut le type est portal |
|
|
if ($category === null) { |
|
|
$category = PORTAL; |
|
|
} |
|
4230 |
// Si le type n'est pas correctement spécifié, alors il est calculé |
// Si le type n'est pas correctement spécifié, alors il est calculé |
4231 |
if ($type !== 'notification_recepisse' |
if ($type !== 'notification_recepisse' |
4232 |
&& $type !== 'notification_instruction' |
&& $type !== 'notification_instruction' |
4234 |
&& $type !== 'notification_service_consulte' |
&& $type !== 'notification_service_consulte' |
4235 |
&& $type !== 'notification_tiers_consulte' |
&& $type !== 'notification_tiers_consulte' |
4236 |
&& $type !== 'notification_depot_demat' |
&& $type !== 'notification_depot_demat' |
4237 |
&& $type !== 'notification_commune') { |
&& $type !== 'notification_commune' |
4238 |
|
&& $type !== 'notification_signataire') { |
4239 |
// |
// |
4240 |
$type = 'notification_instruction'; |
$type = 'notification_instruction'; |
4241 |
// Vérifie si l'instruction est un récépissé |
// Vérifie si l'instruction est un récépissé |
4251 |
} |
} |
4252 |
} |
} |
4253 |
} |
} |
4254 |
// Préparation de la tache de notification |
// Préparation des valeurs de la tâche |
|
$inst_task = $this->f->get_inst__om_dbform(array( |
|
|
"obj" => "task", |
|
|
"idx" => 0, |
|
|
)); |
|
4255 |
$task_val = array( |
$task_val = array( |
4256 |
'type' => $type, |
'type' => $type, |
4257 |
'object_id' => $object_id, |
'object_id' => $object_id, |
4258 |
'dossier' => $dossier, |
'dossier' => $dossier, |
4259 |
'category' => $category, |
'category' => $category, |
4260 |
); |
); |
4261 |
|
// Préparation de la tache de notification |
4262 |
|
$inst_task = $this->f->get_inst__om_dbform(array( |
4263 |
|
"obj" => "task", |
4264 |
|
"idx" => 0, |
4265 |
|
)); |
4266 |
|
|
4267 |
$add_task = $inst_task->add_task(array('val' => $task_val)); |
$add_task = $inst_task->add_task(array('val' => $task_val)); |
4268 |
if ($add_task === false) { |
if ($add_task === false) { |
4494 |
protected function is_parametrage_notification_correct($collectiviteId) { |
protected function is_parametrage_notification_correct($collectiviteId) { |
4495 |
$categorie = $this->f->get_param_option_notification($collectiviteId); |
$categorie = $this->f->get_param_option_notification($collectiviteId); |
4496 |
$urlAccesNotif = $this->f->get_parametre_notification_url_acces($collectiviteId); |
$urlAccesNotif = $this->f->get_parametre_notification_url_acces($collectiviteId); |
4497 |
if ($categorie == 'mail' && $urlAccesNotif == null) { |
if ($categorie === 'mail' && $urlAccesNotif === null) { |
4498 |
return false; |
return false; |
4499 |
} |
} |
4500 |
return true; |
return true; |
4507 |
*/ |
*/ |
4508 |
function triggermodifierapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
function triggermodifierapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
4509 |
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
4510 |
|
$data = array('val' => &$val, 'id' => $id); |
4511 |
|
$this->f->module_manager->run_hooks('triggermodifierapres_pre', $this, $data); |
4512 |
$collectivite_di = $this->get_dossier_instruction_om_collectivite($val['dossier']); |
$collectivite_di = $this->get_dossier_instruction_om_collectivite($val['dossier']); |
4513 |
$message = ''; |
$message = ''; |
4514 |
|
|
4534 |
// Initialisation du type d'événement |
// Initialisation du type d'événement |
4535 |
$type_evmt = ""; |
$type_evmt = ""; |
4536 |
// Récupération de l'action correspondante à l'événement |
// Récupération de l'action correspondante à l'événement |
4537 |
$sql = "SELECT action |
$evenement = $this->f->get_inst__om_dbform(array( |
4538 |
FROM ".DB_PREFIXE."evenement |
"obj" => "evenement", |
4539 |
WHERE evenement=".$this->valF['evenement']; |
"idx" => $this->valF['evenement'] |
4540 |
$action = $this->f->db->getone($sql); |
)); |
|
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
|
|
$this->f->isDatabaseError($action); |
|
4541 |
|
|
4542 |
// Récupération des paramètres de l'action |
// Récupération des paramètres de l'action |
4543 |
$sql = "SELECT * FROM ".DB_PREFIXE."action |
// TODO : remplacer cette requête par l'instanciation de l'action |
4544 |
WHERE action='".$action."'"; |
$qres = $this->f->get_all_results_from_db_query( |
4545 |
$res = $this->f->db->query($sql); |
sprintf( |
4546 |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
'SELECT |
4547 |
$this->f->isDatabaseError($res); |
* |
4548 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
FROM |
4549 |
|
%1$saction |
4550 |
|
WHERE |
4551 |
|
action = \'%2$s\'', |
4552 |
|
DB_PREFIXE, |
4553 |
|
$this->f->db->escapeSimple($evenement->getVal('action')) |
4554 |
|
), |
4555 |
|
array( |
4556 |
|
"origin" => __METHOD__ |
4557 |
|
) |
4558 |
|
); |
4559 |
|
foreach ($qres['result'] as $row) { |
4560 |
// application des regles sur le courrier + delai |
// application des regles sur le courrier + delai |
4561 |
if(preg_match("/date_evenement/",$row['regle_date_limite'])){ |
if(preg_match("/date_evenement/",$row['regle_date_limite'])){ |
4562 |
$valF['date_limite']= $this->regle($row['regle_date_limite'], 'regle_date_limite'); |
$valF['date_limite']= $this->regle($row['regle_date_limite'], 'regle_date_limite'); |
4661 |
} |
} |
4662 |
} |
} |
4663 |
|
|
4664 |
|
// Par défaut les instructions à ajouter suite à la saisie d'une date |
4665 |
|
// de retour signature ou de notification, utilisent l'action 0 |
4666 |
|
// Si la création d'événement d'instruction suivant est déclenchée par |
4667 |
|
// une notification suite au traitement d'une tâche (démat') alors l'ajout |
4668 |
|
// de la nouvelle instruction se fait avec l'action 176 |
4669 |
|
// Cela permet de ne pas contrôler la restriction lors de l'ajout de la |
4670 |
|
// nouvelle instruction, depuis la méthode verifier() |
4671 |
|
$code_action_add = 0; |
4672 |
|
if ($this->getParameter("maj") == 175) { |
4673 |
|
$code_action_add = 176; |
4674 |
|
} |
4675 |
$restriction = $this->get_restriction($val['evenement']); |
$restriction = $this->get_restriction($val['evenement']); |
4676 |
$this->restriction_valid = $this->restrictionIsValid($restriction); |
$this->restriction_valid = $this->restrictionIsValid($restriction); |
4677 |
|
|
4678 |
if($restriction == "" || $this->restriction_valid ){ |
if($restriction == "" || $this->restriction_valid ){ |
4679 |
// Récupération de tous les paramètres de l'événement sélectionné |
// Récupération de tous les paramètres de l'événement sélectionné |
4680 |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
// TODO : remplacer cette requête par l'instanciation de l'evenement |
4681 |
WHERE evenement=".$this->valF['evenement']; |
$qres = $this->f->get_all_results_from_db_query( |
4682 |
$res = $this->f->db->query($sql); |
sprintf( |
4683 |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
'SELECT |
4684 |
$this->f->isDatabaseError($res); |
* |
4685 |
|
FROM |
4686 |
|
%1$sevenement |
4687 |
|
WHERE |
4688 |
|
evenement = %2$d', |
4689 |
|
DB_PREFIXE, |
4690 |
|
intval($this->valF['evenement']) |
4691 |
|
), |
4692 |
|
array( |
4693 |
|
"origin" => __METHOD__ |
4694 |
|
) |
4695 |
|
); |
4696 |
$current_id = $this->getVal($this->clePrimaire); |
$current_id = $this->getVal($this->clePrimaire); |
4697 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
foreach ($qres['result'] as $row) { |
4698 |
// Si la date de retour signature est éditée on vérifie si il existe un événement automatique |
// Si la date de retour signature est éditée on vérifie si il existe un événement automatique |
4699 |
if ($this->getVal('date_retour_signature') == "" AND |
if ($this->getVal('date_retour_signature') == "" AND |
4700 |
$this->valF['date_retour_signature'] != "" AND |
$this->valF['date_retour_signature'] != "" AND |
4718 |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
4719 |
$valNewInstr["date_envoi_controle_legalite"] = $this->f->formatDate($this->valF['date_envoi_controle_legalite']); |
$valNewInstr["date_envoi_controle_legalite"] = $this->f->formatDate($this->valF['date_envoi_controle_legalite']); |
4720 |
$valNewInstr["date_retour_controle_legalite"] = $this->f->formatDate($this->valF['date_retour_controle_legalite']); |
$valNewInstr["date_retour_controle_legalite"] = $this->f->formatDate($this->valF['date_retour_controle_legalite']); |
4721 |
$new_instruction->setParameter("maj", 0); |
$new_instruction->setParameter("maj", $code_action_add); |
4722 |
$new_instruction->class_actions[0]["identifier"] = |
$new_instruction->class_actions[$code_action_add]["identifier"] = |
4723 |
sprintf( |
sprintf( |
4724 |
__("Ajout suite au retour signature de l'instruction %s"), |
__("Ajout suite au retour signature de l'instruction %s"), |
4725 |
$current_id |
$current_id |
4766 |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
4767 |
$valNewInstr["date_envoi_controle_legalite"] = $this->f->formatDate($this->valF['date_envoi_controle_legalite']); |
$valNewInstr["date_envoi_controle_legalite"] = $this->f->formatDate($this->valF['date_envoi_controle_legalite']); |
4768 |
$valNewInstr["date_retour_controle_legalite"] = $this->f->formatDate($this->valF['date_retour_controle_legalite']); |
$valNewInstr["date_retour_controle_legalite"] = $this->f->formatDate($this->valF['date_retour_controle_legalite']); |
4769 |
$new_instruction->setParameter("maj", 0); |
$new_instruction->setParameter("maj", $code_action_add); |
4770 |
$new_instruction->class_actions[0]["identifier"] = |
$new_instruction->class_actions[$code_action_add]["identifier"] = |
4771 |
sprintf(__("Ajout suite à la notification de l'instruction %s"), $current_id); |
sprintf(__("Ajout suite à la notification de l'instruction %s"), $current_id); |
4772 |
$retour = $new_instruction->ajouter($valNewInstr); |
$retour = $new_instruction->ajouter($valNewInstr); |
4773 |
|
|
4826 |
$metadata = $this->getMetadata("om_fichier_instruction"); |
$metadata = $this->getMetadata("om_fichier_instruction"); |
4827 |
|
|
4828 |
// On vérifie si l'instruction à finaliser a un événement de type arrete |
// On vérifie si l'instruction à finaliser a un événement de type arrete |
4829 |
$sql = "SELECT type FROM ".DB_PREFIXE."evenement WHERE evenement = ".$this->getVal("evenement"); |
// TODO : A voir pour remplacer par une instanciation de l'événement. |
4830 |
$typeEvenement = $this->f->db->getOne($sql); |
// Voir également si l'événement ne dois pas être instancié en début de |
4831 |
$this->addToLog(__METHOD__."(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
// méthode pour pouvoir être réutilisé. |
4832 |
if ($this->f->isDatabaseError($typeEvenement, true) === true) { |
$qres = $this->f->get_one_result_from_db_query( |
4833 |
|
sprintf( |
4834 |
|
'SELECT |
4835 |
|
type |
4836 |
|
FROM |
4837 |
|
%1$sevenement |
4838 |
|
WHERE |
4839 |
|
evenement = \'%2$d\'', |
4840 |
|
DB_PREFIXE, |
4841 |
|
intval($this->getVal("evenement")) |
4842 |
|
), |
4843 |
|
array( |
4844 |
|
"origin" => __METHOD__, |
4845 |
|
"force_return" => true, |
4846 |
|
) |
4847 |
|
); |
4848 |
|
|
4849 |
|
if ($qres["code"] !== "OK") { |
4850 |
$this->correct = false; |
$this->correct = false; |
4851 |
$this->addToMessage(__("Erreur de traitement de fichier.")); |
$this->addToMessage(__("Erreur de traitement de fichier.")); |
4852 |
$this->addToLog(__METHOD__."() erreur BDD: ".var_export($typeEvenement->getMessage(), true), DEBUG_MODE); |
$this->addToLog(__METHOD__."() erreur BDD: ".var_export($qres['message'], true), DEBUG_MODE); |
4853 |
return false; |
return false; |
4854 |
} |
} |
4855 |
|
|
4856 |
// Si l'événement est de type arrete, on ajoute les métadonnées spécifiques |
// Si l'événement est de type arrete, on ajoute les métadonnées spécifiques |
4857 |
if ($typeEvenement == 'arrete'){ |
if ($qres['result'] == 'arrete'){ |
4858 |
$metadata = array_merge($metadata, $this->getMetadata("arrete")); |
$metadata = array_merge($metadata, $this->getMetadata("arrete")); |
4859 |
} |
} |
4860 |
|
|
4934 |
if ($ev->getVal('notification') === 'notification_auto_signature_requise') { |
if ($ev->getVal('notification') === 'notification_auto_signature_requise') { |
4935 |
// Récupération de la liste des demandeurs à notifier et de la catégorie |
// Récupération de la liste des demandeurs à notifier et de la catégorie |
4936 |
$categorie = $this->f->get_param_option_notification($collectivite_di); |
$categorie = $this->f->get_param_option_notification($collectivite_di); |
4937 |
$isPortal = $categorie == null || $categorie == '' || $categorie == PORTAL ? true : false; |
$isPortal = $categorie === PORTAL; |
4938 |
$demandeursANotifie = $this->get_demandeurs_notifiable( |
$demandeursANotifie = $this->get_demandeurs_notifiable( |
4939 |
$this->valF['dossier'], |
$this->valF['dossier'], |
4940 |
$isPortal |
$isPortal |
5059 |
} |
} |
5060 |
} |
} |
5061 |
|
|
5062 |
return $this->add_log_to_dossier($id, $val); |
$res = $this->add_log_to_dossier($id, $val); |
5063 |
|
$data = array('val' => &$val, 'id' => $id, 'result' => &$res); |
5064 |
|
$this->f->module_manager->run_hooks('triggermodifierapres_post', $this, $data); |
5065 |
|
return $res; |
5066 |
} |
} |
5067 |
|
|
5068 |
/** |
/** |
5072 |
*/ |
*/ |
5073 |
function triggersupprimer($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
function triggersupprimer($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
5074 |
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
5075 |
|
$data = array('val' => &$val, 'id' => $id); |
5076 |
|
$this->f->module_manager->run_hooks('triggersupprimer_pre', $this, $data); |
5077 |
/** |
/** |
5078 |
* L'objectif ici est de repositionner les valeurs récupérées en |
* L'objectif ici est de repositionner les valeurs récupérées en |
5079 |
* archive dans le dossier d'instruction avant de supprimer l'événement |
* archive dans le dossier d'instruction avant de supprimer l'événement |
5088 |
// est différente |
// est différente |
5089 |
if ($inst_di->getVal($champ) !== $val[sprintf('archive_%s', $champ)]) { |
if ($inst_di->getVal($champ) !== $val[sprintf('archive_%s', $champ)]) { |
5090 |
$val[sprintf('archive_%s', $champ)] === '' ? $valF[$champ] = null : $valF[$champ] = $val[sprintf('archive_%s', $champ)]; |
$val[sprintf('archive_%s', $champ)] === '' ? $valF[$champ] = null : $valF[$champ] = $val[sprintf('archive_%s', $champ)]; |
5091 |
|
// Gestion du cas particulier 'accord_tacite' pour renvoyer la valeur ' ' (3 espaces vides) au lieu de null |
5092 |
|
// Car les valeurs possibles du champ accord_tacite sont : 'Oui', 'Non' ou ' ' |
5093 |
|
if ($champ === "accord_tacite" && $valF[$champ] === null) { |
5094 |
|
$valF[$champ] = ' '; |
5095 |
|
} |
5096 |
} |
} |
5097 |
} |
} |
5098 |
} |
} |
5168 |
'notification_service_consulte', |
'notification_service_consulte', |
5169 |
'notification_tiers_consulte', |
'notification_tiers_consulte', |
5170 |
'notification_depot_demat', |
'notification_depot_demat', |
5171 |
'notification_commune' |
'notification_commune', |
5172 |
|
'notification_signataire' |
5173 |
), |
), |
5174 |
true |
true |
5175 |
); |
); |
5210 |
$this->addToMessage(_("Suppression de l'instruction")." [".$this->f->db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
$this->addToMessage(_("Suppression de l'instruction")." [".$this->f->db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
5211 |
|
|
5212 |
// Mise à jour de la demande si un récépissé d'instruction correspond à l'instruction à supprimer |
// Mise à jour de la demande si un récépissé d'instruction correspond à l'instruction à supprimer |
5213 |
|
|
5214 |
|
$res = true; |
5215 |
|
$data = array('val' => &$val, 'id' => $id, 'result' => &$res); |
5216 |
|
$this->f->module_manager->run_hooks('triggersupprimer_post', $this, $data); |
5217 |
|
return $res; |
5218 |
} |
} |
5219 |
|
|
5220 |
/** |
/** |
5224 |
*/ |
*/ |
5225 |
function triggersupprimerapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
function triggersupprimerapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
5226 |
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
5227 |
|
$data = array('val' => &$val, 'id' => $id); |
5228 |
|
$this->f->module_manager->run_hooks('triggersupprimerapres_pre', $this, $data); |
5229 |
/** |
/** |
5230 |
* Mise à jour de la date de dernière modification du dossier |
* Mise à jour de la date de dernière modification du dossier |
5231 |
* d'instruction |
* d'instruction |
5283 |
|
|
5284 |
// |
// |
5285 |
$val['evenement'] = $this->getVal('evenement'); |
$val['evenement'] = $this->getVal('evenement'); |
5286 |
return $this->add_log_to_dossier($id, $val); |
$res = $this->add_log_to_dossier($id, $val); |
5287 |
|
$data = array('val' => &$val, 'id' => $id, 'result' => &$res); |
5288 |
|
$this->f->module_manager->run_hooks('triggersupprimerapres_post', $this, $data); |
5289 |
|
return $res; |
5290 |
} |
} |
5291 |
|
|
5292 |
/** |
/** |
5376 |
//Test qu'une restriction est présente |
//Test qu'une restriction est présente |
5377 |
if ($restriction != "" ){ |
if ($restriction != "" ){ |
5378 |
|
|
5379 |
//Test si la restriction est valide |
// Vérifie le contexte de la modification et test si la restriction est valide. |
5380 |
|
// Si l'instruction est modifiée par une tache le dossier n'est pas impacté. |
5381 |
|
// Il n'est donc pas nécessaire de vérifier les restrictions. |
5382 |
$this->restriction_valid = $this->restrictionIsValid($restriction); |
$this->restriction_valid = $this->restrictionIsValid($restriction); |
5383 |
if ( !$this->restriction_valid ){ |
if ($this->getParameter("maj") != 176 |
5384 |
|
&& !$this->restriction_valid) { |
5385 |
|
|
5386 |
// Affichage du message si la restriction s'applique |
// Affichage du message si la restriction s'applique |
5387 |
$this->addToMessage( |
$this->addToMessage( |
5576 |
$spe_metadata = $this->getMetadata("om_fichier_instruction"); |
$spe_metadata = $this->getMetadata("om_fichier_instruction"); |
5577 |
|
|
5578 |
//On vérifie si l'instruction à finaliser a un événement de type arrete |
//On vérifie si l'instruction à finaliser a un événement de type arrete |
5579 |
$sql = "SELECT type |
// TODO : A voir pour remplacer par une instanciation de l'événement. |
5580 |
FROM ".DB_PREFIXE."evenement |
// Voir également si l'événement ne dois pas être instancié en début de |
5581 |
WHERE evenement = ".$this->getVal("evenement"); |
// méthode pour pouvoir être réutilisé. |
5582 |
$typeEvenement = $this->f->db->getOne($sql); |
$qres = $this->f->get_one_result_from_db_query( |
5583 |
$this->addToLog(__METHOD__."(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
sprintf( |
5584 |
if ($this->f->isDatabaseError($typeEvenement, true) === true) { |
'SELECT |
5585 |
|
type |
5586 |
|
FROM |
5587 |
|
%1$sevenement |
5588 |
|
WHERE |
5589 |
|
evenement = \'%2$d\'', |
5590 |
|
DB_PREFIXE, |
5591 |
|
intval($this->getVal("evenement")) |
5592 |
|
), |
5593 |
|
array( |
5594 |
|
"origin" => __METHOD__, |
5595 |
|
"force_return" => true, |
5596 |
|
) |
5597 |
|
); |
5598 |
|
|
5599 |
|
if ($qres["code"] !== "OK") { |
5600 |
$this->correct = false; |
$this->correct = false; |
5601 |
$this->addToMessage($bdd_msg_error); |
$this->addToMessage($bdd_msg_error); |
5602 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
5605 |
//Initialisation de la variable |
//Initialisation de la variable |
5606 |
$arrete_metadata = array(); |
$arrete_metadata = array(); |
5607 |
// Si l'événement est de type arrete, on ajoute les métadonnées spécifiques |
// Si l'événement est de type arrete, on ajoute les métadonnées spécifiques |
5608 |
if ( $typeEvenement === 'arrete' ){ |
if ($qres['result'] === 'arrete'){ |
5609 |
$arrete_metadata = $this->getMetadata("arrete"); |
$arrete_metadata = $this->getMetadata("arrete"); |
5610 |
} |
} |
5611 |
|
|
5843 |
} |
} |
5844 |
|
|
5845 |
// Requête sql |
// Requête sql |
5846 |
$sql = "SELECT libelle FROM ".DB_PREFIXE."evenement |
$evenement = $this->f->get_inst__om_dbform(array( |
5847 |
WHERE evenement=".$evenement; |
"obj" => "evenement", |
5848 |
$evenement_libelle = $this->f->db->getone($sql); |
"idx" => $evenement |
5849 |
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
)); |
5850 |
$this->f->isDatabaseError($evenement_libelle); |
|
5851 |
// Retourne le libelle de l'événement |
// Retourne le libelle de l'événement |
5852 |
return $evenement_libelle; |
return $evenement->getVal('libelle'); |
5853 |
} |
} |
5854 |
|
|
5855 |
|
|
5879 |
$dossier = $this->getVal("dossier"); |
$dossier = $this->getVal("dossier"); |
5880 |
} |
} |
5881 |
//Requête pour récupérer les informations essentiels sur le dossier d'instruction |
//Requête pour récupérer les informations essentiels sur le dossier d'instruction |
5882 |
$sql = "SELECT dossier.dossier as dossier, |
$qres = $this->f->get_all_results_from_db_query( |
5883 |
dossier_autorisation.dossier_autorisation as dossier_autorisation, |
sprintf( |
5884 |
to_char(dossier.date_demande, 'YYYY/MM') as date_demande_initiale, |
'SELECT |
5885 |
dossier_instruction_type.code as dossier_instruction_type, |
dossier.dossier AS dossier, |
5886 |
etat_dossier_autorisation.libelle as statut, |
dossier_autorisation.dossier_autorisation AS dossier_autorisation, |
5887 |
dossier_autorisation_type.code as dossier_autorisation_type, |
to_char(dossier.date_demande, \'YYYY/MM\') AS date_demande_initiale, |
5888 |
groupe.code as groupe_instruction, |
dossier_instruction_type.code AS dossier_instruction_type, |
5889 |
CASE WHEN dossier.erp IS TRUE |
etat_dossier_autorisation.libelle AS statut, |
5890 |
THEN 'true' |
dossier_autorisation_type.code AS dossier_autorisation_type, |
5891 |
ELSE 'false' |
groupe.code AS groupe_instruction, |
5892 |
END as erp |
CASE WHEN dossier.erp IS TRUE |
5893 |
FROM ".DB_PREFIXE."dossier |
THEN \'true\' |
5894 |
LEFT JOIN ".DB_PREFIXE."dossier_instruction_type |
ELSE \'false\' |
5895 |
|
END AS erp |
5896 |
|
FROM |
5897 |
|
%1$sdossier |
5898 |
|
LEFT JOIN %1$sdossier_instruction_type |
5899 |
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
5900 |
LEFT JOIN ".DB_PREFIXE."dossier_autorisation |
LEFT JOIN %1$sdossier_autorisation |
5901 |
ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
5902 |
LEFT JOIN ".DB_PREFIXE."etat_dossier_autorisation |
LEFT JOIN %1$setat_dossier_autorisation |
5903 |
ON dossier_autorisation.etat_dossier_autorisation = etat_dossier_autorisation.etat_dossier_autorisation |
ON dossier_autorisation.etat_dossier_autorisation = etat_dossier_autorisation.etat_dossier_autorisation |
5904 |
LEFT JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille |
LEFT JOIN %1$sdossier_autorisation_type_detaille |
5905 |
ON dossier_autorisation.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
ON dossier_autorisation.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
5906 |
LEFT JOIN ".DB_PREFIXE."dossier_autorisation_type |
LEFT JOIN %1$sdossier_autorisation_type |
5907 |
ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
5908 |
LEFT JOIN ".DB_PREFIXE."groupe |
LEFT JOIN %1$sgroupe |
5909 |
ON dossier_autorisation_type.groupe = groupe.groupe |
ON dossier_autorisation_type.groupe = groupe.groupe |
5910 |
WHERE dossier.dossier = '".$dossier."'"; |
WHERE |
5911 |
$res = $this->f->db->query($sql); |
dossier.dossier = \'%2$s\'', |
5912 |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
DB_PREFIXE, |
5913 |
$this->f->isDatabaseError($res); |
$this->f->db->escapeSimple($dossier) |
5914 |
//Le résultat est récupéré dans un objet |
), |
5915 |
$row =& $res->fetchRow(DB_FETCHMODE_OBJECT); |
array( |
5916 |
|
"origin" => __METHOD__, |
5917 |
|
) |
5918 |
|
); |
5919 |
|
$row = array_shift($qres['result']); |
5920 |
|
|
5921 |
//Si il y a un résultat |
//Si il y a un résultat |
5922 |
if ($row !== null) { |
if (! empty($row)) { |
5923 |
|
|
5924 |
// Instrance de la classe dossier |
// Instrance de la classe dossier |
5925 |
$inst_dossier = $this->get_inst_dossier($dossier); |
$inst_dossier = $this->get_inst_dossier($dossier); |
5926 |
|
// TODO : améliorer ce code |
5927 |
|
// |
5928 |
|
// Avant l e résultat été récupéré dans un objet à partir de la requête mais en modifiant pour |
5929 |
|
// utiliser la méthode get_all_results_from_db_query() c'est maintenant un tableau |
5930 |
|
// qu'on obtiens. Pour garder le même fonctionnement on transforme le tableau des |
5931 |
|
// valeurs issues de la requête en objet. |
5932 |
|
$metadata = (object)$row; |
5933 |
// Insère l'attribut version à l'objet |
// Insère l'attribut version à l'objet |
5934 |
$row->version = $inst_dossier->get_dossier_instruction_version(); |
$metadata->version = $inst_dossier->get_di_numero_suffixe(); |
5935 |
|
|
5936 |
//Alors on créé l'objet dossier_instruction |
//Alors on créé l'objet dossier_instruction |
5937 |
$this->specificMetadata = $row; |
$this->specificMetadata = $metadata; |
5938 |
|
|
5939 |
} |
} |
5940 |
} |
} |
5953 |
|
|
5954 |
//On récupère le statut de l'état du dossier à partir de l'identifiant du |
//On récupère le statut de l'état du dossier à partir de l'identifiant du |
5955 |
//dossier |
//dossier |
5956 |
$sql = "SELECT etat.statut |
$qres = $this->f->get_one_result_from_db_query( |
5957 |
FROM ".DB_PREFIXE."dossier |
sprintf( |
5958 |
LEFT JOIN |
'SELECT |
5959 |
".DB_PREFIXE."etat |
etat.statut |
5960 |
ON |
FROM |
5961 |
dossier.etat = etat.etat |
%1$sdossier |
5962 |
WHERE dossier ='".$idx."'"; |
LEFT JOIN |
5963 |
$statut = $this->f->db->getone($sql); |
%1$setat |
5964 |
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
ON |
5965 |
$this->f->isDatabaseError($statut); |
dossier.etat = etat.etat |
5966 |
|
WHERE |
5967 |
|
dossier = \'%2$s\'', |
5968 |
|
DB_PREFIXE, |
5969 |
|
$this->f->db->escapeSimple($idx) |
5970 |
|
), |
5971 |
|
array( |
5972 |
|
"origin" => __METHOD__, |
5973 |
|
) |
5974 |
|
); |
5975 |
} |
} |
5976 |
return $statut; |
|
5977 |
|
return $qres['result']; |
5978 |
} |
} |
5979 |
|
|
5980 |
/** |
/** |
5987 |
$return = array(); |
$return = array(); |
5988 |
|
|
5989 |
// Récupération de toutes les valeurs du dossier d'instruction en cours |
// Récupération de toutes les valeurs du dossier d'instruction en cours |
5990 |
$sql = "SELECT * FROM ".DB_PREFIXE."dossier |
// TODO : remplacer cette requête par une instanciation de l'objet |
5991 |
WHERE dossier='".$this->valF['dossier']."'"; |
$qres = $this->f->get_all_results_from_db_query( |
5992 |
$res = $this->f->db->query($sql); |
sprintf( |
5993 |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
'SELECT |
5994 |
$this->f->isDatabaseError($res); |
* |
5995 |
|
FROM |
5996 |
|
%1$sdossier |
5997 |
|
WHERE |
5998 |
|
dossier = \'%2$s\'', |
5999 |
|
DB_PREFIXE, |
6000 |
|
$this->f->db->escapeSimple($this->valF['dossier']) |
6001 |
|
), |
6002 |
|
array( |
6003 |
|
'origin' => __METHOD__ |
6004 |
|
) |
6005 |
|
); |
6006 |
|
|
6007 |
// |
foreach ($qres['result'] as $row) { |
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
|
6008 |
|
|
6009 |
// Récupération de la valeur actuelle du délai, de l'accord tacite, |
// Récupération de la valeur actuelle du délai, de l'accord tacite, |
6010 |
// de l'état et de l'avis du dossier d'instruction |
// de l'état et de l'avis du dossier d'instruction |
6059 |
* @return boolean |
* @return boolean |
6060 |
*/ |
*/ |
6061 |
function checkEvenementNonVerrouillable($idx) { |
function checkEvenementNonVerrouillable($idx) { |
|
|
|
|
// Initialisation du résultat |
|
|
$non_verrouillable = false; |
|
|
|
|
6062 |
// Si la condition n'est pas vide |
// Si la condition n'est pas vide |
6063 |
if ($idx != "") { |
if ($idx != "") { |
6064 |
|
|
6065 |
// Requête SQL |
// Requête SQL |
6066 |
$sql = "SELECT evenement.non_verrouillable |
$qres = $this->f->get_one_result_from_db_query( |
6067 |
FROM ".DB_PREFIXE."evenement |
sprintf( |
6068 |
LEFT JOIN ".DB_PREFIXE."instruction |
'SELECT |
6069 |
ON instruction.evenement = evenement.evenement |
evenement.non_verrouillable |
6070 |
WHERE instruction.instruction = $idx"; |
FROM |
6071 |
$this->f->addToLog("checkEvenementNonVerrouillable() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
%1$sevenement |
6072 |
$res = $this->f->db->getOne($sql); |
LEFT JOIN %1$sinstruction |
6073 |
$this->f->isDatabaseError($res); |
ON instruction.evenement = evenement.evenement |
6074 |
|
WHERE |
6075 |
// Si le retour de la requête est true |
instruction.instruction = \'%2$s\'', |
6076 |
if ($res == 't') { |
DB_PREFIXE, |
6077 |
// |
intval($idx) |
6078 |
$non_verrouillable = true; |
), |
6079 |
} |
array( |
6080 |
|
"origin" => __METHOD__, |
6081 |
|
) |
6082 |
|
); |
6083 |
} |
} |
6084 |
|
|
6085 |
// Retourne résultat |
// Si on a un résultat et que ce résultat indique que l'événement n'est |
6086 |
return $non_verrouillable; |
// pas vérrouillable renvoie true, sinon renvoie false |
6087 |
|
return isset($qres) && isset($qres['result']) && $qres['result'] == 't'; |
6088 |
} |
} |
6089 |
|
|
6090 |
/** |
/** |
6324 |
*/ |
*/ |
6325 |
function getArreteMetadata() { |
function getArreteMetadata() { |
6326 |
|
|
6327 |
//Récupération de la dernière instruction dont l'événement est de type 'arrete' |
//Récupération de la dernière instruction dont l'événement est de type 'arrete' |
6328 |
$this->metadonneesArrete = array("nomsignataire"=>"", "qualitesignataire"=>"", |
$this->metadonneesArrete = array("nomsignataire"=>"", "qualitesignataire"=>"", |
6329 |
"decisionarrete"=>"", "datenotification"=>"", "datesignaturearrete"=>"", |
"decisionarrete"=>"", "datenotification"=>"", "datesignaturearrete"=>"", |
6330 |
"datecontrolelegalite"=>"", "ap_numrue"=>"", "ap_nomdelavoie"=>"", |
"datecontrolelegalite"=>"", "ap_numrue"=>"", "ap_nomdelavoie"=>"", |
6331 |
"ap_codepostal"=>"", "ap_ville"=>""); |
"ap_codepostal"=>"", "ap_ville"=>""); |
6332 |
|
|
6333 |
$sqlArrete = "SELECT |
$qres = $this->f->get_all_results_from_db_query( |
6334 |
signataire_arrete.prenom || ' ' ||signataire_arrete.nom as \"nomsignataire\", |
sprintf( |
6335 |
signataire_arrete.qualite as \"qualitesignataire\", |
'SELECT |
6336 |
instruction.etat as \"decisionarrete\", |
signataire_arrete.prenom || \' \' ||signataire_arrete.nom as nomsignataire, |
6337 |
instruction.date_retour_rar as \"datenotification\", |
signataire_arrete.qualite as qualitesignataire, |
6338 |
instruction.date_retour_signature as \"datesignaturearrete\", |
instruction.etat as decisionarrete, |
6339 |
instruction.date_retour_controle_legalite as \"datecontrolelegalite\", |
instruction.date_retour_rar as datenotification, |
6340 |
dossier.terrain_adresse_voie_numero as \"ap_numrue\", |
instruction.date_retour_signature as datesignaturearrete, |
6341 |
dossier.terrain_adresse_voie as \"ap_nomdelavoie\", |
instruction.date_retour_controle_legalite as datecontrolelegalite, |
6342 |
dossier.terrain_adresse_code_postal as \"ap_codepostal\", |
dossier.terrain_adresse_voie_numero as ap_numrue, |
6343 |
dossier.terrain_adresse_localite as \"ap_ville\" |
dossier.terrain_adresse_voie as ap_nomdelavoie, |
6344 |
FROM ".DB_PREFIXE."instruction |
dossier.terrain_adresse_code_postal as ap_codepostal, |
6345 |
LEFT JOIN ".DB_PREFIXE."signataire_arrete ON |
dossier.terrain_adresse_localite as ap_ville |
6346 |
instruction.signataire_arrete = signataire_arrete.signataire_arrete |
FROM |
6347 |
LEFT JOIN ".DB_PREFIXE."dossier ON |
%1$sinstruction |
6348 |
instruction.dossier = dossier.dossier |
LEFT JOIN %1$ssignataire_arrete |
6349 |
LEFT JOIN ".DB_PREFIXE."donnees_techniques ON |
ON instruction.signataire_arrete = signataire_arrete.signataire_arrete |
6350 |
donnees_techniques.dossier_instruction = dossier.dossier |
LEFT JOIN %1$sdossier |
6351 |
WHERE instruction.instruction = ".$this->getVal("instruction"); |
ON instruction.dossier = dossier.dossier |
6352 |
$resArrete = $this->f->db->query($sqlArrete); |
LEFT JOIN %1$sdonnees_techniques |
6353 |
$this->addToLog(__METHOD__."(): db->query(\"".$sqlArrete."\");", VERBOSE_MODE); |
ON donnees_techniques.dossier_instruction = dossier.dossier |
6354 |
$this->f->isDatabaseError($resArrete); |
WHERE |
6355 |
$this->metadonneesArrete = $resArrete->fetchRow(DB_FETCHMODE_ASSOC); |
instruction.instruction = %2$d', |
6356 |
|
DB_PREFIXE, |
6357 |
|
intval($this->getVal('instruction')) |
6358 |
|
), |
6359 |
|
array( |
6360 |
|
'origin' => __METHOD__ |
6361 |
|
) |
6362 |
|
); |
6363 |
|
$this->metadonneesArrete = array_shift($qres['result']); |
6364 |
} |
} |
6365 |
|
|
6366 |
/** |
/** |
6766 |
AND dossier.dossier = \'%2$s\' |
AND dossier.dossier = \'%2$s\' |
6767 |
', |
', |
6768 |
DB_PREFIXE, |
DB_PREFIXE, |
6769 |
$idx |
$this->f->db->escapeSimple($idx) |
6770 |
); |
); |
6771 |
|
|
6772 |
|
|
6773 |
// Si collectivité de l'utilisateur niveau mono alors filtre sur celle-ci |
// Si collectivité de l'utilisateur niveau mono alors filtre sur celle-ci |
6774 |
if ($this->f->isCollectiviteMono($_SESSION['collectivite']) === true) { |
if ($this->f->isCollectiviteMono($_SESSION['collectivite']) === true) { |
6775 |
$sql .= sprintf( |
$sql .= sprintf( |
6776 |
' AND dossier.om_collectivite=%1$s', |
' AND dossier.om_collectivite = %1$d', |
6777 |
$_SESSION['collectivite'] |
intval($_SESSION['collectivite']) |
6778 |
); |
); |
6779 |
} |
} |
6780 |
$res = $this->f->db->getone($sql); |
$qres = $this->f->get_one_result_from_db_query( |
6781 |
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
$sql, |
6782 |
$this->f->isDatabaseError($res); |
array( |
6783 |
// Si le dossier n'est pas sujet au changement de decision |
"origin" => __METHOD__, |
6784 |
if($res == null) { |
) |
6785 |
return false; |
); |
6786 |
} |
|
6787 |
return true; |
return $qres['result'] !== null; |
6788 |
} |
} |
6789 |
|
|
6790 |
|
|
6942 |
$collectivite_di = $this->get_dossier_instruction_om_collectivite($this->getVal('dossier')); |
$collectivite_di = $this->get_dossier_instruction_om_collectivite($this->getVal('dossier')); |
6943 |
// Récupération de la liste des demandeurs à notifier et de la catégorie |
// Récupération de la liste des demandeurs à notifier et de la catégorie |
6944 |
$categorie = $this->f->get_param_option_notification($collectivite_di); |
$categorie = $this->f->get_param_option_notification($collectivite_di); |
6945 |
$isPortal = $categorie == null || $categorie == '' || $categorie == PORTAL ? true : false; |
$isPortal = $categorie === PORTAL; |
6946 |
$demandeursANotifie = $this->get_demandeurs_notifiable( |
$demandeursANotifie = $this->get_demandeurs_notifiable( |
6947 |
$this->getVal('dossier'), |
$this->getVal('dossier'), |
6948 |
$isPortal |
$isPortal |
7270 |
"idx" => $idx, |
"idx" => $idx, |
7271 |
)); |
)); |
7272 |
|
|
7273 |
/** |
$qres = $this->f->get_all_results_from_db_query( |
7274 |
* |
sprintf( |
7275 |
*/ |
'SELECT |
7276 |
// |
*, |
7277 |
$sql = "SELECT *, bible.libelle as bible_lib |
bible.libelle as bible_lib |
7278 |
FROM ".DB_PREFIXE."bible |
FROM |
7279 |
LEFT OUTER JOIN ".DB_PREFIXE."dossier_autorisation_type |
%1$sbible |
7280 |
ON bible.dossier_autorisation_type=dossier_autorisation_type.dossier_autorisation_type |
LEFT OUTER JOIN %1$sdossier_autorisation_type |
7281 |
LEFT JOIN ".DB_PREFIXE."om_collectivite |
ON bible.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
7282 |
ON bible.om_collectivite = om_collectivite.om_collectivite |
LEFT JOIN %1$som_collectivite |
7283 |
WHERE (evenement=".$evenement." OR evenement IS NULL) |
ON bible.om_collectivite = om_collectivite.om_collectivite |
7284 |
AND (complement=".$complement." OR complement IS NULL) |
WHERE |
7285 |
AND (bible.dossier_autorisation_type IS NULL |
(evenement = %2$d |
7286 |
OR dossier_autorisation_type.code ='".$code_da_type."') |
OR evenement IS NULL) |
7287 |
AND (om_collectivite.niveau = '2' |
AND (complement = %3$d |
7288 |
OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").") |
OR complement IS NULL) |
7289 |
ORDER BY bible_lib ASC"; |
AND (bible.dossier_autorisation_type IS NULL |
7290 |
$res = $this->f->db->query($sql); |
OR dossier_autorisation_type.code = \'%4$s\') |
7291 |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\");", VERBOSE_MODE); |
AND (om_collectivite.niveau = \'2\' |
7292 |
$this->f->isDatabaseError($res); |
OR bible.om_collectivite = %5$d) |
7293 |
|
ORDER BY |
7294 |
|
bible_lib ASC', |
7295 |
|
DB_PREFIXE, |
7296 |
|
intval($evenement), |
7297 |
|
intval($complement), |
7298 |
|
$this->f->db->escapeSimple($code_da_type), |
7299 |
|
intval($dossier->getVal("om_collectivite")) |
7300 |
|
), |
7301 |
|
array( |
7302 |
|
'origin' => __METHOD__ |
7303 |
|
) |
7304 |
|
); |
7305 |
// |
// |
7306 |
echo "<form method=\"post\" name=\"f3\" action=\"#\">\n"; |
echo "<form method=\"post\" name=\"f3\" action=\"#\">\n"; |
7307 |
// |
// |
7308 |
if ($res->numrows() > 0) { |
if ($qres['row_count'] > 0) { |
7309 |
// |
// |
7310 |
echo "\t<table id='tab-bible' width='100%'>\n"; |
echo "\t<table id='tab-bible' width='100%'>\n"; |
7311 |
// |
// |
7316 |
// |
// |
7317 |
$i = 0; |
$i = 0; |
7318 |
// |
// |
7319 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
foreach ($qres['result'] as $row) { |
7320 |
// |
// |
7321 |
echo "\t\t<tr"; |
echo "\t\t<tr"; |
7322 |
echo " class=\"".($i % 2 == 0 ? "odd" : "even")."\""; |
echo " class=\"".($i % 2 == 0 ? "odd" : "even")."\""; |
7384 |
$retour['complement2_om_html'] = ''; |
$retour['complement2_om_html'] = ''; |
7385 |
$retour['complement3_om_html'] = ''; |
$retour['complement3_om_html'] = ''; |
7386 |
$retour['complement4_om_html'] = ''; |
$retour['complement4_om_html'] = ''; |
7387 |
|
|
7388 |
// Vérification d'une consultation liée à l'événement |
// Vérification d'une consultation liée à l'événement |
7389 |
$consultation = $this->f->db->getOne( |
$instEvenement = $this->f->get_inst__om_dbform(array( |
7390 |
"select consultation from ".DB_PREFIXE."evenement where evenement=".$evenement |
"obj" => "evenement", |
7391 |
); |
"idx" => $evenement, |
7392 |
$this->f->isDatabaseError($consultation); |
)); |
7393 |
|
|
7394 |
// Si consultation liée, récupération du retour d'avis |
// Si consultation liée, récupération du retour d'avis |
7395 |
if($consultation=='Oui'){ |
if($instEvenement->getVal('consultation') == 'Oui'){ |
7396 |
$sql = sprintf( |
|
7397 |
'(SELECT |
$qres = $this->f->get_all_results_from_db_query( |
7398 |
date_retour, |
sprintf( |
7399 |
avis_consultation.libelle as avis_consultation, |
'SELECT |
7400 |
COALESCE(service.libelle, tiers_consulte.libelle) as service |
date_retour, |
7401 |
FROM |
avis_consultation.libelle as avis_consultation, |
7402 |
%1$sconsultation |
COALESCE(service.libelle, tiers_consulte.libelle) as service |
7403 |
LEFT JOIN %1$stiers_consulte ON consultation.tiers_consulte = tiers_consulte.tiers_consulte |
FROM |
7404 |
LEFT JOIN %1$sservice ON consultation.service = service.service |
%1$sconsultation |
7405 |
LEFT JOIN %1$savis_consultation ON consultation.avis_consultation = avis_consultation.avis_consultation |
LEFT JOIN %1$stiers_consulte |
7406 |
WHERE |
ON consultation.tiers_consulte = tiers_consulte.tiers_consulte |
7407 |
dossier = \'%2$s\' |
LEFT JOIN %1$sservice |
7408 |
AND consultation.visible)', |
ON consultation.service = service.service |
7409 |
DB_PREFIXE, |
LEFT JOIN %1$savis_consultation |
7410 |
$this->f->db->escapeSimple($idx) |
ON consultation.avis_consultation = avis_consultation.avis_consultation |
7411 |
|
WHERE |
7412 |
|
dossier = \'%2$s\' |
7413 |
|
AND consultation.visible', |
7414 |
|
DB_PREFIXE, |
7415 |
|
$this->f->db->escapeSimple($idx) |
7416 |
|
), |
7417 |
|
array( |
7418 |
|
'origin' => __METHOD__ |
7419 |
|
) |
7420 |
); |
); |
|
$res = $this->f->db->query($sql); |
|
|
$this->f->isDatabaseError($res); |
|
7421 |
// Récupération des consultations |
// Récupération des consultations |
7422 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
foreach ($qres['result'] as $row) { |
7423 |
$correct=false; |
$correct=false; |
7424 |
// date retour |
// date retour |
7425 |
if ($row['date_retour']<>""){ |
if ($row['date_retour']<>""){ |
7547 |
* @param integer $event id de l'événement |
* @param integer $event id de l'événement |
7548 |
* @param string $idx id du dossier |
* @param string $idx id du dossier |
7549 |
* @param integer $compnb numéro du champ complement |
* @param integer $compnb numéro du champ complement |
7550 |
|
* @param string $type types possibles : automatique ou precharge |
7551 |
* |
* |
7552 |
* @return string Chaîne de texte à insérer dans le champ complement |
* @return string Chaîne de texte à insérer dans le champ complement |
7553 |
*/ |
*/ |
7554 |
function getBible($event, $idx, $compnb) { |
function getBible($event, $idx, $compnb, $type = 'automatique') { |
7555 |
// Récupération de la collectivité du dossier |
// Récupération de la collectivité du dossier |
7556 |
$dossier = $this->f->get_inst__om_dbform(array( |
$dossier = $this->f->get_inst__om_dbform(array( |
7557 |
"obj" => "dossier", |
"obj" => "dossier", |
7562 |
if (preg_match('/[A-Za-z]{2,3}/', $idx, $matches) !== false) { |
if (preg_match('/[A-Za-z]{2,3}/', $idx, $matches) !== false) { |
7563 |
$code_da_type = $matches[0]; |
$code_da_type = $matches[0]; |
7564 |
} |
} |
|
// |
|
|
$sql = "SELECT * FROM ".DB_PREFIXE."bible |
|
|
LEFT OUTER JOIN ".DB_PREFIXE."dossier_autorisation_type |
|
|
ON bible.dossier_autorisation_type= |
|
|
dossier_autorisation_type.dossier_autorisation_type |
|
|
LEFT JOIN |
|
|
".DB_PREFIXE."om_collectivite |
|
|
ON bible.om_collectivite = om_collectivite.om_collectivite |
|
|
WHERE (evenement =".$event." or evenement IS NULL) and |
|
|
(complement=".$compnb." OR complement IS NULL) and |
|
|
automatique='Oui' and |
|
|
(dossier_autorisation_type.code ='".$code_da_type."' or |
|
|
bible.dossier_autorisation_type IS NULL) and |
|
|
(om_collectivite.niveau = '2' OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").")"; |
|
7565 |
|
|
7566 |
$res = $this->f->db->query($sql); |
// Prépare le filtre de la requête selon le type de remplissage voulu |
7567 |
$this->f->isDatabaseError($res); |
$sql_filter_type = ''; |
7568 |
|
if ($type === 'automatique') { |
7569 |
|
$sql_filter_type = "AND automatique = 'Oui'"; |
7570 |
|
} elseif ($type === 'precharge') { |
7571 |
|
$sql_filter_type = "AND precharge IS TRUE"; |
7572 |
|
} |
7573 |
|
|
7574 |
|
$qres = $this->f->get_all_results_from_db_query( |
7575 |
|
sprintf( |
7576 |
|
'SELECT |
7577 |
|
* |
7578 |
|
FROM |
7579 |
|
%1$sbible |
7580 |
|
LEFT OUTER JOIN %1$sdossier_autorisation_type |
7581 |
|
ON bible.dossier_autorisation_type = |
7582 |
|
dossier_autorisation_type.dossier_autorisation_type |
7583 |
|
LEFT JOIN %1$som_collectivite |
7584 |
|
ON bible.om_collectivite = om_collectivite.om_collectivite |
7585 |
|
WHERE |
7586 |
|
(evenement = %2$d |
7587 |
|
OR evenement IS NULL) |
7588 |
|
AND (complement = %3$d |
7589 |
|
OR complement IS NULL) |
7590 |
|
AND (dossier_autorisation_type.code = \'%4$s\' |
7591 |
|
OR bible.dossier_autorisation_type IS NULL) |
7592 |
|
AND (om_collectivite.niveau = \'2\' |
7593 |
|
OR bible.om_collectivite = %5$d) |
7594 |
|
%6$s', |
7595 |
|
DB_PREFIXE, |
7596 |
|
intval($event), |
7597 |
|
intval($compnb), |
7598 |
|
$this->f->db->escapeSimple($code_da_type), |
7599 |
|
intval($dossier->getVal("om_collectivite")), |
7600 |
|
$sql_filter_type |
7601 |
|
), |
7602 |
|
array( |
7603 |
|
"origin" => __METHOD__ |
7604 |
|
) |
7605 |
|
); |
7606 |
$temp = ""; |
$temp = ""; |
7607 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
foreach ($qres['result'] as $row) { |
7608 |
// Remplacement des retours à la ligne par des br |
// Remplacement des retours à la ligne par des br |
7609 |
$temp .= preg_replace( |
$temp .= preg_replace( |
7610 |
'#(\\\r|\\\r\\\n|\\\n)#', '<br/>', $row['contenu'] |
'#(\\\r|\\\r\\\n|\\\n)#', '<br/>', $row['contenu'] |
7658 |
// Affiche le message de validation |
// Affiche le message de validation |
7659 |
else { |
else { |
7660 |
// On récupère le libellé du bordereau pour l'afficher à l'utilisateur |
// On récupère le libellé du bordereau pour l'afficher à l'utilisateur |
7661 |
$sql = "SELECT om_etat.libelle |
$etat = $this->f->get_inst__om_dbform(array( |
7662 |
FROM ".DB_PREFIXE."om_etat |
"obj" => "om_etat", |
7663 |
WHERE om_etat.id = '".$this->f->get_submitted_post_value("bordereau")."'"; |
"idx" => $this->f->get_submitted_post_value("bordereau") |
7664 |
$res = $this->f->db->getone($sql); |
)); |
7665 |
$this->f->addToLog(__METHOD__.": db->getone(\"".$sql."\")", VERBOSE_MODE); |
$qres = $this->f->get_one_result_from_db_query( |
7666 |
$this->f->isDatabaseError($res); |
sprintf( |
7667 |
|
'SELECT |
7668 |
|
om_etat.libelle |
7669 |
|
FROM |
7670 |
|
%som_etat |
7671 |
|
WHERE |
7672 |
|
om_etat.id = \'%s\'', |
7673 |
|
DB_PREFIXE, |
7674 |
|
$this->f->db->escapeSimple($this->f->get_submitted_post_value("bordereau")) |
7675 |
|
), |
7676 |
|
array( |
7677 |
|
"origin" => __METHOD__, |
7678 |
|
) |
7679 |
|
); |
7680 |
|
|
7681 |
// |
// |
7682 |
$message_class = "valid"; |
$message_class = "valid"; |
7683 |
$message = _("Cliquez sur le lien ci-dessous pour telecharger votre bordereau"); |
$message = _("Cliquez sur le lien ci-dessous pour telecharger votre bordereau"); |
7695 |
$message .= "&collectivite=".$this->f->get_submitted_post_value("om_collectivite"); |
$message .= "&collectivite=".$this->f->get_submitted_post_value("om_collectivite"); |
7696 |
} |
} |
7697 |
$message .= "'"." target='_blank'>"; |
$message .= "'"." target='_blank'>"; |
7698 |
$message .= $res." "._("du")." ".$this->f->get_submitted_post_value("date_bordereau_debut") |
$message .= $qres['result']." "._("du")." ".$this->f->get_submitted_post_value("date_bordereau_debut") |
7699 |
." "._("au")." ".$this->f->get_submitted_post_value("date_bordereau_fin"); |
." "._("au")." ".$this->f->get_submitted_post_value("date_bordereau_fin"); |
7700 |
$message .= "</a>"; |
$message .= "</a>"; |
7701 |
} |
} |
7757 |
// Données du select - On récupère ici la liste de tous les états disponibles |
// Données du select - On récupère ici la liste de tous les états disponibles |
7758 |
// dans la table om_etat qui ont un id qui commence par la cahine de caractères |
// dans la table om_etat qui ont un id qui commence par la cahine de caractères |
7759 |
// 'bordereau_' |
// 'bordereau_' |
7760 |
$sql = "SELECT om_etat.id, om_etat.libelle |
$qres = $this->f->get_all_results_from_db_query( |
7761 |
FROM ".DB_PREFIXE."om_etat |
sprintf( |
7762 |
WHERE om_etat.id LIKE 'bordereau_%' |
'SELECT |
7763 |
ORDER BY om_etat.id"; |
om_etat.id, |
7764 |
$res = $this->f->db->query($sql); |
om_etat.libelle |
7765 |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
FROM |
7766 |
$this->f->isDatabaseError($res); |
%1$som_etat |
7767 |
|
WHERE |
7768 |
|
om_etat.id LIKE \'bordereau_%%\' |
7769 |
|
ORDER BY |
7770 |
|
om_etat.id', |
7771 |
|
DB_PREFIXE |
7772 |
|
), |
7773 |
|
array( |
7774 |
|
"origin" => __METHOD__ |
7775 |
|
) |
7776 |
|
); |
7777 |
// Données du select |
// Données du select |
7778 |
$contenu = array( |
$contenu = array( |
7779 |
0 => array("", ), |
0 => array("", ), |
7780 |
1 => array(_("choisir bordereau")), |
1 => array(_("choisir bordereau")), |
7781 |
); |
); |
7782 |
while ($row =& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
foreach ($qres['result'] as $row) { |
7783 |
$contenu[0][] = $row['id']; |
$contenu[0][] = $row['id']; |
7784 |
$contenu[1][] = $row['libelle']; |
$contenu[1][] = $row['libelle']; |
7785 |
} |
} |
7791 |
|
|
7792 |
// Données du select - On récupère ici la liste de tous toutes les collectivités |
// Données du select - On récupère ici la liste de tous toutes les collectivités |
7793 |
// de niveau 1 |
// de niveau 1 |
7794 |
$sql = "SELECT om_collectivite, libelle |
$qres = $this->f->get_all_results_from_db_query( |
7795 |
FROM ".DB_PREFIXE."om_collectivite |
sprintf( |
7796 |
WHERE niveau = '1' ORDER BY libelle"; |
'SELECT |
7797 |
$res = $this->f->db->query($sql); |
om_collectivite, |
7798 |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
libelle |
7799 |
$this->f->isDatabaseError($res); |
FROM |
7800 |
|
%1$som_collectivite |
7801 |
|
WHERE |
7802 |
|
niveau = \'1\' |
7803 |
|
ORDER BY |
7804 |
|
libelle', |
7805 |
|
DB_PREFIXE |
7806 |
|
), |
7807 |
|
array( |
7808 |
|
"origin" => __METHOD__ |
7809 |
|
) |
7810 |
|
); |
7811 |
// La valeur par défaut du select est Toutes |
// La valeur par défaut du select est Toutes |
7812 |
$list_collectivites = array( |
$list_collectivites = array( |
7813 |
0 => array("", ), |
0 => array("", ), |
7817 |
$id_colls = ""; |
$id_colls = ""; |
7818 |
// On stocke dans $id_colls l'id de toutes les collectivités de niveau 1 séparées |
// On stocke dans $id_colls l'id de toutes les collectivités de niveau 1 séparées |
7819 |
// par des virgules, pour un traitement plus facile dans la requête de sous-état |
// par des virgules, pour un traitement plus facile dans la requête de sous-état |
7820 |
while ($row =& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
foreach ($qres['result'] as $row) { |
7821 |
if ($id_colls != "") { |
if ($id_colls != "") { |
7822 |
$id_colls .= ","; |
$id_colls .= ","; |
7823 |
} |
} |
7953 |
$conditions = implode(" OR ", $group_clause); |
$conditions = implode(" OR ", $group_clause); |
7954 |
$sql .= " AND (" . $conditions . ")"; |
$sql .= " AND (" . $conditions . ")"; |
7955 |
|
|
7956 |
$nbInstr = $this->f->db->getone($sql); |
$qres = $this->f->get_one_result_from_db_query( |
7957 |
$this->f->addToLog(__METHOD__.": db->getone(\"".$sql."\")", VERBOSE_MODE); |
$sql, |
7958 |
$this->f->isDatabaseError($nbInstr); |
array( |
7959 |
// |
"origin" => __METHOD__, |
7960 |
if ($nbInstr == "1") { |
) |
7961 |
|
); |
7962 |
|
|
7963 |
|
if ($qres['result'] == "1") { |
7964 |
// Récupération de la date d'envoi de l'instruction bippé |
// Récupération de la date d'envoi de l'instruction bippé |
7965 |
$sql = "SELECT to_char(date_envoi_rar,'DD/MM/YYYY') as date_envoi_rar, instruction FROM ".DB_PREFIXE."instruction WHERE code_barres='".$code_barres."'"; |
$qres = $this->f->get_all_results_from_db_query( |
7966 |
$res = $this->f->db->query($sql); |
sprintf( |
7967 |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
'SELECT |
7968 |
$this->f->isDatabaseError($res); |
to_char(date_envoi_rar, \'DD/MM/YYYY\') as date_envoi_rar, |
7969 |
$row =& $res->fetchRow(DB_FETCHMODE_ASSOC); |
instruction |
7970 |
|
FROM |
7971 |
|
%1$sinstruction |
7972 |
|
WHERE |
7973 |
|
code_barres = \'%2$s\'', |
7974 |
|
DB_PREFIXE, |
7975 |
|
$this->f->db->escapeSimple($code_barres) |
7976 |
|
), |
7977 |
|
array( |
7978 |
|
'origin' => __METHOD__ |
7979 |
|
) |
7980 |
|
); |
7981 |
|
$row = array_shift($qres['result']); |
7982 |
// Si pas de date ou correspond à la date du formulaire on |
// Si pas de date ou correspond à la date du formulaire on |
7983 |
// effectue le traitement |
// effectue le traitement |
7984 |
if ($row["date_envoi_rar"] == "" || $row["date_envoi_rar"] == $date) { |
if ($row["date_envoi_rar"] == "" || $row["date_envoi_rar"] == $date) { |
8274 |
if ($this->f->get_submitted_post_value('validation') !== null) { |
if ($this->f->get_submitted_post_value('validation') !== null) { |
8275 |
if(!empty($type_mise_a_jour) and !empty($date) and !empty($code_barres)) { |
if(!empty($type_mise_a_jour) and !empty($date) and !empty($code_barres)) { |
8276 |
|
|
|
// Vérification de l'existence de l'instruction |
|
|
$sql = "SELECT instruction |
|
|
FROM ".DB_PREFIXE."instruction |
|
|
INNER JOIN ".DB_PREFIXE."dossier |
|
|
ON dossier.dossier=instruction.dossier |
|
|
INNER JOIN ".DB_PREFIXE."dossier_instruction_type |
|
|
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
|
|
INNER JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille |
|
|
ON dossier_instruction_type.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
|
|
INNER JOIN ".DB_PREFIXE."dossier_autorisation_type |
|
|
ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
|
|
INNER JOIN ".DB_PREFIXE."groupe |
|
|
ON dossier_autorisation_type.groupe = groupe.groupe |
|
|
WHERE code_barres='".$this->f->db->escapesimple($code_barres)."'"; |
|
|
|
|
8277 |
// Ajout d'un filtre sur les groupes auxquels l'utilisateur a accès |
// Ajout d'un filtre sur les groupes auxquels l'utilisateur a accès |
8278 |
$group_clause = array(); |
$group_clause = array(); |
8279 |
foreach ($_SESSION["groupe"] as $key => $value) { |
foreach ($_SESSION["groupe"] as $key => $value) { |
8284 |
$group_clause[$key] .= ")"; |
$group_clause[$key] .= ")"; |
8285 |
} |
} |
8286 |
$conditions = implode(" OR ", $group_clause); |
$conditions = implode(" OR ", $group_clause); |
8287 |
$sql .= " AND (" . $conditions . ")"; |
$groupFilter = " AND (" . $conditions . ")"; |
8288 |
|
|
8289 |
|
$qres = $this->f->get_all_results_from_db_query( |
8290 |
$res = $this->f->db->query($sql); |
sprintf( |
8291 |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
'SELECT |
8292 |
$this->f->isDatabaseError($res); |
instruction |
8293 |
|
FROM |
8294 |
if($res->numrows() == 1) { |
%1$sinstruction |
8295 |
|
INNER JOIN %1$sdossier |
8296 |
|
ON dossier.dossier = instruction.dossier |
8297 |
|
INNER JOIN %1$sdossier_instruction_type |
8298 |
|
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
8299 |
|
INNER JOIN %1$sdossier_autorisation_type_detaille |
8300 |
|
ON dossier_instruction_type.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
8301 |
|
INNER JOIN %1$sdossier_autorisation_type |
8302 |
|
ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
8303 |
|
INNER JOIN %1$sgroupe |
8304 |
|
ON dossier_autorisation_type.groupe = groupe.groupe |
8305 |
|
WHERE |
8306 |
|
code_barres = \'%2$s\' |
8307 |
|
%3$s', |
8308 |
|
DB_PREFIXE, |
8309 |
|
$this->f->db->escapeSimple($code_barres), |
8310 |
|
$groupFilter |
8311 |
|
), |
8312 |
|
array( |
8313 |
|
'origin' => __METHOD__ |
8314 |
|
) |
8315 |
|
); |
8316 |
|
if($qres['row_count'] === 1) { |
8317 |
$liste_champs = explode(";", $type_mise_a_jour); |
$liste_champs = explode(";", $type_mise_a_jour); |
8318 |
$row =& $res->fetchRow(DB_FETCHMODE_ASSOC); |
$row = array_shift($qres['result']); |
8319 |
$instr = $this->f->get_inst__om_dbform(array( |
$instr = $this->f->get_inst__om_dbform(array( |
8320 |
"obj" => "instruction", |
"obj" => "instruction", |
8321 |
"idx" => $row['instruction'], |
"idx" => $row['instruction'], |
8401 |
} |
} |
8402 |
} else { |
} else { |
8403 |
// Récupération des infos du dossier |
// Récupération des infos du dossier |
8404 |
$sqlInfo = "SELECT dossier.dossier_libelle, |
$qres = $this->f->get_all_results_from_db_query( |
8405 |
evenement.libelle as evenement, |
sprintf( |
8406 |
autorite_competente.code as autorite_competente_code, |
'SELECT |
8407 |
autorite_competente.libelle as autorite_competente, |
dossier.dossier_libelle, |
8408 |
evenement.type as evenement_type, |
evenement.libelle as evenement, |
8409 |
to_char(date_envoi_signature,'DD/MM/YYYY') as date_envoi_signature, |
autorite_competente.code as autorite_competente_code, |
8410 |
to_char(date_retour_signature,'DD/MM/YYYY') as date_retour_signature, |
autorite_competente.libelle as autorite_competente, |
8411 |
to_char(date_envoi_controle_legalite,'DD/MM/YYYY') as date_envoi_controle_legalite, |
evenement.type as evenement_type, |
8412 |
to_char(date_retour_controle_legalite,'DD/MM/YYYY') as date_retour_controle_legalite, |
to_char(date_envoi_signature,\'DD/MM/YYYY\') as date_envoi_signature, |
8413 |
to_char(date_envoi_rar,'DD/MM/YYYY') as date_envoi_rar, |
to_char(date_retour_signature,\'DD/MM/YYYY\') as date_retour_signature, |
8414 |
to_char(date_retour_rar,'DD/MM/YYYY') as date_retour_rar |
to_char(date_envoi_controle_legalite,\'DD/MM/YYYY\') as date_envoi_controle_legalite, |
8415 |
FROM ".DB_PREFIXE."instruction |
to_char(date_retour_controle_legalite,\'DD/MM/YYYY\') as date_retour_controle_legalite, |
8416 |
INNER JOIN ".DB_PREFIXE."dossier ON |
to_char(date_envoi_rar,\'DD/MM/YYYY\') as date_envoi_rar, |
8417 |
dossier.dossier=instruction.dossier |
to_char(date_retour_rar,\'DD/MM/YYYY\') as date_retour_rar |
8418 |
LEFT JOIN ".DB_PREFIXE."autorite_competente ON |
FROM |
8419 |
dossier.autorite_competente=autorite_competente.autorite_competente |
%1$sinstruction |
8420 |
INNER JOIN ".DB_PREFIXE."evenement ON |
INNER JOIN %1$sdossier |
8421 |
instruction.evenement=evenement.evenement |
ON dossier.dossier=instruction.dossier |
8422 |
WHERE code_barres='".$code_barres."'"; |
LEFT JOIN %1$sautorite_competente |
8423 |
$resInfo = $this->f->db->query($sqlInfo); |
ON dossier.autorite_competente=autorite_competente.autorite_competente |
8424 |
$this->f->isDatabaseError($resInfo); |
INNER JOIN %1$sevenement |
8425 |
$infos = $resInfo->fetchRow(DB_FETCHMODE_ASSOC); |
ON instruction.evenement=evenement.evenement |
8426 |
|
WHERE |
8427 |
|
code_barres = \'%2$s\'', |
8428 |
|
DB_PREFIXE, |
8429 |
|
$this->f->db->escapeSimple($code_barres) |
8430 |
|
), |
8431 |
|
array( |
8432 |
|
"origin" => __METHOD__ |
8433 |
|
) |
8434 |
|
); |
8435 |
|
$infos = array_shift($qres['result']); |
8436 |
|
|
8437 |
// Vérification de la non modification des dates de suivi |
// Vérification de la non modification des dates de suivi |
8438 |
foreach(explode(";", $type_mise_a_jour) as $champ) { |
foreach(explode(";", $type_mise_a_jour) as $champ) { |
8658 |
foreach ($listeCodeBarres as $code_barres) { |
foreach ($listeCodeBarres as $code_barres) { |
8659 |
|
|
8660 |
// On récupère le dossier |
// On récupère le dossier |
8661 |
$sql = "SELECT dossier |
$qres = $this->f->get_one_result_from_db_query( |
8662 |
FROM " . DB_PREFIXE . "instruction |
sprintf( |
8663 |
WHERE code_barres = '" . $code_barres . "'"; |
'SELECT |
8664 |
$dossier = $this->f->db->getOne($sql); |
dossier |
8665 |
$this->f->addToLog(__METHOD__."(): db->getOne(\"".$sql."\")", VERBOSE_MODE); |
FROM |
8666 |
$this->f->isDatabaseError($dossier); |
%1$sinstruction |
8667 |
|
WHERE |
8668 |
|
code_barres = \'%2$s\'', |
8669 |
|
DB_PREFIXE, |
8670 |
|
$this->f->db->escapeSimple($code_barres) |
8671 |
|
), |
8672 |
|
array( |
8673 |
|
"origin" => __METHOD__, |
8674 |
|
) |
8675 |
|
); |
8676 |
|
|
8677 |
$inst_dossier = $this->f->get_inst__om_dbform(array( |
$inst_dossier = $this->f->get_inst__om_dbform(array( |
8678 |
"obj" => "dossier", |
"obj" => "dossier", |
8679 |
"idx" => $dossier, |
"idx" => $qres['result'], |
8680 |
)); |
)); |
8681 |
|
|
8682 |
// En fonction du type de dossier, on récupère un demandeur différent dans les requêtes |
// En fonction du type de dossier, on récupère un demandeur différent dans les requêtes |
8697 |
} |
} |
8698 |
|
|
8699 |
// Test si l'evenement est de type arrete et si un délégataire a été nommé |
// Test si l'evenement est de type arrete et si un délégataire a été nommé |
8700 |
$sql = "SELECT |
$qres = $this->f->get_all_results_from_db_query( |
8701 |
|
sprintf( |
8702 |
|
'SELECT |
8703 |
dossier.dossier_libelle, |
dossier.dossier_libelle, |
8704 |
evenement.type, |
evenement.type, |
8705 |
count(lien_dossier_demandeur) as nbdemandeur, |
count(lien_dossier_demandeur) as nbdemandeur, |
8706 |
CASE |
CASE |
8707 |
WHEN division.libelle IS NOT NULL AND phase.code IS NOT NULL |
WHEN division.libelle IS NOT NULL AND phase.code IS NOT NULL |
8708 |
THEN CONCAT(phase.code, ' - ', division.libelle) |
THEN CONCAT(phase.code, \' - \', division.libelle) |
8709 |
ELSE |
ELSE |
8710 |
phase.code |
phase.code |
8711 |
END AS code_phase |
END AS code_phase |
8712 |
FROM ".DB_PREFIXE."instruction |
FROM |
8713 |
LEFT JOIN ".DB_PREFIXE."dossier |
%1$sinstruction |
8714 |
ON instruction.dossier = dossier.dossier |
LEFT JOIN %1$sdossier |
8715 |
LEFT JOIN ".DB_PREFIXE."division |
ON instruction.dossier = dossier.dossier |
8716 |
ON dossier.division = division.division |
LEFT JOIN %1$sdivision |
8717 |
INNER JOIN ".DB_PREFIXE."evenement ON |
ON dossier.division = division.division |
8718 |
instruction.evenement=evenement.evenement |
INNER JOIN %1$sevenement |
8719 |
LEFT JOIN ".DB_PREFIXE."phase |
ON instruction.evenement=evenement.evenement |
8720 |
ON evenement.phase = phase.phase |
LEFT JOIN %1$sphase |
8721 |
inner JOIN ".DB_PREFIXE."lien_dossier_demandeur ON |
ON evenement.phase = phase.phase |
8722 |
instruction.dossier=lien_dossier_demandeur.dossier |
inner JOIN %1$slien_dossier_demandeur |
8723 |
inner join ".DB_PREFIXE."demandeur on |
ON instruction.dossier=lien_dossier_demandeur.dossier |
8724 |
demandeur.demandeur=lien_dossier_demandeur.demandeur |
inner join %1$sdemandeur |
8725 |
WHERE code_barres='".$code_barres."' |
ON demandeur.demandeur=lien_dossier_demandeur.demandeur |
8726 |
AND " . $sql_demandeur . " |
WHERE |
8727 |
GROUP BY dossier.dossier_libelle, evenement.type, phase.code, division.libelle"; |
code_barres = \'%2$s\' |
8728 |
|
AND %3$s |
8729 |
$res = $this->f->db->query($sql); |
GROUP BY |
8730 |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
dossier.dossier_libelle, |
8731 |
$this->f->isDatabaseError($res); |
evenement.type, |
8732 |
$testDemandeur = $res->fetchrow(DB_FETCHMODE_ASSOC); |
phase.code, |
8733 |
|
division.libelle', |
8734 |
|
DB_PREFIXE, |
8735 |
|
$this->f->db->escapeSimple($code_barres), |
8736 |
|
$sql_demandeur |
8737 |
|
), |
8738 |
|
array( |
8739 |
|
"origin" => __METHOD__ |
8740 |
|
) |
8741 |
|
); |
8742 |
|
$testDemandeur = array_shift($qres['result']); |
8743 |
|
|
8744 |
|
|
8745 |
// Recuperation de l'adresse de destination |
// Recuperation de l'adresse de destination |
|
$sqlAdresse = "SELECT |
|
|
CASE WHEN demandeur.qualite='particulier' |
|
|
THEN TRIM(CONCAT_WS(' ', pc.libelle, demandeur.particulier_nom, demandeur.particulier_prenom)) |
|
|
ELSE TRIM(demandeur.personne_morale_denomination) |
|
|
END as ligne1, |
|
|
CASE WHEN demandeur.qualite='personne_morale' |
|
|
THEN TRIM(demandeur.personne_morale_raison_sociale) |
|
|
ELSE '' |
|
|
END as ligne1_1, |
|
|
CASE WHEN demandeur.qualite='personne_morale' AND (demandeur.personne_morale_nom IS NOT NULL OR demandeur.personne_morale_prenom IS NOT NULL) |
|
|
THEN TRIM(CONCAT_WS(' ', 'rep. par', demandeur.personne_morale_nom, demandeur.personne_morale_prenom)) |
|
|
ELSE '' |
|
|
END as ligne1_2, |
|
|
trim(concat(demandeur.numero,' ',demandeur.voie)) as ligne2, |
|
|
CASE demandeur.complement |
|
|
WHEN null THEN '' |
|
|
ELSE trim(demandeur.complement) |
|
|
END as ligne3, |
|
|
CASE demandeur.lieu_dit |
|
|
WHEN null THEN '' |
|
|
ELSE trim(demandeur.lieu_dit) |
|
|
END as ligne4, |
|
|
CONCAT_WS(' ', demandeur.code_postal, demandeur.localite, |
|
|
(CASE WHEN demandeur.bp IS NOT NULL |
|
|
THEN CONCAT_WS(' ', 'BP', demandeur.bp) |
|
|
ELSE '' |
|
|
END), |
|
|
(CASE WHEN demandeur.cedex IS NOT NULL |
|
|
THEN CONCAT_WS(' ', 'CEDEX', demandeur.cedex) |
|
|
ELSE '' |
|
|
END)) |
|
|
as ligne5, |
|
|
code_barres as code_barres |
|
|
FROM ".DB_PREFIXE."instruction |
|
|
INNER JOIN ".DB_PREFIXE."dossier ON dossier.dossier = instruction.dossier |
|
|
INNER JOIN ".DB_PREFIXE."lien_dossier_demandeur ON dossier.dossier = lien_dossier_demandeur.dossier |
|
|
INNER JOIN ".DB_PREFIXE."demandeur ON lien_dossier_demandeur.demandeur = demandeur.demandeur |
|
|
LEFT OUTER JOIN ".DB_PREFIXE."civilite as pc ON demandeur.particulier_civilite = pc.civilite OR demandeur.personne_morale_civilite = pc.civilite |
|
|
WHERE instruction.code_barres ='".$code_barres."'"; |
|
|
|
|
8746 |
// Envoi pour delegataire ou petitionnaire principal selon le type d'evenement |
// Envoi pour delegataire ou petitionnaire principal selon le type d'evenement |
8747 |
|
$sqlAdresse = " AND demandeur.type_demandeur='petitionnaire' AND lien_dossier_demandeur.petitionnaire_principal IS TRUE"; |
8748 |
if($testDemandeur['type'] != 'arrete' AND $testDemandeur['nbdemandeur'] > 1) { |
if($testDemandeur['type'] != 'arrete' AND $testDemandeur['nbdemandeur'] > 1) { |
8749 |
$sqlAdresse .= " AND demandeur.type_demandeur='delegataire'"; |
$sqlAdresse = " AND demandeur.type_demandeur='delegataire'"; |
|
} else { |
|
|
$sqlAdresse .= " AND demandeur.type_demandeur='petitionnaire' AND lien_dossier_demandeur.petitionnaire_principal IS TRUE"; |
|
8750 |
} |
} |
8751 |
|
|
8752 |
$resAdresse = $this->f->db->query($sqlAdresse); |
$qres = $this->f->get_all_results_from_db_query( |
8753 |
$adresse_dest = $resAdresse->fetchrow(DB_FETCHMODE_ASSOC); |
sprintf( |
8754 |
$this->f->addToLog(__METHOD__.": db->query(\"".$sqlAdresse."\")", VERBOSE_MODE); |
'SELECT |
8755 |
$this->f->isDatabaseError($resAdresse); |
CASE WHEN demandeur.qualite = \'particulier\' |
8756 |
|
THEN TRIM(CONCAT_WS(\' \', pc.libelle, demandeur.particulier_nom, demandeur.particulier_prenom)) |
8757 |
|
ELSE TRIM(demandeur.personne_morale_denomination) |
8758 |
|
END as ligne1, |
8759 |
|
CASE WHEN demandeur.qualite = \'personne_morale\' |
8760 |
|
THEN TRIM(demandeur.personne_morale_raison_sociale) |
8761 |
|
ELSE \'\' |
8762 |
|
END as ligne1_1, |
8763 |
|
CASE WHEN demandeur.qualite = \'personne_morale\' AND (demandeur.personne_morale_nom IS NOT NULL OR demandeur.personne_morale_prenom IS NOT NULL) |
8764 |
|
THEN TRIM(CONCAT_WS(\' \', \'rep. par\', demandeur.personne_morale_nom, demandeur.personne_morale_prenom)) |
8765 |
|
ELSE \'\' |
8766 |
|
END as ligne1_2, |
8767 |
|
trim(concat(demandeur.numero,\' \',demandeur.voie)) as ligne2, |
8768 |
|
CASE demandeur.complement |
8769 |
|
WHEN null THEN \'\' |
8770 |
|
ELSE trim(demandeur.complement) |
8771 |
|
END as ligne3, |
8772 |
|
CASE demandeur.lieu_dit |
8773 |
|
WHEN null THEN \'\' |
8774 |
|
ELSE trim(demandeur.lieu_dit) |
8775 |
|
END as ligne4, |
8776 |
|
CONCAT_WS(\' \', demandeur.code_postal, demandeur.localite, |
8777 |
|
(CASE WHEN demandeur.bp IS NOT NULL |
8778 |
|
THEN CONCAT_WS(\' \', \'BP\', demandeur.bp) |
8779 |
|
ELSE \'\' |
8780 |
|
END), |
8781 |
|
(CASE WHEN demandeur.cedex IS NOT NULL |
8782 |
|
THEN CONCAT_WS(\' \', \'CEDEX\', demandeur.cedex) |
8783 |
|
ELSE \'\' |
8784 |
|
END)) |
8785 |
|
as ligne5, |
8786 |
|
code_barres as code_barres |
8787 |
|
FROM |
8788 |
|
%1$sinstruction |
8789 |
|
INNER JOIN %1$sdossier |
8790 |
|
ON dossier.dossier = instruction.dossier |
8791 |
|
INNER JOIN %1$slien_dossier_demandeur |
8792 |
|
ON dossier.dossier = lien_dossier_demandeur.dossier |
8793 |
|
INNER JOIN %1$sdemandeur |
8794 |
|
ON lien_dossier_demandeur.demandeur = demandeur.demandeur |
8795 |
|
LEFT OUTER JOIN %1$scivilite AS pc |
8796 |
|
ON demandeur.particulier_civilite = pc.civilite |
8797 |
|
OR demandeur.personne_morale_civilite = pc.civilite |
8798 |
|
WHERE |
8799 |
|
instruction.code_barres = \'%2$s\' |
8800 |
|
%3$s', |
8801 |
|
DB_PREFIXE, |
8802 |
|
$this->f->db->escapeSimple($code_barres), |
8803 |
|
$sqlAdresse |
8804 |
|
), |
8805 |
|
array( |
8806 |
|
"origin" => __METHOD__ |
8807 |
|
) |
8808 |
|
); |
8809 |
|
$adresse_dest = array_shift($qres['result']); |
8810 |
|
|
8811 |
// Création adresse destinataire sans ligne vide |
// Création adresse destinataire sans ligne vide |
8812 |
$adresse_destinataire = array(); |
$adresse_destinataire = array(); |
8842 |
} |
} |
8843 |
$pdf_output = $pdf_lettre_rar->output("lettre_rar".date("dmYHis").".pdf","S"); |
$pdf_output = $pdf_lettre_rar->output("lettre_rar".date("dmYHis").".pdf","S"); |
8844 |
$om_edition = $this->f->get_inst__om_edition(); |
$om_edition = $this->f->get_inst__om_edition(); |
8845 |
|
$om_edition->set_object_linked($this); |
8846 |
$om_edition->expose_pdf_output($pdf_output, "lettre_rar".date("dmYHis").".pdf"); |
$om_edition->expose_pdf_output($pdf_output, "lettre_rar".date("dmYHis").".pdf"); |
8847 |
} |
} |
8848 |
} |
} |
9133 |
function get_instruction_by_barcode($barcode) { |
function get_instruction_by_barcode($barcode) { |
9134 |
// Begin |
// Begin |
9135 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
9136 |
|
|
9137 |
// Vérification de l'existence de l'événement d'instruction |
// Vérification de l'existence de l'événement d'instruction |
9138 |
// pour le code-barres donné, en excluant les dossiers liés au groupe CTX |
// pour le code-barres donné, en excluant les dossiers liés au groupe CTX |
9139 |
$sql = "SELECT instruction |
$qres = $this->f->get_one_result_from_db_query( |
9140 |
FROM ".DB_PREFIXE."instruction |
sprintf( |
9141 |
INNER JOIN ".DB_PREFIXE."dossier |
'SELECT |
9142 |
|
instruction |
9143 |
|
FROM |
9144 |
|
%1$sinstruction |
9145 |
|
INNER JOIN %1$sdossier |
9146 |
ON dossier.dossier=instruction.dossier |
ON dossier.dossier=instruction.dossier |
9147 |
INNER JOIN ".DB_PREFIXE."dossier_instruction_type |
INNER JOIN %1$sdossier_instruction_type |
9148 |
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
9149 |
INNER JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille |
INNER JOIN %1$sdossier_autorisation_type_detaille |
9150 |
ON dossier_instruction_type.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
ON dossier_instruction_type.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
9151 |
INNER JOIN ".DB_PREFIXE."dossier_autorisation_type |
INNER JOIN %1$sdossier_autorisation_type |
9152 |
ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
9153 |
INNER JOIN ".DB_PREFIXE."groupe |
INNER JOIN %1$sgroupe |
9154 |
ON dossier_autorisation_type.groupe = groupe.groupe |
ON dossier_autorisation_type.groupe = groupe.groupe |
9155 |
AND groupe.code != 'CTX' |
AND groupe.code != \'CTX\' |
9156 |
WHERE code_barres = '".$this->f->db->escapesimple($barcode)."'"; |
WHERE |
9157 |
$res = $this->f->db->getOne($sql); |
code_barres = \'%2$s\'', |
9158 |
$this->f->addToLog(__METHOD__." : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
DB_PREFIXE, |
9159 |
$this->f->isDatabaseError($res); |
$this->f->db->escapeSimple($barcode) |
9160 |
|
), |
9161 |
|
array( |
9162 |
|
"origin" => __METHOD__, |
9163 |
|
) |
9164 |
|
); |
9165 |
|
|
9166 |
// Retourne résultat |
// Retourne résultat |
9167 |
return $this->end_treatment(__METHOD__, $res); |
return $this->end_treatment(__METHOD__, $qres['result']); |
9168 |
} |
} |
9169 |
|
|
9170 |
/** |
/** |
9365 |
// Cette méthode permet d'exécuter une routine en début des méthodes |
// Cette méthode permet d'exécuter une routine en début des méthodes |
9366 |
// dites de TREATMENT. |
// dites de TREATMENT. |
9367 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
9368 |
$message = __('Erreur de paramétrage :'); |
$message = __('Erreur de paramétrage :'); |
9369 |
$erreurParametrage = false; |
$erreurParametrage = false; |
9370 |
// Récupération du paramétrage de la collectivité du dossier |
// Récupération du paramétrage de la collectivité du dossier |
9371 |
$id_di = $this->getVal('dossier'); |
$id_di = $this->getVal('dossier'); |
9607 |
'idx' => $this->getVal('dossier'), |
'idx' => $this->getVal('dossier'), |
9608 |
)); |
)); |
9609 |
|
|
9610 |
|
//Instanciation de la classe electronicsignature |
9611 |
|
$inst_es = $this->get_electronicsignature_instance(); |
9612 |
|
if ($inst_es === false) { |
9613 |
|
$this->correct = false; |
9614 |
|
return $this->end_treatment(__METHOD__, false); |
9615 |
|
} |
9616 |
|
|
9617 |
|
// Vérifie si la notification se fait via l'application ou via le parapheur |
9618 |
|
try { |
9619 |
|
$notification_required = $inst_es->signer_notification_is_delegated(); |
9620 |
|
} catch(electronicsignature_connector_method_not_implemented_exception $_) { |
9621 |
|
// Si la méthode n'existe pas, on considère que la notification est faite par le parapheur |
9622 |
|
$notification_required = false; |
9623 |
|
} |
9624 |
|
|
9625 |
|
// Si la notification est faite par l'application vérifie que l'adresse mail du |
9626 |
|
// signataire est correcte. Si ce n'est pas le cas le document n'est pas envoyé |
9627 |
|
// au parapheur car il ne sera pas accessible sans le lien transmis dans la |
9628 |
|
// notification |
9629 |
|
if ($notification_required === true) { |
9630 |
|
$signer_mail = $inst_signataire_arrete->getVal('email'); |
9631 |
|
$signer_name = trim($inst_signataire_arrete->getVal('prenom').' '.$inst_signataire_arrete->getVal('nom')); |
9632 |
|
|
9633 |
|
$err_msg = __('Le document n\'a pas pu être envoyé en signature car '); |
9634 |
|
|
9635 |
|
if (empty($signer_mail)) { |
9636 |
|
$this->correct = false; |
9637 |
|
$err_detail = sprintf(__("l'email du signataire '%s' est vide."), $signer_name); |
9638 |
|
$this->addToMessage($err_msg.$err_detail); |
9639 |
|
$this->addToLog(__METHOD__.$err_msg.$err_detail.' Instruction : '.$this->getVal($this->clePrimaire), DEBUG_MODE); |
9640 |
|
return $this->end_treatment(__METHOD__, false); |
9641 |
|
} |
9642 |
|
if (! $this->f->checkValidEmailAddress($signer_mail)) { |
9643 |
|
$this->correct = false; |
9644 |
|
$err_detail = sprintf(__("l'email du signataire '%s' est invalide (%s)."), $signer_name, $signer_mail); |
9645 |
|
$this->addToMessage($err_msg.$err_detail); |
9646 |
|
$this->addToLog(__METHOD__.$err_msg.$err_detail.' Instruction : '.$this->getVal($this->clePrimaire), DEBUG_MODE); |
9647 |
|
return $this->end_treatment(__METHOD__, false); |
9648 |
|
} |
9649 |
|
} |
9650 |
|
|
9651 |
// Récupération du document à signer |
// Récupération du document à signer |
9652 |
$file = $this->f->storage->get($this->getVal('om_fichier_instruction')); |
$file = $this->f->storage->get($this->getVal('om_fichier_instruction')); |
9653 |
if ($file === OP_FAILURE) { |
if ($file === OP_FAILURE) { |
9665 |
"signataire_arrete_nom" => $inst_signataire_arrete->getVal('nom'), |
"signataire_arrete_nom" => $inst_signataire_arrete->getVal('nom'), |
9666 |
"signataire_arrete_prenom" => $inst_signataire_arrete->getVal('prenom'), |
"signataire_arrete_prenom" => $inst_signataire_arrete->getVal('prenom'), |
9667 |
// Permet d'envoyer en signature l'instruction le jour de la date limite |
// Permet d'envoyer en signature l'instruction le jour de la date limite |
9668 |
"date_limite_instruction" => $this->compute_date_limite(1), |
"date_limite_instruction" => $this->compute_date_limite(1) != null ? $this->compute_date_limite(1) : null, |
9669 |
"dossier" => $this->getVal('dossier'), |
"dossier" => $this->getVal('dossier'), |
9670 |
"is_forced_view_files" => $is_forced_view_files, |
"is_forced_view_files" => $is_forced_view_files, |
9671 |
'commentaire_signature' => $is_forced_view_files === true ? __('relecture demandee.') : null |
'commentaire_signature' => $is_forced_view_files === true ? __('relecture demandee.') : null |
9681 |
$metadonnee_dossier['titre_document'] = $this->getDocumentTitre(); |
$metadonnee_dossier['titre_document'] = $this->getDocumentTitre(); |
9682 |
|
|
9683 |
$metadonnee_dossier['url_di'] = sprintf( |
$metadonnee_dossier['url_di'] = sprintf( |
9684 |
'%sapp/index.php?module=form&direct_link=true&obj=dossier_instruction&action=3&direct_field=dossier&direct_form=instruction&direct_action=3&direct_idx=%s', |
'%1$sapp/index.php?module=form&direct_link=true&obj=dossier_instruction&action=3&idx=%2$s&direct_field=dossier&direct_form=document_numerise&direct_action=4&direct_idx=%2$s', |
9685 |
$this->f->get_param_base_path_metadata_url_di() !== null ? $this->f->get_param_base_path_metadata_url_di() : PATH_BASE_URL, |
$this->f->get_param_base_path_metadata_url_di() !== null ? $this->f->get_param_base_path_metadata_url_di() : PATH_BASE_URL, |
9686 |
$this->getVal($this->clePrimaire) |
$this->getVal('dossier') |
9687 |
); |
); |
9688 |
|
|
9689 |
$optional_data = null; |
$optional_data = null; |
9702 |
} |
} |
9703 |
} |
} |
9704 |
|
|
|
//Instanciation de la classe electronicsignature |
|
|
$inst_es = $this->get_electronicsignature_instance(); |
|
|
if ($inst_es === false) { |
|
|
$this->correct = false; |
|
|
return $this->end_treatment(__METHOD__, false); |
|
|
} |
|
|
|
|
9705 |
// Appel de la méthode de l'abstracteur send_for_signature() |
// Appel de la méthode de l'abstracteur send_for_signature() |
9706 |
// Cette méthode doit retourner un tableau de valeur |
// Cette méthode doit retourner un tableau de valeur |
9707 |
try { |
try { |
9724 |
$valF['commentaire_signature'] = isset($result['commentaire_signature']) == true ? $result['commentaire_signature'] : null; |
$valF['commentaire_signature'] = isset($result['commentaire_signature']) == true ? $result['commentaire_signature'] : null; |
9725 |
$valF['date_envoi_signature'] = date("Y-m-d", strtotime($result['date_envoi_signature'])); |
$valF['date_envoi_signature'] = date("Y-m-d", strtotime($result['date_envoi_signature'])); |
9726 |
$valF['historique_signature'] = $this->get_updated_historique_signature($result); |
$valF['historique_signature'] = $this->get_updated_historique_signature($result); |
9727 |
|
$valF['parapheur_lien_page_signature'] = isset($result['signature_page_url']) ? $result['signature_page_url'] : null; |
9728 |
$ret = $this->modifier($valF); |
$ret = $this->modifier($valF); |
9729 |
|
|
9730 |
if ($ret === false) { |
if ($ret === false) { |
9734 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
9735 |
} |
} |
9736 |
|
|
9737 |
|
// Notification du signataire |
9738 |
|
if ($notification_required === true) { |
9739 |
|
if ($this->notify_signer($signer_name, $signer_mail, $data['om_utilisateur_nom']) === false) { |
9740 |
|
$msg = __("Une erreur s'est produite lors de la notification du signataire \"%s (%s)\". Annulation de l'envoi pour signature du document%s."); |
9741 |
|
$this->addToMessage(sprintf($msg, $signer_name, $signer_mail, '')); |
9742 |
|
$this->addToLog(sprintf($msg, $signer_name, $signer_mail, ' : '.$this->getVal($this->clePrimaire)), DEBUG_MODE); |
9743 |
|
// Met à jour les valeurs de l'objet courant pour prendre en compte les modifications faites |
9744 |
|
// precedemment |
9745 |
|
$this->init_record_data($this->getVal($this->clePrimaire)); |
9746 |
|
$this->annuler_envoi_en_signature(); |
9747 |
|
$this->correct = false; |
9748 |
|
return $this->end_treatment(__METHOD__, true); |
9749 |
|
} |
9750 |
|
} |
9751 |
|
|
9752 |
// Message |
// Message |
9753 |
$this->addToMessage(__("Le document a été envoyé pour signature dans le parapheur.")); |
$this->addToMessage(__("Le document a été envoyé pour signature dans le parapheur.")); |
9754 |
if (array_key_exists('signature_page_url', $result) === true) { |
if ($this->f->is_option_enabled('option_afficher_lien_parapheur') === true |
9755 |
|
&& array_key_exists('signature_page_url', $result) === true) { |
9756 |
$this->addToMessage(sprintf( |
$this->addToMessage(sprintf( |
9757 |
'<br> > <a href="%1$s" title="%2$s" target="_blank">%2$s</a>', |
'<br> > <a href="%1$s" title="%2$s" target="_blank">%2$s</a>', |
9758 |
$result['signature_page_url'], |
$result['signature_page_url'], |
9759 |
__("Signez directement le document") |
__("Signez directement le document") |
9760 |
)); |
)); |
9761 |
} |
} |
9762 |
|
if ($notification_required !== true) { |
9763 |
|
$this->addToMessage(__("L'envoi de la notification au signataire est effectué par la plateforme.")); |
9764 |
|
} |
9765 |
|
|
9766 |
// Tout s'est bien passé, on termine le traitement |
// Tout s'est bien passé, on termine le traitement |
9767 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
9768 |
} |
} |
9769 |
|
|
9770 |
/** |
/** |
9771 |
|
* Notifie le signataire d'un document à signer. |
9772 |
|
* Gère l'affichage des messages à destination de l'utilisateur selon l'état du traitement. |
9773 |
|
* En cas d'erreur ajoute une ligne dans les logs de l'application. |
9774 |
|
* |
9775 |
|
* @param string $signer_name Nom du signataire |
9776 |
|
* @param string $signer_mail Mail du signataire |
9777 |
|
* @param string $user_name Nom de l'utilisateur openADS courant |
9778 |
|
* |
9779 |
|
* @return boolean true si succés, false si erreur |
9780 |
|
*/ |
9781 |
|
protected function notify_signer($signer_name, $signer_mail, $user_name) { |
9782 |
|
// message d'erreur |
9783 |
|
$err_msg_log = sprintf( |
9784 |
|
__("Échec de la notification du signataire \"%s (%s)\" lors de l'envoi au parapaheur du document de l'instruction : %s"), |
9785 |
|
$signer_name, |
9786 |
|
$signer_mail, |
9787 |
|
$this->getVal($this->clePrimaire) |
9788 |
|
); |
9789 |
|
$err_msg = sprintf( |
9790 |
|
'%s %s (%s)"', |
9791 |
|
__("Échec de la notification du signataire"), |
9792 |
|
$signer_name, |
9793 |
|
$signer_mail |
9794 |
|
); |
9795 |
|
|
9796 |
|
// vérification des informations requises |
9797 |
|
if (empty($signer_name)) { |
9798 |
|
$err_detail = __("le nom du signataire est vide"); |
9799 |
|
$this->addToLog(__METHOD__.', '.$err_msg_log.', '.$err_detail, DEBUG_MODE); |
9800 |
|
$this->addToMessage($err_msg.', '.$err_detail); |
9801 |
|
return false; |
9802 |
|
} |
9803 |
|
if (empty($signer_mail)) { |
9804 |
|
$err_detail = __("le courriel du signataire est vide"); |
9805 |
|
$this->addToLog(__METHOD__.', '.$err_msg_log.', '.$err_detail, DEBUG_MODE); |
9806 |
|
$this->addToMessage($err_msg.', '.$err_detail); |
9807 |
|
return false; |
9808 |
|
} |
9809 |
|
if (empty($this->getVal('dossier'))) { |
9810 |
|
$err_detail = __("l'identifiant du dossier est vide"); |
9811 |
|
$this->addToLog(__METHOD__.', '.$err_msg_log.', '.$err_detail, DEBUG_MODE); |
9812 |
|
$this->addToMessage($err_msg.', '.$err_detail); |
9813 |
|
return false; |
9814 |
|
} |
9815 |
|
|
9816 |
|
// ajout de la notification à la liste des notifications de l'instruction |
9817 |
|
$instruction_id = $this->getVal($this->clePrimaire); |
9818 |
|
$inst_notif = $this->f->get_inst__om_dbform(array( |
9819 |
|
"obj" => "instruction_notification", |
9820 |
|
"idx" => "]", |
9821 |
|
)); |
9822 |
|
$notif_val = array( |
9823 |
|
'instruction_notification' => null, |
9824 |
|
'instruction' => $instruction_id, |
9825 |
|
'automatique' => true, |
9826 |
|
'emetteur' => $user_name, |
9827 |
|
'date_envoi' => null, |
9828 |
|
'destinataire' => "$signer_name <$signer_mail>", |
9829 |
|
'courriel' => $signer_mail, |
9830 |
|
'date_premier_acces' => null, |
9831 |
|
'statut' => '', |
9832 |
|
'commentaire' => '' |
9833 |
|
); |
9834 |
|
$add_notif = $inst_notif->ajouter($notif_val); |
9835 |
|
if ($add_notif === false) { |
9836 |
|
$err_detail = __("Échec de l'ajout de la notification."); |
9837 |
|
$this->addToLog(__METHOD__.' '.$err_msg_log.'. '.$err_detail.' Notification : '.var_export($notif_val, true), DEBUG_MODE); |
9838 |
|
$this->addToMessage($err_msg); |
9839 |
|
return false; |
9840 |
|
} |
9841 |
|
$notification_id = $inst_notif->getVal($inst_notif->clePrimaire); |
9842 |
|
|
9843 |
|
// ajout d'une tâche de notification (envoi du mail) |
9844 |
|
$notification_task = $this->notification_by_task( |
9845 |
|
$notification_id, |
9846 |
|
$this->getVal('dossier'), |
9847 |
|
'mail', |
9848 |
|
'notification_signataire' |
9849 |
|
); |
9850 |
|
if ($notification_task === false) { |
9851 |
|
$err_detail = sprintf( |
9852 |
|
__("Échec de l'ajout de la tâche de notification (notification %s)."), |
9853 |
|
$notification_id); |
9854 |
|
$this->addToLog(__METHOD__.' '.$err_msg_log.'. '.$err_detail, DEBUG_MODE); |
9855 |
|
$this->addToMessage($err_msg); |
9856 |
|
return false; |
9857 |
|
} |
9858 |
|
|
9859 |
|
// Vérification de la réussite de l'envoi du mail |
9860 |
|
// Fais une requête pour récupérer la liste des notifications de signataire faites par mail |
9861 |
|
// et associées à l'instruction en cours. Récupère uniquement la dernière qui doit être celle |
9862 |
|
// qui viens d'être créée. |
9863 |
|
// Si la tâche d'envoi du mail est en erreur alors on considère que l'envoi du mail a échoué. |
9864 |
|
$qres = $this->f->get_one_result_from_db_query( |
9865 |
|
sprintf( |
9866 |
|
'SELECT |
9867 |
|
state |
9868 |
|
FROM |
9869 |
|
%1$stask |
9870 |
|
WHERE |
9871 |
|
type = \'notification_signataire\' |
9872 |
|
AND category = \'mail\' |
9873 |
|
AND dossier = \'%2$s\' |
9874 |
|
ORDER BY |
9875 |
|
task DESC |
9876 |
|
LIMIT 1', |
9877 |
|
DB_PREFIXE, |
9878 |
|
$this->f->db->escapeSimple($this->getVal('dossier')) |
9879 |
|
), |
9880 |
|
array( |
9881 |
|
'origin' => __METHOD__ |
9882 |
|
) |
9883 |
|
); |
9884 |
|
if ($qres['result'] === 'error') { |
9885 |
|
$err_detail = sprintf( |
9886 |
|
__("Échec de l'envoi du mail de notification (notification %s)."), |
9887 |
|
$notification_id); |
9888 |
|
$this->addToLog(__METHOD__.' '.$err_msg_log.'. '.$err_detail, DEBUG_MODE); |
9889 |
|
$this->addToMessage($err_msg); |
9890 |
|
return false; |
9891 |
|
} |
9892 |
|
|
9893 |
|
// succès de la planification de la notification |
9894 |
|
$this->addToMessage(sprintf( |
9895 |
|
__('Le signataire "%s (%s)" sera notifié prochainement'), |
9896 |
|
$signer_name, |
9897 |
|
$signer_mail)); |
9898 |
|
return true; |
9899 |
|
} |
9900 |
|
|
9901 |
|
/** |
9902 |
* Permet de récupérer la bonne date limite en fonction de si l'instruction |
* Permet de récupérer la bonne date limite en fonction de si l'instruction |
9903 |
* est en incomplet notifié ou non. |
* est en incomplet notifié ou non. |
9904 |
* On peut ajouter des jours à cette date grâce au paramètre "delay". |
* On peut ajouter des jours à cette date grâce au paramètre "delay". |
9922 |
} else { |
} else { |
9923 |
$date_to_compute = $inst_dossier->getVal('date_limite'); |
$date_to_compute = $inst_dossier->getVal('date_limite'); |
9924 |
} |
} |
9925 |
|
if ($date_to_compute != null) { |
9926 |
|
return date("Y-m-d", strtotime($date_to_compute."+ $delay days")); |
9927 |
|
} |
9928 |
|
|
9929 |
$date_limite = date("Y-m-d", strtotime($date_to_compute."+ $delay days")); |
return null; |
|
|
|
|
return $date_limite; |
|
9930 |
} |
} |
9931 |
|
|
9932 |
/** |
/** |
10122 |
* @param boolean permet d'afficher les notifications non liées à des tâches |
* @param boolean permet d'afficher les notifications non liées à des tâches |
10123 |
* @return json |
* @return json |
10124 |
*/ |
*/ |
10125 |
protected function get_json_suivi_notification($typeTache, $nonLieTache = false) { |
public function get_json_suivi_notification($typeTache, $nonLieTache = false) { |
10126 |
$whereTypeTache = ''; |
$whereTypeTache = ''; |
10127 |
$sqlTaskNull = ''; |
$sqlTaskNull = 'INNER'; |
10128 |
|
|
10129 |
// Liste des champs à afficher. Permet également la traduction des noms de colonnes. |
// Liste des champs à afficher. Permet également la traduction des noms de colonnes. |
10130 |
$listeChampsTrad = array( |
$listeChampsTrad = array( |
10153 |
// notification du demandeur principal n'a pas pu être envoyée à cause d'un mauvais |
// notification du demandeur principal n'a pas pu être envoyée à cause d'un mauvais |
10154 |
// paramétrage |
// paramétrage |
10155 |
if(is_bool($nonLieTache) && $nonLieTache === true) { |
if(is_bool($nonLieTache) && $nonLieTache === true) { |
10156 |
$sqlTaskNull = 'OR task.type is null'; |
$sqlTaskNull = 'LEFT'; |
10157 |
} |
} |
10158 |
// Prépare la clause where pour ne récupérer que les notifications liées à certain type de tâches |
// Prépare la clause where pour ne récupérer que les notifications liées à certain type de tâches |
10159 |
// Permet de différencier les notifications des demandeurs de celle des services et de celles des |
// Permet de différencier les notifications des demandeurs de celle des services et de celles des |
10161 |
if (is_array($typeTache) && $typeTache != array()) { |
if (is_array($typeTache) && $typeTache != array()) { |
10162 |
if (is_array($typeTache)) { |
if (is_array($typeTache)) { |
10163 |
$whereTypeTache = sprintf( |
$whereTypeTache = sprintf( |
10164 |
'AND (task.type IN (%1$s) %2$s)', |
'AND (task.task IS NULL OR (task.task IS NOT NULL AND task.type IN (%1$s)))', |
10165 |
"'".implode("', '", $typeTache)."'", |
"'".implode("', '", $typeTache)."'" |
|
$sqlTaskNull |
|
10166 |
); |
); |
10167 |
} |
} |
10168 |
// La date de premier accès n'a pas besoin d'être renseigné pour |
// La date de premier accès n'a pas besoin d'être renseigné pour |
10180 |
$dossier = $this->getVal('dossier'); |
$dossier = $this->getVal('dossier'); |
10181 |
$collectivite_di = $this->get_dossier_instruction_om_collectivite($dossier); |
$collectivite_di = $this->get_dossier_instruction_om_collectivite($dossier); |
10182 |
$modeNotification = $this->f->get_param_option_notification($collectivite_di); |
$modeNotification = $this->f->get_param_option_notification($collectivite_di); |
10183 |
if (empty($modeNotification) || $modeNotification == PORTAL) { |
if ($modeNotification === PORTAL) { |
10184 |
$listeChamps = array( |
$listeChamps = array( |
10185 |
'emetteur', |
'emetteur', |
10186 |
'date_envoi', |
'date_envoi', |
10233 |
ON instruction_notification.instruction_notification = instruction_notification_document.instruction_notification |
ON instruction_notification.instruction_notification = instruction_notification_document.instruction_notification |
10234 |
AND instruction_notification_document.annexe = true |
AND instruction_notification_document.annexe = true |
10235 |
-- Récupère les tâches liées au notification pour pouvoir par la suite identifier le type de notification |
-- Récupère les tâches liées au notification pour pouvoir par la suite identifier le type de notification |
10236 |
LEFT JOIN %1$stask |
%4$s JOIN %1$stask |
10237 |
ON instruction_notification.instruction_notification::CHARACTER VARYING = task.object_id |
ON instruction_notification.instruction_notification::CHARACTER VARYING = task.object_id |
10238 |
|
AND task.type LIKE \'notification%%\' |
10239 |
-- Récupération de la liste des annexes sous la forme d une liste |
-- Récupération de la liste des annexes sous la forme d une liste |
10240 |
LEFT JOIN ( |
LEFT JOIN ( |
10241 |
SELECT |
SELECT |
10262 |
\'{ |
\'{ |
10263 |
"obj" : "consultation", |
"obj" : "consultation", |
10264 |
"champs" : "fichier", |
"champs" : "fichier", |
10265 |
"label" : "Avis - \', service.libelle, \'", |
"label" : "\', CONCAT_WS( \' - \', \'Avis\', service.libelle, to_char(consultation.date_retour,\'DD/MM/YYYY\')), \'", |
10266 |
"id" : "\', consultation.consultation,\'" |
"id" : "\', consultation.consultation, \'" |
10267 |
}\' |
}\' |
10268 |
) |
) |
10269 |
ELSE |
ELSE |
10270 |
CONCAT( |
CONCAT( |
10306 |
ORDER BY |
ORDER BY |
10307 |
date_envoi ASC, instruction_notification.destinataire ASC', |
date_envoi ASC, instruction_notification.destinataire ASC', |
10308 |
DB_PREFIXE, |
DB_PREFIXE, |
10309 |
$this->getVal('instruction'), |
intval($this->getVal('instruction')), |
10310 |
$whereTypeTache |
$whereTypeTache, |
10311 |
|
$sqlTaskNull |
10312 |
|
); |
10313 |
|
$qres = $this->f->get_all_results_from_db_query($sql, array( |
10314 |
|
"origin" => __METHOD__ |
10315 |
|
) |
10316 |
); |
); |
|
$res = $this->f->db->query($sql); |
|
|
$this->f->addToLog(__METHOD__."(): db->query(\"".$sql."\")", VERBOSE_MODE); |
|
|
$this->f->isDatabaseError($res); |
|
10317 |
// Préparation du lien de téléchargement des annexes |
// Préparation du lien de téléchargement des annexes |
10318 |
$htmlList = |
$htmlList = |
10319 |
'<style> |
'<style> |
10332 |
Annexe |
Annexe |
10333 |
</a>'; |
</a>'; |
10334 |
// Stockage des infos de chaque notification dans un tableau |
// Stockage des infos de chaque notification dans un tableau |
10335 |
while( $row =& $res->fetchrow(DB_FETCHMODE_ASSOC) ) { |
foreach ($qres['result'] as $row) { |
10336 |
$valNotif = array(); |
$valNotif = array(); |
10337 |
foreach($listeChamps as $champ) { |
foreach($listeChamps as $champ) { |
10338 |
$valNotif[$champ] = $row[$champ]; |
$valNotif[$champ] = $row[$champ]; |
10611 |
AND evenement = %2$s', |
AND evenement = %2$s', |
10612 |
DB_PREFIXE, |
DB_PREFIXE, |
10613 |
intval($ev_next), |
intval($ev_next), |
10614 |
$dossier |
$this->f->db->escapeSimple($dossier) |
10615 |
), |
), |
10616 |
array( |
array( |
10617 |
"origin" => __METHOD__, |
"origin" => __METHOD__, |
10692 |
FROM |
FROM |
10693 |
%1$sevenement |
%1$sevenement |
10694 |
WHERE |
WHERE |
10695 |
evenement = %2$s |
evenement = %2$d |
10696 |
AND evenement_retour_ar != %3$s', |
AND evenement_retour_ar != %3$d', |
10697 |
DB_PREFIXE, |
DB_PREFIXE, |
10698 |
intval($ev_parent), |
intval($ev_parent), |
10699 |
intval($evenement) |
intval($evenement) |
10806 |
$listeDemandeursNotifiable = array(); |
$listeDemandeursNotifiable = array(); |
10807 |
|
|
10808 |
// Requête de récupération des demandeurs |
// Requête de récupération des demandeurs |
10809 |
$sql = sprintf( |
$qres = $this->f->get_all_results_from_db_query( |
10810 |
'SELECT |
sprintf( |
10811 |
demandeur.demandeur, |
'SELECT |
10812 |
CASE |
demandeur.demandeur, |
10813 |
WHEN demandeur.qualite=\'particulier\' |
CASE |
10814 |
THEN TRIM(CONCAT(demandeur.particulier_nom, \' \', demandeur.particulier_prenom, \' \', demandeur.courriel)) |
WHEN demandeur.qualite=\'particulier\' |
10815 |
ELSE |
THEN TRIM(CONCAT(demandeur.particulier_nom, \' \', demandeur.particulier_prenom, \' \', demandeur.courriel)) |
10816 |
TRIM(CONCAT(demandeur.personne_morale_raison_sociale, \' \', demandeur.personne_morale_denomination, \' \', demandeur.courriel)) |
ELSE |
10817 |
END AS destinataire, |
TRIM(CONCAT(demandeur.personne_morale_raison_sociale, \' \', demandeur.personne_morale_denomination, \' \', demandeur.courriel)) |
10818 |
demandeur.courriel, |
END AS destinataire, |
10819 |
petitionnaire_principal |
demandeur.courriel, |
10820 |
FROM |
petitionnaire_principal |
10821 |
%1$sdossier |
FROM |
10822 |
INNER JOIN %1$slien_dossier_demandeur |
%1$sdossier |
10823 |
ON dossier.dossier = lien_dossier_demandeur.dossier |
INNER JOIN %1$slien_dossier_demandeur |
10824 |
INNER JOIN %1$sdemandeur |
ON dossier.dossier = lien_dossier_demandeur.dossier |
10825 |
ON lien_dossier_demandeur.demandeur = demandeur.demandeur |
INNER JOIN %1$sdemandeur |
10826 |
-- Récupération de la plus ancienne demande associée au dossier (la demande |
ON lien_dossier_demandeur.demandeur = demandeur.demandeur |
10827 |
-- de création du dossier) |
-- Récupération de la plus ancienne demande associée au dossier (la demande |
10828 |
INNER JOIN ( |
-- de création du dossier) |
10829 |
SELECT |
INNER JOIN ( |
10830 |
demande, |
SELECT |
10831 |
dossier_instruction, |
demande, |
10832 |
source_depot |
dossier_instruction, |
10833 |
FROM |
source_depot |
10834 |
%1$sdemande |
FROM |
10835 |
WHERE |
%1$sdemande |
10836 |
dossier_instruction = \'%2$s\' |
WHERE |
10837 |
ORDER BY |
dossier_instruction = \'%2$s\' |
10838 |
demande ASC |
ORDER BY |
10839 |
LIMIT 1 |
demande ASC |
10840 |
) as demande |
LIMIT 1 |
10841 |
ON dossier.dossier = demande.dossier_instruction |
) as demande |
10842 |
WHERE |
ON dossier.dossier = demande.dossier_instruction |
10843 |
dossier.dossier = \'%2$s\' |
WHERE |
10844 |
%3$s |
dossier.dossier = \'%2$s\' |
10845 |
%4$s', |
%3$s |
10846 |
DB_PREFIXE, |
%4$s', |
10847 |
$idDossier, |
DB_PREFIXE, |
10848 |
$condition_demandeur, |
$this->f->db->escapeSimple($idDossier), |
10849 |
$sqlPetitionnairePrincipal |
$condition_demandeur, |
10850 |
); |
$sqlPetitionnairePrincipal |
10851 |
$res = $this->f->db->query($sql); |
), |
10852 |
$this->f->addToLog(__METHOD__."(): db->query(\"".$sql."\")", VERBOSE_MODE); |
array( |
10853 |
$this->f->isDatabaseError($res); |
"origin" => __METHOD__ |
10854 |
|
) |
10855 |
|
); |
10856 |
// Récupération des infos des demandeurs et stockage dans un tableau |
// Récupération des infos des demandeurs et stockage dans un tableau |
10857 |
// ayant pour clé les id des demandeurs |
// ayant pour clé les id des demandeurs |
10858 |
while($row = $res->fetchrow(DB_FETCHMODE_ASSOC)) { |
foreach ($qres['result'] as $row) { |
10859 |
$listeDemandeursNotifiable[$row['demandeur']] = $row; |
$listeDemandeursNotifiable[$row['demandeur']] = $row; |
10860 |
} |
} |
10861 |
|
|
10870 |
*/ |
*/ |
10871 |
public function get_instruction_notification($id_instruction, $typeNotification = null, $nonLieTache = false) { |
public function get_instruction_notification($id_instruction, $typeNotification = null, $nonLieTache = false) { |
10872 |
$whereTypeTache = ''; |
$whereTypeTache = ''; |
10873 |
$sqlTaskNull = ''; |
$sqlTaskNull = 'INNER'; |
10874 |
// Défini si on veux que la requête récupère également les notifications qui n'ont pas |
// Défini si on veux que la requête récupère également les notifications qui n'ont pas |
10875 |
// de tâches associées. C'est le cas pour les notifications de demandeurs lorsque la |
// de tâches associées. C'est le cas pour les notifications de demandeurs lorsque la |
10876 |
// notification du demandeur principal n'a pas pu être envoyée à cause d'un mauvais |
// notification du demandeur principal n'a pas pu être envoyée à cause d'un mauvais |
10877 |
// paramétrage |
// paramétrage |
10878 |
if(is_bool($nonLieTache) && $nonLieTache === true) { |
if(is_bool($nonLieTache) && $nonLieTache === true) { |
10879 |
$sqlTaskNull = 'OR task.type is null'; |
$sqlTaskNull = 'LEFT'; |
10880 |
} |
} |
10881 |
if ($typeNotification != null) { |
if ($typeNotification != null) { |
10882 |
if (is_array($typeNotification)) { |
if (is_array($typeNotification)) { |
10883 |
$whereTypeTache = sprintf( |
$whereTypeTache = sprintf( |
10884 |
'AND (task.type IN (%1$s) %2$s)', |
'AND (task.type IN (%1$s))', |
10885 |
"'".implode("', '", $typeNotification)."'", |
"'".implode("', '", $typeNotification)."'" |
|
$sqlTaskNull |
|
10886 |
); |
); |
10887 |
} else { |
} else { |
10888 |
$whereTypeTache = sprintf( |
$whereTypeTache = sprintf( |
10889 |
'AND (task.type = \'%1$s\' %2$s)', |
'AND (task.type = \'%1$s\')', |
10890 |
$typeNotification, |
$typeNotification |
|
$sqlTaskNull |
|
10891 |
); |
); |
10892 |
} |
} |
10893 |
} |
} |
10894 |
$listeInstrNotif = array(); |
$listeInstrNotif = array(); |
10895 |
$sql = sprintf(' |
$qres = $this->f->get_all_results_from_db_query( |
10896 |
SELECT |
sprintf(' |
10897 |
instruction_notification.instruction_notification |
SELECT |
10898 |
FROM |
instruction_notification.instruction_notification |
10899 |
%1$sinstruction_notification |
FROM |
10900 |
LEFT JOIN %1$stask |
%1$sinstruction_notification |
10901 |
ON instruction_notification.instruction_notification::CHARACTER VARYING = task.object_id |
%4$s JOIN %1$stask |
10902 |
WHERE |
ON instruction_notification.instruction_notification::CHARACTER VARYING = task.object_id |
10903 |
instruction = %2$s |
%3$s |
10904 |
%3$s', |
WHERE |
10905 |
DB_PREFIXE, |
instruction = %2$s', |
10906 |
$id_instruction, |
DB_PREFIXE, |
10907 |
$whereTypeTache |
intval($id_instruction), |
10908 |
|
$whereTypeTache, |
10909 |
|
$sqlTaskNull |
10910 |
|
), |
10911 |
|
array( |
10912 |
|
"origin" => __METHOD__ |
10913 |
|
) |
10914 |
); |
); |
10915 |
$res = $this->f->db->query($sql); |
foreach ($qres['result'] as $row) { |
|
$this->f->addToLog(__METHOD__."(): db->query(\"".$sql."\")", VERBOSE_MODE); |
|
|
$this->f->isDatabaseError($res); |
|
|
while ($row = $res->fetchrow(DB_FETCHMODE_ASSOC)) { |
|
10916 |
$listeInstrNotif[] = $row['instruction_notification']; |
$listeInstrNotif[] = $row['instruction_notification']; |
10917 |
} |
} |
10918 |
return $listeInstrNotif; |
return $listeInstrNotif; |
10953 |
* @return integer|null |
* @return integer|null |
10954 |
*/ |
*/ |
10955 |
protected function getUidDocumentInstructionWithKey($cleGen) { |
protected function getUidDocumentInstructionWithKey($cleGen) { |
10956 |
$query = sprintf( |
$qres = $this->f->get_one_result_from_db_query( |
10957 |
'SELECT |
sprintf( |
10958 |
instruction.om_fichier_instruction |
'SELECT |
10959 |
FROM |
instruction.om_fichier_instruction |
10960 |
%1$sinstruction_notification_document |
FROM |
10961 |
LEFT JOIN %1$sinstruction ON instruction_notification_document.instruction = instruction.instruction |
%1$sinstruction_notification_document |
10962 |
WHERE |
LEFT JOIN %1$sinstruction |
10963 |
instruction_notification_document.cle = \'%2$s\'', |
ON instruction_notification_document.instruction = instruction.instruction |
10964 |
DB_PREFIXE, |
WHERE |
10965 |
$this->f->db->escapeSimple($cleGen) |
instruction_notification_document.cle = \'%2$s\'', |
10966 |
|
DB_PREFIXE, |
10967 |
|
$this->f->db->escapeSimple($cleGen) |
10968 |
|
), |
10969 |
|
array( |
10970 |
|
"origin" => __METHOD__, |
10971 |
|
) |
10972 |
); |
); |
10973 |
|
|
10974 |
$res = $this->f->db->getOne($query); |
return $qres['result']; |
|
$this->addToLog(__METHOD__.": db->getOne(\"".$query."\");", VERBOSE_MODE); |
|
|
$this->f->isDatabaseError($res); |
|
|
return $res; |
|
10975 |
} |
} |
10976 |
|
|
10977 |
/** |
/** |
10982 |
* @return instruction_notification |
* @return instruction_notification |
10983 |
*/ |
*/ |
10984 |
protected function getInstanceNotificationWithKey($key) { |
protected function getInstanceNotificationWithKey($key) { |
10985 |
$sql = sprintf( |
$qres = $this->f->get_one_result_from_db_query( |
10986 |
"SELECT |
sprintf( |
10987 |
instruction_notification |
'SELECT |
10988 |
FROM |
instruction_notification |
10989 |
%1\$sinstruction_notification_document |
FROM |
10990 |
WHERE |
%1$sinstruction_notification_document |
10991 |
cle = '%2\$s'", |
WHERE |
10992 |
DB_PREFIXE, |
cle = \'%2$s\'', |
10993 |
$this->f->db->escapeSimple($key) |
DB_PREFIXE, |
10994 |
|
$this->f->db->escapeSimple($key) |
10995 |
|
), |
10996 |
|
array( |
10997 |
|
"origin" => __METHOD__, |
10998 |
|
) |
10999 |
); |
); |
|
$res = $this->f->db->getOne($sql); |
|
|
$this->addToLog(__METHOD__.": db->getOne(\"".$sql."\");", VERBOSE_MODE); |
|
|
$this->f->isDatabaseError($res); |
|
11000 |
|
|
11001 |
// Récupération de l'instance de notification |
// Récupération de l'instance de notification |
11002 |
$instNotif = $this->f->get_inst__om_dbform(array( |
$instNotif = $this->f->get_inst__om_dbform(array( |
11003 |
"obj" => "instruction_notification", |
"obj" => "instruction_notification", |
11004 |
"idx" => $res, |
"idx" => $qres['result'], |
11005 |
)); |
)); |
11006 |
return $instNotif; |
return $instNotif; |
11007 |
} |
} |
11085 |
// TO_CHAR() introduit un espace avant l'affichage du nombre |
// TO_CHAR() introduit un espace avant l'affichage du nombre |
11086 |
// comme les espaces sont remplacé par des '_' dans le retour de la fonction |
// comme les espaces sont remplacé par des '_' dans le retour de la fonction |
11087 |
// il n'est pas nécessaire de mettre un '_' après le mot instruction. |
// il n'est pas nécessaire de mettre un '_' après le mot instruction. |
11088 |
$sql = sprintf( |
$documentLibelle = $this->f->get_one_result_from_db_query( |
11089 |
'SELECT |
sprintf( |
11090 |
CONCAT( |
'SELECT |
11091 |
\'instruction\', |
CONCAT( |
11092 |
TO_CHAR(instruction.instruction, \'000\'), |
\'instruction\', |
11093 |
\'_\', |
TO_CHAR(instruction.instruction, \'000\'), |
11094 |
LOWER(om_lettretype.libelle) |
\'_\', |
11095 |
) as nom_fichier |
LOWER(om_lettretype.libelle) |
11096 |
FROM |
) AS nom_fichier |
11097 |
%1$sinstruction |
FROM |
11098 |
LEFT JOIN %1$som_lettretype ON om_lettretype.id = instruction.lettretype |
%1$sinstruction |
11099 |
WHERE |
LEFT JOIN %1$som_lettretype |
11100 |
instruction = %2$s', |
ON om_lettretype.id = instruction.lettretype |
11101 |
DB_PREFIXE, |
WHERE |
11102 |
$instruction |
instruction = %2$d', |
11103 |
|
DB_PREFIXE, |
11104 |
|
intval($instruction) |
11105 |
|
), |
11106 |
|
array( |
11107 |
|
"origin" => __METHOD__, |
11108 |
|
) |
11109 |
); |
); |
11110 |
$documentLibelle = $this->f->db->getone($sql); |
|
11111 |
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
$documentLibelle = $documentLibelle['result']; |
|
$this->f->isDatabaseError($documentLibelle); |
|
11112 |
|
|
11113 |
// Transforamtion des ' ' en '_', des accents en lettres sans accents et des |
// Transforamtion des ' ' en '_', des accents en lettres sans accents et des |
11114 |
// caractères spéciaux en '_' |
// caractères spéciaux en '_' |
11213 |
if (empty($tiersANotifier)) { |
if (empty($tiersANotifier)) { |
11214 |
$this->addToLog( |
$this->addToLog( |
11215 |
sprintf( |
sprintf( |
11216 |
'%s() : %s %s : ', |
'%s() : %s %s : %s', |
11217 |
__METHOD__, |
__METHOD__, |
11218 |
__("La récupération des tiers à échoué."), |
__("La récupération des tiers à échoué."), |
11219 |
__('Paramétrage'), |
__('Paramétrage'), |
11336 |
$filtreServiceConsulteDI = ''; |
$filtreServiceConsulteDI = ''; |
11337 |
if (! empty($idPlatau)) { |
if (! empty($idPlatau)) { |
11338 |
$filtreServiceConsulteDI = sprintf( |
$filtreServiceConsulteDI = sprintf( |
11339 |
'AND (tiers_consulte.uid_platau_acteur != \'%s\' |
"-- Filtre les tiers ayant une ligne correspondante a l uid platau du service |
11340 |
OR tiers_consulte.uid_platau_acteur IS NULL)', |
-- en charge du dossier |
11341 |
|
AND (tiers_consulte.uid_platau_acteur !~ ('\y' || '%s' || '\y') |
11342 |
|
OR tiers_consulte.uid_platau_acteur IS NULL)", |
11343 |
$this->f->db->escapeSimple($idPlatau) |
$this->f->db->escapeSimple($idPlatau) |
11344 |
); |
); |
11345 |
} |
} |
11346 |
$rst = $this->f->get_all_results_from_db_query( |
$rst = $this->f->get_all_results_from_db_query( |
11347 |
sprintf( |
sprintf( |
11348 |
'SELECT |
'SELECT |
11349 |
|
-- Tiers notifiables lié à la commune du dossier |
11350 |
tiers_consulte.liste_diffusion, |
tiers_consulte.liste_diffusion, |
11351 |
tiers_consulte.libelle |
tiers_consulte.libelle |
11352 |
FROM |
FROM |
11355 |
ON habilitation_tiers_consulte.tiers_consulte = tiers_consulte.tiers_consulte |
ON habilitation_tiers_consulte.tiers_consulte = tiers_consulte.tiers_consulte |
11356 |
LEFT JOIN %1$slien_habilitation_tiers_consulte_commune |
LEFT JOIN %1$slien_habilitation_tiers_consulte_commune |
11357 |
ON habilitation_tiers_consulte.habilitation_tiers_consulte = lien_habilitation_tiers_consulte_commune.habilitation_tiers_consulte |
ON habilitation_tiers_consulte.habilitation_tiers_consulte = lien_habilitation_tiers_consulte_commune.habilitation_tiers_consulte |
11358 |
|
-- Conservation uniquement des tiers acteur de dossiers |
11359 |
|
JOIN %1$slien_dossier_tiers |
11360 |
|
ON tiers_consulte.tiers_consulte = lien_dossier_tiers.tiers |
11361 |
|
WHERE |
11362 |
|
tiers_consulte.accepte_notification_email IS TRUE |
11363 |
|
AND tiers_consulte.liste_diffusion IS NOT NULL |
11364 |
|
%3$s |
11365 |
|
AND habilitation_tiers_consulte.type_habilitation_tiers_consulte IN (%2$s) |
11366 |
|
AND lien_habilitation_tiers_consulte_commune.commune = %4$d |
11367 |
|
-- Filtre sur les tiers acteur du dossier |
11368 |
|
AND lien_dossier_tiers.dossier = \'%6$s\' |
11369 |
|
UNION |
11370 |
|
SELECT |
11371 |
|
-- Tiers notifiables lié au département du dossier |
11372 |
|
tiers_consulte.liste_diffusion, |
11373 |
|
tiers_consulte.libelle |
11374 |
|
FROM |
11375 |
|
%1$shabilitation_tiers_consulte |
11376 |
|
LEFT JOIN %1$stiers_consulte |
11377 |
|
ON habilitation_tiers_consulte.tiers_consulte = tiers_consulte.tiers_consulte |
11378 |
LEFT JOIN %1$slien_habilitation_tiers_consulte_departement |
LEFT JOIN %1$slien_habilitation_tiers_consulte_departement |
11379 |
ON habilitation_tiers_consulte.habilitation_tiers_consulte = lien_habilitation_tiers_consulte_departement.habilitation_tiers_consulte |
ON habilitation_tiers_consulte.habilitation_tiers_consulte = lien_habilitation_tiers_consulte_departement.habilitation_tiers_consulte |
11380 |
|
-- Conservation uniquement des tiers acteur de dossiers |
11381 |
|
JOIN %1$slien_dossier_tiers |
11382 |
|
ON tiers_consulte.tiers_consulte = lien_dossier_tiers.tiers |
11383 |
WHERE |
WHERE |
11384 |
tiers_consulte.accepte_notification_email IS TRUE |
tiers_consulte.accepte_notification_email IS TRUE |
11385 |
AND tiers_consulte.liste_diffusion IS NOT NULL |
AND tiers_consulte.liste_diffusion IS NOT NULL |
11386 |
%3$s |
%3$s |
11387 |
AND habilitation_tiers_consulte.type_habilitation_tiers_consulte IN (%2$s) |
AND habilitation_tiers_consulte.type_habilitation_tiers_consulte IN (%2$s) |
11388 |
AND ( |
AND lien_habilitation_tiers_consulte_departement.departement = %5$d |
11389 |
lien_habilitation_tiers_consulte_commune.commune = %4$d |
-- Filtre sur les tiers acteur du dossier |
11390 |
OR lien_habilitation_tiers_consulte_departement.departement = %5$d |
AND lien_dossier_tiers.dossier = \'%6$s\'', |
|
) |
|
|
ORDER BY |
|
|
tiers_consulte.libelle |
|
|
', |
|
11391 |
DB_PREFIXE, |
DB_PREFIXE, |
11392 |
implode(', ', $typesHabilitations), |
implode(', ', $typesHabilitations), |
11393 |
$filtreServiceConsulteDI, |
$filtreServiceConsulteDI, |
11394 |
intval($commune), |
intval($commune), |
11395 |
intval($departement) |
intval($departement), |
11396 |
|
$this->f->db->escapeSimple($this->getVal('dossier')) |
11397 |
), |
), |
11398 |
array( |
array( |
11399 |
"origin" => __METHOD__ |
"origin" => __METHOD__ |
11400 |
) |
) |
11401 |
); |
); |
11402 |
|
// Faire un order by sur un union ne fonctionne pas. A la place |
11403 |
|
// c'est le tableau des résultats qui est ordonné. |
11404 |
|
usort($rst['result'], function($a, $b) { |
11405 |
|
return strcmp($a['libelle'], $b['libelle']); |
11406 |
|
}); |
11407 |
return $rst['result']; |
return $rst['result']; |
11408 |
} |
} |
11409 |
|
|
11410 |
|
/** |
11411 |
|
* Gestion spécifique de l'affichage des documents dans le tableau des |
11412 |
|
* documents d'instruction. |
11413 |
|
* Prend en compte qu'une instruction peut également avoir un document lié |
11414 |
|
* dans la table storage. |
11415 |
|
* |
11416 |
|
* @return void |
11417 |
|
*/ |
11418 |
|
public function view_telecharger_editions() { |
11419 |
|
// Récupère l'identifiant du document dans l'URL appelant l'action |
11420 |
|
$idx = $this->f->get_submitted_get_value('idx'); |
11421 |
|
$obj = $this->table; |
11422 |
|
$champ = 'om_fichier_instruction'; |
11423 |
|
// Cas d'un document historisé (dans la table storage) |
11424 |
|
if (strpos($idx, 'STORAGE_') !== false) { |
11425 |
|
$idx = substr($idx, 8); |
11426 |
|
$obj = 'storage'; |
11427 |
|
$champ = 'uid'; |
11428 |
|
} |
11429 |
|
// Ouvre le document |
11430 |
|
$lien = '../app/index.php?module=form&snippet=file&obj='.$obj.'&champ='.$champ.'&id='.$idx; |
11431 |
|
header("Location: ".$lien); |
11432 |
|
} |
11433 |
} |
} |