21 |
|
|
22 |
// |
// |
23 |
require_once "../gen/obj/instruction.class.php"; |
require_once "../gen/obj/instruction.class.php"; |
24 |
|
require_once "../obj/task.class.php"; |
25 |
|
|
26 |
// |
// |
27 |
class instruction extends instruction_gen { |
class instruction extends instruction_gen { |
108 |
*/ |
*/ |
109 |
var $di_reopened = null; |
var $di_reopened = null; |
110 |
|
|
111 |
|
/** |
112 |
|
* Méthode appelée par le module_manager lors de la récupération des modules de cet objet. |
113 |
|
* Permet d'ajouer des modules en plus de ceux récupérer par défaut par le module_manager. |
114 |
|
* |
115 |
|
* @param bool $only_for_class Ne renvoie que les modules pour la classe de l'objet |
116 |
|
* |
117 |
|
* @return array Liste de modules supplémentaires pour cet objet |
118 |
|
*/ |
119 |
|
public function get_modules_append(bool $only_for_class = false) { |
120 |
|
$modules = array(); |
121 |
|
|
122 |
|
// si on est sur un dossier d'instruction |
123 |
|
if ($this->f->contexte_dossier_instruction()) { |
124 |
|
$idx = $this->f->get_submitted_get_value('idxformulaire'); |
125 |
|
|
126 |
|
$object_id = $this->getVal($this->clePrimaire); |
127 |
|
|
128 |
|
$evenements_ids = array(); |
129 |
|
|
130 |
|
// Dans le cas ou on a un identifiant de dossier et que |
131 |
|
// l'objet courant n'a pas de cle primaire définie |
132 |
|
// ou qu'on est dans le contexte d'une classe d'objet |
133 |
|
if (! empty($idx) && (empty($object_id) || $only_for_class === true)) { |
134 |
|
|
135 |
|
// Utilise la valeur evenement si elle est déterminé, |
136 |
|
$evenement = $this->f->get_submitted_post_value('evenement'); |
137 |
|
if (! empty($evenement)) $evenements_ids = array($evenement); |
138 |
|
if (empty($evenements_ids)){ |
139 |
|
// si on est dans le cadre de l'affichage d'une nouvelle instruction |
140 |
|
$action = $this->f->get_submitted_get_value('action'); |
141 |
|
|
142 |
|
if ($action == '0') { |
143 |
|
|
144 |
|
// ajoute les modules des évènements possible sur le dossier courant |
145 |
|
$evenements_data = $this->get_var_sql_forminc__sql_evenement(); |
146 |
|
$evenements_ids = array_column($evenements_data, 'evenement'); |
147 |
|
} |
148 |
|
|
149 |
|
// si on est dans le cadre d'un listing |
150 |
|
else if (is_null($action) || $action === '') { |
151 |
|
|
152 |
|
// récupère la liste des évènements d'instructions du dossier d'instruction |
153 |
|
$sql = sprintf(" |
154 |
|
SELECT |
155 |
|
evenement |
156 |
|
FROM |
157 |
|
".DB_PREFIXE."instruction |
158 |
|
WHERE |
159 |
|
dossier = '%s' |
160 |
|
", $this->f->db->escapeSimple($idx)); |
161 |
|
$qres = $this->f->get_all_results_from_db_query( |
162 |
|
$sql, array('origin' => __METHOD__)); |
163 |
|
if ($qres['code'] !== 'OK') { |
164 |
|
$err_msg = "Failed to execute SQL: $sql. Detail: ".($qres['message'] ?? ''); |
165 |
|
$this->f->log(__METHOD__, $err_msg, 'ERROR'); |
166 |
|
throw new RuntimeException($err_msg); |
167 |
|
} |
168 |
|
|
169 |
|
// ajoute les modules des évènements des instructions du dossier courant |
170 |
|
$evenements_ids = array_column($qres['result'], 'evenement'); |
171 |
|
} |
172 |
|
} |
173 |
|
} |
174 |
|
if (!empty($evenements_ids)){ |
175 |
|
$this->f->log(__METHOD__, 'evenements: '.implode(',', $evenements_ids)); |
176 |
|
$modules = $this->f->module_manager->get_modules_for_object_name_and_ids( |
177 |
|
'evenement', $evenements_ids, $this, false); |
178 |
|
} |
179 |
|
} |
180 |
|
return $modules; |
181 |
|
} |
182 |
|
|
183 |
// {{{ Gestion de la confidentialité des données spécifiques |
// {{{ Gestion de la confidentialité des données spécifiques |
184 |
|
|
185 |
/** |
/** |
203 |
"can_user_access_dossier_contexte_modification", |
"can_user_access_dossier_contexte_modification", |
204 |
"is_evenement_modifiable", |
"is_evenement_modifiable", |
205 |
); |
); |
206 |
$this->class_actions[1]["portlet"]["libelle"] = _("Modifier"); |
$this->class_actions[1]["portlet"]["libelle"] = __("Modifier"); |
207 |
|
|
208 |
// ACTION - 002 - supprimer |
// ACTION - 002 - supprimer |
209 |
// Modifie la condition et le libellé du bouton supprimer |
// Modifie la condition et le libellé du bouton supprimer |
213 |
"can_user_access_dossier_contexte_modification", |
"can_user_access_dossier_contexte_modification", |
214 |
"is_evenement_supprimable", |
"is_evenement_supprimable", |
215 |
); |
); |
216 |
$this->class_actions[2]["portlet"]["libelle"] = _("Supprimer"); |
$this->class_actions[2]["portlet"]["libelle"] = __("Supprimer"); |
217 |
|
|
218 |
// ACTION - 003 - consulter |
// ACTION - 003 - consulter |
219 |
// |
// |
225 |
"identifier" => "finaliser", |
"identifier" => "finaliser", |
226 |
"portlet" => array( |
"portlet" => array( |
227 |
"type" => "action-direct", |
"type" => "action-direct", |
228 |
"libelle" => _("Finaliser le document"), |
"libelle" => __("Finaliser le document"), |
229 |
"order" => 110, |
"order" => 110, |
230 |
"class" => "finalise", |
"class" => "finalise", |
231 |
), |
), |
247 |
"identifier" => "definaliser", |
"identifier" => "definaliser", |
248 |
"portlet" => array( |
"portlet" => array( |
249 |
"type" => "action-direct", |
"type" => "action-direct", |
250 |
"libelle" => _("Reprendre la redaction du document"), |
"libelle" => __("Reprendre la redaction du document"), |
251 |
"order" => 110, |
"order" => 110, |
252 |
"class" => "definalise", |
"class" => "definalise", |
253 |
), |
), |
260 |
"is_unfinalizable_without_bypass", |
"is_unfinalizable_without_bypass", |
261 |
"can_user_access_dossier_contexte_modification", |
"can_user_access_dossier_contexte_modification", |
262 |
"is_not_sent_for_signature", |
"is_not_sent_for_signature", |
263 |
|
"is_not_signed", |
264 |
|
), |
265 |
|
); |
266 |
|
|
267 |
|
// ACTION - 115 - Modification d'un document généré par une instruction |
268 |
|
// Permet à un instructeur de modifier un document généré par une instruction |
269 |
|
$this->class_actions[115] = array( |
270 |
|
"identifier" => "modale_selection_document_signe", |
271 |
|
"portlet" => array( |
272 |
|
"type" => "action-self", |
273 |
|
"libelle" => __("Remplacer par le document signé"), |
274 |
|
"order" => 115, |
275 |
|
"class" => "selection-document-signé", |
276 |
|
), |
277 |
|
"view" => "view_modale_selection_document_signe", |
278 |
|
"permission_suffix" => "selection_document_signe", |
279 |
|
"condition" => array( |
280 |
|
"is_finalized", |
281 |
|
"is_not_date_retour_signature_set", |
282 |
), |
), |
283 |
); |
); |
284 |
|
|
288 |
"identifier" => "edition", |
"identifier" => "edition", |
289 |
"portlet" => array( |
"portlet" => array( |
290 |
"type" => "action-blank", |
"type" => "action-blank", |
291 |
"libelle" => _("Edition"), |
"libelle" => __("Edition"), |
292 |
"order" => 100, |
"order" => 100, |
293 |
"class" => "pdf-16", |
"class" => "pdf-16", |
294 |
), |
), |
303 |
"identifier" => "modifier_suivi", |
"identifier" => "modifier_suivi", |
304 |
"portlet" => array( |
"portlet" => array( |
305 |
"type" => "action-self", |
"type" => "action-self", |
306 |
"libelle" => _("Suivi des dates"), |
"libelle" => __("Suivi des dates"), |
307 |
"order" => 125, |
"order" => 125, |
308 |
"class" => "suivi-dates-16", |
"class" => "suivi-dates-16", |
309 |
), |
), |
352 |
"permission_suffix" => "consulter", |
"permission_suffix" => "consulter", |
353 |
); |
); |
354 |
|
|
355 |
|
// ACTION - 175 - edit_by_notification_task |
356 |
|
// Action à utiliser lors de la mise à jour des instructions par notification |
357 |
|
$this->class_actions[175] = array( |
358 |
|
"identifier" => "edit_by_notification_task", |
359 |
|
"view" => "formulaire", |
360 |
|
"permission_suffix" => "modifier", |
361 |
|
"crud" => "update", |
362 |
|
); |
363 |
|
|
364 |
|
// ACTION - 176 - add_by_evenement_retour_after_notification_task |
365 |
|
// Action à utiliser lors de l'ajout des instructions par événement suivant |
366 |
|
// suite à une notification par tâche (donc notification dématerialisée) |
367 |
|
$this->class_actions[176] = array( |
368 |
|
"identifier" => "add_by_evenement_retour_after_notification_task", |
369 |
|
"view" => "formulaire", |
370 |
|
"permission_suffix" => "ajouter", |
371 |
|
"crud" => "create", |
372 |
|
); |
373 |
|
|
374 |
// ACTION - 180 - pdf_lettre_rar |
// ACTION - 180 - pdf_lettre_rar |
375 |
// Génère PDF sur bordereaux de lettres AR |
// Génère PDF sur bordereaux de lettres AR |
376 |
$this->class_actions[180] = array( |
$this->class_actions[180] = array( |
402 |
"identifier" => "notifier_commune", |
"identifier" => "notifier_commune", |
403 |
"portlet" => array( |
"portlet" => array( |
404 |
"type" => "action-direct-with-confirmation", |
"type" => "action-direct-with-confirmation", |
405 |
"libelle" => _("Notifier la commune par courriel"), |
"libelle" => __("Notifier la commune par courriel"), |
406 |
"order" => 210, |
"order" => 210, |
407 |
"class" => "notifier_commune-16", |
"class" => "notifier_commune-16", |
408 |
), |
), |
434 |
"identifier" => "enable-edition-integrale", |
"identifier" => "enable-edition-integrale", |
435 |
"portlet" => array( |
"portlet" => array( |
436 |
"type" => "action-direct-with-confirmation", |
"type" => "action-direct-with-confirmation", |
437 |
"libelle" => _("Rédaction libre"), |
"libelle" => __("Rédaction libre"), |
438 |
"order" => 50, |
"order" => 50, |
439 |
"class" => "redac-libre-16", |
"class" => "redac-libre-16", |
440 |
), |
), |
455 |
"identifier" => "disable-edition-integrale", |
"identifier" => "disable-edition-integrale", |
456 |
"portlet" => array( |
"portlet" => array( |
457 |
"type" => "action-direct-with-confirmation", |
"type" => "action-direct-with-confirmation", |
458 |
"libelle" => _("Rédaction par compléments"), |
"libelle" => __("Rédaction par compléments"), |
459 |
"order" => 50, |
"order" => 50, |
460 |
"class" => "redac-complement-16", |
"class" => "redac-complement-16", |
461 |
), |
), |
492 |
$this->class_actions[400] = array( |
$this->class_actions[400] = array( |
493 |
"identifier" => "envoyer_a_signature", |
"identifier" => "envoyer_a_signature", |
494 |
"portlet" => array( |
"portlet" => array( |
495 |
"libelle" => _("Envoyer à signature"), |
"libelle" => __("Envoyer à signature"), |
496 |
"type" => "action-direct-with-confirmation", |
"type" => "action-direct-with-confirmation", |
497 |
"class" => "envoyer_a_signature-16", |
"class" => "envoyer_a_signature-16", |
498 |
), |
), |
547 |
"permission_suffix" => "tab", |
"permission_suffix" => "tab", |
548 |
); |
); |
549 |
|
|
550 |
|
// |
551 |
|
$this->class_actions[405] = array( |
552 |
|
"identifier" => "telecharger_editions", |
553 |
|
"view" => "view_telecharger_editions", |
554 |
|
"permission_suffix" => "om_fichier_instruction_telecharger", |
555 |
|
); |
556 |
|
|
557 |
// ACTION - 410 - Notifier les pétitionnaires (mail ou autre) |
// ACTION - 410 - Notifier les pétitionnaires (mail ou autre) |
558 |
$this->class_actions[410] = array( |
$this->class_actions[410] = array( |
559 |
"identifier" => "overlay_notification_manuelle", |
"identifier" => "overlay_notification_manuelle", |
582 |
"is_notifiable_by_task_manual", |
"is_notifiable_by_task_manual", |
583 |
"is_portail_notification_sans_annexe" |
"is_portail_notification_sans_annexe" |
584 |
), |
), |
585 |
"method" => "notifier_demandeur_principal", |
"method" => "notifier_demandeur_principal_via_portal", |
586 |
|
"permission_suffix" => "modifier", |
587 |
|
); |
588 |
|
|
589 |
|
// ACTION - 412 - Vérifie le dépassement de la date limite de notification |
590 |
|
$this->class_actions[412] = array( |
591 |
|
"identifier" => "is_date_limite_notification_dossier_depasse", |
592 |
|
"view" => "is_date_limite_notification_dossier_depasse", |
593 |
"permission_suffix" => "modifier", |
"permission_suffix" => "modifier", |
594 |
); |
); |
595 |
|
|
634 |
"view" => "formulaire", |
"view" => "formulaire", |
635 |
"method" => "envoyer_au_controle_de_legalite", |
"method" => "envoyer_au_controle_de_legalite", |
636 |
"condition" => array( |
"condition" => array( |
637 |
"can_be_sended_to_cl" |
"can_be_sent_to_cl" |
638 |
), |
), |
639 |
"permission_suffix" => "envoyer_au_controle_de_legalite", |
"permission_suffix" => "envoyer_au_controle_de_legalite", |
640 |
); |
); |
659 |
"instruction.evenement", |
"instruction.evenement", |
660 |
"instruction.commentaire", |
"instruction.commentaire", |
661 |
"date_evenement", |
"date_evenement", |
662 |
|
"document_type_instruction", |
663 |
|
"fichier_instruction_name", |
664 |
"instruction.lettretype", |
"instruction.lettretype", |
665 |
"signataire_arrete", |
"signataire_arrete", |
666 |
"flag_edition_integrale", |
"flag_edition_integrale", |
667 |
"om_final_instruction_utilisateur", |
"om_final_instruction_utilisateur", |
668 |
"date_finalisation_courrier", |
"date_finalisation_courrier", |
669 |
"date_envoi_signature", |
"date_envoi_signature", |
670 |
|
"date_retour_signature", |
671 |
"date_envoi_rar", |
"date_envoi_rar", |
|
"date_envoi_controle_legalite", |
|
672 |
|
|
|
"date_retour_signature", |
|
673 |
"date_retour_rar", |
"date_retour_rar", |
674 |
|
"date_envoi_controle_legalite", |
675 |
"date_retour_controle_legalite", |
"date_retour_controle_legalite", |
676 |
|
|
677 |
"numero_arrete", |
"numero_arrete", |
776 |
|
|
777 |
"'' as preview_edition", |
"'' as preview_edition", |
778 |
"envoye_cl_platau", |
"envoye_cl_platau", |
779 |
"'' as log_instruction" |
"'' as log_instruction", |
780 |
|
"parapheur_lien_page_signature" |
781 |
); |
); |
782 |
} |
} |
783 |
|
|
925 |
return false; |
return false; |
926 |
} |
} |
927 |
|
|
928 |
|
/** |
929 |
|
* CONDITION - is_signed |
930 |
|
* |
931 |
|
* Vérifie que l'instruction n'a pas été signée |
932 |
|
* |
933 |
|
* @return boolean |
934 |
|
*/ |
935 |
|
function is_not_signed() { |
936 |
|
// Contrôle si l'utilisateur possède un bypass |
937 |
|
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_definaliser_apres_signature"); |
938 |
|
if ($bypass == true) { |
939 |
|
return true; |
940 |
|
} |
941 |
|
|
942 |
|
return !$this->is_signed(); |
943 |
|
} |
944 |
|
|
945 |
|
|
946 |
/** |
/** |
947 |
* is_sent_to_cl |
* is_sent_to_cl |
970 |
function is_portail_notification_sans_annexe() { |
function is_portail_notification_sans_annexe() { |
971 |
$collectiviteDi = $this->get_dossier_instruction_om_collectivite(); |
$collectiviteDi = $this->get_dossier_instruction_om_collectivite(); |
972 |
$ev = $this->get_inst_evenement($this->getVal('evenement')); |
$ev = $this->get_inst_evenement($this->getVal('evenement')); |
973 |
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') |
|
974 |
&& $ev->getVal('notification') != 'notification_manuelle_annexe' |
&& $ev->getVal('notification') != 'notification_manuelle_annexe' |
975 |
&& $ev->getVal('notification') != 'notification_manuelle_annexe_signature_requise' |
&& $ev->getVal('notification') != 'notification_manuelle_annexe_signature_requise' |
976 |
) { |
) { |
1075 |
* @return boolean |
* @return boolean |
1076 |
*/ |
*/ |
1077 |
function can_display_notification_demandeur() { |
function can_display_notification_demandeur() { |
1078 |
// Le suivi des notification est affiché si l'événement est notifiable |
// Le suivi des notification est affiché si l'instruction a |
1079 |
// et si des notifications ont été envoyées |
// des notifications de demandeurs associées |
1080 |
$evenement_id = $this->getVal("evenement"); |
$idsNotifs = $this->get_instruction_notification( |
1081 |
$inst_evenement = $this->get_inst_evenement($evenement_id); |
$this->getVal($this->clePrimaire), |
1082 |
if ($inst_evenement->getVal('notification') != null && |
array( |
1083 |
$inst_evenement->getVal('notification') != '') { |
'notification_recepisse', |
1084 |
// Des notifications ont été envoyé si il existe au moins une notification |
'notification_instruction', |
1085 |
// liées à l'instruction |
'notification_decision', |
1086 |
$idsNotifs = $this->get_instruction_notification( |
), |
1087 |
$this->getVal($this->clePrimaire), |
true |
1088 |
array( |
); |
1089 |
'notification_recepisse', |
return isset($idsNotifs) && $idsNotifs !== array(); |
|
'notification_instruction', |
|
|
'notification_decision', |
|
|
), |
|
|
true |
|
|
); |
|
|
if (isset($idsNotifs) && $idsNotifs !== array()) { |
|
|
return true; |
|
|
} |
|
|
} |
|
|
return false; |
|
1090 |
} |
} |
1091 |
|
|
1092 |
/** |
/** |
1124 |
* @return boolean |
* @return boolean |
1125 |
*/ |
*/ |
1126 |
function can_display_notification_tiers() { |
function can_display_notification_tiers() { |
1127 |
// Le suivi des notification est affiché si l'événement est notifiable |
// Le suivi des notification est affiché si l'instruction a |
1128 |
// et si des notifications ont été envoyées |
// des notifications de tiers associées |
1129 |
$evenement_id = $this->getVal("evenement"); |
$idsNotifs = $this->get_instruction_notification( |
1130 |
$inst_evenement = $this->get_inst_evenement($evenement_id); |
$this->getVal($this->clePrimaire), |
1131 |
if ($this->get_boolean_from_pgsql_value($inst_evenement->getVal('notification_tiers')) == true) { |
'notification_tiers_consulte' |
1132 |
// Des notifications ont été envoyé si il existe au moins une notification |
); |
1133 |
// de type notification_tiers_consulte liées à l'instruction |
return isset($idsNotifs) && $idsNotifs !== array(); |
|
$idsNotifs = $this->get_instruction_notification( |
|
|
$this->getVal($this->clePrimaire), |
|
|
'notification_tiers_consulte' |
|
|
); |
|
|
if (isset($idsNotifs) && $idsNotifs !== array()) { |
|
|
return true; |
|
|
} |
|
|
} |
|
|
return false; |
|
1134 |
} |
} |
1135 |
|
|
1136 |
/** |
/** |
1183 |
// Termine le traitement |
// Termine le traitement |
1184 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
1185 |
} else { |
} else { |
1186 |
$this->addToMessage(_("Rédaction par compléments activé.")); |
$this->addToMessage(__("Rédaction par compléments activé.")); |
1187 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
1188 |
} |
} |
1189 |
|
|
1246 |
// Termine le traitement |
// Termine le traitement |
1247 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
1248 |
} else { |
} else { |
1249 |
$this->addToMessage(_("Rédaction libre activé.")); |
$this->addToMessage(__("Rédaction libre activé.")); |
1250 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
1251 |
} |
} |
1252 |
|
|
1255 |
} |
} |
1256 |
|
|
1257 |
/** |
/** |
1258 |
* 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é |
1259 |
|
* en paramètre et renvoie l'identifiant du dossier d'autorisation (DA) |
1260 |
|
* associé au dossier. |
1261 |
|
* Si l'identifiant du dossier n'est pas fourni alors cette méthode |
1262 |
|
* renverra NULL |
1263 |
|
* |
1264 |
|
* @param string identifiant du dossier |
1265 |
|
* @return null|string null ou identifiant du DA |
1266 |
*/ |
*/ |
1267 |
function getNumDemandeAutorFromDossier($id) { |
function getNumDemandeAutorFromDossier($id) { |
|
// |
|
1268 |
if (!isset($id)) { |
if (!isset($id)) { |
1269 |
return NULL; |
return NULL; |
1270 |
} |
} |
1271 |
// |
|
1272 |
$sql = "select dossier_autorisation from ".DB_PREFIXE."dossier "; |
$dossier = $this->f->get_inst__om_dbform(array( |
1273 |
$sql .= " where dossier='".$id."'"; |
'obj' => 'dossier', |
1274 |
// |
'idx' => $id, |
1275 |
$dossier_autorisation = $this->f->db->getOne($sql); |
)); |
1276 |
$this->addToLog("getNumDemandeAutorFromDossier(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
|
1277 |
database::isError($dossier_autorisation); |
return $dossier->getVal('dossier_autorisation'); |
|
// |
|
|
return $dossier_autorisation; |
|
1278 |
} |
} |
1279 |
|
|
|
// }}} |
|
1280 |
|
|
1281 |
|
/** |
1282 |
|
* Cette méthode permet de récupérer le libelle du type de document |
1283 |
|
* en instanciant l'objet document_type. |
1284 |
|
* |
1285 |
|
* Un évènement peux avoir ou non un type de document, et si c'est le cas, |
1286 |
|
* on le récupère pour l'afficher. |
1287 |
|
* |
1288 |
|
* @return string|NULL Retourne le libelle du type de document ou vide |
1289 |
|
*/ |
1290 |
|
function get_type_document_linked_with_instruction(){ |
1291 |
|
// |
1292 |
|
$document_type = $this->f->get_inst__om_dbform(array( |
1293 |
|
'obj' => 'document_type', |
1294 |
|
'idx' => $this->getVal("document_type_instruction"), |
1295 |
|
)); |
1296 |
|
if ($document_type->exists() === true) { |
1297 |
|
return $document_type->getVal("libelle"); |
1298 |
|
} |
1299 |
|
return NULL; |
1300 |
|
} |
1301 |
|
|
1302 |
|
|
1303 |
function setType(&$form, $maj) { |
function setType(&$form, $maj) { |
1304 |
|
$data = array('form' => &$form, 'maj' => &$maj); |
1305 |
|
$this->f->module_manager->run_hooks('setType_pre', $this, $data); |
1306 |
|
|
1307 |
// Récupération du mode de l'action |
// Récupération du mode de l'action |
1308 |
$crud = $this->get_action_crud($maj); |
$crud = $this->get_action_crud($maj); |
1309 |
// Récupère la collectivité du dossier d'instruction |
// Récupère la collectivité du dossier d'instruction |
1376 |
} |
} |
1377 |
$form->setType("evenement", "selecthiddenstatic"); |
$form->setType("evenement", "selecthiddenstatic"); |
1378 |
if ($this->has_an_edition() === true) { |
if ($this->has_an_edition() === true) { |
1379 |
|
$form->setType('document_type_instruction', 'selecthiddenstatic'); |
1380 |
$form->setType('lettretype', 'hiddenstatic'); |
$form->setType('lettretype', 'hiddenstatic'); |
1381 |
if ($this->is_in_context_of_foreign_key("signataire_arrete", $this->getParameter("retourformulaire"))) { |
if ($this->is_in_context_of_foreign_key("signataire_arrete", $this->getParameter("retourformulaire"))) { |
1382 |
$form->setType("signataire_arrete", "selecthiddenstatic"); |
$form->setType("signataire_arrete", "selecthiddenstatic"); |
1447 |
$form->setType("date_evenement", "datestatic"); |
$form->setType("date_evenement", "datestatic"); |
1448 |
$form->setType("evenement", "selecthiddenstatic"); |
$form->setType("evenement", "selecthiddenstatic"); |
1449 |
if ($this->has_an_edition() === true) { |
if ($this->has_an_edition() === true) { |
1450 |
|
$form->setType("document_type_instruction", "selecthiddenstatic"); |
1451 |
$form->setType('lettretype', 'hiddenstatic'); |
$form->setType('lettretype', 'hiddenstatic'); |
1452 |
$form->setType("signataire_arrete", "selecthiddenstatic"); |
$form->setType("signataire_arrete", "selecthiddenstatic"); |
1453 |
if ($this->getVal("om_final_instruction") == 't') { |
if ($this->getVal("om_final_instruction") == 't') { |
1519 |
// Si l'instruction a été envoyé au contrôle de légalité et que la |
// Si l'instruction a été envoyé au contrôle de légalité et que la |
1520 |
// tâche envoi_cl lié n'a pas encore été traité il faut indiquer à |
// tâche envoi_cl lié n'a pas encore été traité il faut indiquer à |
1521 |
// l'utilisateur que l'envoi au cl est en cours de traitement. |
// l'utilisateur que l'envoi au cl est en cours de traitement. |
1522 |
if ($this->is_sent_to_cl() === true |
if ($this->is_sent_to_cl() === true |
|
&& empty($this->getVal('date_envoi_controle_legalite')) |
|
1523 |
&& $maj == 3) { |
&& $maj == 3) { |
1524 |
$form->setType("date_envoi_controle_legalite", "hiddenstatic"); |
$form->setType("date_envoi_controle_legalite", "datestatic"); |
1525 |
|
if (empty($this->getVal('date_envoi_controle_legalite'))) { |
1526 |
|
$form->setType("date_envoi_controle_legalite", "hiddenstatic"); |
1527 |
|
} |
1528 |
} |
} |
1529 |
|
$data = array('form' => &$form, 'maj' => &$maj, 'collectivite_di' => $collectivite_di); |
1530 |
|
$this->f->module_manager->run_hooks('setType_post', $this, $data); |
1531 |
} |
} |
1532 |
|
|
1533 |
function setOnchange(&$form,$maj){ |
function setOnchange(&$form,$maj){ |
1534 |
|
$this->f->log(__METHOD__, 'BEGIN'); |
1535 |
|
$data = array('form' => &$form, 'maj' => &$maj); |
1536 |
|
$this->f->module_manager->run_hooks('setOnchange_pre', $this, $data); |
1537 |
|
|
1538 |
parent::setOnchange($form,$maj); |
parent::setOnchange($form,$maj); |
1539 |
|
|
1540 |
// MODE AJOUTER |
// MODE AJOUTER |
1545 |
manage_instruction_evenement_commentaire(this.value, '".addslashes($this->getParameter('idxformulaire'))."');" |
manage_instruction_evenement_commentaire(this.value, '".addslashes($this->getParameter('idxformulaire'))."');" |
1546 |
); |
); |
1547 |
} |
} |
1548 |
|
|
1549 |
|
$data = array('form' => &$form, 'maj' => &$maj); |
1550 |
|
$this->f->module_manager->run_hooks('setOnchange_post', $this, $data); |
1551 |
|
$this->f->log(__METHOD__, 'END'); |
1552 |
} |
} |
1553 |
|
|
1554 |
function evenement_has_an_edition($evenement_id) { |
function evenement_has_an_edition($evenement_id) { |
1582 |
|
|
1583 |
|
|
1584 |
/** |
/** |
1585 |
* CONDITION - can_be_sended_to_cl |
* CONDITION - can_be_sent_to_cl |
1586 |
* |
* |
1587 |
* Vérifie que le contrôle de légalité est disponible |
* Vérifie que le contrôle de légalité est disponible |
1588 |
* |
* |
1589 |
* @return boolean |
* @return boolean |
1590 |
*/ |
*/ |
1591 |
function can_be_sended_to_cl() { |
function can_be_sent_to_cl() { |
1592 |
// Si l'instruction a une édition |
$inst_evenement = $this->get_inst_evenement($this->getVal('evenement')); |
1593 |
// et que l'événement est paramétré pour envoyer le contrôle de légalité |
|
1594 |
|
// Si événement est paramétré pour envoyer le contrôle de légalité |
1595 |
// par Plat'AU |
// par Plat'AU |
1596 |
// et que la date de retour signature est renseignée |
if ($inst_evenement->getVal('envoi_cl_platau') === 't') { |
|
// et que la date d'envoi au contrôle légalité n'est pas renseignée |
|
|
// et qu'il n'existe pas de task envoi_CL en cours (!= done ou canceled) |
|
|
if ($this->has_an_edition() === true) { |
|
1597 |
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
1598 |
$inst_evenement = $this->get_inst_evenement($this->getVal('evenement')); |
|
1599 |
if ($inst_evenement->getVal('envoi_cl_platau') === 't' |
// S'il n'y a pas déjà eu un envoi au CL (flag envoye_cl_platau) |
1600 |
&& empty($this->getVal('date_retour_signature')) === false |
// Que le type de dossier d'autorisation est transmissible à Plat'AU |
1601 |
&& empty($this->getVal('date_envoi_controle_legalite')) === true |
// Que l'état de transmission du dossier n'est pas en 'jamais_transmissible' |
1602 |
&& $this->getVal('envoye_cl_platau') === 'f' |
if ($this->getVal('envoye_cl_platau') === 'f' |
1603 |
&& $this->f->is_type_dossier_platau($inst_di->getVal('dossier_autorisation')) === true |
&& $this->f->is_type_dossier_platau($inst_di->getVal('dossier_autorisation')) === true |
1604 |
&& $inst_di->getVal('etat_transmission_platau') !== 'jamais_transmissible') { |
&& $inst_di->getVal('etat_transmission_platau') !== 'jamais_transmissible') { |
1605 |
// |
|
1606 |
return true; |
// Si l'instruction n'a pas d'édition liée alors elle peut être envoyé au CL |
1607 |
|
if ($this->has_an_edition() === false) { |
1608 |
|
return true; |
1609 |
|
} |
1610 |
|
|
1611 |
|
// Si l'instruction a une édition et que la date de retour signature est renseignée |
1612 |
|
// et que la date d'envoi au contrôle légalité n'est pas renseignée alors on peut |
1613 |
|
// envoyer l'instruction au CL |
1614 |
|
if ($this->has_an_edition() === true |
1615 |
|
&& empty($this->getVal('date_retour_signature')) === false |
1616 |
|
&& empty($this->getVal('date_envoi_controle_legalite')) === true) { |
1617 |
|
|
1618 |
|
return true; |
1619 |
|
} |
1620 |
} |
} |
1621 |
} |
} |
1622 |
// |
// |
1784 |
} |
} |
1785 |
|
|
1786 |
/** |
/** |
1787 |
|
* Renvoie sous la forme d'un tableau la liste des événements pouvant être ajoutés au dossier |
1788 |
|
* dont l'identifiant a été passé en paramètre dans l'url. |
1789 |
|
* |
1790 |
|
* @return array |
1791 |
|
*/ |
1792 |
|
function get_var_sql_forminc__sql_evenement() { |
1793 |
|
// Récupération du numéro de dossier |
1794 |
|
$dossier = $this->getParameter("idxformulaire") ?? $_GET['idxformulaire']; |
1795 |
|
$this->f->log(__METHOD__, 'dossier: '.var_export($dossier, true)); |
1796 |
|
// Si changement de décision par instructeur commune |
1797 |
|
$filter = ''; |
1798 |
|
if ($this->f->isUserInstructeur() === true |
1799 |
|
// TODO faire autrement car ça instancier le dossier et donc charge ses modules ! |
1800 |
|
&& $this->getDivisionFromDossier($dossier) != $_SESSION["division"] |
1801 |
|
&& $this->isInstrCanChangeDecision($dossier) === true) { |
1802 |
|
$filter = "AND evenement.type IN ('arrete', 'changement_decision')"; |
1803 |
|
} |
1804 |
|
// Récupération du libellé, de l'identifiant des évènement et d'un booléen permettant |
1805 |
|
// de déterminer si il s'agit d'évènements suggérés. |
1806 |
|
$qres = $this->f->get_all_results_from_db_query( |
1807 |
|
sprintf( |
1808 |
|
'SELECT |
1809 |
|
DISTINCT(evenement.evenement), |
1810 |
|
evenement.libelle, |
1811 |
|
-- Si l evenement est suggérés alors il sera lié à la table des événements suggérés du dossier |
1812 |
|
CASE WHEN evenement_suggere_dossier.evenement IS NULL |
1813 |
|
THEN FALSE |
1814 |
|
ELSE TRUE |
1815 |
|
END AS is_suggested |
1816 |
|
FROM |
1817 |
|
-- Jointures permettant de récupérer la liste des évènements compatibles avec le dossier |
1818 |
|
-- selon le type de dossier et l état du dossier. |
1819 |
|
%1$sevenement |
1820 |
|
JOIN %1$slien_dossier_instruction_type_evenement |
1821 |
|
ON evenement.evenement = lien_dossier_instruction_type_evenement.evenement |
1822 |
|
JOIN %1$stransition |
1823 |
|
ON evenement.evenement = transition.evenement |
1824 |
|
JOIN %1$sdossier |
1825 |
|
ON lien_dossier_instruction_type_evenement.dossier_instruction_type = dossier.dossier_instruction_type |
1826 |
|
AND transition.etat = dossier.etat |
1827 |
|
-- Jointures avec une sous requêtes servant à récupérer la liste des évènements suggérés du dossier. |
1828 |
|
LEFT JOIN ( |
1829 |
|
SELECT |
1830 |
|
lien_sig_contrainte_evenement.evenement, |
1831 |
|
dossier.dossier |
1832 |
|
FROM |
1833 |
|
%1$slien_sig_contrainte_evenement |
1834 |
|
JOIN %1$ssig_contrainte |
1835 |
|
ON lien_sig_contrainte_evenement.sig_contrainte = sig_contrainte.sig_contrainte |
1836 |
|
JOIN %1$slien_sig_contrainte_dossier_instruction_type |
1837 |
|
ON sig_contrainte.sig_contrainte = lien_sig_contrainte_dossier_instruction_type.sig_contrainte |
1838 |
|
JOIN %1$slien_sig_contrainte_om_collectivite |
1839 |
|
ON sig_contrainte.sig_contrainte = lien_sig_contrainte_om_collectivite.sig_contrainte |
1840 |
|
JOIN %1$scontrainte |
1841 |
|
ON sig_contrainte.libelle = contrainte.libelle |
1842 |
|
JOIN %1$sdossier_contrainte |
1843 |
|
ON contrainte.contrainte = dossier_contrainte.contrainte |
1844 |
|
JOIN %1$sdossier |
1845 |
|
ON dossier_contrainte.dossier = dossier.dossier |
1846 |
|
AND lien_sig_contrainte_dossier_instruction_type.dossier_instruction_type = dossier.dossier_instruction_type |
1847 |
|
JOIN %1$som_collectivite |
1848 |
|
ON lien_sig_contrainte_om_collectivite.om_collectivite = om_collectivite.om_collectivite |
1849 |
|
AND (dossier.om_collectivite = om_collectivite.om_collectivite |
1850 |
|
OR om_collectivite.niveau = \'2\') |
1851 |
|
) AS evenement_suggere_dossier |
1852 |
|
ON evenement.evenement = evenement_suggere_dossier.evenement |
1853 |
|
AND dossier.dossier = evenement_suggere_dossier.dossier |
1854 |
|
WHERE |
1855 |
|
dossier.dossier = \'%2$s\' |
1856 |
|
%3$s |
1857 |
|
ORDER BY |
1858 |
|
is_suggested DESC, |
1859 |
|
evenement.libelle', |
1860 |
|
DB_PREFIXE, |
1861 |
|
$this->f->db->escapeSimple($dossier), |
1862 |
|
$filter |
1863 |
|
), |
1864 |
|
array( |
1865 |
|
"origin" => __METHOD__ |
1866 |
|
) |
1867 |
|
); |
1868 |
|
return $qres['result']; |
1869 |
|
} |
1870 |
|
|
1871 |
|
/** |
1872 |
|
* Récupère un tableau contenant des évènements de la forme : |
1873 |
|
* $events = array( |
1874 |
|
* 1 => array( |
1875 |
|
* 'libelle' => 'evenement_libelle', |
1876 |
|
* 'evenement' => 'identifiant_evenement', |
1877 |
|
* 'is_suggested' => true/false -> booleen indiquant si c'est un événement suggéré |
1878 |
|
* )) |
1879 |
|
* Et le transforme pour pouvoir l'utiliser pour le remplissage d'un select de formulaire. |
1880 |
|
* |
1881 |
|
* Le format de sorti est le suivant : |
1882 |
|
* $select = array( |
1883 |
|
* 0 => array( -> liste des id des événements |
1884 |
|
* '0' => '', |
1885 |
|
* '1' => array( |
1886 |
|
* '0' => array(), -> liste des id des événements suggérés |
1887 |
|
* '1' => array(), -> liste des libelles des événements suggérés |
1888 |
|
* ), |
1889 |
|
* ..., |
1890 |
|
* n => 'id_evenement_n' |
1891 |
|
* ), |
1892 |
|
* 1 => array( |
1893 |
|
* '0' => '__('choisir')." ".__('evenement')', |
1894 |
|
* '1' => '💡 Suggestions', |
1895 |
|
* ..., |
1896 |
|
* 'n' => 'libelle_evenement_n', |
1897 |
|
* ) |
1898 |
|
* ) |
1899 |
|
* |
1900 |
|
* @param array tableau des événements |
1901 |
|
* @return array |
1902 |
|
*/ |
1903 |
|
protected function convert_events_array_to_select_format($events) { |
1904 |
|
// Remplissage du tableau du select en incluant le groupe des instructions suggérées. |
1905 |
|
$contenu = array( |
1906 |
|
0 => array("",), |
1907 |
|
1 => array(__('choisir')." ".__('evenement'),) |
1908 |
|
); |
1909 |
|
|
1910 |
|
if (! empty($events)) { |
1911 |
|
// S'il y a des évènements suggérés extraction de ces événements et mise en place du groupe |
1912 |
|
$suggested_event_group = array_filter($events, function($a) { |
1913 |
|
return $a['is_suggested'] === 't'; |
1914 |
|
}); |
1915 |
|
if (! empty($suggested_event_group)) { |
1916 |
|
// Prépare les données qui permettront d'afficher le groupe des événements |
1917 |
|
// suggérés. |
1918 |
|
$values = array(); |
1919 |
|
$labels = array(); |
1920 |
|
foreach ($suggested_event_group as $index => $suggested_event) { |
1921 |
|
$values[] = $suggested_event['evenement']; |
1922 |
|
$labels[] = $suggested_event['libelle']; |
1923 |
|
// Supprime les évènements suggérés de la liste des évènements |
1924 |
|
unset($events[$index]); |
1925 |
|
} |
1926 |
|
// Remplissage du select pour le groupe |
1927 |
|
$contenu[0][] = array($values, $labels); |
1928 |
|
$contenu[1][] = __('💡 Suggestions'); |
1929 |
|
} |
1930 |
|
|
1931 |
|
// Remplissage du select |
1932 |
|
foreach ($events as $event) { |
1933 |
|
$contenu[0][] = $event['evenement']; |
1934 |
|
$contenu[1][] = $event['libelle']; |
1935 |
|
} |
1936 |
|
} |
1937 |
|
return $contenu; |
1938 |
|
} |
1939 |
|
|
1940 |
|
/** |
1941 |
* SETTER_FORM - setSelect. |
* SETTER_FORM - setSelect. |
1942 |
* |
* |
1943 |
* @return void |
* @return void |
1974 |
// signataire_arrete |
// signataire_arrete |
1975 |
// si contexte DI |
// si contexte DI |
1976 |
if ($this->getParameter("retourformulaire") == "dossier" |
if ($this->getParameter("retourformulaire") == "dossier" |
1977 |
|| $this->getParameter("retourformulaire") == "dossier_instruction" |
|| $this->f->contexte_dossier_instruction()) { |
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_encours" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_encours" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_clotures" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_clotures" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_mes_infractions" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_toutes_infractions" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_mes_recours" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_tous_recours") { |
|
1978 |
// on recupère les signataires de la multicollectivité et de celle du DI |
// on recupère les signataires de la multicollectivité et de celle du DI |
1979 |
$di = $this->f->get_inst__om_dbform(array( |
$di = $this->f->get_inst__om_dbform(array( |
1980 |
"obj" => "dossier_instruction", |
"obj" => "dossier_instruction", |
2015 |
* événements disponibles. |
* événements disponibles. |
2016 |
*/ |
*/ |
2017 |
if ($maj == 0) { |
if ($maj == 0) { |
2018 |
// Récupération des événements par une jointure entre la table dossier |
$evenements = $this->get_var_sql_forminc__sql_evenement(); |
2019 |
// 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("setSelect(): db->query(\"".$sql."\");", VERBOSE_MODE); |
|
|
if (database::isError($res)) { |
|
|
die($res->getMessage()); |
|
|
} |
|
|
// 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); |
|
|
|
|
2020 |
} else { |
} else { |
2021 |
$sql = "SELECT |
// Instanciation de l'événement pour récupérer son libellé |
2022 |
evenement.libelle as lib |
$evenement = $this->f->get_inst__om_dbform(array( |
2023 |
FROM ".DB_PREFIXE."evenement |
"obj" => "evenement", |
2024 |
WHERE evenement.evenement=".$this->getVal("evenement").""; |
"idx" => $this->getVal("evenement"), |
2025 |
$res = $this->f->db->getone($sql); |
)); |
2026 |
$this->addToLog("setSelect(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
|
|
if (database::isError($res)) { |
|
|
die($res->getMessage()); |
|
|
} |
|
|
// |
|
2027 |
$contenu = array( |
$contenu = array( |
2028 |
0 => array($this->getVal("evenement"),), |
0 => array($this->getVal("evenement"),), |
2029 |
1 => array($res,) |
1 => array($evenement->getVal('libelle'),) |
2030 |
); |
); |
2031 |
$form->setSelect("evenement", $contenu); |
$form->setSelect("evenement", $contenu); |
2032 |
} |
} |
2035 |
* Gesion des liens vers la bible |
* Gesion des liens vers la bible |
2036 |
*/ |
*/ |
2037 |
// lien bible_auto |
// lien bible_auto |
2038 |
$contenu = array(_("automatique")); |
$contenu = array(__("automatique")); |
2039 |
$form->setSelect("bible_auto",$contenu); |
$form->setSelect("bible_auto",$contenu); |
2040 |
// lien bible1 |
// lien bible1 |
2041 |
$contenu = array(_("bible")); |
$contenu = array(__("bible")); |
2042 |
$form->setSelect("bible",$contenu); |
$form->setSelect("bible",$contenu); |
2043 |
// lien bible2 |
// lien bible2 |
2044 |
$contenu = array(_("bible")); |
$contenu = array(__("bible")); |
2045 |
$form->setSelect("bible2",$contenu); |
$form->setSelect("bible2",$contenu); |
2046 |
// lien bible3 |
// lien bible3 |
2047 |
$contenu = array(_("bible")); |
$contenu = array(__("bible")); |
2048 |
$form->setSelect("bible3",$contenu); |
$form->setSelect("bible3",$contenu); |
2049 |
// lien bible4 |
// lien bible4 |
2050 |
$contenu = array(_("bible")); |
$contenu = array(__("bible")); |
2051 |
$form->setSelect("bible4",$contenu); |
$form->setSelect("bible4",$contenu); |
2052 |
|
|
2053 |
if ($maj == 1) { |
if ($maj == 1) { |
2054 |
$base64 = $this->init_pdf_temp(); |
$base64 = $this->init_pdf_temp(); |
2055 |
$form->setSelect('live_preview', array('base64'=>$base64)); |
$form->setSelect('live_preview', array('base64'=>$base64)); |
2056 |
$form->setSelect("btn_refresh", array(_('Prévisualiser'))); |
$form->setSelect("btn_refresh", array(__('Prévisualiser'))); |
2057 |
$form->setSelect("btn_preview", array(_('Prévisualiser >>'))); |
$form->setSelect("btn_preview", array(__('Prévisualiser >>'))); |
2058 |
$form->setSelect("btn_redaction", array(_('<< Rédiger'))); |
$form->setSelect("btn_redaction", array(__('<< Rédiger'))); |
2059 |
} |
} |
2060 |
|
|
2061 |
// Selection du type de rédaction à l'ajout |
// Selection du type de rédaction à l'ajout |
2062 |
$content = array( |
$content = array( |
2063 |
0 => array('f', 't', ), |
0 => array('f', 't', ), |
2064 |
1 => array(_('Rédaction par compléments'), _('Rédaction libre'), ), |
1 => array(__('Rédaction par compléments'), __('Rédaction libre'), ), |
2065 |
); |
); |
2066 |
$form->setSelect('flag_edition_integrale', $content); |
$form->setSelect('flag_edition_integrale', $content); |
2067 |
|
|
2074 |
|
|
2075 |
|
|
2076 |
if ($maj == 401) { |
if ($maj == 401) { |
2077 |
$file = $this->f->storage->get($this->getVal('om_fichier_instruction')); |
$idx = $this->getParameter("idx"); |
2078 |
|
$dossier = $this->getParameter("idxformulaire"); |
2079 |
|
if ( strpos($idx, 'STORAGE_') !== FALSE) { |
2080 |
|
$idx = substr($idx, 8); |
2081 |
|
$model = 'storage'; |
2082 |
|
$champ = 'uid'; |
2083 |
|
$object = $this->f->get_inst__om_dbform(array( |
2084 |
|
"obj" => $model, |
2085 |
|
"idx" => $idx, |
2086 |
|
)); |
2087 |
|
|
2088 |
|
$file = $this->f->storage->get($object->getVal($champ)); |
2089 |
|
$label = $file['metadata']['filename']; |
2090 |
|
$href =sprintf( |
2091 |
|
'../app/index.php?module=form&snippet=file&obj=storage&champ=uid&id=%1$s', |
2092 |
|
$idx |
2093 |
|
); |
2094 |
|
$this->addToLog(__METHOD__."(): file['metadata']['filename'] = ".$file['metadata']['filename']." ", DEBUG_MODE); |
2095 |
|
$this->val['preview_edition'] = ''; |
2096 |
|
}else{ |
2097 |
|
$label = $this->getVal("fichier_instruction_name"); |
2098 |
|
$href =sprintf( |
2099 |
|
'../app/index.php?module=form&snippet=file&obj=instruction&champ=om_fichier_instruction&id=%1$s', |
2100 |
|
$this->getVal($this->clePrimaire) |
2101 |
|
); |
2102 |
|
$file = $this->f->storage->get($this->getVal('om_fichier_instruction')); |
2103 |
|
} |
2104 |
|
|
2105 |
$form->setSelect('preview_edition', array( |
$form->setSelect('preview_edition', array( |
2106 |
'base64' => base64_encode($file['file_content']), |
'base64' => base64_encode($file['file_content']), |
2107 |
'mimetype' => $file['metadata']['mimetype'], |
'mimetype' => $file['metadata']['mimetype'], |
2108 |
'label' => 'instruction_'.$this->getVal($this->clePrimaire), |
'label' => $label, |
2109 |
'href' => sprintf( |
'href' => $href |
|
'../app/index.php?module=form&snippet=file&obj=instruction&champ=om_fichier_instruction&id=%1$s', |
|
|
$this->getVal($this->clePrimaire) |
|
|
) |
|
2110 |
)); |
)); |
2111 |
} |
} |
2112 |
|
// document_type_instruction |
2113 |
|
$this->init_select( |
2114 |
|
$form, |
2115 |
|
$this->f->db, |
2116 |
|
$maj, |
2117 |
|
null, |
2118 |
|
"document_type_instruction", |
2119 |
|
$this->get_var_sql_forminc__sql("document_type_instruction"), |
2120 |
|
$this->get_var_sql_forminc__sql("document_type_instruction_by_id"), |
2121 |
|
true |
2122 |
|
); |
2123 |
} |
} |
2124 |
|
|
2125 |
function cleSecondaire($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
function cleSecondaire($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
2129 |
|
|
2130 |
$id = $this->getVal($this->clePrimaire); |
$id = $this->getVal($this->clePrimaire); |
2131 |
|
|
|
|
|
2132 |
//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é |
2133 |
//à la création d'un dossier d'instruction |
//à la création d'un dossier d'instruction |
2134 |
$sql = "SELECT demande_type.dossier_instruction_type |
$qres = $this->f->get_one_result_from_db_query( |
2135 |
FROM ".DB_PREFIXE."demande_type |
sprintf( |
2136 |
LEFT JOIN ".DB_PREFIXE."demande |
'SELECT |
2137 |
ON demande.demande_type = demande_type.demande_type |
demande_type.dossier_instruction_type |
2138 |
WHERE demande.instruction_recepisse = ".$id; |
FROM |
2139 |
$res = $this->f->db->getOne($sql); |
%1$sdemande_type |
2140 |
$this->addToLog("cleSecondaire(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
LEFT JOIN %1$sdemande |
2141 |
if (database::isError($res)) { |
ON demande.demande_type = demande_type.demande_type |
2142 |
die($res->getMessage()); |
WHERE |
2143 |
} |
demande.instruction_recepisse = \'%2$d\'', |
2144 |
|
DB_PREFIXE, |
2145 |
|
intval($id) |
2146 |
|
), |
2147 |
|
array( |
2148 |
|
"origin" => __METHOD__, |
2149 |
|
) |
2150 |
|
); |
2151 |
|
|
2152 |
// 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 |
2153 |
//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 |
2154 |
//supprimé |
//supprimé |
2155 |
if ( $this->correct !== false || $res == null || $res == ""){ |
if ( $this->correct !== false || $qres['result'] == null || $qres['result'] == ""){ |
|
|
|
2156 |
// 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é |
2157 |
// à une demande |
// à une demande |
2158 |
$sql = "SELECT demande |
$qres = $this->f->get_one_result_from_db_query( |
2159 |
FROM ".DB_PREFIXE."demande |
sprintf( |
2160 |
WHERE instruction_recepisse = ".$id; |
'SELECT |
2161 |
$res = $this->f->db->getOne($sql); |
demande |
2162 |
$this->addToLog("cleSecondaire(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
FROM |
2163 |
if (database::isError($res)) { |
%1$sdemande |
2164 |
die($res->getMessage()); |
WHERE |
2165 |
} |
instruction_recepisse = \'%2$d\'', |
2166 |
|
DB_PREFIXE, |
2167 |
|
intval($id) |
2168 |
|
), |
2169 |
|
array( |
2170 |
|
"origin" => __METHOD__, |
2171 |
|
) |
2172 |
|
); |
2173 |
|
|
2174 |
//Si c'est un événement d'instruction lié à une demande |
//Si c'est un événement d'instruction lié à une demande |
2175 |
if ($res != null || $res != ""){ |
if ($qres['result'] != null || $qres['result'] != ""){ |
2176 |
$demande = $this->f->get_inst__om_dbform(array( |
$demande = $this->f->get_inst__om_dbform(array( |
2177 |
"obj" => "demande", |
"obj" => "demande", |
2178 |
"idx" => $res, |
"idx" => $qres['result'], |
2179 |
)); |
)); |
2180 |
|
|
2181 |
//On met à jour la demande en supprimant la liaison vers |
//On met à jour la demande en supprimant la liaison vers |
2182 |
//l'événement d'instruction |
//l'événement d'instruction |
2183 |
$demande->setParameter("maj", 1); |
$demande->setParameter("maj", 1); |
2184 |
$valF = array(); |
$valF = array(); |
2194 |
* Vérification que l'élément supprimé est le dernier pour pouvoir |
* Vérification que l'élément supprimé est le dernier pour pouvoir |
2195 |
* remodifier les données de manière itérative. |
* remodifier les données de manière itérative. |
2196 |
*/ |
*/ |
2197 |
// Initialisation |
$qres = $this->f->get_one_result_from_db_query( |
2198 |
$dernierevenement = ""; |
sprintf( |
2199 |
// Récupération du dernier élément de la table d'instruction qui |
'SELECT |
2200 |
// concerne le dossier en cours |
max(instruction) |
2201 |
$sql = "SELECT max(instruction) |
FROM |
2202 |
FROM ".DB_PREFIXE."instruction |
%1$sinstruction |
2203 |
WHERE dossier ='".$this->getParameter("idxformulaire")."'"; |
WHERE |
2204 |
$dernierevenement = $this->f->db->getOne($sql); |
dossier = \'%2$s\'', |
2205 |
$this->addToLog("setSelect(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
DB_PREFIXE, |
2206 |
if (database::isError($dernierevenement)) { |
$this->f->db->escapeSimple($this->getParameter("idxformulaire")) |
2207 |
die($dernierevenement->getMessage()); |
), |
2208 |
} |
array( |
2209 |
|
"origin" => __METHOD__, |
2210 |
|
) |
2211 |
|
); |
2212 |
|
|
2213 |
// Si on se trouve effectivement sur le dernier evenement d'instruction |
// Si on se trouve effectivement sur le dernier evenement d'instruction |
2214 |
if ($dernierevenement == $id) { |
// alors on valide la suppression sinon on l'annule |
2215 |
|
$this->correct = false; |
2216 |
|
$message = __("Seul le dernier evenement d'instruction peut etre supprime."); |
2217 |
|
if ($qres['result'] == $id) { |
2218 |
// Alors on valide la suppression |
// Alors on valide la suppression |
2219 |
$this->correct = true; |
$this->correct = true; |
2220 |
$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.")); |
|
2221 |
} |
} |
2222 |
|
$this->addToMessage($message); |
2223 |
} |
} |
2224 |
} |
} |
2225 |
|
|
2231 |
|
|
2232 |
//Si le retourformulaire est "dossier_instruction" |
//Si le retourformulaire est "dossier_instruction" |
2233 |
if ($this->getParameter("retourformulaire") == "dossier" |
if ($this->getParameter("retourformulaire") == "dossier" |
2234 |
|| $this->getParameter("retourformulaire") == "dossier_instruction" |
|| $this->f->contexte_dossier_instruction()) { |
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_encours" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_encours" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_clotures" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_clotures" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_mes_infractions" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_toutes_infractions" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_mes_recours" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_tous_recours") { |
|
2235 |
|
|
2236 |
// Vérification de la possibilité de modifier les dates si déjà éditées |
// Vérification de la possibilité de modifier les dates si déjà éditées |
2237 |
if($this->valF[$champ] != "" AND !$this->f->user_is_admin) { |
if($this->valF[$champ] != "" && !$this->f->user_is_admin) { |
2238 |
// si l'utilisateur n'est pas un admin |
// si l'utilisateur n'est pas un admin |
2239 |
if($this->getVal($champ) != "" AND $this->getVal($champ) != $this->valF[$champ]) { |
if($this->getVal($champ) != "" && $this->getVal($champ) != $this->valF[$champ]) { |
2240 |
$this->correct = false; |
|
2241 |
$this->addToMessage(_("Les dates de suivis ne peuvent etre modifiees")); |
// si le champ concerné est 'date_envoi_signature' |
2242 |
|
// et que le statut du parapheur est 'expired' |
2243 |
|
// alors on autorise le changement de la date |
2244 |
|
// pour tous les autres cas, on ne peut modifier la date |
2245 |
|
if ($champ !== 'date_envoi_signature' || $this->getVal('statut_signature') !== 'expired') { |
2246 |
|
$this->correct = false; |
2247 |
|
$this->addToMessage(__("Les dates de suivis ne peuvent etre modifiees")); |
2248 |
|
} |
2249 |
} |
} |
2250 |
} |
} |
2251 |
} |
} |
2260 |
* @return void |
* @return void |
2261 |
*/ |
*/ |
2262 |
function setValsousformulaire(&$form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire, &$dnu1 = null, $dnu2 = null) { |
function setValsousformulaire(&$form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire, &$dnu1 = null, $dnu2 = null) { |
2263 |
|
$data = array('form' => &$form, 'maj' => &$maj, 'validation' => &$validation, 'idxformulaire' => &$idxformulaire, 'retourformulaire' => &$retourformulaire, 'typeformulaire' => &$typeformulaire); |
2264 |
|
$this->f->module_manager->run_hooks('setValsousformulaire_pre', $this, $data); |
2265 |
|
|
2266 |
// parent::setValsousformulaire($form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire); |
// parent::setValsousformulaire($form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire); |
2267 |
// |
// |
2268 |
$this->retourformulaire = $retourformulaire; |
$this->retourformulaire = $retourformulaire; |
2275 |
// Si l'instruction a été envoyé au contrôle de légalité et que la |
// Si l'instruction a été envoyé au contrôle de légalité et que la |
2276 |
// tâche envoi_cl lié n'a pas encore été traité il faut indiquer à |
// tâche envoi_cl lié n'a pas encore été traité il faut indiquer à |
2277 |
// l'utilisateur que l'envoi au cl est en cours de traitement. |
// l'utilisateur que l'envoi au cl est en cours de traitement. |
2278 |
if ($this->is_sent_to_cl() === true |
if ($this->is_sent_to_cl() === true |
2279 |
&& empty($this->getVal('date_envoi_controle_legalite')) |
&& empty($this->getVal('date_envoi_controle_legalite')) |
2280 |
&& $maj == 3) { |
&& $maj == 3) { |
2281 |
$form->setVal("date_envoi_controle_legalite", __("En cours de traitement.")); |
$form->setVal("date_envoi_controle_legalite", __("En cours de traitement.")); |
2282 |
} |
} |
2283 |
// |
// |
2284 |
$this->set_form_default_values($form, $maj, $validation); |
$this->set_form_default_values($form, $maj, $validation); |
2285 |
|
|
2286 |
|
$data = array('form' => &$form, 'maj' => &$maj, 'validation' => &$validation, 'idxformulaire' => &$idxformulaire, 'retourformulaire' => &$retourformulaire, 'typeformulaire' => &$typeformulaire); |
2287 |
|
$this->f->module_manager->run_hooks('setValsousformulaire_post', $this, $data); |
2288 |
} |
} |
2289 |
|
|
2290 |
/** |
/** |
2293 |
* @return void |
* @return void |
2294 |
*/ |
*/ |
2295 |
function set_form_default_values(&$form, $maj, $validation) { |
function set_form_default_values(&$form, $maj, $validation) { |
2296 |
// |
$data = array('form' => &$form, 'maj' => &$maj, 'validation' => &$validation); |
2297 |
|
$this->f->module_manager->run_hooks('set_form_default_values_pre', $this, $data); |
2298 |
|
|
2299 |
if ($maj == 0) { |
if ($maj == 0) { |
2300 |
// si contexte DI |
// si contexte DI |
2301 |
if ($this->getParameter("retourformulaire") == "dossier" |
if ($this->getParameter("retourformulaire") == "dossier" |
2302 |
|| $this->getParameter("retourformulaire") == "dossier_instruction" |
|| $this->f->contexte_dossier_instruction()) { |
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_encours" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_encours" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_clotures" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_clotures" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_mes_infractions" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_toutes_infractions" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_mes_recours" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_tous_recours") { |
|
2303 |
// on recupère les signataires de la multicollectivité et de celle du DI |
// on recupère les signataires de la multicollectivité et de celle du DI |
2304 |
$di = $this->f->get_inst__om_dbform(array( |
$di = $this->f->get_inst__om_dbform(array( |
2305 |
"obj" => "dossier_instruction", |
"obj" => "dossier_instruction", |
2313 |
} else { |
} else { |
2314 |
$sql = $this->get_var_sql_forminc__sql("signataire_arrete_defaut"); |
$sql = $this->get_var_sql_forminc__sql("signataire_arrete_defaut"); |
2315 |
} |
} |
2316 |
$res = $this->f->db->query($sql); |
|
2317 |
$this->f->addToLog(__METHOD__."(): db->query(\"".$sql."\")", VERBOSE_MODE); |
$qres = $this->f->get_all_results_from_db_query($sql, array( |
2318 |
$this->f->isDatabaseError($res); |
"origin" => __METHOD__)); |
2319 |
$row = $res->fetchrow(DB_FETCHMODE_ASSOC); |
$row = array_shift($qres['result']); |
2320 |
if (isset($row["signataire_arrete"]) |
if (isset($row["signataire_arrete"]) |
2321 |
&& is_numeric($row["signataire_arrete"])) { |
&& is_numeric($row["signataire_arrete"])) { |
2322 |
// |
// |
2333 |
$form->setVal("bible3", "bible(3)"); |
$form->setVal("bible3", "bible(3)"); |
2334 |
$form->setVal("bible4", "bible(4)"); |
$form->setVal("bible4", "bible(4)"); |
2335 |
} |
} |
2336 |
// |
// 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 ! |
2337 |
$collectivite_di = $this->get_dossier_instruction_om_collectivite(); |
$collectivite_di = $this->get_dossier_instruction_om_collectivite(); |
2338 |
if ($maj == 1 |
if ($maj == 1 |
2339 |
&& $this->f->is_option_preview_pdf_enabled($collectivite_di) === true |
&& $this->f->is_option_preview_pdf_enabled($collectivite_di) === true |
2365 |
if ($this->can_display_notification_commune()) { |
if ($this->can_display_notification_commune()) { |
2366 |
$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'))); |
2367 |
} |
} |
2368 |
|
if ($this->getVal('flag_edition_integrale') == 't') { |
2369 |
|
$message = __("Aucun contenu à afficher."); |
2370 |
|
if (empty($this->getVal('titre_om_htmletat'))) { |
2371 |
|
$form->setVal("titre_om_htmletat", $message); |
2372 |
|
} |
2373 |
|
if (empty($this->getVal('corps_om_htmletatex'))) { |
2374 |
|
$form->setVal("corps_om_htmletatex", $message); |
2375 |
|
} |
2376 |
|
} |
2377 |
} |
} |
2378 |
|
$data = array('form' => &$form, 'maj' => &$maj, 'validation' => &$validation); |
2379 |
|
$this->f->module_manager->run_hooks('set_form_default_values_post', $this, $data); |
2380 |
} |
} |
2381 |
|
|
2382 |
function setLayout(&$form, $maj){ |
function setLayout(&$form, $maj){ |
2383 |
// En consultation, pour les dossiers qui n'ont pas été transmis par le portail |
$data = array('form' => &$form, 'maj' => &$maj); |
2384 |
// citoyen, si la notification des demandeurs est activée sur l'évenement |
$this->f->module_manager->run_hooks('setLayout_pre', $this, $data); |
2385 |
// 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, on |
|
|
// vérifie si il y a des erreurs de paramétrage et si c'est le cas |
|
|
// on affiche un message d'information |
|
|
if ($this->dossier_depose_sur_portail() == null || |
|
|
! $this->dossier_depose_sur_portail()) { |
|
|
$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' |
|
|
); |
|
|
} |
|
|
} |
|
|
} |
|
2386 |
$form->setBloc('evenement','D',"","sousform-instruction-action-".$maj); |
$form->setBloc('evenement','D',"","sousform-instruction-action-".$maj); |
2387 |
|
|
2388 |
$form->setFieldset('evenement','D',_('Evenement')); |
$form->setFieldset('evenement','D',_('Evenement')); |
2389 |
$form->setFieldset('om_final_instruction_utilisateur','F',''); |
$form->setFieldset('om_final_instruction_utilisateur','F',''); |
2390 |
|
|
2391 |
$form->setBloc('om_final_instruction_utilisateur','F'); |
$form->setBloc('om_final_instruction_utilisateur','F'); |
2392 |
|
// Idem que pour le layout de la synthèse des DI, on est obligé de "casser" le setBloc en utilisant que la fin |
2393 |
|
// afin de bypasser le fait de ne pas avoir le form-content et le portlet dans le meme container |
2394 |
|
$form->setBloc('om_final_instruction_utilisateur','F'); |
2395 |
|
$form->setBloc('parapheur_lien_page_signature','D'); |
2396 |
|
|
2397 |
$form->setBloc('date_finalisation_courrier','D',"",""); |
$form->setBloc('date_finalisation_courrier','D',"",""); |
2398 |
|
|
2399 |
$form->setFieldset('date_finalisation_courrier','D',_('Dates')); |
$form->setFieldset('date_finalisation_courrier','D',_('Dates'),"instruction--suivi-dates"); |
2400 |
$form->setBloc('date_finalisation_courrier','D',"","col_6"); |
$form->setBloc('date_finalisation_courrier','D'); |
2401 |
$form->setBloc('date_envoi_controle_legalite','F'); |
$form->setBloc('date_envoi_rar','F'); |
2402 |
|
|
2403 |
$form->setBloc('date_retour_signature','D',"","col_6"); |
$form->setBloc('date_retour_rar','D'); |
2404 |
$form->setBloc('date_retour_controle_legalite','F'); |
$form->setBloc('date_retour_controle_legalite','F'); |
2405 |
$form->setFieldset('date_retour_controle_legalite','F',''); |
$form->setFieldset('date_retour_controle_legalite','F',''); |
2406 |
|
|
2481 |
$form->setFieldset('corps_om_htmletatex','DF',_('Corps')); |
$form->setFieldset('corps_om_htmletatex','DF',_('Corps')); |
2482 |
$form->setBloc('corps_om_htmletatex','F'); |
$form->setBloc('corps_om_htmletatex','F'); |
2483 |
} |
} |
2484 |
|
$data = array('form' => &$form, 'maj' => &$maj); |
2485 |
|
$this->f->module_manager->run_hooks('setLayout_post', $this, $data); |
2486 |
} |
} |
2487 |
|
|
2488 |
function setLib(&$form, $maj) { |
function setLib(&$form, $maj) { |
2489 |
|
$data = array('form' => &$form, 'maj' => &$maj); |
2490 |
|
$this->f->module_manager->run_hooks('setLib_pre', $this, $data); |
2491 |
// |
// |
2492 |
parent::setLib($form, $maj); |
parent::setLib($form, $maj); |
2493 |
// |
// |
2500 |
$form->setLib('btn_preview', ""); |
$form->setLib('btn_preview', ""); |
2501 |
$form->setLib('btn_redaction', ""); |
$form->setLib('btn_redaction', ""); |
2502 |
$form->setLib('live_preview', ""); |
$form->setLib('live_preview', ""); |
2503 |
$form->setLib('om_final_instruction_utilisateur', _("finalise par")); |
$form->setLib('om_final_instruction_utilisateur', __("finalise par")); |
2504 |
$form->setLib('date_envoi_rar', __("date_envoi_ar")); |
$form->setLib('date_envoi_rar', __("date_envoi_ar")); |
2505 |
$form->setLib('date_retour_rar', __("date_notification")); |
$form->setLib('date_retour_rar', __("date_notification")); |
2506 |
$form->setLib('statut_signature', __("statut")); |
$form->setLib('statut_signature', __("statut")); |
2511 |
$form->setLib('suivi_notification_tiers', ''); |
$form->setLib('suivi_notification_tiers', ''); |
2512 |
$form->setLib('suivi_notification_commune', ''); |
$form->setLib('suivi_notification_commune', ''); |
2513 |
$form->setLib('preview_edition', ""); |
$form->setLib('preview_edition', ""); |
2514 |
|
$form->setLib('document_type_instruction', __("Type de document")); |
2515 |
|
|
2516 |
// Ajout d'une infobulle d'aide lorsque le formulaire est en mode |
// Ajout d'une infobulle d'aide lorsque le formulaire est en mode |
2517 |
// ajout et que l'option de rédaction libre est activée sur la |
// ajout et que l'option de rédaction libre est activée sur la |
2519 |
if ($maj === '0' && $this->is_option_redaction_libre_enabled() === true) { |
if ($maj === '0' && $this->is_option_redaction_libre_enabled() === true) { |
2520 |
// |
// |
2521 |
$help_text_template = '%s <span class="info-16" title="%s"></span>'; |
$help_text_template = '%s <span class="info-16" title="%s"></span>'; |
2522 |
$help_text = _("Attention: le passage du mode 'Rédaction libre' à celui de 'Rédaction par compléments' fait perdre toute la rédaction manuelle effectuée."); |
$help_text = __("Attention: le passage du mode 'Rédaction libre' à celui de 'Rédaction par compléments' fait perdre toute la rédaction manuelle effectuée."); |
2523 |
$form->setLib('flag_edition_integrale', sprintf($help_text_template, _("Type de rédaction"), $help_text)); |
$form->setLib('flag_edition_integrale', sprintf($help_text_template, __("Type de rédaction"), $help_text)); |
2524 |
} |
} |
2525 |
else { |
else { |
2526 |
$form->setLib('flag_edition_integrale', _("Type de rédaction")); |
$form->setLib('flag_edition_integrale', __("Type de rédaction")); |
2527 |
} |
} |
2528 |
|
|
2529 |
// Ajout d'une infobulle d'aide lorsque le formulaire est en mode |
// Ajout d'une infobulle d'aide lorsque le formulaire est en mode |
2533 |
&& $this->f->is_option_preview_pdf_enabled($this->get_dossier_instruction_om_collectivite()) === true) { |
&& $this->f->is_option_preview_pdf_enabled($this->get_dossier_instruction_om_collectivite()) === true) { |
2534 |
// |
// |
2535 |
$help_text_template = '%s <span class="info-16" title="%s"></span>'; |
$help_text_template = '%s <span class="info-16" title="%s"></span>'; |
2536 |
$help_text = _("Attention la modification de la valeur de ce champ n'est pas prise en compte dans la prévisualisation. Pour que cette valeur soit mise à jour, il suffit de valider le formulaire."); |
$help_text = __("Attention la modification de la valeur de ce champ n'est pas prise en compte dans la prévisualisation. Pour que cette valeur soit mise à jour, il suffit de valider le formulaire."); |
2537 |
$form->setLib('date_evenement', sprintf($help_text_template, _('date_evenement'), $help_text)); |
$form->setLib('date_evenement', sprintf($help_text_template, __('date_evenement'), $help_text)); |
2538 |
$form->setLib('signataire_arrete', sprintf($help_text_template, _('signataire_arrete'), $help_text)); |
$form->setLib('signataire_arrete', sprintf($help_text_template, __('signataire_arrete'), $help_text)); |
2539 |
|
} |
2540 |
|
$data = array('form' => &$form, 'maj' => &$maj); |
2541 |
|
$this->f->module_manager->run_hooks('setLib_post', $this, $data); |
2542 |
|
} |
2543 |
|
|
2544 |
|
/** |
2545 |
|
* Surcharge om_dbform::set_form_specificity() |
2546 |
|
* |
2547 |
|
* Traitements spécifiques lié à l'affichage des formulaires. |
2548 |
|
* Les traitements gérés ici sont les suivants : |
2549 |
|
* - Affichage d'un message d'erreur si la lettretype de l'évènement n'a pas |
2550 |
|
* pu être récupérée. |
2551 |
|
* - Affichage d'un message d'information à l'attention de l'utilisateur si |
2552 |
|
* la notification est activée mais qu'elle n'est pas possible à cause du |
2553 |
|
* paramètrage. |
2554 |
|
* |
2555 |
|
* @param formulaire $form Instance formulaire. |
2556 |
|
* @param string $maj |
2557 |
|
* |
2558 |
|
* @return void |
2559 |
|
*/ |
2560 |
|
function set_form_specificity(&$form, $maj) { |
2561 |
|
parent::set_form_specificity($form, $maj); |
2562 |
|
|
2563 |
|
// En consultation, vérifie si une lettretype est associée à l'instruction et a pu être récupérée. |
2564 |
|
// Si ce n'est pas le cas affiche un message d'erreur. |
2565 |
|
if ((! empty($maj) && $maj == 3)) { |
2566 |
|
if (! empty($this->getVal('lettretype'))) { |
2567 |
|
|
2568 |
|
$om_edition = $this->f->get_inst__om_edition(); |
2569 |
|
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
2570 |
|
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
2571 |
|
$edition = $om_edition->get_edition_from_collectivite('om_lettretype', $this->getVal("lettretype"), $collectivite['om_collectivite_idx']); |
2572 |
|
|
2573 |
|
if (empty($edition)) { |
2574 |
|
$this->display_error_message(__("Erreur de paramétrage, le modèle de document n'a pas pu être récupéré. Contactez votre administrateur.")); |
2575 |
|
} |
2576 |
|
} |
2577 |
|
} |
2578 |
|
|
2579 |
|
$this->display_notification_info($maj); |
2580 |
|
} |
2581 |
|
|
2582 |
|
/** |
2583 |
|
* En consultation, pour les dossiers qui n'ont pas été transmis par le portail |
2584 |
|
* citoyen, si la notification des demandeurs est activée sur l'évenement |
2585 |
|
* d'instruction et que le paramétrage du demandeur principal n'est pas |
2586 |
|
* correct alors un message a destination de l'instructeur est affiché. |
2587 |
|
* |
2588 |
|
* @param string $maj |
2589 |
|
* |
2590 |
|
* @return void |
2591 |
|
*/ |
2592 |
|
public function display_notification_info($maj) { |
2593 |
|
if ((! empty($maj) && $maj == 3)) { |
2594 |
|
// Si le dossier n'a pas été déposé sur le portail citoyen (ou si |
2595 |
|
// la requête permettant de savoir le type de demande à échouée) et si |
2596 |
|
// la notification se fait par mail vérifie si il y a des erreurs de |
2597 |
|
// paramétrage et si c'est le cas on affiche un message d'information |
2598 |
|
if ($this->dossier_depose_sur_portail() == null || ! $this->dossier_depose_sur_portail()) { |
2599 |
|
$erreurParam = $this->get_info_notification_fail(); |
2600 |
|
// Récupération de l'évenement d'instruction |
2601 |
|
$instEV = $this->get_inst_evenement(); |
2602 |
|
if (! empty($instEV->getVal('notification')) && $erreurParam != array()) { |
2603 |
|
$class = 'text-info ui-state-highlight ui-state-info'; |
2604 |
|
$message = __("La notification n'est pas possible."); |
2605 |
|
$this->f->display_panel_information( |
2606 |
|
$class, |
2607 |
|
$message, |
2608 |
|
$erreurParam, |
2609 |
|
__('Les données suivantes doivent être modifiées'), |
2610 |
|
'erreur_param_notif' |
2611 |
|
); |
2612 |
|
} |
2613 |
|
} |
2614 |
} |
} |
2615 |
} |
} |
2616 |
|
|
2617 |
/** |
/** |
2618 |
|
* Méthode permettant d'afficher des messages d'erreur sur les formulaires. |
2619 |
|
*/ |
2620 |
|
public function display_error_message($msg) { |
2621 |
|
$this->correct = false; |
2622 |
|
$this->msg = $msg; |
2623 |
|
} |
2624 |
|
|
2625 |
|
/** |
2626 |
* TRIGGER - triggerajouter. |
* TRIGGER - triggerajouter. |
2627 |
|
* Réalise différents traitements avant d'ajouter l'instruction en base. |
2628 |
|
* |
2629 |
|
* Les traitements réalisés sont les suivant : |
2630 |
|
* - TODO : documenter les traietements existant |
2631 |
|
* - Intégre les bibles pré-chargé aux compléments de l'instruction. |
2632 |
|
* Ce traitement n'est déclenché que si l'on est pas en rédaction libre, et que l'évènement a une lettretype. |
2633 |
* |
* |
2634 |
* @return boolean |
* @return boolean |
2635 |
*/ |
*/ |
2636 |
function triggerajouter($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
function triggerajouter($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
2637 |
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
2638 |
|
$parent_res = parent::triggerajouter($id, $dnu1, $val); |
2639 |
|
if ($parent_res === false) return $parent_res; |
2640 |
|
|
2641 |
|
$data = array('val' => &$val, 'id' => $id, 'parent_res' => &$parent_res); |
2642 |
|
$this->f->module_manager->run_hooks('triggerajouter_override_pre', $this, $data); |
2643 |
/** |
/** |
2644 |
* 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 |
2645 |
* et dossier pour les stocker dans l'instruction : |
* et dossier pour les stocker dans l'instruction : |
2675 |
* - avis_decision |
* - avis_decision |
2676 |
*/ |
*/ |
2677 |
// 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é |
2678 |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
$evenement = $this->f->get_inst__om_dbform(array( |
2679 |
WHERE evenement=".$this->valF['evenement']; |
"obj" => "evenement", |
2680 |
$res = $this->f->db->query($sql); |
"idx" => intval($this->valF['evenement']), |
2681 |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
)); |
2682 |
if (database::isError($res)) { |
if ($evenement->exists() === true) { |
|
die($res->getMessage()); |
|
|
} |
|
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
|
2683 |
// Récupération de l'identifiant de l'action |
// Récupération de l'identifiant de l'action |
2684 |
// si une action est paramétrée dans l'événement |
// si une action est paramétrée dans l'événement |
2685 |
$this->valF['action'] = NULL; |
$this->valF['action'] = NULL; |
2686 |
if (isset($row['action']) and !empty($row['action'])) { |
if (!empty($evenement->getVal('action'))) { |
2687 |
$this->valF['action']=$row['action']; |
$this->valF['action']=$evenement->getVal('action'); |
2688 |
} |
} |
2689 |
// Récupération de la valeur du délai |
// Récupération de la valeur du délai |
2690 |
$this->valF['delai'] = $row['delai']; |
$this->valF['delai'] = $evenement->getVal('delai'); |
2691 |
// Récupération de l'identifiant de l'état |
// Récupération de l'identifiant de l'état |
2692 |
// si un état est paramétré dans l'événement |
// si un état est paramétré dans l'événement |
2693 |
$this->valF['etat']=NULL; |
$this->valF['etat']=NULL; |
2694 |
if (isset($row['etat']) and !empty($row['etat'])) { |
if (!empty($evenement->getVal('etat'))) { |
2695 |
$this->valF['etat']=$row['etat']; |
$this->valF['etat']=$evenement->getVal('etat'); |
2696 |
} |
} |
2697 |
// Récupération de la valeur d'accord tacite |
// Récupération de la valeur d'accord tacite |
2698 |
$this->valF['accord_tacite']=$row['accord_tacite']; |
$this->valF['accord_tacite']=$evenement->getVal('accord_tacite'); |
2699 |
// Récupération de la valeur du délai de notification |
// Récupération de la valeur du délai de notification |
2700 |
$this->valF['delai_notification']=$row['delai_notification']; |
$this->valF['delai_notification']=$evenement->getVal('delai_notification'); |
2701 |
// Récupération de l'identifiant de l'avis |
// Récupération de l'identifiant de l'avis |
2702 |
// si un avis est paramétré dans l'événement |
// si un avis est paramétré dans l'événement |
2703 |
$this->valF['avis_decision'] = NULL; |
$this->valF['avis_decision'] = NULL; |
2704 |
if(isset($row['avis_decision']) and !empty($row['avis_decision'])) { |
if(!empty($evenement->getVal('avis_decision'))) { |
2705 |
$this->valF['avis_decision']=$row['avis_decision']; |
$this->valF['avis_decision']=$evenement->getVal('avis_decision'); |
2706 |
} |
} |
2707 |
// Récupération de la valeur de l'autorité compétente |
// Récupération de la valeur de l'autorité compétente |
2708 |
// si l'autorité compétente est paramétré dans l'événement |
// si l'autorité compétente est paramétré dans l'événement |
2709 |
$this->valF['autorite_competente'] = NULL; |
$this->valF['autorite_competente'] = NULL; |
2710 |
if(isset($row['autorite_competente']) and !empty($row['autorite_competente'])) { |
if(!empty($evenement->getVal('autorite_competente'))) { |
2711 |
$this->valF['autorite_competente']=$row['autorite_competente']; |
$this->valF['autorite_competente']=$evenement->getVal('autorite_competente'); |
2712 |
} |
} |
2713 |
// Récupération de la valeur de la lettre type |
// Récupération de la valeur de la lettre type |
2714 |
$this->valF['lettretype']=$row['lettretype']; |
$this->valF['lettretype']=$evenement->getVal('lettretype'); |
2715 |
|
|
2716 |
|
// Récupération de la valeur du document_type |
2717 |
|
if(!empty($evenement->getVal('document_type'))){ |
2718 |
|
$this->valF['document_type_instruction']= $evenement->getVal('document_type'); |
2719 |
|
} |
2720 |
// Récupération de la valeur de la prise en compte métier |
// Récupération de la valeur de la prise en compte métier |
2721 |
// si la prise en compte métier est paramétrée dans l'événement |
// si la prise en compte métier est paramétrée dans l'événement |
2722 |
$this->valF['pec_metier'] = NULL; |
$this->valF['pec_metier'] = NULL; |
2723 |
if(isset($row['pec_metier']) === true and empty($row['pec_metier']) === false) { |
if(!empty($evenement->getVal('pec_metier'))) { |
2724 |
$this->valF['pec_metier'] = $row['pec_metier']; |
$this->valF['pec_metier'] = $evenement->getVal('pec_metier'); |
2725 |
} |
} |
2726 |
} |
} |
2727 |
// 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 |
2728 |
$sql = "SELECT * FROM ".DB_PREFIXE."dossier |
// TODO : remplacer cette requête par l'instanciation de l'objet |
2729 |
WHERE dossier='".$this->valF['dossier']."'"; |
$qres = $this->f->get_all_results_from_db_query( |
2730 |
$res = $this->f->db->query($sql); |
sprintf( |
2731 |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
'SELECT |
2732 |
if (database::isError($res)) { |
* |
2733 |
die($res->getMessage()); |
FROM |
2734 |
} |
%1$sdossier |
2735 |
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
WHERE |
2736 |
|
dossier = \'%2$s\'', |
2737 |
|
DB_PREFIXE, |
2738 |
|
$this->f->db->escapeSimple($this->valF['dossier']) |
2739 |
|
), |
2740 |
|
array( |
2741 |
|
"origin" => __METHOD__, |
2742 |
|
) |
2743 |
|
); |
2744 |
|
$row = array_shift($qres['result']); |
2745 |
$this->updateArchiveData($row); |
$this->updateArchiveData($row); |
2746 |
|
|
2747 |
// Récupération de la duree de validite du dossier d'autorisation |
// Récupération de la duree de validite du dossier d'autorisation |
2748 |
$sql = "SELECT duree_validite_parametrage |
$qres = $this->f->get_one_result_from_db_query( |
2749 |
FROM ".DB_PREFIXE."dossier_autorisation_type_detaille |
sprintf( |
2750 |
LEFT JOIN ".DB_PREFIXE."dossier_autorisation |
'SELECT |
2751 |
ON dossier_autorisation.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
duree_validite_parametrage |
2752 |
LEFT JOIN ".DB_PREFIXE."dossier |
FROM |
2753 |
ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
%1$sdossier_autorisation_type_detaille |
2754 |
WHERE dossier.dossier='".$this->valF['dossier']."'"; |
LEFT JOIN %1$sdossier_autorisation |
2755 |
$duree_validite_parametrage = $this->f->db->getOne($sql); |
ON dossier_autorisation.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
2756 |
$this->addToLog(__METHOD__."(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
LEFT JOIN %1$sdossier |
2757 |
database::isError($duree_validite_parametrage); |
ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
2758 |
if ($duree_validite_parametrage != '') { |
WHERE |
2759 |
$this->valF['duree_validite_parametrage']= $duree_validite_parametrage; |
dossier.dossier = \'%2$s\'', |
2760 |
|
DB_PREFIXE, |
2761 |
|
$this->f->db->escapeSimple($this->valF['dossier']) |
2762 |
|
), |
2763 |
|
array( |
2764 |
|
"origin" => __METHOD__, |
2765 |
|
) |
2766 |
|
); |
2767 |
|
|
2768 |
|
if ($qres['result'] != '') { |
2769 |
|
$this->valF['duree_validite_parametrage'] = $qres['result']; |
2770 |
} |
} |
2771 |
|
|
2772 |
// Identifiant du type de courrier |
// Identifiant du type de courrier |
2774 |
$idCourrier = str_pad($this->valF["instruction"], 10, "0", STR_PAD_LEFT); |
$idCourrier = str_pad($this->valF["instruction"], 10, "0", STR_PAD_LEFT); |
2775 |
// Code barres |
// Code barres |
2776 |
$this->valF["code_barres"] = $idTypeCourrier . $idCourrier; |
$this->valF["code_barres"] = $idTypeCourrier . $idCourrier; |
2777 |
|
|
2778 |
|
// Set dans la propriété valF les valeurs des compléments pour qu'ils soient enregistrés |
2779 |
|
// à l'ajout de l'instruction. |
2780 |
|
// Le traitement n'est réalisé que si il y a une lettretype et qu'on est pas en rédaction libre |
2781 |
|
if (! empty($this->valF['lettretype'])) { |
2782 |
|
$this->set_precharge_complement($this->valF['evenement'], $this->valF['dossier']); |
2783 |
|
} |
2784 |
|
|
2785 |
|
$res = true; |
2786 |
|
$data = array('val' => &$val, 'id' => $id, 'result' => &$res); |
2787 |
|
$this->f->module_manager->run_hooks('triggerajouter_override_post', $this, $data); |
2788 |
|
return $res; |
2789 |
|
} |
2790 |
|
|
2791 |
|
/** |
2792 |
|
* Récupère pour chaque champ complementX_om_html le complément correspondant |
2793 |
|
* et set l'entrée correspondante de valF avec. |
2794 |
|
* |
2795 |
|
* Problème potentiel : Le nombre de complément se base sur le champs complement ayant |
2796 |
|
* l'indice le plus grand visible dans get_var_sql_forminc__champs(). |
2797 |
|
* Dans cette fonction on fait donc 15 itérations. Changer le nombre de complément |
2798 |
|
* aura donc un impact sur cette méthode. |
2799 |
|
* |
2800 |
|
* @param string dossier : identifiant du dossier de l'instruction |
2801 |
|
* @param int evenement : identifiant de l'évènement d'instruction |
2802 |
|
* |
2803 |
|
* @return void |
2804 |
|
*/ |
2805 |
|
public function set_precharge_complement($evenement, $dossier) { |
2806 |
|
// Récupération des bibles et chargement dans les compléments |
2807 |
|
for ($i = 1; $i <= 15; $i++) { |
2808 |
|
// Constitution de l'id du champs. |
2809 |
|
// Pour l'indice 1, l'id est complement_om_html, l'indice n'est pas visible dans ce cas. |
2810 |
|
$field = "complement".($i === 1 ? '' : $i)."_om_html"; |
2811 |
|
// Récupération des compléments correspondant en fonction de l'évènement |
2812 |
|
// et du dossier puis insertion dans la champs voulu |
2813 |
|
$this->valF[$field] = $this->getBible($evenement, $dossier, $i, 'precharge'); |
2814 |
|
} |
2815 |
} |
} |
2816 |
|
|
2817 |
|
|
2818 |
|
|
2819 |
/** |
/** |
2820 |
* Test si une restriction est valide. |
* Test si une restriction est valide. |
2905 |
$res[] = $this->getRestrictionValue($value); |
$res[] = $this->getRestrictionValue($value); |
2906 |
} else { |
} else { |
2907 |
// Message d'erreur |
// Message d'erreur |
2908 |
$error_message = sprintf(_("Le champ %s de l'instruction %s est vide"), "<span class='bold'>".$value."</span>", "<span class='bold'>".$this->valF["instruction"]."</span>"); |
$error_message = sprintf(__("Le champ %s de l'instruction %s est vide"), "<span class='bold'>".$value."</span>", "<span class='bold'>".$this->valF["instruction"]."</span>"); |
2909 |
$this->addToMessage($error_message); |
$this->addToMessage($error_message); |
2910 |
// Arrête le traitement |
// Arrête le traitement |
2911 |
return false; |
return false; |
2981 |
} else { |
} else { |
2982 |
|
|
2983 |
// Message d'erreur |
// Message d'erreur |
2984 |
$error_message = _("Mauvais parametrage de la restriction.")." ". |
$error_message = __("Mauvais parametrage de la restriction.")." ". |
2985 |
_("Contactez votre administrateur"); |
__("Contactez votre administrateur"); |
2986 |
$this->addToMessage($error_message); |
$this->addToMessage($error_message); |
2987 |
// Arrête le traitement |
// Arrête le traitement |
2988 |
return false; |
return false; |
3002 |
if(empty($evenement) || !is_numeric($evenement)) { |
if(empty($evenement) || !is_numeric($evenement)) { |
3003 |
return ""; |
return ""; |
3004 |
} |
} |
3005 |
$sql = "SELECT retour |
|
3006 |
FROM ".DB_PREFIXE."evenement |
$evenement = $this->f->get_inst__om_dbform(array( |
3007 |
WHERE evenement = ".$evenement; |
"obj" => "evenement", |
3008 |
$retour = $this->f->db->getOne($sql); |
"idx" => $evenement, |
3009 |
$this->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE); |
)); |
3010 |
if (database::isError($retour)) { |
|
3011 |
die($retour->getMessage()); |
return $evenement->getVal('retour') == 't'; |
|
} |
|
|
if ($retour == 't') { |
|
|
return true; |
|
|
} else { |
|
|
return false; |
|
|
} |
|
3012 |
} |
} |
3013 |
|
|
3014 |
/** |
/** |
3023 |
return ""; |
return ""; |
3024 |
} |
} |
3025 |
//Récupère la restriction |
//Récupère la restriction |
3026 |
$sql= "SELECT |
$evenement = $this->f->get_inst__om_dbform(array( |
3027 |
restriction |
"obj" => "evenement", |
3028 |
FROM |
"idx" => $evenement, |
3029 |
".DB_PREFIXE."evenement |
)); |
3030 |
WHERE |
|
3031 |
evenement =".$evenement; |
return $evenement->getVal('restriction'); |
|
|
|
|
$restriction = $this->f->db->getOne($sql); |
|
|
$this->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE); |
|
|
if (database::isError($restriction)) { |
|
|
die($restriction->getMessage()); |
|
|
} |
|
|
return $restriction; |
|
3032 |
} |
} |
3033 |
|
|
3034 |
/** |
/** |
3059 |
|
|
3060 |
|
|
3061 |
/** |
/** |
3062 |
|
* Calcul une regle à partir des données de l'url et affiche son |
3063 |
|
* résultat au format json |
3064 |
|
*/ |
3065 |
|
public function is_date_limite_notification_dossier_depasse($contexte_notification_manuelle = False) { |
3066 |
|
// Récupération de la date limite |
3067 |
|
$dossier = $this->f->get_inst__om_dbform(array( |
3068 |
|
'obj' => 'dossier', |
3069 |
|
'idx' => $this->getVal('dossier') |
3070 |
|
)); |
3071 |
|
$date_limite = $dossier->getVal('incomplet_notifie') !== 't' ? |
3072 |
|
$dossier->getVal('date_limite') : |
3073 |
|
$dossier->getVal('date_limite_incompletude'); |
3074 |
|
// Ajout d'un jour à la date limite (reglementaire lors de la notification |
3075 |
|
// par demat) |
3076 |
|
$date_limite = $this->f->mois_date($date_limite, "1", "+", "jour"); |
3077 |
|
// Compare la date limite à j+1 et la date du jour |
3078 |
|
// La date du jour est récupérée via la fonction date pour pouvoir comparer |
3079 |
|
// des timestamps de début de journée |
3080 |
|
if ($contexte_notification_manuelle === True) return strtotime($date_limite) < strtotime(date("Y-m-d")) ? True : False; |
3081 |
|
echo strtotime($date_limite) < strtotime(date("Y-m-d")) ? 'True' : 'False'; |
3082 |
|
} |
3083 |
|
|
3084 |
|
/** |
3085 |
|
* Vérifie si le type d'événement en cours fait partie des types autorisés en paramètres. |
3086 |
|
* |
3087 |
|
* @param object $ev Instance de l'événement associé à l'instruction |
3088 |
|
* @param array $params Types d'événements autorisés |
3089 |
|
* @return boolean |
3090 |
|
*/ |
3091 |
|
public function is_type_evenement_autorise($ev, $params = array()) { |
3092 |
|
$type_evenement = $ev->getVal('type'); |
3093 |
|
if (isset($params["types_evenements_autorises"]) |
3094 |
|
&& ! empty($params["types_evenements_autorises"]) |
3095 |
|
&& in_array($type_evenement, $params["types_evenements_autorises"], true) === true) { |
3096 |
|
return true; |
3097 |
|
} |
3098 |
|
return false; |
3099 |
|
} |
3100 |
|
|
3101 |
|
/** |
3102 |
|
* Vérifie si la date limite de notification au demandeur est dépassée. |
3103 |
|
* |
3104 |
|
* @param boolean $add_one_day Active ou non l'ajout d'un jour à la DLN |
3105 |
|
* @return boolean |
3106 |
|
*/ |
3107 |
|
public function is_date_limite_notification_premier_mois_depasee($add_one_day = false) { |
3108 |
|
$dln = $this->getVal('archive_date_notification_delai'); |
3109 |
|
if ($dln === '' |
3110 |
|
|| $dln === null) { |
3111 |
|
// |
3112 |
|
$dossier = $this->f->get_inst__om_dbform(array( |
3113 |
|
'obj' => 'dossier', |
3114 |
|
'idx' => $this->getVal('dossier') |
3115 |
|
)); |
3116 |
|
$dln = $dossier->getVal('date_notification_delai'); |
3117 |
|
} |
3118 |
|
if ($dln === '' |
3119 |
|
|| $dln === null) { |
3120 |
|
// |
3121 |
|
return false; |
3122 |
|
} |
3123 |
|
// Ajout d'un jour à la date limite de notification |
3124 |
|
if ($add_one_day === true) { |
3125 |
|
$dln = $this->f->mois_date($dln, "1", "+", "jour"); |
3126 |
|
} |
3127 |
|
// Compare la date limite de notification et la date du jour |
3128 |
|
return strtotime($dln) <= strtotime(date("Y-m-d")); |
3129 |
|
} |
3130 |
|
|
3131 |
|
/** |
3132 |
* Calcul des règle d'action selon leur type. |
* Calcul des règle d'action selon leur type. |
3133 |
* |
* |
3134 |
* Types de règle : |
* Types de règle : |
3149 |
|
|
3150 |
// Supprime tous les espaces de la chaîne de caractère |
// Supprime tous les espaces de la chaîne de caractère |
3151 |
$rule = str_replace(' ', '', $rule); |
$rule = str_replace(' ', '', $rule); |
3152 |
|
// On force les minuscules |
3153 |
|
$rule = strtolower($rule); |
3154 |
// Coupe la chaîne au niveau de l'opérateur |
// Coupe la chaîne au niveau de l'opérateur |
3155 |
$operands = explode ("+", $rule); |
$operands = explode ("+", $rule); |
3156 |
// Nombre d'opérande |
// Nombre d'opérande |
3182 |
"regle_date_ait", |
"regle_date_ait", |
3183 |
"regle_date_transmission_parquet", |
"regle_date_transmission_parquet", |
3184 |
"regle_date_affichage", |
"regle_date_affichage", |
3185 |
|
"duree_validite", |
3186 |
|
"duree_validite_parametrage", |
3187 |
); |
); |
3188 |
// Tableau des champs de type numérique |
// Tableau des champs de type numérique |
3189 |
$rule_type_numeric = array( |
$rule_type_numeric = array( |
3190 |
|
); |
3191 |
|
// Tableau des champs de type text |
3192 |
|
$rule_type_time_delai = array( |
3193 |
"regle_delai", |
"regle_delai", |
3194 |
"regle_delai_incompletude", |
"regle_delai_incompletude", |
3195 |
); |
); |
3242 |
$type = "specific"; |
$type = "specific"; |
3243 |
} |
} |
3244 |
if (in_array($rule_name, $rule_type_technical_data) === true) { |
if (in_array($rule_name, $rule_type_technical_data) === true) { |
3245 |
$type = 'text'; |
$type = 'technical_text'; |
3246 |
} |
} |
3247 |
if (in_array($rule_name, $rule_type_simple) === true) { |
if (in_array($rule_name, $rule_type_simple) === true) { |
3248 |
$type = 'simple'; |
$type = 'simple'; |
3249 |
} |
} |
3250 |
|
if (in_array($rule_name, $rule_type_time_delai) === true) { |
3251 |
|
$type = "time_delai"; |
3252 |
|
} |
3253 |
|
|
3254 |
// 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 |
3255 |
// Récupère directement la valeur de l'opérande |
// Récupère directement la valeur de l'opérande |
3259 |
} |
} |
3260 |
|
|
3261 |
// Initialisation des variables |
// Initialisation des variables |
|
$key_date = 0; |
|
3262 |
$total_numeric = 0; |
$total_numeric = 0; |
3263 |
$res_text = ''; |
$res_text = ''; |
3264 |
|
$final_date = null; |
3265 |
|
|
3266 |
// Pour chaque opérande |
// Pour chaque opérande |
3267 |
foreach ($operands as $key => $operand) { |
foreach ($operands as $key => $operand) { |
|
|
|
3268 |
// Si c'est une règle de type date |
// Si c'est une règle de type date |
3269 |
if ($type == 'date') { |
if ($type == 'date') { |
3270 |
// Vérifie si au moins une des opérandes est une date |
if (is_numeric($operand) === false){ |
3271 |
if (is_numeric($operand) === false |
$rule_value = $this->get_value_for_rule($operand); |
3272 |
&& $this->get_value_for_rule($operand) !== null |
if ( |
3273 |
&& $this->f->check_date($this->get_value_for_rule($operand)) == true) { |
$rule_value !== null |
3274 |
// Récupère la position de la date |
&& ( |
3275 |
$key_date = $key; |
strpos($operand, 'mois') !== false |
3276 |
|
|| strpos($operand, 'jour') !== false |
3277 |
|
) |
3278 |
|
){ |
3279 |
|
$rule_value = $operand; |
3280 |
|
} |
3281 |
|
if ($rule_value !== null){ |
3282 |
|
// Vérifie si l'opérande est une date |
3283 |
|
if ($this->f->check_date($rule_value) == true) { |
3284 |
|
// Affecte la date |
3285 |
|
$final_date = $rule_value; |
3286 |
|
}else{ |
3287 |
|
// Gère les opérandes |
3288 |
|
preg_match_all('/(\d+) *([a-zA-Z]*)/', $rule_value, $matches, PREG_OFFSET_CAPTURE); |
3289 |
|
|
3290 |
|
// Ajoute l'opérande au total |
3291 |
|
foreach ($matches[1] as $matche_key => $matche_value) { |
3292 |
|
$timelength = $matches[1][$matche_key][0]; |
3293 |
|
$timetype = 'mois'; |
3294 |
|
if ( $matches[2][$matche_key][0] != ''){ |
3295 |
|
$timetype = $matches[2][$matche_key][0]; |
3296 |
|
} |
3297 |
|
// Ajout au calcul de la date |
3298 |
|
$final_date = $this->f->mois_date( |
3299 |
|
$final_date, |
3300 |
|
$timelength, |
3301 |
|
"+", |
3302 |
|
$timetype |
3303 |
|
); |
3304 |
|
} |
3305 |
|
} |
3306 |
|
} |
3307 |
} |
} |
3308 |
// Les autres opérandes doivent être que des numériques |
// Les autres opérandes doivent être que des numériques |
3309 |
if (is_numeric($operand) == true) { |
if (is_numeric($operand) == true) { |
3310 |
// Ajoute l'opérande au total |
// Ajoute l'opérande au total |
3311 |
$total_numeric += $operand; |
// Ajout au calcul de la date |
3312 |
} |
$final_date = $this->f->mois_date($final_date, |
3313 |
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); |
|
3314 |
} |
} |
3315 |
} |
} |
3316 |
|
|
3330 |
} |
} |
3331 |
|
|
3332 |
// Si c'est une règle de type text |
// Si c'est une règle de type text |
3333 |
if ($type === 'text') { |
if ($type === 'text' || $type === 'technical_text') { |
3334 |
// Concatène toutes les chaînes de caractère |
// Concatène toutes les chaînes de caractère |
3335 |
$res_text .= $this->get_value_for_rule($operand); |
$res_text .= $this->get_value_for_rule($operand); |
3336 |
} |
} |
3337 |
|
|
3338 |
|
// Si c'est une règle de type time_delai |
3339 |
|
if ($type === 'time_delai') { |
3340 |
|
$rule_value = $this->get_value_for_rule($operand); |
3341 |
|
if ( strlen($res_text) != 0) { |
3342 |
|
$res_text .= "+"; |
3343 |
|
} |
3344 |
|
if ($rule_value != null && $rule_value != ''){ |
3345 |
|
// Supprime tous les espaces de la chaîne de caractère |
3346 |
|
// Concatène toutes les chaînes de caractère |
3347 |
|
$res_text .= $rule_value; |
3348 |
|
} else { |
3349 |
|
$res_text .= $operand; |
3350 |
|
} |
3351 |
|
} |
3352 |
|
|
3353 |
} |
} |
3354 |
|
|
3355 |
// Résultat pour une règle de type date |
// Résultat pour une règle de type date |
3356 |
if ($type == 'date') { |
if ($type == 'date') { |
3357 |
// Retourne le calcul de la date |
// Retourne la date |
3358 |
return $this->f->mois_date($this->valF[$operands[$key_date]], |
return $final_date; |
|
$total_numeric, "+"); |
|
3359 |
} |
} |
3360 |
|
|
3361 |
// Résultat pour une règle de type numérique |
// Résultat pour une règle de type numérique |
3365 |
} |
} |
3366 |
|
|
3367 |
// Résultat pour une règle de type text |
// Résultat pour une règle de type text |
3368 |
if ($type === 'text') { |
if (in_array($type, array('text', 'technical_text')) === true) { |
3369 |
// Retourne la chaîne de caractère |
// Retourne la chaîne de caractère |
3370 |
return $res_text; |
return $res_text; |
3371 |
} |
} |
3372 |
|
|
3373 |
|
// Résultat pour une règle de type text |
3374 |
|
if (in_array($type, array('time_delai')) === true) { |
3375 |
|
// Traitement de la valeur à afficher |
3376 |
|
$res_text = str_replace(' ', '', $res_text); |
3377 |
|
$res_text = preg_replace('/(\d+)/', '$1 ', $res_text); |
3378 |
|
$res_text = preg_replace('/(\+)/', ' $1 ', $res_text); |
3379 |
|
$res_text = trim(preg_replace('/\s\s+/', ' ', strtolower($res_text))); |
3380 |
|
return $res_text; |
3381 |
|
} |
3382 |
|
|
3383 |
if ($type === 'simple' || $type === 'bool') { |
if ($type === 'simple' || $type === 'bool') { |
3384 |
// Retourne la valeur du champs rule |
// Retourne la valeur du champs rule |
3385 |
return $rule; |
return $rule; |
3411 |
|
|
3412 |
|
|
3413 |
/** |
/** |
3414 |
|
* Cette méthode permet de générer le nom de fichier lors de la génération du PDF |
3415 |
|
* (Édition et finalisation) en fonction de l'existence ou non du type de document. |
3416 |
|
* |
3417 |
|
* Pour générer le nom du fichier, si le type de document en lien avec l'évènement existe, on récupère son libellé |
3418 |
|
* sinon on utilise l'id de la lettretype en lien avec l'évènement. |
3419 |
|
* |
3420 |
|
* @return string : le nom du fichier générer |
3421 |
|
*/ |
3422 |
|
function determinate_name_doc_pdf(){ |
3423 |
|
$id_DI = $this->getVal("dossier"); |
3424 |
|
$date = date('Ymd'); |
3425 |
|
$data = ""; |
3426 |
|
|
3427 |
|
// Récupération de l'id de la lettre type associée à l'instruction |
3428 |
|
$data = $this->getVal("lettretype"); |
3429 |
|
|
3430 |
|
// Récupération de l'id de l'instruction |
3431 |
|
$id_instr = $this->getVal("instruction"); |
3432 |
|
|
3433 |
|
// Si il existe un type de document associé à l'instruction, on le prend à la place de l'id de la lettretype |
3434 |
|
if(!empty($this->get_type_document_linked_with_instruction())){ |
3435 |
|
$data = strtolower(str_replace(" ", "-", $this->get_type_document_linked_with_instruction())); |
3436 |
|
} |
3437 |
|
|
3438 |
|
// On retourne le nom du fichier généré |
3439 |
|
return $this->f->normalize_string( |
3440 |
|
sprintf( |
3441 |
|
"%s_%s_%s_%s", |
3442 |
|
$id_DI, |
3443 |
|
$id_instr, |
3444 |
|
$date, |
3445 |
|
$data |
3446 |
|
) |
3447 |
|
); |
3448 |
|
} |
3449 |
|
|
3450 |
|
|
3451 |
|
/** |
3452 |
* [get_inst_donnees_techniques description] |
* [get_inst_donnees_techniques description] |
3453 |
* |
* |
3454 |
* @param [type] $donnees_techniques [description] |
* @param [type] $donnees_techniques [description] |
3457 |
*/ |
*/ |
3458 |
function get_inst_donnees_techniques($donnees_techniques = null) { |
function get_inst_donnees_techniques($donnees_techniques = null) { |
3459 |
// |
// |
3460 |
if (isset($this->inst_donnees_techniques) === false or |
if (isset($this->inst_donnees_techniques) === false || |
3461 |
$this->inst_donnees_techniques === null) { |
$this->inst_donnees_techniques === null) { |
3462 |
// |
// |
3463 |
if (is_null($donnees_techniques)) { |
if (is_null($donnees_techniques)) { |
3479 |
* @return string L'identifiant des données techniques liées du dossier |
* @return string L'identifiant des données techniques liées du dossier |
3480 |
*/ |
*/ |
3481 |
function getDonneesTechniques() { |
function getDonneesTechniques() { |
3482 |
|
|
3483 |
|
$qres = $this->f->get_one_result_from_db_query( |
3484 |
|
sprintf( |
3485 |
|
'SELECT |
3486 |
|
donnees_techniques |
3487 |
|
FROM |
3488 |
|
%1$sdonnees_techniques |
3489 |
|
WHERE |
3490 |
|
dossier_instruction = \'%2$s\'', |
3491 |
|
DB_PREFIXE, |
3492 |
|
$this->f->db->escapeSimple($this->valF["dossier"]) |
3493 |
|
), |
3494 |
|
array( |
3495 |
|
"origin" => __METHOD__, |
3496 |
|
) |
3497 |
|
); |
3498 |
|
|
3499 |
$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->f->addToLog("getStatut() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
|
|
if ( database::isError($donnees_techniques)){ |
|
|
die(); |
|
|
} |
|
|
|
|
|
return $donnees_techniques; |
|
3500 |
} |
} |
3501 |
|
|
3502 |
/** |
/** |
3512 |
function triggerajouterapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
function triggerajouterapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
3513 |
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
3514 |
|
|
3515 |
|
$parent_res = parent::triggerajouterapres($id, $dnu1, $val); |
3516 |
|
if ($parent_res === false) return $parent_res; |
3517 |
|
|
3518 |
|
$data = array('val' => &$val, 'id' => $id, 'parent_res' => &$parent_res); |
3519 |
|
$this->f->module_manager->run_hooks('triggerajouterapres_override_pre', $this, $data); |
3520 |
|
|
3521 |
// 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 |
3522 |
$inst_di = $this->get_inst_dossier($this->valF['dossier']); |
$inst_di = $this->get_inst_dossier($this->valF['dossier']); |
3523 |
// Instance de la classe evenement |
// Instance de la classe evenement |
3541 |
$valF_dt = array(); |
$valF_dt = array(); |
3542 |
// |
// |
3543 |
// Récupération des paramètres de l'action |
// Récupération des paramètres de l'action |
3544 |
$sql = "SELECT * FROM ".DB_PREFIXE."action |
// TODO : remplacer cette requête par l'instanciation de l'action |
3545 |
WHERE action='".$this->valF['action']."'"; |
$qres = $this->f->get_all_results_from_db_query( |
3546 |
$res = $this->f->db->query($sql); |
sprintf( |
3547 |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
'SELECT |
3548 |
if (database::isError($res)) { |
* |
3549 |
die($res->getMessage()); |
FROM |
3550 |
} |
%1$saction |
3551 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
WHERE |
3552 |
|
action = \'%2$s\'', |
3553 |
|
DB_PREFIXE, |
3554 |
|
$this->f->db->escapeSimple($this->valF['action']) |
3555 |
|
), |
3556 |
|
array( |
3557 |
|
"origin" => __METHOD__ |
3558 |
|
) |
3559 |
|
); |
3560 |
|
foreach ($qres['result'] as $row) { |
3561 |
|
|
3562 |
// pour chacune des regles, on applique la regle |
// pour chacune des regles, on applique la regle |
3563 |
if ($row['regle_delai'] != '') { |
if ($row['regle_delai'] != '') { |
3699 |
$dt_id = $this->getDonneesTechniques(); |
$dt_id = $this->getDonneesTechniques(); |
3700 |
// On met à jour le dossier |
// On met à jour le dossier |
3701 |
$cle = " donnees_techniques='".$dt_id."'"; |
$cle = " donnees_techniques='".$dt_id."'"; |
3702 |
$res1 = $this->f->db->autoExecute(DB_PREFIXE.'donnees_techniques', $valF_dt, DB_AUTOQUERY_UPDATE, $cle); |
$res1 = $this->f->db->autoexecute(DB_PREFIXE.'donnees_techniques', $valF_dt, DB_AUTOQUERY_UPDATE, $cle); |
3703 |
$this->addToLog(__METHOD__."(): db->autoexecute(\"".DB_PREFIXE."donnees_techniques\", ".print_r($valF_dt, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
$this->addToLog( |
3704 |
if (database::isError($res1)) { |
__METHOD__."(): db->autoexecute(\"".DB_PREFIXE."donnees_techniques\", ".print_r($valF_dt, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", |
3705 |
die($res->getMessage()); |
VERBOSE_MODE |
3706 |
} |
); |
3707 |
|
$this->f->isDatabaseError($res1); |
3708 |
// Affichage d'informations à l'utilisateur |
// Affichage d'informations à l'utilisateur |
3709 |
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$this->f->db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
$this->addToMessage(__('enregistrement')." ".$this->valF['dossier']." ".__('table')." dossier [".$this->f->db->affectedRows()." ".__('enregistrement')." ".__('mis_a_jour')."]"); |
3710 |
} |
} |
3711 |
// Si des valeurs ont été calculées alors on met à jour l'enregistrement |
// Si des valeurs ont été calculées alors on met à jour l'enregistrement |
3712 |
if (count($valF) > 0) { |
if (count($valF) > 0) { |
3724 |
return false; |
return false; |
3725 |
} |
} |
3726 |
// Affichage d'informations à l'utilisateur |
// Affichage d'informations à l'utilisateur |
3727 |
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$this->f->db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
$this->addToMessage(__('enregistrement')." ".$this->valF['dossier']." ".__('table')." dossier [".$this->f->db->affectedRows()." ".__('enregistrement')." ".__('mis_a_jour')."]"); |
3728 |
} |
} |
3729 |
|
|
3730 |
/** |
/** |
3754 |
$ret = $this->f->send_message_to_referentiel_erp(105, $infos); |
$ret = $this->f->send_message_to_referentiel_erp(105, $infos); |
3755 |
if ($ret !== true) { |
if ($ret !== true) { |
3756 |
$this->cleanMessage(); |
$this->cleanMessage(); |
3757 |
$this->addToMessage(_("Une erreur s'est produite lors de la notification (105) du référentiel ERP. Contactez votre administrateur.")); |
$this->addToMessage(__("Une erreur s'est produite lors de la notification (105) du référentiel ERP. Contactez votre administrateur.")); |
3758 |
return false; |
return false; |
3759 |
} |
} |
3760 |
$this->addToMessage(_("Notification (105) du référentiel ERP OK.")); |
$this->addToMessage(__("Notification (105) du référentiel ERP OK.")); |
3761 |
} |
} |
3762 |
|
|
3763 |
// Si le mode en rédaction intégrale est activé |
// Si le mode en rédaction intégrale est activé |
3827 |
// et dans le message d'erreur |
// et dans le message d'erreur |
3828 |
if ($finalize === false) { |
if ($finalize === false) { |
3829 |
$this->f->addToLog(__METHOD__."() : ERROR - Impossible de finaliser l'instruction.", DEBUG_MODE); |
$this->f->addToLog(__METHOD__."() : ERROR - Impossible de finaliser l'instruction.", DEBUG_MODE); |
3830 |
$this->addToMessage(_("Erreur lors de la finalisation de l'instruction. Contactez votre administrateur.")); |
$this->addToMessage(__("Erreur lors de la finalisation de l'instruction. Contactez votre administrateur.")); |
3831 |
return false; |
return false; |
3832 |
} |
} |
3833 |
} |
} |
3927 |
// Notification automatique à l'ajout de l'instruction si la notification |
// Notification automatique à l'ajout de l'instruction si la notification |
3928 |
// automatique est choisie et qu'il n'y a pas de lettretype associée à l'événement |
// automatique est choisie et qu'il n'y a pas de lettretype associée à l'événement |
3929 |
if ($inst_evenement->getVal('notification') === 'notification_automatique' && |
if ($inst_evenement->getVal('notification') === 'notification_automatique' && |
3930 |
($inst_evenement->getVal('lettretype') === null || |
($inst_evenement->getVal('lettretype') === null || $inst_evenement->getVal('lettretype') === '')) { |
3931 |
$inst_evenement->getVal('lettretype') === '')) { |
|
3932 |
|
// Message à afficher dans les logs pour indiquer quelle notification a échouée |
3933 |
|
$msgLog = sprintf( |
3934 |
|
'%s %s : %d', |
3935 |
|
__('Erreur lors de la notification automatique du(des) pétitionnaire(s).'), |
3936 |
|
__('Instruction notifiée'), |
3937 |
|
$id |
3938 |
|
); |
3939 |
|
|
3940 |
// 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 |
3941 |
$categorie = $this->f->get_param_option_notification($collectivite_di); |
$categorie = $this->f->get_param_option_notification($collectivite_di); |
3942 |
$isPortal = $categorie == null || $categorie == '' || $categorie == 'portal' ? true : false; |
$isPortal = $categorie === PORTAL; |
3943 |
$demandeursANotifie = $this->get_demandeurs_notifiable( |
$demandeursANotifie = $this->get_demandeurs_notifiable( |
3944 |
$this->valF['dossier'], |
$this->valF['dossier'], |
3945 |
$isPortal |
$isPortal |
3946 |
); |
); |
3947 |
|
|
3948 |
|
// |
3949 |
|
$msg_notif = ''; |
3950 |
|
|
3951 |
// Création d'une notification et d'une tâche pour chaque demandeur à notifier |
// Création d'une notification et d'une tâche pour chaque demandeur à notifier |
3952 |
$demandeurPrincipalNotifie = false; |
$demandeurPrincipalNotifie = false; |
3953 |
foreach ($demandeursANotifie as $demandeur) { |
foreach ($demandeursANotifie as $demandeur) { |
3967 |
continue; |
continue; |
3968 |
} |
} |
3969 |
} |
} |
3970 |
// Ajout de la notif et récupération de son id |
// Récupération du contenu de l'option option_bloquer_notif_auto_dln |
3971 |
$idNotif = $this->ajouter_notification( |
$option_bloquer_notif_auto_dln_types_evenements = $this->f->getParameter("option_bloquer_notif_auto_dln") !== null ? explode(';', $this->f->getParameter("option_bloquer_notif_auto_dln")) : null; |
3972 |
$this->valF[$this->clePrimaire], |
// On vérifie l'existence du paramètre 'option_bloquer_notif_auto_dln', |
3973 |
$this->f->get_connected_user_login_name(), |
// On vérifie si la date limite est dépassée ou si le type d'événement est erroné |
3974 |
$demandeur, |
if (! empty($option_bloquer_notif_auto_dln_types_evenements) |
3975 |
$collectivite_di, |
&& $this->is_type_evenement_autorise($inst_evenement, array('types_evenements_autorises'=> $option_bloquer_notif_auto_dln_types_evenements)) === true |
3976 |
array(), |
&& $this->is_date_limite_notification_premier_mois_depasee() === true) { |
3977 |
true |
// Ajout de la notif et récupération de son id |
3978 |
); |
$idNotif = $this->ajouter_notification( |
3979 |
if ($idNotif === false) { |
$this->valF[$this->clePrimaire], |
3980 |
return false; |
$this->f->get_connected_user_login_name(), |
3981 |
|
$demandeur, |
3982 |
|
$collectivite_di, |
3983 |
|
array(), |
3984 |
|
true, |
3985 |
|
'Echec', |
3986 |
|
__('La date limite de notification au demandeur est dépassée') |
3987 |
|
); |
3988 |
|
if ($idNotif === false) { |
3989 |
|
// Termine le traitement |
3990 |
|
$this->addToLog( |
3991 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
3992 |
|
DEBUG_MODE |
3993 |
|
); |
3994 |
|
return $this->end_treatment(__METHOD__, false); |
3995 |
|
} |
3996 |
|
$msg_notif .= sprintf('%s<br/>%s', __("La notification n'a pas été générée, car la date limite de notification au demandeur est dépassée."), __("Le suivi de la notification est disponible depuis l'instruction.")); |
3997 |
} |
} |
3998 |
// Création de la tache en lui donnant l'id de la notification |
else { |
3999 |
$notification_by_task = $this->notification_by_task( |
// Ajout de la notif et récupération de son id |
4000 |
$idNotif, |
$idNotif = $this->ajouter_notification( |
4001 |
$this->valF['dossier'], |
$this->valF[$this->clePrimaire], |
4002 |
$categorie |
$this->f->get_connected_user_login_name(), |
4003 |
); |
$demandeur, |
4004 |
if ($notification_by_task === false) { |
$collectivite_di, |
4005 |
$this->addToMessage( |
array(), |
4006 |
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
true |
4007 |
); |
); |
4008 |
return false; |
if ($idNotif === false) { |
4009 |
|
$this->addToLog( |
4010 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
4011 |
|
DEBUG_MODE |
4012 |
|
); |
4013 |
|
return false; |
4014 |
|
} |
4015 |
|
// Création de la tache en lui donnant l'id de la notification |
4016 |
|
$notification_by_task = $this->notification_by_task( |
4017 |
|
$idNotif, |
4018 |
|
$this->valF['dossier'], |
4019 |
|
$categorie |
4020 |
|
); |
4021 |
|
if ($notification_by_task === false) { |
4022 |
|
$this->addToLog( |
4023 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
4024 |
|
DEBUG_MODE |
4025 |
|
); |
4026 |
|
$this->addToMessage( |
4027 |
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
4028 |
|
); |
4029 |
|
return false; |
4030 |
|
} |
4031 |
|
$msg_notif .= sprintf('%s<br/>%s', __("La notification a été générée."), __("Le suivi de la notification est disponible depuis l'instruction.")); |
4032 |
} |
} |
4033 |
} |
} |
4034 |
// Si le demandeur principal n'est pas notifiable, on créé une nouvelle notification |
// Pour la notification par mail ou la notification via portal si le dossier a |
4035 |
// en erreur avec en commentaire la raison pour laquelle le demandeur principal |
// été déposés via portal, si le demandeur principal n'est pas notifiable, |
4036 |
// n'a pas pu être notifié |
// on créé une nouvelle notification en erreur avec en commentaire la raison pour |
4037 |
if (! $demandeurPrincipalNotifie) { |
// laquelle le demandeur principal n'a pas pu être notifié |
4038 |
|
$depotPortal = $this->dossier_depose_sur_portail(); |
4039 |
|
if (! $demandeurPrincipalNotifie && ($isPortal === false || $depotPortal === true)) { |
4040 |
|
// Précision dans les logs que le pétitionnaire principal n'est pas notifiable. |
4041 |
|
// ' ' permet de mettre un espace entre les 2 msg de log. |
4042 |
|
$msgLog .= sprintf(' %s', __('Le pétitionnaire principale n\'est pas notifiable.')); |
4043 |
// Analyse pour savoir pourquoi le demandeur principal n'est pas notifiable |
// Analyse pour savoir pourquoi le demandeur principal n'est pas notifiable |
4044 |
$erreursParam = $this->get_info_notification_fail($val['dossier']); |
$erreursParam = $this->get_info_notification_fail($val['dossier']); |
4045 |
$demandeurPrincipal = $this->get_info_petitionnaire_principal_dossier($val['dossier']); |
$demandeurPrincipal = $this->get_info_petitionnaire_principal_dossier($val['dossier']); |
4055 |
implode(' ', $erreursParam) |
implode(' ', $erreursParam) |
4056 |
); |
); |
4057 |
if ($idNotif === false) { |
if ($idNotif === false) { |
4058 |
|
$this->addToLog( |
4059 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
4060 |
|
DEBUG_MODE |
4061 |
|
); |
4062 |
$this->addToMessage( |
$this->addToMessage( |
4063 |
__('Erreur : la création de la notification a échouée.'). |
__('Erreur : la création de la notification a échouée.'). |
4064 |
__("Veuillez contacter votre administrateur.") |
__("Veuillez contacter votre administrateur.") |
4070 |
$dossier_message = $this->get_inst_dossier_message(0); |
$dossier_message = $this->get_inst_dossier_message(0); |
4071 |
$dossier_message_val = array( |
$dossier_message_val = array( |
4072 |
'dossier' => $val['dossier'], |
'dossier' => $val['dossier'], |
4073 |
'type' => _('erreur expedition'), |
'type' => __('erreur expedition'), |
4074 |
'emetteur' => $this->f->get_connected_user_login_name().' (automatique)', |
'emetteur' => $this->f->get_connected_user_login_name().' (automatique)', |
4075 |
'login' => $_SESSION['login'], |
'login' => $_SESSION['login'], |
4076 |
'date_emission' => date('Y-m-d H:i:s'), |
'date_emission' => date('Y-m-d H:i:s'), |
4077 |
'contenu' => _('Échec lors de la notification de l\'instruction '). |
'contenu' => __('Échec lors de la notification de l\'instruction '). |
4078 |
$inst_evenement->getVal('libelle'). |
$inst_evenement->getVal('libelle'). |
4079 |
'.<br>'. |
'.<br>'. |
4080 |
implode("\n", $erreursParam). |
implode("\n", $erreursParam). |
4081 |
'<br>'. |
'<br>'. |
4082 |
_('Veuillez corriger ces informations avant de renvoyer la notification.') |
__('Veuillez corriger ces informations avant de renvoyer la notification.') |
4083 |
); |
); |
4084 |
$add = $dossier_message->add_notification_message($dossier_message_val, true); |
$add = $dossier_message->add_notification_message($dossier_message_val, true); |
4085 |
// Si une erreur se produit pendant l'ajout |
// Si une erreur se produit pendant l'ajout |
4088 |
return false; |
return false; |
4089 |
} |
} |
4090 |
} |
} |
4091 |
$this->addToMessage($message = sprintf('%s<br/>%s', __("La notification a été générée."), __("Le suivi de la notification est disponible depuis l'instruction."))); |
$this->addToMessage($msg_notif); |
4092 |
} |
} |
4093 |
|
|
4094 |
// Notification automatique en cas de dépôt de dossier dématérialisé |
// Notification automatique en cas de dépôt de dossier dématérialisé |
4098 |
$this->f->is_option_notification_depot_demat_enabled($collectivite_di) |
$this->f->is_option_notification_depot_demat_enabled($collectivite_di) |
4099 |
&& $this->is_instruction_recepisse() |
&& $this->is_instruction_recepisse() |
4100 |
) { |
) { |
4101 |
|
// Message à afficher dans les logs pour indiquer quelle notification a échouée |
4102 |
|
$msgLog = sprintf( |
4103 |
|
__('Erreur lors de la notification de dépôt du dossier dématérialisé : %s.'), |
4104 |
|
$val['dossier'] |
4105 |
|
); |
4106 |
// Récupère l'instance de la demande |
// Récupère l'instance de la demande |
4107 |
$demande = $inst_di->get_inst_demande(); |
$demande = $inst_di->get_inst_demande(); |
4108 |
// Récupère la liste des mails fournis en paramètre |
// Vérifie que le dossier a été déposé via platau ou portal |
|
$listeEmails = $this->f->get_param_courriel_de_notification_commune($collectivite_di); |
|
|
// Vérifie que le dossier a été déposé via platau ou ideau et qu'il y a |
|
|
// des adresses à notifier |
|
4109 |
if ( |
if ( |
4110 |
($demande->getVal('source_depot') == 'platau' || |
($demande->getVal('source_depot') == PLATAU || |
4111 |
$demande->getVal('source_depot') == 'ideau') && |
$demande->getVal('source_depot') == PORTAL) |
|
! empty($listeEmails) |
|
4112 |
) { |
) { |
4113 |
foreach ($listeEmails as $email) { |
// Récupère la liste des mails fournis en paramètre. Si aucun adresse n'a été récupéré |
4114 |
// Ajout de la notif et récupération de son id |
// l'envoi de la notification n'est pas effectué et un message d'erreur est affiché. |
4115 |
$destinataire = array( |
$listeEmails = $this->f->get_param_courriel_de_notification_commune($collectivite_di); |
4116 |
'destinataire' => $email, |
if (empty($listeEmails)) { |
4117 |
'courriel' => $email |
$this->addToLog( |
4118 |
); |
sprintf( |
4119 |
$idNotif = $this->ajouter_notification( |
'%s(): %s %s', |
4120 |
$this->valF[$this->clePrimaire], |
__METHOD__, |
4121 |
$this->f->get_connected_user_login_name(), |
$msgLog, |
4122 |
$destinataire, |
__('Aucun courriel paramétré.') |
4123 |
$collectivite_di, |
), |
4124 |
array(), |
DEBUG_MODE |
|
true |
|
4125 |
); |
); |
4126 |
if ($idNotif === false) { |
} else { |
4127 |
return false; |
foreach ($listeEmails as $email) { |
4128 |
} |
// Ajout de la notif et récupération de son id |
4129 |
// Création de la tache en lui donnant l'id de la notification |
$destinataire = array( |
4130 |
$notification_by_task = $this->notification_by_task( |
'destinataire' => $email, |
4131 |
$idNotif, |
'courriel' => $email |
|
$this->valF['dossier'], |
|
|
'mail', |
|
|
'notification_depot_demat' |
|
|
); |
|
|
if ($notification_by_task === false) { |
|
|
$this->addToMessage( |
|
|
__("Erreur lors de la génération de la notification de dépot de dossier par voie dématérialisée.") |
|
4132 |
); |
); |
4133 |
return false; |
$idNotif = $this->ajouter_notification( |
4134 |
|
$this->valF[$this->clePrimaire], |
4135 |
|
$this->f->get_connected_user_login_name(), |
4136 |
|
$destinataire, |
4137 |
|
$collectivite_di, |
4138 |
|
array(), |
4139 |
|
true |
4140 |
|
); |
4141 |
|
if ($idNotif === false) { |
4142 |
|
$this->addToLog( |
4143 |
|
sprintf('%s(): %s', __METHOD__, $msgLog), |
4144 |
|
DEBUG_MODE |
4145 |
|
); |
4146 |
|
return false; |
4147 |
|
} |
4148 |
|
// Création de la tache en lui donnant l'id de la notification |
4149 |
|
$notification_by_task = $this->notification_by_task( |
4150 |
|
$idNotif, |
4151 |
|
$this->valF['dossier'], |
4152 |
|
'mail', |
4153 |
|
'notification_depot_demat' |
4154 |
|
); |
4155 |
|
if ($notification_by_task === false) { |
4156 |
|
$this->addToMessage( |
4157 |
|
__("Erreur lors de la génération de la notification de dépot de dossier par voie dématérialisée.") |
4158 |
|
); |
4159 |
|
$this->addToLog( |
4160 |
|
sprintf('%s(): %s', __METHOD__, $msgLog), |
4161 |
|
DEBUG_MODE |
4162 |
|
); |
4163 |
|
return false; |
4164 |
|
} |
4165 |
} |
} |
4166 |
} |
} |
4167 |
} |
} |
4178 |
$inst_da = $inst_di->get_inst_dossier_autorisation(); |
$inst_da = $inst_di->get_inst_dossier_autorisation(); |
4179 |
$params['di_id'] = $this->valF['dossier']; |
$params['di_id'] = $this->valF['dossier']; |
4180 |
if ($inst_da->majDossierAutorisation($params) === false) { |
if ($inst_da->majDossierAutorisation($params) === false) { |
4181 |
$this->addToMessage(_("Erreur lors de la mise a jour des donnees du dossier d'autorisation. Contactez votre administrateur.")); |
$this->addToMessage(__("Erreur lors de la mise a jour des donnees du dossier d'autorisation. Contactez votre administrateur.")); |
4182 |
$this->correct = false; |
$this->correct = false; |
4183 |
return false; |
return false; |
4184 |
} |
} |
4186 |
/** |
/** |
4187 |
* Historisation de la vie du DI. |
* Historisation de la vie du DI. |
4188 |
*/ |
*/ |
4189 |
// |
|
4190 |
return $this->add_log_to_dossier($id, array_merge($val, $this->valF)); |
$res = $this->add_log_to_dossier($id, array_merge($val, $this->valF)); |
4191 |
|
|
4192 |
|
$data = array('val' => &$val, 'id' => $id, 'result' => &$res); |
4193 |
|
$this->f->module_manager->run_hooks('triggerajouterapres_override_post', $this, $data); |
4194 |
|
return $res; |
4195 |
} |
} |
4196 |
|
|
4197 |
/** |
/** |
4198 |
* 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 |
4199 |
* sont remplies. |
* sont remplies. |
4200 |
* Les conditions vérifiées sont les suivantes : |
* Les conditions vérifiées sont les suivantes : |
4201 |
|
* - L'option de notification *option_notification* doit être définie |
4202 |
* - Le petitionnaire principal doit accepter les notifications |
* - Le petitionnaire principal doit accepter les notifications |
4203 |
* - Le pétitionnaire principal doit avoir une adresse mail renseignée |
* - Le pétitionnaire principal doit avoir une adresse mail renseignée |
4204 |
* - Le pétitionnaire principal doit avoir une adresse mail correcte |
* - Le pétitionnaire principal doit avoir une adresse mail correcte |
4209 |
* @param string identifiant du dossier sur lequel les notifications ont échouée |
* @param string identifiant du dossier sur lequel les notifications ont échouée |
4210 |
* @return string |
* @return string |
4211 |
*/ |
*/ |
4212 |
protected function get_info_notification_fail($dossier = null) { |
public function get_info_notification_fail($dossier = null) { |
4213 |
// Utilise l'identifiant du dossier passé en paramètre et si aucun dossier n'a été récupéré |
// Utilise l'identifiant du dossier passé en paramètre et si aucun dossier n'a été récupéré |
4214 |
// utilise celui associé à l'instruction |
// utilise celui associé à l'instruction |
4215 |
if ($dossier == null) { |
if ($dossier == null) { |
4217 |
} |
} |
4218 |
// Tableau contenant la liste des messages d'erreur |
// Tableau contenant la liste des messages d'erreur |
4219 |
$errorMessage = array(); |
$errorMessage = array(); |
4220 |
|
// Récupère l'option de notification |
4221 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite($dossier); |
4222 |
|
$option_notification = $this->f->get_param_option_notification($collectivite_di); |
4223 |
|
if ($option_notification !== PORTAL && $option_notification !== 'mail') { |
4224 |
|
$errorMessage[] = __("L'option de notification option_notification doit obligatoirement être définie."); |
4225 |
|
} |
4226 |
// Récupère les informations du demandeurs principal |
// Récupère les informations du demandeurs principal |
4227 |
$infoPetitionnaire = $this->get_info_petitionnaire_principal_dossier($dossier); |
$infoPetitionnaire = $this->get_info_petitionnaire_principal_dossier($dossier); |
4228 |
// 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 |
4264 |
if (empty($dossier)) { |
if (empty($dossier)) { |
4265 |
$dossier = $this->getVal('dossier'); |
$dossier = $this->getVal('dossier'); |
4266 |
} |
} |
4267 |
$sql = sprintf( |
$qres = $this->f->get_one_result_from_db_query( |
4268 |
'SELECT |
sprintf( |
4269 |
dossier |
'SELECT |
4270 |
FROM |
dossier |
4271 |
%1$sdossier |
FROM |
4272 |
-- Récuperation de la première demande associée au dossier |
%1$sdossier |
4273 |
LEFT JOIN ( |
-- Récuperation de la première demande associée au dossier |
4274 |
SELECT |
LEFT JOIN ( |
4275 |
demande, |
SELECT |
4276 |
dossier_instruction, |
demande, |
4277 |
source_depot |
dossier_instruction, |
4278 |
FROM |
source_depot |
4279 |
%1$sdemande |
FROM |
4280 |
WHERE |
%1$sdemande |
4281 |
dossier_instruction = \'%2$s\' |
WHERE |
4282 |
ORDER BY |
dossier_instruction = \'%2$s\' |
4283 |
demande ASC |
ORDER BY |
4284 |
LIMIT 1 |
demande ASC |
4285 |
) as demande ON dossier.dossier = demande.dossier_instruction |
LIMIT 1 |
4286 |
WHERE |
) AS demande |
4287 |
dossier.dossier = \'%2$s\' |
ON dossier.dossier = demande.dossier_instruction |
4288 |
AND demande.source_depot = \'portal\'', |
WHERE |
4289 |
DB_PREFIXE, |
dossier.dossier = \'%2$s\' |
4290 |
$dossier |
AND demande.source_depot = \'portal\'', |
4291 |
|
DB_PREFIXE, |
4292 |
|
$this->f->db->escapeSimple($dossier) |
4293 |
|
), |
4294 |
|
array( |
4295 |
|
"origin" => __METHOD__, |
4296 |
|
"force_return" => true, |
4297 |
|
) |
4298 |
); |
); |
4299 |
$res = $this->f->get_one_result_from_db_query($sql, true); |
if ($qres["code"] !== "OK") { |
|
if ($res['code'] === 'KO') { |
|
4300 |
$this->addToMessage(__('Erreur : La vérification du mode de dépôt du dossier à échoué')); |
$this->addToMessage(__('Erreur : La vérification du mode de dépôt du dossier à échoué')); |
4301 |
return; |
return; |
4302 |
} |
} |
4303 |
// Si on a un résultat c'est que le dossier a été déposé via le portail |
// Si on a un résultat c'est que le dossier a été déposé via le portail |
4304 |
return ! empty($res['result']); |
return ! empty($qres["result"]); |
4305 |
} |
} |
4306 |
|
|
4307 |
public function is_service_notifiable() { |
public function is_service_notifiable() { |
4329 |
} |
} |
4330 |
} |
} |
4331 |
// Vérifie si la notification des tiers est active pour l'évènement |
// Vérifie si la notification des tiers est active pour l'évènement |
4332 |
return $this->get_boolean_from_pgsql_value($evenement->getVal('notification_tiers')); |
return ! empty($evenement->getVal('notification_tiers')); |
4333 |
} |
} |
4334 |
|
|
4335 |
/** |
/** |
4377 |
} |
} |
4378 |
|
|
4379 |
/** |
/** |
4380 |
* 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 |
4381 |
* principal. |
* pour le demandeur principal. |
4382 |
* |
* |
4383 |
* @return boolean true si le traitement à réussi |
* @return boolean true si le traitement à réussi |
4384 |
*/ |
*/ |
4385 |
protected function notifier_demandeur_principal() { |
protected function notifier_demandeur_principal_via_portal() { |
4386 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
4387 |
$message = ''; |
$message = ''; |
4388 |
// Récupération des informations concernant le demandeur |
// Récupération des informations concernant le demandeur |
4407 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
4408 |
} |
} |
4409 |
// 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 |
4410 |
$notification_by_task = $this->notification_by_task($idNotification, $dossier); |
$notification_by_task = $this->notification_by_task($idNotification, $dossier, PORTAL); |
4411 |
if ($notification_by_task === false) { |
if ($notification_by_task === false) { |
4412 |
$this->addToMessage( |
$this->addToMessage( |
4413 |
__("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).") |
4422 |
} |
} |
4423 |
|
|
4424 |
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'; |
|
|
} |
|
4425 |
// 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é |
4426 |
if ($type !== 'notification_recepisse' |
if ($type !== 'notification_recepisse' |
4427 |
&& $type !== 'notification_instruction' |
&& $type !== 'notification_instruction' |
4429 |
&& $type !== 'notification_service_consulte' |
&& $type !== 'notification_service_consulte' |
4430 |
&& $type !== 'notification_tiers_consulte' |
&& $type !== 'notification_tiers_consulte' |
4431 |
&& $type !== 'notification_depot_demat' |
&& $type !== 'notification_depot_demat' |
4432 |
&& $type !== 'notification_commune') { |
&& $type !== 'notification_commune' |
4433 |
|
&& $type !== 'notification_signataire') { |
4434 |
// |
// |
4435 |
$type = 'notification_instruction'; |
$type = 'notification_instruction'; |
4436 |
// Vérifie si l'instruction est un récépissé |
// Vérifie si l'instruction est un récépissé |
4446 |
} |
} |
4447 |
} |
} |
4448 |
} |
} |
4449 |
// 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, |
|
|
)); |
|
4450 |
$task_val = array( |
$task_val = array( |
4451 |
'type' => $type, |
'type' => $type, |
4452 |
'object_id' => $object_id, |
'object_id' => $object_id, |
4453 |
'dossier' => $dossier, |
'dossier' => $dossier, |
4454 |
'category' => $category, |
'category' => $category, |
4455 |
); |
); |
4456 |
|
// Préparation de la tache de notification |
4457 |
|
$inst_task = $this->f->get_inst__om_dbform(array( |
4458 |
|
"obj" => "task", |
4459 |
|
"idx" => 0, |
4460 |
|
)); |
4461 |
|
|
4462 |
$add_task = $inst_task->add_task(array('val' => $task_val)); |
$add_task = $inst_task->add_task(array('val' => $task_val)); |
4463 |
if ($add_task === false) { |
if ($add_task === false) { |
4464 |
|
$this->addToLog( |
4465 |
|
sprintf( |
4466 |
|
'%s(): %s %s : %s', |
4467 |
|
__METHOD__, |
4468 |
|
__('Echec de l\'ajout de la tâche de notification.'), |
4469 |
|
__('Paramétrage de la tâche'), |
4470 |
|
var_export($task_val, true) |
4471 |
|
), |
4472 |
|
DEBUG_MODE |
4473 |
|
); |
4474 |
return false; |
return false; |
4475 |
} |
} |
4476 |
|
|
4543 |
// Vérification que les paramètres nécessaires à l'envoi de la notification existe avant |
// Vérification que les paramètres nécessaires à l'envoi de la notification existe avant |
4544 |
// de créer la notification |
// de créer la notification |
4545 |
if (! $this->is_parametrage_notification_correct($collectiviteId)) { |
if (! $this->is_parametrage_notification_correct($collectiviteId)) { |
4546 |
$this->addToMessage(__("Erreur de paramétrage. L'url d'accès au(x) document(s) notifié(s) n'est pas paramétrée.")); |
$msgErreur = __("Erreur de paramétrage. L'url d'accès au(x) document(s) notifié(s) n'est pas paramétrée."); |
4547 |
|
$this->addToMessage($msgErreur); |
4548 |
|
$this->addToLog( |
4549 |
|
sprintf('%s() : %s', __METHOD__, $msgErreur), |
4550 |
|
DEBUG_MODE |
4551 |
|
); |
4552 |
return false; |
return false; |
4553 |
} |
} |
4554 |
// Préparation de la notification |
// Préparation de la notification |
4573 |
$add_notif = $inst_notif->ajouter($notif_val); |
$add_notif = $inst_notif->ajouter($notif_val); |
4574 |
if ($add_notif === false) { |
if ($add_notif === false) { |
4575 |
$this->addToMessage(__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).")); |
$this->addToMessage(__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).")); |
4576 |
|
$this->addToLog( |
4577 |
|
sprintf( |
4578 |
|
'%s() : %s %s : %s', |
4579 |
|
__METHOD__, |
4580 |
|
__("Echec de l'ajout de la notification en base de données."), |
4581 |
|
__('Paramétrage de la notification'), |
4582 |
|
var_export($notif_val, true) |
4583 |
|
), |
4584 |
|
DEBUG_MODE |
4585 |
|
); |
4586 |
return false; |
return false; |
4587 |
} |
} |
4588 |
|
|
4665 |
|
|
4666 |
$add_notif_doc = $inst_notif_doc->ajouter($notif_doc_val); |
$add_notif_doc = $inst_notif_doc->ajouter($notif_doc_val); |
4667 |
if ($add_notif_doc === false) { |
if ($add_notif_doc === false) { |
4668 |
|
$this->addToLog( |
4669 |
|
sprintf( |
4670 |
|
'%s() : %s %s : %s', |
4671 |
|
__METHOD__, |
4672 |
|
__('Echec de l\'ajout du paramétrage du document notifié en base de données.'), |
4673 |
|
__('Paramétrage du document'), |
4674 |
|
var_export($notif_doc_val, true) |
4675 |
|
), |
4676 |
|
DEBUG_MODE |
4677 |
|
); |
4678 |
return false; |
return false; |
4679 |
} |
} |
4680 |
return true; |
return true; |
4681 |
} |
} |
4682 |
|
|
4683 |
|
/** |
4684 |
|
* Récupère via une requête la liste des identifiants des éléments de la table |
4685 |
|
* parametrage_annexe liés à une instruction. |
4686 |
|
* Boucle sur cette liste pour instancier le parametrage_annexe correspondant |
4687 |
|
* et lui appliquer le traitement de suppression. |
4688 |
|
* |
4689 |
|
* @param integer identifiant d'une instruction |
4690 |
|
* @return boolean état du traitement. True : OK, False : Echec |
4691 |
|
*/ |
4692 |
|
function supprimer_parametrage_annexe($id_instruction) { |
4693 |
|
// Récupère la liste des parametrage_annexe associés à l'instruction |
4694 |
|
$qres = $this->f->get_all_results_from_db_query(sprintf( |
4695 |
|
'SELECT parametrage_annexe |
4696 |
|
FROM %sparametrage_annexe |
4697 |
|
WHERE parametrage_annexe.instruction = %d', |
4698 |
|
DB_PREFIXE, |
4699 |
|
intval($id_instruction)), |
4700 |
|
array('origin' => __METHOD__)); |
4701 |
|
// Instancie puis supprime chacun des éléments de la liste |
4702 |
|
foreach ($qres['result'] as $res) { |
4703 |
|
$parametrage_annexe = $this->f->get_inst__om_dbform(array( |
4704 |
|
'obj' => 'parametrage_annexe', |
4705 |
|
'idx' => $res['parametrage_annexe'] |
4706 |
|
)); |
4707 |
|
foreach ($parametrage_annexe->champs as $champ) { |
4708 |
|
$val[$champ] = $parametrage_annexe->getVal($champ); |
4709 |
|
} |
4710 |
|
$suppression = $parametrage_annexe->supprimer($val); |
4711 |
|
// En cas d'échec arrête le traitement et renvoie false |
4712 |
|
if ($suppression === false) { |
4713 |
|
return false; |
4714 |
|
} |
4715 |
|
} |
4716 |
|
return true; |
4717 |
|
} |
4718 |
|
|
4719 |
/** |
/** |
4720 |
* Vérifie si le paramétrage de la notification des demandeurs est correct. |
* Vérifie si le paramétrage de la notification des demandeurs est correct. |
4721 |
* |
* |
4725 |
protected function is_parametrage_notification_correct($collectiviteId) { |
protected function is_parametrage_notification_correct($collectiviteId) { |
4726 |
$categorie = $this->f->get_param_option_notification($collectiviteId); |
$categorie = $this->f->get_param_option_notification($collectiviteId); |
4727 |
$urlAccesNotif = $this->f->get_parametre_notification_url_acces($collectiviteId); |
$urlAccesNotif = $this->f->get_parametre_notification_url_acces($collectiviteId); |
4728 |
if ($categorie == 'mail' && $urlAccesNotif == null) { |
if ($categorie === 'mail' && $urlAccesNotif === null) { |
4729 |
return false; |
return false; |
4730 |
} |
} |
4731 |
return true; |
return true; |
4738 |
*/ |
*/ |
4739 |
function triggermodifierapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
function triggermodifierapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
4740 |
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
4741 |
|
$data = array('val' => &$val, 'id' => $id); |
4742 |
|
$this->f->module_manager->run_hooks('triggermodifierapres_pre', $this, $data); |
4743 |
$collectivite_di = $this->get_dossier_instruction_om_collectivite($val['dossier']); |
$collectivite_di = $this->get_dossier_instruction_om_collectivite($val['dossier']); |
4744 |
$message = ''; |
$message = ''; |
4745 |
/** |
$res = true; |
4746 |
* L'objectif ici est d'effectuer les recalculs de date dans le dossier |
// Définit si le dossier d'instruction doit être mis à jour |
4747 |
* si la date de l'evenement est modifiee |
$update_dossier = true; |
4748 |
*/ |
// Les actions de mise à jour des dates ne doivent pas appliquer |
4749 |
// Initialisation |
// l'action de l'événement et donc ne pas mettre à jour le dossier |
4750 |
$valF = array(); |
if ($this->getParameter("maj") == 125 |
4751 |
$valF_dt = array(); |
|| $this->getParameter("maj") == 170 |
4752 |
// Initialisation du type d'événement |
|| $this->getParameter("maj") == 175) { |
4753 |
$type_evmt = ""; |
$update_dossier = false; |
|
// Récupération de l'action correspondante à l'événement |
|
|
$sql = "SELECT action |
|
|
FROM ".DB_PREFIXE."evenement |
|
|
WHERE evenement=".$this->valF['evenement']; |
|
|
$action = $this->f->db->getOne($sql); |
|
|
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
|
|
if (database::isError($action)) { |
|
|
die($action->getMessage()); |
|
4754 |
} |
} |
4755 |
|
|
4756 |
// Récupération des paramètres de l'action |
// Traitement en cas de mise à jour du dossier |
4757 |
$sql = "SELECT * FROM ".DB_PREFIXE."action |
if ($update_dossier === true) { |
4758 |
WHERE action='".$action."'"; |
/** |
4759 |
$res = $this->f->db->query($sql); |
* L'objectif ici est d'effectuer les recalculs de date dans le dossier |
4760 |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
* si la date de l'evenement est modifiee |
4761 |
if (database::isError($res)) { |
*/ |
4762 |
die($res->getMessage()); |
// Initialisation |
4763 |
} |
$valF = array(); |
4764 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
$valF_dt = array(); |
4765 |
// application des regles sur le courrier + delai |
// Initialisation du type d'événement |
4766 |
if(preg_match("/date_evenement/",$row['regle_date_limite'])){ |
$type_evmt = ""; |
4767 |
$valF['date_limite']= $this->regle($row['regle_date_limite'], 'regle_date_limite'); |
// Récupération de l'action correspondante à l'événement |
4768 |
} |
$evenement = $this->f->get_inst__om_dbform(array( |
4769 |
if(preg_match("/date_evenement/",$row['regle_date_complet'])){ |
"obj" => "evenement", |
4770 |
$valF['date_complet']= $this->regle($row['regle_date_complet'], 'regle_date_complet'); |
"idx" => $this->valF['evenement'] |
4771 |
} |
)); |
4772 |
if(preg_match("/date_evenement/",$row['regle_date_dernier_depot'])){ |
|
4773 |
$valF['date_dernier_depot']= $this->regle($row['regle_date_dernier_depot'], 'regle_date_dernier_depot'); |
// Récupération des paramètres de l'action |
4774 |
} |
// TODO : remplacer cette requête par l'instanciation de l'action |
4775 |
if(preg_match("/date_evenement/",$row['regle_date_notification_delai'])){ |
$qres = $this->f->get_all_results_from_db_query( |
4776 |
$valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai'], 'regle_date_notification_delai'); |
sprintf( |
4777 |
} |
'SELECT |
4778 |
if(preg_match("/date_evenement/",$row['regle_date_decision'])){ |
* |
4779 |
$valF['date_decision']= $this->regle($row['regle_date_decision'], 'regle_date_decision'); |
FROM |
4780 |
} |
%1$saction |
4781 |
if(preg_match("/date_evenement/",$row['regle_date_rejet'])){ |
WHERE |
4782 |
$valF['date_rejet']= $this->regle($row['regle_date_rejet'], 'regle_date_rejet'); |
action = \'%2$s\'', |
4783 |
} |
DB_PREFIXE, |
4784 |
if(preg_match("/date_evenement/",$row['regle_date_validite'])){ |
$this->f->db->escapeSimple($evenement->getVal('action')) |
4785 |
$valF['date_validite']= $this->regle($row['regle_date_validite'], 'regle_date_validite'); |
), |
4786 |
} |
array( |
4787 |
if(preg_match("/date_evenement/",$row['regle_date_chantier'])){ |
"origin" => __METHOD__ |
4788 |
$valF['date_chantier']= $this->regle($row['regle_date_chantier'], 'regle_date_chantier'); |
) |
4789 |
} |
); |
4790 |
if(preg_match("/date_evenement/",$row['regle_date_achevement'])){ |
foreach ($qres['result'] as $row) { |
4791 |
$valF['date_achevement']= $this->regle($row['regle_date_achevement'], 'regle_date_achevement'); |
// application des regles sur le courrier + delai |
4792 |
} |
if(preg_match("/date_evenement/",$row['regle_date_limite'])){ |
4793 |
if(preg_match("/date_evenement/",$row['regle_date_conformite'])){ |
$valF['date_limite']= $this->regle($row['regle_date_limite'], 'regle_date_limite'); |
4794 |
$valF['date_conformite']= $this->regle($row['regle_date_conformite'], 'regle_date_conformite'); |
} |
4795 |
} |
if(preg_match("/date_evenement/",$row['regle_date_complet'])){ |
4796 |
if(preg_match("/date_evenement/",$row['regle_date_cloture_instruction'])){ |
$valF['date_complet']= $this->regle($row['regle_date_complet'], 'regle_date_complet'); |
4797 |
$valF['date_cloture_instruction']= $this->regle($row['regle_date_cloture_instruction'], 'regle_date_cloture_instruction'); |
} |
4798 |
} |
if(preg_match("/date_evenement/",$row['regle_date_dernier_depot'])){ |
4799 |
if(preg_match("/date_evenement/",$row['regle_date_premiere_visite'])){ |
$valF['date_dernier_depot']= $this->regle($row['regle_date_dernier_depot'], 'regle_date_dernier_depot'); |
4800 |
$valF['date_premiere_visite']= $this->regle($row['regle_date_premiere_visite'], 'regle_date_premiere_visite'); |
} |
4801 |
} |
if(preg_match("/date_evenement/",$row['regle_date_notification_delai'])){ |
4802 |
if(preg_match("/date_evenement/",$row['regle_date_derniere_visite'])){ |
$valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai'], 'regle_date_notification_delai'); |
4803 |
$valF['date_derniere_visite']= $this->regle($row['regle_date_derniere_visite'], 'regle_date_derniere_visite'); |
} |
4804 |
} |
if(preg_match("/date_evenement/",$row['regle_date_decision'])){ |
4805 |
if(preg_match("/date_evenement/",$row['regle_date_contradictoire'])){ |
$valF['date_decision']= $this->regle($row['regle_date_decision'], 'regle_date_decision'); |
4806 |
$valF['date_contradictoire']= $this->regle($row['regle_date_contradictoire'], 'regle_date_contradictoire'); |
} |
4807 |
} |
if(preg_match("/date_evenement/",$row['regle_date_rejet'])){ |
4808 |
if(preg_match("/date_evenement/",$row['regle_date_retour_contradictoire'])){ |
$valF['date_rejet']= $this->regle($row['regle_date_rejet'], 'regle_date_rejet'); |
4809 |
$valF['date_retour_contradictoire']= $this->regle($row['regle_date_retour_contradictoire'], 'regle_date_retour_contradictoire'); |
} |
4810 |
} |
if(preg_match("/date_evenement/",$row['regle_date_validite'])){ |
4811 |
if(preg_match("/date_evenement/",$row['regle_date_ait'])){ |
$valF['date_validite']= $this->regle($row['regle_date_validite'], 'regle_date_validite'); |
4812 |
$valF['date_ait']= $this->regle($row['regle_date_ait'], 'regle_date_ait'); |
} |
4813 |
} |
if(preg_match("/date_evenement/",$row['regle_date_chantier'])){ |
4814 |
if(preg_match("/date_evenement/",$row['regle_date_transmission_parquet'])){ |
$valF['date_chantier']= $this->regle($row['regle_date_chantier'], 'regle_date_chantier'); |
4815 |
$valF['date_transmission_parquet']= $this->regle($row['regle_date_transmission_parquet'], 'regle_date_transmission_parquet'); |
} |
4816 |
} |
if(preg_match("/date_evenement/",$row['regle_date_achevement'])){ |
4817 |
if ($row['regle_donnees_techniques1'] !== '') { |
$valF['date_achevement']= $this->regle($row['regle_date_achevement'], 'regle_date_achevement'); |
4818 |
$valF_dt[$row['cible_regle_donnees_techniques1']] = $this->regle($row['regle_donnees_techniques1'], 'regle_donnees_techniques1'); |
} |
4819 |
} |
if(preg_match("/date_evenement/",$row['regle_date_conformite'])){ |
4820 |
if ($row['regle_donnees_techniques2'] !== '') { |
$valF['date_conformite']= $this->regle($row['regle_date_conformite'], 'regle_date_conformite'); |
4821 |
$valF_dt[$row['cible_regle_donnees_techniques2']] = $this->regle($row['regle_donnees_techniques2'], 'regle_donnees_techniques2'); |
} |
4822 |
} |
if(preg_match("/date_evenement/",$row['regle_date_cloture_instruction'])){ |
4823 |
if ($row['regle_donnees_techniques3'] !== '') { |
$valF['date_cloture_instruction']= $this->regle($row['regle_date_cloture_instruction'], 'regle_date_cloture_instruction'); |
4824 |
$valF_dt[$row['cible_regle_donnees_techniques3']] = $this->regle($row['regle_donnees_techniques3'], 'regle_donnees_techniques3'); |
} |
4825 |
} |
if(preg_match("/date_evenement/",$row['regle_date_premiere_visite'])){ |
4826 |
if ($row['regle_donnees_techniques4'] !== '') { |
$valF['date_premiere_visite']= $this->regle($row['regle_date_premiere_visite'], 'regle_date_premiere_visite'); |
4827 |
$valF_dt[$row['cible_regle_donnees_techniques4']] = $this->regle($row['regle_donnees_techniques4'], 'regle_donnees_techniques4'); |
} |
4828 |
} |
if(preg_match("/date_evenement/",$row['regle_date_derniere_visite'])){ |
4829 |
if ($row['regle_donnees_techniques5'] !== '') { |
$valF['date_derniere_visite']= $this->regle($row['regle_date_derniere_visite'], 'regle_date_derniere_visite'); |
4830 |
$valF_dt[$row['cible_regle_donnees_techniques5']] = $this->regle($row['regle_donnees_techniques5'], 'regle_donnees_techniques5'); |
} |
4831 |
} |
if(preg_match("/date_evenement/",$row['regle_date_contradictoire'])){ |
4832 |
if ($row['regle_dossier_instruction_type'] !== '') { |
$valF['date_contradictoire']= $this->regle($row['regle_date_contradictoire'], 'regle_date_contradictoire'); |
4833 |
$valF['dossier_instruction_type'] = $this->regle($row['regle_dossier_instruction_type'], 'regle_dossier_instruction_type'); |
} |
4834 |
|
if(preg_match("/date_evenement/",$row['regle_date_retour_contradictoire'])){ |
4835 |
|
$valF['date_retour_contradictoire']= $this->regle($row['regle_date_retour_contradictoire'], 'regle_date_retour_contradictoire'); |
4836 |
|
} |
4837 |
|
if(preg_match("/date_evenement/",$row['regle_date_ait'])){ |
4838 |
|
$valF['date_ait']= $this->regle($row['regle_date_ait'], 'regle_date_ait'); |
4839 |
|
} |
4840 |
|
if(preg_match("/date_evenement/",$row['regle_date_transmission_parquet'])){ |
4841 |
|
$valF['date_transmission_parquet']= $this->regle($row['regle_date_transmission_parquet'], 'regle_date_transmission_parquet'); |
4842 |
|
} |
4843 |
|
if ($row['regle_donnees_techniques1'] !== '') { |
4844 |
|
$valF_dt[$row['cible_regle_donnees_techniques1']] = $this->regle($row['regle_donnees_techniques1'], 'regle_donnees_techniques1'); |
4845 |
|
} |
4846 |
|
if ($row['regle_donnees_techniques2'] !== '') { |
4847 |
|
$valF_dt[$row['cible_regle_donnees_techniques2']] = $this->regle($row['regle_donnees_techniques2'], 'regle_donnees_techniques2'); |
4848 |
|
} |
4849 |
|
if ($row['regle_donnees_techniques3'] !== '') { |
4850 |
|
$valF_dt[$row['cible_regle_donnees_techniques3']] = $this->regle($row['regle_donnees_techniques3'], 'regle_donnees_techniques3'); |
4851 |
|
} |
4852 |
|
if ($row['regle_donnees_techniques4'] !== '') { |
4853 |
|
$valF_dt[$row['cible_regle_donnees_techniques4']] = $this->regle($row['regle_donnees_techniques4'], 'regle_donnees_techniques4'); |
4854 |
|
} |
4855 |
|
if ($row['regle_donnees_techniques5'] !== '') { |
4856 |
|
$valF_dt[$row['cible_regle_donnees_techniques5']] = $this->regle($row['regle_donnees_techniques5'], 'regle_donnees_techniques5'); |
4857 |
|
} |
4858 |
|
if ($row['regle_dossier_instruction_type'] !== '') { |
4859 |
|
$valF['dossier_instruction_type'] = $this->regle($row['regle_dossier_instruction_type'], 'regle_dossier_instruction_type'); |
4860 |
|
} |
4861 |
} |
} |
4862 |
} |
// Si des valeurs de données techniques ont été calculées alors on met à jour l'enregistrement |
4863 |
// Si des valeurs de données techniques ont été calculées alors on met à jour l'enregistrement |
if (count($valF_dt) > 0) { |
4864 |
if (count($valF_dt) > 0) { |
$dt_id = $this->getDonneesTechniques(); |
4865 |
$dt_id = $this->getDonneesTechniques(); |
// On met à jour le dossier |
4866 |
// On met à jour le dossier |
$cle = " donnees_techniques='".$dt_id."'"; |
4867 |
$cle = " donnees_techniques='".$dt_id."'"; |
$res1 = $this->f->db->autoExecute(DB_PREFIXE.'donnees_techniques', $valF_dt, DB_AUTOQUERY_UPDATE, $cle); |
4868 |
$res1 = $this->f->db->autoExecute(DB_PREFIXE.'donnees_techniques', $valF_dt, DB_AUTOQUERY_UPDATE, $cle); |
$this->addToLog( |
4869 |
$this->addToLog(__METHOD__."(): db->autoexecute(\"".DB_PREFIXE."donnees_techniques\", ".print_r($valF_dt, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
__METHOD__."(): db->autoexecute(\"".DB_PREFIXE."donnees_techniques\", ".print_r($valF_dt, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", |
4870 |
if (database::isError($res1)) { |
VERBOSE_MODE |
4871 |
die($res->getMessage()); |
); |
4872 |
|
$this->f->isDatabaseError($res1); |
4873 |
|
// Affichage d'informations à l'utilisateur |
4874 |
|
$this->addToMessage(__('enregistrement')." ".$this->valF['dossier']." ".__('table')." dossier [".$this->f->db->affectedRows()." ".__('enregistrement')." ".__('mis_a_jour')."]"); |
4875 |
} |
} |
4876 |
// Affichage d'informations à l'utilisateur |
// Si des valeurs ont été calculées alors on met à jour l'enregistrement |
4877 |
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$this->f->db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
if (count($valF) > 0) { |
4878 |
} |
$inst_dossier = $this->f->get_inst__om_dbform(array( |
4879 |
// Si des valeurs ont été calculées alors on met à jour l'enregistrement |
"obj" => "dossier", |
4880 |
if (count($valF) > 0) { |
"idx" => $this->valF['dossier'], |
4881 |
// |
)); |
4882 |
$inst_dossier = $this->f->get_inst__om_dbform(array( |
$valF['instruction'] = $id; |
4883 |
"obj" => "dossier", |
$valF['crud'] = 'update'; |
4884 |
"idx" => $this->valF['dossier'], |
$update_by_instruction = $inst_dossier->update_by_instruction($valF); |
4885 |
)); |
if ($update_by_instruction === false) { |
4886 |
$valF['instruction'] = $id; |
$this->cleanMessage(); |
4887 |
$valF['crud'] = 'update'; |
$this->addToMessage(sprintf('%s %s', __("Une erreur s'est produite lors de la mise à jour du dossier d'instruction."), __("Veuillez contacter votre administrateur."))); |
4888 |
$update_by_instruction = $inst_dossier->update_by_instruction($valF); |
return false; |
4889 |
if ($update_by_instruction === false) { |
} |
4890 |
$this->cleanMessage(); |
// Affichage d'informations à l'utilisateur |
4891 |
$this->addToMessage(sprintf('%s %s', __("Une erreur s'est produite lors de la mise à jour du dossier d'instruction."), __("Veuillez contacter votre administrateur."))); |
$this->addToMessage(__('enregistrement')." ".$this->valF['dossier']." ".__('table')." dossier [".$this->f->db->affectedRows()." ".__('enregistrement')." ".__('mis_a_jour')."]"); |
|
return false; |
|
4892 |
} |
} |
|
// Affichage d'informations à l'utilisateur |
|
|
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$this->f->db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
|
4893 |
} |
} |
4894 |
|
|
4895 |
|
// Par défaut les instructions à ajouter suite à la saisie d'une date |
4896 |
|
// de retour signature ou de notification, utilisent l'action 0 |
4897 |
|
// Si la création d'événement d'instruction suivant est déclenchée par |
4898 |
|
// une notification suite au traitement d'une tâche (démat') alors l'ajout |
4899 |
|
// de la nouvelle instruction se fait avec l'action 176 |
4900 |
|
// Cela permet de ne pas contrôler la restriction lors de l'ajout de la |
4901 |
|
// nouvelle instruction, depuis la méthode verifier() |
4902 |
|
$code_action_add = 0; |
4903 |
|
if ($this->getParameter("maj") == 175) { |
4904 |
|
$code_action_add = 176; |
4905 |
|
} |
4906 |
$restriction = $this->get_restriction($val['evenement']); |
$restriction = $this->get_restriction($val['evenement']); |
4907 |
$this->restriction_valid = $this->restrictionIsValid($restriction); |
$this->restriction_valid = $this->restrictionIsValid($restriction); |
4908 |
|
|
4909 |
if($restriction == "" || $this->restriction_valid ){ |
if($restriction == "" || $this->restriction_valid ){ |
4910 |
// 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é |
4911 |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
// TODO : remplacer cette requête par l'instanciation de l'evenement |
4912 |
WHERE evenement=".$this->valF['evenement']; |
$qres = $this->f->get_all_results_from_db_query( |
4913 |
$res = $this->f->db->query($sql); |
sprintf( |
4914 |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
'SELECT |
4915 |
if (database::isError($res)) { |
* |
4916 |
die($res->getMessage()); |
FROM |
4917 |
} |
%1$sevenement |
4918 |
|
WHERE |
4919 |
|
evenement = %2$d', |
4920 |
|
DB_PREFIXE, |
4921 |
|
intval($this->valF['evenement']) |
4922 |
|
), |
4923 |
|
array( |
4924 |
|
"origin" => __METHOD__ |
4925 |
|
) |
4926 |
|
); |
4927 |
$current_id = $this->getVal($this->clePrimaire); |
$current_id = $this->getVal($this->clePrimaire); |
4928 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
foreach ($qres['result'] as $row) { |
4929 |
// 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 |
4930 |
if ($this->getVal('date_retour_signature') == "" AND |
if ( |
4931 |
$this->valF['date_retour_signature'] != "" AND |
$this->getVal('date_retour_signature') == "" && |
4932 |
$row['evenement_retour_signature'] != "") { |
$this->valF['date_retour_signature'] != "" |
4933 |
$new_instruction = $this->f->get_inst__om_dbform(array( |
){ |
4934 |
"obj" => "instruction", |
// On Lance le hook |
4935 |
"idx" => "]", |
$data = array('val' => $this->valF); |
4936 |
)); |
$data['dossier'] = $this->valF['dossier']; |
4937 |
// Création d'un tableau avec la liste des champs de l'instruction |
$this->f->module_manager->run_hooks('update_date_retour_signature_pre', $this, $data); |
4938 |
foreach($new_instruction->champs as $champ) { |
|
4939 |
$valNewInstr[$champ] = ""; |
// On vérifie si il existe un événement automatique |
4940 |
} |
if ( |
4941 |
// Définition des valeurs de la nouvelle instruction |
$row['evenement_retour_signature'] != "" |
4942 |
$valNewInstr["evenement"] = $row['evenement_retour_signature']; |
) { |
4943 |
$valNewInstr["destinataire"] = $this->valF['destinataire']; |
$new_instruction = $this->f->get_inst__om_dbform(array( |
4944 |
$valNewInstr["dossier"] = $this->valF['dossier']; |
"obj" => "instruction", |
4945 |
$valNewInstr["date_evenement"] = $this->f->formatDate($this->valF['date_retour_signature']); |
"idx" => "]", |
4946 |
$valNewInstr["date_envoi_signature"] = $this->f->formatDate($this->valF['date_envoi_signature']); |
)); |
4947 |
$valNewInstr["date_retour_signature"] = $this->f->formatDate($this->valF['date_retour_signature']); |
// Création d'un tableau avec la liste des champs de l'instruction |
4948 |
$valNewInstr["date_envoi_rar"] = $this->f->formatDate($this->valF['date_envoi_rar']); |
foreach($new_instruction->champs as $champ) { |
4949 |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
$valNewInstr[$champ] = ""; |
4950 |
$valNewInstr["date_envoi_controle_legalite"] = $this->f->formatDate($this->valF['date_envoi_controle_legalite']); |
} |
4951 |
$valNewInstr["date_retour_controle_legalite"] = $this->f->formatDate($this->valF['date_retour_controle_legalite']); |
// Définition des valeurs de la nouvelle instruction |
4952 |
$new_instruction->setParameter("maj", 0); |
$valNewInstr["evenement"] = $row['evenement_retour_signature']; |
4953 |
$new_instruction->class_actions[0]["identifier"] = |
$valNewInstr["destinataire"] = $this->valF['destinataire']; |
4954 |
"retour signature de l'instruction $current_id"; |
$valNewInstr["dossier"] = $this->valF['dossier']; |
4955 |
$retour = $new_instruction->ajouter($valNewInstr); |
$valNewInstr["date_evenement"] = $this->f->formatDate($this->valF['date_retour_signature']); |
4956 |
|
$valNewInstr["date_envoi_signature"] = $this->f->formatDate($this->valF['date_envoi_signature']); |
4957 |
//Si une erreur s'est produite et qu'il s'agit d'un problème |
$valNewInstr["date_retour_signature"] = $this->f->formatDate($this->valF['date_retour_signature']); |
4958 |
//de restriction |
$valNewInstr["date_envoi_rar"] = $this->f->formatDate($this->valF['date_envoi_rar']); |
4959 |
if ($retour == false && !$new_instruction->restriction_valid){ |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
4960 |
$error_message = $this->get_restriction_error_message($restriction); |
$valNewInstr["date_envoi_controle_legalite"] = $this->f->formatDate($this->valF['date_envoi_controle_legalite']); |
4961 |
$this->f->displayMessage("error", $error_message); |
$valNewInstr["date_retour_controle_legalite"] = $this->f->formatDate($this->valF['date_retour_controle_legalite']); |
4962 |
$this->addToLog(__METHOD__."(): evenement retour ". |
$new_instruction->setParameter("maj", $code_action_add); |
4963 |
"instruction ".$this->valF[$this->clePrimaire]." : ". |
$new_instruction->class_actions[$code_action_add]["identifier"] = |
4964 |
$new_instruction->msg); |
sprintf( |
4965 |
} |
__("Ajout suite au retour signature de l'instruction %s"), |
4966 |
//Si une erreur s'est produite après le test de la restriction |
$current_id |
4967 |
elseif ($retour == false && $new_instruction->restriction_valid){ |
); |
4968 |
$this->correct = false ; |
$retour = $new_instruction->ajouter($valNewInstr); |
4969 |
$this->msg .= $new_instruction->msg; |
|
4970 |
return false; |
//Si une erreur s'est produite et qu'il s'agit d'un problème |
4971 |
|
//de restriction |
4972 |
|
if ($retour == false && !$new_instruction->restriction_valid){ |
4973 |
|
$error_message = $this->get_restriction_error_message($restriction); |
4974 |
|
$this->f->displayMessage("error", $error_message); |
4975 |
|
$this->addToLog(__METHOD__."(): evenement retour ". |
4976 |
|
"instruction ".$this->valF[$this->clePrimaire]." : ". |
4977 |
|
$new_instruction->msg); |
4978 |
|
} |
4979 |
|
//Si une erreur s'est produite après le test de la restriction |
4980 |
|
elseif ($retour == false && $new_instruction->restriction_valid){ |
4981 |
|
$this->correct = false ; |
4982 |
|
$this->msg .= $new_instruction->msg; |
4983 |
|
return false; |
4984 |
|
} |
4985 |
} |
} |
4986 |
|
|
4987 |
|
$this->f->module_manager->run_hooks('update_date_retour_signature_post', $this, $data); |
4988 |
} |
} |
4989 |
// Si la date de retour AR est éditée on vérifie si il existe un événement automatique |
|
4990 |
if ($this->getVal('date_retour_rar') == "" AND |
// Si la date de retour AR est éditée |
4991 |
$this->valF['date_retour_rar'] != "") { |
if ( |
4992 |
|
$this->getVal('date_retour_rar') == "" && |
4993 |
if($row['evenement_retour_ar'] != "") { |
$this->valF['date_retour_rar'] != "" |
4994 |
|
){ |
4995 |
|
// On Lance le hook Notification/Date retour Accusée Reception |
4996 |
|
$data = array('val' => $this->valF); |
4997 |
|
$data['dossier'] = $this->valF['dossier']; |
4998 |
|
$this->f->module_manager->run_hooks('update_date_retour_rar_pre', $this, $data); |
4999 |
|
|
5000 |
|
// On vérifie si il existe un événement automatique |
5001 |
|
if ( $row['evenement_retour_ar'] != "" ) { |
5002 |
$new_instruction = $this->f->get_inst__om_dbform(array( |
$new_instruction = $this->f->get_inst__om_dbform(array( |
5003 |
"obj" => "instruction", |
"obj" => "instruction", |
5004 |
"idx" => "]", |
"idx" => "]", |
5018 |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
5019 |
$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']); |
5020 |
$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']); |
5021 |
$new_instruction->setParameter("maj", 0); |
$new_instruction->setParameter("maj", $code_action_add); |
5022 |
$new_instruction->class_actions[0]["identifier"] = |
$new_instruction->class_actions[$code_action_add]["identifier"] = |
5023 |
"notification de l'instruction $current_id"; |
sprintf(__("Ajout suite à la notification de l'instruction %s"), $current_id); |
5024 |
$retour = $new_instruction->ajouter($valNewInstr); |
$retour = $new_instruction->ajouter($valNewInstr); |
5025 |
|
|
5026 |
//Si une erreur s'est produite et qu'il s'agit d'un problème |
//Si une erreur s'est produite et qu'il s'agit d'un problème |
5041 |
return false; |
return false; |
5042 |
} |
} |
5043 |
} |
} |
5044 |
|
$this->f->module_manager->run_hooks('update_date_retour_rar_post', $this, $data); |
5045 |
|
} |
5046 |
|
|
5047 |
|
// Si la date_envoi_signature est éditée |
5048 |
|
if ( |
5049 |
|
$this->getVal('date_envoi_signature') == "" && |
5050 |
|
$this->valF['date_envoi_signature'] != "" |
5051 |
|
){ |
5052 |
|
// On Lance le hook |
5053 |
|
$data = array('val' => $this->valF); |
5054 |
|
$data['dossier'] = $this->valF['dossier']; |
5055 |
|
$this->f->module_manager->run_hooks('update_date_envoi_signature', $this, $data); |
5056 |
|
} |
5057 |
|
// Si la date de envoi AR est éditée |
5058 |
|
if ( |
5059 |
|
$this->getVal('date_envoi_rar') == "" && |
5060 |
|
$this->valF['date_envoi_rar'] != "" |
5061 |
|
){ |
5062 |
|
// On Lance le hook |
5063 |
|
$data = array('val' => $this->valF); |
5064 |
|
$data['dossier'] = $this->valF['dossier']; |
5065 |
|
$this->f->module_manager->run_hooks('update_date_envoi_rar', $this, $data); |
5066 |
|
} |
5067 |
|
// Si la date de envoi controle legalite est éditée |
5068 |
|
if ( |
5069 |
|
$this->getVal('date_envoi_controle_legalite') == "" && |
5070 |
|
$this->valF['date_envoi_controle_legalite'] != "" |
5071 |
|
){ |
5072 |
|
// On Lance le hook |
5073 |
|
$data = array('val' => $this->valF); |
5074 |
|
$data['dossier'] = $this->valF['dossier']; |
5075 |
|
$this->f->module_manager->run_hooks('update_date_envoi_controle_legalite', $this, $data); |
5076 |
|
} |
5077 |
|
// Si la date de retour controle legalite est éditée |
5078 |
|
if ( |
5079 |
|
$this->getVal('date_retour_controle_legalite') == "" && |
5080 |
|
$this->valF['date_retour_controle_legalite'] != "" |
5081 |
|
){ |
5082 |
|
// On Lance le hook |
5083 |
|
$data = array('val' => $this->valF); |
5084 |
|
$data['dossier'] = $this->valF['dossier']; |
5085 |
|
$this->f->module_manager->run_hooks('update_date_retour_controle_legalite', $this, $data); |
5086 |
} |
} |
5087 |
} |
} |
5088 |
} |
} |
5089 |
|
|
5090 |
/** |
// Traitement en cas de mise à jour du dossier |
5091 |
* Mise à jour de la date de dernière modification du dossier |
if ($update_dossier === true) { |
5092 |
* d'instruction |
/** |
5093 |
*/ |
* Mise à jour de la date de dernière modification du dossier |
5094 |
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
* d'instruction |
5095 |
$inst_di->update_last_modification_date(); |
*/ |
5096 |
|
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
5097 |
|
$inst_di->update_last_modification_date(); |
5098 |
|
|
5099 |
// Mise à jour des données du dossier d'autorisation |
// Mise à jour des données du dossier d'autorisation |
5100 |
$da = $this->f->get_inst__om_dbform(array( |
$da = $this->f->get_inst__om_dbform(array( |
5101 |
"obj" => "dossier_autorisation", |
"obj" => "dossier_autorisation", |
5102 |
"idx" => $this->getNumDemandeAutorFromDossier($this->valF['dossier']), |
"idx" => $this->getNumDemandeAutorFromDossier($this->valF['dossier']), |
5103 |
)); |
)); |
5104 |
$params = array( |
$params = array( |
5105 |
'di_id' => $this->getVal('dossier'), |
'di_id' => $this->getVal('dossier'), |
5106 |
); |
); |
5107 |
if($da->majDossierAutorisation($params) === false) { |
if($da->majDossierAutorisation($params) === false) { |
5108 |
$this->addToMessage(_("Erreur lors de la mise a jour des donnees du dossier d'autorisation. Contactez votre administrateur.")); |
$this->addToMessage(__("Erreur lors de la mise a jour des donnees du dossier d'autorisation. Contactez votre administrateur.")); |
5109 |
$this->correct = false; |
$this->correct = false; |
5110 |
return false; |
return false; |
5111 |
|
} |
5112 |
} |
} |
5113 |
|
|
5114 |
// mise à jour des métadonnées issues des dates de suivi |
// mise à jour des métadonnées issues des dates de suivi |
5120 |
$metadata = $this->getMetadata("om_fichier_instruction"); |
$metadata = $this->getMetadata("om_fichier_instruction"); |
5121 |
|
|
5122 |
// 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 |
5123 |
$sql = "SELECT type FROM ".DB_PREFIXE."evenement WHERE evenement = ".$this->getVal("evenement"); |
// TODO : A voir pour remplacer par une instanciation de l'événement. |
5124 |
$typeEvenement = $this->f->db->getOne($sql); |
// Voir également si l'événement ne dois pas être instancié en début de |
5125 |
$this->addToLog(__METHOD__."(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
// méthode pour pouvoir être réutilisé. |
5126 |
if ($this->f->isDatabaseError($typeEvenement, true) === true) { |
$qres = $this->f->get_one_result_from_db_query( |
5127 |
|
sprintf( |
5128 |
|
'SELECT |
5129 |
|
type |
5130 |
|
FROM |
5131 |
|
%1$sevenement |
5132 |
|
WHERE |
5133 |
|
evenement = \'%2$d\'', |
5134 |
|
DB_PREFIXE, |
5135 |
|
intval($this->getVal("evenement")) |
5136 |
|
), |
5137 |
|
array( |
5138 |
|
"origin" => __METHOD__, |
5139 |
|
"force_return" => true, |
5140 |
|
) |
5141 |
|
); |
5142 |
|
|
5143 |
|
if ($qres["code"] !== "OK") { |
5144 |
$this->correct = false; |
$this->correct = false; |
5145 |
$this->addToMessage(__("Erreur de traitement de fichier.")); |
$this->addToMessage(__("Erreur de traitement de fichier.")); |
5146 |
$this->addToLog(__METHOD__."() erreur BDD: ".var_export($typeEvenement->getMessage(), true), DEBUG_MODE); |
$this->addToLog(__METHOD__."() erreur BDD: ".var_export($qres['message'], true), DEBUG_MODE); |
5147 |
return false; |
return false; |
5148 |
} |
} |
5149 |
|
|
5150 |
// 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 |
5151 |
if ($typeEvenement == 'arrete'){ |
if ($qres['result'] == 'arrete'){ |
5152 |
$metadata = array_merge($metadata, $this->getMetadata("arrete")); |
$metadata = array_merge($metadata, $this->getMetadata("arrete")); |
5153 |
} |
} |
5154 |
|
|
5196 |
} |
} |
5197 |
} |
} |
5198 |
|
|
5199 |
// Notification auto des demandeurs |
// Déclenchement des notifications automatique après finalisation et |
5200 |
|
// retour de signature |
5201 |
if ($dateRetourSignatureModified === true |
if ($dateRetourSignatureModified === true |
5202 |
&& $this->valF['date_retour_signature'] !== '' |
&& $this->valF['date_retour_signature'] !== '' |
5203 |
&& $this->valF['date_retour_signature'] !== null) { |
&& $this->valF['date_retour_signature'] !== null) { |
5204 |
// |
|
5205 |
|
// Message à afficher dans les logs pour indiquer quelle notification a échouée |
5206 |
|
$msgLog = sprintf( |
5207 |
|
'%s %s : %d', |
5208 |
|
__('Erreur lors de la notification automatique du(des) pétitionnaire(s) après retour signature.'), |
5209 |
|
__('Instruction notifiée'), |
5210 |
|
$id |
5211 |
|
); |
5212 |
|
|
5213 |
|
// Récupération de l'instance de l'événement pour accéder au paramètrage |
5214 |
|
// des notifications |
5215 |
$ev = $this->get_inst_evenement($this->valF['evenement']); |
$ev = $this->get_inst_evenement($this->valF['evenement']); |
5216 |
|
// Si la notification automatique des tiers consulté est active |
5217 |
|
// déclenche le traitement de notification. |
5218 |
|
// Ce traitement va envoyer des courriels de notification à tous les tiers concernés |
5219 |
|
$typeNotifTiers = $ev->getVal('notification_tiers'); |
5220 |
|
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
5221 |
|
if ($typeNotifTiers === 'notification_automatique') { |
5222 |
|
if ($this->traitement_notification_automatique_tiers_consulte($ev, $inst_di) === false) { |
5223 |
|
$this->addToMessage(__('Le traitement de la notification automatique de tiers à échoué.')); |
5224 |
|
$this->correct = false; |
5225 |
|
} |
5226 |
|
} |
5227 |
|
|
5228 |
if ($ev->getVal('notification') === 'notification_auto_signature_requise') { |
if ($ev->getVal('notification') === 'notification_auto_signature_requise') { |
5229 |
// 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 |
5230 |
$categorie = $this->f->get_param_option_notification($collectivite_di); |
$categorie = $this->f->get_param_option_notification($collectivite_di); |
5231 |
$isPortal = $categorie == null || $categorie == '' || $categorie == 'portal' ? true : false; |
$isPortal = $categorie === PORTAL; |
5232 |
$demandeursANotifie = $this->get_demandeurs_notifiable( |
$demandeursANotifie = $this->get_demandeurs_notifiable( |
5233 |
$this->valF['dossier'], |
$this->valF['dossier'], |
5234 |
$isPortal |
$isPortal |
5235 |
); |
); |
5236 |
|
|
5237 |
|
// |
5238 |
|
$msg_notif = ''; |
5239 |
|
|
5240 |
// Création d'une notification et d'une tâche pour chaque demandeur à notifier |
// Création d'une notification et d'une tâche pour chaque demandeur à notifier |
5241 |
$demandeurPrincipalNotifie = false; |
$demandeurPrincipalNotifie = false; |
5242 |
foreach ($demandeursANotifie as $demandeur) { |
foreach ($demandeursANotifie as $demandeur) { |
5256 |
continue; |
continue; |
5257 |
} |
} |
5258 |
} |
} |
5259 |
// Ajout de la notif et récupération de son id |
// Récupération du contenu de l'option option_bloquer_notif_auto_dln |
5260 |
$idNotif = $this->ajouter_notification( |
$option_bloquer_notif_auto_dln_types_evenements = $this->f->getParameter("option_bloquer_notif_auto_dln") !== null ? explode(';', $this->f->getParameter("option_bloquer_notif_auto_dln")) : null; |
5261 |
$this->valF[$this->clePrimaire], |
// On vérifie l'existence du paramètre 'option_bloquer_notif_auto_dln', |
5262 |
$this->f->get_connected_user_login_name(), |
// On vérifie si la date limite est dépassée ou si le type d'événement est erroné |
5263 |
$demandeur, |
if (! empty($option_bloquer_notif_auto_dln_types_evenements) |
5264 |
$collectivite_di, |
&& $this->is_type_evenement_autorise($ev, array('types_evenements_autorises'=> $option_bloquer_notif_auto_dln_types_evenements)) === true |
5265 |
array(), |
&& $this->is_date_limite_notification_premier_mois_depasee() === true) { |
5266 |
true |
// Ajout de la notif et récupération de son id |
5267 |
); |
$idNotif = $this->ajouter_notification( |
5268 |
if ($idNotif === false) { |
$this->valF[$this->clePrimaire], |
5269 |
return false; |
$this->f->get_connected_user_login_name(), |
5270 |
|
$demandeur, |
5271 |
|
$collectivite_di, |
5272 |
|
array(), |
5273 |
|
true, |
5274 |
|
'Echec', |
5275 |
|
__('La date limite de notification au demandeur est dépassée') |
5276 |
|
); |
5277 |
|
if ($idNotif === false) { |
5278 |
|
// Termine le traitement |
5279 |
|
$this->addToLog( |
5280 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
5281 |
|
DEBUG_MODE |
5282 |
|
); |
5283 |
|
return $this->end_treatment(__METHOD__, false); |
5284 |
|
} |
5285 |
|
$msg_notif .= sprintf('%s<br/>%s', __("La notification n'a pas été générée, car la date limite de notification au demandeur est dépassée."), __("Le suivi de la notification est disponible depuis l'instruction.")); |
5286 |
} |
} |
5287 |
// Création de la tache en lui donnant l'id de la notification |
else { |
5288 |
$notification_by_task = $this->notification_by_task( |
// Ajout de la notif et récupération de son id |
5289 |
$idNotif, |
$idNotif = $this->ajouter_notification( |
5290 |
$this->valF['dossier'], |
$this->valF[$this->clePrimaire], |
5291 |
$categorie |
$this->f->get_connected_user_login_name(), |
5292 |
); |
$demandeur, |
5293 |
if ($notification_by_task === false) { |
$collectivite_di, |
5294 |
$this->addToMessage( |
array(), |
5295 |
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
true |
5296 |
); |
); |
5297 |
return false; |
if ($idNotif === false) { |
5298 |
|
$this->addToLog( |
5299 |
|
sprintf('%s() : %s',__METHOD__, $msgLog), |
5300 |
|
DEBUG_MODE |
5301 |
|
); |
5302 |
|
return false; |
5303 |
|
} |
5304 |
|
// Création de la tache en lui donnant l'id de la notification |
5305 |
|
$notification_by_task = $this->notification_by_task( |
5306 |
|
$idNotif, |
5307 |
|
$this->valF['dossier'], |
5308 |
|
$categorie |
5309 |
|
); |
5310 |
|
if ($notification_by_task === false) { |
5311 |
|
$this->addToLog( |
5312 |
|
sprintf('%s() : %s',__METHOD__, $msgLog), |
5313 |
|
DEBUG_MODE |
5314 |
|
); |
5315 |
|
$this->addToMessage( |
5316 |
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
5317 |
|
); |
5318 |
|
return false; |
5319 |
|
} |
5320 |
|
$msg_notif .= sprintf('%s<br/>%s', __("La notification a été générée."), __("Le suivi de la notification est disponible depuis l'instruction.")); |
5321 |
} |
} |
5322 |
} |
} |
5323 |
// Si le demandeur principal n'est pas notifiable, on créé une nouvelle notification |
|
5324 |
// en erreur avec en commentaire la raison pour laquelle le demandeur principal |
// Pour la notification par mail ou la notification via portal si le dossier a |
5325 |
// n'a pas pu être notifié |
// été déposés via portal, si le demandeur principal n'est pas notifiable, |
5326 |
if (! $demandeurPrincipalNotifie) { |
// on créé une nouvelle notification en erreur avec en commentaire la raison pour |
5327 |
|
// laquelle le demandeur principal n'a pas pu être notifié |
5328 |
|
$depotPortal = $this->dossier_depose_sur_portail(); |
5329 |
|
if (! $demandeurPrincipalNotifie && ($isPortal === false || $depotPortal === true)) { |
5330 |
|
// Précise dans les logs que le pétitionnaire principal n'a pas été notifié |
5331 |
|
$msgLog .= sprintf(' %s', __('Le pétitionnaire principale n\'est pas notifiable.')); |
5332 |
// Analyse pour savoir pourquoi le demandeur principal n'est pas notifiable |
// Analyse pour savoir pourquoi le demandeur principal n'est pas notifiable |
5333 |
$erreursParam = $this->get_info_notification_fail(); |
$erreursParam = $this->get_info_notification_fail(); |
5334 |
$demandeurPrincipal = $this->get_info_petitionnaire_principal_dossier($this->getVal('dossier')); |
$demandeurPrincipal = $this->get_info_petitionnaire_principal_dossier($this->getVal('dossier')); |
5344 |
implode(' ', $erreursParam) |
implode(' ', $erreursParam) |
5345 |
); |
); |
5346 |
if ($idNotif === false) { |
if ($idNotif === false) { |
5347 |
|
$this->addToLog( |
5348 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
5349 |
|
DEBUG_MODE |
5350 |
|
); |
5351 |
$this->addToMessage( |
$this->addToMessage( |
5352 |
__('Erreur : la création de la notification a échouée.'). |
__('Erreur : la création de la notification a échouée.'). |
5353 |
__("Veuillez contacter votre administrateur.") |
__("Veuillez contacter votre administrateur.") |
5359 |
$dossier_message = $this->get_inst_dossier_message(0); |
$dossier_message = $this->get_inst_dossier_message(0); |
5360 |
$dossier_message_val = array( |
$dossier_message_val = array( |
5361 |
'dossier' => $this->getVal('dossier'), |
'dossier' => $this->getVal('dossier'), |
5362 |
'type' => _('erreur expedition'), |
'type' => __('erreur expedition'), |
5363 |
'emetteur' => $this->f->get_connected_user_login_name(), |
'emetteur' => $this->f->get_connected_user_login_name(), |
5364 |
'login' => $_SESSION['login'], |
'login' => $_SESSION['login'], |
5365 |
'date_emission' => date('Y-m-d H:i:s'), |
'date_emission' => date('Y-m-d H:i:s'), |
5366 |
'contenu' => _('Échec lors de la notification de l\'instruction '). |
'contenu' => __('Échec lors de la notification de l\'instruction '). |
5367 |
$ev->getVal('libelle'). |
$ev->getVal('libelle'). |
5368 |
'.<br>'. |
'.<br>'. |
5369 |
implode("\n", $erreursParam). |
implode("\n", $erreursParam). |
5370 |
'<br>'. |
'<br>'. |
5371 |
_('Veuillez corriger ces informations avant de renvoyer la notification.') |
__('Veuillez corriger ces informations avant de renvoyer la notification.') |
5372 |
); |
); |
5373 |
$add = $dossier_message->add_notification_message($dossier_message_val, true); |
$add = $dossier_message->add_notification_message($dossier_message_val, true); |
5374 |
// Si une erreur se produit pendant l'ajout |
// Si une erreur se produit pendant l'ajout |
5375 |
if ($add !== true) { |
if ($add !== true) { |
5376 |
$this->addToLog(__METHOD__."(): Le message d'alerte concernant l'echec de l'envoi de la notification n'a pas pu être envoyé.", DEBUG_MODE); |
$this->addToLog( |
5377 |
|
sprintf( |
5378 |
|
'%s() : %s', |
5379 |
|
__METHOD__, |
5380 |
|
__("Le message d'alerte concernant l'echec de l'envoi de la notification n'a pas pu être envoyé.") |
5381 |
|
), |
5382 |
|
DEBUG_MODE |
5383 |
|
); |
5384 |
return false; |
return false; |
5385 |
} |
} |
5386 |
} |
} |
5387 |
$this->addToMessage($message .= sprintf('%s<br/>%s', __("La notification a été générée."), __("Le suivi de la notification est disponible depuis l'instruction."))); |
$this->addToMessage($msg_notif); |
5388 |
} |
} |
5389 |
} |
} |
5390 |
|
// Assigner les champs 'valF' à 'val' lorsque la modification a réussi |
5391 |
return $this->add_log_to_dossier($id, $val); |
if ($res !== false) { |
5392 |
|
foreach($this->champs as $index => $champ) { |
5393 |
|
// if (get_class($this) == 'instruction') { |
5394 |
|
$this->f->log(__METHOD__, "[".var_export(get_class($this), true)."] this->valF[$champ]): ".var_export($this->valF[$champ] ?? null, true).", this->val[$index]: ".var_export($this->val[$index] ?? null, true), 'DEBUG', 'seb'); |
5395 |
|
// } |
5396 |
|
$this->val[$index] = $this->valF[$champ] ?? null; |
5397 |
|
} |
5398 |
|
} |
5399 |
|
$res = $this->add_log_to_dossier($id, $val); |
5400 |
|
$data = array('val' => &$val, 'id' => $id, 'result' => &$res); |
5401 |
|
$this->f->module_manager->run_hooks('triggermodifierapres_post', $this, $data); |
5402 |
|
return $res; |
5403 |
} |
} |
5404 |
|
|
5405 |
/** |
/** |
5409 |
*/ |
*/ |
5410 |
function triggersupprimer($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
function triggersupprimer($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
5411 |
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
5412 |
|
$data = array('val' => &$val, 'id' => $id); |
5413 |
|
$this->f->module_manager->run_hooks('triggersupprimer_pre', $this, $data); |
5414 |
/** |
/** |
5415 |
* 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 |
5416 |
* archive dans le dossier d'instruction avant de supprimer l'événement |
* archive dans le dossier d'instruction avant de supprimer l'événement |
5425 |
// est différente |
// est différente |
5426 |
if ($inst_di->getVal($champ) !== $val[sprintf('archive_%s', $champ)]) { |
if ($inst_di->getVal($champ) !== $val[sprintf('archive_%s', $champ)]) { |
5427 |
$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)]; |
5428 |
|
// Gestion du cas particulier 'accord_tacite' pour renvoyer la valeur ' ' (3 espaces vides) au lieu de null |
5429 |
|
// Car les valeurs possibles du champ accord_tacite sont : 'Oui', 'Non' ou ' ' |
5430 |
|
if ($champ === "accord_tacite" && $valF[$champ] === null) { |
5431 |
|
$valF[$champ] = ' '; |
5432 |
|
} |
5433 |
} |
} |
5434 |
} |
} |
5435 |
} |
} |
5504 |
'notification_decision', |
'notification_decision', |
5505 |
'notification_service_consulte', |
'notification_service_consulte', |
5506 |
'notification_tiers_consulte', |
'notification_tiers_consulte', |
5507 |
|
'notification_depot_demat', |
5508 |
|
'notification_commune', |
5509 |
|
'notification_signataire' |
5510 |
), |
), |
5511 |
true |
true |
5512 |
); |
); |
5533 |
} |
} |
5534 |
} |
} |
5535 |
|
|
5536 |
|
// Suppression du paramétrage de l'annexe lié à l'évènement |
5537 |
|
if ($this->supprimer_parametrage_annexe($this->getVal($this->clePrimaire)) === false) { |
5538 |
|
$this->addToLog(sprintf( |
5539 |
|
"%s %s", |
5540 |
|
__("Erreur lors de la suppression du paramétrage des annexes de l'instruction."), |
5541 |
|
__("Veuillez contacter votre administrateur.") |
5542 |
|
), DEBUG_MODE); |
5543 |
|
return false; |
5544 |
|
} |
5545 |
|
|
5546 |
// On met à jour le dossier |
// On met à jour le dossier |
5547 |
$valF['instruction'] = $id; |
$valF['instruction'] = $id; |
5548 |
$valF['crud'] = 'delete'; |
$valF['crud'] = 'delete'; |
5554 |
} |
} |
5555 |
|
|
5556 |
// Affichage d'informations à l'utilisateur |
// Affichage d'informations à l'utilisateur |
5557 |
$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')."]"); |
5558 |
|
|
5559 |
// 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 |
5560 |
|
|
5561 |
|
$res = true; |
5562 |
|
$data = array('val' => &$val, 'id' => $id, 'result' => &$res); |
5563 |
|
$this->f->module_manager->run_hooks('triggersupprimer_post', $this, $data); |
5564 |
|
return $res; |
5565 |
} |
} |
5566 |
|
|
5567 |
/** |
/** |
5571 |
*/ |
*/ |
5572 |
function triggersupprimerapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
function triggersupprimerapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
5573 |
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
5574 |
|
$data = array('val' => &$val, 'id' => $id); |
5575 |
|
$this->f->module_manager->run_hooks('triggersupprimerapres_pre', $this, $data); |
5576 |
/** |
/** |
5577 |
* Mise à jour de la date de dernière modification du dossier |
* Mise à jour de la date de dernière modification du dossier |
5578 |
* d'instruction |
* d'instruction |
5592 |
'di_reopened' => $this->get_att_di_reopened(), |
'di_reopened' => $this->get_att_di_reopened(), |
5593 |
); |
); |
5594 |
if($da->majDossierAutorisation($params) === false) { |
if($da->majDossierAutorisation($params) === false) { |
5595 |
$this->addToMessage(_("Erreur lors de la mise a jour des donnees du dossier d'autorisation. Contactez votre administrateur.")); |
$this->addToMessage(__("Erreur lors de la mise a jour des donnees du dossier d'autorisation. Contactez votre administrateur.")); |
5596 |
$this->correct = false; |
$this->correct = false; |
5597 |
return false; |
return false; |
5598 |
} |
} |
5611 |
"obj" => "task", |
"obj" => "task", |
5612 |
"idx" => $task_exists, |
"idx" => $task_exists, |
5613 |
)); |
)); |
5614 |
if ($inst_task->getVal('state') === $inst_task::STATUS_NEW || $inst_task->getVal('state') === $inst_task::STATUS_DRAFT) { |
if ($inst_task->getVal('state') === task::STATUS_NEW || $inst_task->getVal('state') === task::STATUS_DRAFT) { |
5615 |
$task_val = array( |
$task_val = array( |
5616 |
'state' => $inst_task::STATUS_CANCELED, |
'state' => task::STATUS_CANCELED, |
5617 |
); |
); |
5618 |
$update_task = $inst_task->update_task(array('val' => $task_val)); |
$update_task = $inst_task->update_task(array('val' => $task_val)); |
5619 |
if ($update_task === false) { |
if ($update_task === false) { |
5630 |
|
|
5631 |
// |
// |
5632 |
$val['evenement'] = $this->getVal('evenement'); |
$val['evenement'] = $this->getVal('evenement'); |
5633 |
return $this->add_log_to_dossier($id, $val); |
$res = $this->add_log_to_dossier($id, $val); |
5634 |
|
$data = array('val' => &$val, 'id' => $id, 'result' => &$res); |
5635 |
|
$this->f->module_manager->run_hooks('triggersupprimerapres_post', $this, $data); |
5636 |
|
return $res; |
5637 |
} |
} |
5638 |
|
|
5639 |
/** |
/** |
5666 |
function get_restriction_error_message($restriction) { |
function get_restriction_error_message($restriction) { |
5667 |
// Affichage du message si la restriction s'applique |
// Affichage du message si la restriction s'applique |
5668 |
// Contexte du suivi des dates (message simple) |
// Contexte du suivi des dates (message simple) |
5669 |
$message_restrict = _("Probleme de dates :"); |
$message_restrict = __("Probleme de dates :"); |
5670 |
// Split restriction |
// Split restriction |
5671 |
$champs_restrict = preg_split( |
$champs_restrict = preg_split( |
5672 |
'/(\W+)/', |
'/(\W+)/', |
5677 |
$formated_restrict = ""; |
$formated_restrict = ""; |
5678 |
// Ajout des chaînes à traduire |
// Ajout des chaînes à traduire |
5679 |
foreach ($champs_restrict as $value) { |
foreach ($champs_restrict as $value) { |
5680 |
$formated_restrict .= _($value)." "; |
$formated_restrict .= __($value)." "; |
5681 |
} |
} |
5682 |
$formated_restrict = substr($formated_restrict, 0, -1); |
$formated_restrict = substr($formated_restrict, 0, -1); |
5683 |
// Message d'erreur dans le contexte du suivi des dates |
// Message d'erreur dans le contexte du suivi des dates |
5684 |
if($this->getParameter("maj") == 170) { |
if($this->getParameter("maj") == 170) { |
5685 |
$message_restrict .= " "._("contactez l'instructeur du dossier"); |
$message_restrict .= " ".__("contactez l'instructeur du dossier"); |
5686 |
$message_restrict .= "<br/>(".$formated_restrict.")"; |
$message_restrict .= "<br/>(".$formated_restrict.")"; |
5687 |
} else { |
} else { |
5688 |
// Affichage du message si la restriction s'applique |
// Affichage du message si la restriction s'applique |
5723 |
//Test qu'une restriction est présente |
//Test qu'une restriction est présente |
5724 |
if ($restriction != "" ){ |
if ($restriction != "" ){ |
5725 |
|
|
5726 |
//Test si la restriction est valide |
// Vérifie le contexte de la modification et test si la restriction est valide. |
5727 |
|
// Si l'instruction est modifiée par une tache le dossier n'est pas impacté. |
5728 |
|
// Il n'est donc pas nécessaire de vérifier les restrictions. |
5729 |
$this->restriction_valid = $this->restrictionIsValid($restriction); |
$this->restriction_valid = $this->restrictionIsValid($restriction); |
5730 |
if ( !$this->restriction_valid ){ |
if ($this->getParameter("maj") != 176 |
5731 |
|
&& !$this->restriction_valid) { |
5732 |
|
|
5733 |
// Affichage du message si la restriction s'applique |
// Affichage du message si la restriction s'applique |
5734 |
$this->addToMessage( |
$this->addToMessage( |
5763 |
$string_error_fields = implode(", ", $check_field_exist); |
$string_error_fields = implode(", ", $check_field_exist); |
5764 |
|
|
5765 |
// Message d'erreur |
// Message d'erreur |
5766 |
$error_message = _("Le champ %s n'est pas utilisable pour le champ %s"); |
$error_message = __("Le champ %s n'est pas utilisable pour le champ %s"); |
5767 |
if (count($check_field_exist) > 1) { |
if (count($check_field_exist) > 1) { |
5768 |
$error_message = _("Les champs %s ne sont pas utilisable pour le champ %s"); |
$error_message = __("Les champs %s ne sont pas utilisable pour le champ %s"); |
5769 |
} |
} |
5770 |
|
|
5771 |
// Affiche l'erreur |
// Affiche l'erreur |
5772 |
$this->correct=false; |
$this->correct=false; |
5773 |
$this->addToMessage(sprintf($error_message, $string_error_fields, _("restriction"))); |
$this->addToMessage(sprintf($error_message, $string_error_fields, __("restriction"))); |
5774 |
$this->addToMessage(_("Veuillez contacter votre administrateur.")); |
$this->addToMessage(__("Veuillez contacter votre administrateur.")); |
5775 |
} |
} |
5776 |
} |
} |
5777 |
|
|
5809 |
* @param string identifiant du dossier |
* @param string identifiant du dossier |
5810 |
* @return array|boolean |
* @return array|boolean |
5811 |
*/ |
*/ |
5812 |
protected function get_info_petitionnaire_principal_dossier($dossier = null) { |
public function get_info_petitionnaire_principal_dossier($dossier = null) { |
5813 |
// Si l'identifiant de l'instruction n'a pas été fournit on récupère celui de |
// Si l'identifiant de l'instruction n'a pas été fournit on récupère celui de |
5814 |
// l'objet courant |
// l'objet courant |
5815 |
if (empty($dossier)) { |
if (empty($dossier)) { |
5824 |
|
|
5825 |
// Requête sql servant à récupérer toutes les informations relatives au demandeurs |
// Requête sql servant à récupérer toutes les informations relatives au demandeurs |
5826 |
// principal |
// principal |
5827 |
$sql = sprintf( |
$qres = $this->f->get_all_results_from_db_query( |
5828 |
'SELECT |
sprintf( |
5829 |
-- Récupère toutes les informations du demandeur principal |
'SELECT |
5830 |
demandeur.*, |
-- Récupère toutes les informations du demandeur principal |
5831 |
CASE |
demandeur.*, |
5832 |
WHEN demandeur.qualite=\'particulier\' |
CASE |
5833 |
THEN TRIM(CONCAT(demandeur.particulier_nom, \' \', demandeur.particulier_prenom, \' \', demandeur.courriel)) |
WHEN demandeur.qualite=\'particulier\' |
5834 |
ELSE |
THEN TRIM(CONCAT(demandeur.particulier_nom, \' \', demandeur.particulier_prenom, \' \', demandeur.courriel)) |
5835 |
TRIM(CONCAT(demandeur.personne_morale_raison_sociale, \' \', demandeur.personne_morale_denomination, \' \', demandeur.courriel)) |
ELSE |
5836 |
END AS destinataire |
TRIM(CONCAT(demandeur.personne_morale_raison_sociale, \' \', demandeur.personne_morale_denomination, \' \', demandeur.courriel)) |
5837 |
FROM |
END AS destinataire |
5838 |
%1$sdossier |
FROM |
5839 |
LEFT JOIN %1$slien_dossier_demandeur |
%1$sdossier |
5840 |
ON lien_dossier_demandeur.dossier = dossier.dossier |
LEFT JOIN %1$slien_dossier_demandeur |
5841 |
LEFT JOIN %1$sdemandeur |
ON lien_dossier_demandeur.dossier = dossier.dossier |
5842 |
ON demandeur.demandeur = lien_dossier_demandeur.demandeur |
LEFT JOIN %1$sdemandeur |
5843 |
WHERE |
ON demandeur.demandeur = lien_dossier_demandeur.demandeur |
5844 |
dossier.dossier = \'%2$s\' |
WHERE |
5845 |
AND lien_dossier_demandeur.petitionnaire_principal IS TRUE', |
dossier.dossier = \'%2$s\' |
5846 |
DB_PREFIXE, |
AND lien_dossier_demandeur.petitionnaire_principal IS TRUE', |
5847 |
$dossier |
DB_PREFIXE, |
5848 |
|
$this->f->db->escapeSimple($dossier) |
5849 |
|
), |
5850 |
|
array( |
5851 |
|
"origin" => __METHOD__, |
5852 |
|
) |
5853 |
); |
); |
5854 |
|
if (is_array($qres["result"]) === true |
5855 |
$res = $this->f->get_one_row_result_from_db_query($sql); |
&& array_key_exists(0, $qres["result"]) === true) { |
5856 |
if ($res['code'] === 'KO') { |
// |
5857 |
return false; |
return $qres["result"][0]; |
5858 |
} |
} |
5859 |
return $res['result']; |
return null; |
5860 |
} |
} |
5861 |
|
|
5862 |
|
|
5875 |
$id_inst = $this->getVal($this->clePrimaire); |
$id_inst = $this->getVal($this->clePrimaire); |
5876 |
|
|
5877 |
// |
// |
5878 |
$admin_msg_error = _("Veuillez contacter votre administrateur."); |
$admin_msg_error = __("Veuillez contacter votre administrateur."); |
5879 |
$file_msg_error = _("Erreur de traitement de fichier.") |
$file_msg_error = __("Erreur de traitement de fichier.") |
5880 |
." ".$admin_msg_error; |
." ".$admin_msg_error; |
5881 |
$bdd_msg_error = _("Erreur de base de données.") |
$bdd_msg_error = __("Erreur de base de données.") |
5882 |
." ".$admin_msg_error; |
." ".$admin_msg_error; |
5883 |
$log_msg_error = "Finalisation non enregistrée - id instruction = %s - uid fichier = %s"; |
$log_msg_error = "Finalisation non enregistrée - id instruction = %s - uid fichier = %s"; |
5884 |
|
|
5885 |
// Si on finalise le document |
// Si on finalise le document |
5886 |
if ($mode == "finalize"){ |
if ($mode == "finalize"){ |
5887 |
// |
// |
5888 |
$etat = _('finalisation'); |
$etat = __('finalisation'); |
5889 |
|
|
5890 |
// Récupère la collectivite du dossier d'instruction |
// Récupère la collectivite du dossier d'instruction |
5891 |
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
5914 |
|
|
5915 |
//Métadonnées du document |
//Métadonnées du document |
5916 |
$metadata = array( |
$metadata = array( |
5917 |
'filename' => 'instruction_'.$id_inst.'.pdf', |
'filename' => $this->determinate_name_doc_pdf().'.pdf', |
5918 |
'mimetype' => 'application/pdf', |
'mimetype' => 'application/pdf', |
5919 |
'size' => strlen($pdf_output) |
'size' => strlen($pdf_output) |
5920 |
); |
); |
5923 |
$spe_metadata = $this->getMetadata("om_fichier_instruction"); |
$spe_metadata = $this->getMetadata("om_fichier_instruction"); |
5924 |
|
|
5925 |
//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 |
5926 |
$sql = "SELECT type |
// TODO : A voir pour remplacer par une instanciation de l'événement. |
5927 |
FROM ".DB_PREFIXE."evenement |
// Voir également si l'événement ne dois pas être instancié en début de |
5928 |
WHERE evenement = ".$this->getVal("evenement"); |
// méthode pour pouvoir être réutilisé. |
5929 |
$typeEvenement = $this->f->db->getOne($sql); |
$qres = $this->f->get_one_result_from_db_query( |
5930 |
$this->addToLog(__METHOD__."(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
sprintf( |
5931 |
if ($this->f->isDatabaseError($typeEvenement, true) === true) { |
'SELECT |
5932 |
|
type |
5933 |
|
FROM |
5934 |
|
%1$sevenement |
5935 |
|
WHERE |
5936 |
|
evenement = \'%2$d\'', |
5937 |
|
DB_PREFIXE, |
5938 |
|
intval($this->getVal("evenement")) |
5939 |
|
), |
5940 |
|
array( |
5941 |
|
"origin" => __METHOD__, |
5942 |
|
"force_return" => true, |
5943 |
|
) |
5944 |
|
); |
5945 |
|
|
5946 |
|
if ($qres["code"] !== "OK") { |
5947 |
$this->correct = false; |
$this->correct = false; |
5948 |
$this->addToMessage($bdd_msg_error); |
$this->addToMessage($bdd_msg_error); |
5949 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
5952 |
//Initialisation de la variable |
//Initialisation de la variable |
5953 |
$arrete_metadata = array(); |
$arrete_metadata = array(); |
5954 |
// 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 |
5955 |
if ( $typeEvenement === 'arrete' ){ |
if ($qres['result'] === 'arrete'){ |
5956 |
$arrete_metadata = $this->getMetadata("arrete"); |
$arrete_metadata = $this->getMetadata("arrete"); |
5957 |
} |
} |
5958 |
|
|
5959 |
$metadata = array_merge($metadata, $spe_metadata, $arrete_metadata); |
$metadata = array_merge($metadata, $spe_metadata, $arrete_metadata); |
5960 |
|
|
5961 |
/* |
// Mise à jour du nom du fichier en bdd suite à la finalisation de l'instruction |
5962 |
// transforme le tableau de métadonnées en objet |
$res = $this->f->db->autoExecute( |
5963 |
$mdf = new MetadataFactory(); |
DB_PREFIXE.$this->table, |
5964 |
$md = $mdf->build('Instruction', $metadata); |
['fichier_instruction_name' => $metadata['filename']], |
5965 |
*/ |
DB_AUTOQUERY_UPDATE, |
5966 |
|
"instruction='".$this->getVal("instruction")."'" |
5967 |
|
); |
5968 |
|
|
5969 |
// Si le document a déjà été finalisé on le met à jour |
// Si le document a déjà été finalisé on le met à jour |
5970 |
// en conservant son UID |
// en conservant son UID |
5971 |
if ($this->getVal("om_fichier_instruction") != ''){ |
if ($this->getVal("om_fichier_instruction") != ''){ |
5972 |
$uid = $this->f->storage->update( |
$uid = $this->f->storage->update( |
5973 |
$this->getVal("om_fichier_instruction"), $pdf_output, $metadata); |
$this->getVal("om_fichier_instruction"), $pdf_output, $metadata |
5974 |
|
); |
5975 |
} |
} |
5976 |
// Sinon on crée un nouveau document et dont on récupère l'UID |
// Sinon on crée un nouveau document et dont on récupère l'UID |
5977 |
else { |
else { |
5982 |
// Si on définalise le document |
// Si on définalise le document |
5983 |
if ($mode == "unfinalize") { |
if ($mode == "unfinalize") { |
5984 |
// |
// |
5985 |
$etat = _('définalisation'); |
$etat = __('définalisation'); |
5986 |
// Récupération de l'uid du document finalisé |
// Récupération de l'uid du document finalisé |
5987 |
$uid = $this->getVal("om_fichier_instruction"); |
$uid = $this->getVal("om_fichier_instruction"); |
5988 |
} |
} |
6078 |
} |
} |
6079 |
|
|
6080 |
// |
// |
6081 |
$this->addToMessage(sprintf(_("La %s du document s'est effectuee avec succes."), $etat)); |
$this->addToMessage(sprintf(__("La %s du document s'est effectuee avec succes."), $etat)); |
6082 |
// |
// |
6083 |
if ($this->add_log_to_dossier($id_inst, $val) === false) { |
if ($this->add_log_to_dossier($id_inst, $val) === false) { |
6084 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
6186 |
protected function getTitle() { |
protected function getTitle() { |
6187 |
|
|
6188 |
// Récupère le champ événement |
// Récupère le champ événement |
6189 |
if (isset($this->valF["evenement"]) AND $this->valF["evenement"] != "") { |
if (isset($this->valF["evenement"]) && $this->valF["evenement"] != "") { |
6190 |
$evenement = $this->valF["evenement"]; |
$evenement = $this->valF["evenement"]; |
6191 |
} else { |
} else { |
6192 |
$evenement = $this->getVal("evenement"); |
$evenement = $this->getVal("evenement"); |
6193 |
} |
} |
6194 |
|
|
6195 |
// Requête sql |
// Requête sql |
6196 |
$sql = "SELECT libelle FROM ".DB_PREFIXE."evenement |
$evenement = $this->f->get_inst__om_dbform(array( |
6197 |
WHERE evenement=".$evenement; |
"obj" => "evenement", |
6198 |
$evenement_libelle = $this->f->db->getOne($sql); |
"idx" => $evenement |
6199 |
$this->addToLog("getTitle(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
)); |
|
if (database::isError($evenement_libelle)) { |
|
|
die(); |
|
|
} |
|
6200 |
|
|
6201 |
// Retourne le libelle de l'événement |
// Retourne le libelle de l'événement |
6202 |
return $evenement_libelle; |
return $evenement->getVal('libelle'); |
6203 |
} |
} |
6204 |
|
|
6205 |
|
|
6223 |
* nécessaire à l'ajout d'un document. |
* nécessaire à l'ajout d'un document. |
6224 |
*/ |
*/ |
6225 |
public function getSpecificMetadata() { |
public function getSpecificMetadata() { |
6226 |
if (isset($this->valF["dossier"]) AND $this->valF["dossier"] != "") { |
if (isset($this->valF["dossier"]) && $this->valF["dossier"] != "") { |
6227 |
$dossier = $this->valF["dossier"]; |
$dossier = $this->valF["dossier"]; |
6228 |
} else { |
} else { |
6229 |
$dossier = $this->getVal("dossier"); |
$dossier = $this->getVal("dossier"); |
6230 |
} |
} |
6231 |
//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 |
6232 |
$sql = "SELECT dossier.dossier as dossier, |
$qres = $this->f->get_all_results_from_db_query( |
6233 |
dossier_autorisation.dossier_autorisation as dossier_autorisation, |
sprintf( |
6234 |
to_char(dossier.date_demande, 'YYYY/MM') as date_demande_initiale, |
'SELECT |
6235 |
dossier_instruction_type.code as dossier_instruction_type, |
dossier.dossier AS dossier, |
6236 |
etat_dossier_autorisation.libelle as statut, |
dossier_autorisation.dossier_autorisation AS dossier_autorisation, |
6237 |
dossier_autorisation_type.code as dossier_autorisation_type, |
to_char(dossier.date_demande, \'YYYY/MM\') AS date_demande_initiale, |
6238 |
groupe.code as groupe_instruction, |
dossier_instruction_type.code AS dossier_instruction_type, |
6239 |
CASE WHEN dossier.erp IS TRUE |
etat_dossier_autorisation.libelle AS statut, |
6240 |
THEN 'true' |
dossier_autorisation_type.code AS dossier_autorisation_type, |
6241 |
ELSE 'false' |
groupe.code AS groupe_instruction, |
6242 |
END as erp |
CASE WHEN dossier.erp IS TRUE |
6243 |
FROM ".DB_PREFIXE."dossier |
THEN \'true\' |
6244 |
LEFT JOIN ".DB_PREFIXE."dossier_instruction_type |
ELSE \'false\' |
6245 |
|
END AS erp |
6246 |
|
FROM |
6247 |
|
%1$sdossier |
6248 |
|
LEFT JOIN %1$sdossier_instruction_type |
6249 |
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
6250 |
LEFT JOIN ".DB_PREFIXE."dossier_autorisation |
LEFT JOIN %1$sdossier_autorisation |
6251 |
ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
6252 |
LEFT JOIN ".DB_PREFIXE."etat_dossier_autorisation |
LEFT JOIN %1$setat_dossier_autorisation |
6253 |
ON dossier_autorisation.etat_dossier_autorisation = etat_dossier_autorisation.etat_dossier_autorisation |
ON dossier_autorisation.etat_dossier_autorisation = etat_dossier_autorisation.etat_dossier_autorisation |
6254 |
LEFT JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille |
LEFT JOIN %1$sdossier_autorisation_type_detaille |
6255 |
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 |
6256 |
LEFT JOIN ".DB_PREFIXE."dossier_autorisation_type |
LEFT JOIN %1$sdossier_autorisation_type |
6257 |
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 |
6258 |
LEFT JOIN ".DB_PREFIXE."groupe |
LEFT JOIN %1$sgroupe |
6259 |
ON dossier_autorisation_type.groupe = groupe.groupe |
ON dossier_autorisation_type.groupe = groupe.groupe |
6260 |
WHERE dossier.dossier = '".$dossier."'"; |
WHERE |
6261 |
$res = $this->f->db->query($sql); |
dossier.dossier = \'%2$s\'', |
6262 |
$this->f->addToLog("getSpecificMetadata() : db->query(".$sql.")", VERBOSE_MODE); |
DB_PREFIXE, |
6263 |
if ( database::isError($res)){ |
$this->f->db->escapeSimple($dossier) |
6264 |
die(); |
), |
6265 |
} |
array( |
6266 |
|
"origin" => __METHOD__, |
6267 |
//Le résultat est récupéré dans un objet |
) |
6268 |
$row =& $res->fetchRow(DB_FETCHMODE_OBJECT); |
); |
6269 |
|
$row = array_shift($qres['result']); |
6270 |
|
|
6271 |
//Si il y a un résultat |
//Si il y a un résultat |
6272 |
if ($row !== null) { |
if (! empty($row)) { |
6273 |
|
|
6274 |
// Instrance de la classe dossier |
// Instrance de la classe dossier |
6275 |
$inst_dossier = $this->get_inst_dossier($dossier); |
$inst_dossier = $this->get_inst_dossier($dossier); |
6276 |
|
// TODO : améliorer ce code |
6277 |
|
// |
6278 |
|
// Avant l e résultat été récupéré dans un objet à partir de la requête mais en modifiant pour |
6279 |
|
// utiliser la méthode get_all_results_from_db_query() c'est maintenant un tableau |
6280 |
|
// qu'on obtiens. Pour garder le même fonctionnement on transforme le tableau des |
6281 |
|
// valeurs issues de la requête en objet. |
6282 |
|
$metadata = (object)$row; |
6283 |
// Insère l'attribut version à l'objet |
// Insère l'attribut version à l'objet |
6284 |
$row->version = $inst_dossier->get_dossier_instruction_version(); |
$metadata->version = $inst_dossier->get_di_numero_suffixe(); |
6285 |
|
|
6286 |
//Alors on créé l'objet dossier_instruction |
//Alors on créé l'objet dossier_instruction |
6287 |
$this->specificMetadata = $row; |
$this->specificMetadata = $metadata; |
6288 |
|
|
6289 |
} |
} |
6290 |
} |
} |
6303 |
|
|
6304 |
//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 |
6305 |
//dossier |
//dossier |
6306 |
$sql = "SELECT etat.statut |
$qres = $this->f->get_one_result_from_db_query( |
6307 |
FROM ".DB_PREFIXE."dossier |
sprintf( |
6308 |
LEFT JOIN |
'SELECT |
6309 |
".DB_PREFIXE."etat |
etat.statut |
6310 |
ON |
FROM |
6311 |
dossier.etat = etat.etat |
%1$sdossier |
6312 |
WHERE dossier ='".$idx."'"; |
LEFT JOIN |
6313 |
$statut = $this->f->db->getOne($sql); |
%1$setat |
6314 |
$this->f->addToLog("getStatutAutorisationDossier() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
ON |
6315 |
if ( database::isError($statut)){ |
dossier.etat = etat.etat |
6316 |
die(); |
WHERE |
6317 |
} |
dossier = \'%2$s\'', |
6318 |
|
DB_PREFIXE, |
6319 |
|
$this->f->db->escapeSimple($idx) |
6320 |
|
), |
6321 |
|
array( |
6322 |
|
"origin" => __METHOD__, |
6323 |
|
) |
6324 |
|
); |
6325 |
} |
} |
6326 |
return $statut; |
|
6327 |
|
return $qres['result']; |
6328 |
} |
} |
6329 |
|
|
6330 |
/** |
/** |
6337 |
$return = array(); |
$return = array(); |
6338 |
|
|
6339 |
// 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 |
6340 |
$sql = "SELECT * FROM ".DB_PREFIXE."dossier |
// TODO : remplacer cette requête par une instanciation de l'objet |
6341 |
WHERE dossier='".$this->valF['dossier']."'"; |
$qres = $this->f->get_all_results_from_db_query( |
6342 |
$res = $this->f->db->query($sql); |
sprintf( |
6343 |
$this->addToLog("get_dossier_actual(): db->query(\"".$sql."\");", VERBOSE_MODE); |
'SELECT |
6344 |
$this->f->isDatabaseError($res); |
* |
6345 |
|
FROM |
6346 |
|
%1$sdossier |
6347 |
|
WHERE |
6348 |
|
dossier = \'%2$s\'', |
6349 |
|
DB_PREFIXE, |
6350 |
|
$this->f->db->escapeSimple($this->valF['dossier']) |
6351 |
|
), |
6352 |
|
array( |
6353 |
|
'origin' => __METHOD__ |
6354 |
|
) |
6355 |
|
); |
6356 |
|
|
6357 |
// |
foreach ($qres['result'] as $row) { |
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
|
6358 |
|
|
6359 |
// 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, |
6360 |
// de l'état et de l'avis du dossier d'instruction |
// de l'état et de l'avis du dossier d'instruction |
6409 |
* @return boolean |
* @return boolean |
6410 |
*/ |
*/ |
6411 |
function checkEvenementNonVerrouillable($idx) { |
function checkEvenementNonVerrouillable($idx) { |
|
|
|
|
// Initialisation du résultat |
|
|
$non_verrouillable = false; |
|
|
|
|
6412 |
// Si la condition n'est pas vide |
// Si la condition n'est pas vide |
6413 |
if ($idx != "") { |
if ($idx != "") { |
6414 |
|
|
6415 |
// Requête SQL |
// Requête SQL |
6416 |
$sql = "SELECT evenement.non_verrouillable |
$qres = $this->f->get_one_result_from_db_query( |
6417 |
FROM ".DB_PREFIXE."evenement |
sprintf( |
6418 |
LEFT JOIN ".DB_PREFIXE."instruction |
'SELECT |
6419 |
ON instruction.evenement = evenement.evenement |
evenement.non_verrouillable |
6420 |
WHERE instruction.instruction = $idx"; |
FROM |
6421 |
$this->f->addToLog("checkEvenementNonVerrouillable() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
%1$sevenement |
6422 |
$res = $this->f->db->getOne($sql); |
LEFT JOIN %1$sinstruction |
6423 |
$this->f->isDatabaseError($res); |
ON instruction.evenement = evenement.evenement |
6424 |
|
WHERE |
6425 |
// Si le retour de la requête est true |
instruction.instruction = \'%2$s\'', |
6426 |
if ($res == 't') { |
DB_PREFIXE, |
6427 |
// |
intval($idx) |
6428 |
$non_verrouillable = true; |
), |
6429 |
} |
array( |
6430 |
|
"origin" => __METHOD__, |
6431 |
|
) |
6432 |
|
); |
6433 |
} |
} |
6434 |
|
|
6435 |
// Retourne résultat |
// Si on a un résultat et que ce résultat indique que l'événement n'est |
6436 |
return $non_verrouillable; |
// pas vérrouillable renvoie true, sinon renvoie false |
6437 |
|
return isset($qres) && isset($qres['result']) && $qres['result'] == 't'; |
6438 |
} |
} |
6439 |
|
|
6440 |
/** |
/** |
6674 |
*/ |
*/ |
6675 |
function getArreteMetadata() { |
function getArreteMetadata() { |
6676 |
|
|
6677 |
//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' |
6678 |
$this->metadonneesArrete = array("nomsignataire"=>"", "qualitesignataire"=>"", |
$this->metadonneesArrete = array("nomsignataire"=>"", "qualitesignataire"=>"", |
6679 |
"decisionarrete"=>"", "datenotification"=>"", "datesignaturearrete"=>"", |
"decisionarrete"=>"", "datenotification"=>"", "datesignaturearrete"=>"", |
6680 |
"datecontrolelegalite"=>"", "ap_numrue"=>"", "ap_nomdelavoie"=>"", |
"datecontrolelegalite"=>"", "ap_numrue"=>"", "ap_nomdelavoie"=>"", |
6681 |
"ap_codepostal"=>"", "ap_ville"=>""); |
"ap_codepostal"=>"", "ap_ville"=>""); |
6682 |
|
|
6683 |
$sqlArrete = "SELECT |
$qres = $this->f->get_all_results_from_db_query( |
6684 |
signataire_arrete.prenom || ' ' ||signataire_arrete.nom as \"nomsignataire\", |
sprintf( |
6685 |
signataire_arrete.qualite as \"qualitesignataire\", |
'SELECT |
6686 |
instruction.etat as \"decisionarrete\", |
signataire_arrete.prenom || \' \' ||signataire_arrete.nom as nomsignataire, |
6687 |
instruction.date_retour_rar as \"datenotification\", |
signataire_arrete.qualite as qualitesignataire, |
6688 |
instruction.date_retour_signature as \"datesignaturearrete\", |
instruction.etat as decisionarrete, |
6689 |
instruction.date_retour_controle_legalite as \"datecontrolelegalite\", |
instruction.date_retour_rar as datenotification, |
6690 |
dossier.terrain_adresse_voie_numero as \"ap_numrue\", |
instruction.date_retour_signature as datesignaturearrete, |
6691 |
dossier.terrain_adresse_voie as \"ap_nomdelavoie\", |
instruction.date_retour_controle_legalite as datecontrolelegalite, |
6692 |
dossier.terrain_adresse_code_postal as \"ap_codepostal\", |
dossier.terrain_adresse_voie_numero as ap_numrue, |
6693 |
dossier.terrain_adresse_localite as \"ap_ville\" |
dossier.terrain_adresse_voie as ap_nomdelavoie, |
6694 |
FROM ".DB_PREFIXE."instruction |
dossier.terrain_adresse_code_postal as ap_codepostal, |
6695 |
LEFT JOIN ".DB_PREFIXE."signataire_arrete ON |
dossier.terrain_adresse_localite as ap_ville |
6696 |
instruction.signataire_arrete = signataire_arrete.signataire_arrete |
FROM |
6697 |
LEFT JOIN ".DB_PREFIXE."dossier ON |
%1$sinstruction |
6698 |
instruction.dossier = dossier.dossier |
LEFT JOIN %1$ssignataire_arrete |
6699 |
LEFT JOIN ".DB_PREFIXE."donnees_techniques ON |
ON instruction.signataire_arrete = signataire_arrete.signataire_arrete |
6700 |
donnees_techniques.dossier_instruction = dossier.dossier |
LEFT JOIN %1$sdossier |
6701 |
WHERE instruction.instruction = ".$this->getVal("instruction"); |
ON instruction.dossier = dossier.dossier |
6702 |
$resArrete = $this->f->db->query($sqlArrete); |
LEFT JOIN %1$sdonnees_techniques |
6703 |
$this->f->addToLog("getArreteMetadata(): db->query(\"".$sqlArrete."\");", VERBOSE_MODE); |
ON donnees_techniques.dossier_instruction = dossier.dossier |
6704 |
if ( database::isError($resArrete)){ |
WHERE |
6705 |
die(); |
instruction.instruction = %2$d', |
6706 |
} |
DB_PREFIXE, |
6707 |
|
intval($this->getVal('instruction')) |
6708 |
$this->metadonneesArrete = $resArrete->fetchRow(DB_FETCHMODE_ASSOC); |
), |
6709 |
|
array( |
6710 |
|
'origin' => __METHOD__ |
6711 |
|
) |
6712 |
|
); |
6713 |
|
$this->metadonneesArrete = array_shift($qres['result']); |
6714 |
} |
} |
6715 |
|
|
6716 |
/** |
/** |
6784 |
|
|
6785 |
// Si l'utilisateur est instructeur de la commune du dossier et que |
// Si l'utilisateur est instructeur de la commune du dossier et que |
6786 |
// l'instruction est créée par un instructeur de la commune |
// l'instruction est créée par un instructeur de la commune |
6787 |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
if ($this->is_instructeur_from_collectivite_dossier() === true && |
6788 |
$this->getVal('created_by_commune') === 't') { |
$this->getVal('created_by_commune') === 't') { |
6789 |
return true; |
return true; |
6790 |
} |
} |
6877 |
* @return, boolean true/false |
* @return, boolean true/false |
6878 |
*/ |
*/ |
6879 |
function is_instructeur_from_collectivite_dossier() { |
function is_instructeur_from_collectivite_dossier() { |
6880 |
if ($this->f->isUserInstructeur() === true and |
if ($this->f->isUserInstructeur() === true && |
6881 |
$this->f->om_utilisateur["om_collectivite"] == $this->get_dossier_instruction_om_collectivite()) { |
$this->f->om_utilisateur["om_collectivite"] == $this->get_dossier_instruction_om_collectivite()) { |
6882 |
return true; |
return true; |
6883 |
} |
} |
6902 |
} |
} |
6903 |
// Si l'utilisateur est un intructeur qui correspond à la |
// Si l'utilisateur est un intructeur qui correspond à la |
6904 |
// division du dossier ou qu'il peut changer la décision |
// division du dossier ou qu'il peut changer la décision |
6905 |
if ($this->is_instructeur_from_division_dossier() === true or |
if ($this->is_instructeur_from_division_dossier() === true || |
6906 |
$this->isInstrCanChangeDecision($this->getParameter('idxformulaire')) === true) { |
$this->isInstrCanChangeDecision($this->getParameter('idxformulaire')) === true) { |
6907 |
// |
// |
6908 |
return true; |
return true; |
6946 |
|
|
6947 |
// Si l'utilisateur est instructeur de la commune du dossier et que |
// Si l'utilisateur est instructeur de la commune du dossier et que |
6948 |
// l'instruction est créée par un instructeur de la commune |
// l'instruction est créée par un instructeur de la commune |
6949 |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
if ($this->is_instructeur_from_collectivite_dossier() === true && |
6950 |
$this->getVal('created_by_commune') === 't') { |
$this->getVal('created_by_commune') === 't') { |
6951 |
return true; |
return true; |
6952 |
} |
} |
7011 |
|
|
7012 |
// Si l'utilisateur est instructeur de la commune du dossier et que |
// Si l'utilisateur est instructeur de la commune du dossier et que |
7013 |
// l'instruction est créée par un instructeur de la commune |
// l'instruction est créée par un instructeur de la commune |
7014 |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
if ($this->is_instructeur_from_collectivite_dossier() === true && |
7015 |
$this->getVal('created_by_commune') === 't') { |
$this->getVal('created_by_commune') === 't') { |
7016 |
return true; |
return true; |
7017 |
} |
} |
7049 |
*/ |
*/ |
7050 |
function isInstrCanChangeDecision($idx) { |
function isInstrCanChangeDecision($idx) { |
7051 |
|
|
7052 |
if ($this->f->isAccredited(array("instruction", "instruction_changer_decision"), "OR") !== true or |
if ($this->f->isAccredited(array("instruction", "instruction_changer_decision"), "OR") !== true || |
7053 |
$this->f->isUserInstructeur() !== true) { |
$this->f->isUserInstructeur() !== true) { |
7054 |
return false; |
return false; |
7055 |
} |
} |
7116 |
AND dossier.dossier = \'%2$s\' |
AND dossier.dossier = \'%2$s\' |
7117 |
', |
', |
7118 |
DB_PREFIXE, |
DB_PREFIXE, |
7119 |
$idx |
$this->f->db->escapeSimple($idx) |
7120 |
); |
); |
7121 |
|
|
7122 |
|
|
7123 |
// Si collectivité de l'utilisateur niveau mono alors filtre sur celle-ci |
// Si collectivité de l'utilisateur niveau mono alors filtre sur celle-ci |
7124 |
if ($this->f->isCollectiviteMono($_SESSION['collectivite']) === true) { |
if ($this->f->isCollectiviteMono($_SESSION['collectivite']) === true) { |
7125 |
$sql .= sprintf( |
$sql .= sprintf( |
7126 |
' AND dossier.om_collectivite=%1$s', |
' AND dossier.om_collectivite = %1$d', |
7127 |
$_SESSION['collectivite'] |
intval($_SESSION['collectivite']) |
7128 |
); |
); |
7129 |
} |
} |
7130 |
$res = $this->f->db->getone($sql); |
$qres = $this->f->get_one_result_from_db_query( |
7131 |
if (database::isError($res)) { |
$sql, |
7132 |
die(); |
array( |
7133 |
} |
"origin" => __METHOD__, |
7134 |
// Si le dossier n'est pas sujet au changement de decision |
) |
7135 |
if($res == null) { |
); |
7136 |
return false; |
|
7137 |
} |
return $qres['result'] !== null; |
|
return true; |
|
7138 |
} |
} |
7139 |
|
|
7140 |
|
|
7219 |
|
|
7220 |
|
|
7221 |
/** |
/** |
7222 |
|
* CONDITION - is_finalized. |
7223 |
|
* |
7224 |
|
* Condition pour vérifier si une instruction est finalisée. |
7225 |
|
* |
7226 |
|
* @return boolean |
7227 |
|
*/ |
7228 |
|
public function is_finalized() { |
7229 |
|
|
7230 |
|
return $this->getVal('om_final_instruction') === "t"; |
7231 |
|
} |
7232 |
|
|
7233 |
|
/** |
7234 |
|
* CONDITION - is_not_date_retour_signature_set. |
7235 |
|
* |
7236 |
|
* Condition pour vérifier si une date de retour signature n'est pas définie. |
7237 |
|
* |
7238 |
|
* @return boolean |
7239 |
|
*/ |
7240 |
|
public function is_not_date_retour_signature_set() { |
7241 |
|
|
7242 |
|
return $this->getVal('date_retour_signature') == null; |
7243 |
|
|
7244 |
|
} |
7245 |
|
|
7246 |
|
|
7247 |
|
/** |
7248 |
* TREATMENT - finalize. |
* TREATMENT - finalize. |
7249 |
* |
* |
7250 |
* Permet de finaliser un enregistrement. |
* Permet de finaliser un enregistrement. |
7254 |
* @return boolean |
* @return boolean |
7255 |
*/ |
*/ |
7256 |
function finalize($val = array()) { |
function finalize($val = array()) { |
|
|
|
7257 |
// 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 |
7258 |
// dites de TREATMENT. |
// dites de TREATMENT. |
7259 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
7260 |
$message = ''; |
$message = ''; |
7261 |
$ev = $this->get_inst_evenement($this->getVal('evenement')); |
$ev = $this->get_inst_evenement($this->getVal('evenement')); |
7262 |
|
|
7263 |
|
$this->f->log(__METHOD__, 'BEGIN'); |
7264 |
|
$collectivite_di = null; |
7265 |
|
$data = array('val' => &$val); |
7266 |
|
$data['ev'] = $ev; |
7267 |
|
$data['collectivite_di'] = $collectivite_di; |
7268 |
|
$this->f->module_manager->run_hooks('finalize_pre', $this, $data); |
7269 |
|
|
7270 |
// Controle du signataire |
// Controle du signataire |
7271 |
if (! $this->controle_signataire($ev)) { |
if (! $this->controle_signataire($ev)) { |
7272 |
$this->addToMessage(__("Le document ne peut pas être finalisé car aucun signataire n'a été sélectionné.")); |
$this->addToMessage(__("Le document ne peut pas être finalisé car aucun signataire n'a été sélectionné.")); |
7287 |
// Envoi des notifications aux demandeurs si la notification est automatique |
// Envoi des notifications aux demandeurs si la notification est automatique |
7288 |
// et que la signature n'est pas requise |
// et que la signature n'est pas requise |
7289 |
if ($ev->getVal('notification') === 'notification_automatique') { |
if ($ev->getVal('notification') === 'notification_automatique') { |
7290 |
|
// Préparation du message de log en cas d'erreur de notification |
7291 |
|
$msgLog = sprintf( |
7292 |
|
'%s %s : %d', |
7293 |
|
__('Erreur lors de la notification automatique du(des) pétitionnaire(s) suite à la finalisation de l\'instruction.'), |
7294 |
|
__('Instruction notifiée'), |
7295 |
|
$this->getVal($this->clePrimaire) |
7296 |
|
); |
7297 |
// Récupération de la catégorie et envoie des notifications au(x) demandeur(s) |
// Récupération de la catégorie et envoie des notifications au(x) demandeur(s) |
7298 |
$collectivite_di = $this->get_dossier_instruction_om_collectivite($this->getVal('dossier')); |
$collectivite_di = $this->get_dossier_instruction_om_collectivite($this->getVal('dossier')); |
7299 |
// 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 |
7300 |
$categorie = $this->f->get_param_option_notification($collectivite_di); |
$categorie = $this->f->get_param_option_notification($collectivite_di); |
7301 |
$isPortal = $categorie == null || $categorie == '' || $categorie == 'portal' ? true : false; |
$isPortal = $categorie === PORTAL; |
7302 |
$demandeursANotifie = $this->get_demandeurs_notifiable( |
$demandeursANotifie = $this->get_demandeurs_notifiable( |
7303 |
$this->getVal('dossier'), |
$this->getVal('dossier'), |
7304 |
$isPortal |
$isPortal |
7324 |
continue; |
continue; |
7325 |
} |
} |
7326 |
} |
} |
7327 |
// Ajout de la notif et récupération de son id |
// |
7328 |
$idNotif = $this->ajouter_notification( |
$msg_notif = ''; |
7329 |
$this->getVal($this->clePrimaire), |
|
7330 |
$this->f->get_connected_user_login_name(), |
$option_bloquer_notif_auto_dln_types_evenements = $this->f->getParameter("option_bloquer_notif_auto_dln") !== null ? explode(';', $this->f->getParameter("option_bloquer_notif_auto_dln")) : null; |
7331 |
$demandeur, |
// On vérifie l'existence du paramètre 'option_bloquer_notif_auto_dln', |
7332 |
$collectivite_di, |
// On vérifie si la date limite est dépassée ou si le type d'événement est erroné |
7333 |
array(), |
if (! empty($option_bloquer_notif_auto_dln_types_evenements) |
7334 |
true |
&& $this->is_type_evenement_autorise($ev, array('types_evenements_autorises'=> $option_bloquer_notif_auto_dln_types_evenements)) === true |
7335 |
); |
&& $this->is_date_limite_notification_premier_mois_depasee() === true) { |
7336 |
if ($idNotif === false) { |
// Ajout de la notif et récupération de son id |
7337 |
// Termine le traitement |
$idNotif = $this->ajouter_notification( |
7338 |
return $this->end_treatment(__METHOD__, false); |
$this->getVal($this->clePrimaire), |
7339 |
|
$this->f->get_connected_user_login_name(), |
7340 |
|
$demandeur, |
7341 |
|
$collectivite_di, |
7342 |
|
array(), |
7343 |
|
true, |
7344 |
|
'Echec', |
7345 |
|
__('La date limite de notification au demandeur est dépassée') |
7346 |
|
); |
7347 |
|
if ($idNotif === false) { |
7348 |
|
// Termine le traitement |
7349 |
|
$this->addToLog( |
7350 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
7351 |
|
DEBUG_MODE |
7352 |
|
); |
7353 |
|
return $this->end_treatment(__METHOD__, false); |
7354 |
|
} |
7355 |
|
$msg_notif = sprintf('%s<br/>%s', __("La notification n'a pas été générée, car la date limite de notification au demandeur est dépassée."), __("Le suivi de la notification est disponible depuis l'instruction.")); |
7356 |
} |
} |
7357 |
$notification_by_task = $this->notification_by_task( |
else { |
7358 |
$idNotif, |
// Ajout de la notif et récupération de son id |
7359 |
$this->getVal('dossier'), |
$idNotif = $this->ajouter_notification( |
7360 |
$categorie |
$this->getVal($this->clePrimaire), |
7361 |
); |
$this->f->get_connected_user_login_name(), |
7362 |
if ($notification_by_task === false) { |
$demandeur, |
7363 |
$this->addToMessage( |
$collectivite_di, |
7364 |
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
array(), |
7365 |
|
true |
7366 |
); |
); |
7367 |
// Termine le traitement |
if ($idNotif === false) { |
7368 |
return $this->end_treatment(__METHOD__, false); |
// Termine le traitement |
7369 |
|
$this->addToLog( |
7370 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
7371 |
|
DEBUG_MODE |
7372 |
|
); |
7373 |
|
return $this->end_treatment(__METHOD__, false); |
7374 |
|
} |
7375 |
|
$notification_by_task = $this->notification_by_task( |
7376 |
|
$idNotif, |
7377 |
|
$this->getVal('dossier'), |
7378 |
|
$categorie |
7379 |
|
); |
7380 |
|
if ($notification_by_task === false) { |
7381 |
|
$this->addToLog( |
7382 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
7383 |
|
DEBUG_MODE |
7384 |
|
); |
7385 |
|
$this->addToMessage( |
7386 |
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
7387 |
|
); |
7388 |
|
// Termine le traitement |
7389 |
|
return $this->end_treatment(__METHOD__, false); |
7390 |
|
} |
7391 |
|
$msg_notif = sprintf('%s<br/>%s', __("La notification a été générée."), __("Le suivi de la notification est disponible depuis l'instruction.")); |
7392 |
} |
} |
|
$this->addToMessage($message .= sprintf('%s<br/>%s', __("La notification a été générée."), __("Le suivi de la notification est disponible depuis l'instruction."))); |
|
7393 |
} |
} |
7394 |
|
$this->addToMessage($message .= $msg_notif); |
7395 |
} |
} |
7396 |
// Si le demandeur principal n'est pas notifiable, on créé une nouvelle notification |
// Pour la notification par mail ou la notification via portal si le dossier a |
7397 |
// en erreur avec en commentaire la raison pour laquelle le demandeur principal |
// été déposés via portal, si le demandeur principal n'est pas notifiable, |
7398 |
// n'a pas pu être notifié |
// on créé une nouvelle notification en erreur avec en commentaire la raison pour |
7399 |
if (! $demandeurPrincipalNotifie) { |
// laquelle le demandeur principal n'a pas pu être notifié |
7400 |
|
$depotPortal = $this->dossier_depose_sur_portail(); |
7401 |
|
if (! $demandeurPrincipalNotifie && ($isPortal === false || $depotPortal === true)) { |
7402 |
|
// Préparation des logs pour indiquer que le pétitionnaire principale n'est pas notifiable |
7403 |
|
$msgLog .= sprintf(' %s', __('Le pétitionnaire principale n\'est pas notifiable.')); |
7404 |
// Analyse pour savoir pourquoi le demandeur principal n'est pas notifiable |
// Analyse pour savoir pourquoi le demandeur principal n'est pas notifiable |
7405 |
$erreursParam = $this->get_info_notification_fail(); |
$erreursParam = $this->get_info_notification_fail(); |
7406 |
$demandeurPrincipal = $this->get_info_petitionnaire_principal_dossier($this->getVal('dossier')); |
$demandeurPrincipal = $this->get_info_petitionnaire_principal_dossier($this->getVal('dossier')); |
7420 |
__('Erreur : la création de la notification a échouée.'). |
__('Erreur : la création de la notification a échouée.'). |
7421 |
__("Veuillez contacter votre administrateur.") |
__("Veuillez contacter votre administrateur.") |
7422 |
); |
); |
7423 |
|
$this->addToLog( |
7424 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
7425 |
|
DEBUG_MODE |
7426 |
|
); |
7427 |
return false; |
return false; |
7428 |
} |
} |
7429 |
// Prépare un message d'alerte à destination de l'instructeur pour l'informer |
// Prépare un message d'alerte à destination de l'instructeur pour l'informer |
7431 |
$dossier_message = $this->get_inst_dossier_message(0); |
$dossier_message = $this->get_inst_dossier_message(0); |
7432 |
$dossier_message_val = array( |
$dossier_message_val = array( |
7433 |
'dossier' => $this->getVal('dossier'), |
'dossier' => $this->getVal('dossier'), |
7434 |
'type' => _('erreur expedition'), |
'type' => __('erreur expedition'), |
7435 |
'emetteur' => $this->f->get_connected_user_login_name(), |
'emetteur' => $this->f->get_connected_user_login_name(), |
7436 |
'login' => $_SESSION['login'], |
'login' => $_SESSION['login'], |
7437 |
'date_emission' => date('Y-m-d H:i:s'), |
'date_emission' => date('Y-m-d H:i:s'), |
7438 |
'contenu' => _('Échec lors de la notification de l\'instruction '). |
'contenu' => __('Échec lors de la notification de l\'instruction '). |
7439 |
$ev->getVal('libelle'). |
$ev->getVal('libelle'). |
7440 |
'.<br>'. |
'.<br>'. |
7441 |
implode("\n", $erreursParam). |
implode("\n", $erreursParam). |
7442 |
'<br>'. |
'<br>'. |
7443 |
_('Veuillez corriger ces informations avant de renvoyer la notification.') |
__('Veuillez corriger ces informations avant de renvoyer la notification.') |
7444 |
); |
); |
7445 |
$add = $dossier_message->add_notification_message($dossier_message_val, true); |
$add = $dossier_message->add_notification_message($dossier_message_val, true); |
7446 |
// Si une erreur se produit pendant l'ajout |
// Si une erreur se produit pendant l'ajout |
7452 |
} |
} |
7453 |
|
|
7454 |
// Termine le traitement |
// Termine le traitement |
7455 |
|
// Événement |
7456 |
|
$data['ev'] = $ev; |
7457 |
|
$data['collectivite_di'] = $collectivite_di; |
7458 |
|
$this->f->module_manager->run_hooks('finalize_post', $this, $data); |
7459 |
|
$this->f->log(__METHOD__, 'END'); |
7460 |
|
|
7461 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
7462 |
} |
} |
7463 |
|
|
7571 |
|
|
7572 |
// Génération du PDF |
// Génération du PDF |
7573 |
$result = $this->compute_pdf_output('lettretype', $this->getVal("lettretype"), $collectivite, null, $params); |
$result = $this->compute_pdf_output('lettretype', $this->getVal("lettretype"), $collectivite, null, $params); |
7574 |
|
$result['filename'] = $this->determinate_name_doc_pdf(); |
7575 |
// Affichage du PDF |
// Affichage du PDF |
7576 |
$this->expose_pdf_output( |
$this->expose_pdf_output( |
7577 |
$result['pdf_output'], |
$result['pdf_output'], |
7641 |
// |
// |
7642 |
$this->f->displayStartContent(); |
$this->f->displayStartContent(); |
7643 |
// |
// |
7644 |
$this->f->setTitle(_("Liste des éléments de la bible en lien avec un evenement")); |
$this->f->setTitle(__("Liste des éléments de la bible en lien avec un evenement")); |
7645 |
$this->f->displayTitle(); |
$this->f->displayTitle(); |
7646 |
|
|
7647 |
/** |
/** |
7666 |
"idx" => $idx, |
"idx" => $idx, |
7667 |
)); |
)); |
7668 |
|
|
7669 |
/** |
$qres = $this->f->get_all_results_from_db_query( |
7670 |
* |
sprintf( |
7671 |
*/ |
'SELECT |
7672 |
// |
*, |
7673 |
$sql = "SELECT *, bible.libelle as bible_lib |
bible.libelle as bible_lib |
7674 |
FROM ".DB_PREFIXE."bible |
FROM |
7675 |
LEFT OUTER JOIN ".DB_PREFIXE."dossier_autorisation_type |
%1$sbible |
7676 |
ON bible.dossier_autorisation_type=dossier_autorisation_type.dossier_autorisation_type |
LEFT OUTER JOIN %1$sdossier_autorisation_type |
7677 |
LEFT JOIN ".DB_PREFIXE."om_collectivite |
ON bible.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
7678 |
ON bible.om_collectivite = om_collectivite.om_collectivite |
LEFT JOIN %1$som_collectivite |
7679 |
WHERE (evenement=".$evenement." OR evenement IS NULL) |
ON bible.om_collectivite = om_collectivite.om_collectivite |
7680 |
AND (complement=".$complement." OR complement IS NULL) |
WHERE |
7681 |
AND (bible.dossier_autorisation_type IS NULL |
(evenement = %2$d |
7682 |
OR dossier_autorisation_type.code ='".$code_da_type."') |
OR evenement IS NULL) |
7683 |
AND (om_collectivite.niveau = '2' |
AND (complement = %3$d |
7684 |
OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").") |
OR complement IS NULL) |
7685 |
ORDER BY bible_lib ASC"; |
AND (bible.dossier_autorisation_type IS NULL |
7686 |
$res = $this->f->db->query($sql); |
OR dossier_autorisation_type.code = \'%4$s\') |
7687 |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\");", VERBOSE_MODE); |
AND (om_collectivite.niveau = \'2\' |
7688 |
$this->f->isDatabaseError($res); |
OR bible.om_collectivite = %5$d) |
7689 |
|
ORDER BY |
7690 |
|
bible_lib ASC', |
7691 |
|
DB_PREFIXE, |
7692 |
|
intval($evenement), |
7693 |
|
intval($complement), |
7694 |
|
$this->f->db->escapeSimple($code_da_type), |
7695 |
|
intval($dossier->getVal("om_collectivite")) |
7696 |
|
), |
7697 |
|
array( |
7698 |
|
'origin' => __METHOD__ |
7699 |
|
) |
7700 |
|
); |
7701 |
// |
// |
7702 |
echo "<form method=\"post\" name=\"f3\" action=\"#\">\n"; |
echo "<form method=\"post\" name=\"f3\" action=\"#\">\n"; |
7703 |
// |
// |
7704 |
if ($res->numrows() > 0) { |
if ($qres['row_count'] > 0) { |
7705 |
// |
// |
7706 |
echo "\t<table id='tab-bible' width='100%'>\n"; |
echo "\t<table id='tab-bible' width='100%'>\n"; |
7707 |
// |
// |
7708 |
echo "\t\t<tr class=\"ui-tabs-nav ui-accordion ui-state-default tab-title\">"; |
echo "\t\t<tr class=\"ui-tabs-nav ui-accordion ui-state-default tab-title\">"; |
7709 |
echo "<th>"._("Choisir")."</th>"; |
echo "<th>".__("Choisir")."</th>"; |
7710 |
echo "<th>"._("Libelle")."</th>"; |
echo "<th>".__("Libelle")."</th>"; |
7711 |
echo "</tr>\n"; |
echo "</tr>\n"; |
7712 |
// |
// |
7713 |
$i = 0; |
$i = 0; |
7714 |
// |
// |
7715 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
foreach ($qres['result'] as $row) { |
7716 |
// |
// |
7717 |
echo "\t\t<tr"; |
echo "\t\t<tr"; |
7718 |
echo " class=\"".($i % 2 == 0 ? "odd" : "even")."\""; |
echo " class=\"".($i % 2 == 0 ? "odd" : "even")."\""; |
7730 |
// |
// |
7731 |
echo "<div class=\"formControls\">\n"; |
echo "<div class=\"formControls\">\n"; |
7732 |
$this->f->layout->display_form_button(array( |
$this->f->layout->display_form_button(array( |
7733 |
"value" => _("Valider"), |
"value" => __("Valider"), |
7734 |
"onclick" => "bible_return('f2', 'complement".($complement == "1" ? "" : $complement)."_om_html'); return false;", |
"onclick" => "bible_return('f2', 'complement".($complement == "1" ? "" : $complement)."_om_html'); return false;", |
7735 |
)); |
)); |
7736 |
$this->f->displayLinkJsCloseWindow(); |
$this->f->displayLinkJsCloseWindow(); |
7739 |
} else { |
} else { |
7740 |
// |
// |
7741 |
$message_class = "error"; |
$message_class = "error"; |
7742 |
$message = _("Aucun element dans la bible pour l'evenement")." : ".$evenement; |
$message = __("Aucun element dans la bible pour l'evenement")." : ".$evenement; |
7743 |
$this->f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
7744 |
// |
// |
7745 |
echo "<div class=\"formControls\">\n"; |
echo "<div class=\"formControls\">\n"; |
7780 |
$retour['complement2_om_html'] = ''; |
$retour['complement2_om_html'] = ''; |
7781 |
$retour['complement3_om_html'] = ''; |
$retour['complement3_om_html'] = ''; |
7782 |
$retour['complement4_om_html'] = ''; |
$retour['complement4_om_html'] = ''; |
7783 |
|
|
7784 |
// Vérification d'une consultation liée à l'événement |
// Vérification d'une consultation liée à l'événement |
7785 |
$consultation = $this->f->db->getOne( |
$instEvenement = $this->f->get_inst__om_dbform(array( |
7786 |
"select consultation from ".DB_PREFIXE."evenement where evenement=".$evenement |
"obj" => "evenement", |
7787 |
); |
"idx" => $evenement, |
7788 |
$this->f->isDatabaseError($consultation); |
)); |
7789 |
|
|
7790 |
// Si consultation liée, récupération du retour d'avis |
// Si consultation liée, récupération du retour d'avis |
7791 |
if($consultation=='Oui'){ |
if($instEvenement->getVal('consultation') == 'Oui'){ |
7792 |
$sql = sprintf( |
|
7793 |
'(SELECT |
$qres = $this->f->get_all_results_from_db_query( |
7794 |
date_retour, |
sprintf( |
7795 |
avis_consultation.libelle as avis_consultation, |
'SELECT |
7796 |
COALESCE(service.libelle, tiers_consulte.libelle) as service |
date_retour, |
7797 |
FROM |
avis_consultation.libelle as avis_consultation, |
7798 |
%1$sconsultation |
COALESCE(service.libelle, tiers_consulte.libelle) as service |
7799 |
LEFT JOIN %1$stiers_consulte ON consultation.tiers_consulte = tiers_consulte.tiers_consulte |
FROM |
7800 |
LEFT JOIN %1$sservice ON consultation.service = service.service |
%1$sconsultation |
7801 |
LEFT JOIN %1$savis_consultation ON consultation.avis_consultation = avis_consultation.avis_consultation |
LEFT JOIN %1$stiers_consulte |
7802 |
WHERE |
ON consultation.tiers_consulte = tiers_consulte.tiers_consulte |
7803 |
dossier = \'%2$s\' |
LEFT JOIN %1$sservice |
7804 |
AND consultation.visible)', |
ON consultation.service = service.service |
7805 |
DB_PREFIXE, |
LEFT JOIN %1$savis_consultation |
7806 |
$this->f->db->escapeSimple($idx) |
ON consultation.avis_consultation = avis_consultation.avis_consultation |
7807 |
|
WHERE |
7808 |
|
dossier = \'%2$s\' |
7809 |
|
AND consultation.visible', |
7810 |
|
DB_PREFIXE, |
7811 |
|
$this->f->db->escapeSimple($idx) |
7812 |
|
), |
7813 |
|
array( |
7814 |
|
'origin' => __METHOD__ |
7815 |
|
) |
7816 |
); |
); |
|
$res = $this->f->db->query($sql); |
|
|
$this->f->isDatabaseError($res); |
|
7817 |
// Récupération des consultations |
// Récupération des consultations |
7818 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
foreach ($qres['result'] as $row) { |
7819 |
$correct=false; |
$correct=false; |
7820 |
// date retour |
// date retour |
7821 |
if ($row['date_retour']<>""){ |
if ($row['date_retour']<>""){ |
7822 |
if ($formatDate=="AAAA-MM-JJ"){ |
if ($formatDate=="AAAA-MM-JJ"){ |
7823 |
$date = explode("-", $row['date_retour']); |
$date = explode("-", $row['date_retour']); |
7824 |
// controle de date |
// controle de date |
7825 |
if (count($date) == 3 and |
if (count($date) == 3 && |
7826 |
checkdate($date[1], $date[2], $date[0])) { |
checkdate($date[1], $date[2], $date[0])) { |
7827 |
$date_retour_f= $date[2]."/".$date[1]."/".$date[0]; |
$date_retour_f= $date[2]."/".$date[1]."/".$date[0]; |
7828 |
$correct=true; |
$correct=true; |
7943 |
* @param integer $event id de l'événement |
* @param integer $event id de l'événement |
7944 |
* @param string $idx id du dossier |
* @param string $idx id du dossier |
7945 |
* @param integer $compnb numéro du champ complement |
* @param integer $compnb numéro du champ complement |
7946 |
|
* @param string $type types possibles : automatique ou precharge |
7947 |
* |
* |
7948 |
* @return string Chaîne de texte à insérer dans le champ complement |
* @return string Chaîne de texte à insérer dans le champ complement |
7949 |
*/ |
*/ |
7950 |
function getBible($event, $idx, $compnb) { |
function getBible($event, $idx, $compnb, $type = 'automatique') { |
7951 |
// Récupération de la collectivité du dossier |
// Récupération de la collectivité du dossier |
7952 |
$dossier = $this->f->get_inst__om_dbform(array( |
$dossier = $this->f->get_inst__om_dbform(array( |
7953 |
"obj" => "dossier", |
"obj" => "dossier", |
7958 |
if (preg_match('/[A-Za-z]{2,3}/', $idx, $matches) !== false) { |
if (preg_match('/[A-Za-z]{2,3}/', $idx, $matches) !== false) { |
7959 |
$code_da_type = $matches[0]; |
$code_da_type = $matches[0]; |
7960 |
} |
} |
|
// |
|
|
$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").")"; |
|
7961 |
|
|
7962 |
$res = $this->f->db->query($sql); |
// Prépare le filtre de la requête selon le type de remplissage voulu |
7963 |
$this->f->isDatabaseError($res); |
$sql_filter_type = ''; |
7964 |
|
if ($type === 'automatique') { |
7965 |
|
$sql_filter_type = "AND automatique = 'Oui'"; |
7966 |
|
} elseif ($type === 'precharge') { |
7967 |
|
$sql_filter_type = "AND precharge IS TRUE"; |
7968 |
|
} |
7969 |
|
|
7970 |
|
$qres = $this->f->get_all_results_from_db_query( |
7971 |
|
sprintf( |
7972 |
|
'SELECT |
7973 |
|
* |
7974 |
|
FROM |
7975 |
|
%1$sbible |
7976 |
|
LEFT OUTER JOIN %1$sdossier_autorisation_type |
7977 |
|
ON bible.dossier_autorisation_type = |
7978 |
|
dossier_autorisation_type.dossier_autorisation_type |
7979 |
|
LEFT JOIN %1$som_collectivite |
7980 |
|
ON bible.om_collectivite = om_collectivite.om_collectivite |
7981 |
|
WHERE |
7982 |
|
(evenement = %2$d |
7983 |
|
OR evenement IS NULL) |
7984 |
|
AND (complement = %3$d |
7985 |
|
OR complement IS NULL) |
7986 |
|
AND (dossier_autorisation_type.code = \'%4$s\' |
7987 |
|
OR bible.dossier_autorisation_type IS NULL) |
7988 |
|
AND (om_collectivite.niveau = \'2\' |
7989 |
|
OR bible.om_collectivite = %5$d) |
7990 |
|
%6$s', |
7991 |
|
DB_PREFIXE, |
7992 |
|
intval($event), |
7993 |
|
intval($compnb), |
7994 |
|
$this->f->db->escapeSimple($code_da_type), |
7995 |
|
intval($dossier->getVal("om_collectivite")), |
7996 |
|
$sql_filter_type |
7997 |
|
), |
7998 |
|
array( |
7999 |
|
"origin" => __METHOD__ |
8000 |
|
) |
8001 |
|
); |
8002 |
$temp = ""; |
$temp = ""; |
8003 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
foreach ($qres['result'] as $row) { |
8004 |
// Remplacement des retours à la ligne par des br |
// Remplacement des retours à la ligne par des br |
8005 |
$temp .= preg_replace( |
$temp .= preg_replace( |
8006 |
'#(\\\r|\\\r\\\n|\\\n)#', '<br/>', $row['contenu'] |
'#(\\\r|\\\r\\\n|\\\n)#', '<br/>', $row['contenu'] |
8033 |
if ($this->f->get_submitted_post_value("bordereau") !== null && $this->f->get_submitted_post_value("bordereau") == "" ) { |
if ($this->f->get_submitted_post_value("bordereau") !== null && $this->f->get_submitted_post_value("bordereau") == "" ) { |
8034 |
// Si aucun bordereau n'a été sélectionné |
// Si aucun bordereau n'a été sélectionné |
8035 |
$message_class = "error"; |
$message_class = "error"; |
8036 |
$message = _("Veuillez selectionner un bordereau."); |
$message = __("Veuillez selectionner un bordereau."); |
8037 |
} |
} |
8038 |
// Sinon si les dates ne sont pas valide |
// Sinon si les dates ne sont pas valide |
8039 |
elseif (($this->f->get_submitted_post_value("date_bordereau_debut") !== null |
elseif (($this->f->get_submitted_post_value("date_bordereau_debut") !== null |
8042 |
&& $this->f->get_submitted_post_value("date_bordereau_fin") == "")) { |
&& $this->f->get_submitted_post_value("date_bordereau_fin") == "")) { |
8043 |
// Si aucune date n'a été saisie |
// Si aucune date n'a été saisie |
8044 |
$message_class = "error"; |
$message_class = "error"; |
8045 |
$message = _("Veuillez saisir une date valide."); |
$message = __("Veuillez saisir une date valide."); |
8046 |
} |
} |
8047 |
// Sinon si les dates ne sont pas valides |
// Sinon si les dates ne sont pas valides |
8048 |
elseif ($this->f->get_submitted_post_value("bordereau") === "bordereau_avis_maire_prefet" |
elseif ($this->f->get_submitted_post_value("bordereau") === "bordereau_avis_maire_prefet" |
8049 |
&& $this->f->getParameter("id_evenement_bordereau_avis_maire_prefet") == null) { |
&& $this->f->getParameter("id_evenement_bordereau_avis_maire_prefet") == null) { |
8050 |
// Si aucune date n'a été saisie |
// Si aucune date n'a été saisie |
8051 |
$message_class = "error"; |
$message_class = "error"; |
8052 |
$message = _("Erreur de parametrage. Contactez votre administrateur."); |
$message = __("Erreur de parametrage. Contactez votre administrateur."); |
8053 |
} |
} |
8054 |
// Affiche le message de validation |
// Affiche le message de validation |
8055 |
else { |
else { |
8056 |
// 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 |
8057 |
$sql = "SELECT om_etat.libelle |
$etat = $this->f->get_inst__om_dbform(array( |
8058 |
FROM ".DB_PREFIXE."om_etat |
"obj" => "om_etat", |
8059 |
WHERE om_etat.id = '".$this->f->get_submitted_post_value("bordereau")."'"; |
"idx" => $this->f->get_submitted_post_value("bordereau") |
8060 |
$res = $this->f->db->getone($sql); |
)); |
8061 |
$this->f->addToLog(__METHOD__.": db->getone(\"".$sql."\")", VERBOSE_MODE); |
$qres = $this->f->get_one_result_from_db_query( |
8062 |
$this->f->isDatabaseError($res); |
sprintf( |
8063 |
|
'SELECT |
8064 |
|
om_etat.libelle |
8065 |
|
FROM |
8066 |
|
%som_etat |
8067 |
|
WHERE |
8068 |
|
om_etat.id = \'%s\'', |
8069 |
|
DB_PREFIXE, |
8070 |
|
$this->f->db->escapeSimple($this->f->get_submitted_post_value("bordereau")) |
8071 |
|
), |
8072 |
|
array( |
8073 |
|
"origin" => __METHOD__, |
8074 |
|
) |
8075 |
|
); |
8076 |
|
|
8077 |
// |
// |
8078 |
$message_class = "valid"; |
$message_class = "valid"; |
8079 |
$message = _("Cliquez sur le lien ci-dessous pour telecharger votre bordereau"); |
$message = __("Cliquez sur le lien ci-dessous pour telecharger votre bordereau"); |
8080 |
$message .= " : <br/><br/>"; |
$message .= " : <br/><br/>"; |
8081 |
$message .= "<a class='om-prev-icon pdf-16'"; |
$message .= "<a class='om-prev-icon pdf-16'"; |
8082 |
$message .= " title=\""._("Bordereau")."\""; |
$message .= " title=\"".__("Bordereau")."\""; |
8083 |
$message .= "href='".OM_ROUTE_FORM."&obj=instruction"; |
$message .= "href='".OM_ROUTE_FORM."&obj=instruction"; |
8084 |
$message .= "&action=220"; |
$message .= "&action=220"; |
8085 |
$message .= "&idx=0"; |
$message .= "&idx=0"; |
8091 |
$message .= "&collectivite=".$this->f->get_submitted_post_value("om_collectivite"); |
$message .= "&collectivite=".$this->f->get_submitted_post_value("om_collectivite"); |
8092 |
} |
} |
8093 |
$message .= "'"." target='_blank'>"; |
$message .= "'"." target='_blank'>"; |
8094 |
$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") |
8095 |
." "._("au")." ".$this->f->get_submitted_post_value("date_bordereau_fin"); |
." ".__("au")." ".$this->f->get_submitted_post_value("date_bordereau_fin"); |
8096 |
$message .= "</a>"; |
$message .= "</a>"; |
8097 |
} |
} |
8098 |
} |
} |
8124 |
"champs" => $champs, |
"champs" => $champs, |
8125 |
)); |
)); |
8126 |
// Paramétrage du champ date_bordereau_debut |
// Paramétrage du champ date_bordereau_debut |
8127 |
$form->setLib("date_bordereau_debut", _("date_bordereau_debut")); |
$form->setLib("date_bordereau_debut", __("date_bordereau_debut")); |
8128 |
$form->setType("date_bordereau_debut", "date"); |
$form->setType("date_bordereau_debut", "date"); |
8129 |
$form->setTaille("date_bordereau_debut", 12); |
$form->setTaille("date_bordereau_debut", 12); |
8130 |
$form->setMax("date_bordereau_debut", 12); |
$form->setMax("date_bordereau_debut", 12); |
8132 |
$form->setOnchange("date_bordereau_debut", "fdate(this)"); |
$form->setOnchange("date_bordereau_debut", "fdate(this)"); |
8133 |
$form->setVal("date_bordereau_debut", date("d/m/Y")); |
$form->setVal("date_bordereau_debut", date("d/m/Y")); |
8134 |
// Paramétrage du champ date_bordereau_fin |
// Paramétrage du champ date_bordereau_fin |
8135 |
$form->setLib("date_bordereau_fin", _("date_bordereau_fin")); |
$form->setLib("date_bordereau_fin", __("date_bordereau_fin")); |
8136 |
$form->setType("date_bordereau_fin", "date"); |
$form->setType("date_bordereau_fin", "date"); |
8137 |
$form->setTaille("date_bordereau_fin", 12); |
$form->setTaille("date_bordereau_fin", 12); |
8138 |
$form->setMax("date_bordereau_fin", 12); |
$form->setMax("date_bordereau_fin", 12); |
8140 |
$form->setOnchange("date_bordereau_fin", "fdate(this)"); |
$form->setOnchange("date_bordereau_fin", "fdate(this)"); |
8141 |
$form->setVal("date_bordereau_fin", date("d/m/Y")); |
$form->setVal("date_bordereau_fin", date("d/m/Y")); |
8142 |
// Paramétrage du champ bordereau |
// Paramétrage du champ bordereau |
8143 |
$form->setLib("bordereau", _("bordereau")); |
$form->setLib("bordereau", __("bordereau")); |
8144 |
$form->setType("bordereau", "select"); |
$form->setType("bordereau", "select"); |
8145 |
$form->setRequired("bordereau"); |
$form->setRequired("bordereau"); |
8146 |
// Valeurs des champs |
// Valeurs des champs |
8153 |
// 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 |
8154 |
// 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 |
8155 |
// 'bordereau_' |
// 'bordereau_' |
8156 |
$sql = "SELECT om_etat.id, om_etat.libelle |
$qres = $this->f->get_all_results_from_db_query( |
8157 |
FROM ".DB_PREFIXE."om_etat |
sprintf( |
8158 |
WHERE om_etat.id LIKE 'bordereau_%' |
'SELECT |
8159 |
ORDER BY om_etat.id"; |
om_etat.id, |
8160 |
$res = $this->f->db->query($sql); |
om_etat.libelle |
8161 |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
FROM |
8162 |
$this->f->isDatabaseError($res); |
%1$som_etat |
8163 |
|
WHERE |
8164 |
|
om_etat.id LIKE \'bordereau_%%\' |
8165 |
|
ORDER BY |
8166 |
|
om_etat.id', |
8167 |
|
DB_PREFIXE |
8168 |
|
), |
8169 |
|
array( |
8170 |
|
"origin" => __METHOD__ |
8171 |
|
) |
8172 |
|
); |
8173 |
// Données du select |
// Données du select |
8174 |
$contenu = array( |
$contenu = array( |
8175 |
0 => array("", ), |
0 => array("", ), |
8176 |
1 => array(_("choisir bordereau")), |
1 => array(__("choisir bordereau")), |
8177 |
); |
); |
8178 |
while ($row =& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
foreach ($qres['result'] as $row) { |
8179 |
$contenu[0][] = $row['id']; |
$contenu[0][] = $row['id']; |
8180 |
$contenu[1][] = $row['libelle']; |
$contenu[1][] = $row['libelle']; |
8181 |
} |
} |
8182 |
$form->setSelect("bordereau", $contenu); |
$form->setSelect("bordereau", $contenu); |
8183 |
// |
// |
8184 |
if ($_SESSION["niveau"] == 2) { |
if ($_SESSION["niveau"] == 2) { |
8185 |
$form->setLib("om_collectivite", _("collectivite")); |
$form->setLib("om_collectivite", __("collectivite")); |
8186 |
$form->setType("om_collectivite", "select"); |
$form->setType("om_collectivite", "select"); |
8187 |
|
|
8188 |
// 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 |
8189 |
// de niveau 1 |
// de niveau 1 |
8190 |
$sql = "SELECT om_collectivite, libelle |
$qres = $this->f->get_all_results_from_db_query( |
8191 |
FROM ".DB_PREFIXE."om_collectivite |
sprintf( |
8192 |
WHERE niveau = '1' ORDER BY libelle"; |
'SELECT |
8193 |
$res = $this->f->db->query($sql); |
om_collectivite, |
8194 |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
libelle |
8195 |
$this->f->isDatabaseError($res); |
FROM |
8196 |
|
%1$som_collectivite |
8197 |
|
WHERE |
8198 |
|
niveau = \'1\' |
8199 |
|
ORDER BY |
8200 |
|
libelle', |
8201 |
|
DB_PREFIXE |
8202 |
|
), |
8203 |
|
array( |
8204 |
|
"origin" => __METHOD__ |
8205 |
|
) |
8206 |
|
); |
8207 |
// La valeur par défaut du select est Toutes |
// La valeur par défaut du select est Toutes |
8208 |
$list_collectivites = array( |
$list_collectivites = array( |
8209 |
0 => array("", ), |
0 => array("", ), |
8210 |
1 => array(_("toutes")) |
1 => array(__("toutes")) |
8211 |
); |
); |
8212 |
|
|
8213 |
$id_colls = ""; |
$id_colls = ""; |
8214 |
// 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 |
8215 |
// 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 |
8216 |
while ($row =& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
foreach ($qres['result'] as $row) { |
8217 |
if ($id_colls != "") { |
if ($id_colls != "") { |
8218 |
$id_colls .= ","; |
$id_colls .= ","; |
8219 |
} |
} |
8231 |
$form->enpied(); |
$form->enpied(); |
8232 |
// Affichage du bouton |
// Affichage du bouton |
8233 |
printf("\t<div class=\"formControls\">\n"); |
printf("\t<div class=\"formControls\">\n"); |
8234 |
$this->f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
$this->f->layout->display_form_button(array("value" => __("Valider"), "name" => "validation")); |
8235 |
printf("\t</div>\n"); |
printf("\t</div>\n"); |
8236 |
// Fermeture du formulaire |
// Fermeture du formulaire |
8237 |
printf("\t</form>\n"); |
printf("\t</form>\n"); |
8310 |
if (empty($date) || empty($liste_code_barres_instruction)) { |
if (empty($date) || empty($liste_code_barres_instruction)) { |
8311 |
// |
// |
8312 |
$message_class = "error"; |
$message_class = "error"; |
8313 |
$message = _("Tous les champs doivent etre remplis."); |
$message = __("Tous les champs doivent etre remplis."); |
8314 |
} else { |
} else { |
8315 |
// Création d'un tableau d'instruction |
// Création d'un tableau d'instruction |
8316 |
$liste = explode("\r\n", $this->f->get_submitted_post_value("liste_code_barres_instruction")); |
$liste = explode("\r\n", $this->f->get_submitted_post_value("liste_code_barres_instruction")); |
8349 |
$conditions = implode(" OR ", $group_clause); |
$conditions = implode(" OR ", $group_clause); |
8350 |
$sql .= " AND (" . $conditions . ")"; |
$sql .= " AND (" . $conditions . ")"; |
8351 |
|
|
8352 |
$nbInstr = $this->f->db->getone($sql); |
$qres = $this->f->get_one_result_from_db_query( |
8353 |
$this->f->addToLog(__METHOD__.": db->getone(\"".$sql."\")", VERBOSE_MODE); |
$sql, |
8354 |
$this->f->isDatabaseError($nbInstr); |
array( |
8355 |
// |
"origin" => __METHOD__, |
8356 |
if ($nbInstr == "1") { |
) |
8357 |
|
); |
8358 |
|
|
8359 |
|
if ($qres['result'] == "1") { |
8360 |
// Récupération de la date d'envoi de l'instruction bippé |
// Récupération de la date d'envoi de l'instruction bippé |
8361 |
$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( |
8362 |
$res = $this->f->db->query($sql); |
sprintf( |
8363 |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
'SELECT |
8364 |
$this->f->isDatabaseError($res); |
to_char(date_envoi_rar, \'DD/MM/YYYY\') as date_envoi_rar, |
8365 |
$row =& $res->fetchRow(DB_FETCHMODE_ASSOC); |
instruction |
8366 |
|
FROM |
8367 |
|
%1$sinstruction |
8368 |
|
WHERE |
8369 |
|
code_barres = \'%2$s\'', |
8370 |
|
DB_PREFIXE, |
8371 |
|
$this->f->db->escapeSimple($code_barres) |
8372 |
|
), |
8373 |
|
array( |
8374 |
|
'origin' => __METHOD__ |
8375 |
|
) |
8376 |
|
); |
8377 |
|
$row = array_shift($qres['result']); |
8378 |
// Si pas de date ou correspond à la date du formulaire on |
// Si pas de date ou correspond à la date du formulaire on |
8379 |
// effectue le traitement |
// effectue le traitement |
8380 |
if ($row["date_envoi_rar"] == "" || $row["date_envoi_rar"] == $date) { |
if ($row["date_envoi_rar"] == "" || $row["date_envoi_rar"] == $date) { |
8455 |
if ($error != "") { |
if ($error != "") { |
8456 |
$error .= "<br/>"; |
$error .= "<br/>"; |
8457 |
} |
} |
8458 |
$error .= sprintf(_("Une erreur s'est produite lors de la modification de l'instruction %s."), |
$error .= sprintf(__("Une erreur s'est produite lors de la modification de l'instruction %s."), |
8459 |
$code_barres); |
$code_barres); |
8460 |
$error .= " "; |
$error .= " "; |
8461 |
$error .= _("Veuillez contacter votre administrateur."); |
$error .= __("Veuillez contacter votre administrateur."); |
8462 |
} |
} |
8463 |
} else { |
} else { |
8464 |
// |
// |
8465 |
if ($error != "") { |
if ($error != "") { |
8466 |
$error .= "<br/>"; |
$error .= "<br/>"; |
8467 |
} |
} |
8468 |
$error .= sprintf(_("Le document correspondant au |
$error .= sprintf(__("Le document correspondant au |
8469 |
code barres %s n'est pas finalise, |
code barres %s n'est pas finalise, |
8470 |
le bordereau ne sera pas genere."), |
le bordereau ne sera pas genere."), |
8471 |
$code_barres); |
$code_barres); |
8476 |
if ($error != "") { |
if ($error != "") { |
8477 |
$error .= "<br/>"; |
$error .= "<br/>"; |
8478 |
} |
} |
8479 |
$error .= _("Une lettre correspondante a l'instruction ayant pour code barres")." ".$code_barres." "._("a deja ete envoyee, le bordereau ne sera pas genere."); |
$error .= __("Une lettre correspondante a l'instruction ayant pour code barres")." ".$code_barres." ".__("a deja ete envoyee, le bordereau ne sera pas genere."); |
8480 |
} |
} |
8481 |
} else { |
} else { |
8482 |
// |
// |
8483 |
if ($error != "") { |
if ($error != "") { |
8484 |
$error .= "<br/>"; |
$error .= "<br/>"; |
8485 |
} |
} |
8486 |
$error .= _("Le numero")." ".$code_barres." "._("ne correspond a aucun code barres d'instruction."); |
$error .= __("Le numero")." ".$code_barres." ".__("ne correspond a aucun code barres d'instruction."); |
8487 |
} |
} |
8488 |
} else { |
} else { |
8489 |
// |
// |
8490 |
if ($error != "") { |
if ($error != "") { |
8491 |
$error .= "<br/>"; |
$error .= "<br/>"; |
8492 |
} |
} |
8493 |
$error .= _("Le code barres d'instruction")." ".$code_barres." "._("n'est pas valide."); |
$error .= __("Le code barres d'instruction")." ".$code_barres." ".__("n'est pas valide."); |
8494 |
} |
} |
8495 |
} |
} |
8496 |
} |
} |
8515 |
echo "\n<p>"; |
echo "\n<p>"; |
8516 |
echo "\n<span class=\"ui-icon ui-icon-info\"></span>"; |
echo "\n<span class=\"ui-icon ui-icon-info\"></span>"; |
8517 |
echo "\n<span class=\"text\">"; |
echo "\n<span class=\"text\">"; |
8518 |
echo _("Cliquez sur le lien ci-dessous pour telecharger votre document"); |
echo __("Cliquez sur le lien ci-dessous pour telecharger votre document"); |
8519 |
echo " : \n<br/><br/>"; |
echo " : \n<br/><br/>"; |
8520 |
echo "\n<a class='om-prev-icon pdf-16'"; |
echo "\n<a class='om-prev-icon pdf-16'"; |
8521 |
echo "\n title=\""._("imprimer les AR")."\""; |
echo "\n title=\"".__("imprimer les AR")."\""; |
8522 |
echo "\n href=\"".OM_ROUTE_FORM."&obj=instruction&action=180&idx=0&liste=".implode(",",$id4Gen)."\""; |
echo "\n href=\"".OM_ROUTE_FORM."&obj=instruction&action=180&idx=0&liste=".implode(",",$id4Gen)."\""; |
8523 |
echo "\n target='_blank'>"; |
echo "\n target='_blank'>"; |
8524 |
echo _("Telecharger le document pour")." ".$nbLettres." "._("AR"); |
echo __("Telecharger le document pour")." ".$nbLettres." ".__("AR"); |
8525 |
echo "\n</a>"; |
echo "\n</a>"; |
8526 |
echo "\n</span>"; |
echo "\n</span>"; |
8527 |
echo "\n</p>"; |
echo "\n</p>"; |
8529 |
if ($isAccredited === true) { |
if ($isAccredited === true) { |
8530 |
echo '<fieldset id="fieldset-form-rar-lien_di" class="cadre ui-corner-all startClosed" style="background-color: inherite;">'; |
echo '<fieldset id="fieldset-form-rar-lien_di" class="cadre ui-corner-all startClosed" style="background-color: inherite;">'; |
8531 |
echo "\n<legend class=\"ui-corner-all ui-widget-content ui-state-active\" style=\"background-color: transparent; color: inherit;\">\n"; |
echo "\n<legend class=\"ui-corner-all ui-widget-content ui-state-active\" style=\"background-color: transparent; color: inherit;\">\n"; |
8532 |
echo _('Dossiers concernés par ce traitement'); |
echo __('Dossiers concernés par ce traitement'); |
8533 |
echo "\n</legend>"; |
echo "\n</legend>"; |
8534 |
echo "\n<div class=\"fieldsetContent\" style=\"display: none;background-color: inherite\">"; |
echo "\n<div class=\"fieldsetContent\" style=\"display: none;background-color: inherite\">"; |
8535 |
|
|
8537 |
echo "\n<br/>"; |
echo "\n<br/>"; |
8538 |
echo "\n<p>"; |
echo "\n<p>"; |
8539 |
echo "\n<span class='text'>"; |
echo "\n<span class='text'>"; |
8540 |
echo _("Certains dossiers ont été omis de la liste ci-dessous car vous ne possédez pas les permissions nécessaires pour y accéder."); |
echo __("Certains dossiers ont été omis de la liste ci-dessous car vous ne possédez pas les permissions nécessaires pour y accéder."); |
8541 |
echo "</span>"; |
echo "</span>"; |
8542 |
echo "\n</p>"; |
echo "\n</p>"; |
8543 |
echo "\n<br/>"; |
echo "\n<br/>"; |
8549 |
$code_datd = $inst_datd->getVal('code'); |
$code_datd = $inst_datd->getVal('code'); |
8550 |
|
|
8551 |
$obj = "dossier_instruction"; |
$obj = "dossier_instruction"; |
8552 |
if ($code_datd === 'REC' OR $code_datd === 'REG') { |
if ($code_datd === 'REC' || $code_datd === 'REG') { |
8553 |
$obj = "dossier_contentieux_tous_recours"; |
$obj = "dossier_contentieux_tous_recours"; |
8554 |
} |
} |
8555 |
if ($code_datd === 'IN') { |
if ($code_datd === 'IN') { |
8561 |
|
|
8562 |
echo "\n<p>"; |
echo "\n<p>"; |
8563 |
echo "\n<span class='text'>"; |
echo "\n<span class='text'>"; |
8564 |
echo "\n<a class=\"om-icon om-icon-16 consult-16\" title=\"" . _('Consulter') . "\""; |
echo "\n<a class=\"om-icon om-icon-16 consult-16\" title=\"" . __('Consulter') . "\""; |
8565 |
echo "\n href=\"".OM_ROUTE_FORM."&obj=dossier_instruction&action=3&idx="; |
echo "\n href=\"".OM_ROUTE_FORM."&obj=dossier_instruction&action=3&idx="; |
8566 |
echo $dossier->getVal("dossier"); |
echo $dossier->getVal("dossier"); |
8567 |
echo "\">"; |
echo "\">"; |
8568 |
echo "\n</a>"; |
echo "\n</a>"; |
8569 |
|
|
8570 |
echo "\n<a title=\""._("Consulter")."\" style=\"vertical-align:middle;\""; |
echo "\n<a title=\"".__("Consulter")."\" style=\"vertical-align:middle;\""; |
8571 |
echo " href=\"".OM_ROUTE_FORM."&obj="; |
echo " href=\"".OM_ROUTE_FORM."&obj="; |
8572 |
echo $obj; |
echo $obj; |
8573 |
echo "&action=3&idx="; |
echo "&action=3&idx="; |
8602 |
"champs" => $champs, |
"champs" => $champs, |
8603 |
)); |
)); |
8604 |
// Paramétrage du champ date du formulaire |
// Paramétrage du champ date du formulaire |
8605 |
$form->setLib("date", _("Date")."* :"); |
$form->setLib("date", __("Date")."* :"); |
8606 |
$form->setType("date", "date"); |
$form->setType("date", "date"); |
8607 |
$form->setOnchange("date", "fdate(this)"); |
$form->setOnchange("date", "fdate(this)"); |
8608 |
$form->setVal("date", ($date == "" ? date("d/m/Y") : $date)); |
$form->setVal("date", ($date == "" ? date("d/m/Y") : $date)); |
8609 |
$form->setTaille("date", 10); |
$form->setTaille("date", 10); |
8610 |
$form->setMax("date", 10); |
$form->setMax("date", 10); |
8611 |
// Paramétrage du champ liste_code_barres_instruction du formulaire |
// Paramétrage du champ liste_code_barres_instruction du formulaire |
8612 |
$form->setLib("liste_code_barres_instruction", _("Liste des codes barres d'instructions scannes")."* :"); |
$form->setLib("liste_code_barres_instruction", __("Liste des codes barres d'instructions scannes")."* :"); |
8613 |
$form->setType("liste_code_barres_instruction", "textarea"); |
$form->setType("liste_code_barres_instruction", "textarea"); |
8614 |
$form->setVal("liste_code_barres_instruction", $liste_code_barres_instruction); |
$form->setVal("liste_code_barres_instruction", $liste_code_barres_instruction); |
8615 |
$form->setTaille("liste_code_barres_instruction", 20); |
$form->setTaille("liste_code_barres_instruction", 20); |
8620 |
$form->enpied(); |
$form->enpied(); |
8621 |
// Affichage du bouton |
// Affichage du bouton |
8622 |
echo "\t<div class=\"formControls\">\n"; |
echo "\t<div class=\"formControls\">\n"; |
8623 |
$this->f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
$this->f->layout->display_form_button(array("value" => __("Valider"), "name" => "validation")); |
8624 |
echo "\t</div>\n"; |
echo "\t</div>\n"; |
8625 |
// Fermeture du formulaire |
// Fermeture du formulaire |
8626 |
echo "\t</form>\n"; |
echo "\t</form>\n"; |
8668 |
|
|
8669 |
// Si le formulaire a été validé |
// Si le formulaire a été validé |
8670 |
if ($this->f->get_submitted_post_value('validation') !== null) { |
if ($this->f->get_submitted_post_value('validation') !== null) { |
8671 |
if(!empty($type_mise_a_jour) and !empty($date) and !empty($code_barres)) { |
if(!empty($type_mise_a_jour) && !empty($date) && !empty($code_barres)) { |
|
|
|
|
// 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)."'"; |
|
8672 |
|
|
8673 |
// 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 |
8674 |
$group_clause = array(); |
$group_clause = array(); |
8680 |
$group_clause[$key] .= ")"; |
$group_clause[$key] .= ")"; |
8681 |
} |
} |
8682 |
$conditions = implode(" OR ", $group_clause); |
$conditions = implode(" OR ", $group_clause); |
8683 |
$sql .= " AND (" . $conditions . ")"; |
$groupFilter = " AND (" . $conditions . ")"; |
|
|
|
8684 |
|
|
8685 |
$res = $this->f->db->query($sql); |
$qres = $this->f->get_all_results_from_db_query( |
8686 |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
sprintf( |
8687 |
$this->f->isDatabaseError($res); |
'SELECT |
8688 |
|
instruction |
8689 |
if($res->numrows() == 1) { |
FROM |
8690 |
|
%1$sinstruction |
8691 |
|
INNER JOIN %1$sdossier |
8692 |
|
ON dossier.dossier = instruction.dossier |
8693 |
|
INNER JOIN %1$sdossier_instruction_type |
8694 |
|
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
8695 |
|
INNER JOIN %1$sdossier_autorisation_type_detaille |
8696 |
|
ON dossier_instruction_type.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
8697 |
|
INNER JOIN %1$sdossier_autorisation_type |
8698 |
|
ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
8699 |
|
INNER JOIN %1$sgroupe |
8700 |
|
ON dossier_autorisation_type.groupe = groupe.groupe |
8701 |
|
WHERE |
8702 |
|
code_barres = \'%2$s\' |
8703 |
|
%3$s', |
8704 |
|
DB_PREFIXE, |
8705 |
|
$this->f->db->escapeSimple($code_barres), |
8706 |
|
$groupFilter |
8707 |
|
), |
8708 |
|
array( |
8709 |
|
'origin' => __METHOD__ |
8710 |
|
) |
8711 |
|
); |
8712 |
|
if($qres['row_count'] === 1) { |
8713 |
$liste_champs = explode(";", $type_mise_a_jour); |
$liste_champs = explode(";", $type_mise_a_jour); |
8714 |
$row =& $res->fetchRow(DB_FETCHMODE_ASSOC); |
$row = array_shift($qres['result']); |
8715 |
$instr = $this->f->get_inst__om_dbform(array( |
$instr = $this->f->get_inst__om_dbform(array( |
8716 |
"obj" => "instruction", |
"obj" => "instruction", |
8717 |
"idx" => $row['instruction'], |
"idx" => $row['instruction'], |
8718 |
)); |
)); |
8719 |
// Mise à jour des dates après l'écran de verification |
// Mise à jour des dates après l'écran de verification |
8720 |
if($this->f->get_submitted_post_value('is_valid') !== null and $this->f->get_submitted_post_value('is_valid') == "true") { |
if($this->f->get_submitted_post_value('is_valid') !== null && $this->f->get_submitted_post_value('is_valid') == "true") { |
8721 |
$valF = array(); |
$valF = array(); |
8722 |
foreach($instr->champs as $id => $champ) { |
foreach($instr->champs as $id => $champ) { |
8723 |
$valF[$champ] = $instr->val[$id]; |
$valF[$champ] = $instr->val[$id]; |
8755 |
|
|
8756 |
// Vérification de la finalisation du document |
// Vérification de la finalisation du document |
8757 |
// correspondant au code barres |
// correspondant au code barres |
8758 |
if($valF["om_final_instruction"] === 't' or |
if($valF["om_final_instruction"] === 't' || |
8759 |
$valF["lettretype"] == '') { |
$valF["lettretype"] == '') { |
8760 |
$code_barres = ""; |
$code_barres = ""; |
8761 |
|
|
8792 |
// Indique que le traitement est en erreur |
// Indique que le traitement est en erreur |
8793 |
$correct = false; |
$correct = false; |
8794 |
// Message d'erreur |
// Message d'erreur |
8795 |
$error = sprintf(_("Le document n'est pas finalise."), |
$error = sprintf(__("Le document n'est pas finalise."), |
8796 |
"<span class='bold'>".$code_barres."</span>"); |
"<span class='bold'>".$code_barres."</span>"); |
8797 |
} |
} |
8798 |
} else { |
} else { |
8799 |
// Récupération des infos du dossier |
// Récupération des infos du dossier |
8800 |
$sqlInfo = "SELECT dossier.dossier_libelle, |
$qres = $this->f->get_all_results_from_db_query( |
8801 |
evenement.libelle as evenement, |
sprintf( |
8802 |
autorite_competente.code as autorite_competente_code, |
'SELECT |
8803 |
autorite_competente.libelle as autorite_competente, |
dossier.dossier_libelle, |
8804 |
evenement.type as evenement_type, |
evenement.libelle as evenement, |
8805 |
to_char(date_envoi_signature,'DD/MM/YYYY') as date_envoi_signature, |
autorite_competente.code as autorite_competente_code, |
8806 |
to_char(date_retour_signature,'DD/MM/YYYY') as date_retour_signature, |
autorite_competente.libelle as autorite_competente, |
8807 |
to_char(date_envoi_controle_legalite,'DD/MM/YYYY') as date_envoi_controle_legalite, |
evenement.type as evenement_type, |
8808 |
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, |
8809 |
to_char(date_envoi_rar,'DD/MM/YYYY') as date_envoi_rar, |
to_char(date_retour_signature,\'DD/MM/YYYY\') as date_retour_signature, |
8810 |
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, |
8811 |
FROM ".DB_PREFIXE."instruction |
to_char(date_retour_controle_legalite,\'DD/MM/YYYY\') as date_retour_controle_legalite, |
8812 |
INNER JOIN ".DB_PREFIXE."dossier ON |
to_char(date_envoi_rar,\'DD/MM/YYYY\') as date_envoi_rar, |
8813 |
dossier.dossier=instruction.dossier |
to_char(date_retour_rar,\'DD/MM/YYYY\') as date_retour_rar |
8814 |
LEFT JOIN ".DB_PREFIXE."autorite_competente ON |
FROM |
8815 |
dossier.autorite_competente=autorite_competente.autorite_competente |
%1$sinstruction |
8816 |
INNER JOIN ".DB_PREFIXE."evenement ON |
INNER JOIN %1$sdossier |
8817 |
instruction.evenement=evenement.evenement |
ON dossier.dossier=instruction.dossier |
8818 |
WHERE code_barres='".$code_barres."'"; |
LEFT JOIN %1$sautorite_competente |
8819 |
$resInfo = $this->f->db->query($sqlInfo); |
ON dossier.autorite_competente=autorite_competente.autorite_competente |
8820 |
$this->f->isDatabaseError($resInfo); |
INNER JOIN %1$sevenement |
8821 |
$infos = $resInfo->fetchRow(DB_FETCHMODE_ASSOC); |
ON instruction.evenement=evenement.evenement |
8822 |
|
WHERE |
8823 |
|
code_barres = \'%2$s\'', |
8824 |
|
DB_PREFIXE, |
8825 |
|
$this->f->db->escapeSimple($code_barres) |
8826 |
|
), |
8827 |
|
array( |
8828 |
|
"origin" => __METHOD__ |
8829 |
|
) |
8830 |
|
); |
8831 |
|
$infos = array_shift($qres['result']); |
8832 |
|
|
8833 |
// Vérification de la non modification des dates de suivi |
// Vérification de la non modification des dates de suivi |
8834 |
foreach(explode(";", $type_mise_a_jour) as $champ) { |
foreach(explode(";", $type_mise_a_jour) as $champ) { |
8839 |
break; |
break; |
8840 |
} |
} |
8841 |
} |
} |
8842 |
if($infos[$champ] != "" AND $infos[$champ] != $date) { |
if($infos[$champ] != "" && $infos[$champ] != $date) { |
8843 |
$error = _("Les dates de suivis ne peuvent etre modifiees"); |
$error = __("Les dates de suivis ne peuvent etre modifiees"); |
8844 |
$date_error = true; |
$date_error = true; |
8845 |
break; |
break; |
8846 |
} |
} |
8847 |
} |
} |
8848 |
} |
} |
8849 |
} else { |
} else { |
8850 |
$error = _("Le numero saisi ne correspond a aucun code barres d'instruction."); |
$error = __("Le numero saisi ne correspond a aucun code barres d'instruction."); |
8851 |
} |
} |
8852 |
|
|
8853 |
} else { |
} else { |
8854 |
$error = _("Tous les champs doivent etre remplis."); |
$error = __("Tous les champs doivent etre remplis."); |
8855 |
} |
} |
8856 |
} |
} |
8857 |
|
|
8869 |
|
|
8870 |
// Affichage du message de validation de la saisie |
// Affichage du message de validation de la saisie |
8871 |
if($correct === true) { |
if($correct === true) { |
8872 |
$this->f->displayMessage("ok", _("Saisie enregistree")); |
$this->f->displayMessage("ok", __("Saisie enregistree")); |
8873 |
} |
} |
8874 |
// Ouverture du formulaire |
// Ouverture du formulaire |
8875 |
echo "\t<form"; |
echo "\t<form"; |
8895 |
)); |
)); |
8896 |
// Paramétrage des champs du formulaire |
// Paramétrage des champs du formulaire |
8897 |
// Parametrage du champ type_mise_a_jour |
// Parametrage du champ type_mise_a_jour |
8898 |
$form->setLib("type_mise_a_jour", _("Date a mettre a jour")."* :"); |
$form->setLib("type_mise_a_jour", __("Date a mettre a jour")."* :"); |
8899 |
if(isset($infos)) { |
if(isset($infos)) { |
8900 |
$form->setType("type_mise_a_jour", "selecthiddenstatic"); |
$form->setType("type_mise_a_jour", "selecthiddenstatic"); |
8901 |
|
|
8907 |
$contenu = array(); |
$contenu = array(); |
8908 |
|
|
8909 |
$contenu[0][0] = "date_envoi_signature"; |
$contenu[0][0] = "date_envoi_signature"; |
8910 |
$contenu[1][0] = _("date d'envoi pour signature Mairie/Prefet"); |
$contenu[1][0] = __("date d'envoi pour signature Mairie/Prefet"); |
8911 |
|
|
8912 |
$contenu[0][1] = "date_retour_signature"; |
$contenu[0][1] = "date_retour_signature"; |
8913 |
$contenu[1][1] = _("date de retour de signature Mairie/Prefet"); |
$contenu[1][1] = __("date de retour de signature Mairie/Prefet"); |
8914 |
|
|
8915 |
$contenu[0][2] = "date_retour_signature;date_envoi_controle_legalite"; |
$contenu[0][2] = "date_retour_signature;date_envoi_controle_legalite"; |
8916 |
$contenu[1][2] = _("date de retour de signature + Envoi controle legalite"); |
$contenu[1][2] = __("date de retour de signature + Envoi controle legalite"); |
8917 |
|
|
8918 |
$contenu[0][3] = "date_envoi_controle_legalite"; |
$contenu[0][3] = "date_envoi_controle_legalite"; |
8919 |
$contenu[1][3] = _("date d'envoi au controle de legalite"); |
$contenu[1][3] = __("date d'envoi au controle de legalite"); |
8920 |
|
|
8921 |
$contenu[0][4] = "date_retour_controle_legalite"; |
$contenu[0][4] = "date_retour_controle_legalite"; |
8922 |
$contenu[1][4] = _("date de retour de controle de legalite"); |
$contenu[1][4] = __("date de retour de controle de legalite"); |
8923 |
|
|
8924 |
$contenu[0][5] = "date_retour_rar"; |
$contenu[0][5] = "date_retour_rar"; |
8925 |
$contenu[1][5] = __("date de notification du correspondant"); |
$contenu[1][5] = __("date de notification du correspondant"); |
8927 |
$form->setSelect("type_mise_a_jour", $contenu); |
$form->setSelect("type_mise_a_jour", $contenu); |
8928 |
|
|
8929 |
// Parametrage du champ date |
// Parametrage du champ date |
8930 |
$form->setLib("date", _("Date")."* :"); |
$form->setLib("date", __("Date")."* :"); |
8931 |
if(isset($infos)) { |
if(isset($infos)) { |
8932 |
$form->setType("date", "hiddenstaticdate"); |
$form->setType("date", "hiddenstaticdate"); |
8933 |
|
|
8939 |
$form->setMax("date", 10); |
$form->setMax("date", 10); |
8940 |
|
|
8941 |
// Parametrage du champ code_barres |
// Parametrage du champ code_barres |
8942 |
$form->setLib("code_barres", _("Code barres d'instruction")."* :"); |
$form->setLib("code_barres", __("Code barres d'instruction")."* :"); |
8943 |
if(isset($infos)) { |
if(isset($infos)) { |
8944 |
$form->setType("code_barres", "hiddenstatic"); |
$form->setType("code_barres", "hiddenstatic"); |
8945 |
} else { |
} else { |
8968 |
} |
} |
8969 |
|
|
8970 |
// Parametrage du champ dossier |
// Parametrage du champ dossier |
8971 |
$form->setLib("dossier_libelle", _("dossier_libelle")." :"); |
$form->setLib("dossier_libelle", __("dossier_libelle")." :"); |
8972 |
$form->setType("dossier_libelle", "static"); |
$form->setType("dossier_libelle", "static"); |
8973 |
$form->setVal("dossier_libelle", $infos['dossier_libelle']); |
$form->setVal("dossier_libelle", $infos['dossier_libelle']); |
8974 |
|
|
8975 |
// Parametrage du champ evenement |
// Parametrage du champ evenement |
8976 |
$form->setLib("evenement", _("evenement")." :"); |
$form->setLib("evenement", __("evenement")." :"); |
8977 |
$form->setType("evenement", "static"); |
$form->setType("evenement", "static"); |
8978 |
$form->setVal("evenement", $infos['evenement']); |
$form->setVal("evenement", $infos['evenement']); |
8979 |
|
|
8980 |
// Parametrage du champ autorite_competente |
// Parametrage du champ autorite_competente |
8981 |
$form->setLib("autorite_competente", _("Autorite competente")." :"); |
$form->setLib("autorite_competente", __("Autorite competente")." :"); |
8982 |
$form->setType("autorite_competente", "static"); |
$form->setType("autorite_competente", "static"); |
8983 |
$form->setVal("autorite_competente", $infos['autorite_competente']); |
$form->setVal("autorite_competente", $infos['autorite_competente']); |
8984 |
|
|
8986 |
$form->setLib("date_envoi_rar", __("date_envoi_ar")." :"); |
$form->setLib("date_envoi_rar", __("date_envoi_ar")." :"); |
8987 |
$form->setLib("date_retour_rar", __("date_notification")." :"); |
$form->setLib("date_retour_rar", __("date_notification")." :"); |
8988 |
|
|
8989 |
$form->setLib("date_envoi_signature", _("date_envoi_signature")." :"); |
$form->setLib("date_envoi_signature", __("date_envoi_signature")." :"); |
8990 |
$form->setLib("date_retour_signature", _("date_retour_signature")." :"); |
$form->setLib("date_retour_signature", __("date_retour_signature")." :"); |
8991 |
$form->setLib("date_envoi_controle_legalite", _("date_envoi_controle_legalite")." :"); |
$form->setLib("date_envoi_controle_legalite", __("date_envoi_controle_legalite")." :"); |
8992 |
$form->setLib("date_retour_controle_legalite", _("date_retour_controle_legalite")." :"); |
$form->setLib("date_retour_controle_legalite", __("date_retour_controle_legalite")." :"); |
8993 |
// Configuration des libellé en fonction de l'autorité compétente |
// Configuration des libellé en fonction de l'autorité compétente |
8994 |
if($infos['autorite_competente_code'] == 'ETAT') { |
if($infos['autorite_competente_code'] == 'ETAT') { |
8995 |
$form->setType("date_envoi_controle_legalite", "hiddendate"); |
$form->setType("date_envoi_controle_legalite", "hiddendate"); |
8997 |
} |
} |
8998 |
|
|
8999 |
// Ajout d'un champ hidden permettant de savoir que le formulaire précédant est celui de vérification |
// Ajout d'un champ hidden permettant de savoir que le formulaire précédant est celui de vérification |
9000 |
$form->setLib("is_valid", _("Valide")." :"); |
$form->setLib("is_valid", __("Valide")." :"); |
9001 |
$form->setType("is_valid", "hidden"); |
$form->setType("is_valid", "hidden"); |
9002 |
$form->setVal("is_valid", 'true'); |
$form->setVal("is_valid", 'true'); |
9003 |
|
|
9018 |
echo "\t<div class=\"formControls\">\n"; |
echo "\t<div class=\"formControls\">\n"; |
9019 |
// |
// |
9020 |
if(!$date_error) { |
if(!$date_error) { |
9021 |
$this->f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
$this->f->layout->display_form_button(array("value" => __("Valider"), "name" => "validation")); |
9022 |
} |
} |
9023 |
// Si pas sur l'écran de validation |
// Si pas sur l'écran de validation |
9024 |
if(isset($infos)) { |
if(isset($infos)) { |
9054 |
foreach ($listeCodeBarres as $code_barres) { |
foreach ($listeCodeBarres as $code_barres) { |
9055 |
|
|
9056 |
// On récupère le dossier |
// On récupère le dossier |
9057 |
$sql = "SELECT dossier |
$qres = $this->f->get_one_result_from_db_query( |
9058 |
FROM " . DB_PREFIXE . "instruction |
sprintf( |
9059 |
WHERE code_barres = '" . $code_barres . "'"; |
'SELECT |
9060 |
$dossier = $this->f->db->getOne($sql); |
dossier |
9061 |
$this->f->addToLog(__METHOD__."(): db->getOne(\"".$sql."\")", VERBOSE_MODE); |
FROM |
9062 |
$this->f->isDatabaseError($dossier); |
%1$sinstruction |
9063 |
|
WHERE |
9064 |
|
code_barres = \'%2$s\'', |
9065 |
|
DB_PREFIXE, |
9066 |
|
$this->f->db->escapeSimple($code_barres) |
9067 |
|
), |
9068 |
|
array( |
9069 |
|
"origin" => __METHOD__, |
9070 |
|
) |
9071 |
|
); |
9072 |
|
|
9073 |
$inst_dossier = $this->f->get_inst__om_dbform(array( |
$inst_dossier = $this->f->get_inst__om_dbform(array( |
9074 |
"obj" => "dossier", |
"obj" => "dossier", |
9075 |
"idx" => $dossier, |
"idx" => $qres['result'], |
9076 |
)); |
)); |
9077 |
|
|
9078 |
// 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 |
9093 |
} |
} |
9094 |
|
|
9095 |
// 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é |
9096 |
$sql = "SELECT |
$qres = $this->f->get_all_results_from_db_query( |
9097 |
|
sprintf( |
9098 |
|
'SELECT |
9099 |
dossier.dossier_libelle, |
dossier.dossier_libelle, |
9100 |
evenement.type, |
evenement.type, |
9101 |
count(lien_dossier_demandeur) as nbdemandeur, |
count(lien_dossier_demandeur) as nbdemandeur, |
9102 |
CASE |
CASE |
9103 |
WHEN division.libelle IS NOT NULL AND phase.code IS NOT NULL |
WHEN division.libelle IS NOT NULL AND phase.code IS NOT NULL |
9104 |
THEN CONCAT(phase.code, ' - ', division.libelle) |
THEN CONCAT(phase.code, \' - \', division.libelle) |
9105 |
ELSE |
ELSE |
9106 |
phase.code |
phase.code |
9107 |
END AS code_phase |
END AS code_phase |
9108 |
FROM ".DB_PREFIXE."instruction |
FROM |
9109 |
LEFT JOIN ".DB_PREFIXE."dossier |
%1$sinstruction |
9110 |
ON instruction.dossier = dossier.dossier |
LEFT JOIN %1$sdossier |
9111 |
LEFT JOIN ".DB_PREFIXE."division |
ON instruction.dossier = dossier.dossier |
9112 |
ON dossier.division = division.division |
LEFT JOIN %1$sdivision |
9113 |
INNER JOIN ".DB_PREFIXE."evenement ON |
ON dossier.division = division.division |
9114 |
instruction.evenement=evenement.evenement |
INNER JOIN %1$sevenement |
9115 |
LEFT JOIN ".DB_PREFIXE."phase |
ON instruction.evenement=evenement.evenement |
9116 |
ON evenement.phase = phase.phase |
LEFT JOIN %1$sphase |
9117 |
inner JOIN ".DB_PREFIXE."lien_dossier_demandeur ON |
ON evenement.phase = phase.phase |
9118 |
instruction.dossier=lien_dossier_demandeur.dossier |
inner JOIN %1$slien_dossier_demandeur |
9119 |
inner join ".DB_PREFIXE."demandeur on |
ON instruction.dossier=lien_dossier_demandeur.dossier |
9120 |
demandeur.demandeur=lien_dossier_demandeur.demandeur |
inner join %1$sdemandeur |
9121 |
WHERE code_barres='".$code_barres."' |
ON demandeur.demandeur=lien_dossier_demandeur.demandeur |
9122 |
AND " . $sql_demandeur . " |
WHERE |
9123 |
GROUP BY dossier.dossier_libelle, evenement.type, phase.code, division.libelle"; |
code_barres = \'%2$s\' |
9124 |
|
AND %3$s |
9125 |
$res = $this->f->db->query($sql); |
GROUP BY |
9126 |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
dossier.dossier_libelle, |
9127 |
$this->f->isDatabaseError($res); |
evenement.type, |
9128 |
$testDemandeur = $res->fetchrow(DB_FETCHMODE_ASSOC); |
phase.code, |
9129 |
|
division.libelle', |
9130 |
|
DB_PREFIXE, |
9131 |
|
$this->f->db->escapeSimple($code_barres), |
9132 |
|
$sql_demandeur |
9133 |
|
), |
9134 |
|
array( |
9135 |
|
"origin" => __METHOD__ |
9136 |
|
) |
9137 |
|
); |
9138 |
|
$testDemandeur = array_shift($qres['result']); |
9139 |
|
|
9140 |
|
|
9141 |
// 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."'"; |
|
|
|
|
9142 |
// Envoi pour delegataire ou petitionnaire principal selon le type d'evenement |
// Envoi pour delegataire ou petitionnaire principal selon le type d'evenement |
9143 |
if($testDemandeur['type'] != 'arrete' AND $testDemandeur['nbdemandeur'] > 1) { |
$sqlAdresse = " AND demandeur.type_demandeur='petitionnaire' AND lien_dossier_demandeur.petitionnaire_principal IS TRUE"; |
9144 |
$sqlAdresse .= " AND demandeur.type_demandeur='delegataire'"; |
if($testDemandeur['type'] != 'arrete' && $testDemandeur['nbdemandeur'] > 1) { |
9145 |
} else { |
$sqlAdresse = " AND demandeur.type_demandeur='delegataire'"; |
|
$sqlAdresse .= " AND demandeur.type_demandeur='petitionnaire' AND lien_dossier_demandeur.petitionnaire_principal IS TRUE"; |
|
9146 |
} |
} |
9147 |
|
|
9148 |
$resAdresse = $this->f->db->query($sqlAdresse); |
$qres = $this->f->get_all_results_from_db_query( |
9149 |
$adresse_dest = $resAdresse->fetchrow(DB_FETCHMODE_ASSOC); |
sprintf( |
9150 |
$this->f->addToLog(__METHOD__.": db->query(\"".$sqlAdresse."\")", VERBOSE_MODE); |
'SELECT |
9151 |
$this->f->isDatabaseError($resAdresse); |
CASE WHEN demandeur.qualite = \'particulier\' |
9152 |
|
THEN TRIM(CONCAT_WS(\' \', pc.libelle, demandeur.particulier_nom, demandeur.particulier_prenom)) |
9153 |
|
ELSE TRIM(demandeur.personne_morale_denomination) |
9154 |
|
END as ligne1, |
9155 |
|
CASE WHEN demandeur.qualite = \'personne_morale\' |
9156 |
|
THEN TRIM(demandeur.personne_morale_raison_sociale) |
9157 |
|
ELSE \'\' |
9158 |
|
END as ligne1_1, |
9159 |
|
CASE WHEN demandeur.qualite = \'personne_morale\' AND (demandeur.personne_morale_nom IS NOT NULL OR demandeur.personne_morale_prenom IS NOT NULL) |
9160 |
|
THEN TRIM(CONCAT_WS(\' \', \'rep. par\', demandeur.personne_morale_nom, demandeur.personne_morale_prenom)) |
9161 |
|
ELSE \'\' |
9162 |
|
END as ligne1_2, |
9163 |
|
trim(concat(demandeur.numero,\' \',demandeur.voie)) as ligne2, |
9164 |
|
CASE demandeur.complement |
9165 |
|
WHEN null THEN \'\' |
9166 |
|
ELSE trim(demandeur.complement) |
9167 |
|
END as ligne3, |
9168 |
|
CASE demandeur.lieu_dit |
9169 |
|
WHEN null THEN \'\' |
9170 |
|
ELSE trim(demandeur.lieu_dit) |
9171 |
|
END as ligne4, |
9172 |
|
CONCAT_WS(\' \', demandeur.code_postal, demandeur.localite, |
9173 |
|
(CASE WHEN demandeur.bp IS NOT NULL |
9174 |
|
THEN CONCAT_WS(\' \', \'BP\', demandeur.bp) |
9175 |
|
ELSE \'\' |
9176 |
|
END), |
9177 |
|
(CASE WHEN demandeur.cedex IS NOT NULL |
9178 |
|
THEN CONCAT_WS(\' \', \'CEDEX\', demandeur.cedex) |
9179 |
|
ELSE \'\' |
9180 |
|
END)) |
9181 |
|
as ligne5, |
9182 |
|
code_barres as code_barres |
9183 |
|
FROM |
9184 |
|
%1$sinstruction |
9185 |
|
INNER JOIN %1$sdossier |
9186 |
|
ON dossier.dossier = instruction.dossier |
9187 |
|
INNER JOIN %1$slien_dossier_demandeur |
9188 |
|
ON dossier.dossier = lien_dossier_demandeur.dossier |
9189 |
|
INNER JOIN %1$sdemandeur |
9190 |
|
ON lien_dossier_demandeur.demandeur = demandeur.demandeur |
9191 |
|
LEFT OUTER JOIN %1$scivilite AS pc |
9192 |
|
ON demandeur.particulier_civilite = pc.civilite |
9193 |
|
OR demandeur.personne_morale_civilite = pc.civilite |
9194 |
|
WHERE |
9195 |
|
instruction.code_barres = \'%2$s\' |
9196 |
|
%3$s', |
9197 |
|
DB_PREFIXE, |
9198 |
|
$this->f->db->escapeSimple($code_barres), |
9199 |
|
$sqlAdresse |
9200 |
|
), |
9201 |
|
array( |
9202 |
|
"origin" => __METHOD__ |
9203 |
|
) |
9204 |
|
); |
9205 |
|
$adresse_dest = array_shift($qres['result']); |
9206 |
|
|
9207 |
// Création adresse destinataire sans ligne vide |
// Création adresse destinataire sans ligne vide |
9208 |
$adresse_destinataire = array(); |
$adresse_destinataire = array(); |
9238 |
} |
} |
9239 |
$pdf_output = $pdf_lettre_rar->output("lettre_rar".date("dmYHis").".pdf","S"); |
$pdf_output = $pdf_lettre_rar->output("lettre_rar".date("dmYHis").".pdf","S"); |
9240 |
$om_edition = $this->f->get_inst__om_edition(); |
$om_edition = $this->f->get_inst__om_edition(); |
9241 |
|
$om_edition->set_object_linked($this); |
9242 |
$om_edition->expose_pdf_output($pdf_output, "lettre_rar".date("dmYHis").".pdf"); |
$om_edition->expose_pdf_output($pdf_output, "lettre_rar".date("dmYHis").".pdf"); |
9243 |
} |
} |
9244 |
} |
} |
9296 |
if($ret === true) { |
if($ret === true) { |
9297 |
// Message de validation avec lien PDF |
// Message de validation avec lien PDF |
9298 |
$message_class = "valid"; |
$message_class = "valid"; |
9299 |
$message = '• '._("Veuillez cliquer sur le lien ci-dessous pour telecharger votre bordereau"); |
$message = '• '.__("Veuillez cliquer sur le lien ci-dessous pour telecharger votre bordereau"); |
9300 |
$message .= " : <br/><br/>"; |
$message .= " : <br/><br/>"; |
9301 |
$message .= "<a class='om-prev-icon pdf-16'"; |
$message .= "<a class='om-prev-icon pdf-16'"; |
9302 |
$message .= " id=\"generer_bordereau_envoi_maire\""; |
$message .= " id=\"generer_bordereau_envoi_maire\""; |
9303 |
$message .= " title=\""._("Bordereau")."\""; |
$message .= " title=\"".__("Bordereau")."\""; |
9304 |
$message .= " href='".OM_ROUTE_FORM."&obj=instruction"; |
$message .= " href='".OM_ROUTE_FORM."&obj=instruction"; |
9305 |
$message .= "&action=200"; |
$message .= "&action=200"; |
9306 |
$message .= "&idx=".$id_instruction."'"; |
$message .= "&idx=".$id_instruction."'"; |
9307 |
$message .= " target='_blank'>"; |
$message .= " target='_blank'>"; |
9308 |
$message .= _("Bordereau d'envoi au maire"); |
$message .= __("Bordereau d'envoi au maire"); |
9309 |
$message .= "</a><br/><br/>"; |
$message .= "</a><br/><br/>"; |
9310 |
$message .= '• '._("Rappel des informations saisies")." :<br/><br/>"; |
$message .= '• '.__("Rappel des informations saisies")." :<br/><br/>"; |
9311 |
$message .= _("Code du courrier")." : ".$code_barres."<br/>"; |
$message .= __("Code du courrier")." : ".$code_barres."<br/>"; |
9312 |
$message .= _("Date d'envoi du courrier pour signature par le maire")." : ".$date; |
$message .= __("Date d'envoi du courrier pour signature par le maire")." : ".$date; |
9313 |
|
|
9314 |
} else { |
} else { |
9315 |
// Message d'erreur |
// Message d'erreur |
9316 |
$message_class = "error"; |
$message_class = "error"; |
9317 |
$message = sprintf(_("Erreur lors de la mise a jour de l'evenement d'instruction correspondant au code barres %s."), |
$message = sprintf(__("Erreur lors de la mise a jour de l'evenement d'instruction correspondant au code barres %s."), |
9318 |
$code_barres); |
$code_barres); |
9319 |
} |
} |
9320 |
} |
} |
9321 |
else { |
else { |
9322 |
$message_class = "error"; |
$message_class = "error"; |
9323 |
$message = _("Le numero saisi ne correspond a aucun code-barres d'evenement d'instruction."); |
$message = __("Le numero saisi ne correspond a aucun code-barres d'evenement d'instruction."); |
9324 |
} |
} |
9325 |
} |
} |
9326 |
else { |
else { |
9327 |
$message_class = "error"; |
$message_class = "error"; |
9328 |
$message = _("La date est invalide."); |
$message = __("La date est invalide."); |
9329 |
} |
} |
9330 |
} else { |
} else { |
9331 |
$message_class = "error"; |
$message_class = "error"; |
9332 |
$message = _("Tous les champs doivent etre remplis."); |
$message = __("Tous les champs doivent etre remplis."); |
9333 |
} |
} |
9334 |
} |
} |
9335 |
|
|
9391 |
// Affichage du bouton |
// Affichage du bouton |
9392 |
printf("\t<div class=\"formControls\">\n"); |
printf("\t<div class=\"formControls\">\n"); |
9393 |
// |
// |
9394 |
$this->f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
$this->f->layout->display_form_button(array("value" => __("Valider"), "name" => "validation")); |
9395 |
printf("\t</div>\n"); |
printf("\t</div>\n"); |
9396 |
// Fermeture du formulaire |
// Fermeture du formulaire |
9397 |
printf("\t</form>\n"); |
printf("\t</form>\n"); |
9493 |
$this->getVal('dossier') |
$this->getVal('dossier') |
9494 |
); |
); |
9495 |
} |
} |
9496 |
|
|
9497 |
|
/** |
9498 |
|
* VIEW - view_modale_selection_document_signe |
9499 |
|
* |
9500 |
|
* Ouvre le sous-formulaire de notification des services consulte |
9501 |
|
* en ajaxIt dans un overlay. |
9502 |
|
* Cette action est bindée pour utiliser la fonction popUpIt. |
9503 |
|
* |
9504 |
|
* @return void |
9505 |
|
*/ |
9506 |
|
function view_modale_selection_document_signe() { |
9507 |
|
|
9508 |
|
// Vérification de l'accessibilité sur l'élément |
9509 |
|
$this->checkAccessibility(); |
9510 |
|
|
9511 |
|
printf( |
9512 |
|
'<script type="text/javascript" > |
9513 |
|
overlayIt(\'%1$s\',\'%2$s&objsf=%1$s&idxformulaire=%4$s&retourformulaire=dossier_instruction&obj=%1$s&action=115&idx=%3$s\', 1); |
9514 |
|
</script>', |
9515 |
|
'instruction_modale', |
9516 |
|
OM_ROUTE_SOUSFORM, |
9517 |
|
$this->getVal($this->clePrimaire), |
9518 |
|
$this->getVal('dossier') |
9519 |
|
); |
9520 |
|
} |
9521 |
|
|
9522 |
/** |
/** |
9523 |
* Retourne l'événement d'instruction dont on donne le code-barres, avec un filtre |
* Retourne l'événement d'instruction dont on donne le code-barres, avec un filtre |
9524 |
* pour exclure les dossiers du groupe contentieux. |
* pour exclure les dossiers du groupe contentieux. |
9529 |
function get_instruction_by_barcode($barcode) { |
function get_instruction_by_barcode($barcode) { |
9530 |
// Begin |
// Begin |
9531 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
9532 |
|
|
9533 |
// Vérification de l'existence de l'événement d'instruction |
// Vérification de l'existence de l'événement d'instruction |
9534 |
// 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 |
9535 |
$sql = "SELECT instruction |
$qres = $this->f->get_one_result_from_db_query( |
9536 |
FROM ".DB_PREFIXE."instruction |
sprintf( |
9537 |
INNER JOIN ".DB_PREFIXE."dossier |
'SELECT |
9538 |
|
instruction |
9539 |
|
FROM |
9540 |
|
%1$sinstruction |
9541 |
|
INNER JOIN %1$sdossier |
9542 |
ON dossier.dossier=instruction.dossier |
ON dossier.dossier=instruction.dossier |
9543 |
INNER JOIN ".DB_PREFIXE."dossier_instruction_type |
INNER JOIN %1$sdossier_instruction_type |
9544 |
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
9545 |
INNER JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille |
INNER JOIN %1$sdossier_autorisation_type_detaille |
9546 |
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 |
9547 |
INNER JOIN ".DB_PREFIXE."dossier_autorisation_type |
INNER JOIN %1$sdossier_autorisation_type |
9548 |
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 |
9549 |
INNER JOIN ".DB_PREFIXE."groupe |
INNER JOIN %1$sgroupe |
9550 |
ON dossier_autorisation_type.groupe = groupe.groupe |
ON dossier_autorisation_type.groupe = groupe.groupe |
9551 |
AND groupe.code != 'CTX' |
AND groupe.code != \'CTX\' |
9552 |
WHERE code_barres = '".$this->f->db->escapesimple($barcode)."'"; |
WHERE |
9553 |
$res = $this->f->db->getOne($sql); |
code_barres = \'%2$s\'', |
9554 |
$this->f->addToLog(__METHOD__." : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
DB_PREFIXE, |
9555 |
$this->f->isDatabaseError($res); |
$this->f->db->escapeSimple($barcode) |
9556 |
|
), |
9557 |
|
array( |
9558 |
|
"origin" => __METHOD__, |
9559 |
|
) |
9560 |
|
); |
9561 |
|
|
9562 |
// Retourne résultat |
// Retourne résultat |
9563 |
return $this->end_treatment(__METHOD__, $res); |
return $this->end_treatment(__METHOD__, $qres['result']); |
9564 |
} |
} |
9565 |
|
|
9566 |
/** |
/** |
9578 |
// Begin |
// Begin |
9579 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
9580 |
// Requête |
// Requête |
9581 |
$res = $this->f->db->autoExecute( |
$res = $this->f->db->autoexecute( |
9582 |
DB_PREFIXE.$this->table, |
DB_PREFIXE.$this->table, |
9583 |
$valF, |
$valF, |
9584 |
DB_AUTOQUERY_UPDATE, |
DB_AUTOQUERY_UPDATE, |
9585 |
$this->getCle($id) |
$this->getCle($id) |
9586 |
); |
); |
9587 |
// S'il y a eu une erreur |
$this->addToLog( |
9588 |
if (database::isError($res, true)) { |
__METHOD__."(): db->autoexecute(\"".DB_PREFIXE.'.'.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($id)."\");", |
9589 |
|
VERBOSE_MODE |
9590 |
|
); |
9591 |
|
if ($this->f->isDatabaseError($res, true) !== false) { |
9592 |
$this->end_treatment(__METHOD__, false); |
$this->end_treatment(__METHOD__, false); |
9593 |
} |
} |
9594 |
// |
// |
9761 |
// 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 |
9762 |
// dites de TREATMENT. |
// dites de TREATMENT. |
9763 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
9764 |
$message = __('Erreur de paramétrage :'); |
$message = __('Erreur de paramétrage :'); |
9765 |
$erreurParametrage = false; |
$erreurParametrage = false; |
9766 |
// Récupération du paramétrage de la collectivité du dossier |
// Récupération du paramétrage de la collectivité du dossier |
9767 |
$id_di = $this->getVal('dossier'); |
$id_di = $this->getVal('dossier'); |
10003 |
'idx' => $this->getVal('dossier'), |
'idx' => $this->getVal('dossier'), |
10004 |
)); |
)); |
10005 |
|
|
10006 |
|
//Instanciation de la classe electronicsignature |
10007 |
|
$inst_es = $this->get_electronicsignature_instance(); |
10008 |
|
if ($inst_es === false) { |
10009 |
|
$this->correct = false; |
10010 |
|
return $this->end_treatment(__METHOD__, false); |
10011 |
|
} |
10012 |
|
|
10013 |
|
// Vérifie si la notification se fait via l'application ou via le parapheur |
10014 |
|
try { |
10015 |
|
$notification_required = $inst_es->signer_notification_is_delegated(); |
10016 |
|
} catch(electronicsignature_connector_method_not_implemented_exception $_) { |
10017 |
|
// Si la méthode n'existe pas, on considère que la notification est faite par le parapheur |
10018 |
|
$notification_required = false; |
10019 |
|
} |
10020 |
|
|
10021 |
|
// Si la notification est faite par l'application vérifie que l'adresse mail du |
10022 |
|
// signataire est correcte. Si ce n'est pas le cas le document n'est pas envoyé |
10023 |
|
// au parapheur car il ne sera pas accessible sans le lien transmis dans la |
10024 |
|
// notification |
10025 |
|
if ($notification_required === true) { |
10026 |
|
$signer_mail = $inst_signataire_arrete->getVal('email'); |
10027 |
|
$signer_name = trim($inst_signataire_arrete->getVal('prenom').' '.$inst_signataire_arrete->getVal('nom')); |
10028 |
|
|
10029 |
|
$err_msg = __('Le document n\'a pas pu être envoyé en signature car '); |
10030 |
|
|
10031 |
|
if (empty($signer_mail)) { |
10032 |
|
$this->correct = false; |
10033 |
|
$err_detail = sprintf(__("l'email du signataire '%s' est vide."), $signer_name); |
10034 |
|
$this->addToMessage($err_msg.$err_detail); |
10035 |
|
$this->addToLog(__METHOD__.$err_msg.$err_detail.' Instruction : '.$this->getVal($this->clePrimaire), DEBUG_MODE); |
10036 |
|
return $this->end_treatment(__METHOD__, false); |
10037 |
|
} |
10038 |
|
if (! $this->f->checkValidEmailAddress($signer_mail)) { |
10039 |
|
$this->correct = false; |
10040 |
|
$err_detail = sprintf(__("l'email du signataire '%s' est invalide (%s)."), $signer_name, $signer_mail); |
10041 |
|
$this->addToMessage($err_msg.$err_detail); |
10042 |
|
$this->addToLog(__METHOD__.$err_msg.$err_detail.' Instruction : '.$this->getVal($this->clePrimaire), DEBUG_MODE); |
10043 |
|
return $this->end_treatment(__METHOD__, false); |
10044 |
|
} |
10045 |
|
} |
10046 |
|
|
10047 |
// Récupération du document à signer |
// Récupération du document à signer |
10048 |
$file = $this->f->storage->get($this->getVal('om_fichier_instruction')); |
$file = $this->f->storage->get($this->getVal('om_fichier_instruction')); |
10049 |
if ($file === OP_FAILURE) { |
if ($file === OP_FAILURE) { |
10054 |
} |
} |
10055 |
|
|
10056 |
// Initialisation des paramètre à passer pour l'envoi en signature |
// Initialisation des paramètre à passer pour l'envoi en signature |
10057 |
|
$this->f->getUserInfos(); |
10058 |
$data = array( |
$data = array( |
10059 |
"om_utilisateur_email" => $this->f->om_utilisateur['email'], |
"om_utilisateur_email" => $this->f->om_utilisateur['email'], |
10060 |
"om_utilisateur_nom" => $this->f->om_utilisateur['nom'], |
"om_utilisateur_nom" => $this->f->om_utilisateur['nom'], |
10062 |
"signataire_arrete_nom" => $inst_signataire_arrete->getVal('nom'), |
"signataire_arrete_nom" => $inst_signataire_arrete->getVal('nom'), |
10063 |
"signataire_arrete_prenom" => $inst_signataire_arrete->getVal('prenom'), |
"signataire_arrete_prenom" => $inst_signataire_arrete->getVal('prenom'), |
10064 |
// 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 |
10065 |
"date_limite_instruction" => $this->compute_date_limite(1), |
"date_limite_instruction" => $this->compute_date_limite(1) != null ? $this->compute_date_limite(1) : null, |
10066 |
"dossier" => $this->getVal('dossier'), |
"dossier" => $this->getVal('dossier'), |
10067 |
"is_forced_view_files" => $is_forced_view_files, |
"is_forced_view_files" => $is_forced_view_files, |
10068 |
'commentaire_signature' => $is_forced_view_files === true ? __('relecture demandee.') : null |
'commentaire_signature' => $is_forced_view_files === true ? __('relecture demandee.') : null, |
10069 |
|
'instruction' => $this->getVal($this->clePrimaire), |
10070 |
|
'last_statut_signature' => $this->getVal('statut_signature'), |
10071 |
|
'last_commentaire_signature' => $this->getVal('commentaire_signature'), |
10072 |
); |
); |
10073 |
|
|
10074 |
// Initialisation des métadonnées |
// Initialisation des métadonnées |
10075 |
$metadonnee_dossier = $file['metadata']; |
$metadonnee_dossier = $file['metadata']; |
10076 |
// récupération de l'extension du fichier |
// Récupération du libellé du document transmis au parapheur |
10077 |
$extension = substr($metadonnee_dossier['filename'], strrpos($metadonnee_dossier['filename'], '.')); |
$metadonnee_dossier['filename'] = $this->getVal('fichier_instruction_name'); |
|
// Modification du libellé du document transmis au parapheur |
|
|
// pour le mettre sous la forme : instruction_xxx_libelle_lettretype.extension |
|
|
$metadonnee_dossier['filename'] = $this->getDocumentLibelle().$extension; |
|
10078 |
$metadonnee_dossier['titre_document'] = $this->getDocumentTitre(); |
$metadonnee_dossier['titre_document'] = $this->getDocumentTitre(); |
10079 |
|
|
10080 |
$metadonnee_dossier['url_di'] = sprintf( |
$metadonnee_dossier['url_di'] = sprintf( |
10081 |
'%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', |
10082 |
$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, |
10083 |
$this->getVal($this->clePrimaire) |
$this->getVal('dossier') |
10084 |
); |
); |
10085 |
|
|
10086 |
$optional_data = null; |
$optional_data = null; |
10099 |
} |
} |
10100 |
} |
} |
10101 |
|
|
|
//Instanciation de la classe electronicsignature |
|
|
$inst_es = $this->get_electronicsignature_instance(); |
|
|
if ($inst_es === false) { |
|
|
$this->correct = false; |
|
|
return $this->end_treatment(__METHOD__, false); |
|
|
} |
|
|
|
|
10102 |
// Appel de la méthode de l'abstracteur send_for_signature() |
// Appel de la méthode de l'abstracteur send_for_signature() |
10103 |
// Cette méthode doit retourner un tableau de valeur |
// Cette méthode doit retourner un tableau de valeur |
10104 |
try { |
try { |
10121 |
$valF['commentaire_signature'] = isset($result['commentaire_signature']) == true ? $result['commentaire_signature'] : null; |
$valF['commentaire_signature'] = isset($result['commentaire_signature']) == true ? $result['commentaire_signature'] : null; |
10122 |
$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'])); |
10123 |
$valF['historique_signature'] = $this->get_updated_historique_signature($result); |
$valF['historique_signature'] = $this->get_updated_historique_signature($result); |
10124 |
|
$valF['parapheur_lien_page_signature'] = isset($result['signature_page_url']) ? $result['signature_page_url'] : null; |
10125 |
|
$this->setParameter("maj", 1); |
10126 |
$ret = $this->modifier($valF); |
$ret = $this->modifier($valF); |
10127 |
|
|
10128 |
if ($ret === false) { |
if ($ret === false) { |
10132 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
10133 |
} |
} |
10134 |
|
|
10135 |
|
// Notification du signataire |
10136 |
|
if ($notification_required === true) { |
10137 |
|
if ($this->notify_signer($signer_name, $signer_mail, $data['om_utilisateur_nom']) === false) { |
10138 |
|
$msg = __("Une erreur s'est produite lors de la notification du signataire \"%s (%s)\". Annulation de l'envoi pour signature du document%s."); |
10139 |
|
$this->addToMessage(sprintf($msg, $signer_name, $signer_mail, '')); |
10140 |
|
$this->addToLog(sprintf($msg, $signer_name, $signer_mail, ' : '.$this->getVal($this->clePrimaire)), DEBUG_MODE); |
10141 |
|
// Met à jour les valeurs de l'objet courant pour prendre en compte les modifications faites |
10142 |
|
// precedemment |
10143 |
|
$this->init_record_data($this->getVal($this->clePrimaire)); |
10144 |
|
$this->annuler_envoi_en_signature(); |
10145 |
|
$this->correct = false; |
10146 |
|
return $this->end_treatment(__METHOD__, true); |
10147 |
|
} |
10148 |
|
} |
10149 |
|
|
10150 |
// Message |
// Message |
10151 |
$this->addToMessage(__("Le document a été envoyé pour signature dans le parapheur.")); |
$this->addToMessage(__("Le document a été envoyé pour signature dans le parapheur.")); |
10152 |
if (array_key_exists('signature_page_url', $result) === true) { |
if ($this->f->is_option_enabled('option_afficher_lien_parapheur') === true |
10153 |
|
&& array_key_exists('signature_page_url', $result) === true) { |
10154 |
$this->addToMessage(sprintf( |
$this->addToMessage(sprintf( |
10155 |
'<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>', |
10156 |
$result['signature_page_url'], |
$result['signature_page_url'], |
10157 |
__("Signez directement le document") |
__("Signez directement le document") |
10158 |
)); |
)); |
10159 |
} |
} |
10160 |
|
if ($notification_required !== true) { |
10161 |
|
$this->addToMessage(__("L'envoi de la notification au signataire est effectué par la plateforme.")); |
10162 |
|
} |
10163 |
|
|
10164 |
// Tout s'est bien passé, on termine le traitement |
// Tout s'est bien passé, on termine le traitement |
10165 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
10166 |
} |
} |
10167 |
|
|
10168 |
/** |
/** |
10169 |
|
* Notifie le signataire d'un document à signer. |
10170 |
|
* Gère l'affichage des messages à destination de l'utilisateur selon l'état du traitement. |
10171 |
|
* En cas d'erreur ajoute une ligne dans les logs de l'application. |
10172 |
|
* |
10173 |
|
* @param string $signer_name Nom du signataire |
10174 |
|
* @param string $signer_mail Mail du signataire |
10175 |
|
* @param string $user_name Nom de l'utilisateur openADS courant |
10176 |
|
* |
10177 |
|
* @return boolean true si succés, false si erreur |
10178 |
|
*/ |
10179 |
|
protected function notify_signer($signer_name, $signer_mail, $user_name) { |
10180 |
|
// message d'erreur |
10181 |
|
$err_msg_log = sprintf( |
10182 |
|
__("Échec de la notification du signataire \"%s (%s)\" lors de l'envoi au parapaheur du document de l'instruction : %s"), |
10183 |
|
$signer_name, |
10184 |
|
$signer_mail, |
10185 |
|
$this->getVal($this->clePrimaire) |
10186 |
|
); |
10187 |
|
$err_msg = sprintf( |
10188 |
|
'%s %s (%s)"', |
10189 |
|
__("Échec de la notification du signataire"), |
10190 |
|
$signer_name, |
10191 |
|
$signer_mail |
10192 |
|
); |
10193 |
|
|
10194 |
|
// vérification des informations requises |
10195 |
|
if (empty($signer_name)) { |
10196 |
|
$err_detail = __("le nom du signataire est vide"); |
10197 |
|
$this->addToLog(__METHOD__.', '.$err_msg_log.', '.$err_detail, DEBUG_MODE); |
10198 |
|
$this->addToMessage($err_msg.', '.$err_detail); |
10199 |
|
return false; |
10200 |
|
} |
10201 |
|
if (empty($signer_mail)) { |
10202 |
|
$err_detail = __("le courriel du signataire est vide"); |
10203 |
|
$this->addToLog(__METHOD__.', '.$err_msg_log.', '.$err_detail, DEBUG_MODE); |
10204 |
|
$this->addToMessage($err_msg.', '.$err_detail); |
10205 |
|
return false; |
10206 |
|
} |
10207 |
|
if (empty($this->getVal('dossier'))) { |
10208 |
|
$err_detail = __("l'identifiant du dossier est vide"); |
10209 |
|
$this->addToLog(__METHOD__.', '.$err_msg_log.', '.$err_detail, DEBUG_MODE); |
10210 |
|
$this->addToMessage($err_msg.', '.$err_detail); |
10211 |
|
return false; |
10212 |
|
} |
10213 |
|
|
10214 |
|
// ajout de la notification à la liste des notifications de l'instruction |
10215 |
|
$instruction_id = $this->getVal($this->clePrimaire); |
10216 |
|
$inst_notif = $this->f->get_inst__om_dbform(array( |
10217 |
|
"obj" => "instruction_notification", |
10218 |
|
"idx" => "]", |
10219 |
|
)); |
10220 |
|
$notif_val = array( |
10221 |
|
'instruction_notification' => null, |
10222 |
|
'instruction' => $instruction_id, |
10223 |
|
'automatique' => true, |
10224 |
|
'emetteur' => $user_name, |
10225 |
|
'date_envoi' => null, |
10226 |
|
'destinataire' => "$signer_name <$signer_mail>", |
10227 |
|
'courriel' => $signer_mail, |
10228 |
|
'date_premier_acces' => null, |
10229 |
|
'statut' => '', |
10230 |
|
'commentaire' => '' |
10231 |
|
); |
10232 |
|
$add_notif = $inst_notif->ajouter($notif_val); |
10233 |
|
if ($add_notif === false) { |
10234 |
|
$err_detail = __("Échec de l'ajout de la notification."); |
10235 |
|
$this->addToLog(__METHOD__.' '.$err_msg_log.'. '.$err_detail.' Notification : '.var_export($notif_val, true), DEBUG_MODE); |
10236 |
|
$this->addToMessage($err_msg); |
10237 |
|
return false; |
10238 |
|
} |
10239 |
|
$notification_id = $inst_notif->getVal($inst_notif->clePrimaire); |
10240 |
|
|
10241 |
|
// ajout d'une tâche de notification (envoi du mail) |
10242 |
|
$notification_task = $this->notification_by_task( |
10243 |
|
$notification_id, |
10244 |
|
$this->getVal('dossier'), |
10245 |
|
'mail', |
10246 |
|
'notification_signataire' |
10247 |
|
); |
10248 |
|
if ($notification_task === false) { |
10249 |
|
$err_detail = sprintf( |
10250 |
|
__("Échec de l'ajout de la tâche de notification (notification %s)."), |
10251 |
|
$notification_id); |
10252 |
|
$this->addToLog(__METHOD__.' '.$err_msg_log.'. '.$err_detail, DEBUG_MODE); |
10253 |
|
$this->addToMessage($err_msg); |
10254 |
|
return false; |
10255 |
|
} |
10256 |
|
|
10257 |
|
// Vérification de la réussite de l'envoi du mail |
10258 |
|
// Fais une requête pour récupérer la liste des notifications de signataire faites par mail |
10259 |
|
// et associées à l'instruction en cours. Récupère uniquement la dernière qui doit être celle |
10260 |
|
// qui viens d'être créée. |
10261 |
|
// Si la tâche d'envoi du mail est en erreur alors on considère que l'envoi du mail a échoué. |
10262 |
|
$qres = $this->f->get_one_result_from_db_query( |
10263 |
|
sprintf( |
10264 |
|
'SELECT |
10265 |
|
state |
10266 |
|
FROM |
10267 |
|
%1$stask |
10268 |
|
WHERE |
10269 |
|
type = \'notification_signataire\' |
10270 |
|
AND category = \'mail\' |
10271 |
|
AND dossier = \'%2$s\' |
10272 |
|
ORDER BY |
10273 |
|
task DESC |
10274 |
|
LIMIT 1', |
10275 |
|
DB_PREFIXE, |
10276 |
|
$this->f->db->escapeSimple($this->getVal('dossier')) |
10277 |
|
), |
10278 |
|
array( |
10279 |
|
'origin' => __METHOD__ |
10280 |
|
) |
10281 |
|
); |
10282 |
|
if ($qres['result'] === 'error') { |
10283 |
|
$err_detail = sprintf( |
10284 |
|
__("Échec de l'envoi du mail de notification (notification %s)."), |
10285 |
|
$notification_id); |
10286 |
|
$this->addToLog(__METHOD__.' '.$err_msg_log.'. '.$err_detail, DEBUG_MODE); |
10287 |
|
$this->addToMessage($err_msg); |
10288 |
|
return false; |
10289 |
|
} |
10290 |
|
// TODO gérer les autres cas (gestion d'erreur) |
10291 |
|
|
10292 |
|
// succès de la planification de la notification |
10293 |
|
$this->addToMessage(sprintf( |
10294 |
|
__('Le signataire "%s (%s)" sera notifié prochainement'), |
10295 |
|
$signer_name, |
10296 |
|
$signer_mail)); |
10297 |
|
return true; |
10298 |
|
} |
10299 |
|
|
10300 |
|
/** |
10301 |
* 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 |
10302 |
* est en incomplet notifié ou non. |
* est en incomplet notifié ou non. |
10303 |
* 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". |
10321 |
} else { |
} else { |
10322 |
$date_to_compute = $inst_dossier->getVal('date_limite'); |
$date_to_compute = $inst_dossier->getVal('date_limite'); |
10323 |
} |
} |
10324 |
|
if ($date_to_compute != null) { |
10325 |
|
return date("Y-m-d", strtotime($date_to_compute."+ $delay days")); |
10326 |
|
} |
10327 |
|
|
10328 |
$date_limite = date("Y-m-d", strtotime($date_to_compute."+ $delay days")); |
return null; |
|
|
|
|
return $date_limite; |
|
10329 |
} |
} |
10330 |
|
|
10331 |
/** |
/** |
10470 |
$valF['date_envoi_signature'] = null; |
$valF['date_envoi_signature'] = null; |
10471 |
$valF['historique_signature'] = $this->get_updated_historique_signature($result); |
$valF['historique_signature'] = $this->get_updated_historique_signature($result); |
10472 |
|
|
10473 |
|
$this->setParameter("maj", 1); |
10474 |
$ret = $this->modifier($valF); |
$ret = $this->modifier($valF); |
10475 |
|
|
10476 |
if ($ret === false) { |
if ($ret === false) { |
10522 |
* @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 |
10523 |
* @return json |
* @return json |
10524 |
*/ |
*/ |
10525 |
protected function get_json_suivi_notification($typeTache, $nonLieTache = false) { |
public function get_json_suivi_notification($typeTache, $nonLieTache = false) { |
10526 |
$whereTypeTache = ''; |
$whereTypeTache = ''; |
10527 |
$sqlTaskNull = ''; |
$sqlTaskNull = 'INNER'; |
10528 |
|
|
10529 |
// Liste des champs à afficher. Permet également la traduction des noms de colonnes. |
// Liste des champs à afficher. Permet également la traduction des noms de colonnes. |
10530 |
$listeChampsTrad = array( |
$listeChampsTrad = array( |
10553 |
// 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 |
10554 |
// paramétrage |
// paramétrage |
10555 |
if(is_bool($nonLieTache) && $nonLieTache === true) { |
if(is_bool($nonLieTache) && $nonLieTache === true) { |
10556 |
$sqlTaskNull = 'OR task.type is null'; |
$sqlTaskNull = 'LEFT'; |
10557 |
} |
} |
10558 |
// 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 |
10559 |
// 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 |
10561 |
if (is_array($typeTache) && $typeTache != array()) { |
if (is_array($typeTache) && $typeTache != array()) { |
10562 |
if (is_array($typeTache)) { |
if (is_array($typeTache)) { |
10563 |
$whereTypeTache = sprintf( |
$whereTypeTache = sprintf( |
10564 |
'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)))', |
10565 |
"'".implode("', '", $typeTache)."'", |
"'".implode("', '", $typeTache)."'" |
|
$sqlTaskNull |
|
10566 |
); |
); |
10567 |
} |
} |
10568 |
// 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 |
10580 |
$dossier = $this->getVal('dossier'); |
$dossier = $this->getVal('dossier'); |
10581 |
$collectivite_di = $this->get_dossier_instruction_om_collectivite($dossier); |
$collectivite_di = $this->get_dossier_instruction_om_collectivite($dossier); |
10582 |
$modeNotification = $this->f->get_param_option_notification($collectivite_di); |
$modeNotification = $this->f->get_param_option_notification($collectivite_di); |
10583 |
if (empty($modeNotification) || $modeNotification == 'portal') { |
if ($modeNotification === PORTAL) { |
10584 |
$listeChamps = array( |
$listeChamps = array( |
10585 |
'emetteur', |
'emetteur', |
10586 |
'date_envoi', |
'date_envoi', |
10633 |
ON instruction_notification.instruction_notification = instruction_notification_document.instruction_notification |
ON instruction_notification.instruction_notification = instruction_notification_document.instruction_notification |
10634 |
AND instruction_notification_document.annexe = true |
AND instruction_notification_document.annexe = true |
10635 |
-- 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 |
10636 |
LEFT JOIN %1$stask |
%4$s JOIN %1$stask |
10637 |
ON instruction_notification.instruction_notification::CHARACTER VARYING = task.object_id |
ON instruction_notification.instruction_notification::CHARACTER VARYING = task.object_id |
10638 |
|
AND task.type LIKE \'notification%%\' |
10639 |
-- 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 |
10640 |
LEFT JOIN ( |
LEFT JOIN ( |
10641 |
SELECT |
SELECT |
10662 |
\'{ |
\'{ |
10663 |
"obj" : "consultation", |
"obj" : "consultation", |
10664 |
"champs" : "fichier", |
"champs" : "fichier", |
10665 |
"label" : "Avis - \', service.libelle, \'", |
"label" : "\', CONCAT_WS( \' - \', \'Avis\', service.libelle, to_char(consultation.date_retour,\'DD/MM/YYYY\')), \'", |
10666 |
"id" : "\', consultation.consultation,\'" |
"id" : "\', consultation.consultation, \'" |
10667 |
}\' |
}\' |
10668 |
) |
) |
10669 |
ELSE |
ELSE |
10670 |
CONCAT( |
CONCAT( |
10706 |
ORDER BY |
ORDER BY |
10707 |
date_envoi ASC, instruction_notification.destinataire ASC', |
date_envoi ASC, instruction_notification.destinataire ASC', |
10708 |
DB_PREFIXE, |
DB_PREFIXE, |
10709 |
$this->getVal('instruction'), |
intval($this->getVal('instruction')), |
10710 |
$whereTypeTache |
$whereTypeTache, |
10711 |
|
$sqlTaskNull |
10712 |
|
); |
10713 |
|
$qres = $this->f->get_all_results_from_db_query($sql, array( |
10714 |
|
"origin" => __METHOD__ |
10715 |
|
) |
10716 |
); |
); |
|
$res = $this->f->db->query($sql); |
|
|
$this->f->addToLog(__METHOD__."(): db->query(\"".$sql."\")", VERBOSE_MODE); |
|
|
$this->f->isDatabaseError($res); |
|
10717 |
// Préparation du lien de téléchargement des annexes |
// Préparation du lien de téléchargement des annexes |
10718 |
$htmlList = |
$htmlList = |
10719 |
'<style> |
'<style> |
10732 |
Annexe |
Annexe |
10733 |
</a>'; |
</a>'; |
10734 |
// Stockage des infos de chaque notification dans un tableau |
// Stockage des infos de chaque notification dans un tableau |
10735 |
while( $row =& $res->fetchrow(DB_FETCHMODE_ASSOC) ) { |
foreach ($qres['result'] as $row) { |
10736 |
$valNotif = array(); |
$valNotif = array(); |
10737 |
foreach($listeChamps as $champ) { |
foreach($listeChamps as $champ) { |
10738 |
$valNotif[$champ] = $row[$champ]; |
$valNotif[$champ] = $row[$champ]; |
10782 |
* @return void |
* @return void |
10783 |
*/ |
*/ |
10784 |
public function handle_electronicsignature_exception(electronicsignature_exception $exception) { |
public function handle_electronicsignature_exception(electronicsignature_exception $exception) { |
10785 |
$this->f->displayMessage('error', $exception->getMessage()); |
$this->correct = false; |
10786 |
|
$this->addToMessage($exception->getMessage()); |
10787 |
} |
} |
10788 |
|
|
10789 |
|
|
10801 |
try { |
try { |
10802 |
require_once "electronicsignature.class.php"; |
require_once "electronicsignature.class.php"; |
10803 |
$collectivites = array("collectivite_idx" => $this->get_dossier_instruction_om_collectivite(), "collectivite_multi_idx" => $this->f->get_idx_collectivite_multi()); |
$collectivites = array("collectivite_idx" => $this->get_dossier_instruction_om_collectivite(), "collectivite_multi_idx" => $this->f->get_idx_collectivite_multi()); |
10804 |
$this->electronicsignature_instance = new electronicsignature($collectivites); |
$extra_params = array( |
10805 |
|
"inst_framework" => $this->f, |
10806 |
|
); |
10807 |
|
$this->electronicsignature_instance = new electronicsignature($collectivites, $extra_params); |
10808 |
} catch (electronicsignature_exception $e) { |
} catch (electronicsignature_exception $e) { |
10809 |
if ($with_handle_error === true) { |
if ($with_handle_error === true) { |
10810 |
$this->handle_electronicsignature_exception($e); |
$this->handle_electronicsignature_exception($e); |
10827 |
$this->correct = true; |
$this->correct = true; |
10828 |
|
|
10829 |
// |
// |
10830 |
if ($this->can_be_sended_to_cl() === true) { |
if ($this->can_be_sent_to_cl() === true) { |
10831 |
// Création de la task 'envoi_CL' |
// Création de la task 'envoi_CL' |
10832 |
$inst_task = $this->f->get_inst__om_dbform(array( |
$inst_task = $this->f->get_inst__om_dbform(array( |
10833 |
"obj" => "task", |
"obj" => "task", |
10845 |
&& ($inst_di->getVal('etat_transmission_platau') == 'non_transmissible' |
&& ($inst_di->getVal('etat_transmission_platau') == 'non_transmissible' |
10846 |
|| $inst_di->getVal('etat_transmission_platau') == 'transmis_mais_non_transmissible')) { |
|| $inst_di->getVal('etat_transmission_platau') == 'transmis_mais_non_transmissible')) { |
10847 |
// |
// |
10848 |
$task_val['state'] = $inst_task::STATUS_DRAFT; |
$task_val['state'] = task::STATUS_DRAFT; |
10849 |
} |
} |
10850 |
$add_task = $inst_task->add_task(array('val' => $task_val)); |
$add_task = $inst_task->add_task(array('val' => $task_val)); |
10851 |
if ($add_task === false) { |
if ($add_task === false) { |
10866 |
DB_AUTOQUERY_UPDATE, |
DB_AUTOQUERY_UPDATE, |
10867 |
$this->getCle($this->getVal($this->clePrimaire)) |
$this->getCle($this->getVal($this->clePrimaire)) |
10868 |
); |
); |
10869 |
$this->addToLog(__METHOD__."(): db->autoexecute(\"".DB_PREFIXE.'.'.$this->table."\", ".print_r($instr_val, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($this->clePrimaire)."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->autoexecute(\"".DB_PREFIXE.'.'.$this->table."\", ".print_r($instr_val, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($this->getVal($this->clePrimaire))."\");", VERBOSE_MODE); |
10870 |
if ($this->f->isDatabaseError($res, true) === true) { |
if ($this->f->isDatabaseError($res, true) === true) { |
10871 |
$this->addToMessage(sprintf('%s %s', |
$this->addToMessage(sprintf('%s %s', |
10872 |
__("Une erreur s'est produite lors de la mise à jour de l'instruction."), |
__("Une erreur s'est produite lors de la mise à jour de l'instruction."), |
10951 |
return $val; |
return $val; |
10952 |
} |
} |
10953 |
|
|
10954 |
|
/** |
10955 |
|
* Permet de récupérer l'identifiant de l'instruction sur le dossier, ayant |
10956 |
|
* comme événement lié le suivant définit dans l'événement de l'instruction |
10957 |
|
* instanciée. |
10958 |
|
* |
10959 |
|
* @param string $next_type Correspond aux trois déclenchement automatique |
10960 |
|
* de création d'instruction paramétré sur un événement. |
10961 |
|
* @param integer $instruction Identifiant de l'instruction à instancier. |
10962 |
|
* @return mixed Identifiant de l'instruction recherchée ou false. |
10963 |
|
*/ |
10964 |
public function get_related_instructions_next($next_type = 'retour_signature', $instruction = null) { |
public function get_related_instructions_next($next_type = 'retour_signature', $instruction = null) { |
10965 |
if (in_array($next_type, array('retour_signature', 'retour_ar', 'suivant_tacite', )) === false) { |
if (in_array($next_type, array('retour_signature', 'retour_ar', 'suivant_tacite', )) === false) { |
10966 |
return false; |
return false; |
10979 |
$evenement = $inst->getVal('evenement'); |
$evenement = $inst->getVal('evenement'); |
10980 |
$dossier = $inst->getVal('dossier'); |
$dossier = $inst->getVal('dossier'); |
10981 |
} |
} |
10982 |
// |
// Récupération de l'identifiant de l'événement paramétré comme suivant |
10983 |
$query = sprintf(' |
// sur l'instruction instanciée |
10984 |
SELECT evenement_%3$s |
$qres = $this->f->get_one_result_from_db_query( |
10985 |
FROM %1$sevenement |
sprintf( |
10986 |
WHERE evenement = %2$s |
'SELECT |
10987 |
', |
evenement_%3$s |
10988 |
DB_PREFIXE, |
FROM |
10989 |
$evenement, |
%1$sevenement |
10990 |
$next_type |
WHERE |
10991 |
); |
evenement = %2$s', |
10992 |
$res = $this->f->get_one_result_from_db_query($query, true); |
DB_PREFIXE, |
10993 |
if ($res['code'] === 'KO') { |
intval($evenement), |
10994 |
|
$next_type |
10995 |
|
), |
10996 |
|
array( |
10997 |
|
"origin" => __METHOD__, |
10998 |
|
"force_return" => true, |
10999 |
|
) |
11000 |
|
); |
11001 |
|
if ($qres["code"] !== "OK") { |
11002 |
return false; |
return false; |
11003 |
} |
} |
11004 |
$ev_next = $res['result']; |
$ev_next = $qres["result"]; |
11005 |
// |
// Récupération de l'instruction dans le dossier utilisant l'événement |
11006 |
$query = sprintf(' |
// suivant identifié dans la requête précédente |
11007 |
SELECT MAX(instruction.instruction) as instruction |
$qres = $this->f->get_one_result_from_db_query( |
11008 |
FROM %1$sinstruction |
sprintf( |
11009 |
WHERE dossier = \'%3$s\' |
'SELECT |
11010 |
AND evenement = %2$s |
MAX(instruction.instruction) as instruction |
11011 |
', |
FROM |
11012 |
DB_PREFIXE, |
%1$sinstruction |
11013 |
$ev_next, |
WHERE |
11014 |
$dossier |
dossier = \'%3$s\' |
11015 |
|
AND evenement = %2$s', |
11016 |
|
DB_PREFIXE, |
11017 |
|
intval($ev_next), |
11018 |
|
$this->f->db->escapeSimple($dossier) |
11019 |
|
), |
11020 |
|
array( |
11021 |
|
"origin" => __METHOD__, |
11022 |
|
"force_return" => true, |
11023 |
|
) |
11024 |
); |
); |
11025 |
$res = $this->f->get_one_result_from_db_query($query, true); |
if ($qres["code"] !== "OK") { |
|
if ($res['code'] === 'KO') { |
|
11026 |
return false; |
return false; |
11027 |
} |
} |
11028 |
// |
return $qres["result"]; |
|
return $res['result']; |
|
11029 |
} |
} |
11030 |
|
|
11031 |
public function get_related_instructions($instruction = null) { |
public function get_related_instructions($instruction = null) { |
11044 |
$dossier = $inst->getVal('dossier'); |
$dossier = $inst->getVal('dossier'); |
11045 |
} |
} |
11046 |
// |
// |
11047 |
$query = sprintf(' |
$qres = $this->f->get_one_result_from_db_query( |
11048 |
SELECT evenement |
sprintf( |
11049 |
FROM %1$sevenement |
'SELECT |
11050 |
WHERE evenement_retour_ar = %2$s |
evenement |
11051 |
OR evenement_retour_signature = %2$s |
FROM |
11052 |
', |
%1$sevenement |
11053 |
DB_PREFIXE, |
WHERE |
11054 |
$evenement |
evenement_retour_ar = %2$s |
11055 |
|
OR evenement_retour_signature = %2$s', |
11056 |
|
DB_PREFIXE, |
11057 |
|
intval($evenement) |
11058 |
|
), |
11059 |
|
array( |
11060 |
|
"origin" => __METHOD__, |
11061 |
|
"force_return" => true, |
11062 |
|
) |
11063 |
); |
); |
11064 |
$res = $this->f->get_one_result_from_db_query($query, true); |
if ($qres["code"] !== "OK") { |
|
if ($res['code'] === 'KO') { |
|
11065 |
return false; |
return false; |
11066 |
} |
} |
11067 |
$ev_parent = $res['result']; |
$ev_parent = $qres["result"]; |
11068 |
// |
// |
11069 |
$query = sprintf(' |
$qres = $this->f->get_one_result_from_db_query( |
11070 |
SELECT MAX(instruction.instruction) as instruction |
sprintf( |
11071 |
FROM %1$sinstruction |
'SELECT |
11072 |
WHERE dossier = \'%3$s\' |
MAX(instruction.instruction) as instruction |
11073 |
AND evenement = %2$s |
FROM |
11074 |
', |
%1$sinstruction |
11075 |
DB_PREFIXE, |
WHERE |
11076 |
$ev_parent, |
dossier = \'%3$s\' |
11077 |
$dossier |
AND evenement = %2$s', |
11078 |
|
DB_PREFIXE, |
11079 |
|
intval($ev_parent), |
11080 |
|
$this->f->db->escapeSimple($dossier) |
11081 |
|
), |
11082 |
|
array( |
11083 |
|
"origin" => __METHOD__, |
11084 |
|
"force_return" => true, |
11085 |
|
) |
11086 |
); |
); |
11087 |
$res = $this->f->get_one_result_from_db_query($query, true); |
if ($qres["code"] !== "OK") { |
|
if ($res['code'] === 'KO') { |
|
11088 |
return false; |
return false; |
11089 |
} |
} |
11090 |
$result[] = $res['result']; |
$result[] = $qres["result"]; |
11091 |
// |
// |
11092 |
$query = sprintf(' |
$qres = $this->f->get_one_result_from_db_query( |
11093 |
SELECT evenement_retour_ar |
sprintf( |
11094 |
FROM %1$sevenement |
'SELECT |
11095 |
WHERE evenement = %2$s |
evenement_retour_ar |
11096 |
AND evenement_retour_ar != %3$s |
FROM |
11097 |
', |
%1$sevenement |
11098 |
DB_PREFIXE, |
WHERE |
11099 |
$ev_parent, |
evenement = %2$d |
11100 |
$evenement |
AND evenement_retour_ar != %3$d', |
11101 |
|
DB_PREFIXE, |
11102 |
|
intval($ev_parent), |
11103 |
|
intval($evenement) |
11104 |
|
), |
11105 |
|
array( |
11106 |
|
"origin" => __METHOD__, |
11107 |
|
"force_return" => true, |
11108 |
|
) |
11109 |
); |
); |
11110 |
$res = $this->f->get_one_result_from_db_query($query, true); |
if ($qres["code"] !== "OK") { |
|
if ($res['code'] === 'KO') { |
|
11111 |
return false; |
return false; |
11112 |
} |
} |
11113 |
$evenements[] = $res['result']; |
$evenements[] = $qres["result"]; |
11114 |
// |
// |
11115 |
$query = sprintf(' |
$qres = $this->f->get_one_result_from_db_query( |
11116 |
SELECT evenement_retour_signature |
sprintf( |
11117 |
FROM %1$sevenement |
'SELECT |
11118 |
WHERE evenement = %2$s |
evenement_retour_signature |
11119 |
AND evenement_retour_signature != %3$s |
FROM |
11120 |
', |
%1$sevenement |
11121 |
DB_PREFIXE, |
WHERE |
11122 |
$ev_parent, |
evenement = %2$s |
11123 |
$evenement |
AND evenement_retour_signature != %3$s |
11124 |
|
', |
11125 |
|
DB_PREFIXE, |
11126 |
|
intval($ev_parent), |
11127 |
|
intval($evenement) |
11128 |
|
), |
11129 |
|
array( |
11130 |
|
"origin" => __METHOD__, |
11131 |
|
"force_return" => true, |
11132 |
|
) |
11133 |
); |
); |
11134 |
$res = $this->f->get_one_result_from_db_query($query, true); |
if ($qres["code"] !== "OK") { |
|
if ($res['code'] === 'KO') { |
|
11135 |
return false; |
return false; |
11136 |
} |
} |
11137 |
$evenements[] = $res['result']; |
$evenements[] = $qres["result"]; |
11138 |
foreach ($evenements as $value) { |
foreach ($evenements as $value) { |
11139 |
if ($value !== null) { |
if ($value !== null) { |
11140 |
$query = sprintf(' |
$qres = $this->f->get_one_result_from_db_query( |
11141 |
SELECT MAX(instruction.instruction) as instruction |
sprintf( |
11142 |
FROM %1$sinstruction |
'SELECT |
11143 |
WHERE dossier = \'%3$s\' |
MAX(instruction.instruction) as instruction |
11144 |
AND evenement = %2$s |
FROM |
11145 |
', |
%1$sinstruction |
11146 |
DB_PREFIXE, |
WHERE |
11147 |
$value, |
dossier = \'%3$s\' |
11148 |
$dossier |
AND evenement = %2$s', |
11149 |
|
DB_PREFIXE, |
11150 |
|
intval($value), |
11151 |
|
$this->f->db->escapeSimple($dossier) |
11152 |
|
), |
11153 |
|
array( |
11154 |
|
"origin" => __METHOD__, |
11155 |
|
"force_return" => true, |
11156 |
|
) |
11157 |
); |
); |
11158 |
$res = $this->f->get_one_result_from_db_query($query, true); |
if ($qres["code"] !== "OK") { |
|
if ($res['code'] === 'KO') { |
|
11159 |
return false; |
return false; |
11160 |
} |
} |
11161 |
$result[] = $res['result']; |
$result[] = $qres["result"]; |
11162 |
} |
} |
11163 |
} |
} |
11164 |
return $result; |
return $result; |
11189 |
* pour une notification de categorie portail |
* pour une notification de categorie portail |
11190 |
* @return array liste des demandeurs pouvant être notifié |
* @return array liste des demandeurs pouvant être notifié |
11191 |
*/ |
*/ |
11192 |
protected function get_demandeurs_notifiable($idDossier = null, $portail = false) { |
public function get_demandeurs_notifiable($idDossier = null, $portail = false) { |
11193 |
if ($idDossier === null) { |
if ($idDossier === null) { |
11194 |
$idDossier = $this->getVal('dossier'); |
$idDossier = $this->getVal('dossier'); |
11195 |
} |
} |
11210 |
$listeDemandeursNotifiable = array(); |
$listeDemandeursNotifiable = array(); |
11211 |
|
|
11212 |
// Requête de récupération des demandeurs |
// Requête de récupération des demandeurs |
11213 |
$sql = sprintf( |
$qres = $this->f->get_all_results_from_db_query( |
11214 |
'SELECT |
sprintf( |
11215 |
demandeur.demandeur, |
'SELECT |
11216 |
CASE |
demandeur.demandeur, |
11217 |
WHEN demandeur.qualite=\'particulier\' |
CASE |
11218 |
THEN TRIM(CONCAT(demandeur.particulier_nom, \' \', demandeur.particulier_prenom, \' \', demandeur.courriel)) |
WHEN demandeur.qualite=\'particulier\' |
11219 |
ELSE |
THEN TRIM(CONCAT(demandeur.particulier_nom, \' \', demandeur.particulier_prenom, \' \', demandeur.courriel)) |
11220 |
TRIM(CONCAT(demandeur.personne_morale_raison_sociale, \' \', demandeur.personne_morale_denomination, \' \', demandeur.courriel)) |
ELSE |
11221 |
END AS destinataire, |
TRIM(CONCAT(demandeur.personne_morale_raison_sociale, \' \', demandeur.personne_morale_denomination, \' \', demandeur.courriel)) |
11222 |
demandeur.courriel, |
END AS destinataire, |
11223 |
petitionnaire_principal |
demandeur.courriel, |
11224 |
FROM |
petitionnaire_principal |
11225 |
%1$sdossier |
FROM |
11226 |
INNER JOIN %1$slien_dossier_demandeur |
%1$sdossier |
11227 |
ON dossier.dossier = lien_dossier_demandeur.dossier |
INNER JOIN %1$slien_dossier_demandeur |
11228 |
INNER JOIN %1$sdemandeur |
ON dossier.dossier = lien_dossier_demandeur.dossier |
11229 |
ON lien_dossier_demandeur.demandeur = demandeur.demandeur |
INNER JOIN %1$sdemandeur |
11230 |
-- Récupération de la plus ancienne demande associée au dossier (la demande |
ON lien_dossier_demandeur.demandeur = demandeur.demandeur |
11231 |
-- de création du dossier) |
-- Récupération de la plus ancienne demande associée au dossier (la demande |
11232 |
INNER JOIN ( |
-- de création du dossier) |
11233 |
SELECT |
INNER JOIN ( |
11234 |
demande, |
SELECT |
11235 |
dossier_instruction, |
demande, |
11236 |
source_depot |
dossier_instruction, |
11237 |
FROM |
source_depot |
11238 |
%1$sdemande |
FROM |
11239 |
WHERE |
%1$sdemande |
11240 |
dossier_instruction = \'%2$s\' |
WHERE |
11241 |
ORDER BY |
dossier_instruction = \'%2$s\' |
11242 |
demande ASC |
ORDER BY |
11243 |
LIMIT 1 |
demande ASC |
11244 |
) as demande |
LIMIT 1 |
11245 |
ON dossier.dossier = demande.dossier_instruction |
) as demande |
11246 |
WHERE |
ON dossier.dossier = demande.dossier_instruction |
11247 |
dossier.dossier = \'%2$s\' |
WHERE |
11248 |
%3$s |
dossier.dossier = \'%2$s\' |
11249 |
%4$s', |
%3$s |
11250 |
DB_PREFIXE, |
%4$s', |
11251 |
$idDossier, |
DB_PREFIXE, |
11252 |
$condition_demandeur, |
$this->f->db->escapeSimple($idDossier), |
11253 |
$sqlPetitionnairePrincipal |
$condition_demandeur, |
11254 |
); |
$sqlPetitionnairePrincipal |
11255 |
$res = $this->f->db->query($sql); |
), |
11256 |
$this->f->addToLog(__METHOD__."(): db->query(\"".$sql."\")", VERBOSE_MODE); |
array( |
11257 |
$this->f->isDatabaseError($res); |
"origin" => __METHOD__ |
11258 |
|
) |
11259 |
|
); |
11260 |
// Récupération des infos des demandeurs et stockage dans un tableau |
// Récupération des infos des demandeurs et stockage dans un tableau |
11261 |
// ayant pour clé les id des demandeurs |
// ayant pour clé les id des demandeurs |
11262 |
while($row = $res->fetchrow(DB_FETCHMODE_ASSOC)) { |
foreach ($qres['result'] as $row) { |
11263 |
$listeDemandeursNotifiable[$row['demandeur']] = $row; |
$listeDemandeursNotifiable[$row['demandeur']] = $row; |
11264 |
} |
} |
11265 |
|
|
11273 |
* @return array liste des instruction_notification liés à l'instruction |
* @return array liste des instruction_notification liés à l'instruction |
11274 |
*/ |
*/ |
11275 |
public function get_instruction_notification($id_instruction, $typeNotification = null, $nonLieTache = false) { |
public function get_instruction_notification($id_instruction, $typeNotification = null, $nonLieTache = false) { |
11276 |
$whereTypeTache = ''; |
// Compose la clause définissant dans la requête le type de tâche attendus |
11277 |
$sqlTaskNull = ''; |
$clause_type_tache = ''; |
|
// Défini si on veux que la requête récupère également les notifications qui n'ont pas |
|
|
// de tâches associées. C'est le cas pour les notifications de demandeurs lorsque la |
|
|
// notification du demandeur principal n'a pas pu être envoyée à cause d'un mauvais |
|
|
// paramétrage |
|
|
if(is_bool($nonLieTache) && $nonLieTache === true) { |
|
|
$sqlTaskNull = 'OR task.type is null'; |
|
|
} |
|
11278 |
if ($typeNotification != null) { |
if ($typeNotification != null) { |
11279 |
if (is_array($typeNotification)) { |
if (is_array($typeNotification)) { |
11280 |
$whereTypeTache = sprintf( |
$clause_type_tache = sprintf( |
11281 |
'AND (task.type IN (%1$s) %2$s)', |
'AND task.type IN (\'%1$s\')', |
11282 |
"'".implode("', '", $typeNotification)."'", |
implode("', '", $typeNotification), |
|
$sqlTaskNull |
|
11283 |
); |
); |
11284 |
} else { |
} else { |
11285 |
$whereTypeTache = sprintf( |
$clause_type_tache = sprintf( |
11286 |
'AND (task.type = \'%1$s\' %2$s)', |
'AND task.type = \'%1$s\'', |
11287 |
$typeNotification, |
$typeNotification |
|
$sqlTaskNull |
|
11288 |
); |
); |
11289 |
} |
} |
11290 |
} |
} |
11291 |
$listeInstrNotif = array(); |
|
11292 |
$sql = sprintf(' |
// Récupère les notifications liées à des tâches du type voulu et les stocke dans un tableau |
11293 |
SELECT |
$qres = $this->f->get_all_results_from_db_query( |
11294 |
instruction_notification.instruction_notification |
sprintf(' |
11295 |
FROM |
SELECT |
11296 |
%1$sinstruction_notification |
instruction_notification.instruction_notification |
11297 |
LEFT JOIN %1$stask |
FROM |
11298 |
ON instruction_notification.instruction_notification::CHARACTER VARYING = task.object_id |
%1$sinstruction_notification |
11299 |
WHERE |
INNER JOIN %1$stask |
11300 |
instruction = %2$s |
ON instruction_notification.instruction_notification::CHARACTER VARYING = task.object_id |
11301 |
%3$s', |
%3$s |
11302 |
DB_PREFIXE, |
WHERE |
11303 |
$id_instruction, |
instruction = %2$s', |
11304 |
$whereTypeTache |
DB_PREFIXE, |
11305 |
|
intval($id_instruction), |
11306 |
|
$clause_type_tache |
11307 |
|
), |
11308 |
|
array( |
11309 |
|
"origin" => __METHOD__, |
11310 |
|
'log_level' => DEBUG_MODE |
11311 |
|
) |
11312 |
); |
); |
11313 |
$res = $this->f->db->query($sql); |
$listeInstrNotif = array(); |
11314 |
$this->f->addToLog(__METHOD__."(): db->query(\"".$sql."\")", VERBOSE_MODE); |
foreach ($qres['result'] as $row) { |
|
$this->f->isDatabaseError($res); |
|
|
while ($row = $res->fetchrow(DB_FETCHMODE_ASSOC)) { |
|
11315 |
$listeInstrNotif[] = $row['instruction_notification']; |
$listeInstrNotif[] = $row['instruction_notification']; |
11316 |
} |
} |
11317 |
|
|
11318 |
|
// Défini si on veux que la requête récupère également les notifications qui n'ont pas |
11319 |
|
// de tâches associées. C'est le cas pour les notifications de demandeurs lorsque la |
11320 |
|
// notification du demandeur principal n'a pas pu être envoyée à cause d'un mauvais |
11321 |
|
// paramétrage |
11322 |
|
if(is_bool($nonLieTache) && $nonLieTache === true) { |
11323 |
|
$qres = $this->f->get_all_results_from_db_query( |
11324 |
|
sprintf(' |
11325 |
|
SELECT |
11326 |
|
instruction_notification.instruction_notification |
11327 |
|
FROM |
11328 |
|
%1$sinstruction_notification |
11329 |
|
LEFT JOIN %1$stask |
11330 |
|
ON instruction_notification.instruction_notification::CHARACTER VARYING = task.object_id |
11331 |
|
AND task.type LIKE \'%%notification%%\' |
11332 |
|
WHERE |
11333 |
|
instruction = %2$s |
11334 |
|
AND task.task IS NULL', |
11335 |
|
DB_PREFIXE, |
11336 |
|
intval($id_instruction) |
11337 |
|
), |
11338 |
|
array( |
11339 |
|
"origin" => __METHOD__ |
11340 |
|
) |
11341 |
|
); |
11342 |
|
|
11343 |
|
foreach ($qres['result'] as $row) { |
11344 |
|
$listeInstrNotif[] = $row['instruction_notification']; |
11345 |
|
} |
11346 |
|
} |
11347 |
|
|
11348 |
return $listeInstrNotif; |
return $listeInstrNotif; |
11349 |
} |
} |
11350 |
|
|
11354 |
* |
* |
11355 |
* @return string clé d'accès du document |
* @return string clé d'accès du document |
11356 |
*/ |
*/ |
11357 |
protected function getCleAccesDocument() { |
function getCleAccesDocument() { |
11358 |
// Initialisation d'un tableau |
// Initialisation d'un tableau |
11359 |
$number_list = array(); |
$number_list = array(); |
11360 |
|
|
11383 |
* @return integer|null |
* @return integer|null |
11384 |
*/ |
*/ |
11385 |
protected function getUidDocumentInstructionWithKey($cleGen) { |
protected function getUidDocumentInstructionWithKey($cleGen) { |
11386 |
$query = sprintf( |
$qres = $this->f->get_one_result_from_db_query( |
11387 |
'SELECT |
sprintf( |
11388 |
instruction.om_fichier_instruction |
'SELECT |
11389 |
FROM |
instruction.om_fichier_instruction |
11390 |
%1$sinstruction_notification_document |
FROM |
11391 |
LEFT JOIN %1$sinstruction ON instruction_notification_document.instruction = instruction.instruction |
%1$sinstruction_notification_document |
11392 |
WHERE |
LEFT JOIN %1$sinstruction |
11393 |
instruction_notification_document.cle = \'%2$s\'', |
ON instruction_notification_document.instruction = instruction.instruction |
11394 |
DB_PREFIXE, |
WHERE |
11395 |
$this->f->db->escapeSimple($cleGen) |
instruction_notification_document.cle = \'%2$s\'', |
11396 |
|
DB_PREFIXE, |
11397 |
|
$this->f->db->escapeSimple($cleGen) |
11398 |
|
), |
11399 |
|
array( |
11400 |
|
"origin" => __METHOD__, |
11401 |
|
) |
11402 |
); |
); |
11403 |
|
|
11404 |
$res = $this->f->db->getOne($query); |
return $qres['result']; |
|
$this->addToLog(__METHOD__.": db->getOne(\"".$query."\");", VERBOSE_MODE); |
|
|
$this->f->isDatabaseError($res); |
|
|
return $res; |
|
11405 |
} |
} |
11406 |
|
|
11407 |
/** |
/** |
11412 |
* @return instruction_notification |
* @return instruction_notification |
11413 |
*/ |
*/ |
11414 |
protected function getInstanceNotificationWithKey($key) { |
protected function getInstanceNotificationWithKey($key) { |
11415 |
$sql = sprintf( |
$qres = $this->f->get_one_result_from_db_query( |
11416 |
"SELECT |
sprintf( |
11417 |
instruction_notification |
'SELECT |
11418 |
FROM |
instruction_notification |
11419 |
%1\$sinstruction_notification_document |
FROM |
11420 |
WHERE |
%1$sinstruction_notification_document |
11421 |
cle = '%2\$s'", |
WHERE |
11422 |
DB_PREFIXE, |
cle = \'%2$s\'', |
11423 |
$this->f->db->escapeSimple($key) |
DB_PREFIXE, |
11424 |
|
$this->f->db->escapeSimple($key) |
11425 |
|
), |
11426 |
|
array( |
11427 |
|
"origin" => __METHOD__, |
11428 |
|
) |
11429 |
); |
); |
|
$res = $this->f->db->getOne($sql); |
|
|
$this->addToLog(__METHOD__.": db->getOne(\"".$sql."\");", VERBOSE_MODE); |
|
|
$this->f->isDatabaseError($res); |
|
11430 |
|
|
11431 |
// Récupération de l'instance de notification |
// Récupération de l'instance de notification |
11432 |
$instNotif = $this->f->get_inst__om_dbform(array( |
$instNotif = $this->f->get_inst__om_dbform(array( |
11433 |
"obj" => "instruction_notification", |
"obj" => "instruction_notification", |
11434 |
"idx" => $res, |
"idx" => $qres['result'], |
11435 |
)); |
)); |
11436 |
return $instNotif; |
return $instNotif; |
11437 |
} |
} |
11502 |
} |
} |
11503 |
|
|
11504 |
/** |
/** |
|
* Compose le nom du document à transmettre au parapheur. |
|
|
* Le nom ets composé de cette manière : |
|
|
* instruction_xxx_libelle_de_la_lettre_type_associee |
|
|
* ou xxx correspond au numéro de l'instruction |
|
|
*/ |
|
|
protected function getDocumentLibelle() { |
|
|
// Récupère le champ instruction |
|
|
$instruction = $this->getVal("instruction"); |
|
|
|
|
|
// Requête sql servant à récupérer le titre du document |
|
|
// TO_CHAR() introduit un espace avant l'affichage du nombre |
|
|
// comme les espaces sont remplacé par des '_' dans le retour de la fonction |
|
|
// il n'est pas nécessaire de mettre un '_' après le mot instruction. |
|
|
$sql = sprintf( |
|
|
'SELECT |
|
|
CONCAT( |
|
|
\'instruction\', |
|
|
TO_CHAR(instruction.instruction, \'000\'), |
|
|
\'_\', |
|
|
LOWER(om_lettretype.libelle) |
|
|
) as nom_fichier |
|
|
FROM |
|
|
%1$sinstruction |
|
|
LEFT JOIN %1$som_lettretype ON om_lettretype.id = instruction.lettretype |
|
|
WHERE |
|
|
instruction = %2$s', |
|
|
DB_PREFIXE, |
|
|
$instruction |
|
|
); |
|
|
$documentLibelle = $this->f->db->getOne($sql); |
|
|
$this->addToLog("getDocumentTitre(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
|
|
if (database::isError($documentLibelle)) { |
|
|
die(); |
|
|
} |
|
|
|
|
|
// Transforamtion des ' ' en '_', des accents en lettres sans accents et des |
|
|
// caractères spéciaux en '_' |
|
|
// La méthode normalize_string est utilisé pour gérer les accents |
|
|
$documentLibelle = $this->f->normalize_string($documentLibelle); |
|
|
// TODO : comparer cette liste et celle de la méthode normalize_string |
|
|
// pour éviter les doublons + vérifier qu'il n'y a pas de doublons dans cette |
|
|
// liste |
|
|
$invalid = array('Œ'=>'oe', 'œ'=>'oe', 'Ÿ'=>'y', 'ü'=>'u', |
|
|
'¢' => '_', 'ß' => '_', '¥' => '_', '£' => '_', '™' => '_', '©' => '_', |
|
|
'®' => '_', 'ª' => '_', '×' => '_', '÷' => '_', '±' => '_', '²' => '_', |
|
|
'³' => '_', '¼' => '_', '½' => '_', '¾' => '_', 'µ' => '_', '¿' => '_', |
|
|
'¶' => '_', '·' => '_', '¸' => '_', 'º' => '_', '°' => '_', '¯' => '_', |
|
|
'§' => '_', '…' => '_', '¤' => '_', '¦' => '_', '≠' => '_', '¬' => '_', |
|
|
'ˆ' => '_', '¨' => '_', '‰' => '_', '¤' => '_', '€' => '_', '$' => '_', |
|
|
'«' => '_', '»' => '_', '‹' => '_', '›' => '_', 'ƒ' => '_', '¥' => '_', |
|
|
'‘‘' => '_', '‚' => '_', '!' => '_', '¡' => '_', '¢' => '_', '£' => '_', |
|
|
'?' => '_', '[' => '_', ']' => '_', '´' => '_', '`' => '_', '^' => '_', |
|
|
'~' => '_', '˜' => '_', '#' => '_', '*' => '_', '.' => '_', ':' => '_', |
|
|
';' => '_', '•' => '_', '¯' => '_', '‾' => '_', '–' => '_', '–' => '_', |
|
|
'—' => '_', '_' => '_', '|' => '_', '¦' => '_', '‡' => '_', '§' => '_', |
|
|
'¶' => '_', '©' => '_', '®' => '_', '™' => '_', '&' => '_', '@' => '_', |
|
|
'/' => '_', '\\' => '_', '◊' => '_', '♠' => '_', '♣' => '_', '♥' => '_', |
|
|
'♦' => '_', '←' => '_', '↑' => '_', '→' => '_', '↓' => '_', '↔' => '_', |
|
|
'°' => '_', 'µ' => '_', '<' => '_', '>' => '_', '≤' => '_', '≥' => '_', |
|
|
'=' => '_', '≈' => '_', '≠' => '_', '≡' => '_', '±' => '_', '−' => '_', |
|
|
'+' => '_', '×' => '_', '÷' => '_', '⁄' => '_', '%' => '_', '‰' => '_', |
|
|
'¼' => '_', '½' => '_', '¾' => '_', '¹' => '_', '²' => '_', '³' => '_', |
|
|
'' => '_', 'º' => '_', 'ª' => '_', 'ƒ' => '_', '′' => '_', '″' => '_', |
|
|
'∂' => '_', '∏' => '_', '∑' => '_', '√' => '_', '∞' => '_', '¬' => '_', |
|
|
'∩' => '_', '∫' => '_', 'α' => '_', 'Α' => '_', 'β' => '_', 'Β' => '_', |
|
|
'γ' => '_', 'Γ' => '_', 'δ' => '_', 'Δ' => '_', 'ε' => '_', 'Ε' => '_', |
|
|
'ζ' => '_', 'Ζ' => '_', 'η' => '_', 'Η' => '_', 'θ' => '_', 'Θ' => '_', |
|
|
'ι' => '_', 'Ι' => '_', 'κ' => '_', 'Κ' => '_', 'λ' => '_', 'Λ' => '_', |
|
|
'μ' => '_', 'Μ' => '_', 'ν' => '_', 'Ν' => '_', 'ξ' => '_', 'Ξ' => '_', |
|
|
'ο' => '_', 'Ο' => '_', 'π' => '_', 'Π' => '_', 'ρ' => '_', 'Ρ' => '_', |
|
|
'σ' => '_', 'ς' => '_', 'Σ' => '_', 'τ' => '_', 'Τ' => '_', 'υ' => '_', |
|
|
'Υ' => '_', 'φ' => '_', 'Φ' => '_', 'χ' => '_', 'Χ' => '_', 'ψ' => '_', |
|
|
'Ψ' => '_', 'ω' => '_', 'Ω' => '_', ',' => '_', ' ' => '_' |
|
|
); |
|
|
|
|
|
return str_replace(array_keys($invalid), array_values($invalid), $documentLibelle); |
|
|
} |
|
|
|
|
|
/** |
|
11505 |
* Surcharge permettant de ne pas afficher le fil d'Ariane dans |
* Surcharge permettant de ne pas afficher le fil d'Ariane dans |
11506 |
* l'overlay de notification des demandeurs. |
* l'overlay de notification des demandeurs. |
11507 |
*/ |
*/ |
11512 |
} |
} |
11513 |
return parent::getSubFormTitle($ent); |
return parent::getSubFormTitle($ent); |
11514 |
} |
} |
11515 |
}// fin classe |
|
11516 |
|
/** |
11517 |
|
* Traitement de la notification automatique des tiers consulté. |
11518 |
|
* |
11519 |
|
* Récupère la liste des adresses mails des tiers notifiables. Pour chaque adresses |
11520 |
|
* récupérées ajoute une notification et une tâche de notification par mail. |
11521 |
|
* La création de la tâche de notification par mail déclenchera l'envoi du mail |
11522 |
|
* et la mise à jour du suivi. |
11523 |
|
* |
11524 |
|
* Les tiers notifiables sont ceux : |
11525 |
|
* - n’ayant pas un ID PLAT’AU correspondant à l’ID PLAT’AU du service consultant |
11526 |
|
* - ayant une habilitation dont le type est listé dans les paramètres de |
11527 |
|
* notification de l’événement, |
11528 |
|
* - intervenant sur la commune ou le département du dossier |
11529 |
|
* - ayant au moins une adresse mail valide |
11530 |
|
* |
11531 |
|
* @param evenement instance de l'événement associée à l'instruction |
11532 |
|
* @param dossier instance du dossier de l'instruction |
11533 |
|
* @return boolean indique si le traitement à réussi |
11534 |
|
*/ |
11535 |
|
public function traitement_notification_automatique_tiers_consulte($evenement, $dossier) { |
11536 |
|
// Récupération de l'identifiant plat'au du service consultant |
11537 |
|
$consultationEntrante = $dossier->get_inst_consultation_entrante(); |
11538 |
|
// Récupération de la liste des types d'habilitations autorisées pour |
11539 |
|
// cette notification |
11540 |
|
$typesHabilitationsNotifiable = $evenement->get_types_habilitation_notifiable(); |
11541 |
|
// Récupération du département et de la commune du dossier |
11542 |
|
$commune = $dossier->getVal('commune'); |
11543 |
|
// Le département est récupéré à partir de la commune du dossier donc si la |
11544 |
|
// commune n'a pas pu être récupéré on ne récupère pas non plus le département. |
11545 |
|
$idDepartement = null; |
11546 |
|
if (! empty($commune)) { |
11547 |
|
$departement = $dossier->get_inst_departement_dossier(); |
11548 |
|
$idDepartement = $departement->getVal($departement->clePrimaire); |
11549 |
|
} |
11550 |
|
// Récupération des courriels des tiers notifiables |
11551 |
|
$tiersANotifier = $this->get_courriels_tiers_notifiable( |
11552 |
|
$typesHabilitationsNotifiable, |
11553 |
|
$consultationEntrante->getVal('service_consultant_id'), |
11554 |
|
$commune, |
11555 |
|
$idDepartement |
11556 |
|
); |
11557 |
|
// Traitement de chacune des listes de diffusion pour extraire les |
11558 |
|
// courriels, vérifier la validité des courriels et envoyer la |
11559 |
|
// notification |
11560 |
|
$notificationSend = false; |
11561 |
|
if (empty($tiersANotifier)) { |
11562 |
|
$this->addToLog( |
11563 |
|
sprintf( |
11564 |
|
'%s() : %s %s : %s', |
11565 |
|
__METHOD__, |
11566 |
|
__("La récupération des tiers à échoué."), |
11567 |
|
__('Paramétrage'), |
11568 |
|
var_export( |
11569 |
|
array( |
11570 |
|
'types_habilitations_notifiable' => $typesHabilitationsNotifiable, |
11571 |
|
'service_consultant' => $consultationEntrante->getVal('service_consultant_id'), |
11572 |
|
'id_commune' => $commune, |
11573 |
|
'id_departement' => $idDepartement |
11574 |
|
), |
11575 |
|
true |
11576 |
|
) |
11577 |
|
), |
11578 |
|
DEBUG_MODE |
11579 |
|
); |
11580 |
|
return false; |
11581 |
|
} |
11582 |
|
foreach($tiersANotifier as $tierANotifier) { |
11583 |
|
// Découpe la liste de diffusion pour stocker les adresses mails |
11584 |
|
// des tiers dans un tableau |
11585 |
|
$courriels = |
11586 |
|
array_filter( |
11587 |
|
array_map( |
11588 |
|
'trim', |
11589 |
|
preg_split("/\r\n|\n|\r/", $tierANotifier['liste_diffusion']))); |
11590 |
|
|
11591 |
|
foreach ($courriels as $courriel) { |
11592 |
|
// Pour chaque adresse mail vérifie si l'adresse est valide |
11593 |
|
if (! $this->f->checkValidEmailAddress($courriel)) { |
11594 |
|
continue; |
11595 |
|
} |
11596 |
|
$destinataire = array( |
11597 |
|
'destinataire' => $tierANotifier['libelle'].' : '.$courriel, |
11598 |
|
'courriel' => $courriel |
11599 |
|
); |
11600 |
|
// Si l'adresse est valide ajoute une nouvelle notification |
11601 |
|
// et une tâche d'envoi de mails |
11602 |
|
$idNotif = $this->ajouter_notification( |
11603 |
|
$this->getVal($this->clePrimaire), |
11604 |
|
$this->f->get_connected_user_login_name(), |
11605 |
|
$destinataire, |
11606 |
|
$this->get_dossier_instruction_om_collectivite(), |
11607 |
|
array(), |
11608 |
|
true |
11609 |
|
); |
11610 |
|
if ($idNotif === false) { |
11611 |
|
$this->addToLog( |
11612 |
|
__METHOD__. |
11613 |
|
__("L'ajout de la notification a échoué."), |
11614 |
|
DEBUG_MODE |
11615 |
|
); |
11616 |
|
return false; |
11617 |
|
} |
11618 |
|
// Création de la tache en lui donnant l'id de la notification |
11619 |
|
$notification_by_task = $this->notification_by_task( |
11620 |
|
$idNotif, |
11621 |
|
$dossier->getVal('dossier'), |
11622 |
|
'mail', |
11623 |
|
'notification_tiers_consulte' |
11624 |
|
); |
11625 |
|
if ($notification_by_task === false) { |
11626 |
|
$this->addToLog( |
11627 |
|
__METHOD__. |
11628 |
|
__("L'ajout de la tâche de notification a échoué."), |
11629 |
|
DEBUG_MODE |
11630 |
|
); |
11631 |
|
$this->addToMessage( |
11632 |
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
11633 |
|
); |
11634 |
|
return false; |
11635 |
|
} |
11636 |
|
$notificationSend = true; |
11637 |
|
} |
11638 |
|
} |
11639 |
|
// Si aucune notification n'a été envoyé car il n'y a pas de courriels |
11640 |
|
// valide, affiche un message dans les logs pour avoir un suivi. |
11641 |
|
if (! $notificationSend) { |
11642 |
|
$this->addToLog( |
11643 |
|
sprintf( |
11644 |
|
'%s %s : %s %s : %s', |
11645 |
|
__METHOD__, |
11646 |
|
__("Il n'y a pas de tiers notifiable pour l'instruction"), |
11647 |
|
$evenement->getVal('libelle'), |
11648 |
|
__("du dossier"), |
11649 |
|
$this->getVal('dossier') |
11650 |
|
), |
11651 |
|
DEBUG_MODE |
11652 |
|
); |
11653 |
|
} |
11654 |
|
return true; |
11655 |
|
} |
11656 |
|
|
11657 |
|
/** |
11658 |
|
* Récupère, à l'aide d'une requête, la liste de diffusion des tiers |
11659 |
|
* respectant les conditions suvantes : |
11660 |
|
* - le tiers consulté dois accepté les notifications |
11661 |
|
* - la liste de diffusion ne dois pas être vide |
11662 |
|
* - l'uid du tiers consulté ne dois pas être celui passé en paramètre |
11663 |
|
* si pas d'uid passé en paramètre alors on ne filtre pas selon l'uid |
11664 |
|
* du tiers |
11665 |
|
* - le type d'habilitation des tiers dois appartenir à la liste |
11666 |
|
* fournie en paramètre |
11667 |
|
* - le tiers dois être associé à la commune ou au département passé |
11668 |
|
* en paramètre |
11669 |
|
* |
11670 |
|
* @param array $typesHabilitations tableau contenant la liste des types d'habilitation |
11671 |
|
* pouvant être notifiée |
11672 |
|
* @param integer $idPlautau uid de l'acteur plat'au du dossier qui ne dois pas être notifié |
11673 |
|
* @param integer $commune identifiant de la commune du dossier |
11674 |
|
* @param integer $departement identifiant du département du dossier |
11675 |
|
* |
11676 |
|
* @return array listes de diffusion des tiers notifiable |
11677 |
|
*/ |
11678 |
|
public function get_courriels_tiers_notifiable(array $typesHabilitations, $idPlatau, $commune, $departement) { |
11679 |
|
// Si paramètre non renseigné alors ne renvoie rien |
11680 |
|
if (empty($typesHabilitations) || empty($commune) || empty($departement)) { |
11681 |
|
return false; |
11682 |
|
} |
11683 |
|
// Si il n'y a pas d'acteur associé au dossier alors on ne filtre pas sur l'uid de l'acteur |
11684 |
|
$filtreServiceConsulteDI = ''; |
11685 |
|
if (! empty($idPlatau)) { |
11686 |
|
$filtreServiceConsulteDI = sprintf( |
11687 |
|
"-- Filtre les tiers ayant une ligne correspondante a l uid platau du service |
11688 |
|
-- en charge du dossier |
11689 |
|
AND (tiers_consulte.uid_platau_acteur !~ ('\y' || '%s' || '\y') |
11690 |
|
OR tiers_consulte.uid_platau_acteur IS NULL)", |
11691 |
|
$this->f->db->escapeSimple($idPlatau) |
11692 |
|
); |
11693 |
|
} |
11694 |
|
$rst = $this->f->get_all_results_from_db_query( |
11695 |
|
sprintf( |
11696 |
|
'SELECT |
11697 |
|
-- Tiers notifiables lié à la commune du dossier |
11698 |
|
tiers_consulte.liste_diffusion, |
11699 |
|
tiers_consulte.libelle |
11700 |
|
FROM |
11701 |
|
%1$shabilitation_tiers_consulte |
11702 |
|
LEFT JOIN %1$stiers_consulte |
11703 |
|
ON habilitation_tiers_consulte.tiers_consulte = tiers_consulte.tiers_consulte |
11704 |
|
LEFT JOIN %1$slien_habilitation_tiers_consulte_commune |
11705 |
|
ON habilitation_tiers_consulte.habilitation_tiers_consulte = lien_habilitation_tiers_consulte_commune.habilitation_tiers_consulte |
11706 |
|
-- Conservation uniquement des tiers acteur de dossiers |
11707 |
|
JOIN %1$slien_dossier_tiers |
11708 |
|
ON tiers_consulte.tiers_consulte = lien_dossier_tiers.tiers |
11709 |
|
WHERE |
11710 |
|
tiers_consulte.accepte_notification_email IS TRUE |
11711 |
|
AND tiers_consulte.liste_diffusion IS NOT NULL |
11712 |
|
%3$s |
11713 |
|
AND habilitation_tiers_consulte.type_habilitation_tiers_consulte IN (%2$s) |
11714 |
|
AND lien_habilitation_tiers_consulte_commune.commune = %4$d |
11715 |
|
-- Filtre sur les tiers acteur du dossier |
11716 |
|
AND lien_dossier_tiers.dossier = \'%6$s\' |
11717 |
|
UNION |
11718 |
|
SELECT |
11719 |
|
-- Tiers notifiables lié au département du dossier |
11720 |
|
tiers_consulte.liste_diffusion, |
11721 |
|
tiers_consulte.libelle |
11722 |
|
FROM |
11723 |
|
%1$shabilitation_tiers_consulte |
11724 |
|
LEFT JOIN %1$stiers_consulte |
11725 |
|
ON habilitation_tiers_consulte.tiers_consulte = tiers_consulte.tiers_consulte |
11726 |
|
LEFT JOIN %1$slien_habilitation_tiers_consulte_departement |
11727 |
|
ON habilitation_tiers_consulte.habilitation_tiers_consulte = lien_habilitation_tiers_consulte_departement.habilitation_tiers_consulte |
11728 |
|
-- Conservation uniquement des tiers acteur de dossiers |
11729 |
|
JOIN %1$slien_dossier_tiers |
11730 |
|
ON tiers_consulte.tiers_consulte = lien_dossier_tiers.tiers |
11731 |
|
WHERE |
11732 |
|
tiers_consulte.accepte_notification_email IS TRUE |
11733 |
|
AND tiers_consulte.liste_diffusion IS NOT NULL |
11734 |
|
%3$s |
11735 |
|
AND habilitation_tiers_consulte.type_habilitation_tiers_consulte IN (%2$s) |
11736 |
|
AND lien_habilitation_tiers_consulte_departement.departement = %5$d |
11737 |
|
-- Filtre sur les tiers acteur du dossier |
11738 |
|
AND lien_dossier_tiers.dossier = \'%6$s\'', |
11739 |
|
DB_PREFIXE, |
11740 |
|
implode(', ', $typesHabilitations), |
11741 |
|
$filtreServiceConsulteDI, |
11742 |
|
intval($commune), |
11743 |
|
intval($departement), |
11744 |
|
$this->f->db->escapeSimple($this->getVal('dossier')) |
11745 |
|
), |
11746 |
|
array( |
11747 |
|
"origin" => __METHOD__ |
11748 |
|
) |
11749 |
|
); |
11750 |
|
// Faire un order by sur un union ne fonctionne pas. A la place |
11751 |
|
// c'est le tableau des résultats qui est ordonné. |
11752 |
|
usort($rst['result'], function($a, $b) { |
11753 |
|
return strcmp($a['libelle'], $b['libelle']); |
11754 |
|
}); |
11755 |
|
return $rst['result']; |
11756 |
|
} |
11757 |
|
|
11758 |
|
/** |
11759 |
|
* Gestion spécifique de l'affichage des documents dans le tableau des |
11760 |
|
* documents d'instruction. |
11761 |
|
* Prend en compte qu'une instruction peut également avoir un document lié |
11762 |
|
* dans la table storage. |
11763 |
|
* |
11764 |
|
* @return void |
11765 |
|
*/ |
11766 |
|
public function view_telecharger_editions() { |
11767 |
|
// Récupère l'identifiant du document dans l'URL appelant l'action |
11768 |
|
$idx = $this->f->get_submitted_get_value('idx'); |
11769 |
|
$obj = $this->table; |
11770 |
|
$champ = 'om_fichier_instruction'; |
11771 |
|
// Cas d'un document historisé (dans la table storage) |
11772 |
|
if (strpos($idx, 'STORAGE_') !== false) { |
11773 |
|
$idx = substr($idx, 8); |
11774 |
|
$obj = 'storage'; |
11775 |
|
$champ = 'uid'; |
11776 |
|
} |
11777 |
|
// Ouvre le document |
11778 |
|
$lien = '../app/index.php?module=form&snippet=file&obj='.$obj.'&champ='.$champ.'&id='.$idx; |
11779 |
|
header("Location: ".$lien); |
11780 |
|
} |
11781 |
|
} |