1 |
<?php |
<?php |
2 |
/** |
/** |
3 |
|
* DBFORM - 'instruction' - Surcharge gen. |
4 |
|
* |
5 |
* specific : |
* specific : |
6 |
* - cle secondaire |
* - cle secondaire |
7 |
* destruction autorisée que pour le dernier evenement |
* destruction autorisée que pour le dernier evenement |
14 |
* - function mois_date : pour ajouter des mois a une date |
* - function mois_date : pour ajouter des mois a une date |
15 |
* [add months (delay) and calculation final date] |
* [add months (delay) and calculation final date] |
16 |
* - voir script_lang.js : bible ... |
* - voir script_lang.js : bible ... |
17 |
* |
* |
18 |
* @package openfoncier |
* @package openfoncier |
19 |
* @version SVN : $Id$ |
* @version SVN : $Id$ |
20 |
*/ |
*/ |
29 |
var $abstract_type = array( |
var $abstract_type = array( |
30 |
"om_fichier_instruction" => "file", |
"om_fichier_instruction" => "file", |
31 |
); |
); |
32 |
|
|
|
var $retourformulaire; // specific |
|
|
var $idxformulaire; // specific |
|
33 |
var $valEvenement; |
var $valEvenement; |
34 |
var $restriction_valid = null; |
var $restriction_valid = null; |
35 |
// Tableau contenant une partie des métadonnées arrêtés |
// Tableau contenant une partie des métadonnées arrêtés |
69 |
"groupeInstruction" => 'getGroupeInstruction', |
"groupeInstruction" => 'getGroupeInstruction', |
70 |
"title" => 'getTitle', |
"title" => 'getTitle', |
71 |
'concerneERP' => 'get_concerne_erp', |
'concerneERP' => 'get_concerne_erp', |
72 |
|
|
73 |
|
'date_cloture_metier' => 'getDossierDateDecision', |
74 |
|
'type' => 'getDocumentType', |
75 |
|
'dossier_autorisation_type_detaille' => 'getDossierAutorisationTypeDetaille', |
76 |
|
'dossier_instruction_type' => 'getDossierInstructionTypeLibelle', |
77 |
|
'region' => 'getDossierRegion', |
78 |
|
'departement' => 'getDossierDepartement', |
79 |
|
'commune' => 'getDossierCommune', |
80 |
|
'annee' => 'getDossierAnnee', |
81 |
|
'division' => 'getDossierDivision', |
82 |
|
'collectivite' => 'getDossierServiceOrCollectivite', |
83 |
), |
), |
84 |
"arrete" => array( |
"arrete" => array( |
85 |
"numArrete" => "getNumArrete", |
"numArrete" => "getNumArrete", |
96 |
"ap_ville" => "getAp_ville", |
"ap_ville" => "getAp_ville", |
97 |
"activite" => "getActivite", |
"activite" => "getActivite", |
98 |
"dateControleLegalite" => "getDateControleLegalite", |
"dateControleLegalite" => "getDateControleLegalite", |
99 |
), |
) |
100 |
); |
); |
101 |
|
|
102 |
function __construct($id, &$db, $debug) { |
/** |
103 |
$this->constructeur($id, $db, $debug); |
* Flag pour identifier la reprise de l'instruction d'un dossier. |
104 |
} |
* Le statut de l'état passe de "cloture" à "encours". |
105 |
|
* |
106 |
|
* @var boolean |
107 |
|
*/ |
108 |
|
var $di_reopened = null; |
109 |
|
|
110 |
// {{{ Gestion de la confidentialité des données spécifiques |
// {{{ Gestion de la confidentialité des données spécifiques |
111 |
|
|
128 |
"is_editable", |
"is_editable", |
129 |
"is_finalizable_without_bypass", |
"is_finalizable_without_bypass", |
130 |
"can_user_access_dossier_contexte_modification", |
"can_user_access_dossier_contexte_modification", |
131 |
|
"is_evenement_modifiable", |
132 |
); |
); |
133 |
$this->class_actions[1]["portlet"]["libelle"] = _("Modifier"); |
$this->class_actions[1]["portlet"]["libelle"] = _("Modifier"); |
134 |
|
|
137 |
$this->class_actions[2]["condition"] = array( |
$this->class_actions[2]["condition"] = array( |
138 |
"is_deletable", |
"is_deletable", |
139 |
"is_finalizable_without_bypass", |
"is_finalizable_without_bypass", |
140 |
"can_user_access_dossier_contexte_modification" |
"can_user_access_dossier_contexte_modification", |
141 |
|
"is_evenement_supprimable", |
142 |
); |
); |
143 |
$this->class_actions[2]["portlet"]["libelle"] = _("Supprimer"); |
$this->class_actions[2]["portlet"]["libelle"] = _("Supprimer"); |
144 |
|
|
186 |
"is_unfinalizable", |
"is_unfinalizable", |
187 |
"is_unfinalizable_without_bypass", |
"is_unfinalizable_without_bypass", |
188 |
"can_user_access_dossier_contexte_modification", |
"can_user_access_dossier_contexte_modification", |
189 |
|
"is_not_sent_for_signature", |
190 |
|
), |
191 |
|
); |
192 |
|
|
193 |
|
// ACTION - 115 - Modification d'un document généré par une instruction |
194 |
|
// Permet à un instructeur de modifier un document généré par une instruction |
195 |
|
$this->class_actions[115] = array( |
196 |
|
"identifier" => "modale_selection_document_signe", |
197 |
|
"portlet" => array( |
198 |
|
"type" => "action-self", |
199 |
|
"libelle" => _("Remplacer par le document signé"), |
200 |
|
"order" => 115, |
201 |
|
"class" => "selection-document-signé", |
202 |
|
), |
203 |
|
"view" => "view_modale_selection_document_signe", |
204 |
|
"permission_suffix" => "selection_document_signe", |
205 |
|
"condition" => array( |
206 |
|
"is_finalized", |
207 |
|
"is_not_date_retour_signature_set", |
208 |
), |
), |
209 |
); |
); |
210 |
|
|
278 |
"permission_suffix" => "consulter", |
"permission_suffix" => "consulter", |
279 |
); |
); |
280 |
|
|
281 |
|
// ACTION - 175 - edit_by_notification_task |
282 |
|
// Action à utiliser lors de la mise à jour des instructions par notification |
283 |
|
$this->class_actions[175] = array( |
284 |
|
"identifier" => "edit_by_notification_task", |
285 |
|
"view" => "formulaire", |
286 |
|
"permission_suffix" => "modifier", |
287 |
|
"crud" => "update", |
288 |
|
); |
289 |
|
|
290 |
|
// ACTION - 176 - add_by_evenement_retour_after_notification_task |
291 |
|
// Action à utiliser lors de l'ajout des instructions par événement suivant |
292 |
|
// suite à une notification par tâche (donc notification dématerialisée) |
293 |
|
$this->class_actions[176] = array( |
294 |
|
"identifier" => "add_by_evenement_retour_after_notification_task", |
295 |
|
"view" => "formulaire", |
296 |
|
"permission_suffix" => "ajouter", |
297 |
|
"crud" => "create", |
298 |
|
); |
299 |
|
|
300 |
// ACTION - 180 - pdf_lettre_rar |
// ACTION - 180 - pdf_lettre_rar |
301 |
// Génère PDF sur bordereaux de lettres RAR |
// Génère PDF sur bordereaux de lettres AR |
302 |
$this->class_actions[180] = array( |
$this->class_actions[180] = array( |
303 |
"identifier" => "pdf_lettre_rar", |
"identifier" => "pdf_lettre_rar", |
304 |
"view" => "view_pdf_lettre_rar", |
"view" => "view_pdf_lettre_rar", |
345 |
"view" => "view_generate_suivi_bordereaux", |
"view" => "view_generate_suivi_bordereaux", |
346 |
"permission_suffix" => "consulter", |
"permission_suffix" => "consulter", |
347 |
); |
); |
|
} |
|
348 |
|
|
349 |
|
// ACTION - 777 - pdf_temp |
350 |
|
// Crée un PDF temporaire et affiche son contenu en base64 |
351 |
|
$this->class_actions[777] = array( |
352 |
|
"identifier" => "pdf_temp", |
353 |
|
"view" => "view_pdf_temp", |
354 |
|
"permission_suffix" => "modifier", |
355 |
|
"condition" => array("can_user_access_dossier_contexte_modification"), |
356 |
|
); |
357 |
|
|
358 |
/** |
// ACTION - 701 |
359 |
* Cette méthode permet de récupérer le dossier d'autorisation d'un dossier |
$this->class_actions[701] = array( |
360 |
*/ |
"identifier" => "enable-edition-integrale", |
361 |
function getNumDemandeAutorFromDossier($id) { |
"portlet" => array( |
362 |
// |
"type" => "action-direct-with-confirmation", |
363 |
if (!isset($id)) { |
"libelle" => _("Rédaction libre"), |
364 |
return NULL; |
"order" => 50, |
365 |
} |
"class" => "redac-libre-16", |
366 |
// |
), |
367 |
$sql = "select dossier_autorisation from ".DB_PREFIXE."dossier "; |
"view" => "formulaire", |
368 |
$sql .= " where dossier='".$id."'"; |
"method" => "enable_edition_integrale", |
369 |
|
"permission_suffix" => "modifier", |
370 |
|
"condition" => array( |
371 |
|
"is_editable", |
372 |
|
"is_finalizable_without_bypass", |
373 |
|
"can_user_access_dossier_contexte_modification", |
374 |
|
"is_edition_integrale_not_enabled", |
375 |
|
"is_option_redaction_libre_enabled", |
376 |
|
"has_an_edition", |
377 |
|
), |
378 |
|
); |
379 |
|
// ACTION - 702 |
380 |
|
$this->class_actions[702] = array( |
381 |
|
"identifier" => "disable-edition-integrale", |
382 |
|
"portlet" => array( |
383 |
|
"type" => "action-direct-with-confirmation", |
384 |
|
"libelle" => _("Rédaction par compléments"), |
385 |
|
"order" => 50, |
386 |
|
"class" => "redac-complement-16", |
387 |
|
), |
388 |
|
"view" => "formulaire", |
389 |
|
"method" => "disable_edition_integrale", |
390 |
|
"permission_suffix" => "modifier", |
391 |
|
"condition" => array( |
392 |
|
"is_editable", |
393 |
|
"is_finalizable_without_bypass", |
394 |
|
"can_user_access_dossier_contexte_modification", |
395 |
|
"is_edition_integrale_enabled", |
396 |
|
"is_option_redaction_libre_enabled", |
397 |
|
"has_an_edition", |
398 |
|
), |
399 |
|
); |
400 |
|
// ACTION - 300 - evenement_has_an_edition_json |
401 |
// |
// |
402 |
$dossier_autorisation = $this->db->getOne($sql); |
$this->class_actions[300] = array( |
403 |
$this->addToLog("getNumDemandeAutorFromDossier(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
"identifier" => "evenement_has_an_edition_json", |
404 |
database::isError($dossier_autorisation); |
"view" => "view_evenement_has_an_edition_json", |
405 |
|
"permission_suffix" => "consulter", |
406 |
|
); |
407 |
|
|
408 |
|
// ACTION - 301 - evenement_has_a_commentaire |
409 |
// |
// |
410 |
return $dossier_autorisation; |
$this->class_actions[301] = array( |
411 |
} |
"identifier" => "evenement_has_a_commentaire_json", |
412 |
|
"view" => "view_evenement_has_a_commentaire_json", |
413 |
|
"permission_suffix" => "consulter", |
414 |
|
); |
415 |
|
|
416 |
// }}} |
// ACTION - 400 - Envoyer en signature |
417 |
|
// Cet évenement permet d'envoyer le document au parapheur pour signature |
418 |
|
$this->class_actions[400] = array( |
419 |
|
"identifier" => "envoyer_a_signature", |
420 |
|
"portlet" => array( |
421 |
|
"libelle" => _("Envoyer à signature"), |
422 |
|
"type" => "action-direct-with-confirmation", |
423 |
|
"class" => "envoyer_a_signature-16", |
424 |
|
), |
425 |
|
"view" => "formulaire", |
426 |
|
"method" => "envoyer_a_signature_sans_relecture", |
427 |
|
"condition" => array( |
428 |
|
"can_be_signed", |
429 |
|
), |
430 |
|
"permission_suffix" => "envoyer_a_signature", |
431 |
|
); |
432 |
|
|
433 |
|
// ACTION - 402 - Envoyer en signature avec relecture |
434 |
|
// Cet évenement permet d'envoyer le document au parapheur pour signature |
435 |
|
$this->class_actions[402] = array( |
436 |
|
"identifier" => "envoyer_a_signature_relecture", |
437 |
|
"portlet" => array( |
438 |
|
"libelle" => __("Envoyer à signature avec relecture"), |
439 |
|
"type" => "action-direct-with-confirmation", |
440 |
|
"class" => "envoyer_a_signature-16", |
441 |
|
), |
442 |
|
"view" => "formulaire", |
443 |
|
"method" => "envoyer_a_signature_avec_relecture", |
444 |
|
"condition" => array( |
445 |
|
"can_be_signed", |
446 |
|
"is_parapheur_relecture_parameter_enabled" |
447 |
|
), |
448 |
|
"permission_suffix" => "envoyer_a_signature", |
449 |
|
); |
450 |
|
|
451 |
|
// ACTION - 404 - Annuler l'envoi en signature |
452 |
|
// Cet évenement permet d'annuler l'envoi en signature du document au parapheur |
453 |
|
$this->class_actions[404] = array( |
454 |
|
"identifier" => "annuler_envoi_signature", |
455 |
|
"portlet" => array( |
456 |
|
"libelle" => __("Annuler l'envoi en signature"), |
457 |
|
"type" => "action-direct-with-confirmation", |
458 |
|
"class" => "annuler_envoi_signature-16", |
459 |
|
), |
460 |
|
"view" => "formulaire", |
461 |
|
"method" => "annuler_envoi_en_signature", |
462 |
|
"condition" => array( |
463 |
|
"is_sent_for_signature", |
464 |
|
"is_parapheur_annulation_parameter_enabled" |
465 |
|
), |
466 |
|
"permission_suffix" => "envoyer_a_signature", |
467 |
|
); |
468 |
|
|
|
function setType(&$form, $maj) { |
|
|
// |
|
|
parent::setType($form, $maj); |
|
|
// On cache tous les champs |
|
|
// XXX |
|
|
$form->setType('complement5_om_html', 'hidden'); |
|
|
$form->setType('bible5', 'hidden'); |
|
|
$form->setType('complement6_om_html', 'hidden'); |
|
|
$form->setType('bible6', 'hidden'); |
|
|
$form->setType('complement7_om_html', 'hidden'); |
|
|
$form->setType('bible7', 'hidden'); |
|
|
$form->setType('complement8_om_html', 'hidden'); |
|
|
$form->setType('bible8', 'hidden'); |
|
|
$form->setType('complement9_om_html', 'hidden'); |
|
|
$form->setType('bible9', 'hidden'); |
|
|
$form->setType('complement10_om_html', 'hidden'); |
|
|
$form->setType('bible10', 'hidden'); |
|
|
$form->setType('complement11_om_html', 'hidden'); |
|
|
$form->setType('bible11', 'hidden'); |
|
|
$form->setType('complement12_om_html', 'hidden'); |
|
|
$form->setType('bible12', 'hidden'); |
|
|
$form->setType('complement13_om_html', 'hidden'); |
|
|
$form->setType('bible13', 'hidden'); |
|
|
$form->setType('complement14_om_html', 'hidden'); |
|
|
$form->setType('bible14', 'hidden'); |
|
|
$form->setType('complement15_om_html', 'hidden'); |
|
|
$form->setType('bible15', 'hidden'); |
|
|
// |
|
|
$form->setType('delai', 'hidden'); |
|
|
$form->setType('etat', 'hidden'); |
|
|
$form->setType('accord_tacite', 'hidden'); |
|
|
$form->setType('action', 'hidden'); |
|
|
$form->setType('delai_notification', 'hidden'); |
|
|
$form->setType('avis_decision', 'hidden'); |
|
|
$form->setType('autorite_competente', 'hidden'); |
|
|
// |
|
|
$form->setType('archive_delai', 'hidden'); |
|
|
$form->setType('archive_etat', 'hidden'); |
|
|
$form->setType('archive_accord_tacite', 'hidden'); |
|
|
$form->setType('archive_avis', 'hidden'); |
|
|
$form->setType('archive_date_complet', 'hiddendate'); |
|
|
$form->setType('archive_date_dernier_depot', 'hiddendate'); |
|
|
$form->setType('archive_date_rejet', 'hiddendate'); |
|
|
$form->setType('archive_date_limite', 'hiddendate'); |
|
|
$form->setType('archive_date_notification_delai', 'hiddendate'); |
|
|
$form->setType('archive_date_decision', 'hiddendate'); |
|
|
$form->setType('archive_date_validite', 'hiddendate'); |
|
|
$form->setType('archive_date_achevement', 'hiddendate'); |
|
|
$form->setType('archive_date_conformite', 'hiddendate'); |
|
|
$form->setType('archive_date_chantier', 'hiddendate'); |
|
|
$form->setType('archive_autorite_competente','hidden'); |
|
|
$form->setType('date_depot','hidden'); |
|
|
// |
|
|
$form->setType('numero_arrete', 'hidden'); |
|
469 |
// |
// |
470 |
$form->setType('code_barres', 'hidden'); |
$this->class_actions[401] = array( |
471 |
|
"identifier" => "preview_edition", |
472 |
|
"view" => "formulaire", |
473 |
|
"permission_suffix" => "tab", |
474 |
|
); |
475 |
|
|
476 |
|
// ACTION - 410 - Notifier les pétitionnaires (mail ou autre) |
477 |
|
$this->class_actions[410] = array( |
478 |
|
"identifier" => "overlay_notification_manuelle", |
479 |
|
"portlet" => array( |
480 |
|
"libelle" => __("Notifier les pétitionnaires"), |
481 |
|
"type" => "action-self", |
482 |
|
"class" => "notifier_commune-16", |
483 |
|
), |
484 |
|
"condition" => array( |
485 |
|
"is_notifiable_by_task_manual", |
486 |
|
"is_not_portail_notification_sans_annexe" |
487 |
|
), |
488 |
|
"view" => "view_overlay_notification_manuelle", |
489 |
|
"permission_suffix" => "modifier", |
490 |
|
); |
491 |
|
|
492 |
|
// ACTION - 411 - Notifier les pétitionnaires (portail citoyen) |
493 |
|
$this->class_actions[411] = array( |
494 |
|
"identifier" => "notification_manuelle_portal", |
495 |
|
"portlet" => array( |
496 |
|
"libelle" => __("Notifier les pétitionnaires"), |
497 |
|
"type" => "action-direct-with-confirmation", |
498 |
|
"class" => "notifier_commune-16", |
499 |
|
), |
500 |
|
"condition" => array( |
501 |
|
"is_notifiable_by_task_manual", |
502 |
|
"is_portail_notification_sans_annexe" |
503 |
|
), |
504 |
|
"method" => "notifier_demandeur_principal", |
505 |
|
"permission_suffix" => "modifier", |
506 |
|
); |
507 |
|
|
508 |
|
// ACTION - 420 - Notifier les services consultés (mail) |
509 |
|
$this->class_actions[420] = array( |
510 |
|
"identifier" => "overlay_notification_service_consulte", |
511 |
|
"portlet" => array( |
512 |
|
"libelle" => __("Notifier les services consultés"), |
513 |
|
"type" => "action-self", |
514 |
|
"class" => "notifier_commune-16", |
515 |
|
), |
516 |
|
"condition" => array( |
517 |
|
"is_service_notifiable" |
518 |
|
), |
519 |
|
"view" => "view_overlay_notification_service_consulte", |
520 |
|
"permission_suffix" => "tab", |
521 |
|
); |
522 |
|
|
523 |
|
// ACTION - 430 - Notifier les tiers consultés (mail) |
524 |
|
$this->class_actions[430] = array( |
525 |
|
"identifier" => "overlay_notification_tiers_consulte", |
526 |
|
"portlet" => array( |
527 |
|
"libelle" => __("Notifier les tiers consultés"), |
528 |
|
"type" => "action-self", |
529 |
|
"class" => "notifier_commune-16", |
530 |
|
), |
531 |
|
"condition" => array( |
532 |
|
"is_tiers_notifiable" |
533 |
|
), |
534 |
|
"view" => "view_overlay_notification_tiers_consulte", |
535 |
|
"permission_suffix" => "tab", |
536 |
|
); |
537 |
|
|
538 |
// |
// |
539 |
$form->setType('archive_incompletude','hidden'); |
$this->class_actions[403] = array( |
540 |
$form->setType('archive_incomplet_notifie','hidden'); |
"identifier" => "envoyer_au_controle_de_legalite", |
541 |
$form->setType('archive_evenement_suivant_tacite','hidden'); |
"portlet" => array( |
542 |
$form->setType('archive_evenement_suivant_tacite_incompletude','hidden'); |
"libelle" => __("Envoyer au contrôle de légalité"), |
543 |
$form->setType('archive_etat_pendant_incompletude','hidden'); |
"type" => "action-direct-with-confirmation", |
544 |
$form->setType('archive_date_limite_incompletude','hiddendate'); |
"class" => "envoyer_au_controle_de_legalite-16", |
545 |
$form->setType('archive_delai_incompletude','hidden'); |
), |
546 |
|
"view" => "formulaire", |
547 |
|
"method" => "envoyer_au_controle_de_legalite", |
548 |
|
"condition" => array( |
549 |
|
"can_be_sended_to_cl" |
550 |
|
), |
551 |
|
"permission_suffix" => "envoyer_au_controle_de_legalite", |
552 |
|
); |
553 |
|
|
554 |
// |
// |
555 |
$form->setType('archive_date_cloture_instruction','hidden'); |
$this->class_actions[998] = array( |
556 |
$form->setType('archive_date_premiere_visite','hidden'); |
"identifier" => "json_data", |
557 |
$form->setType('archive_date_derniere_visite','hidden'); |
"view" => "view_json_data", |
558 |
$form->setType('archive_date_contradictoire','hidden'); |
"permission_suffix" => "consulter", |
559 |
$form->setType('archive_date_retour_contradictoire','hidden'); |
); |
560 |
$form->setType('archive_date_ait','hiddendate'); |
} |
561 |
$form->setType('archive_date_transmission_parquet','hidden'); |
|
562 |
|
/** |
563 |
|
* Clause select pour la requête de sélection des données de l'enregistrement. |
564 |
|
* |
565 |
|
* @return array |
566 |
|
*/ |
567 |
|
function get_var_sql_forminc__champs() { |
568 |
|
return array( |
569 |
|
"instruction", |
570 |
|
"destinataire", |
571 |
|
"instruction.evenement", |
572 |
|
"instruction.commentaire", |
573 |
|
"date_evenement", |
574 |
|
"instruction.lettretype", |
575 |
|
"signataire_arrete", |
576 |
|
"flag_edition_integrale", |
577 |
|
"om_final_instruction_utilisateur", |
578 |
|
"date_finalisation_courrier", |
579 |
|
"date_envoi_signature", |
580 |
|
"date_envoi_rar", |
581 |
|
"date_envoi_controle_legalite", |
582 |
|
|
583 |
|
"date_retour_signature", |
584 |
|
"date_retour_rar", |
585 |
|
"date_retour_controle_legalite", |
586 |
|
|
587 |
|
"numero_arrete", |
588 |
|
|
589 |
|
"complement_om_html", |
590 |
|
"'' as bible_auto", |
591 |
|
"'' as bible", |
592 |
|
"complement2_om_html", |
593 |
|
"'' as bible2", |
594 |
|
"complement3_om_html", |
595 |
|
"'' as bible3", |
596 |
|
"complement4_om_html", |
597 |
|
"'' as bible4", |
598 |
|
|
599 |
|
"titre_om_htmletat", |
600 |
|
"corps_om_htmletatex", |
601 |
|
|
602 |
|
"'' as btn_preview", |
603 |
|
"'' as btn_redaction", |
604 |
|
|
605 |
|
"'' as btn_refresh", |
606 |
|
"'' as live_preview", |
607 |
|
|
608 |
|
"dossier", |
609 |
|
"instruction.action", |
610 |
|
"instruction.delai", |
611 |
|
"instruction.etat", |
612 |
|
"instruction.autorite_competente", |
613 |
|
"instruction.accord_tacite", |
614 |
|
"instruction.delai_notification", |
615 |
|
"instruction.avis_decision", |
616 |
|
"archive_delai", |
617 |
|
"archive_accord_tacite", |
618 |
|
"archive_etat", |
619 |
|
"archive_avis", |
620 |
|
"archive_date_complet", |
621 |
|
"archive_date_rejet", |
622 |
|
"archive_date_limite", |
623 |
|
"archive_date_notification_delai", |
624 |
|
"archive_date_decision", |
625 |
|
"archive_date_validite", |
626 |
|
"archive_date_achevement", |
627 |
|
"archive_date_conformite", |
628 |
|
"archive_date_chantier", |
629 |
|
"archive_date_dernier_depot", |
630 |
|
"date_depot", |
631 |
|
"date_depot_mairie", |
632 |
|
"complement5_om_html", |
633 |
|
"'' as bible5", |
634 |
|
"complement6_om_html", |
635 |
|
"'' as bible6", |
636 |
|
"complement7_om_html", |
637 |
|
"'' as bible7", |
638 |
|
"complement8_om_html", |
639 |
|
"'' as bible8", |
640 |
|
"complement9_om_html", |
641 |
|
"'' as bible9", |
642 |
|
"complement10_om_html", |
643 |
|
"'' as bible10", |
644 |
|
"complement11_om_html", |
645 |
|
"'' as bible11", |
646 |
|
"complement12_om_html", |
647 |
|
"complement13_om_html", |
648 |
|
"complement14_om_html", |
649 |
|
"complement15_om_html", |
650 |
|
"archive_incompletude", |
651 |
|
"archive_incomplet_notifie", |
652 |
|
"archive_evenement_suivant_tacite", |
653 |
|
"archive_evenement_suivant_tacite_incompletude", |
654 |
|
"archive_etat_pendant_incompletude", |
655 |
|
"archive_date_limite_incompletude", |
656 |
|
"archive_delai_incompletude", |
657 |
|
"archive_autorite_competente", |
658 |
|
"code_barres", |
659 |
|
"om_fichier_instruction", |
660 |
|
"om_final_instruction", |
661 |
|
"om_fichier_instruction_dossier_final", |
662 |
|
"document_numerise", |
663 |
|
"duree_validite_parametrage", |
664 |
|
"duree_validite", |
665 |
|
"created_by_commune", |
666 |
|
"archive_date_cloture_instruction", |
667 |
|
"archive_date_premiere_visite", |
668 |
|
"archive_date_derniere_visite", |
669 |
|
"archive_date_contradictoire", |
670 |
|
"archive_date_retour_contradictoire", |
671 |
|
"archive_date_ait", |
672 |
|
"archive_date_transmission_parquet", |
673 |
|
"archive_dossier_instruction_type", |
674 |
|
"archive_date_affichage", |
675 |
|
"pec_metier", |
676 |
|
"archive_pec_metier", |
677 |
|
"archive_a_qualifier", |
678 |
|
"id_parapheur_signature", |
679 |
|
"statut_signature", |
680 |
|
"commentaire_signature", |
681 |
|
"historique_signature", |
682 |
|
"'' as suivi_notification", |
683 |
|
"'' as suivi_notification_service", |
684 |
|
"'' as suivi_notification_tiers", |
685 |
|
"'' as suivi_notification_commune", |
686 |
|
|
687 |
|
"'' as preview_edition", |
688 |
|
"envoye_cl_platau", |
689 |
|
"'' as log_instruction" |
690 |
|
); |
691 |
|
} |
692 |
|
|
693 |
|
/** |
694 |
|
* CONDITION - is_edition_integrale_enabled |
695 |
|
* |
696 |
|
* Vérifie que la rédaction libre est activée sur l'instruction en cours. |
697 |
|
* |
698 |
|
* @return boolean |
699 |
|
*/ |
700 |
|
function is_edition_integrale_enabled() { |
701 |
|
if ($this->getVal("flag_edition_integrale") == 't') { |
702 |
|
return true; |
703 |
|
} |
704 |
|
return false; |
705 |
|
} |
706 |
|
|
707 |
|
/** |
708 |
|
* CONDITION - is_edition_integrale_not_enabled |
709 |
|
* |
710 |
|
* Vérifie que la rédaction libre est désactivée sur l'instruction en cours. |
711 |
|
* |
712 |
|
* @return boolean |
713 |
|
*/ |
714 |
|
function is_edition_integrale_not_enabled() { |
715 |
|
return !$this->is_edition_integrale_enabled(); |
716 |
|
} |
717 |
|
|
718 |
|
/** |
719 |
|
* CONDITION - is_option_redaction_libre_enabled |
720 |
|
* |
721 |
|
* Vérifie que l'option de rédaction libre est activée. |
722 |
|
* |
723 |
|
* @return boolean |
724 |
|
*/ |
725 |
|
function is_option_redaction_libre_enabled() { |
726 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite(); |
727 |
|
return $this->f->is_option_redaction_libre_enabled($collectivite_di); |
728 |
|
} |
729 |
|
|
730 |
|
/** |
731 |
|
* CONDITION - is_option_parapheur_relecture_enabled |
732 |
|
* |
733 |
|
* Vérifie que l'option de relecture lors de l'envoi en signature est activée. |
734 |
|
* |
735 |
|
* @return boolean |
736 |
|
*/ |
737 |
|
function is_parapheur_relecture_parameter_enabled() { |
738 |
|
//Instanciation de la classe electronicsignature |
739 |
|
$inst_es = $this->get_electronicsignature_instance(); |
740 |
|
if ($inst_es === false) { |
741 |
|
return false; |
742 |
|
} |
743 |
|
|
744 |
|
if ($inst_es->get_conf('is_forced_view_files') !== 'true' && $inst_es->get_conf('is_forced_view_files') !== true) { |
745 |
|
return false; |
746 |
|
} |
747 |
|
|
748 |
|
return true; |
749 |
|
} |
750 |
|
|
751 |
|
/** |
752 |
|
* CONDITION - is_parapheur_annulation_parameter_enabled |
753 |
|
* |
754 |
|
* Vérifie que l'option d'annulation de l'envoi en signature est activée. |
755 |
|
* |
756 |
|
* @return boolean |
757 |
|
*/ |
758 |
|
function is_parapheur_annulation_parameter_enabled() { |
759 |
|
//Instanciation de la classe electronicsignature |
760 |
|
$inst_es = $this->get_electronicsignature_instance(); |
761 |
|
if ($inst_es === false) { |
762 |
|
return false; |
763 |
|
} |
764 |
|
|
765 |
|
if ($inst_es->get_conf('cancel_send') !== 'true' && $inst_es->get_conf('cancel_send') !== true) { |
766 |
|
return false; |
767 |
|
} |
768 |
|
|
769 |
|
return true; |
770 |
|
} |
771 |
|
|
772 |
|
|
773 |
|
/** |
774 |
|
* CONDITION - is_sent_for_signature |
775 |
|
* |
776 |
|
* Vérifie que l'instruction a été envoyé à signature |
777 |
|
* |
778 |
|
* @return boolean |
779 |
|
*/ |
780 |
|
function is_sent_for_signature() { |
781 |
|
// Si un parapheur a été configuré |
782 |
|
// et que le champ id_parapheur_signature n'est pas vide |
783 |
|
// que le status est différent de "canceled" ou "expired" |
784 |
|
// alors l'évènement a été envoyé en signature |
785 |
|
if ($this->has_connector_electronicsignature() === true |
786 |
|
&& empty($this->getVal("id_parapheur_signature")) === false |
787 |
|
&& ($this->getVal("statut_signature") != "canceled" |
788 |
|
&& $this->getVal("statut_signature") != "expired" |
789 |
|
&& $this->getVal("statut_signature") != "finished")) { |
790 |
|
// |
791 |
|
return true; |
792 |
|
} |
793 |
|
|
794 |
|
return false; |
795 |
|
} |
796 |
|
|
797 |
|
/** |
798 |
|
* CONDITION - is_not_sent_for_signature |
799 |
|
* |
800 |
|
* Vérifie que l'instruction n'a pas été envoyé à signature |
801 |
|
* |
802 |
|
* @return boolean |
803 |
|
*/ |
804 |
|
function is_not_sent_for_signature() { |
805 |
|
// Contrôle si l'utilisateur possède un bypass |
806 |
|
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_definaliser_bypass"); |
807 |
|
if ($bypass == true) { |
808 |
|
return true; |
809 |
|
} |
810 |
|
|
811 |
|
return !$this->is_sent_for_signature(); |
812 |
|
} |
813 |
|
|
814 |
|
|
815 |
|
/** |
816 |
|
* CONDITION - is_signed |
817 |
|
* |
818 |
|
* Vérifie que l'instruction a été signé |
819 |
|
* |
820 |
|
* @return boolean |
821 |
|
*/ |
822 |
|
function is_signed() { |
823 |
|
// Si un parapheur a été configuré |
824 |
|
// et que le champ id_parapheur_signature n'est pas vide |
825 |
|
// et que le statut est égal à "finished" |
826 |
|
// alors le document de l'instruciton à été signé |
827 |
|
if ($this->has_connector_electronicsignature() === true |
828 |
|
&& empty($this->getVal("id_parapheur_signature")) === false |
829 |
|
&& $this->getVal("statut_signature") == "finished") { |
830 |
|
// |
831 |
|
return true; |
832 |
|
} |
833 |
|
|
834 |
|
return false; |
835 |
|
} |
836 |
|
|
837 |
|
|
838 |
|
/** |
839 |
|
* is_sent_to_cl |
840 |
|
* |
841 |
|
* Vérifie que l'instruction a été envoyé au contrôle de légalité |
842 |
|
* |
843 |
|
* @return boolean |
844 |
|
*/ |
845 |
|
function is_sent_to_cl() { |
846 |
|
// Si la case à cocher de l'instruction envoye_cl_platau est à "t" |
847 |
|
if ($this->getVal('envoye_cl_platau') === 't') { |
848 |
|
// |
849 |
|
return true; |
850 |
|
} |
851 |
// |
// |
852 |
$form->setType('duree_validite','hidden'); |
return false; |
853 |
$form->setType('duree_validite_parametrage','hidden'); |
} |
854 |
|
|
855 |
|
/** |
856 |
|
* CONDITION - is_portail_notification |
857 |
|
* |
858 |
|
* Vérifie si la notification est une notification de catégorie portail |
859 |
|
* |
860 |
|
* @return boolean |
861 |
|
*/ |
862 |
|
function is_portail_notification_sans_annexe() { |
863 |
|
$collectiviteDi = $this->get_dossier_instruction_om_collectivite(); |
864 |
|
$ev = $this->get_inst_evenement($this->getVal('evenement')); |
865 |
|
if ($this->f->get_param_option_notification($collectiviteDi) === PORTAL |
866 |
|
&& $ev->getVal('notification') != 'notification_manuelle_annexe' |
867 |
|
&& $ev->getVal('notification') != 'notification_manuelle_annexe_signature_requise' |
868 |
|
) { |
869 |
|
return true; |
870 |
|
} |
871 |
|
return false; |
872 |
|
} |
873 |
|
|
874 |
|
/** |
875 |
|
* CONDITION - is_not_portail_notification |
876 |
|
* |
877 |
|
* Vérifie si la notification n'est pas une notification de catégorie portail |
878 |
|
* |
879 |
|
* @return boolean |
880 |
|
*/ |
881 |
|
function is_not_portail_notification_sans_annexe() { |
882 |
|
return (! $this->is_portail_notification_sans_annexe()); |
883 |
|
} |
884 |
|
|
885 |
|
/** |
886 |
|
* CONDITION - can_be_signed |
887 |
|
* |
888 |
|
* Vérifie que le document de l'instruction peut être envoyé au parapheur pour signature |
889 |
|
* |
890 |
|
* @return boolean |
891 |
|
*/ |
892 |
|
function can_be_signed() { |
893 |
|
// Instanciation de l'objet signataire_arrete |
894 |
|
$inst_signataire_arrete = $this->f->get_inst__om_dbform(array( |
895 |
|
"obj" => "signataire_arrete", |
896 |
|
"idx" => $this->getVal("signataire_arrete"), |
897 |
|
)); |
898 |
|
// Si un parapheur a été configuré, que le document est finalisé, que le signataire |
899 |
|
// possède une adresse email, on vérifie le champ id_parapheur_signature |
900 |
|
// S'il est vide l'évènement peut être envoyé en signature |
901 |
|
// S'il ne l'est pas, alors on vérifie le champ statut_signature |
902 |
|
// Si la valeur de ce champ est égal à "canceled" ou "expired" |
903 |
|
// alors l'évènement peut être envoyé en signature |
904 |
|
if ($this->has_connector_electronicsignature() === true |
905 |
|
&& $this->getVal("om_final_instruction") == 't' |
906 |
|
&& empty($inst_signataire_arrete->getVal('email')) === false) { |
907 |
|
// |
908 |
|
if (empty($this->getVal("id_parapheur_signature")) === true |
909 |
|
|| $this->getVal("statut_signature") == "canceled" |
910 |
|
|| $this->getVal("statut_signature") == "expired") { |
911 |
|
// |
912 |
|
return true; |
913 |
|
} |
914 |
|
} |
915 |
|
|
916 |
|
$this->addToLog(__METHOD__."() has_connector_electronicsignature: ".var_export($this->has_connector_electronicsignature(), true), EXTRA_VERBOSE_MODE); |
917 |
|
$this->addToLog(__METHOD__."() om_final_instruction: ".var_export($this->getVal("om_final_instruction"), true), EXTRA_VERBOSE_MODE); |
918 |
|
$this->addToLog(__METHOD__."() email: ".var_export($inst_signataire_arrete->getVal('email'), true), EXTRA_VERBOSE_MODE); |
919 |
|
$this->addToLog(__METHOD__."() id_parapheur_signature: ".var_export($this->getVal("id_parapheur_signature"), true), EXTRA_VERBOSE_MODE); |
920 |
|
$this->addToLog(__METHOD__."() statut_signature: ".var_export($this->getVal("statut_signature"), true), EXTRA_VERBOSE_MODE); |
921 |
|
|
922 |
|
return false; |
923 |
|
} |
924 |
|
|
925 |
|
/** |
926 |
|
* CONDITION - has_connector_electronicsignature |
927 |
|
* |
928 |
|
* Vérifie qu'un parapheur est paramétré |
929 |
|
* |
930 |
|
* @return boolean |
931 |
|
*/ |
932 |
|
function has_connector_electronicsignature() { |
933 |
|
$inst_es = $this->get_electronicsignature_instance(false); |
934 |
|
if ($inst_es === false) { |
935 |
|
return false; |
936 |
|
} |
937 |
|
return true; |
938 |
|
} |
939 |
|
|
940 |
|
/** |
941 |
|
* CONDITION - can_display_parapheur |
942 |
|
* |
943 |
|
* Vérifie que le fieldset "Suivi Parapheur" soit affichable |
944 |
|
* |
945 |
|
* @return boolean |
946 |
|
*/ |
947 |
|
function can_display_parapheur() { |
948 |
|
$evenement_id = $this->getVal("evenement"); |
949 |
|
$inst_evenement = $this->get_inst_evenement($evenement_id); |
950 |
|
if ($this->has_connector_electronicsignature() === true |
951 |
|
&& $inst_evenement->getVal('lettretype') !== '' |
952 |
|
&& $inst_evenement->getVal('lettretype') !== null |
953 |
|
&& (empty($this->getVal("id_parapheur_signature")) === false |
954 |
|
|| empty($this->getVal("historique_signature")) === false)) { |
955 |
|
// |
956 |
|
return true; |
957 |
|
} |
958 |
|
|
959 |
|
return false; |
960 |
|
} |
961 |
|
|
962 |
|
/** |
963 |
|
* CONDITION - can_display_notification |
964 |
|
* |
965 |
|
* Vérifie que le champs "Suivi notification" est affichable |
966 |
|
* |
967 |
|
* @return boolean |
968 |
|
*/ |
969 |
|
function can_display_notification_demandeur() { |
970 |
|
// Le suivi des notification est affiché si l'événement est notifiable |
971 |
|
// et si des notifications ont été envoyées |
972 |
|
$evenement_id = $this->getVal("evenement"); |
973 |
|
$inst_evenement = $this->get_inst_evenement($evenement_id); |
974 |
|
if ($inst_evenement->getVal('notification') != null && |
975 |
|
$inst_evenement->getVal('notification') != '') { |
976 |
|
// Des notifications ont été envoyé si il existe au moins une notification |
977 |
|
// liées à l'instruction |
978 |
|
$idsNotifs = $this->get_instruction_notification( |
979 |
|
$this->getVal($this->clePrimaire), |
980 |
|
array( |
981 |
|
'notification_recepisse', |
982 |
|
'notification_instruction', |
983 |
|
'notification_decision', |
984 |
|
), |
985 |
|
true |
986 |
|
); |
987 |
|
if (isset($idsNotifs) && $idsNotifs !== array()) { |
988 |
|
return true; |
989 |
|
} |
990 |
|
} |
991 |
|
return false; |
992 |
|
} |
993 |
|
|
994 |
|
/** |
995 |
|
* CONDITION - can_display_notification |
996 |
|
* |
997 |
|
* Vérifie que le champs "suivi_notification_service" est affichable |
998 |
|
* |
999 |
|
* @return boolean |
1000 |
|
*/ |
1001 |
|
function can_display_notification_service() { |
1002 |
|
// Le suivi des notification est affiché si l'événement est notifiable |
1003 |
|
// et si des notifications ont été envoyées |
1004 |
|
$evenement_id = $this->getVal("evenement"); |
1005 |
|
$inst_evenement = $this->get_inst_evenement($evenement_id); |
1006 |
|
if ($this->get_boolean_from_pgsql_value($inst_evenement->getVal('notification_service')) == true) { |
1007 |
|
// Des notifications ont été envoyé si il existe au moins une notification |
1008 |
|
// de type notification_service_consulte liées à l'instruction |
1009 |
|
$idsNotifs = $this->get_instruction_notification( |
1010 |
|
$this->getVal($this->clePrimaire), |
1011 |
|
'notification_service_consulte' |
1012 |
|
); |
1013 |
|
if (isset($idsNotifs) && $idsNotifs !== array()) { |
1014 |
|
return true; |
1015 |
|
} |
1016 |
|
} |
1017 |
|
return false; |
1018 |
|
} |
1019 |
|
|
1020 |
|
|
1021 |
|
/** |
1022 |
|
* CONDITION - can_display_notification_tiers |
1023 |
|
* |
1024 |
|
* Vérifie que le champs "suivi_notification_tiers" est affichable |
1025 |
|
* |
1026 |
|
* @return boolean |
1027 |
|
*/ |
1028 |
|
function can_display_notification_tiers() { |
1029 |
|
// Le suivi des notification est affiché si l'événement est notifiable |
1030 |
|
// et si des notifications ont été envoyées |
1031 |
|
$evenement_id = $this->getVal("evenement"); |
1032 |
|
$inst_evenement = $this->get_inst_evenement($evenement_id); |
1033 |
|
if (! empty($inst_evenement->getVal('notification_tiers'))) { |
1034 |
|
// Des notifications ont été envoyé si il existe au moins une notification |
1035 |
|
// de type notification_tiers_consulte liées à l'instruction |
1036 |
|
$idsNotifs = $this->get_instruction_notification( |
1037 |
|
$this->getVal($this->clePrimaire), |
1038 |
|
'notification_tiers_consulte' |
1039 |
|
); |
1040 |
|
if (isset($idsNotifs) && $idsNotifs !== array()) { |
1041 |
|
return true; |
1042 |
|
} |
1043 |
|
} |
1044 |
|
return false; |
1045 |
|
} |
1046 |
|
|
1047 |
|
/** |
1048 |
|
* CONDITION - can_display_notification_commune |
1049 |
|
* |
1050 |
|
* Vérifie que le champs "suivi_notification_commune" est affichable |
1051 |
|
* |
1052 |
|
* @return boolean |
1053 |
|
*/ |
1054 |
|
function can_display_notification_commune() { |
1055 |
|
// Le suivi des notification si il existe au moins une notification |
1056 |
|
// de type notification_depot_demat liées à l'instruction |
1057 |
|
$idsNotifs = $this->get_instruction_notification( |
1058 |
|
$this->getVal($this->clePrimaire), |
1059 |
|
array('notification_depot_demat', 'notification_commune') |
1060 |
|
); |
1061 |
|
if (isset($idsNotifs) && $idsNotifs !== array()) { |
1062 |
|
return true; |
1063 |
|
} |
1064 |
|
return false; |
1065 |
|
} |
1066 |
|
|
1067 |
|
/** |
1068 |
|
* TREATMENT - disable_edition_integrale. |
1069 |
|
* |
1070 |
|
* Cette methode permet de passer la consultation en "lu" |
1071 |
|
* |
1072 |
|
* @return boolean true si maj effectué false sinon |
1073 |
|
*/ |
1074 |
|
function disable_edition_integrale() { |
1075 |
|
// Cette méthode permet d'exécuter une routine en début des méthodes |
1076 |
|
// dites de TREATMENT. |
1077 |
|
$this->begin_treatment(__METHOD__); |
1078 |
|
$this->correct = true; |
1079 |
|
$valF = array( |
1080 |
|
"flag_edition_integrale" => false, |
1081 |
|
"titre_om_htmletat" => null, |
1082 |
|
"corps_om_htmletatex" => null, |
1083 |
|
); |
1084 |
|
$res = $this->f->db->autoExecute( |
1085 |
|
DB_PREFIXE.$this->table, |
1086 |
|
$valF, |
1087 |
|
DB_AUTOQUERY_UPDATE, |
1088 |
|
$this->clePrimaire."=".$this->getVal($this->clePrimaire) |
1089 |
|
); |
1090 |
|
if ($this->f->isDatabaseError($res, true)) { |
1091 |
|
// Appel de la methode de recuperation des erreurs |
1092 |
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
1093 |
|
$this->correct = false; |
1094 |
|
// Termine le traitement |
1095 |
|
return $this->end_treatment(__METHOD__, false); |
1096 |
|
} else { |
1097 |
|
$this->addToMessage(_("Rédaction par compléments activé.")); |
1098 |
|
return $this->end_treatment(__METHOD__, true); |
1099 |
|
} |
1100 |
|
|
1101 |
|
// Termine le traitement |
1102 |
|
return $this->end_treatment(__METHOD__, false); |
1103 |
|
} |
1104 |
|
|
1105 |
|
/** |
1106 |
|
* TREATMENT - enable_edition_integrale. |
1107 |
|
* |
1108 |
|
* Cette methode permet de passer la consultation en "lu" |
1109 |
|
* |
1110 |
|
* @return boolean true si maj effectué false sinon |
1111 |
|
*/ |
1112 |
|
function enable_edition_integrale() { |
1113 |
|
// Cette méthode permet d'exécuter une routine en début des méthodes |
1114 |
|
// dites de TREATMENT. |
1115 |
|
$this->begin_treatment(__METHOD__); |
1116 |
|
$this->correct = true; |
1117 |
|
|
1118 |
|
// Récupère la collectivite du dossier d'instruction |
1119 |
|
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
1120 |
|
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
1121 |
|
// |
1122 |
|
$params = array( |
1123 |
|
"specific" => array( |
1124 |
|
"corps" => array( |
1125 |
|
"mode" => "get", |
1126 |
|
) |
1127 |
|
), |
1128 |
|
); |
1129 |
|
$result = $this->compute_pdf_output('lettretype', $this->getVal('lettretype'), $collectivite, null, $params); |
1130 |
|
$corps = $result['pdf_output']; |
1131 |
// |
// |
1132 |
$form->setType('created_by_commune','hidden'); |
$params = array( |
1133 |
|
"specific" => array( |
1134 |
|
"titre" => array( |
1135 |
|
"mode" => "get", |
1136 |
|
) |
1137 |
|
), |
1138 |
|
); |
1139 |
|
$result = $this->compute_pdf_output('lettretype', $this->getVal('lettretype'), $collectivite, null, $params); |
1140 |
|
$titre = $result['pdf_output']; |
1141 |
// |
// |
1142 |
// gestion du champ "finalisé par" |
$valF = array( |
1143 |
if ($this->getVal("om_final_instruction") == 't') { |
"flag_edition_integrale" => true, |
1144 |
$form->setType('om_final_instruction_utilisateur', 'static'); |
"titre_om_htmletat" => $titre, |
1145 |
|
"corps_om_htmletatex" => $corps, |
1146 |
|
); |
1147 |
|
$res = $this->f->db->autoExecute( |
1148 |
|
DB_PREFIXE.$this->table, |
1149 |
|
$valF, |
1150 |
|
DB_AUTOQUERY_UPDATE, |
1151 |
|
$this->clePrimaire."=".$this->getVal($this->clePrimaire) |
1152 |
|
); |
1153 |
|
if ($this->f->isDatabaseError($res, true)) { |
1154 |
|
// Appel de la methode de recuperation des erreurs |
1155 |
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
1156 |
|
$this->correct = false; |
1157 |
|
// Termine le traitement |
1158 |
|
return $this->end_treatment(__METHOD__, false); |
1159 |
} else { |
} else { |
1160 |
$form->setType('om_final_instruction_utilisateur', 'hidden'); |
$this->addToMessage(_("Rédaction libre activé.")); |
1161 |
|
return $this->end_treatment(__METHOD__, true); |
1162 |
} |
} |
1163 |
// |
|
1164 |
if ($maj < 2 || $maj == 125) { //ajouter, modifier et suivi des dates |
// Termine le traitement |
1165 |
$form->setType('destinataire', 'hidden'); |
return $this->end_treatment(__METHOD__, false); |
1166 |
$form->setType('lettretype', 'hiddenstatic'); |
} |
1167 |
$form->setType('complement_om_html', 'html'); |
|
1168 |
$form->setType('complement2_om_html', 'html'); |
/** |
1169 |
$form->setType('complement3_om_html', 'html'); |
* Cette méthode instancie le dossier à partir de l'identifiant passé |
1170 |
$form->setType('complement4_om_html', 'html'); |
* en paramètre et renvoie l'identifiant du dossier d'autorisation (DA) |
1171 |
$form->setType('bible_auto', 'httpclick'); |
* associé au dossier. |
1172 |
$form->setType('bible', 'httpclick'); |
* Si l'identifiant du dossier n'est pas fourni alors cette méthode |
1173 |
$form->setType('bible2', 'httpclick'); |
* renverra NULL |
1174 |
$form->setType('bible3', 'httpclick'); |
* |
1175 |
$form->setType('bible4', 'httpclick'); |
* @param string identifiant du dossier |
1176 |
$form->setType('dossier', 'hidden'); |
* @return null|string null ou identifiant du DA |
1177 |
$form->setType('libelle', 'hiddenstatic'); |
*/ |
1178 |
$form->setType('signataire_arrete','select'); |
function getNumDemandeAutorFromDossier($id) { |
1179 |
$form->setType('date_envoi_signature','datedisabled'); |
if (!isset($id)) { |
1180 |
$form->setType('date_retour_signature','datedisabled'); |
return NULL; |
1181 |
$form->setType('date_envoi_rar','datedisabled'); |
} |
1182 |
$form->setType('date_retour_rar','datedisabled'); |
|
1183 |
$form->setType('date_envoi_controle_legalite','datedisabled'); |
$dossier = $this->f->get_inst__om_dbform(array( |
1184 |
$form->setType('date_retour_controle_legalite','datedisabled'); |
'obj' => 'dossier', |
1185 |
$form->setType('date_finalisation_courrier','datedisabled'); |
'idx' => $id, |
1186 |
|
)); |
1187 |
if($maj==0){ // ajouter |
|
1188 |
$form->setType('instruction', 'hidden'); |
return $dossier->getVal('dossier_autorisation'); |
1189 |
$form->setType('lettretype', 'hidden'); |
} |
1190 |
$form->setType('evenement', 'select'); |
|
1191 |
$form->setType('date_evenement', 'date2'); |
|
1192 |
}else{ // modifier et suivi des dates |
function setType(&$form, $maj) { |
1193 |
$form->setType('instruction', 'hiddenstatic'); |
// Récupération du mode de l'action |
1194 |
$form->setType('evenement', 'selecthiddenstatic'); |
$crud = $this->get_action_crud($maj); |
1195 |
//$form->setType('date_evenement', 'hiddenstaticdate'); |
// Récupère la collectivité du dossier d'instruction |
1196 |
$form->setType('date_evenement', 'date2'); |
$collectivite_di = $this->get_dossier_instruction_om_collectivite(); |
1197 |
|
|
1198 |
|
// Cache tous les champs |
1199 |
|
foreach ($this->champs as $value) { |
1200 |
|
$form->setType($value, 'hidden'); |
1201 |
|
} |
1202 |
|
|
1203 |
|
// Les champs historique_signature et statut_signature ne sont pas saisissable dans tous les cas |
1204 |
|
if ($this->can_display_parapheur() === true && $maj == 3) { |
1205 |
|
$form->setType('statut_signature', 'selectstatic'); |
1206 |
|
$form->setType('historique_signature', 'jsontotab'); |
1207 |
|
if ($this->getVal('commentaire_signature') == null) { |
1208 |
|
$form->setType('commentaire_signature', 'hidden'); |
1209 |
|
} else { |
1210 |
|
$form->setType('commentaire_signature', 'hiddenstatic'); |
1211 |
|
} |
1212 |
|
} |
1213 |
|
|
1214 |
|
// Le champ de suivi des notifications des demandeurs n'est pas affichable dans tous les cas |
1215 |
|
if ($maj == 3 && $this->can_display_notification_demandeur() === true) { |
1216 |
|
$form->setType('suivi_notification', 'jsontotab'); |
1217 |
|
} |
1218 |
|
// Le champ de suivi des notifications des services n'est pas affichable dans tous les cas |
1219 |
|
if ($maj == 3 && $this->can_display_notification_service() === true) { |
1220 |
|
$form->setType('suivi_notification_service', 'jsontotab'); |
1221 |
|
} |
1222 |
|
// Le champ de suivi des notifications des tiers n'est pas affichable dans tous les cas |
1223 |
|
if ($maj == 3 && $this->can_display_notification_tiers() === true) { |
1224 |
|
$form->setType('suivi_notification_tiers', 'jsontotab'); |
1225 |
|
} |
1226 |
|
// Le champ de suivi des notifications des communes n'est pas affichable dans tous les cas |
1227 |
|
if ($maj == 3 && $this->can_display_notification_commune() === true) { |
1228 |
|
$form->setType('suivi_notification_commune', 'jsontotab'); |
1229 |
|
} |
1230 |
|
|
1231 |
|
// MODE AJOUTER |
1232 |
|
if ($this->getParameter('maj') == 0) { |
1233 |
|
$form->setType('commentaire', 'textareahidden'); |
1234 |
|
// Si l'option est active passage du champ date en lecture seule |
1235 |
|
if ($this->f->is_option_date_evenement_instruction_lecture_seule($collectivite_di) === true) { |
1236 |
|
$form->setType("date_evenement", "hiddenstaticdate"); |
1237 |
|
} else { |
1238 |
|
$form->setType("date_evenement", "date"); |
1239 |
|
} |
1240 |
|
if ($this->is_in_context_of_foreign_key("evenement", $this->getParameter("retourformulaire"))) { |
1241 |
|
$form->setType("evenement", "selecthiddenstatic"); |
1242 |
|
} else { |
1243 |
|
$form->setType("evenement", "select"); |
1244 |
|
} |
1245 |
|
if ($this->is_in_context_of_foreign_key("signataire_arrete", $this->getParameter("retourformulaire"))) { |
1246 |
|
$form->setType("signataire_arrete", "selecthiddenstatic"); |
1247 |
|
} else { |
1248 |
|
$form->setType("signataire_arrete", "select"); |
1249 |
|
} |
1250 |
|
if ($this->is_option_redaction_libre_enabled() === true) { |
1251 |
|
$form->setType("flag_edition_integrale", "select"); |
1252 |
|
} |
1253 |
|
} |
1254 |
|
|
1255 |
|
// MODE MODIFIER |
1256 |
|
if ($this->getParameter('maj') == 1) { |
1257 |
|
// Si l'option est active passage du champ date en lecture seule |
1258 |
|
if ($this->f->is_option_date_evenement_instruction_lecture_seule($collectivite_di) === true) { |
1259 |
|
$form->setType("date_evenement", "hiddenstaticdate"); |
1260 |
|
} else { |
1261 |
|
$form->setType("date_evenement", "date"); |
1262 |
|
} |
1263 |
|
$form->setType("evenement", "selecthiddenstatic"); |
1264 |
|
if ($this->has_an_edition() === true) { |
1265 |
|
$form->setType('lettretype', 'hiddenstatic'); |
1266 |
|
if ($this->is_in_context_of_foreign_key("signataire_arrete", $this->getParameter("retourformulaire"))) { |
1267 |
|
$form->setType("signataire_arrete", "selecthiddenstatic"); |
1268 |
|
} else { |
1269 |
|
$form->setType("signataire_arrete", "select"); |
1270 |
|
} |
1271 |
|
if ($this->getVal("flag_edition_integrale") == "t") { |
1272 |
|
$form->setType("titre_om_htmletat", "htmlEtat"); |
1273 |
|
$form->setType("corps_om_htmletatex", "htmlEtatEx"); |
1274 |
|
} else { |
1275 |
|
$form->setType("complement_om_html", "html"); |
1276 |
|
$form->setType("complement2_om_html", "html"); |
1277 |
|
$form->setType("complement3_om_html", "html"); |
1278 |
|
$form->setType("complement4_om_html", "html"); |
1279 |
|
$form->setType('bible_auto', 'httpclick'); |
1280 |
|
$form->setType('bible', 'httpclick'); |
1281 |
|
$form->setType('bible2', 'httpclick'); |
1282 |
|
$form->setType('bible3', 'httpclick'); |
1283 |
|
$form->setType('bible4', 'httpclick'); |
1284 |
|
} |
1285 |
|
if ($this->f->is_option_preview_pdf_enabled($collectivite_di) === true) { |
1286 |
|
// |
1287 |
|
$form->setType('btn_refresh', 'httpclickbutton'); |
1288 |
|
$form->setType('btn_preview', 'httpclickbutton'); |
1289 |
|
$form->setType('btn_redaction', 'httpclickbutton'); |
1290 |
|
// /!\ le type du champs est utilisé dans un selecteur dans le jscript.js |
1291 |
|
// pour identifiant le champ de prévisualisation et régler sa taille à |
1292 |
|
// l'affichage du champ. En cas de modification, le selecteur doit également |
1293 |
|
// être mis à jour |
1294 |
|
$form->setType('live_preview', 'previsualiser_pdf'); |
1295 |
|
} |
1296 |
|
|
1297 |
// necessaire pour calcul de date en modification |
// necessaire pour calcul de date en modification |
1298 |
//$form->setType('delai', 'hiddenstatic'); |
//$form->setType('delai', 'hiddenstatic'); |
1299 |
// les administrateurs technique et fonctionnel peuvent |
// les administrateurs technique et fonctionnel peuvent |
1300 |
// modifier tous les champs de date |
// modifier tous les champs de date |
1301 |
// si l'instruction a déjà été finalisée au moins une fois |
// si l'instruction a déjà été finalisée au moins une fois |
1302 |
if (($this->f->isAccredited(array(get_class($this), get_class($this)."modification_dates"), "OR") |
if (($this->f->isAccredited(array($this->get_absolute_class_name(), $this->get_absolute_class_name()."modification_dates"), "OR") |
1303 |
|| $this->f->isAccredited(array('instruction', 'instruction_modification_dates'), "OR")) |
|| $this->f->isAccredited(array('instruction', 'instruction_modification_dates'), "OR")) |
1304 |
&& $this->getVal("date_finalisation_courrier") != '') { |
&& $this->getVal("date_finalisation_courrier") != '') { |
1305 |
|
// |
1306 |
$form->setType('date_envoi_signature', 'date'); |
$form->setType('date_envoi_signature', 'date'); |
1307 |
$form->setType('date_retour_signature', 'date'); |
$form->setType('date_retour_signature', 'date'); |
1308 |
|
if ($this->is_sent_for_signature() === true |
1309 |
|
&& $this->is_signed() === true) { |
1310 |
|
// |
1311 |
|
$form->setType("date_envoi_signature", "datereadonly"); |
1312 |
|
$form->setType("date_retour_signature", "datereadonly"); |
1313 |
|
} |
1314 |
$form->setType('date_envoi_rar', 'date'); |
$form->setType('date_envoi_rar', 'date'); |
1315 |
$form->setType('date_retour_rar', 'date'); |
$form->setType('date_retour_rar', 'date'); |
1316 |
$form->setType('date_envoi_controle_legalite', 'date'); |
$form->setType('date_envoi_controle_legalite', 'date'); |
1317 |
|
if ($this->is_sent_to_cl() === true) { |
1318 |
|
$form->setType("date_envoi_controle_legalite", "datedisabled"); |
1319 |
|
} |
1320 |
$form->setType('date_retour_controle_legalite', 'date'); |
$form->setType('date_retour_controle_legalite', 'date'); |
1321 |
$form->setType('date_finalisation_courrier', 'date'); |
$form->setType('date_finalisation_courrier', 'date'); |
|
// suivi des dates |
|
|
if ($maj == 125) { |
|
|
$form->setType('date_evenement', 'hiddenstaticdate'); |
|
|
$form->setType('complement_om_html', 'hiddenstatic'); |
|
|
$form->setType('complement2_om_html', 'hiddenstatic'); |
|
|
$form->setType('complement3_om_html', 'hiddenstatic'); |
|
|
$form->setType('complement4_om_html', 'hiddenstatic'); |
|
|
$form->setType('bible_auto', 'hidden'); |
|
|
$form->setType('bible', 'hidden'); |
|
|
$form->setType('bible2', 'hidden'); |
|
|
$form->setType('bible3', 'hidden'); |
|
|
$form->setType('bible4', 'hidden'); |
|
|
$form->setType('signataire_arrete','selecthiddenstatic'); |
|
|
$form->setType('om_final_instruction_utilisateur', 'hiddenstatic'); |
|
|
} |
|
1322 |
} |
} |
1323 |
} |
} |
|
} elseif($maj==2){ |
|
|
$form->setType('dossier', 'hidden'); |
|
|
$form->setType('bible_auto', 'hidden'); |
|
|
$form->setType('bible', 'hidden'); |
|
|
$form->setType('bible2', 'hidden'); |
|
|
$form->setType('bible3', 'hidden'); |
|
|
$form->setType('bible4', 'hidden'); |
|
|
}else { |
|
|
$form->setType('destinataire', 'hidden'); |
|
|
$form->setType('dossier', 'hidden'); |
|
|
$form->setType('bible_auto', 'hidden'); |
|
|
$form->setType('bible', 'hidden'); |
|
|
$form->setType('bible2', 'hidden'); |
|
|
$form->setType('bible3', 'hidden'); |
|
|
$form->setType('bible4', 'hidden'); |
|
|
} |
|
|
|
|
|
//Cache les champs pour la finalisation |
|
|
$form->setType('om_fichier_instruction', 'hidden'); |
|
|
$form->setType('om_final_instruction', 'hidden'); |
|
|
// Cache le document arrêté |
|
|
$form->setType('document_numerise', 'hidden'); |
|
|
|
|
|
//Masquer les champs date_envoi_controle_legalite et |
|
|
//date_retour_controle_legalite si ce n'est pas un arrêté et si ce n'est |
|
|
//pas un utilisateur ayant le droit spécifique |
|
|
if ( !is_numeric($this->getVal("avis_decision"))&& |
|
|
!$this->f->isAccredited(array("instruction", "instruction_modification_dates"), "OR")){ |
|
|
|
|
|
$form->setType("date_envoi_controle_legalite", "hiddendate"); |
|
|
$form->setType("date_retour_controle_legalite", "hiddendate"); |
|
1324 |
} |
} |
1325 |
|
|
1326 |
// Pour les actions finalize, unfinalize et notifier_commune |
// MODE CONSULTER + SUPPRIMER + SUIVI DES DATES 125 + NOTIFICATION MANUELLE |
1327 |
if($maj == 100 || $maj == 110 || $maj == 210) { |
if ($this->getParameter('maj') == 3 |
1328 |
// |
|| $this->getParameter('maj') == 2 |
1329 |
foreach ($this->champs as $value) { |
|| $this->getParameter('maj') == 125 |
1330 |
// Cache tous les champs |
|| $this->getParameter('maj') == 410) { |
1331 |
$form->setType($value, 'hidden'); |
// |
1332 |
|
$form->setType("date_evenement", "datestatic"); |
1333 |
|
$form->setType("evenement", "selecthiddenstatic"); |
1334 |
|
if ($this->has_an_edition() === true) { |
1335 |
|
$form->setType('lettretype', 'hiddenstatic'); |
1336 |
|
$form->setType("signataire_arrete", "selecthiddenstatic"); |
1337 |
|
if ($this->getVal("om_final_instruction") == 't') { |
1338 |
|
$form->setType('om_final_instruction_utilisateur', 'textareastatic'); |
1339 |
|
} else { |
1340 |
|
$form->setType('om_final_instruction_utilisateur', 'hidden'); |
1341 |
|
} |
1342 |
|
} |
1343 |
|
if ($this->evenement_has_a_commentaire($this->getVal('evenement')) === true ) { |
1344 |
|
$form->setType('commentaire', 'textareastatic'); |
1345 |
|
} |
1346 |
|
} |
1347 |
|
|
1348 |
|
// MODE CONSULTER + SUPPRIMER + NOTIFICATION MANUELLE |
1349 |
|
if ($this->getParameter('maj') == 3 |
1350 |
|
|| $this->getParameter('maj') == 2 |
1351 |
|
|| $this->getParameter('maj') == 410) { |
1352 |
|
// Si il n'y a pas de lettre type (edition) associé à l'événement |
1353 |
|
// les dates de suivi ne sont pas affichée |
1354 |
|
if ($this->has_an_edition() === true) { |
1355 |
|
$form->setType('date_envoi_signature', 'datestatic'); |
1356 |
|
$form->setType('date_retour_signature', 'datestatic'); |
1357 |
|
$form->setType('date_envoi_rar', 'datestatic'); |
1358 |
|
$form->setType('date_retour_rar', 'datestatic'); |
1359 |
|
$form->setType('date_envoi_controle_legalite', 'datestatic'); |
1360 |
|
$form->setType('date_retour_controle_legalite', 'datestatic'); |
1361 |
|
$form->setType('date_finalisation_courrier', 'datestatic'); |
1362 |
|
if ($this->getVal("flag_edition_integrale") == "t") { |
1363 |
|
$form->setType("titre_om_htmletat", "htmlstatic"); |
1364 |
|
$form->setType("corps_om_htmletatex", "htmlstatic"); |
1365 |
|
} else { |
1366 |
|
$form->setType("complement_om_html", "htmlstatic"); |
1367 |
|
$form->setType("complement2_om_html", "htmlstatic"); |
1368 |
|
$form->setType("complement3_om_html", "htmlstatic"); |
1369 |
|
$form->setType("complement4_om_html", "htmlstatic"); |
1370 |
|
} |
1371 |
|
} |
1372 |
|
} |
1373 |
|
|
1374 |
|
// MODE SUIVI DES DATES 125 |
1375 |
|
if ($this->getParameter('maj') == 125) { |
1376 |
|
$form->setType("date_evenement", "hiddenstaticdate"); |
1377 |
|
$form->setType('om_final_instruction_utilisateur', 'hiddenstatic'); |
1378 |
|
$form->setType('date_envoi_signature', 'date'); |
1379 |
|
$form->setType('date_retour_signature', 'date'); |
1380 |
|
if ($this->is_sent_for_signature() === true |
1381 |
|
|| $this->is_signed() === true) { |
1382 |
|
// |
1383 |
|
$form->setType("date_envoi_signature", "datereadonly"); |
1384 |
|
$form->setType("date_retour_signature", "datereadonly"); |
1385 |
|
} |
1386 |
|
$form->setType('date_envoi_rar', 'date'); |
1387 |
|
$form->setType('date_retour_rar', 'date'); |
1388 |
|
$form->setType('date_envoi_controle_legalite', 'date'); |
1389 |
|
if ($this->is_sent_to_cl() === true) { |
1390 |
|
$form->setType("date_envoi_controle_legalite", "datedisabled"); |
1391 |
} |
} |
1392 |
|
$form->setType('date_retour_controle_legalite', 'date'); |
1393 |
|
$form->setType('date_finalisation_courrier', 'date'); |
1394 |
} |
} |
1395 |
|
|
1396 |
|
if ($maj == 401) { |
1397 |
|
foreach ($this->champs as $champ) { |
1398 |
|
$form->setType($champ, 'hidden'); |
1399 |
|
} |
1400 |
|
$form->setType('preview_edition', 'previsualiser'); |
1401 |
|
} |
1402 |
|
|
1403 |
|
// Si l'instruction a été envoyé au contrôle de légalité et que la |
1404 |
|
// tâche envoi_cl lié n'a pas encore été traité il faut indiquer à |
1405 |
|
// l'utilisateur que l'envoi au cl est en cours de traitement. |
1406 |
|
if ($this->is_sent_to_cl() === true |
1407 |
|
&& empty($this->getVal('date_envoi_controle_legalite')) |
1408 |
|
&& $maj == 3) { |
1409 |
|
$form->setType("date_envoi_controle_legalite", "hiddenstatic"); |
1410 |
|
} |
1411 |
|
} |
1412 |
|
|
1413 |
|
function setOnchange(&$form,$maj){ |
1414 |
|
parent::setOnchange($form,$maj); |
1415 |
|
|
1416 |
|
// MODE AJOUTER |
1417 |
|
if ($this->getParameter('maj') == 0) { |
1418 |
|
$form->setOnchange( |
1419 |
|
"evenement", |
1420 |
|
"manage_instruction_evenement_lettretype(this.value, '".addslashes($this->getParameter('idxformulaire'))."'); |
1421 |
|
manage_instruction_evenement_commentaire(this.value, '".addslashes($this->getParameter('idxformulaire'))."');" |
1422 |
|
); |
1423 |
|
} |
1424 |
|
} |
1425 |
|
|
1426 |
|
function evenement_has_an_edition($evenement_id) { |
1427 |
|
$evenement = $this->get_inst_evenement($evenement_id); |
1428 |
|
$lettretype = $evenement->getVal('lettretype'); |
1429 |
|
if ($lettretype !== '' && $lettretype !== null) { |
1430 |
|
return true; |
1431 |
|
} |
1432 |
|
return false; |
1433 |
} |
} |
1434 |
|
|
1435 |
function setSelect(&$form, $maj,&$db,$debug) { |
function view_evenement_has_an_edition_json() { |
1436 |
|
$json_return = array( |
1437 |
|
"lettretype" => $this->evenement_has_an_edition($this->f->get_submitted_get_value('evenement_id')), |
1438 |
|
"option_redaction_libre_enabled" => $this->is_option_redaction_libre_enabled(), |
1439 |
|
); |
1440 |
|
echo json_encode($json_return); |
1441 |
|
} |
1442 |
|
|
1443 |
|
function evenement_has_a_commentaire($evenement_id) { |
1444 |
|
$evenement = $this->get_inst_evenement($evenement_id); |
1445 |
|
return $this->get_boolean_from_pgsql_value($evenement->getVal('commentaire')); |
1446 |
|
} |
1447 |
|
|
1448 |
|
function view_evenement_has_a_commentaire_json() { |
1449 |
|
$json_return = array( |
1450 |
|
"commentaire" => $this->evenement_has_a_commentaire($this->f->get_submitted_get_value('evenement_id')) |
1451 |
|
); |
1452 |
|
echo json_encode($json_return); |
1453 |
|
} |
1454 |
|
|
1455 |
|
|
1456 |
|
/** |
1457 |
|
* CONDITION - can_be_sended_to_cl |
1458 |
|
* |
1459 |
|
* Vérifie que le contrôle de légalité est disponible |
1460 |
|
* |
1461 |
|
* @return boolean |
1462 |
|
*/ |
1463 |
|
function can_be_sended_to_cl() { |
1464 |
|
// Si l'instruction a une édition |
1465 |
|
// et que l'événement est paramétré pour envoyer le contrôle de légalité |
1466 |
|
// par Plat'AU |
1467 |
|
// et que la date de retour signature est renseignée |
1468 |
|
// et que la date d'envoi au contrôle légalité n'est pas renseignée |
1469 |
|
// et qu'il n'existe pas de task envoi_CL en cours (!= done ou canceled) |
1470 |
|
if ($this->has_an_edition() === true) { |
1471 |
|
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
1472 |
|
$inst_evenement = $this->get_inst_evenement($this->getVal('evenement')); |
1473 |
|
if ($inst_evenement->getVal('envoi_cl_platau') === 't' |
1474 |
|
&& empty($this->getVal('date_retour_signature')) === false |
1475 |
|
&& empty($this->getVal('date_envoi_controle_legalite')) === true |
1476 |
|
&& $this->getVal('envoye_cl_platau') === 'f' |
1477 |
|
&& $this->f->is_type_dossier_platau($inst_di->getVal('dossier_autorisation')) === true |
1478 |
|
&& $inst_di->getVal('etat_transmission_platau') !== 'jamais_transmissible') { |
1479 |
|
// |
1480 |
|
return true; |
1481 |
|
} |
1482 |
|
} |
1483 |
|
// |
1484 |
|
return false; |
1485 |
|
} |
1486 |
|
|
1487 |
|
/** |
1488 |
|
* |
1489 |
|
* @return string |
1490 |
|
*/ |
1491 |
|
function get_var_sql_forminc__sql_signataire_arrete() { |
1492 |
|
return sprintf( |
1493 |
|
"SELECT |
1494 |
|
signataire_arrete.signataire_arrete, |
1495 |
|
CONCAT_WS( |
1496 |
|
' - ', |
1497 |
|
CONCAT_WS(' ', signataire_arrete.prenom, signataire_arrete.nom), |
1498 |
|
signataire_habilitation.libelle, |
1499 |
|
signataire_arrete.description |
1500 |
|
) |
1501 |
|
FROM |
1502 |
|
%1\$ssignataire_arrete |
1503 |
|
LEFT JOIN %1\$ssignataire_habilitation |
1504 |
|
ON signataire_arrete.signataire_habilitation = signataire_habilitation.signataire_habilitation |
1505 |
|
WHERE |
1506 |
|
((signataire_arrete.om_validite_debut IS NULL |
1507 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1508 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE)) |
1509 |
|
OR (signataire_arrete.om_validite_debut <= CURRENT_DATE |
1510 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1511 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE))) |
1512 |
|
ORDER BY |
1513 |
|
signataire_arrete.prenom, |
1514 |
|
signataire_arrete.nom", |
1515 |
|
DB_PREFIXE |
1516 |
|
); |
1517 |
|
} |
1518 |
|
|
1519 |
|
/** |
1520 |
|
* |
1521 |
|
* @return string |
1522 |
|
*/ |
1523 |
|
function get_var_sql_forminc__sql_signataire_arrete_by_id() { |
1524 |
|
return sprintf( |
1525 |
|
"SELECT |
1526 |
|
signataire_arrete.signataire_arrete, |
1527 |
|
CONCAT_WS( |
1528 |
|
' - ', |
1529 |
|
CONCAT_WS(' ', signataire_arrete.prenom, signataire_arrete.nom), |
1530 |
|
signataire_habilitation.libelle, |
1531 |
|
signataire_arrete.description |
1532 |
|
) |
1533 |
|
FROM |
1534 |
|
%1\$ssignataire_arrete |
1535 |
|
LEFT JOIN %1\$ssignataire_habilitation |
1536 |
|
ON signataire_arrete.signataire_habilitation = signataire_habilitation.signataire_habilitation |
1537 |
|
WHERE |
1538 |
|
signataire_arrete.signataire_arrete = <idx>", |
1539 |
|
DB_PREFIXE |
1540 |
|
); |
1541 |
|
} |
1542 |
|
|
1543 |
|
/** |
1544 |
|
* |
1545 |
|
* @return string |
1546 |
|
*/ |
1547 |
|
function get_var_sql_forminc__sql_signataire_arrete_by_di() { |
1548 |
|
return sprintf( |
1549 |
|
"SELECT |
1550 |
|
signataire_arrete.signataire_arrete, |
1551 |
|
CONCAT_WS( |
1552 |
|
' - ', |
1553 |
|
CONCAT_WS(' ', signataire_arrete.prenom, signataire_arrete.nom), |
1554 |
|
signataire_habilitation.libelle, |
1555 |
|
signataire_arrete.description |
1556 |
|
) |
1557 |
|
FROM |
1558 |
|
%1\$ssignataire_arrete |
1559 |
|
LEFT JOIN %1\$som_collectivite |
1560 |
|
ON signataire_arrete.om_collectivite = om_collectivite.om_collectivite |
1561 |
|
LEFT JOIN %1\$ssignataire_habilitation |
1562 |
|
ON signataire_arrete.signataire_habilitation = signataire_habilitation.signataire_habilitation |
1563 |
|
WHERE |
1564 |
|
((signataire_arrete.om_validite_debut IS NULL |
1565 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1566 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE)) |
1567 |
|
OR (signataire_arrete.om_validite_debut <= CURRENT_DATE |
1568 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1569 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE))) |
1570 |
|
AND (om_collectivite.niveau = '2' |
1571 |
|
OR signataire_arrete.om_collectivite = <collectivite_di>) |
1572 |
|
ORDER BY |
1573 |
|
signataire_arrete.prenom, signataire_arrete.nom", |
1574 |
|
DB_PREFIXE |
1575 |
|
); |
1576 |
|
} |
1577 |
|
|
1578 |
|
/** |
1579 |
|
* |
1580 |
|
* @return string |
1581 |
|
*/ |
1582 |
|
function get_var_sql_forminc__sql_signataire_arrete_defaut() { |
1583 |
|
return sprintf( |
1584 |
|
"SELECT |
1585 |
|
signataire_arrete.signataire_arrete, |
1586 |
|
CONCAT_WS( |
1587 |
|
' - ', |
1588 |
|
CONCAT_WS(' ', signataire_arrete.prenom, signataire_arrete.nom), |
1589 |
|
signataire_habilitation.libelle, |
1590 |
|
signataire_arrete.description |
1591 |
|
) |
1592 |
|
FROM |
1593 |
|
%1\$ssignataire_arrete |
1594 |
|
LEFT JOIN %1\$ssignataire_habilitation |
1595 |
|
ON signataire_arrete.signataire_habilitation = signataire_habilitation.signataire_habilitation |
1596 |
|
WHERE |
1597 |
|
((signataire_arrete.om_validite_debut IS NULL |
1598 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1599 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE)) |
1600 |
|
OR (signataire_arrete.om_validite_debut <= CURRENT_DATE |
1601 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1602 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE))) |
1603 |
|
AND signataire_arrete.defaut IS TRUE |
1604 |
|
ORDER BY |
1605 |
|
signataire_arrete.prenom, signataire_arrete.nom", |
1606 |
|
DB_PREFIXE |
1607 |
|
); |
1608 |
|
} |
1609 |
|
|
1610 |
|
/** |
1611 |
|
* |
1612 |
|
* @return string |
1613 |
|
*/ |
1614 |
|
function get_var_sql_forminc__sql_signataire_arrete_defaut_by_di() { |
1615 |
|
return sprintf( |
1616 |
|
"SELECT |
1617 |
|
signataire_arrete.signataire_arrete, |
1618 |
|
CONCAT_WS( |
1619 |
|
' - ', |
1620 |
|
CONCAT_WS(' ', signataire_arrete.prenom, signataire_arrete.nom), |
1621 |
|
signataire_habilitation.libelle, |
1622 |
|
signataire_arrete.description |
1623 |
|
) |
1624 |
|
FROM |
1625 |
|
%1\$ssignataire_arrete |
1626 |
|
LEFT JOIN %1\$ssignataire_habilitation |
1627 |
|
ON signataire_arrete.signataire_habilitation = signataire_habilitation.signataire_habilitation |
1628 |
|
LEFT JOIN %1\$som_collectivite |
1629 |
|
ON signataire_arrete.om_collectivite = om_collectivite.om_collectivite |
1630 |
|
WHERE |
1631 |
|
((signataire_arrete.om_validite_debut IS NULL |
1632 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1633 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE)) |
1634 |
|
OR (signataire_arrete.om_validite_debut <= CURRENT_DATE |
1635 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1636 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE))) |
1637 |
|
AND signataire_arrete.defaut IS TRUE |
1638 |
|
AND (om_collectivite.niveau = '2' |
1639 |
|
OR signataire_arrete.om_collectivite = <collectivite_di>) |
1640 |
|
ORDER BY |
1641 |
|
signataire_arrete.prenom, |
1642 |
|
signataire_arrete.nom", |
1643 |
|
DB_PREFIXE |
1644 |
|
); |
1645 |
|
} |
1646 |
|
|
1647 |
|
/** |
1648 |
|
* SETTER_FORM - setSelect. |
1649 |
|
* |
1650 |
|
* @return void |
1651 |
|
*/ |
1652 |
|
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
1653 |
|
//parent::setSelect($form, $maj); |
1654 |
/** |
/** |
1655 |
* On ne surcharge pas la méthode parent car une requête sur la table |
* On ne surcharge pas la méthode parent car une requête sur la table |
1656 |
* dossier est mauvaise pour les performances, car la requête qui |
* dossier est mauvaise pour les performances, car la requête qui |
1658 |
* champs action, avis_decision et etat ne sont pas utilisés comme des |
* champs action, avis_decision et etat ne sont pas utilisés comme des |
1659 |
* select |
* select |
1660 |
*/ |
*/ |
|
if(file_exists ("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc.php")) |
|
|
include ("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc.php"); |
|
|
elseif(file_exists ("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc")) |
|
|
include ("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc"); |
|
|
|
|
1661 |
//// action |
//// action |
1662 |
//$this->init_select($form, $db, $maj, $debug, "action", |
//$this->init_select($form, $this->f->db, $maj, null, "action", |
1663 |
// $sql_action, $sql_action_by_id, false); |
// $sql_action, $sql_action_by_id, false); |
1664 |
|
|
1665 |
//// avis_decision |
//// avis_decision |
1666 |
//$this->init_select($form, $db, $maj, $debug, "avis_decision", |
//$this->init_select($form, $this->f->db, $maj, null, "avis_decision", |
1667 |
// $sql_avis_decision, $sql_avis_decision_by_id, false); |
// $sql_avis_decision, $sql_avis_decision_by_id, false); |
1668 |
|
|
1669 |
//// dossier |
//// dossier |
1670 |
//$this->init_select($form, $db, $maj, $debug, "dossier", |
//$this->init_select($form, $this->f->db, $maj, null, "dossier", |
1671 |
// $sql_dossier, $sql_dossier_by_id, false); |
// $sql_dossier, $sql_dossier_by_id, false); |
1672 |
|
|
1673 |
//// etat |
//// etat |
1674 |
//$this->init_select($form, $db, $maj, $debug, "etat", |
//$this->init_select($form, $this->f->db, $maj, null, "etat", |
1675 |
// $sql_etat, $sql_etat_by_id, false); |
// $sql_etat, $sql_etat_by_id, false); |
1676 |
|
|
1677 |
//// evenement |
//// evenement |
1678 |
//$this->init_select($form, $db, $maj, $debug, "evenement", |
//$this->init_select($form, $this->f->db, $maj, null, "evenement", |
1679 |
// $sql_evenement, $sql_evenement_by_id, false); |
// $sql_evenement, $sql_evenement_by_id, false); |
1680 |
|
|
1681 |
// signataire_arrete |
// signataire_arrete |
1682 |
// si contexte DI |
// si contexte DI |
1683 |
if ($this->getParameter("retourformulaire") == "dossier" |
if ($this->getParameter("retourformulaire") == "dossier" |
1684 |
|| $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") { |
|
1685 |
// 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 |
1686 |
require_once "../obj/dossier_instruction.class.php"; |
$di = $this->f->get_inst__om_dbform(array( |
1687 |
$di = new dossier_instruction($this->getParameter('idxformulaire'), $db, $debug); |
"obj" => "dossier_instruction", |
1688 |
$sql_signataire_arrete_by_di = str_replace('<collectivite_di>', $di->getVal("om_collectivite"), $sql_signataire_arrete_by_di); |
"idx" => $this->getParameter('idxformulaire'), |
1689 |
$this->init_select($form, $db, $maj, $debug, "signataire_arrete", |
)); |
1690 |
$sql_signataire_arrete_by_di, $sql_signataire_arrete_by_id, true); |
$sql_signataire_arrete_by_di = str_replace( |
1691 |
|
'<collectivite_di>', |
1692 |
|
$di->getVal("om_collectivite"), |
1693 |
|
$this->get_var_sql_forminc__sql("signataire_arrete_by_di") |
1694 |
|
); |
1695 |
|
$this->init_select( |
1696 |
|
$form, |
1697 |
|
$this->f->db, |
1698 |
|
$maj, |
1699 |
|
null, |
1700 |
|
"signataire_arrete", |
1701 |
|
$sql_signataire_arrete_by_di, |
1702 |
|
$this->get_var_sql_forminc__sql("signataire_arrete_by_id"), |
1703 |
|
true |
1704 |
|
); |
1705 |
} else { |
} else { |
1706 |
$this->init_select($form, $db, $maj, $debug, "signataire_arrete", |
$this->init_select( |
1707 |
$sql_signataire_arrete, $sql_signataire_arrete_by_id, true); |
$form, |
1708 |
|
$this->f->db, |
1709 |
|
$maj, |
1710 |
|
null, |
1711 |
|
"signataire_arrete", |
1712 |
|
$this->get_var_sql_forminc__sql("signataire_arrete"), |
1713 |
|
$this->get_var_sql_forminc__sql("signataire_arrete_by_id"), |
1714 |
|
true |
1715 |
|
); |
1716 |
} |
} |
1717 |
|
|
1718 |
/** |
/** |
1737 |
INNER JOIN ".DB_PREFIXE."transition |
INNER JOIN ".DB_PREFIXE."transition |
1738 |
ON evenement.evenement = transition.evenement |
ON evenement.evenement = transition.evenement |
1739 |
AND dossier.etat=transition.etat |
AND dossier.etat=transition.etat |
1740 |
WHERE dossier.dossier='".$this->idxformulaire."' "; |
WHERE dossier.dossier='".$this->getParameter("idxformulaire")."' "; |
1741 |
|
|
1742 |
// Si changement de décision par instructeur commune |
// Si changement de décision par instructeur commune |
1743 |
if($this->f->isUserInstructeur() === true |
if($this->f->isUserInstructeur() === true |
1744 |
&& $this->getDivisionFromDossier($this->idxformulaire) != $_SESSION["division"] |
&& $this->getDivisionFromDossier($this->getParameter("idxformulaire")) != $_SESSION["division"] |
1745 |
&& $this->isInstrCanChangeDecision($this->idxformulaire) === true) { |
&& $this->isInstrCanChangeDecision($this->getParameter("idxformulaire")) === true) { |
1746 |
$sql .= "AND evenement.type IN ('arrete', 'changement_decision') "; |
$sql .= "AND evenement.type IN ('arrete', 'changement_decision') "; |
1747 |
} |
} |
1748 |
$sql .= "ORDER BY evenement.libelle, evenement.action"; |
$sql .= "ORDER BY evenement.libelle, evenement.action"; |
1749 |
$res = $db->query($sql); |
$res = $this->f->db->query($sql); |
1750 |
$this->addToLog("setSelect(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
1751 |
if (database::isError($res)) { |
$this->f->isDatabaseError($res); |
|
die($res->getMessage()); |
|
|
} |
|
1752 |
// Remplissage du tableau du select |
// Remplissage du tableau du select |
1753 |
$contenu = array( |
$contenu = array( |
1754 |
0 => array("",), |
0 => array("",), |
1759 |
$contenu[1][] = $row[1]; |
$contenu[1][] = $row[1]; |
1760 |
} |
} |
1761 |
$form->setSelect("evenement", $contenu); |
$form->setSelect("evenement", $contenu); |
1762 |
|
|
1763 |
} else { |
} else { |
1764 |
$sql = "SELECT |
// Instanciation de l'événement pour récupérer son libellé |
1765 |
evenement.libelle as lib |
$evenement = $this->f->get_inst__om_dbform(array( |
1766 |
FROM ".DB_PREFIXE."evenement |
"obj" => "evenement", |
1767 |
WHERE evenement.evenement=".$this->getVal("evenement").""; |
"idx" => $this->getVal("evenement"), |
1768 |
$res = $db->getone($sql); |
)); |
1769 |
$this->addToLog("setSelect(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
|
|
if (database::isError($res)) { |
|
|
die($res->getMessage()); |
|
|
} |
|
|
// |
|
1770 |
$contenu = array( |
$contenu = array( |
1771 |
0 => array($this->getVal("evenement"),), |
0 => array($this->getVal("evenement"),), |
1772 |
1 => array($res,) |
1 => array($evenement->getVal('libelle'),) |
1773 |
); |
); |
1774 |
$form->setSelect("evenement", $contenu); |
$form->setSelect("evenement", $contenu); |
1775 |
} |
} |
1792 |
// lien bible4 |
// lien bible4 |
1793 |
$contenu = array(_("bible")); |
$contenu = array(_("bible")); |
1794 |
$form->setSelect("bible4",$contenu); |
$form->setSelect("bible4",$contenu); |
1795 |
|
|
1796 |
|
if ($maj == 1) { |
1797 |
|
$base64 = $this->init_pdf_temp(); |
1798 |
|
$form->setSelect('live_preview', array('base64'=>$base64)); |
1799 |
|
$form->setSelect("btn_refresh", array(_('Prévisualiser'))); |
1800 |
|
$form->setSelect("btn_preview", array(_('Prévisualiser >>'))); |
1801 |
|
$form->setSelect("btn_redaction", array(_('<< Rédiger'))); |
1802 |
|
} |
1803 |
|
|
1804 |
|
// Selection du type de rédaction à l'ajout |
1805 |
|
$content = array( |
1806 |
|
0 => array('f', 't', ), |
1807 |
|
1 => array(_('Rédaction par compléments'), _('Rédaction libre'), ), |
1808 |
|
); |
1809 |
|
$form->setSelect('flag_edition_integrale', $content); |
1810 |
|
|
1811 |
|
$contenu = array(); |
1812 |
|
foreach(array('waiting', 'in_progress', 'canceled', 'expired', 'finished') as $value) { |
1813 |
|
$contenu[0][] = $value; |
1814 |
|
$contenu[1][] = $this->get_trad_for_statut($value); |
1815 |
|
} |
1816 |
|
$form->setSelect('statut_signature', $contenu); |
1817 |
|
|
1818 |
|
|
1819 |
|
if ($maj == 401) { |
1820 |
|
$file = $this->f->storage->get($this->getVal('om_fichier_instruction')); |
1821 |
|
$form->setSelect('preview_edition', array( |
1822 |
|
'base64' => base64_encode($file['file_content']), |
1823 |
|
'mimetype' => $file['metadata']['mimetype'], |
1824 |
|
'label' => 'instruction_'.$this->getVal($this->clePrimaire), |
1825 |
|
'href' => sprintf( |
1826 |
|
'../app/index.php?module=form&snippet=file&obj=instruction&champ=om_fichier_instruction&id=%1$s', |
1827 |
|
$this->getVal($this->clePrimaire) |
1828 |
|
) |
1829 |
|
)); |
1830 |
|
} |
1831 |
} |
} |
1832 |
|
|
1833 |
function cleSecondaire($id, &$db, $val, $DEBUG) { |
function cleSecondaire($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
1834 |
// |
// |
1835 |
parent::cleSecondaire($id, $db, $val, $DEBUG); |
// Vérifie uniquementla cle secondaire : demande |
1836 |
|
$this->rechercheTable($this->f->db, "demande", "instruction_recepisse", $id); |
1837 |
|
|
1838 |
$id = $this->getVal($this->clePrimaire); |
$id = $this->getVal($this->clePrimaire); |
1839 |
|
|
|
|
|
1840 |
//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é |
1841 |
//à la création d'un dossier d'instruction |
//à la création d'un dossier d'instruction |
1842 |
$sql = "SELECT demande_type.dossier_instruction_type |
$qres = $this->f->get_one_result_from_db_query( |
1843 |
FROM ".DB_PREFIXE."demande_type |
sprintf( |
1844 |
LEFT JOIN ".DB_PREFIXE."demande |
'SELECT |
1845 |
ON demande.demande_type = demande_type.demande_type |
demande_type.dossier_instruction_type |
1846 |
WHERE demande.instruction_recepisse = ".$id; |
FROM |
1847 |
$res = $this->db->getOne($sql); |
%1$sdemande_type |
1848 |
$this->addToLog("cleSecondaire(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
LEFT JOIN %1$sdemande |
1849 |
if (database::isError($res)) { |
ON demande.demande_type = demande_type.demande_type |
1850 |
die($res->getMessage()); |
WHERE |
1851 |
} |
demande.instruction_recepisse = \'%2$d\'', |
1852 |
|
DB_PREFIXE, |
1853 |
|
intval($id) |
1854 |
|
), |
1855 |
|
array( |
1856 |
|
"origin" => __METHOD__, |
1857 |
|
) |
1858 |
|
); |
1859 |
|
|
1860 |
// 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 |
1861 |
//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 |
1862 |
//supprimé |
//supprimé |
1863 |
if ( $this->correct !== false || $res == null || $res == ""){ |
if ( $this->correct !== false || $qres['result'] == null || $qres['result'] == ""){ |
|
|
|
1864 |
// 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é |
1865 |
// à une demande |
// à une demande |
1866 |
$sql = "SELECT demande |
$qres = $this->f->get_one_result_from_db_query( |
1867 |
FROM ".DB_PREFIXE."demande |
sprintf( |
1868 |
WHERE instruction_recepisse = ".$id; |
'SELECT |
1869 |
$res = $this->db->getOne($sql); |
demande |
1870 |
$this->addToLog("cleSecondaire(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
FROM |
1871 |
if (database::isError($res)) { |
%1$sdemande |
1872 |
die($res->getMessage()); |
WHERE |
1873 |
} |
instruction_recepisse = \'%2$d\'', |
1874 |
|
DB_PREFIXE, |
1875 |
|
intval($id) |
1876 |
|
), |
1877 |
|
array( |
1878 |
|
"origin" => __METHOD__, |
1879 |
|
) |
1880 |
|
); |
1881 |
|
|
1882 |
//Si c'est un événement d'instruction lié à une demande |
//Si c'est un événement d'instruction lié à une demande |
1883 |
if ($res != null || $res != ""){ |
if ($qres['result'] != null || $qres['result'] != ""){ |
1884 |
|
$demande = $this->f->get_inst__om_dbform(array( |
1885 |
require_once "../obj/demande.class.php"; |
"obj" => "demande", |
1886 |
$demande = new demande($res, $this->db, DEBUG); |
"idx" => $qres['result'], |
1887 |
|
)); |
1888 |
|
|
1889 |
//On met à jour la demande en supprimant la liaison vers |
//On met à jour la demande en supprimant la liaison vers |
1890 |
//l'événement d'instruction |
//l'événement d'instruction |
1891 |
$demande->setParameter("maj", 1); |
$demande->setParameter("maj", 1); |
1892 |
$valF = array(); |
$valF = array(); |
1895 |
} |
} |
1896 |
$valF['date_demande']=$demande->dateDBToForm($valF['date_demande']); |
$valF['date_demande']=$demande->dateDBToForm($valF['date_demande']); |
1897 |
$valF['instruction_recepisse']=NULL; |
$valF['instruction_recepisse']=NULL; |
1898 |
$ret = $demande->modifier($valF, $this->db, DEBUG); |
$ret = $demande->modifier($valF); |
1899 |
} |
} |
1900 |
|
|
1901 |
/** |
/** |
1902 |
* Vérification que l'élément supprimé est le dernier pour pouvoir |
* Vérification que l'élément supprimé est le dernier pour pouvoir |
1903 |
* remodifier les données de manière itérative. |
* remodifier les données de manière itérative. |
1904 |
*/ |
*/ |
1905 |
// Initialisation |
$qres = $this->f->get_one_result_from_db_query( |
1906 |
$dernierevenement = ""; |
sprintf( |
1907 |
// Récupération du dernier élément de la table d'instruction qui |
'SELECT |
1908 |
// concerne le dossier en cours |
max(instruction) |
1909 |
$sql = "SELECT max(instruction) |
FROM |
1910 |
FROM ".DB_PREFIXE."instruction |
%1$sinstruction |
1911 |
WHERE dossier ='".$this->idxformulaire."'"; |
WHERE |
1912 |
$dernierevenement = $db->getOne($sql); |
dossier = \'%2$s\'', |
1913 |
$this->addToLog("setSelect(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
DB_PREFIXE, |
1914 |
if (database::isError($dernierevenement)) { |
$this->f->db->escapeSimple($this->getParameter("idxformulaire")) |
1915 |
die($dernierevenement->getMessage()); |
), |
1916 |
} |
array( |
1917 |
|
"origin" => __METHOD__, |
1918 |
|
) |
1919 |
|
); |
1920 |
|
|
1921 |
// Si on se trouve effectivement sur le dernier evenement d'instruction |
// Si on se trouve effectivement sur le dernier evenement d'instruction |
1922 |
if ($dernierevenement == $id) { |
// alors on valide la suppression sinon on l'annule |
1923 |
|
$this->correct = false; |
1924 |
|
$message = __("Seul le dernier evenement d'instruction peut etre supprime."); |
1925 |
|
if ($qres['result'] == $id) { |
1926 |
// Alors on valide la suppression |
// Alors on valide la suppression |
1927 |
$this->correct = true; |
$this->correct = true; |
1928 |
$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.")); |
|
1929 |
} |
} |
1930 |
|
$this->addToMessage($message); |
1931 |
} |
} |
1932 |
} |
} |
1933 |
|
|
1939 |
|
|
1940 |
//Si le retourformulaire est "dossier_instruction" |
//Si le retourformulaire est "dossier_instruction" |
1941 |
if ($this->getParameter("retourformulaire") == "dossier" |
if ($this->getParameter("retourformulaire") == "dossier" |
1942 |
|| $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") { |
|
1943 |
|
|
1944 |
// 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 |
1945 |
if($this->valF[$champ] != "" AND !$this->f->user_is_admin) { |
if($this->valF[$champ] != "" AND !$this->f->user_is_admin) { |
1955 |
return true; |
return true; |
1956 |
} |
} |
1957 |
|
|
1958 |
/*Met des valeurs par défaut dans certains des sous-formulaire*/ |
/** |
1959 |
function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire){ |
* SETTER_FORM - setValsousformulaire (setVal). |
1960 |
|
* |
1961 |
|
* @return void |
1962 |
|
*/ |
1963 |
|
function setValsousformulaire(&$form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire, &$dnu1 = null, $dnu2 = null) { |
1964 |
|
// parent::setValsousformulaire($form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire); |
1965 |
|
// |
1966 |
|
$this->retourformulaire = $retourformulaire; |
1967 |
// |
// |
|
$this->retourformulaire=$retourformulaire; |
|
|
$this->idxformulaire=$idxformulaire; |
|
|
// Ajout |
|
1968 |
if ($maj == 0) { |
if ($maj == 0) { |
1969 |
$form->setVal("destinataire", $idxformulaire); |
$form->setVal("destinataire", $this->getParameter("idxformulaire")); |
1970 |
$form->setVal("dossier", $idxformulaire); |
$form->setVal("dossier", $this->getParameter("idxformulaire")); |
1971 |
|
} |
1972 |
|
|
1973 |
|
// Si l'instruction a été envoyé au contrôle de légalité et que la |
1974 |
|
// tâche envoi_cl lié n'a pas encore été traité il faut indiquer à |
1975 |
|
// l'utilisateur que l'envoi au cl est en cours de traitement. |
1976 |
|
if ($this->is_sent_to_cl() === true |
1977 |
|
&& empty($this->getVal('date_envoi_controle_legalite')) |
1978 |
|
&& $maj == 3) { |
1979 |
|
$form->setVal("date_envoi_controle_legalite", __("En cours de traitement.")); |
1980 |
} |
} |
1981 |
// |
// |
1982 |
$this->set_form_default_values($form, $maj, $validation); |
$this->set_form_default_values($form, $maj, $validation); |
1983 |
} |
} |
1984 |
|
|
1985 |
/** |
/** |
1986 |
* Permet de pré-remplir les valeurs des formulaires. |
* SETTER_FORM - set_form_default_values (setVal). |
1987 |
* |
* |
1988 |
* @param [object] $form formulaire |
* @return void |
|
* @param [integer] $maj mode |
|
|
* @param [integer] $validation validation |
|
1989 |
*/ |
*/ |
1990 |
function set_form_default_values(&$form, $maj, $validation) { |
function set_form_default_values(&$form, $maj, $validation) { |
1991 |
|
// |
|
// Ajout |
|
1992 |
if ($maj == 0) { |
if ($maj == 0) { |
|
if(file_exists ("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc.php")) |
|
|
include ("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc.php"); |
|
|
elseif(file_exists ("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc")) |
|
|
include ("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc"); |
|
1993 |
// si contexte DI |
// si contexte DI |
1994 |
if ($this->getParameter("retourformulaire") == "dossier" |
if ($this->getParameter("retourformulaire") == "dossier" |
1995 |
|| $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") { |
|
1996 |
// 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 |
1997 |
require_once "../obj/dossier_instruction.class.php"; |
$di = $this->f->get_inst__om_dbform(array( |
1998 |
$di = new dossier_instruction($this->getParameter('idxformulaire'), $db, DEBUG); |
"obj" => "dossier_instruction", |
1999 |
$sql = str_replace('<collectivite_di>', $di->getVal("om_collectivite"), $sql_signataire_arrete_defaut_by_di); |
"idx" => $this->getParameter("idxformulaire"), |
2000 |
|
)); |
2001 |
|
$sql = str_replace( |
2002 |
|
"<collectivite_di>", |
2003 |
|
$di->getVal("om_collectivite"), |
2004 |
|
$this->get_var_sql_forminc__sql("signataire_arrete_defaut_by_di") |
2005 |
|
); |
2006 |
} else { |
} else { |
2007 |
$sql = $sql_signataire_arrete_defaut; |
$sql = $this->get_var_sql_forminc__sql("signataire_arrete_defaut"); |
2008 |
} |
} |
|
// Date du jour |
|
|
$form->setVal("date_evenement", date('Y-m-d')); |
|
|
|
|
|
// Exécution de la requête |
|
2009 |
$res = $this->f->db->query($sql); |
$res = $this->f->db->query($sql); |
2010 |
$this->f->addToLog("setVal(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__."(): db->query(\"".$sql."\")", VERBOSE_MODE); |
2011 |
if ( database::isError($res)){ |
$this->f->isDatabaseError($res); |
|
die(); |
|
|
} |
|
|
|
|
2012 |
$row = $res->fetchrow(DB_FETCHMODE_ASSOC); |
$row = $res->fetchrow(DB_FETCHMODE_ASSOC); |
2013 |
|
if (isset($row["signataire_arrete"]) |
2014 |
if (isset($row['signataire_arrete']) && is_numeric($row['signataire_arrete'])){ |
&& is_numeric($row["signataire_arrete"])) { |
2015 |
$form->setVal("signataire_arrete",$row['signataire_arrete']); |
// |
2016 |
|
$form->setVal("signataire_arrete", $row["signataire_arrete"]); |
2017 |
} |
} |
2018 |
|
// Date du jour |
2019 |
|
$form->setVal("date_evenement", date("Y-m-d")); |
2020 |
} |
} |
2021 |
|
// |
|
// Ajout et modification |
|
2022 |
if ($maj == 0 || $maj == 1 || $maj == 125) { |
if ($maj == 0 || $maj == 1 || $maj == 125) { |
2023 |
$form->setVal("bible_auto","bible_auto()"); |
$form->setVal("bible_auto", "bible_auto()"); |
2024 |
$form->setVal("bible","bible(1)"); |
$form->setVal("bible", "bible(1)"); |
2025 |
$form->setVal("bible2","bible(2)"); |
$form->setVal("bible2", "bible(2)"); |
2026 |
$form->setVal("bible3","bible(3)"); |
$form->setVal("bible3", "bible(3)"); |
2027 |
$form->setVal("bible4","bible(4)"); |
$form->setVal("bible4", "bible(4)"); |
2028 |
|
} |
2029 |
|
// |
2030 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite(); |
2031 |
|
if ($maj == 1 |
2032 |
|
&& $this->f->is_option_preview_pdf_enabled($collectivite_di) === true |
2033 |
|
&& $this->has_an_edition() === true) { |
2034 |
|
// |
2035 |
|
$form->setVal("live_preview", $this->getVal($this->clePrimaire)); |
2036 |
|
$form->setVal("btn_refresh", "reload_pdf_viewer()"); |
2037 |
|
$form->setVal("btn_preview", "show_instr_preview()"); |
2038 |
|
$form->setVal("btn_redaction", "show_instr_redaction()"); |
2039 |
|
} |
2040 |
|
|
2041 |
|
// Gestion de l'affichage des suivis de notification des demandeurs, des services, des tiers et |
2042 |
|
// des communes |
2043 |
|
if ($maj == 3) { |
2044 |
|
if ($this->can_display_notification_demandeur()) { |
2045 |
|
$typeNotification = array( |
2046 |
|
'notification_recepisse', |
2047 |
|
'notification_instruction', |
2048 |
|
'notification_decision', |
2049 |
|
); |
2050 |
|
$form->setVal("suivi_notification", $this->get_json_suivi_notification($typeNotification, true)); |
2051 |
|
} |
2052 |
|
if ($this->can_display_notification_service()) { |
2053 |
|
$form->setVal("suivi_notification_service", $this->get_json_suivi_notification(array('notification_service_consulte'))); |
2054 |
|
} |
2055 |
|
if ($this->can_display_notification_tiers()) { |
2056 |
|
$form->setVal("suivi_notification_tiers", $this->get_json_suivi_notification(array('notification_tiers_consulte'))); |
2057 |
|
} |
2058 |
|
if ($this->can_display_notification_commune()) { |
2059 |
|
$form->setVal("suivi_notification_commune", $this->get_json_suivi_notification(array('notification_depot_demat', 'notification_commune'))); |
2060 |
|
} |
2061 |
} |
} |
2062 |
} |
} |
2063 |
|
|
|
|
|
2064 |
function setLayout(&$form, $maj){ |
function setLayout(&$form, $maj){ |
2065 |
if ( $maj < 2 OR $maj == 3 OR $maj == 125 ) { |
// En consultation, pour les dossiers qui n'ont pas été transmis par le portail |
2066 |
/*Champ sur lequel s'ouvre le bloc 1 */ |
// citoyen, si la notification des demandeurs est activée sur l'évenement |
2067 |
$form->setBloc('evenement','D',"","col_12"); |
// d'instruction et que le paramétrage du demandeur principal n'est pas |
2068 |
|
// correct alors un message a destination de l'instructeur est affiché. |
2069 |
|
if ($maj == 3) { |
2070 |
|
// Si le dossier n'a pas été déposé sur le portail citoyen (ou si |
2071 |
|
// la requête permettant de savoir le type de demande à échouée) et si |
2072 |
|
// la notification se fait par mail vérifie si il y a des erreurs de |
2073 |
|
// paramétrage et si c'est le cas on affiche un message d'information |
2074 |
|
$collectivite = $this->get_dossier_instruction_om_collectivite($this->getVal('dossier')); |
2075 |
|
$categorieNotif = $this->f->get_param_option_notification($collectivite); |
2076 |
|
if (($this->dossier_depose_sur_portail() == null || |
2077 |
|
! $this->dossier_depose_sur_portail()) && |
2078 |
|
$categorieNotif === 'mail' ) { |
2079 |
|
$erreurParam = $this->get_info_notification_fail(); |
2080 |
|
// Récupération de l'évenement d'instruction |
2081 |
|
$instEV = $this->get_inst_evenement(); |
2082 |
|
if (! empty($instEV->getVal('notification')) && $erreurParam != array()) { |
2083 |
|
$class = 'text-info ui-state-highlight ui-state-info'; |
2084 |
|
$message = __("Attention l'envoi de notification automatique n'est pas possible."); |
2085 |
|
$this->f->display_panel_information( |
2086 |
|
$class, |
2087 |
|
$message, |
2088 |
|
$erreurParam, |
2089 |
|
__('Veuillez corriger les informations suivantes.'), |
2090 |
|
'erreur_param_notif' |
2091 |
|
); |
2092 |
|
} |
2093 |
|
} |
2094 |
|
} |
2095 |
|
$form->setBloc('evenement','D',"","sousform-instruction-action-".$maj); |
2096 |
|
|
2097 |
$form->setFieldset('evenement','D',_('Evenement')); |
$form->setFieldset('evenement','D',_('Evenement')); |
2098 |
$form->setFieldset('om_final_instruction_utilisateur','F',''); |
$form->setFieldset('om_final_instruction_utilisateur','F',''); |
2099 |
|
|
2100 |
$form->setBloc('om_final_instruction_utilisateur','F'); |
$form->setBloc('om_final_instruction_utilisateur','F'); |
2101 |
|
|
2102 |
$form->setBloc('date_finalisation_courrier','D',"","col_12"); |
$form->setBloc('date_finalisation_courrier','D',"",""); |
2103 |
|
|
2104 |
$form->setFieldset('date_finalisation_courrier','D',_('Dates')); |
$form->setFieldset('date_finalisation_courrier','D',_('Dates')); |
2105 |
$form->setBloc('date_finalisation_courrier','D',"","col_6"); |
$form->setBloc('date_finalisation_courrier','D',"","col_6"); |
2106 |
$form->setBloc('date_envoi_controle_legalite','F'); |
$form->setBloc('date_envoi_controle_legalite','F'); |
2107 |
|
|
2108 |
$form->setBloc('signataire_arrete','D',"","col_6"); |
$form->setBloc('date_retour_signature','D',"","col_6"); |
2109 |
$form->setBloc('date_retour_controle_legalite','F'); |
$form->setBloc('date_retour_controle_legalite','F'); |
2110 |
$form->setFieldset('date_retour_controle_legalite','F',''); |
$form->setFieldset('date_retour_controle_legalite','F',''); |
2111 |
|
|
2112 |
$form->setBloc('date_retour_controle_legalite','F'); |
$form->setBloc('date_retour_controle_legalite','F'); |
2113 |
|
|
2114 |
$form->setBloc('complement_om_html','D',"","col_12"); |
$form->setBloc('statut_signature','D'); |
2115 |
|
$form->setFieldset('statut_signature','D','Suivi Parapheur'); |
2116 |
|
$form->setBloc('commentaire_signature','F'); |
2117 |
|
$form->setBloc('historique_signature','D'); |
2118 |
|
$form->setFieldset('historique_signature', 'DF', __("Historique"), "collapsible, startClosed"); |
2119 |
|
$form->setBloc('historique_signature','F'); |
2120 |
|
$form->setFieldset('historique_signature','F'); |
2121 |
|
|
2122 |
|
$form->setFieldset('suivi_notification', 'D', __("Suivi notification"), "collapsible"); |
2123 |
|
$form->setFieldset('suivi_notification','F'); |
2124 |
|
$form->setFieldset('suivi_notification_service', 'D', __("Suivi notification service"), "collapsible"); |
2125 |
|
$form->setFieldset('suivi_notification_service','F'); |
2126 |
|
$form->setFieldset('suivi_notification_tiers', 'D', __("Suivi notification tiers"), "collapsible"); |
2127 |
|
$form->setFieldset('suivi_notification_tiers','F'); |
2128 |
|
$form->setFieldset('suivi_notification_commune', 'D', __("Suivi notification commune"), "collapsible"); |
2129 |
|
$form->setFieldset('suivi_notification_commune','F'); |
2130 |
|
|
2131 |
|
if ($maj == 1) { |
2132 |
|
// Récupère la collectivité du dossier d'instruction |
2133 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite(); |
2134 |
|
|
2135 |
|
// |
2136 |
|
if ($this->f->is_option_preview_pdf_enabled($collectivite_di) === true |
2137 |
|
&& $this->has_an_edition() === true) { |
2138 |
|
// |
2139 |
|
$form->setBloc('complement_om_html','D',"","container_instr_edition"); |
2140 |
|
$form->setBloc('complement_om_html','D',"","hidelabel box_instr_edition redaction_instr_edition"); |
2141 |
|
$form->setBloc('complement_om_html','D',"","box_instr_edition_main"); |
2142 |
|
$form->setFieldset('complement_om_html','D',_('Complement')); |
2143 |
|
$form->setFieldset('bible','F',''); |
2144 |
|
$form->setFieldset('complement2_om_html','D',_('Complement 2')); |
2145 |
|
$form->setFieldset('bible2','F',''); |
2146 |
|
$form->setFieldset('complement3_om_html','D',_('Complement 3')); |
2147 |
|
$form->setFieldset('bible3','F',''); |
2148 |
|
$form->setFieldset('complement4_om_html','D',_('Complement 4')); |
2149 |
|
$form->setFieldset('bible4','F',''); |
2150 |
|
$form->setFieldset('titre_om_htmletat','DF',_('Titre'), 'startClosed'); |
2151 |
|
$form->setFieldset('corps_om_htmletatex','DF',_('Corps')); |
2152 |
|
$form->setBloc('corps_om_htmletatex','F'); |
2153 |
|
$form->setBloc('btn_preview','DF',"","box_instr_edition_btn"); |
2154 |
|
$form->setBloc('btn_preview','F'); |
2155 |
|
$form->setBloc('btn_redaction','D', '',"hidelabel box_instr_edition preview_instr_edition"); |
2156 |
|
$form->setBloc('btn_redaction','DF',"","box_instr_edition_btn"); |
2157 |
|
$form->setFieldset('btn_refresh','D',_('Prévisualisation'), "box_instr_edition_main"); |
2158 |
|
$form->setFieldset('live_preview','F'); |
2159 |
|
$form->setBloc('live_preview','F'); |
2160 |
|
$form->setBloc('live_preview','F'); |
2161 |
|
} else { |
2162 |
|
$form->setBloc('complement_om_html','D',"","hidelabel"); |
2163 |
|
$form->setFieldset('complement_om_html','D',_('Complement')); |
2164 |
|
$form->setFieldset('bible','F',''); |
2165 |
|
$form->setFieldset('complement2_om_html','D',_('Complement 2')); |
2166 |
|
$form->setFieldset('bible2','F',''); |
2167 |
|
$form->setFieldset('complement3_om_html','D',_('Complement 3')); |
2168 |
|
$form->setFieldset('bible3','F',''); |
2169 |
|
$form->setFieldset('complement4_om_html','D',_('Complement 4')); |
2170 |
|
$form->setFieldset('bible4','F',''); |
2171 |
|
$form->setFieldset('titre_om_htmletat','DF',_('Titre'), 'startClosed'); |
2172 |
|
$form->setFieldset('corps_om_htmletatex','DF',_('Corps')); |
2173 |
|
$form->setBloc('corps_om_htmletatex','F'); |
2174 |
|
} |
2175 |
|
} else { |
2176 |
|
$form->setBloc('complement_om_html','D',"","hidelabel"); |
2177 |
$form->setFieldset('complement_om_html','D',_('Complement')); |
$form->setFieldset('complement_om_html','D',_('Complement')); |
2178 |
$form->setFieldset('bible','F',''); |
$form->setFieldset('bible','F',''); |
|
$form->setBloc('bible','F'); |
|
|
|
|
|
$form->setBloc('complement2_om_html','D',"","col_12"); |
|
2179 |
$form->setFieldset('complement2_om_html','D',_('Complement 2')); |
$form->setFieldset('complement2_om_html','D',_('Complement 2')); |
2180 |
$form->setFieldset('bible2','F',''); |
$form->setFieldset('bible2','F',''); |
|
$form->setBloc('bible2','F'); |
|
|
|
|
|
$form->setBloc('complement3_om_html','D',"","col_12"); |
|
2181 |
$form->setFieldset('complement3_om_html','D',_('Complement 3')); |
$form->setFieldset('complement3_om_html','D',_('Complement 3')); |
2182 |
$form->setFieldset('bible3','F',''); |
$form->setFieldset('bible3','F',''); |
|
$form->setBloc('bible3','F'); |
|
|
|
|
|
$form->setBloc('complement4_om_html','D',"","col_12"); |
|
2183 |
$form->setFieldset('complement4_om_html','D',_('Complement 4')); |
$form->setFieldset('complement4_om_html','D',_('Complement 4')); |
2184 |
$form->setFieldset('bible4','F',''); |
$form->setFieldset('bible4','F',''); |
2185 |
$form->setBloc('bible4','F'); |
$form->setFieldset('titre_om_htmletat','DF',_('Titre'), 'startClosed'); |
2186 |
|
$form->setFieldset('corps_om_htmletatex','DF',_('Corps')); |
2187 |
|
$form->setBloc('corps_om_htmletatex','F'); |
2188 |
} |
} |
2189 |
} |
} |
2190 |
|
|
2197 |
$form->setLib('bible2', ""); |
$form->setLib('bible2', ""); |
2198 |
$form->setLib('bible3', ""); |
$form->setLib('bible3', ""); |
2199 |
$form->setLib('bible4', ""); |
$form->setLib('bible4', ""); |
2200 |
|
$form->setLib('btn_refresh', ""); |
2201 |
|
$form->setLib('btn_preview', ""); |
2202 |
|
$form->setLib('btn_redaction', ""); |
2203 |
|
$form->setLib('live_preview', ""); |
2204 |
$form->setLib('om_final_instruction_utilisateur', _("finalise par")); |
$form->setLib('om_final_instruction_utilisateur', _("finalise par")); |
2205 |
|
$form->setLib('date_envoi_rar', __("date_envoi_ar")); |
2206 |
|
$form->setLib('date_retour_rar', __("date_notification")); |
2207 |
|
$form->setLib('statut_signature', __("statut")); |
2208 |
|
$form->setLib('commentaire_signature', __("commentaire")); |
2209 |
|
$form->setLib('historique_signature', ''); |
2210 |
|
$form->setLib('suivi_notification', ''); |
2211 |
|
$form->setLib('suivi_notification_service', ''); |
2212 |
|
$form->setLib('suivi_notification_tiers', ''); |
2213 |
|
$form->setLib('suivi_notification_commune', ''); |
2214 |
|
$form->setLib('preview_edition', ""); |
2215 |
|
|
2216 |
|
// Ajout d'une infobulle d'aide lorsque le formulaire est en mode |
2217 |
|
// ajout et que l'option de rédaction libre est activée sur la |
2218 |
|
// collectivité du dossier |
2219 |
|
if ($maj === '0' && $this->is_option_redaction_libre_enabled() === true) { |
2220 |
|
// |
2221 |
|
$help_text_template = '%s <span class="info-16" title="%s"></span>'; |
2222 |
|
$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."); |
2223 |
|
$form->setLib('flag_edition_integrale', sprintf($help_text_template, _("Type de rédaction"), $help_text)); |
2224 |
|
} |
2225 |
|
else { |
2226 |
|
$form->setLib('flag_edition_integrale', _("Type de rédaction")); |
2227 |
|
} |
2228 |
|
|
2229 |
|
// Ajout d'une infobulle d'aide lorsque le formulaire est en mode |
2230 |
|
// modification et que l'option de prévisualisation de l'édition est |
2231 |
|
// activée sur la collectivité du dossier |
2232 |
|
if ($maj === '1' |
2233 |
|
&& $this->f->is_option_preview_pdf_enabled($this->get_dossier_instruction_om_collectivite()) === true) { |
2234 |
|
// |
2235 |
|
$help_text_template = '%s <span class="info-16" title="%s"></span>'; |
2236 |
|
$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."); |
2237 |
|
$form->setLib('date_evenement', sprintf($help_text_template, _('date_evenement'), $help_text)); |
2238 |
|
$form->setLib('signataire_arrete', sprintf($help_text_template, _('signataire_arrete'), $help_text)); |
2239 |
|
} |
2240 |
} |
} |
2241 |
|
|
2242 |
function triggerajouter($id, &$db, $val, $DEBUG) { |
/** |
2243 |
|
* TRIGGER - triggerajouter. |
2244 |
|
* |
2245 |
|
* @return boolean |
2246 |
|
*/ |
2247 |
|
function triggerajouter($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
2248 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
2249 |
/** |
/** |
2250 |
* 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 |
2251 |
* et dossier pour les stocker dans l'instruction : |
* et dossier pour les stocker dans l'instruction : |
2258 |
* - delai_notification |
* - delai_notification |
2259 |
* - lettretype |
* - lettretype |
2260 |
* - autorite_competente |
* - autorite_competente |
2261 |
|
* - pec_metier |
2262 |
* - complement_om_html |
* - complement_om_html |
2263 |
* - complement2_om_html |
* - complement2_om_html |
2264 |
* - complement3_om_html |
* - complement3_om_html |
2283 |
// 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é |
2284 |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
2285 |
WHERE evenement=".$this->valF['evenement']; |
WHERE evenement=".$this->valF['evenement']; |
2286 |
$res = $db->query($sql); |
$res = $this->f->db->query($sql); |
2287 |
$this->addToLog("triggerajouter(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
2288 |
if (database::isError($res)) { |
$this->f->isDatabaseError($res); |
|
die($res->getMessage()); |
|
|
} |
|
2289 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
2290 |
// Récupération de l'identifiant de l'action |
// Récupération de l'identifiant de l'action |
2291 |
// si une action est paramétrée dans l'événement |
// si une action est paramétrée dans l'événement |
2319 |
} |
} |
2320 |
// Récupération de la valeur de la lettre type |
// Récupération de la valeur de la lettre type |
2321 |
$this->valF['lettretype']=$row['lettretype']; |
$this->valF['lettretype']=$row['lettretype']; |
2322 |
|
// Récupération de la valeur de la prise en compte métier |
2323 |
|
// si la prise en compte métier est paramétrée dans l'événement |
2324 |
|
$this->valF['pec_metier'] = NULL; |
2325 |
|
if(isset($row['pec_metier']) === true and empty($row['pec_metier']) === false) { |
2326 |
|
$this->valF['pec_metier'] = $row['pec_metier']; |
2327 |
|
} |
2328 |
} |
} |
2329 |
// 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 |
2330 |
$sql = "SELECT * FROM ".DB_PREFIXE."dossier |
$sql = "SELECT * FROM ".DB_PREFIXE."dossier |
2331 |
WHERE dossier='".$this->valF['dossier']."'"; |
WHERE dossier='".$this->valF['dossier']."'"; |
2332 |
$res = $db->query($sql); |
$res = $this->f->db->query($sql); |
2333 |
$this->addToLog("triggerajouter(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
2334 |
if (database::isError($res)) { |
$this->f->isDatabaseError($res); |
|
die($res->getMessage()); |
|
|
} |
|
2335 |
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
2336 |
$this->updateArchiveData($row); |
$this->updateArchiveData($row); |
2337 |
|
|
2338 |
// Récupération de la duree de validite du dossier d'autorisation |
// Récupération de la duree de validite du dossier d'autorisation |
2339 |
$sql = "SELECT duree_validite_parametrage |
$qres = $this->f->get_one_result_from_db_query( |
2340 |
FROM ".DB_PREFIXE."dossier_autorisation_type_detaille |
sprintf( |
2341 |
LEFT JOIN ".DB_PREFIXE."dossier_autorisation |
'SELECT |
2342 |
ON dossier_autorisation.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
duree_validite_parametrage |
2343 |
LEFT JOIN ".DB_PREFIXE."dossier |
FROM |
2344 |
ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
%1$sdossier_autorisation_type_detaille |
2345 |
WHERE dossier.dossier='".$this->valF['dossier']."'"; |
LEFT JOIN %1$sdossier_autorisation |
2346 |
$duree_validite_parametrage = $db->getOne($sql); |
ON dossier_autorisation.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
2347 |
$this->addToLog("triggerajouter(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
LEFT JOIN %1$sdossier |
2348 |
database::isError($duree_validite_parametrage); |
ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
2349 |
if ($duree_validite_parametrage != '') { |
WHERE |
2350 |
$this->valF['duree_validite_parametrage']= $duree_validite_parametrage; |
dossier.dossier = \'%2$s\'', |
2351 |
|
DB_PREFIXE, |
2352 |
|
$this->f->db->escapeSimple($this->valF['dossier']) |
2353 |
|
), |
2354 |
|
array( |
2355 |
|
"origin" => __METHOD__, |
2356 |
|
) |
2357 |
|
); |
2358 |
|
|
2359 |
|
if ($qres['result'] != '') { |
2360 |
|
$this->valF['duree_validite_parametrage'] = $qres['result']; |
2361 |
} |
} |
2362 |
|
|
2363 |
// Identifiant du type de courrier |
// Identifiant du type de courrier |
2367 |
$this->valF["code_barres"] = $idTypeCourrier . $idCourrier; |
$this->valF["code_barres"] = $idTypeCourrier . $idCourrier; |
2368 |
} |
} |
2369 |
|
|
2370 |
// Test si une restriction est valide |
/** |
2371 |
// return boolean |
* Test si une restriction est valide. |
2372 |
|
* |
2373 |
|
* @return boolean |
2374 |
|
*/ |
2375 |
function restrictionIsValid($restriction){ |
function restrictionIsValid($restriction){ |
2376 |
if($this->restriction_valid != null) { |
if($this->restriction_valid != null) { |
2377 |
return $this->restriction_valid; |
return $this->restriction_valid; |
2553 |
if(empty($evenement) || !is_numeric($evenement)) { |
if(empty($evenement) || !is_numeric($evenement)) { |
2554 |
return ""; |
return ""; |
2555 |
} |
} |
2556 |
$sql = "SELECT retour |
|
2557 |
FROM ".DB_PREFIXE."evenement |
$evenement = $this->f->get_inst__om_dbform(array( |
2558 |
WHERE evenement = ".$evenement; |
"obj" => "evenement", |
2559 |
$retour = $this->db->getOne($sql); |
"idx" => $evenement, |
2560 |
$this->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE); |
)); |
2561 |
if (database::isError($retour)) { |
|
2562 |
die($retour->getMessage()); |
return $evenement->getVal('retour') == 't'; |
|
} |
|
|
if ($retour == 't') { |
|
|
return true; |
|
|
} else { |
|
|
return false; |
|
|
} |
|
2563 |
} |
} |
2564 |
|
|
2565 |
/** |
/** |
2574 |
return ""; |
return ""; |
2575 |
} |
} |
2576 |
//Récupère la restriction |
//Récupère la restriction |
2577 |
$sql= "SELECT |
$evenement = $this->f->get_inst__om_dbform(array( |
2578 |
restriction |
"obj" => "evenement", |
2579 |
FROM |
"idx" => $evenement, |
2580 |
".DB_PREFIXE."evenement |
)); |
2581 |
WHERE |
|
2582 |
evenement =".$evenement; |
return $evenement->getVal('restriction'); |
|
|
|
|
$restriction = $this->db->getOne($sql); |
|
|
$this->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE); |
|
|
if (database::isError($restriction)) { |
|
|
die($restriction->getMessage()); |
|
|
} |
|
|
return $restriction; |
|
2583 |
} |
} |
2584 |
|
|
2585 |
/** |
/** |
2660 |
"regle_date_retour_contradictoire", |
"regle_date_retour_contradictoire", |
2661 |
"regle_date_ait", |
"regle_date_ait", |
2662 |
"regle_date_transmission_parquet", |
"regle_date_transmission_parquet", |
2663 |
|
"regle_date_affichage", |
2664 |
); |
); |
2665 |
// Tableau des champs de type numérique |
// Tableau des champs de type numérique |
2666 |
$rule_type_numeric = array( |
$rule_type_numeric = array( |
2672 |
); |
); |
2673 |
// Tableau des champs de type booléen |
// Tableau des champs de type booléen |
2674 |
$rule_type_bool = array( |
$rule_type_bool = array( |
2675 |
|
"regle_a_qualifier", |
2676 |
|
"regle_incompletude", |
2677 |
|
"regle_incomplet_notifie", |
2678 |
|
"regle_evenement_suivant_tacite_incompletude", |
2679 |
); |
); |
2680 |
// Tableau des champs spécifiques |
// Tableau des champs spécifiques |
2681 |
$rule_type_specific = array( |
$rule_type_specific = array( |
2683 |
"regle_etat", |
"regle_etat", |
2684 |
"regle_accord_tacite", |
"regle_accord_tacite", |
2685 |
"regle_avis", |
"regle_avis", |
2686 |
|
"regle_pec_metier", |
2687 |
|
"regle_etat_pendant_incompletude", |
2688 |
); |
); |
2689 |
// Tableau des champs de données techniques |
// Tableau des champs de données techniques |
2690 |
$rule_type_technical_data = array( |
$rule_type_technical_data = array( |
2694 |
'regle_donnees_techniques4', |
'regle_donnees_techniques4', |
2695 |
'regle_donnees_techniques5', |
'regle_donnees_techniques5', |
2696 |
); |
); |
2697 |
|
// Tableau des champs simple |
2698 |
|
$rule_type_simple = array( |
2699 |
|
"regle_dossier_instruction_type", |
2700 |
|
); |
2701 |
|
|
2702 |
// Définit le type du champ |
// Définit le type du champ |
2703 |
if (in_array($rule_name, $rule_type_date) == true) { |
if (in_array($rule_name, $rule_type_date) == true) { |
2718 |
if (in_array($rule_name, $rule_type_technical_data) === true) { |
if (in_array($rule_name, $rule_type_technical_data) === true) { |
2719 |
$type = 'text'; |
$type = 'text'; |
2720 |
} |
} |
2721 |
|
if (in_array($rule_name, $rule_type_simple) === true) { |
2722 |
|
$type = 'simple'; |
2723 |
|
} |
2724 |
|
|
2725 |
// 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 |
2726 |
// Récupère directement la valeur de l'opérande |
// Récupère directement la valeur de l'opérande |
2727 |
if ($type === 'specific' || $type === 'bool') { |
if ($type === 'specific') { |
2728 |
// |
// |
2729 |
return $this->get_value_for_rule($rule); |
return $this->get_value_for_rule($rule); |
2730 |
} |
} |
2799 |
// Retourne la chaîne de caractère |
// Retourne la chaîne de caractère |
2800 |
return $res_text; |
return $res_text; |
2801 |
} |
} |
2802 |
|
if ($type === 'simple' || $type === 'bool') { |
2803 |
|
// Retourne la valeur du champs rule |
2804 |
|
return $rule; |
2805 |
|
} |
2806 |
} |
} |
2807 |
|
|
2808 |
|
|
2845 |
$donnees_techniques = $this->getDonneesTechniques(); |
$donnees_techniques = $this->getDonneesTechniques(); |
2846 |
} |
} |
2847 |
// |
// |
2848 |
require_once "../obj/donnees_techniques.class.php"; |
$this->inst_donnees_techniques = $this->f->get_inst__om_dbform(array( |
2849 |
$this->inst_donnees_techniques = new donnees_techniques($donnees_techniques); |
"obj" => "donnees_techniques", |
2850 |
|
"idx" => $donnees_techniques, |
2851 |
|
)); |
2852 |
} |
} |
2853 |
// |
// |
2854 |
return $this->inst_donnees_techniques; |
return $this->inst_donnees_techniques; |
2860 |
* @return string L'identifiant des données techniques liées du dossier |
* @return string L'identifiant des données techniques liées du dossier |
2861 |
*/ |
*/ |
2862 |
function getDonneesTechniques() { |
function getDonneesTechniques() { |
2863 |
|
|
2864 |
|
$qres = $this->f->get_one_result_from_db_query( |
2865 |
|
sprintf( |
2866 |
|
'SELECT |
2867 |
|
donnees_techniques |
2868 |
|
FROM |
2869 |
|
%1$sdonnees_techniques |
2870 |
|
WHERE |
2871 |
|
dossier_instruction = \'%2$s\'', |
2872 |
|
DB_PREFIXE, |
2873 |
|
$this->f->db->escapeSimple($this->valF["dossier"]) |
2874 |
|
), |
2875 |
|
array( |
2876 |
|
"origin" => __METHOD__, |
2877 |
|
) |
2878 |
|
); |
2879 |
|
|
2880 |
$donnees_techniques = ''; |
return $qres['result']; |
|
|
|
|
$sql = "SELECT donnees_techniques |
|
|
FROM ".DB_PREFIXE."donnees_techniques |
|
|
WHERE dossier_instruction ='".$this->valF["dossier"]."'"; |
|
|
$donnees_techniques = $this->db->getOne($sql); |
|
|
$this->f->addToLog("getStatut() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
|
|
if ( database::isError($donnees_techniques)){ |
|
|
die(); |
|
|
} |
|
|
|
|
|
return $donnees_techniques; |
|
2881 |
} |
} |
2882 |
|
|
|
|
|
2883 |
/** |
/** |
2884 |
* TRIGGER - triggerajouterapres. |
* TRIGGER - triggerajouterapres. |
2885 |
* |
* |
2890 |
* |
* |
2891 |
* @return boolean |
* @return boolean |
2892 |
*/ |
*/ |
2893 |
function triggerajouterapres($id, &$db, $val, $DEBUG) { |
function triggerajouterapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
2894 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
2895 |
|
|
2896 |
// 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 |
2897 |
$inst_di = $this->get_inst_dossier($this->valF['dossier']); |
$inst_di = $this->get_inst_dossier($this->valF['dossier']); |
|
|
|
2898 |
// Instance de la classe evenement |
// Instance de la classe evenement |
2899 |
$inst_evenement = $this->get_inst_evenement($this->valF['evenement']); |
$inst_evenement = $this->get_inst_evenement($this->valF['evenement']); |
2900 |
|
// Instance de l'état courant du dossier d'instruction |
2901 |
|
$inst_current_etat = $this->f->get_inst__om_dbform(array( |
2902 |
|
"obj" => "etat", |
2903 |
|
"idx" => $inst_di->get_id_etat(), |
2904 |
|
)); |
2905 |
|
|
2906 |
/** |
/** |
2907 |
* Mise à jour des valeurs du dossier en fonction des valeurs calculées |
* Mise à jour des valeurs du dossier en fonction des valeurs calculées |
2909 |
*/ |
*/ |
2910 |
// état de complétude actuel du dossier |
// état de complétude actuel du dossier |
2911 |
$incompletude = ($inst_di->getVal('incompletude') == 't' ? true : false); |
$incompletude = ($inst_di->getVal('incompletude') == 't' ? true : false); |
2912 |
|
// L'événement suivant tacite paramétré est destiné à la gestion de l'incomplétude |
2913 |
|
$ev_suiv_tacite_incompletude = false; |
2914 |
// Initialisation |
// Initialisation |
2915 |
$valF = ""; |
$valF = array(); |
2916 |
$valF_dt = ""; |
$valF_dt = array(); |
2917 |
// |
// |
|
if($incompletude === FALSE) { |
|
|
// Si l'événement d'instruction est de type incompletude |
|
|
if($inst_evenement->getVal('type') == "incompletude") { |
|
|
// On marque le dossier en incomplétude pour application des actions |
|
|
$incompletude = TRUE; |
|
|
// Set du flag incomplétude de la table dossier |
|
|
$valF['incompletude'] = TRUE; |
|
|
// Enregistrement de l'état dans la variable provisoire |
|
|
$valF['etat_pendant_incompletude'] = $this->valF['archive_etat']; |
|
|
} |
|
|
} else { |
|
|
// Si l'evenement d'instruction est de type retour ou contient une |
|
|
// decision, on sort d'incomplétude |
|
|
if($inst_evenement->getVal('type') == "retour" OR |
|
|
$inst_evenement->getVal('avis_decision') != NULL) { |
|
|
// On enlève la marque d'incomplétude pour application des actions |
|
|
$incompletude = FALSE; |
|
|
// On enlève le flag d'incomplétude sur l'enregistrement de la table dossier |
|
|
$valF['incompletude'] = FALSE; |
|
|
$valF['incomplet_notifie'] = FALSE; |
|
|
// Restauration de l'état depuis l'état provisoire |
|
|
$valF['etat'] = $this->valF['archive_etat_pendant_incompletude']; |
|
|
// On vide la variable provisoire ainsi que le délai de complétude |
|
|
// et la date limite de complétude |
|
|
$valF['etat_pendant_incompletude'] = NULL; |
|
|
$valF['delai_incompletude'] = NULL; |
|
|
$valF['date_limite_incompletude'] = NULL; |
|
|
$valF['evenement_suivant_tacite_incompletude'] = NULL; |
|
|
} |
|
|
} |
|
2918 |
// Récupération des paramètres de l'action |
// Récupération des paramètres de l'action |
2919 |
$sql = "SELECT * FROM ".DB_PREFIXE."action |
$sql = "SELECT * FROM ".DB_PREFIXE."action |
2920 |
WHERE action='".$this->valF['action']."'"; |
WHERE action='".$this->valF['action']."'"; |
2921 |
$res = $db->query($sql); |
$res = $this->f->db->query($sql); |
2922 |
$this->addToLog("triggerajouterapres(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
2923 |
if (database::isError($res)) { |
$this->f->isDatabaseError($res); |
|
die($res->getMessage()); |
|
|
} |
|
2924 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
2925 |
|
|
2926 |
// pour chacune des regles, on applique la regle |
// pour chacune des regles, on applique la regle |
2973 |
$valF['autorite_competente'] = $this->regle($row['regle_autorite_competente'], 'regle_autorite_competente'); |
$valF['autorite_competente'] = $this->regle($row['regle_autorite_competente'], 'regle_autorite_competente'); |
2974 |
} |
} |
2975 |
if ($row['regle_etat'] != '') { |
if ($row['regle_etat'] != '') { |
2976 |
// Si on est dans le cas général ou qu'on est en incomplétude et |
$valF['etat'] = $this->regle($row['regle_etat'], 'regle_etat'); |
|
// qu'on a un événement de type incomplétude alors : on stocke |
|
|
// l'état dans la variable courante |
|
|
if ($incompletude == FALSE OR $inst_evenement->getVal('type') == "incompletude") { |
|
|
$valF['etat'] = $this->regle($row['regle_etat'], 'regle_etat'); |
|
|
} else { |
|
|
$valF['etat_pendant_incompletude'] = $this->regle($row['regle_etat'], 'regle_etat'); |
|
|
} |
|
2977 |
} |
} |
2978 |
if ($row['regle_date_cloture_instruction'] !== '') { |
if ($row['regle_date_cloture_instruction'] !== '') { |
2979 |
$valF['date_cloture_instruction'] = $this->regle($row['regle_date_cloture_instruction'], 'regle_date_cloture_instruction'); |
$valF['date_cloture_instruction'] = $this->regle($row['regle_date_cloture_instruction'], 'regle_date_cloture_instruction'); |
3011 |
if ($row['regle_date_transmission_parquet'] !== '') { |
if ($row['regle_date_transmission_parquet'] !== '') { |
3012 |
$valF['date_transmission_parquet'] = $this->regle($row['regle_date_transmission_parquet'], 'regle_date_transmission_parquet'); |
$valF['date_transmission_parquet'] = $this->regle($row['regle_date_transmission_parquet'], 'regle_date_transmission_parquet'); |
3013 |
} |
} |
3014 |
|
if ($row['regle_dossier_instruction_type'] !== '') { |
3015 |
|
$valF['dossier_instruction_type'] = $this->regle($row['regle_dossier_instruction_type'], 'regle_dossier_instruction_type'); |
3016 |
|
} |
3017 |
|
// La date d'affichage est modifiée seulement si le champ n'est pas |
3018 |
|
// renseigné |
3019 |
|
if ($row['regle_date_affichage'] !== '' |
3020 |
|
&& ($inst_di->getVal('date_affichage') === '' |
3021 |
|
|| $inst_di->getVal('date_affichage') === null)) { |
3022 |
|
// |
3023 |
|
$valF['date_affichage'] = $this->regle($row['regle_date_affichage'], 'regle_date_affichage'); |
3024 |
|
} |
3025 |
|
// |
3026 |
|
if ($row['regle_pec_metier'] != '') { |
3027 |
|
$valF['pec_metier'] = $this->regle($row['regle_pec_metier'], 'regle_pec_metier'); |
3028 |
|
} |
3029 |
|
if ($row['regle_a_qualifier'] != '') { |
3030 |
|
$valF['a_qualifier'] = $this->regle($row['regle_a_qualifier'], 'regle_a_qualifier'); |
3031 |
|
} |
3032 |
|
// |
3033 |
|
if ($row['regle_incompletude'] != '') { |
3034 |
|
$valF['incompletude'] = $this->regle($row['regle_incompletude'], 'regle_incompletude'); |
3035 |
|
} |
3036 |
|
if ($row['regle_incomplet_notifie'] != '') { |
3037 |
|
$valF['incomplet_notifie'] = $this->regle($row['regle_incomplet_notifie'], 'regle_incomplet_notifie'); |
3038 |
|
} |
3039 |
|
if ($row['regle_etat_pendant_incompletude'] != '') { |
3040 |
|
$valF['etat_pendant_incompletude'] = $this->regle($row['regle_etat_pendant_incompletude'], 'regle_etat_pendant_incompletude'); |
3041 |
|
} |
3042 |
|
if ($row['regle_evenement_suivant_tacite_incompletude'] != '') { |
3043 |
|
$resti = $this->regle($row['regle_evenement_suivant_tacite_incompletude'], 'regle_evenement_suivant_tacite_incompletude'); |
3044 |
|
if (strtolower($resti) === 't' || strtolower($resti) === 'true') { |
3045 |
|
$ev_suiv_tacite_incompletude = true; |
3046 |
|
} |
3047 |
|
} |
3048 |
} |
} |
3049 |
|
|
3050 |
// Si l'événement a un événement suivant tacite |
// Si l'événement a un événement suivant tacite |
3051 |
if($inst_evenement->getVal('evenement_suivant_tacite') != '') { |
if($inst_evenement->getVal('evenement_suivant_tacite') != '') { |
3052 |
// Si le DI n'est pas en incomplétude, l'événement tacite est stocké |
// En fonction de l'action de l'événement, l'événement suivant tacite ne sera |
3053 |
// dans le champ evenement_suivant_tacite du dossier |
// pas associé de le même façon au dossier d'instruction |
3054 |
if ($incompletude == false OR $inst_evenement->getVal('type') != "incompletude") { |
if ($ev_suiv_tacite_incompletude === false) { |
|
// |
|
3055 |
$valF['evenement_suivant_tacite'] = $inst_evenement->getVal('evenement_suivant_tacite'); |
$valF['evenement_suivant_tacite'] = $inst_evenement->getVal('evenement_suivant_tacite'); |
3056 |
} else { |
} |
3057 |
// Sinon l'événement tacite est stocké dans le champ |
if ($ev_suiv_tacite_incompletude === true) { |
|
// evenement_suivant_tacite_incompletude du dossier |
|
3058 |
$valF['evenement_suivant_tacite_incompletude'] = $inst_evenement->getVal('evenement_suivant_tacite'); |
$valF['evenement_suivant_tacite_incompletude'] = $inst_evenement->getVal('evenement_suivant_tacite'); |
3059 |
} |
} |
3060 |
} |
} |
3061 |
// Si des valeurs de données techniques ont été calculées alors on met à jour l'enregistrement |
// Si des valeurs de données techniques ont été calculées alors on met à jour l'enregistrement |
3062 |
if ($valF_dt != "") { |
if (count($valF_dt) > 0) { |
3063 |
$dt_id = $this->getDonneesTechniques(); |
$dt_id = $this->getDonneesTechniques(); |
3064 |
// On met à jour le dossier |
// On met à jour le dossier |
3065 |
$cle = " donnees_techniques='".$dt_id."'"; |
$cle = " donnees_techniques='".$dt_id."'"; |
3066 |
$res1 = $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); |
3067 |
$this->addToLog("triggerajouterapres(): db->autoexecute(\"".DB_PREFIXE."donnees_techniques\", ".print_r($valF_dt, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
$this->addToLog( |
3068 |
if (database::isError($res1)) { |
__METHOD__."(): db->autoexecute(\"".DB_PREFIXE."donnees_techniques\", ".print_r($valF_dt, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", |
3069 |
die($res->getMessage()); |
VERBOSE_MODE |
3070 |
} |
); |
3071 |
|
$this->f->isDatabaseError($res1); |
3072 |
// Affichage d'informations à l'utilisateur |
// Affichage d'informations à l'utilisateur |
3073 |
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$this->f->db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
3074 |
} |
} |
3075 |
// 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 |
3076 |
if ($valF != "") { |
if (count($valF) > 0) { |
3077 |
// On met à jour le dossier |
// |
3078 |
$cle = " dossier='".$this->valF['dossier']."'"; |
$inst_dossier = $this->f->get_inst__om_dbform(array( |
3079 |
$res1 = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle); |
"obj" => "dossier", |
3080 |
$this->addToLog("triggerajouterapres(): db->autoexecute(\"".DB_PREFIXE."dossier\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
"idx" => $this->valF['dossier'], |
3081 |
if (database::isError($res1)) { |
)); |
3082 |
die($res->getMessage()); |
$valF['instruction'] = $id; |
3083 |
|
$valF['crud'] = 'create'; |
3084 |
|
$update_by_instruction = $inst_dossier->update_by_instruction($valF); |
3085 |
|
if ($update_by_instruction === false) { |
3086 |
|
$this->cleanMessage(); |
3087 |
|
$this->addToMessage(sprintf('%s %s', __("Une erreur s'est produite lors de la mise à jour du dossier d'instruction."), __("Veuillez contacter votre administrateur."))); |
3088 |
|
return false; |
3089 |
} |
} |
3090 |
// Affichage d'informations à l'utilisateur |
// Affichage d'informations à l'utilisateur |
3091 |
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$this->f->db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
3092 |
} |
} |
3093 |
|
|
3094 |
/** |
/** |
3124 |
$this->addToMessage(_("Notification (105) du référentiel ERP OK.")); |
$this->addToMessage(_("Notification (105) du référentiel ERP OK.")); |
3125 |
} |
} |
3126 |
|
|
3127 |
|
// Si le mode en rédaction intégrale est activé |
3128 |
|
if (isset($this->valF['flag_edition_integrale']) === true |
3129 |
|
&& $this->valF['flag_edition_integrale'] === true) { |
3130 |
|
$redactionIntegraleValF = array(); |
3131 |
|
|
3132 |
|
// Récupère la collectivite du dossier d'instruction |
3133 |
|
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
3134 |
|
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
3135 |
|
// Récupère le corps de la lettre type |
3136 |
|
$params = array( |
3137 |
|
"specific" => array( |
3138 |
|
"corps" => array( |
3139 |
|
"mode" => "get", |
3140 |
|
) |
3141 |
|
), |
3142 |
|
); |
3143 |
|
$result = $this->compute_pdf_output('lettretype', $this->valF['lettretype'], $collectivite, $id, $params); |
3144 |
|
$redactionIntegraleValF['corps_om_htmletatex'] = $result['pdf_output']; |
3145 |
|
// Récupère le titre de la lettre type |
3146 |
|
$params = array( |
3147 |
|
"specific" => array( |
3148 |
|
"titre" => array( |
3149 |
|
"mode" => "get", |
3150 |
|
) |
3151 |
|
), |
3152 |
|
); |
3153 |
|
$result = $this->compute_pdf_output('lettretype', $this->valF['lettretype'], $collectivite, $id, $params); |
3154 |
|
$redactionIntegraleValF['titre_om_htmletat'] = $result['pdf_output']; |
3155 |
|
|
3156 |
|
// mise à jour en base de données |
3157 |
|
$res = $this->f->db->autoExecute( |
3158 |
|
DB_PREFIXE.$this->table, |
3159 |
|
$redactionIntegraleValF, |
3160 |
|
DB_AUTOQUERY_UPDATE, |
3161 |
|
$this->clePrimaire."=".$id |
3162 |
|
); |
3163 |
|
$this->addToLog(__METHOD__."(): db->autoexecute(\"".DB_PREFIXE.'.'.$this->table."\", ".print_r($redactionIntegraleValF, true).", DB_AUTOQUERY_UPDATE, \"".$this->clePrimaire."=".$id."\");", VERBOSE_MODE); |
3164 |
|
if ($this->f->isDatabaseError($res, true) === true) { |
3165 |
|
return false; |
3166 |
|
} |
3167 |
|
} |
3168 |
|
|
3169 |
|
/** |
3170 |
|
* Finalisation automatique de l'instruction si le paramétrage de l'événement l'autorise |
3171 |
|
*/ |
3172 |
|
// Si la finalisation automatique de l'événement est activée |
3173 |
|
// ET si l'instruction n'a pas déjà été finalisée |
3174 |
|
// ET s'il existe une lettre type associée |
3175 |
|
if ($inst_evenement->getVal('finaliser_automatiquement') === 't' |
3176 |
|
&& $inst_evenement->getVal('om_final_instruction') !== 't' |
3177 |
|
&& $inst_evenement->getVal('lettretype') !== '' |
3178 |
|
&& $inst_evenement->getVal('lettretype') !== null) { |
3179 |
|
|
3180 |
|
// On instancie l'instruction |
3181 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
3182 |
|
"obj" => "instruction", |
3183 |
|
"idx" => $this->valF[$this->clePrimaire], |
3184 |
|
)); |
3185 |
|
|
3186 |
|
// On finalise l'instruction dans le contexte de finalisation : action 100 |
3187 |
|
$inst_instruction->setParameter('maj', 100); |
3188 |
|
$finalize = $inst_instruction->finalize($inst_instruction->valF); |
3189 |
|
|
3190 |
|
// Une erreur de finalisation renvoie 'false' : ajout dans les logs |
3191 |
|
// et dans le message d'erreur |
3192 |
|
if ($finalize === false) { |
3193 |
|
$this->f->addToLog(__METHOD__."() : ERROR - Impossible de finaliser l'instruction.", DEBUG_MODE); |
3194 |
|
$this->addToMessage(_("Erreur lors de la finalisation de l'instruction. Contactez votre administrateur.")); |
3195 |
|
return false; |
3196 |
|
} |
3197 |
|
} |
3198 |
|
|
3199 |
|
/** |
3200 |
|
* Finalisation automatique des instructions tacites ou retours. |
3201 |
|
*/ |
3202 |
|
// Si l'option de finalisation automatique des instructions tacites ou |
3203 |
|
// retours est activée et l'événement d'instruction a une lettre type |
3204 |
|
// associée |
3205 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite($val['dossier']); |
3206 |
|
if ($this->f->is_option_finalisation_auto_enabled($collectivite_di) === true |
3207 |
|
&& $inst_evenement->getVal('lettretype') !== '' |
3208 |
|
&& $inst_evenement->getVal('lettretype') !== null) { |
3209 |
|
|
3210 |
|
// Rècupère l'identifiant de l'événement |
3211 |
|
$evenement_id = $inst_evenement->getVal($inst_evenement->clePrimaire); |
3212 |
|
|
3213 |
|
// Si l'événement d'instruction est identifié comme un événement |
3214 |
|
// retour |
3215 |
|
// OU l'événement d'instruction est l'événement suivant tacite du |
3216 |
|
// dossier d'instruction (incomplétude prise en compte) |
3217 |
|
// ET l'événement d'instruction n'a pas déjà été finalisé |
3218 |
|
if (($inst_evenement->getVal("retour") === 't' |
3219 |
|
|| ($inst_di->getVal('evenement_suivant_tacite_incompletude') === $evenement_id |
3220 |
|
|| $inst_di->getVal('evenement_suivant_tacite') === $evenement_id)) |
3221 |
|
&& ($inst_evenement->getVal('om_final_instruction') !== 't')) { |
3222 |
|
|
3223 |
|
// Finalise l'instruction |
3224 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
3225 |
|
"obj" => "instruction", |
3226 |
|
"idx" => $this->valF[$this->clePrimaire], |
3227 |
|
)); |
3228 |
|
$inst_instruction->setParameter('maj', 100); |
3229 |
|
$finalize = $inst_instruction->finalize($inst_instruction->valF); |
3230 |
|
if ($finalize === false) { |
3231 |
|
// |
3232 |
|
return false; |
3233 |
|
} |
3234 |
|
} |
3235 |
|
} |
3236 |
|
|
3237 |
|
/** |
3238 |
|
* Mise à jour de la version de clôture *version_clos* du dossier si et |
3239 |
|
* seulement si l'instruction met à jour l'état du dossier. |
3240 |
|
*/ |
3241 |
|
if (isset($valF['etat']) === true |
3242 |
|
&& $valF['etat'] !== null |
3243 |
|
&& $valF['etat'] !== '') { |
3244 |
|
// Instanciation de l'état appliqué sur le dossier par l'instruction |
3245 |
|
$inst_etat = $this->f->get_inst__om_dbform(array( |
3246 |
|
"obj" => "etat", |
3247 |
|
"idx" => $valF['etat'], |
3248 |
|
)); |
3249 |
|
// |
3250 |
|
$update_version_clos = null; |
3251 |
|
// En cas d'instruction qui clôture le dossier |
3252 |
|
if ($inst_etat->getVal('statut') === 'cloture') { |
3253 |
|
$update_version_clos = $inst_di->update_version_clos('up'); |
3254 |
|
} |
3255 |
|
// En cas d'instruction qui rouvre le dossier |
3256 |
|
if ($inst_current_etat->getVal('statut') === 'cloture' |
3257 |
|
&& $inst_etat->getVal('statut') !== 'cloture') { |
3258 |
|
// |
3259 |
|
$update_version_clos = $inst_di->update_version_clos('down'); |
3260 |
|
// |
3261 |
|
$params = array( |
3262 |
|
'di_reopened' => true, |
3263 |
|
); |
3264 |
|
} |
3265 |
|
// |
3266 |
|
if ($update_version_clos === false) { |
3267 |
|
$this->f->addToLog(sprintf( |
3268 |
|
"%s() : ERREUR - %s %s", |
3269 |
|
__METHOD__, |
3270 |
|
sprintf( |
3271 |
|
__("Impossible de mettre à jour la version de clôture du dossier d'instruction %s."), |
3272 |
|
$inst_di->getVal($inst_di->clePrimaire) |
3273 |
|
), |
3274 |
|
sprintf( |
3275 |
|
__("L'instruction tente d'appliquer l'état %s."), |
3276 |
|
$inst_etat->getVal($inst_etat->clePrimaire) |
3277 |
|
) |
3278 |
|
)); |
3279 |
|
$this->addToMessage(sprintf( |
3280 |
|
"%s %s", |
3281 |
|
__("Erreur lors de la mise à jour de la version de clôture du dossier d'instruction."), |
3282 |
|
__("Veuillez contacter votre administrateur.") |
3283 |
|
)); |
3284 |
|
return false; |
3285 |
|
} |
3286 |
|
} |
3287 |
|
|
3288 |
|
/** |
3289 |
|
* Notification automatique |
3290 |
|
*/ |
3291 |
|
// Notification automatique à l'ajout de l'instruction si la notification |
3292 |
|
// automatique est choisie et qu'il n'y a pas de lettretype associée à l'événement |
3293 |
|
if ($inst_evenement->getVal('notification') === 'notification_automatique' && |
3294 |
|
($inst_evenement->getVal('lettretype') === null || |
3295 |
|
$inst_evenement->getVal('lettretype') === '')) { |
3296 |
|
// Message à afficher dans les logs pour indiquer quelle notification a échouée |
3297 |
|
$msgLog = sprintf( |
3298 |
|
'%s %s : %d', |
3299 |
|
__('Erreur lors de la notification automatique du(des) pétitionnaire(s).'), |
3300 |
|
__('Instruction notifiée'), |
3301 |
|
$id |
3302 |
|
); |
3303 |
|
|
3304 |
|
// Récupération de la liste des demandeurs à notifier et de la catégorie |
3305 |
|
$categorie = $this->f->get_param_option_notification($collectivite_di); |
3306 |
|
$isPortal = $categorie === PORTAL; |
3307 |
|
$demandeursANotifie = $this->get_demandeurs_notifiable( |
3308 |
|
$this->valF['dossier'], |
3309 |
|
$isPortal |
3310 |
|
); |
3311 |
|
|
3312 |
|
// Création d'une notification et d'une tâche pour chaque demandeur à notifier |
3313 |
|
$demandeurPrincipalNotifie = false; |
3314 |
|
foreach ($demandeursANotifie as $demandeur) { |
3315 |
|
// Identifie si le demandeur principal a été notifié ou pas |
3316 |
|
// et récupère ses informations |
3317 |
|
if ($demandeur['petitionnaire_principal'] == 't') { |
3318 |
|
$demandeurPrincipalNotifie = true; |
3319 |
|
// Si le demandeur principal est notifiable mais qu'il y a des erreurs dans |
3320 |
|
// son paramétrage, on effectue pas le traitement et on passe à l'itération |
3321 |
|
// suivante. On le considère également comme non notifié pour gérer l'envoie |
3322 |
|
// des messages d'erreurs |
3323 |
|
// Si la demande a été déposée via le portail alors le paramétrage n'a pas |
3324 |
|
// d'impact sur la notification |
3325 |
|
$erreursParam = $this->get_info_notification_fail($val['dossier']); |
3326 |
|
if (! $this->dossier_depose_sur_portail($val['dossier']) && $erreursParam != array()) { |
3327 |
|
$demandeurPrincipalNotifie = false; |
3328 |
|
continue; |
3329 |
|
} |
3330 |
|
} |
3331 |
|
// Ajout de la notif et récupération de son id |
3332 |
|
$idNotif = $this->ajouter_notification( |
3333 |
|
$this->valF[$this->clePrimaire], |
3334 |
|
$this->f->get_connected_user_login_name(), |
3335 |
|
$demandeur, |
3336 |
|
$collectivite_di, |
3337 |
|
array(), |
3338 |
|
true |
3339 |
|
); |
3340 |
|
if ($idNotif === false) { |
3341 |
|
$this->addToLog( |
3342 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
3343 |
|
DEBUG_MODE |
3344 |
|
); |
3345 |
|
return false; |
3346 |
|
} |
3347 |
|
// Création de la tache en lui donnant l'id de la notification |
3348 |
|
$notification_by_task = $this->notification_by_task( |
3349 |
|
$idNotif, |
3350 |
|
$this->valF['dossier'], |
3351 |
|
$categorie |
3352 |
|
); |
3353 |
|
if ($notification_by_task === false) { |
3354 |
|
$this->addToLog( |
3355 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
3356 |
|
DEBUG_MODE |
3357 |
|
); |
3358 |
|
$this->addToMessage( |
3359 |
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
3360 |
|
); |
3361 |
|
return false; |
3362 |
|
} |
3363 |
|
} |
3364 |
|
// Pour la notification par mail ou la notification via portal si le dossier a |
3365 |
|
// été déposés via portal, si le demandeur principal n'est pas notifiable, |
3366 |
|
// on créé une nouvelle notification en erreur avec en commentaire la raison pour |
3367 |
|
// laquelle le demandeur principal n'a pas pu être notifié |
3368 |
|
$depotPortal = $this->dossier_depose_sur_portail(); |
3369 |
|
if (! $demandeurPrincipalNotifie && ($isPortal === false || $depotPortal === true)) { |
3370 |
|
// Précision dans les logs que le pétitionnaire principal n'est pas notifiable. |
3371 |
|
// ' ' permet de mettre un espace entre les 2 msg de log. |
3372 |
|
$msgLog .= sprintf(' %s', __('Le pétitionnaire principale n\'est pas notifiable.')); |
3373 |
|
// Analyse pour savoir pourquoi le demandeur principal n'est pas notifiable |
3374 |
|
$erreursParam = $this->get_info_notification_fail($val['dossier']); |
3375 |
|
$demandeurPrincipal = $this->get_info_petitionnaire_principal_dossier($val['dossier']); |
3376 |
|
// Ajout de la notif et récupération de son id |
3377 |
|
$idNotif = $this->ajouter_notification( |
3378 |
|
$this->valF[$this->clePrimaire], |
3379 |
|
$this->f->get_connected_user_login_name(), |
3380 |
|
$demandeurPrincipal, |
3381 |
|
$collectivite_di, |
3382 |
|
array(), |
3383 |
|
true, |
3384 |
|
'Echec', |
3385 |
|
implode(' ', $erreursParam) |
3386 |
|
); |
3387 |
|
if ($idNotif === false) { |
3388 |
|
$this->addToLog( |
3389 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
3390 |
|
DEBUG_MODE |
3391 |
|
); |
3392 |
|
$this->addToMessage( |
3393 |
|
__('Erreur : la création de la notification a échouée.'). |
3394 |
|
__("Veuillez contacter votre administrateur.") |
3395 |
|
); |
3396 |
|
return false; |
3397 |
|
} |
3398 |
|
// Prépare un message d'alerte à destination de l'instructeur pour l'informer |
3399 |
|
// de l'échec de la notification |
3400 |
|
$dossier_message = $this->get_inst_dossier_message(0); |
3401 |
|
$dossier_message_val = array( |
3402 |
|
'dossier' => $val['dossier'], |
3403 |
|
'type' => _('erreur expedition'), |
3404 |
|
'emetteur' => $this->f->get_connected_user_login_name().' (automatique)', |
3405 |
|
'login' => $_SESSION['login'], |
3406 |
|
'date_emission' => date('Y-m-d H:i:s'), |
3407 |
|
'contenu' => _('Échec lors de la notification de l\'instruction '). |
3408 |
|
$inst_evenement->getVal('libelle'). |
3409 |
|
'.<br>'. |
3410 |
|
implode("\n", $erreursParam). |
3411 |
|
'<br>'. |
3412 |
|
_('Veuillez corriger ces informations avant de renvoyer la notification.') |
3413 |
|
); |
3414 |
|
$add = $dossier_message->add_notification_message($dossier_message_val, true); |
3415 |
|
// Si une erreur se produit pendant l'ajout |
3416 |
|
if ($add !== true) { |
3417 |
|
$this->addToLog(__METHOD__."(): Le message d'alerte concernant l'echec de l'envoi de la notification n'a pas pu être envoyé.", DEBUG_MODE); |
3418 |
|
return false; |
3419 |
|
} |
3420 |
|
} |
3421 |
|
$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."))); |
3422 |
|
} |
3423 |
|
|
3424 |
|
// Notification automatique en cas de dépôt de dossier dématérialisé |
3425 |
|
// Vérifie si l'option de notification est active et si il s'agit bien d'une |
3426 |
|
// instruction de récépissé |
3427 |
|
if ( |
3428 |
|
$this->f->is_option_notification_depot_demat_enabled($collectivite_di) |
3429 |
|
&& $this->is_instruction_recepisse() |
3430 |
|
) { |
3431 |
|
// Message à afficher dans les logs pour indiquer quelle notification a échouée |
3432 |
|
$msgLog = sprintf( |
3433 |
|
__('Erreur lors de la notification de dépôt du dossier dématérialisé : %s.'), |
3434 |
|
$val['dossier'] |
3435 |
|
); |
3436 |
|
// Récupère l'instance de la demande |
3437 |
|
$demande = $inst_di->get_inst_demande(); |
3438 |
|
// Vérifie que le dossier a été déposé via platau ou portal |
3439 |
|
if ( |
3440 |
|
($demande->getVal('source_depot') == PLATAU || |
3441 |
|
$demande->getVal('source_depot') == PORTAL) |
3442 |
|
) { |
3443 |
|
// Récupère la liste des mails fournis en paramètre. Si aucun adresse n'a été récupéré |
3444 |
|
// l'envoi de la notification n'est pas effectué et un message d'erreur est affiché. |
3445 |
|
$listeEmails = $this->f->get_param_courriel_de_notification_commune($collectivite_di); |
3446 |
|
if (empty($listeEmails)) { |
3447 |
|
$this->addToLog( |
3448 |
|
sprintf( |
3449 |
|
'%s(): %s %s', |
3450 |
|
__METHOD__, |
3451 |
|
$msgLog, |
3452 |
|
__('Aucun courriel paramétré.') |
3453 |
|
), |
3454 |
|
DEBUG_MODE |
3455 |
|
); |
3456 |
|
} else { |
3457 |
|
foreach ($listeEmails as $email) { |
3458 |
|
// Ajout de la notif et récupération de son id |
3459 |
|
$destinataire = array( |
3460 |
|
'destinataire' => $email, |
3461 |
|
'courriel' => $email |
3462 |
|
); |
3463 |
|
$idNotif = $this->ajouter_notification( |
3464 |
|
$this->valF[$this->clePrimaire], |
3465 |
|
$this->f->get_connected_user_login_name(), |
3466 |
|
$destinataire, |
3467 |
|
$collectivite_di, |
3468 |
|
array(), |
3469 |
|
true |
3470 |
|
); |
3471 |
|
if ($idNotif === false) { |
3472 |
|
$this->addToLog( |
3473 |
|
sprintf('%s(): %s', __METHOD__, $msgLog), |
3474 |
|
DEBUG_MODE |
3475 |
|
); |
3476 |
|
return false; |
3477 |
|
} |
3478 |
|
// Création de la tache en lui donnant l'id de la notification |
3479 |
|
$notification_by_task = $this->notification_by_task( |
3480 |
|
$idNotif, |
3481 |
|
$this->valF['dossier'], |
3482 |
|
'mail', |
3483 |
|
'notification_depot_demat' |
3484 |
|
); |
3485 |
|
if ($notification_by_task === false) { |
3486 |
|
$this->addToMessage( |
3487 |
|
__("Erreur lors de la génération de la notification de dépot de dossier par voie dématérialisée.") |
3488 |
|
); |
3489 |
|
$this->addToLog( |
3490 |
|
sprintf('%s(): %s', __METHOD__, $msgLog), |
3491 |
|
DEBUG_MODE |
3492 |
|
); |
3493 |
|
return false; |
3494 |
|
} |
3495 |
|
} |
3496 |
|
} |
3497 |
|
} |
3498 |
|
} |
3499 |
|
|
3500 |
|
/** |
3501 |
|
* Mise à jour de la date de dernière modification du dossier |
3502 |
|
*/ |
3503 |
|
$inst_di->update_last_modification_date(); |
3504 |
|
|
3505 |
/** |
/** |
3506 |
* Mise à jour des données du DA. |
* Mise à jour des données du DA. |
3507 |
*/ |
*/ |
|
// |
|
3508 |
$inst_da = $inst_di->get_inst_dossier_autorisation(); |
$inst_da = $inst_di->get_inst_dossier_autorisation(); |
3509 |
// |
$params['di_id'] = $this->valF['dossier']; |
3510 |
if ($inst_da->majDossierAutorisation() === false) { |
if ($inst_da->majDossierAutorisation($params) === false) { |
3511 |
$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.")); |
3512 |
$this->correct = false; |
$this->correct = false; |
3513 |
return false; |
return false; |
3520 |
return $this->add_log_to_dossier($id, array_merge($val, $this->valF)); |
return $this->add_log_to_dossier($id, array_merge($val, $this->valF)); |
3521 |
} |
} |
3522 |
|
|
3523 |
function triggermodifierapres($id,&$db,$val,$DEBUG) { |
/** |
3524 |
/** |
* Cette méthode vérifie si toutes les conditions de l'envoi de la notification |
3525 |
* L'objectif ici est d'effectuer les recalculs de date dans le dossier |
* sont remplies. |
3526 |
* si la date de l'evenement est modifiee |
* Les conditions vérifiées sont les suivantes : |
3527 |
*/ |
* - L'option de notification *option_notification* doit être définie |
3528 |
// Initialisation |
* - Le petitionnaire principal doit accepter les notifications |
3529 |
$valF = ""; |
* - Le pétitionnaire principal doit avoir une adresse mail renseignée |
3530 |
$valF_dt = ""; |
* - Le pétitionnaire principal doit avoir une adresse mail correcte |
3531 |
// Initialisation du type d'événement |
* Pour chaque vérification effectué un message d'erreur est ajouté si la |
3532 |
$type_evmt = ""; |
* condition n'est pas remplie. |
3533 |
// Récupération de l'action correspondante à l'événement |
* Renvoie le message d'erreur en sortie. |
3534 |
$sql = "SELECT action |
* |
3535 |
FROM ".DB_PREFIXE."evenement |
* @param string identifiant du dossier sur lequel les notifications ont échouée |
3536 |
WHERE evenement=".$this->valF['evenement']; |
* @return string |
3537 |
$action = $db->getOne($sql); |
*/ |
3538 |
$this->addToLog("triggermodifierapres(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
protected function get_info_notification_fail($dossier = null) { |
3539 |
if (database::isError($action)) { |
// Utilise l'identifiant du dossier passé en paramètre et si aucun dossier n'a été récupéré |
3540 |
die($action->getMessage()); |
// utilise celui associé à l'instruction |
3541 |
|
if ($dossier == null) { |
3542 |
|
$dossier = $this->getVal('dossier'); |
3543 |
|
} |
3544 |
|
// Tableau contenant la liste des messages d'erreur |
3545 |
|
$errorMessage = array(); |
3546 |
|
// Récupère l'option de notification |
3547 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite($dossier); |
3548 |
|
$option_notification = $this->f->get_param_option_notification($collectivite_di); |
3549 |
|
if ($option_notification !== PORTAL && $option_notification !== 'mail') { |
3550 |
|
$errorMessage[] = __("L'option de notification option_notification doit obligatoirement être définie."); |
3551 |
|
} |
3552 |
|
// Récupère les informations du demandeurs principal |
3553 |
|
$infoPetitionnaire = $this->get_info_petitionnaire_principal_dossier($dossier); |
3554 |
|
// Vérifie si le pétitionnaire principal à bien la case "accepte les notification" cochée |
3555 |
|
if (isset($infoPetitionnaire['notification']) && $infoPetitionnaire['notification'] != 't') { |
3556 |
|
$errorMessage[] = __('Le pétitionnaire principal n\'accepte pas les notifications.'); |
3557 |
|
} |
3558 |
|
// Vérifie si l'adresse mail du pétitionnaire principale est renseignée |
3559 |
|
if (isset($infoPetitionnaire['courriel']) && ! empty($infoPetitionnaire['courriel'])) { |
3560 |
|
// Vérifie si le format de l'adresse mail est pas correct et, si ce n'est pas le cas, informe l'utilisateur |
3561 |
|
// qu'il doit le corriger avant de pouvoir ajouter l'nstruction |
3562 |
|
if (! $this->f->checkValidEmailAddress($infoPetitionnaire['courriel'])) { |
3563 |
|
$errorMessage[] = __('Le courriel du pétitionnaire principal n\'est pas correct : '). |
3564 |
|
$infoPetitionnaire['courriel']. |
3565 |
|
'.'; |
3566 |
|
} |
3567 |
|
} else { |
3568 |
|
// Si le courriel du pétitionnaire principal |
3569 |
|
$errorMessage[] = __('Le courriel du pétitionnaire principal n\'est pas renseigné.'); |
3570 |
} |
} |
3571 |
|
|
3572 |
// Récupération des paramètres de l'action |
return $errorMessage; |
3573 |
$sql = "SELECT * FROM ".DB_PREFIXE."action |
} |
3574 |
WHERE action='".$action."'"; |
|
3575 |
$res = $db->query($sql); |
/** |
3576 |
$this->addToLog("triggermodifierapres(): db->query(\"".$sql."\");", VERBOSE_MODE); |
* Méthode servant à vérifier si un dossier a été déposé sur |
3577 |
if (database::isError($res)) { |
* le portail citoyen ou pas. |
3578 |
die($res->getMessage()); |
* La verification se fait via une requête sql dans laquelle |
3579 |
|
* on va chercher un dossier ayant pour id l'identifiant de |
3580 |
|
* dossier associé à l'instruction et pour lequel la demande |
3581 |
|
* associée la plus ancienne est une demande de création de |
3582 |
|
* dossier via portail |
3583 |
|
* |
3584 |
|
* @param string identifiant du dossier. Si non renseigné c'est le dossier |
3585 |
|
* associé à l'instruction qui est utilisé |
3586 |
|
* @return boolean|void true : dossier déposé via portail, false : dossier |
3587 |
|
* non déposé via portail et null : erreur de base de données. |
3588 |
|
*/ |
3589 |
|
protected function dossier_depose_sur_portail($dossier = null) { |
3590 |
|
if (empty($dossier)) { |
3591 |
|
$dossier = $this->getVal('dossier'); |
3592 |
|
} |
3593 |
|
$qres = $this->f->get_one_result_from_db_query( |
3594 |
|
sprintf( |
3595 |
|
'SELECT |
3596 |
|
dossier |
3597 |
|
FROM |
3598 |
|
%1$sdossier |
3599 |
|
-- Récuperation de la première demande associée au dossier |
3600 |
|
LEFT JOIN ( |
3601 |
|
SELECT |
3602 |
|
demande, |
3603 |
|
dossier_instruction, |
3604 |
|
source_depot |
3605 |
|
FROM |
3606 |
|
%1$sdemande |
3607 |
|
WHERE |
3608 |
|
dossier_instruction = \'%2$s\' |
3609 |
|
ORDER BY |
3610 |
|
demande ASC |
3611 |
|
LIMIT 1 |
3612 |
|
) AS demande |
3613 |
|
ON dossier.dossier = demande.dossier_instruction |
3614 |
|
WHERE |
3615 |
|
dossier.dossier = \'%2$s\' |
3616 |
|
AND demande.source_depot = \'portal\'', |
3617 |
|
DB_PREFIXE, |
3618 |
|
$this->f->db->escapeSimple($dossier) |
3619 |
|
), |
3620 |
|
array( |
3621 |
|
"origin" => __METHOD__, |
3622 |
|
"force_return" => true, |
3623 |
|
) |
3624 |
|
); |
3625 |
|
if ($qres["code"] !== "OK") { |
3626 |
|
$this->addToMessage(__('Erreur : La vérification du mode de dépôt du dossier à échoué')); |
3627 |
|
return; |
3628 |
} |
} |
3629 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
// Si on a un résultat c'est que le dossier a été déposé via le portail |
3630 |
// application des regles sur le courrier + delai |
return ! empty($qres["result"]); |
3631 |
if(preg_match("/date_evenement/",$row['regle_date_limite'])){ |
} |
3632 |
$valF['date_limite']= $this->regle($row['regle_date_limite'], 'regle_date_limite'); |
|
3633 |
} |
public function is_service_notifiable() { |
3634 |
if(preg_match("/date_evenement/",$row['regle_date_complet'])){ |
$evenement = $this->get_inst_evenement($this->getVal('evenement')); |
3635 |
$valF['date_complet']= $this->regle($row['regle_date_complet'], 'regle_date_complet'); |
|
3636 |
} |
// Si l'instruction a une édition non finalisé quel que soit |
3637 |
if(preg_match("/date_evenement/",$row['regle_date_dernier_depot'])){ |
// le type de notification, il n'est pas notifiable |
3638 |
$valF['date_dernier_depot']= $this->regle($row['regle_date_dernier_depot'], 'regle_date_dernier_depot'); |
if ($this->has_an_edition() === true) { |
3639 |
} |
if ($this->is_unfinalizable_without_bypass() === false) { |
3640 |
if(preg_match("/date_evenement/",$row['regle_date_notification_delai'])){ |
return false; |
|
$valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai'], 'regle_date_notification_delai'); |
|
|
} |
|
|
if(preg_match("/date_evenement/",$row['regle_date_decision'])){ |
|
|
$valF['date_decision']= $this->regle($row['regle_date_decision'], 'regle_date_decision'); |
|
|
} |
|
|
if(preg_match("/date_evenement/",$row['regle_date_rejet'])){ |
|
|
$valF['date_rejet']= $this->regle($row['regle_date_rejet'], 'regle_date_rejet'); |
|
|
} |
|
|
if(preg_match("/date_evenement/",$row['regle_date_validite'])){ |
|
|
$valF['date_validite']= $this->regle($row['regle_date_validite'], 'regle_date_validite'); |
|
|
} |
|
|
if(preg_match("/date_evenement/",$row['regle_date_chantier'])){ |
|
|
$valF['date_chantier']= $this->regle($row['regle_date_chantier'], 'regle_date_chantier'); |
|
|
} |
|
|
if(preg_match("/date_evenement/",$row['regle_date_achevement'])){ |
|
|
$valF['date_achevement']= $this->regle($row['regle_date_achevement'], 'regle_date_achevement'); |
|
|
} |
|
|
if(preg_match("/date_evenement/",$row['regle_date_conformite'])){ |
|
|
$valF['date_conformite']= $this->regle($row['regle_date_conformite'], 'regle_date_conformite'); |
|
|
} |
|
|
if(preg_match("/date_evenement/",$row['regle_date_cloture_instruction'])){ |
|
|
$valF['date_cloture_instruction']= $this->regle($row['regle_date_cloture_instruction'], 'regle_date_cloture_instruction'); |
|
|
} |
|
|
if(preg_match("/date_evenement/",$row['regle_date_premiere_visite'])){ |
|
|
$valF['date_premiere_visite']= $this->regle($row['regle_date_premiere_visite'], 'regle_date_premiere_visite'); |
|
|
} |
|
|
if(preg_match("/date_evenement/",$row['regle_date_derniere_visite'])){ |
|
|
$valF['date_derniere_visite']= $this->regle($row['regle_date_derniere_visite'], 'regle_date_derniere_visite'); |
|
|
} |
|
|
if(preg_match("/date_evenement/",$row['regle_date_contradictoire'])){ |
|
|
$valF['date_contradictoire']= $this->regle($row['regle_date_contradictoire'], 'regle_date_contradictoire'); |
|
3641 |
} |
} |
3642 |
if(preg_match("/date_evenement/",$row['regle_date_retour_contradictoire'])){ |
} |
3643 |
$valF['date_retour_contradictoire']= $this->regle($row['regle_date_retour_contradictoire'], 'regle_date_retour_contradictoire'); |
// Vérifie si la notification des tiers est active pour l'évènement |
3644 |
|
return $this->get_boolean_from_pgsql_value($evenement->getVal('notification_service')); |
3645 |
|
} |
3646 |
|
|
3647 |
|
public function is_tiers_notifiable() { |
3648 |
|
$evenement = $this->get_inst_evenement($this->getVal('evenement')); |
3649 |
|
|
3650 |
|
// Si l'instruction a une édition non finalisé quel que soit |
3651 |
|
// le type de notification, il n'est pas notifiable |
3652 |
|
if ($this->has_an_edition() === true) { |
3653 |
|
if ($this->is_unfinalizable_without_bypass() === false) { |
3654 |
|
return false; |
3655 |
} |
} |
3656 |
if(preg_match("/date_evenement/",$row['regle_date_ait'])){ |
} |
3657 |
$valF['date_ait']= $this->regle($row['regle_date_ait'], 'regle_date_ait'); |
// Vérifie si la notification des tiers est active pour l'évènement |
3658 |
|
return ! empty($evenement->getVal('notification_tiers')); |
3659 |
|
} |
3660 |
|
|
3661 |
|
/** |
3662 |
|
* Méthode permettant de savoir si une instruction peut |
3663 |
|
* être notifiée manuellement selon les différents types |
3664 |
|
* de notification. |
3665 |
|
* |
3666 |
|
* Si l'instruction a une édition non finalisée alors elle n'est pas |
3667 |
|
* manuellement notifiable. |
3668 |
|
* Si l'instruction est associé à un événement de notification pour |
3669 |
|
* lequel un retour signature est recquis, elle n'est notifiable que |
3670 |
|
* si la date de retour de signature est remplie. |
3671 |
|
* Par défaut si le type de notification n'est pas connu alors l'instruction |
3672 |
|
* n'est pas notifiable. |
3673 |
|
* Pour tous les autres cas l'instruction est manuellement notifiable. |
3674 |
|
* |
3675 |
|
* @return boolean true : notifiable | false : non notifiable |
3676 |
|
*/ |
3677 |
|
public function is_notifiable_by_task_manual() { |
3678 |
|
$ev = $this->get_inst_evenement($this->getVal('evenement')); |
3679 |
|
|
3680 |
|
// Si l'instruction a une édition non finalisé quel que soit |
3681 |
|
// le type de notification, il n'est pas notifiable |
3682 |
|
if ($this->has_an_edition() === true) { |
3683 |
|
if ($this->is_unfinalizable_without_bypass() === false) { |
3684 |
|
return false; |
3685 |
} |
} |
3686 |
if(preg_match("/date_evenement/",$row['regle_date_transmission_parquet'])){ |
} |
3687 |
$valF['date_transmission_parquet']= $this->regle($row['regle_date_transmission_parquet'], 'regle_date_transmission_parquet'); |
|
3688 |
|
// Gestion des différents cas selon la valeur du champs notification |
3689 |
|
if ($ev->getVal('notification') == 'notification_manuelle' || |
3690 |
|
$ev->getVal('notification') == 'notification_manuelle_annexe' || |
3691 |
|
$ev->getVal('notification') == 'notification_automatique' |
3692 |
|
) { |
3693 |
|
return true; |
3694 |
|
} elseif (($ev->getVal('notification') == 'notification_auto_signature_requise' || |
3695 |
|
$ev->getVal('notification') == 'notification_manuelle_signature_requise' || |
3696 |
|
$ev->getVal('notification') == 'notification_manuelle_annexe_signature_requise') && |
3697 |
|
$this->getVal('date_retour_signature') != null && |
3698 |
|
$this->getVal('date_retour_signature') != '' |
3699 |
|
) { |
3700 |
|
return true ; |
3701 |
|
} |
3702 |
|
return false; |
3703 |
|
} |
3704 |
|
|
3705 |
|
/** |
3706 |
|
* Crée une instance et une tache de notification pour le demandeur |
3707 |
|
* principal. |
3708 |
|
* |
3709 |
|
* @return boolean true si le traitement à réussi |
3710 |
|
*/ |
3711 |
|
protected function notifier_demandeur_principal() { |
3712 |
|
$this->begin_treatment(__METHOD__); |
3713 |
|
$message = ''; |
3714 |
|
// Récupération des informations concernant le demandeur |
3715 |
|
$dossier = $this->getVal('dossier'); |
3716 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite($dossier); |
3717 |
|
$demandeur = $this->get_demandeurs_notifiable( |
3718 |
|
$dossier, |
3719 |
|
true |
3720 |
|
); |
3721 |
|
if ($demandeur !== array()) { |
3722 |
|
$destinataire = array_values($demandeur); |
3723 |
|
// Ajout de la notif et récupération de son id |
3724 |
|
$idNotification = $this->ajouter_notification( |
3725 |
|
$this->getVal($this->clePrimaire), |
3726 |
|
$this->f->get_connected_user_login_name(), |
3727 |
|
$destinataire[0], |
3728 |
|
$collectivite_di, |
3729 |
|
array(), |
3730 |
|
true |
3731 |
|
); |
3732 |
|
if ($idNotification === false) { |
3733 |
|
return $this->end_treatment(__METHOD__, false); |
3734 |
} |
} |
3735 |
if ($row['regle_donnees_techniques1'] !== '') { |
// Création de la tâche en lui donnant l'id de la notification |
3736 |
$valF_dt[$row['cible_regle_donnees_techniques1']] = $this->regle($row['regle_donnees_techniques1'], 'regle_donnees_techniques1'); |
$notification_by_task = $this->notification_by_task($idNotification, $dossier); |
3737 |
|
if ($notification_by_task === false) { |
3738 |
|
$this->addToMessage( |
3739 |
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
3740 |
|
); |
3741 |
|
return $this->end_treatment(__METHOD__, false); |
3742 |
} |
} |
3743 |
if ($row['regle_donnees_techniques2'] !== '') { |
$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."))); |
3744 |
$valF_dt[$row['cible_regle_donnees_techniques2']] = $this->regle($row['regle_donnees_techniques2'], 'regle_donnees_techniques2'); |
return $this->end_treatment(__METHOD__, true); |
3745 |
|
} |
3746 |
|
$this->addToMessage( __("Le demandeur principal n'est pas notifiable.")); |
3747 |
|
return $this->end_treatment(__METHOD__, false); |
3748 |
|
} |
3749 |
|
|
3750 |
|
public function notification_by_task($object_id, $dossier, $category = null, $type = null) { |
3751 |
|
// Si le type n'est pas correctement spécifié, alors il est calculé |
3752 |
|
if ($type !== 'notification_recepisse' |
3753 |
|
&& $type !== 'notification_instruction' |
3754 |
|
&& $type !== 'notification_decision' |
3755 |
|
&& $type !== 'notification_service_consulte' |
3756 |
|
&& $type !== 'notification_tiers_consulte' |
3757 |
|
&& $type !== 'notification_depot_demat' |
3758 |
|
&& $type !== 'notification_commune') { |
3759 |
|
// |
3760 |
|
$type = 'notification_instruction'; |
3761 |
|
// Vérifie si l'instruction est un récépissé |
3762 |
|
if ($this->is_instruction_recepisse()) { |
3763 |
|
$type = 'notification_recepisse'; |
3764 |
|
|
3765 |
|
} |
3766 |
|
// Vérifie si l'instruction est une décision |
3767 |
|
if ($type !== 'notification_recepisse') { |
3768 |
|
$avis_decision = $this->getVal('avis_decision') !== null ? $this->getVal('avis_decision') : $this->valF['avis_decision']; |
3769 |
|
if ($avis_decision !== null && $avis_decision !== '') { |
3770 |
|
$type = 'notification_decision'; |
3771 |
|
} |
3772 |
} |
} |
3773 |
if ($row['regle_donnees_techniques3'] !== '') { |
} |
3774 |
$valF_dt[$row['cible_regle_donnees_techniques3']] = $this->regle($row['regle_donnees_techniques3'], 'regle_donnees_techniques3'); |
// Préparation des valeurs de la tâche |
3775 |
|
$task_val = array( |
3776 |
|
'type' => $type, |
3777 |
|
'object_id' => $object_id, |
3778 |
|
'dossier' => $dossier, |
3779 |
|
'category' => $category, |
3780 |
|
); |
3781 |
|
// Préparation de la tache de notification |
3782 |
|
$inst_task = $this->f->get_inst__om_dbform(array( |
3783 |
|
"obj" => "task", |
3784 |
|
"idx" => 0, |
3785 |
|
)); |
3786 |
|
|
3787 |
|
$add_task = $inst_task->add_task(array('val' => $task_val)); |
3788 |
|
if ($add_task === false) { |
3789 |
|
$this->addToLog( |
3790 |
|
sprintf( |
3791 |
|
'%s(): %s %s : %s', |
3792 |
|
__METHOD__, |
3793 |
|
__('Echec de l\'ajout de la tâche de notification.'), |
3794 |
|
__('Paramétrage de la tâche'), |
3795 |
|
var_export($task_val, true) |
3796 |
|
), |
3797 |
|
DEBUG_MODE |
3798 |
|
); |
3799 |
|
return false; |
3800 |
|
} |
3801 |
|
|
3802 |
|
return true; |
3803 |
|
} |
3804 |
|
|
3805 |
|
/** |
3806 |
|
* Cette méthode permet de savoir si l'instruction est une instruction |
3807 |
|
* de recepisse (instruction lié à l'ajout du dossier). |
3808 |
|
* |
3809 |
|
* Pour cela, on récupère la liste des actions qui ont menées à la création |
3810 |
|
* de l'instruction. Si une de ces actions est lié à un objet "demande" on |
3811 |
|
* en deduis que c'est l'ajout d'une demande qui a déclenché la création de |
3812 |
|
* l'instruction et donc qu'il s'agit d'un recepisse. |
3813 |
|
* |
3814 |
|
* @return boolean |
3815 |
|
*/ |
3816 |
|
protected function is_instruction_recepisse() { |
3817 |
|
// Récupère la liste des actions qui ont mené à la création de |
3818 |
|
// l'instruction |
3819 |
|
$trace = debug_backtrace(); |
3820 |
|
// Parcours la liste des actions et si une de ces actions est lié |
3821 |
|
// à la classe demande on cosidère que l'instruction est un recepisse |
3822 |
|
foreach ($trace as $key => $value) { |
3823 |
|
if (isset($trace[$key]['class']) === true |
3824 |
|
&& empty($trace[$key]['class']) === false) { |
3825 |
|
if (strtolower($trace[$key]['class']) === 'demande') { |
3826 |
|
return true; |
3827 |
|
} |
3828 |
} |
} |
3829 |
if ($row['regle_donnees_techniques4'] !== '') { |
} |
3830 |
$valF_dt[$row['cible_regle_donnees_techniques4']] = $this->regle($row['regle_donnees_techniques4'], 'regle_donnees_techniques4'); |
return false; |
3831 |
|
} |
3832 |
|
|
3833 |
|
/** |
3834 |
|
* A partir des informations passée en argument ajoute un nouvel élément |
3835 |
|
* dans la table instruction_notification. |
3836 |
|
* Avant l'ajout vérifie en utilisant l'id de la collectivité passée en |
3837 |
|
* paramètre si le paramétrage attendus est ok. |
3838 |
|
* Ajoute également un nouvel élement dans instruction_notification_document |
3839 |
|
* si l'instruction possède une lettretype. |
3840 |
|
* Si un identifiant d'une instruction annexe est donnée ajoute un deuxième |
3841 |
|
* élement dans la table instruction_notification_document qui correspondra |
3842 |
|
* à l'annexe de la notification. |
3843 |
|
* |
3844 |
|
* @param integer identifiant de l'instruction notifiée |
3845 |
|
* @param string information concernant l'emetteur |
3846 |
|
* @param array tableau contenant 2 entrées |
3847 |
|
* - destinatire : nom, prenom ou raison sociale, dénomination et courriel |
3848 |
|
* - courriel : adresse mail de la personne à notifier |
3849 |
|
* @param integer identifiant de la collectivité permettant de récupèrer les |
3850 |
|
* paramètres à valider |
3851 |
|
* @param boolean indique si la notification est automatique ou manuelle |
3852 |
|
* @param integer identifiant d'une instruction dont l'édition sera annexé |
3853 |
|
* à la notification |
3854 |
|
* |
3855 |
|
* @return integer|boolean identifiant de la notification créée si le traitement |
3856 |
|
* a réussie, false sinon. |
3857 |
|
*/ |
3858 |
|
protected function ajouter_notification( |
3859 |
|
$idInstruction, |
3860 |
|
$emetteur, |
3861 |
|
$destinataire, |
3862 |
|
$collectiviteId, |
3863 |
|
$annexes = array(), |
3864 |
|
$demandeAuto = false, |
3865 |
|
$statut = 'en cours d\'envoi', |
3866 |
|
$commentaire = 'Notification en cours de traitement' |
3867 |
|
) { |
3868 |
|
// Vérification que les paramètres nécessaires à l'envoi de la notification existe avant |
3869 |
|
// de créer la notification |
3870 |
|
if (! $this->is_parametrage_notification_correct($collectiviteId)) { |
3871 |
|
$msgErreur = __("Erreur de paramétrage. L'url d'accès au(x) document(s) notifié(s) n'est pas paramétrée."); |
3872 |
|
$this->addToMessage($msgErreur); |
3873 |
|
$this->addToLog( |
3874 |
|
sprintf('%s() : %s', __METHOD__, $msgErreur), |
3875 |
|
DEBUG_MODE |
3876 |
|
); |
3877 |
|
return false; |
3878 |
|
} |
3879 |
|
// Préparation de la notification |
3880 |
|
$inst_notif = $this->f->get_inst__om_dbform(array( |
3881 |
|
"obj" => "instruction_notification", |
3882 |
|
"idx" => "]", |
3883 |
|
)); |
3884 |
|
$notif_val = array( |
3885 |
|
'instruction_notification' => null, |
3886 |
|
'instruction' => $idInstruction, |
3887 |
|
'automatique' => $demandeAuto, |
3888 |
|
'emetteur' => $emetteur, |
3889 |
|
'date_envoi' => null, |
3890 |
|
'destinataire' => $destinataire['destinataire'], |
3891 |
|
'courriel' => $destinataire['courriel'], |
3892 |
|
'date_premier_acces' => null, |
3893 |
|
'statut' => $statut, |
3894 |
|
'commentaire' => $commentaire |
3895 |
|
); |
3896 |
|
|
3897 |
|
// Création de la notification |
3898 |
|
$add_notif = $inst_notif->ajouter($notif_val); |
3899 |
|
if ($add_notif === false) { |
3900 |
|
$this->addToMessage(__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).")); |
3901 |
|
$this->addToLog( |
3902 |
|
sprintf( |
3903 |
|
'%s() : %s %s : %s', |
3904 |
|
__METHOD__, |
3905 |
|
__("Echec de l'ajout de la notification en base de données."), |
3906 |
|
__('Paramétrage de la notification'), |
3907 |
|
var_export($notif_val, true) |
3908 |
|
), |
3909 |
|
DEBUG_MODE |
3910 |
|
); |
3911 |
|
return false; |
3912 |
|
} |
3913 |
|
|
3914 |
|
// Si il y a une lettretype finalisé stockage de la clé d'accès au documents |
3915 |
|
if ($this->evenement_has_an_edition($this->getVal('evenement')) === true) { |
3916 |
|
$add_notif_doc = $this->ajouter_notification_document( |
3917 |
|
$inst_notif->getVal($inst_notif->clePrimaire), |
3918 |
|
$this->getVal($this->clePrimaire), |
3919 |
|
'instruction' |
3920 |
|
); |
3921 |
|
if ($add_notif_doc === false) { |
3922 |
|
$this->addToMessage(__("Erreur lors de la génération de la notification du document.")); |
3923 |
|
return false; |
3924 |
} |
} |
3925 |
if ($row['regle_donnees_techniques5'] !== '') { |
} |
3926 |
$valF_dt[$row['cible_regle_donnees_techniques5']] = $this->regle($row['regle_donnees_techniques5'], 'regle_donnees_techniques5'); |
// Si une annexe a été choisie stockage de la clé d'accès à l'annexe |
3927 |
|
if (! empty($annexes) && is_array($annexes)) { |
3928 |
|
$add_notif_annexe = $this->ajouter_notification_document_multiple( |
3929 |
|
$inst_notif->getVal($inst_notif->clePrimaire), |
3930 |
|
$annexes |
3931 |
|
); |
3932 |
|
if ($add_notif_annexe === false) { |
3933 |
|
$this->addToMessage(__("Erreur lors de la génération de la notification de l'annexe.")); |
3934 |
|
return false; |
3935 |
} |
} |
3936 |
} |
} |
3937 |
// Si des valeurs de données techniques ont été calculées alors on met à jour l'enregistrement |
|
3938 |
if ($valF_dt != "") { |
// Renvoie l'id de la nouvelle instance de instruction_notification |
3939 |
$dt_id = $this->getDonneesTechniques(); |
return $inst_notif->getVal($inst_notif->clePrimaire); |
3940 |
// On met à jour le dossier |
} |
3941 |
$cle = " donnees_techniques='".$dt_id."'"; |
|
3942 |
$res1 = $db->autoExecute(DB_PREFIXE.'donnees_techniques', $valF_dt, DB_AUTOQUERY_UPDATE, $cle); |
/** |
3943 |
$this->addToLog("triggerajouterapres(): db->autoexecute(\"".DB_PREFIXE."donnees_techniques\", ".print_r($valF_dt, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
* Pour chaque élément du tableau passé en paramètre ajoute une nouvelle |
3944 |
if (database::isError($res1)) { |
* instance dans la table instruction_notification_document lié a la |
3945 |
die($res->getMessage()); |
* notification dont l'id est passé en paramètre. |
3946 |
|
* |
3947 |
|
* @param array tableau contenant les informations nécessaires pour créer les annexes |
3948 |
|
* |
3949 |
|
* @return integer|boolean identifiant de la notification créée si le traitement |
3950 |
|
* a réussie, false sinon. |
3951 |
|
*/ |
3952 |
|
protected function ajouter_notification_document_multiple($idNotification, $listeDocument) { |
3953 |
|
foreach ($listeDocument as $paramDoc) { |
3954 |
|
if (! $this->ajouter_notification_document($idNotification, $paramDoc['id'], $paramDoc['tableDocument'], $paramDoc['isAnnexe'])) { |
3955 |
|
$this->addToMessage(__("Erreur lors de la génération des documents à notifier.")); |
3956 |
|
return false; |
3957 |
} |
} |
|
// Affichage d'informations à l'utilisateur |
|
|
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
|
3958 |
} |
} |
3959 |
// Si des valeurs ont été calculées alors on met à jour l'enregistrement |
return true; |
3960 |
if ($valF != "") { |
} |
3961 |
// On met à jour le dossier |
|
3962 |
$cle = " dossier='".$this->valF['dossier']."'"; |
/** |
3963 |
$res1 = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle); |
* Ajoute un élément dans la table instruction_notification_document en utilisant |
3964 |
$this->addToLog("triggermodifierapres(): db->autoexecute(\"".DB_PREFIXE."dossier\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
* les éléments fourni en paramètre |
3965 |
if (database::isError($res1)) { |
* |
3966 |
die($res->getMessage()); |
* @param integer $idNotification : id de la notification à laquelle on associe le document |
3967 |
|
* @param integer $idDocument : id de l'objet auquel est rattaché le document |
3968 |
|
* @param string $tableDocument : nom de la table a laquelle est rattaché le document |
3969 |
|
* @param boolean $isAnnexe : indique si le document est une annexe ou pas |
3970 |
|
* |
3971 |
|
* @return boolean indique si le traitement a réussi |
3972 |
|
*/ |
3973 |
|
protected function ajouter_notification_document($idNotification, $idDocument, $tableDocument, $isAnnexe = false) { |
3974 |
|
$inst_notif_doc = $this->f->get_inst__om_dbform(array( |
3975 |
|
"obj" => "instruction_notification_document", |
3976 |
|
"idx" => "]", |
3977 |
|
)); |
3978 |
|
// l'attribut instruction doit obligatoirement être renseigné |
3979 |
|
// pour éviter toutes confusion avec d'autres instruction l'id |
3980 |
|
// 0 est donné au document n'appartenant pas aux instructions |
3981 |
|
$notif_doc_val = array( |
3982 |
|
'instruction_notification_document' => null, |
3983 |
|
'instruction_notification' => $idNotification, |
3984 |
|
'instruction' => $tableDocument == 'instruction' ? $idDocument : 0, |
3985 |
|
'document_type' => $tableDocument, |
3986 |
|
'document_id' => $idDocument, |
3987 |
|
'cle' => $this->getCleAccesDocument(), |
3988 |
|
'annexe' => $isAnnexe |
3989 |
|
); |
3990 |
|
|
3991 |
|
$add_notif_doc = $inst_notif_doc->ajouter($notif_doc_val); |
3992 |
|
if ($add_notif_doc === false) { |
3993 |
|
$this->addToLog( |
3994 |
|
sprintf( |
3995 |
|
'%s() : %s %s : %s', |
3996 |
|
__METHOD__, |
3997 |
|
__('Echec de l\'ajout du paramétrage du document notifié en base de données.'), |
3998 |
|
__('Paramétrage du document'), |
3999 |
|
var_export($notif_doc_val, true) |
4000 |
|
), |
4001 |
|
DEBUG_MODE |
4002 |
|
); |
4003 |
|
return false; |
4004 |
|
} |
4005 |
|
return true; |
4006 |
|
} |
4007 |
|
|
4008 |
|
/** |
4009 |
|
* Vérifie si le paramétrage de la notification des demandeurs est correct. |
4010 |
|
* |
4011 |
|
* @param integer identifiant de la collectivité |
4012 |
|
* @return boolean |
4013 |
|
*/ |
4014 |
|
protected function is_parametrage_notification_correct($collectiviteId) { |
4015 |
|
$categorie = $this->f->get_param_option_notification($collectiviteId); |
4016 |
|
$urlAccesNotif = $this->f->get_parametre_notification_url_acces($collectiviteId); |
4017 |
|
if ($categorie === 'mail' && $urlAccesNotif === null) { |
4018 |
|
return false; |
4019 |
|
} |
4020 |
|
return true; |
4021 |
|
} |
4022 |
|
|
4023 |
|
/** |
4024 |
|
* TRIGGER - triggermodifierapres. |
4025 |
|
* |
4026 |
|
* @return boolean |
4027 |
|
*/ |
4028 |
|
function triggermodifierapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
4029 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
4030 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite($val['dossier']); |
4031 |
|
$message = ''; |
4032 |
|
|
4033 |
|
// Définit si le dossier d'instruction doit être mis à jour |
4034 |
|
$update_dossier = true; |
4035 |
|
// Les actions de mise à jour des dates ne doivent pas appliquer |
4036 |
|
// l'action de l'événement et donc ne pas mettre à jour le dossier |
4037 |
|
if ($this->getParameter("maj") == 125 |
4038 |
|
|| $this->getParameter("maj") == 170 |
4039 |
|
|| $this->getParameter("maj") == 175) { |
4040 |
|
$update_dossier = false; |
4041 |
|
} |
4042 |
|
|
4043 |
|
// Traitement en cas de mise à jour du dossier |
4044 |
|
if ($update_dossier === true) { |
4045 |
|
/** |
4046 |
|
* L'objectif ici est d'effectuer les recalculs de date dans le dossier |
4047 |
|
* si la date de l'evenement est modifiee |
4048 |
|
*/ |
4049 |
|
// Initialisation |
4050 |
|
$valF = array(); |
4051 |
|
$valF_dt = array(); |
4052 |
|
// Initialisation du type d'événement |
4053 |
|
$type_evmt = ""; |
4054 |
|
// Récupération de l'action correspondante à l'événement |
4055 |
|
$evenement = $this->f->get_inst__om_dbform(array( |
4056 |
|
"obj" => "evenement", |
4057 |
|
"idx" => $this->valF['evenement'] |
4058 |
|
)); |
4059 |
|
|
4060 |
|
// Récupération des paramètres de l'action |
4061 |
|
$sql = sprintf( |
4062 |
|
'SELECT |
4063 |
|
* |
4064 |
|
FROM |
4065 |
|
%1$saction |
4066 |
|
WHERE |
4067 |
|
action = \'%2$s\'', |
4068 |
|
DB_PREFIXE, |
4069 |
|
$this->f->db->escapeSimple($evenement->getVal('action')) |
4070 |
|
); |
4071 |
|
$res = $this->f->db->query($sql); |
4072 |
|
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
4073 |
|
$this->f->isDatabaseError($res); |
4074 |
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
4075 |
|
// application des regles sur le courrier + delai |
4076 |
|
if(preg_match("/date_evenement/",$row['regle_date_limite'])){ |
4077 |
|
$valF['date_limite']= $this->regle($row['regle_date_limite'], 'regle_date_limite'); |
4078 |
|
} |
4079 |
|
if(preg_match("/date_evenement/",$row['regle_date_complet'])){ |
4080 |
|
$valF['date_complet']= $this->regle($row['regle_date_complet'], 'regle_date_complet'); |
4081 |
|
} |
4082 |
|
if(preg_match("/date_evenement/",$row['regle_date_dernier_depot'])){ |
4083 |
|
$valF['date_dernier_depot']= $this->regle($row['regle_date_dernier_depot'], 'regle_date_dernier_depot'); |
4084 |
|
} |
4085 |
|
if(preg_match("/date_evenement/",$row['regle_date_notification_delai'])){ |
4086 |
|
$valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai'], 'regle_date_notification_delai'); |
4087 |
|
} |
4088 |
|
if(preg_match("/date_evenement/",$row['regle_date_decision'])){ |
4089 |
|
$valF['date_decision']= $this->regle($row['regle_date_decision'], 'regle_date_decision'); |
4090 |
|
} |
4091 |
|
if(preg_match("/date_evenement/",$row['regle_date_rejet'])){ |
4092 |
|
$valF['date_rejet']= $this->regle($row['regle_date_rejet'], 'regle_date_rejet'); |
4093 |
|
} |
4094 |
|
if(preg_match("/date_evenement/",$row['regle_date_validite'])){ |
4095 |
|
$valF['date_validite']= $this->regle($row['regle_date_validite'], 'regle_date_validite'); |
4096 |
|
} |
4097 |
|
if(preg_match("/date_evenement/",$row['regle_date_chantier'])){ |
4098 |
|
$valF['date_chantier']= $this->regle($row['regle_date_chantier'], 'regle_date_chantier'); |
4099 |
|
} |
4100 |
|
if(preg_match("/date_evenement/",$row['regle_date_achevement'])){ |
4101 |
|
$valF['date_achevement']= $this->regle($row['regle_date_achevement'], 'regle_date_achevement'); |
4102 |
|
} |
4103 |
|
if(preg_match("/date_evenement/",$row['regle_date_conformite'])){ |
4104 |
|
$valF['date_conformite']= $this->regle($row['regle_date_conformite'], 'regle_date_conformite'); |
4105 |
|
} |
4106 |
|
if(preg_match("/date_evenement/",$row['regle_date_cloture_instruction'])){ |
4107 |
|
$valF['date_cloture_instruction']= $this->regle($row['regle_date_cloture_instruction'], 'regle_date_cloture_instruction'); |
4108 |
|
} |
4109 |
|
if(preg_match("/date_evenement/",$row['regle_date_premiere_visite'])){ |
4110 |
|
$valF['date_premiere_visite']= $this->regle($row['regle_date_premiere_visite'], 'regle_date_premiere_visite'); |
4111 |
|
} |
4112 |
|
if(preg_match("/date_evenement/",$row['regle_date_derniere_visite'])){ |
4113 |
|
$valF['date_derniere_visite']= $this->regle($row['regle_date_derniere_visite'], 'regle_date_derniere_visite'); |
4114 |
|
} |
4115 |
|
if(preg_match("/date_evenement/",$row['regle_date_contradictoire'])){ |
4116 |
|
$valF['date_contradictoire']= $this->regle($row['regle_date_contradictoire'], 'regle_date_contradictoire'); |
4117 |
|
} |
4118 |
|
if(preg_match("/date_evenement/",$row['regle_date_retour_contradictoire'])){ |
4119 |
|
$valF['date_retour_contradictoire']= $this->regle($row['regle_date_retour_contradictoire'], 'regle_date_retour_contradictoire'); |
4120 |
|
} |
4121 |
|
if(preg_match("/date_evenement/",$row['regle_date_ait'])){ |
4122 |
|
$valF['date_ait']= $this->regle($row['regle_date_ait'], 'regle_date_ait'); |
4123 |
|
} |
4124 |
|
if(preg_match("/date_evenement/",$row['regle_date_transmission_parquet'])){ |
4125 |
|
$valF['date_transmission_parquet']= $this->regle($row['regle_date_transmission_parquet'], 'regle_date_transmission_parquet'); |
4126 |
|
} |
4127 |
|
if ($row['regle_donnees_techniques1'] !== '') { |
4128 |
|
$valF_dt[$row['cible_regle_donnees_techniques1']] = $this->regle($row['regle_donnees_techniques1'], 'regle_donnees_techniques1'); |
4129 |
|
} |
4130 |
|
if ($row['regle_donnees_techniques2'] !== '') { |
4131 |
|
$valF_dt[$row['cible_regle_donnees_techniques2']] = $this->regle($row['regle_donnees_techniques2'], 'regle_donnees_techniques2'); |
4132 |
|
} |
4133 |
|
if ($row['regle_donnees_techniques3'] !== '') { |
4134 |
|
$valF_dt[$row['cible_regle_donnees_techniques3']] = $this->regle($row['regle_donnees_techniques3'], 'regle_donnees_techniques3'); |
4135 |
|
} |
4136 |
|
if ($row['regle_donnees_techniques4'] !== '') { |
4137 |
|
$valF_dt[$row['cible_regle_donnees_techniques4']] = $this->regle($row['regle_donnees_techniques4'], 'regle_donnees_techniques4'); |
4138 |
|
} |
4139 |
|
if ($row['regle_donnees_techniques5'] !== '') { |
4140 |
|
$valF_dt[$row['cible_regle_donnees_techniques5']] = $this->regle($row['regle_donnees_techniques5'], 'regle_donnees_techniques5'); |
4141 |
|
} |
4142 |
|
if ($row['regle_dossier_instruction_type'] !== '') { |
4143 |
|
$valF['dossier_instruction_type'] = $this->regle($row['regle_dossier_instruction_type'], 'regle_dossier_instruction_type'); |
4144 |
|
} |
4145 |
|
} |
4146 |
|
// Si des valeurs de données techniques ont été calculées alors on met à jour l'enregistrement |
4147 |
|
if (count($valF_dt) > 0) { |
4148 |
|
$dt_id = $this->getDonneesTechniques(); |
4149 |
|
// On met à jour le dossier |
4150 |
|
$cle = " donnees_techniques='".$dt_id."'"; |
4151 |
|
$res1 = $this->f->db->autoExecute(DB_PREFIXE.'donnees_techniques', $valF_dt, DB_AUTOQUERY_UPDATE, $cle); |
4152 |
|
$this->addToLog( |
4153 |
|
__METHOD__."(): db->autoexecute(\"".DB_PREFIXE."donnees_techniques\", ".print_r($valF_dt, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", |
4154 |
|
VERBOSE_MODE |
4155 |
|
); |
4156 |
|
$this->f->isDatabaseError($res1); |
4157 |
|
// Affichage d'informations à l'utilisateur |
4158 |
|
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$this->f->db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
4159 |
|
} |
4160 |
|
// Si des valeurs ont été calculées alors on met à jour l'enregistrement |
4161 |
|
if (count($valF) > 0) { |
4162 |
|
$inst_dossier = $this->f->get_inst__om_dbform(array( |
4163 |
|
"obj" => "dossier", |
4164 |
|
"idx" => $this->valF['dossier'], |
4165 |
|
)); |
4166 |
|
$valF['instruction'] = $id; |
4167 |
|
$valF['crud'] = 'update'; |
4168 |
|
$update_by_instruction = $inst_dossier->update_by_instruction($valF); |
4169 |
|
if ($update_by_instruction === false) { |
4170 |
|
$this->cleanMessage(); |
4171 |
|
$this->addToMessage(sprintf('%s %s', __("Une erreur s'est produite lors de la mise à jour du dossier d'instruction."), __("Veuillez contacter votre administrateur."))); |
4172 |
|
return false; |
4173 |
|
} |
4174 |
|
// Affichage d'informations à l'utilisateur |
4175 |
|
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$this->f->db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
4176 |
} |
} |
|
// Affichage d'informations à l'utilisateur |
|
|
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
|
4177 |
} |
} |
4178 |
|
|
4179 |
|
// Par défaut les instructions à ajouter suite à la saisie d'une date |
4180 |
|
// de retour signature ou de notification, utilisent l'action 0 |
4181 |
|
// Si la création d'événement d'instruction suivant est déclenchée par |
4182 |
|
// une notification suite au traitement d'une tâche (démat') alors l'ajout |
4183 |
|
// de la nouvelle instruction se fait avec l'action 176 |
4184 |
|
// Cela permet de ne pas contrôler la restriction lors de l'ajout de la |
4185 |
|
// nouvelle instruction, depuis la méthode verifier() |
4186 |
|
$code_action_add = 0; |
4187 |
|
if ($this->getParameter("maj") == 175) { |
4188 |
|
$code_action_add = 176; |
4189 |
|
} |
4190 |
$restriction = $this->get_restriction($val['evenement']); |
$restriction = $this->get_restriction($val['evenement']); |
4191 |
$this->restriction_valid = $this->restrictionIsValid($restriction); |
$this->restriction_valid = $this->restrictionIsValid($restriction); |
4192 |
|
|
4194 |
// 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é |
4195 |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
4196 |
WHERE evenement=".$this->valF['evenement']; |
WHERE evenement=".$this->valF['evenement']; |
4197 |
$res = $db->query($sql); |
$res = $this->f->db->query($sql); |
4198 |
$this->addToLog("triggermodifierapres(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
4199 |
if (database::isError($res)) { |
$this->f->isDatabaseError($res); |
|
die($res->getMessage()); |
|
|
} |
|
4200 |
$current_id = $this->getVal($this->clePrimaire); |
$current_id = $this->getVal($this->clePrimaire); |
4201 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
4202 |
// Si la date de retour signature est éditée on vérifie si il existe un événement automatique |
// Si la date de retour signature est éditée on vérifie si il existe un événement automatique |
4203 |
if ($this->getVal('date_retour_signature') == "" AND |
if ($this->getVal('date_retour_signature') == "" AND |
4204 |
$this->valF['date_retour_signature'] != "" AND |
$this->valF['date_retour_signature'] != "" AND |
4205 |
$row['evenement_retour_signature'] != "") { |
$row['evenement_retour_signature'] != "") { |
4206 |
$new_instruction = new instruction("]", $db, $DEBUG); |
$new_instruction = $this->f->get_inst__om_dbform(array( |
4207 |
|
"obj" => "instruction", |
4208 |
|
"idx" => "]", |
4209 |
|
)); |
4210 |
// Création d'un tableau avec la liste des champs de l'instruction |
// Création d'un tableau avec la liste des champs de l'instruction |
4211 |
foreach($new_instruction->champs as $champ) { |
foreach($new_instruction->champs as $champ) { |
4212 |
$valNewInstr[$champ] = ""; |
$valNewInstr[$champ] = ""; |
4222 |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
4223 |
$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']); |
4224 |
$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']); |
4225 |
$new_instruction->setParameter("maj", 0); |
$new_instruction->setParameter("maj", $code_action_add); |
4226 |
$new_instruction->class_actions[0]["identifier"] = |
$new_instruction->class_actions[$code_action_add]["identifier"] = |
4227 |
"retour signature de l'instruction $current_id"; |
sprintf( |
4228 |
$retour = $new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
__("Ajout suite au retour signature de l'instruction %s"), |
4229 |
|
$current_id |
4230 |
|
); |
4231 |
|
$retour = $new_instruction->ajouter($valNewInstr); |
4232 |
|
|
4233 |
//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 |
4234 |
//de restriction |
//de restriction |
4235 |
if ($retour == false && !$new_instruction->restriction_valid){ |
if ($retour == false && !$new_instruction->restriction_valid){ |
4236 |
$error_message = $this->get_restriction_error_message($restriction); |
$error_message = $this->get_restriction_error_message($restriction); |
4237 |
$this->f->displayMessage("error", $error_message); |
$this->f->displayMessage("error", $error_message); |
4238 |
$this->addToLog("triggermodifierapres() : evenement retour ". |
$this->addToLog(__METHOD__."(): evenement retour ". |
4239 |
"instruction ".$this->valF[$this->clePrimaire]." : ". |
"instruction ".$this->valF[$this->clePrimaire]." : ". |
4240 |
$new_instruction->msg); |
$new_instruction->msg); |
4241 |
} |
} |
4251 |
$this->valF['date_retour_rar'] != "") { |
$this->valF['date_retour_rar'] != "") { |
4252 |
|
|
4253 |
if($row['evenement_retour_ar'] != "") { |
if($row['evenement_retour_ar'] != "") { |
4254 |
$new_instruction = new instruction("]", $db, $DEBUG); |
$new_instruction = $this->f->get_inst__om_dbform(array( |
4255 |
|
"obj" => "instruction", |
4256 |
|
"idx" => "]", |
4257 |
|
)); |
4258 |
// Création d'un tableau avec la liste des champs de l'instruction |
// Création d'un tableau avec la liste des champs de l'instruction |
4259 |
foreach($new_instruction->champs as $champ) { |
foreach($new_instruction->champs as $champ) { |
4260 |
$valNewInstr[$champ] = ""; |
$valNewInstr[$champ] = ""; |
4270 |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
4271 |
$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']); |
4272 |
$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']); |
4273 |
$new_instruction->setParameter("maj", 0); |
$new_instruction->setParameter("maj", $code_action_add); |
4274 |
$new_instruction->class_actions[0]["identifier"] = |
$new_instruction->class_actions[$code_action_add]["identifier"] = |
4275 |
"retour RAR de l'instruction $current_id"; |
sprintf(__("Ajout suite à la notification de l'instruction %s"), $current_id); |
4276 |
$retour = $new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
$retour = $new_instruction->ajouter($valNewInstr); |
4277 |
|
|
4278 |
//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 |
4279 |
//de restriction |
//de restriction |
4281 |
$error_message = $this->get_restriction_error_message($restriction); |
$error_message = $this->get_restriction_error_message($restriction); |
4282 |
$this->f->displayMessage("error", $error_message); |
$this->f->displayMessage("error", $error_message); |
4283 |
$this->addToLog( |
$this->addToLog( |
4284 |
"triggermodifierapres() : evenement retour instruction ". |
__METHOD__."(): evenement retour instruction ". |
4285 |
$this->valF[$this->clePrimaire]." : ". |
$this->valF[$this->clePrimaire]." : ". |
4286 |
$new_instruction->msg |
$new_instruction->msg |
4287 |
); |
); |
4293 |
return false; |
return false; |
4294 |
} |
} |
4295 |
} |
} |
4296 |
// Mise à jour du flag incomplet_notifie dans dossier si la |
} |
4297 |
// date limite d'instruction n'est pas dépassée |
} |
4298 |
if($row['type']=='incompletude' && |
} |
4299 |
($this->valF['archive_date_notification_delai'] >= $this->valF['date_retour_rar'] || |
|
4300 |
$this->valF['archive_date_notification_delai'] == "")) { |
// Traitement en cas de mise à jour du dossier |
4301 |
$valFIncomp['incomplet_notifie'] = true; |
if ($update_dossier === true) { |
4302 |
$cle = " dossier='".$val['dossier']."'"; |
/** |
4303 |
$resIncomp = $db->autoExecute( |
* Mise à jour de la date de dernière modification du dossier |
4304 |
DB_PREFIXE.'dossier', |
* d'instruction |
4305 |
$valFIncomp, |
*/ |
4306 |
DB_AUTOQUERY_UPDATE, |
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
4307 |
$cle |
$inst_di->update_last_modification_date(); |
4308 |
|
|
4309 |
|
// Mise à jour des données du dossier d'autorisation |
4310 |
|
$da = $this->f->get_inst__om_dbform(array( |
4311 |
|
"obj" => "dossier_autorisation", |
4312 |
|
"idx" => $this->getNumDemandeAutorFromDossier($this->valF['dossier']), |
4313 |
|
)); |
4314 |
|
$params = array( |
4315 |
|
'di_id' => $this->getVal('dossier'), |
4316 |
|
); |
4317 |
|
if($da->majDossierAutorisation($params) === false) { |
4318 |
|
$this->addToMessage(_("Erreur lors de la mise a jour des donnees du dossier d'autorisation. Contactez votre administrateur.")); |
4319 |
|
$this->correct = false; |
4320 |
|
return false; |
4321 |
|
} |
4322 |
|
} |
4323 |
|
|
4324 |
|
// mise à jour des métadonnées issues des dates de suivi |
4325 |
|
$dateRetourSignatureModified = ($this->valF['date_retour_signature'] != $this->getVal('date_retour_signature')); |
4326 |
|
$dateRetourRARModified = ($this->valF['date_retour_rar'] != $this->getVal('date_retour_rar')); |
4327 |
|
if ($dateRetourSignatureModified || $dateRetourRARModified) { |
4328 |
|
|
4329 |
|
// Calculs des nouvelles métadonnées |
4330 |
|
$metadata = $this->getMetadata("om_fichier_instruction"); |
4331 |
|
|
4332 |
|
// On vérifie si l'instruction à finaliser a un événement de type arrete |
4333 |
|
// TODO : A voir pour remplacer par une instanciation de l'événement. |
4334 |
|
// Voir également si l'événement ne dois pas être instancié en début de |
4335 |
|
// méthode pour pouvoir être réutilisé. |
4336 |
|
$qres = $this->f->get_one_result_from_db_query( |
4337 |
|
sprintf( |
4338 |
|
'SELECT |
4339 |
|
type |
4340 |
|
FROM |
4341 |
|
%1$sevenement |
4342 |
|
WHERE |
4343 |
|
evenement = \'%2$d\'', |
4344 |
|
DB_PREFIXE, |
4345 |
|
intval($this->getVal("evenement")) |
4346 |
|
), |
4347 |
|
array( |
4348 |
|
"origin" => __METHOD__, |
4349 |
|
"force_return" => true, |
4350 |
|
) |
4351 |
|
); |
4352 |
|
|
4353 |
|
if ($qres["code"] !== "OK") { |
4354 |
|
$this->correct = false; |
4355 |
|
$this->addToMessage(__("Erreur de traitement de fichier.")); |
4356 |
|
$this->addToLog(__METHOD__."() erreur BDD: ".var_export($qres['message'], true), DEBUG_MODE); |
4357 |
|
return false; |
4358 |
|
} |
4359 |
|
|
4360 |
|
// Si l'événement est de type arrete, on ajoute les métadonnées spécifiques |
4361 |
|
if ($qres['result'] == 'arrete'){ |
4362 |
|
$metadata = array_merge($metadata, $this->getMetadata("arrete")); |
4363 |
|
} |
4364 |
|
|
4365 |
|
// Filtre pour conserver uniquement les métadonnées liées aux dates |
4366 |
|
$metadataToKeep = array( |
4367 |
|
"statutAutorisation", |
4368 |
|
"dateEvenementDocument", |
4369 |
|
'date_cloture_metier', |
4370 |
|
"NotificationArrete", |
4371 |
|
"dateNotificationArrete", |
4372 |
|
"controleLegalite", |
4373 |
|
"dateSignature", |
4374 |
|
"nomSignataire", |
4375 |
|
"qualiteSignataire", |
4376 |
|
"dateControleLegalite", |
4377 |
|
); |
4378 |
|
$metadata = array_filter( |
4379 |
|
$metadata, |
4380 |
|
function($key) use ($metadataToKeep) { return in_array($key, $metadataToKeep); }, |
4381 |
|
ARRAY_FILTER_USE_KEY |
4382 |
|
); |
4383 |
|
|
4384 |
|
// Mise à jour des métadonnées du document en GED |
4385 |
|
$docUid = $this->getVal("om_fichier_instruction"); |
4386 |
|
$operationOrUID = $this->f->storage->update_metadata($docUid, $metadata); |
4387 |
|
if ($operationOrUID == 'OP_FAILURE') { |
4388 |
|
$this->correct = false; |
4389 |
|
$this->addToMessage(__("Erreur de traitement de fichier.")); |
4390 |
|
$this->addToLog(__METHOD__."() failed to update metadata: ".var_export($operationOrUID, true), DEBUG_MODE); |
4391 |
|
return false; |
4392 |
|
} |
4393 |
|
|
4394 |
|
// mise à jour de l'UID du document en BDD |
4395 |
|
else { |
4396 |
|
$valF = array('om_fichier_instruction' => $operationOrUID); |
4397 |
|
$res = $this->f->db->autoExecute(DB_PREFIXE.$this->table, $valF, DB_AUTOQUERY_UPDATE, $this->getCle($id)); |
4398 |
|
$this->addToLog(__METHOD__.'() : db->autoExecute("'.DB_PREFIXE.$this->table.'", '.print_r($valF, true).', DB_AUTOQUERY_UPDATE, "'.$this->getCle($id).'")', VERBOSE_MODE); |
4399 |
|
if ($this->f->isDatabaseError($res, true) === true) { |
4400 |
|
$this->correct = false; |
4401 |
|
$this->addToMessage(__("Erreur de traitement de fichier.")); |
4402 |
|
$this->addToLog(__METHOD__."() erreur BDD: ".var_export($res->getMessage(), true), DEBUG_MODE); |
4403 |
|
return false; |
4404 |
|
} |
4405 |
|
$this->addToMessage(__("La mise a jour du document s'est effectuee avec succes.")); |
4406 |
|
} |
4407 |
|
} |
4408 |
|
|
4409 |
|
// Déclenchement des notifications automatique après finalisation et |
4410 |
|
// retour de signature |
4411 |
|
if ($dateRetourSignatureModified === true |
4412 |
|
&& $this->valF['date_retour_signature'] !== '' |
4413 |
|
&& $this->valF['date_retour_signature'] !== null) { |
4414 |
|
|
4415 |
|
// Message à afficher dans les logs pour indiquer quelle notification a échouée |
4416 |
|
$msgLog = sprintf( |
4417 |
|
'%s %s : %d', |
4418 |
|
__('Erreur lors de la notification automatique du(des) pétitionnaire(s) après retour signature.'), |
4419 |
|
__('Instruction notifiée'), |
4420 |
|
$id |
4421 |
|
); |
4422 |
|
|
4423 |
|
// Récupération de l'instance de l'événement pour accéder au paramètrage |
4424 |
|
// des notifications |
4425 |
|
$ev = $this->get_inst_evenement($this->valF['evenement']); |
4426 |
|
// Si la notification automatique des tiers consulté est active |
4427 |
|
// déclenche le traitement de notification. |
4428 |
|
// Ce traitement va envoyer des courriels de notification à tous les tiers concernés |
4429 |
|
$typeNotifTiers = $ev->getVal('notification_tiers'); |
4430 |
|
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
4431 |
|
if ($typeNotifTiers === 'notification_automatique') { |
4432 |
|
if ($this->traitement_notification_automatique_tiers_consulte($ev, $inst_di) === false) { |
4433 |
|
$this->addToMessage(__('Le traitement de la notification automatique de tiers à échoué.')); |
4434 |
|
$this->correct = false; |
4435 |
|
} |
4436 |
|
} |
4437 |
|
|
4438 |
|
if ($ev->getVal('notification') === 'notification_auto_signature_requise') { |
4439 |
|
// Récupération de la liste des demandeurs à notifier et de la catégorie |
4440 |
|
$categorie = $this->f->get_param_option_notification($collectivite_di); |
4441 |
|
$isPortal = $categorie === PORTAL; |
4442 |
|
$demandeursANotifie = $this->get_demandeurs_notifiable( |
4443 |
|
$this->valF['dossier'], |
4444 |
|
$isPortal |
4445 |
|
); |
4446 |
|
|
4447 |
|
// Création d'une notification et d'une tâche pour chaque demandeur à notifier |
4448 |
|
$demandeurPrincipalNotifie = false; |
4449 |
|
foreach ($demandeursANotifie as $demandeur) { |
4450 |
|
// Identifie si le demandeur principal a été notifié ou pas |
4451 |
|
// et récupère ses informations |
4452 |
|
if ($demandeur['petitionnaire_principal'] == 't') { |
4453 |
|
$demandeurPrincipalNotifie = true; |
4454 |
|
// Si le demandeur principal est notifiable mais qu'il y a des erreurs dans |
4455 |
|
// son paramétrage, on effectue pas le traitement et on passe à l'itération |
4456 |
|
// suivante. On le considère également comme non notifié pour gérer l'envoie |
4457 |
|
// des messages d'erreurs |
4458 |
|
// Si la demande a été déposée via le portail alors le paramétrage n'a pas |
4459 |
|
// d'impact sur la notification |
4460 |
|
$erreursParam = $this->get_info_notification_fail(); |
4461 |
|
if (! $this->dossier_depose_sur_portail() && $erreursParam != array()) { |
4462 |
|
$demandeurPrincipalNotifie = false; |
4463 |
|
continue; |
4464 |
|
} |
4465 |
|
} |
4466 |
|
// Ajout de la notif et récupération de son id |
4467 |
|
$idNotif = $this->ajouter_notification( |
4468 |
|
$this->valF[$this->clePrimaire], |
4469 |
|
$this->f->get_connected_user_login_name(), |
4470 |
|
$demandeur, |
4471 |
|
$collectivite_di, |
4472 |
|
array(), |
4473 |
|
true |
4474 |
|
); |
4475 |
|
if ($idNotif === false) { |
4476 |
|
$this->addToLog( |
4477 |
|
sprintf('%s() : %s',__METHOD__, $msgLog), |
4478 |
|
DEBUG_MODE |
4479 |
); |
); |
4480 |
|
return false; |
4481 |
|
} |
4482 |
|
// Création de la tache en lui donnant l'id de la notification |
4483 |
|
$notification_by_task = $this->notification_by_task( |
4484 |
|
$idNotif, |
4485 |
|
$this->valF['dossier'], |
4486 |
|
$categorie |
4487 |
|
); |
4488 |
|
if ($notification_by_task === false) { |
4489 |
$this->addToLog( |
$this->addToLog( |
4490 |
"triggersupprimer(): db->autoexecute(\"". |
sprintf('%s() : %s',__METHOD__, $msgLog), |
4491 |
DB_PREFIXE."dossier\", ".print_r($valFIncomp, true). |
DEBUG_MODE |
|
", DB_AUTOQUERY_UPDATE, \"".$cle."\");", |
|
|
VERBOSE_MODE |
|
4492 |
); |
); |
4493 |
if (database::isError($resIncomp)) { |
$this->addToMessage( |
4494 |
die($resIncomp->getMessage()); |
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
4495 |
} |
); |
4496 |
|
return false; |
4497 |
} |
} |
4498 |
} |
} |
4499 |
|
// Pour la notification par mail ou la notification via portal si le dossier a |
4500 |
|
// été déposés via portal, si le demandeur principal n'est pas notifiable, |
4501 |
|
// on créé une nouvelle notification en erreur avec en commentaire la raison pour |
4502 |
|
// laquelle le demandeur principal n'a pas pu être notifié |
4503 |
|
$depotPortal = $this->dossier_depose_sur_portail(); |
4504 |
|
if (! $demandeurPrincipalNotifie && ($isPortal === false || $depotPortal === true)) { |
4505 |
|
// Précise dans les logs que le pétitionnaire principal n'a pas été notifié |
4506 |
|
$msgLog .= sprintf(' %s', __('Le pétitionnaire principale n\'est pas notifiable.')); |
4507 |
|
// Analyse pour savoir pourquoi le demandeur principal n'est pas notifiable |
4508 |
|
$erreursParam = $this->get_info_notification_fail(); |
4509 |
|
$demandeurPrincipal = $this->get_info_petitionnaire_principal_dossier($this->getVal('dossier')); |
4510 |
|
// Ajout de la notif et récupération de son id |
4511 |
|
$idNotif = $this->ajouter_notification( |
4512 |
|
$this->valF[$this->clePrimaire], |
4513 |
|
$this->f->get_connected_user_login_name(), |
4514 |
|
$demandeurPrincipal, |
4515 |
|
$collectivite_di, |
4516 |
|
array(), |
4517 |
|
true, |
4518 |
|
'Echec', |
4519 |
|
implode(' ', $erreursParam) |
4520 |
|
); |
4521 |
|
if ($idNotif === false) { |
4522 |
|
$this->addToLog( |
4523 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
4524 |
|
DEBUG_MODE |
4525 |
|
); |
4526 |
|
$this->addToMessage( |
4527 |
|
__('Erreur : la création de la notification a échouée.'). |
4528 |
|
__("Veuillez contacter votre administrateur.") |
4529 |
|
); |
4530 |
|
return false; |
4531 |
|
} |
4532 |
|
// Prépare un message d'alerte à destination de l'instructeur pour l'informer |
4533 |
|
// de l'échec de la notification |
4534 |
|
$dossier_message = $this->get_inst_dossier_message(0); |
4535 |
|
$dossier_message_val = array( |
4536 |
|
'dossier' => $this->getVal('dossier'), |
4537 |
|
'type' => _('erreur expedition'), |
4538 |
|
'emetteur' => $this->f->get_connected_user_login_name(), |
4539 |
|
'login' => $_SESSION['login'], |
4540 |
|
'date_emission' => date('Y-m-d H:i:s'), |
4541 |
|
'contenu' => _('Échec lors de la notification de l\'instruction '). |
4542 |
|
$ev->getVal('libelle'). |
4543 |
|
'.<br>'. |
4544 |
|
implode("\n", $erreursParam). |
4545 |
|
'<br>'. |
4546 |
|
_('Veuillez corriger ces informations avant de renvoyer la notification.') |
4547 |
|
); |
4548 |
|
$add = $dossier_message->add_notification_message($dossier_message_val, true); |
4549 |
|
// Si une erreur se produit pendant l'ajout |
4550 |
|
if ($add !== true) { |
4551 |
|
$this->addToLog( |
4552 |
|
sprintf( |
4553 |
|
'%s() : %s', |
4554 |
|
__METHOD__, |
4555 |
|
__("Le message d'alerte concernant l'echec de l'envoi de la notification n'a pas pu être envoyé.") |
4556 |
|
), |
4557 |
|
DEBUG_MODE |
4558 |
|
); |
4559 |
|
return false; |
4560 |
|
} |
4561 |
|
} |
4562 |
|
$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."))); |
4563 |
} |
} |
4564 |
} |
} |
4565 |
|
|
|
// Mise à jour des données du dossier d'autorisation |
|
|
require_once "../obj/dossier_autorisation.class.php"; |
|
|
$da = new dossier_autorisation($this->getNumDemandeAutorFromDossier($this->valF['dossier']), $this->db, DEBUG); |
|
|
if($da->majDossierAutorisation() === false) { |
|
|
$this->addToMessage(_("Erreur lors de la mise a jour des donnees du dossier d'autorisation. Contactez votre administrateur.")); |
|
|
$this->correct = false; |
|
|
return false; |
|
|
} |
|
4566 |
return $this->add_log_to_dossier($id, $val); |
return $this->add_log_to_dossier($id, $val); |
4567 |
} |
} |
4568 |
|
|
4569 |
function triggersupprimer($id,&$db,$val,$DEBUG) { |
/** |
4570 |
|
* TRIGGER - triggersupprimer. |
4571 |
|
* |
4572 |
|
* @return boolean |
4573 |
|
*/ |
4574 |
|
function triggersupprimer($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
4575 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
4576 |
/** |
/** |
4577 |
* 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 |
4578 |
* archive dans le dossier d'instruction avant de supprimer l'événement |
* archive dans le dossier d'instruction avant de supprimer l'événement |
4579 |
* d'instruction |
* d'instruction si les valeurs du dossier sont différentes |
4580 |
*/ |
*/ |
4581 |
|
$valF = array(); |
4582 |
// Mise à jour des 4 valeurs modifiées par l'action |
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
4583 |
$valF['delai'] = $val['archive_delai']; |
foreach ($inst_di->champs as $key => $champ) { |
4584 |
$valF['accord_tacite'] = $val['archive_accord_tacite']; |
// Si le champ du DI à une archive dans l'instruction |
4585 |
$valF['etat'] = $val['archive_etat']; |
if (isset($val[sprintf('archive_%s', $champ)]) === true) { |
4586 |
if ($val['archive_avis'] != '') { |
// Si la valeur entre le champ du DI et son archive dans instruction |
4587 |
$valF['avis_decision'] = $val['archive_avis']; |
// est différente |
4588 |
} else { |
if ($inst_di->getVal($champ) !== $val[sprintf('archive_%s', $champ)]) { |
4589 |
$valF['avis_decision'] = null; |
$val[sprintf('archive_%s', $champ)] === '' ? $valF[$champ] = null : $valF[$champ] = $val[sprintf('archive_%s', $champ)]; |
4590 |
} |
} |
4591 |
// Mise à jour des dates avec la valeur présente dans le formulaire |
} |
|
// de suppression. Si la valeur de la date est vide alors on fixe |
|
|
// à la valeur null |
|
|
if ($val['archive_date_complet'] != '') { |
|
|
$valF['date_complet'] = $val['archive_date_complet']; |
|
|
} else { |
|
|
$valF['date_complet'] = null; |
|
|
} |
|
|
if ($val['archive_date_dernier_depot'] != '') { |
|
|
$valF['date_dernier_depot'] = $val['archive_date_dernier_depot']; |
|
|
} else { |
|
|
$valF['date_dernier_depot'] = null; |
|
|
} |
|
|
if ($val['archive_date_rejet'] != '') { |
|
|
$valF['date_rejet'] = $val['archive_date_rejet']; |
|
|
} else { |
|
|
$valF['date_rejet'] = null; |
|
|
} |
|
|
if ($val['archive_date_limite'] != '') { |
|
|
$valF['date_limite'] = $val['archive_date_limite']; |
|
|
} else { |
|
|
$valF['date_limite'] = null; |
|
|
} |
|
|
if ($val['archive_date_notification_delai'] != '') { |
|
|
$valF['date_notification_delai'] = $val['archive_date_notification_delai']; |
|
|
} else { |
|
|
$valF['date_notification_delai'] = null; |
|
|
} |
|
|
if ($val['archive_date_decision'] != '') { |
|
|
$valF['date_decision'] = $val['archive_date_decision']; |
|
|
} else { |
|
|
$valF['date_decision'] = null; |
|
|
} |
|
|
if ($val['archive_date_validite'] != '') { |
|
|
$valF['date_validite'] = $val['archive_date_validite']; |
|
|
} else { |
|
|
$valF['date_validite'] = null; |
|
|
} |
|
|
if ($val['archive_date_achevement'] != '') { |
|
|
$valF['date_achevement'] = $val['archive_date_achevement']; |
|
|
} else { |
|
|
$valF['date_achevement'] = null; |
|
|
} |
|
|
if ($val['archive_date_chantier'] != '') { |
|
|
$valF['date_chantier'] = $val['archive_date_chantier']; |
|
|
} else { |
|
|
$valF['date_chantier'] = null; |
|
|
} |
|
|
if ($val['archive_date_conformite'] != '') { |
|
|
$valF['date_conformite'] = $val['archive_date_conformite']; |
|
|
} else { |
|
|
$valF['date_conformite'] = null; |
|
|
} |
|
|
if ($val['archive_incompletude'] != '') { |
|
|
$valF['incompletude'] = $val['archive_incompletude']; |
|
|
} else { |
|
|
$valF['incompletude'] = null; |
|
|
} |
|
|
if ($val['archive_incomplet_notifie'] != '') { |
|
|
$valF['incomplet_notifie'] = $val['archive_incomplet_notifie']; |
|
|
} else { |
|
|
$valF['incomplet_notifie'] = null; |
|
|
} |
|
|
if ($val['archive_evenement_suivant_tacite'] != '') { |
|
|
$valF['evenement_suivant_tacite'] = $val['archive_evenement_suivant_tacite']; |
|
|
} else { |
|
|
$valF['evenement_suivant_tacite'] = null; |
|
|
} |
|
|
if ($val['archive_evenement_suivant_tacite_incompletude'] != '') { |
|
|
$valF['evenement_suivant_tacite_incompletude'] = $val['archive_evenement_suivant_tacite_incompletude']; |
|
|
} else { |
|
|
$valF['evenement_suivant_tacite_incompletude'] = null; |
|
|
} |
|
|
if ($val['archive_etat_pendant_incompletude'] != '') { |
|
|
$valF['etat_pendant_incompletude'] = $val['archive_etat_pendant_incompletude']; |
|
|
} else { |
|
|
$valF['etat_pendant_incompletude'] = null; |
|
|
} |
|
|
if ($val['archive_date_limite_incompletude'] != '') { |
|
|
$valF['date_limite_incompletude'] = $val['archive_date_limite_incompletude']; |
|
|
} else { |
|
|
$valF['date_limite_incompletude'] = null; |
|
|
} |
|
|
if ($val['archive_delai_incompletude'] != '') { |
|
|
$valF['delai_incompletude'] = $val['archive_delai_incompletude']; |
|
|
} else { |
|
|
$valF['delai_incompletude'] = null; |
|
|
} |
|
|
if ($val['archive_autorite_competente'] != '') { |
|
|
$valF['autorite_competente'] = $val['archive_autorite_competente']; |
|
|
} else { |
|
|
$valF['autorite_competente'] = null; |
|
4592 |
} |
} |
4593 |
$valF['date_cloture_instruction'] = null; |
// Spécificité du champ avis_decision dont le champ archive est nommé |
4594 |
if ($val['archive_date_cloture_instruction'] !== '') { |
// différemment |
4595 |
$valF['date_cloture_instruction'] = $val['archive_date_cloture_instruction']; |
if ($inst_di->getVal('avis_decision') !== $val['archive_avis']) { |
4596 |
|
$val['archive_avis'] === '' ? $valF['avis_decision'] = null : $valF['avis_decision'] = $val['archive_avis']; |
4597 |
|
} |
4598 |
|
// Spécificité de la date d'affichage dont la valeur n'ai jamais modifiée |
4599 |
|
// par l'archive |
4600 |
|
unset($valF['date_affichage']); |
4601 |
|
|
4602 |
|
/** |
4603 |
|
* Mise à jour de la version de clôture *version_clos* du dossier si et |
4604 |
|
* seulement si l'instruction met à jour l'état du dossier. |
4605 |
|
*/ |
4606 |
|
if (isset($valF['etat']) === true |
4607 |
|
&& $valF['etat'] !== null |
4608 |
|
&& $valF['etat'] !== '') { |
4609 |
|
// Récupère l'état actuel du dossier d'instruction |
4610 |
|
$inst_current_etat = $this->f->get_inst__om_dbform(array( |
4611 |
|
"obj" => "etat", |
4612 |
|
"idx" => $inst_di->get_id_etat(), |
4613 |
|
)); |
4614 |
|
// Instanciation de l'état archivé appliqué sur le dossier |
4615 |
|
$inst_etat = $this->f->get_inst__om_dbform(array( |
4616 |
|
"obj" => "etat", |
4617 |
|
"idx" => $valF['etat'], |
4618 |
|
)); |
4619 |
|
// |
4620 |
|
$update_version_clos = null; |
4621 |
|
// En cas de clôture du dossier par l'état archivé |
4622 |
|
if ($inst_etat->getVal('statut') === 'cloture') { |
4623 |
|
$update_version_clos = $inst_di->update_version_clos('up'); |
4624 |
|
} |
4625 |
|
// En cas de réouverture du dossier par l'état archivé |
4626 |
|
if ($inst_current_etat->getVal('statut') === 'cloture' |
4627 |
|
&& $inst_etat->getVal('statut') !== 'cloture') { |
4628 |
|
// |
4629 |
|
$update_version_clos = $inst_di->update_version_clos('down'); |
4630 |
|
// |
4631 |
|
$this->set_att_di_reopened(true); |
4632 |
|
} |
4633 |
|
// |
4634 |
|
if ($update_version_clos === false) { |
4635 |
|
$this->f->addToLog(sprintf( |
4636 |
|
"%s() : ERREUR - %s %s", |
4637 |
|
__METHOD__, |
4638 |
|
sprintf( |
4639 |
|
__("Impossible de mettre à jour la version de clôture du dossier d'instruction %s."), |
4640 |
|
$inst_di->getVal($inst_di->clePrimaire) |
4641 |
|
), |
4642 |
|
sprintf( |
4643 |
|
__("L'instruction tente d'appliquer l'état %s."), |
4644 |
|
$inst_etat->getVal($inst_etat->clePrimaire) |
4645 |
|
) |
4646 |
|
)); |
4647 |
|
$this->addToMessage(sprintf( |
4648 |
|
"%s %s", |
4649 |
|
__("Erreur lors de la mise à jour de la version de clôture du dossier d'instruction."), |
4650 |
|
__("Veuillez contacter votre administrateur.") |
4651 |
|
)); |
4652 |
|
return false; |
4653 |
|
} |
4654 |
} |
} |
4655 |
// Dates concernant les dossiers contentieux |
// On supprime toutes les notications liées à l'instruction |
4656 |
// Date de première visite |
$notifASupprimer = $this->get_instruction_notification( |
4657 |
$valF['date_premiere_visite'] = null; |
$this->getVal($this->clePrimaire), |
4658 |
if ($val['archive_date_premiere_visite'] !== '') { |
array( |
4659 |
$valF['date_premiere_visite'] = $val['archive_date_premiere_visite']; |
'notification_recepisse', |
4660 |
} |
'notification_instruction', |
4661 |
// Date de dernière visite |
'notification_decision', |
4662 |
$valF['date_derniere_visite'] = null; |
'notification_service_consulte', |
4663 |
if ($val['archive_date_derniere_visite'] !== '') { |
'notification_tiers_consulte', |
4664 |
$valF['date_derniere_visite'] = $val['archive_date_derniere_visite']; |
'notification_depot_demat', |
4665 |
} |
'notification_commune' |
4666 |
// Date contradictoire |
), |
4667 |
$valF['date_contradictoire'] = null; |
true |
4668 |
if ($val['archive_date_contradictoire'] !== '') { |
); |
4669 |
$valF['date_contradictoire'] = $val['archive_date_contradictoire']; |
|
4670 |
} |
foreach ($notifASupprimer as $idNotif) { |
4671 |
// Date de retour contradictoire |
$inst_notif = $this->f->get_inst__om_dbform(array( |
4672 |
$valF['date_retour_contradictoire'] = null; |
"obj" => "instruction_notification", |
4673 |
if ($val['archive_date_retour_contradictoire'] !== '') { |
"idx" => $idNotif, |
4674 |
$valF['date_retour_contradictoire'] = $val['archive_date_retour_contradictoire']; |
)); |
4675 |
} |
$val_notif = array(); |
4676 |
// Date de l'AIT |
foreach ($inst_notif->champs as $champ) { |
4677 |
$valF['date_ait'] = null; |
$val_notif[$champ] = $inst_notif->getVal($champ); |
4678 |
if ($val['archive_date_ait'] !== '') { |
} |
4679 |
$valF['date_ait'] = $val['archive_date_ait']; |
// La suppression des notifications entrainera la suppression des tâches qui y sont |
4680 |
} |
// liées |
4681 |
// Date de transmission au parquet |
$supprNotif = $inst_notif->supprimer($val_notif); |
4682 |
$valF['date_transmission_parquet'] = null; |
if ($supprNotif == false) { |
4683 |
if ($val['archive_date_transmission_parquet'] !== '') { |
$this->addToMessage(sprintf( |
4684 |
$valF['date_transmission_parquet'] = $val['archive_date_transmission_parquet']; |
"%s %s", |
4685 |
|
__("Erreur lors de la suppression des notifications de l'instruction."), |
4686 |
|
__("Veuillez contacter votre administrateur.") |
4687 |
|
)); |
4688 |
|
return false; |
4689 |
|
} |
4690 |
} |
} |
4691 |
|
|
4692 |
// On met à jour le dossier |
// On met à jour le dossier |
4693 |
$cle = " dossier='".$val['dossier']."'"; |
$valF['instruction'] = $id; |
4694 |
$res = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle); |
$valF['crud'] = 'delete'; |
4695 |
$this->addToLog("triggersupprimer(): db->autoexecute(\"".DB_PREFIXE."dossier\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
$update_by_instruction = $inst_di->update_by_instruction($valF); |
4696 |
if (database::isError($res)) { |
if ($update_by_instruction === false) { |
4697 |
die($res->getMessage()); |
$this->cleanMessage(); |
4698 |
|
$this->addToMessage(sprintf('%s %s', __("Une erreur s'est produite lors de la mise à jour du dossier d'instruction."), __("Veuillez contacter votre administrateur."))); |
4699 |
|
return false; |
4700 |
} |
} |
4701 |
|
|
4702 |
// Affichage d'informations à l'utilisateur |
// Affichage d'informations à l'utilisateur |
4703 |
$this->addToMessage(_("Suppression de l'instruction")." [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
$this->addToMessage(_("Suppression de l'instruction")." [".$this->f->db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
4704 |
|
|
4705 |
// 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 |
4706 |
} |
} |
4707 |
|
|
4708 |
function triggersupprimerapres($id,&$db,$val,$DEBUG) { |
/** |
4709 |
|
* TRIGGER - triggersupprimerapres. |
4710 |
|
* |
4711 |
|
* @return boolean |
4712 |
|
*/ |
4713 |
|
function triggersupprimerapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
4714 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
4715 |
|
/** |
4716 |
|
* Mise à jour de la date de dernière modification du dossier |
4717 |
|
* d'instruction |
4718 |
|
*/ |
4719 |
|
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
4720 |
|
$inst_di->update_last_modification_date(); |
4721 |
|
|
4722 |
// Mise à jour des données du dossier d'autorisation |
/** |
4723 |
require_once "../obj/dossier_autorisation.class.php"; |
* Mise à jour des données du dossier d'autorisation |
4724 |
$da = new dossier_autorisation($this->getNumDemandeAutorFromDossier($val["dossier"]), $this->db, DEBUG); |
*/ |
4725 |
if($da->majDossierAutorisation() === false) { |
$da = $this->f->get_inst__om_dbform(array( |
4726 |
|
"obj" => "dossier_autorisation", |
4727 |
|
"idx" => $this->getNumDemandeAutorFromDossier($val["dossier"]), |
4728 |
|
)); |
4729 |
|
$params = array( |
4730 |
|
'di_id' => $this->getVal('dossier'), |
4731 |
|
'di_reopened' => $this->get_att_di_reopened(), |
4732 |
|
); |
4733 |
|
if($da->majDossierAutorisation($params) === false) { |
4734 |
$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.")); |
4735 |
$this->correct = false; |
$this->correct = false; |
4736 |
return false; |
return false; |
4737 |
} |
} |
4738 |
|
|
4739 |
|
/** |
4740 |
|
* Gestion des tâches pour la dématérialisation |
4741 |
|
*/ |
4742 |
|
$inst_task_empty = $this->f->get_inst__om_dbform(array( |
4743 |
|
"obj" => "task", |
4744 |
|
"idx" => 0, |
4745 |
|
)); |
4746 |
|
foreach ($inst_di->task_types as $task_type) { |
4747 |
|
$task_exists = $inst_task_empty->task_exists($task_type, $id); |
4748 |
|
if ($task_exists !== false) { |
4749 |
|
$inst_task = $this->f->get_inst__om_dbform(array( |
4750 |
|
"obj" => "task", |
4751 |
|
"idx" => $task_exists, |
4752 |
|
)); |
4753 |
|
if ($inst_task->getVal('state') === $inst_task::STATUS_NEW || $inst_task->getVal('state') === $inst_task::STATUS_DRAFT) { |
4754 |
|
$task_val = array( |
4755 |
|
'state' => $inst_task::STATUS_CANCELED, |
4756 |
|
); |
4757 |
|
$update_task = $inst_task->update_task(array('val' => $task_val)); |
4758 |
|
if ($update_task === false) { |
4759 |
|
$this->addToMessage(sprintf('%s %s', |
4760 |
|
sprintf(__("Une erreur s'est produite lors de la modification de la tâche %."), $inst_task->getVal($inst_task->clePrimaire)), |
4761 |
|
__("Veuillez contacter votre administrateur.") |
4762 |
|
)); |
4763 |
|
$this->correct = false; |
4764 |
|
return false; |
4765 |
|
} |
4766 |
|
} |
4767 |
|
} |
4768 |
|
} |
4769 |
|
|
4770 |
|
// |
4771 |
$val['evenement'] = $this->getVal('evenement'); |
$val['evenement'] = $this->getVal('evenement'); |
4772 |
return $this->add_log_to_dossier($id, $val); |
return $this->add_log_to_dossier($id, $val); |
4773 |
} |
} |
4774 |
|
|
4775 |
/** |
/** |
4776 |
|
* Permet de mettre la valeur passée en paramètre dans l'attribut de classe |
4777 |
|
* "di_reopened". |
4778 |
|
* |
4779 |
|
* @param boolean $val |
4780 |
|
*/ |
4781 |
|
function set_att_di_reopened($val) { |
4782 |
|
$this->di_reopened = $val; |
4783 |
|
} |
4784 |
|
|
4785 |
|
/** |
4786 |
|
* Permet de récupérer la valeur de l'attribut de classe "di_reopened". |
4787 |
|
* |
4788 |
|
* @return boolean |
4789 |
|
*/ |
4790 |
|
function get_att_di_reopened() { |
4791 |
|
return $this->di_reopened; |
4792 |
|
} |
4793 |
|
|
4794 |
|
/** |
4795 |
* Permet de composer un message d'erreur sur restriction non valide en |
* Permet de composer un message d'erreur sur restriction non valide en |
4796 |
* fonction du contexte. |
* fonction du contexte. |
4797 |
* |
* |
4830 |
} |
} |
4831 |
|
|
4832 |
/** |
/** |
4833 |
* Vérifie la restriction sur l'événement. |
* Surcharge de la méthode verifier() de la classe om_dbform pour y ajouter |
4834 |
* |
* les vérifications suivantes : |
4835 |
* @param array $val valeurs du formulaire |
* - Si l'instruction à un événement associé et que cet événement à des restrictions : |
4836 |
* @param database $db handler database |
* 1. vérifie si la restriction est valide, si ce n'est pas le cas récupère et affiche |
4837 |
* @param boolean $DEBUG NA |
* le message d'erreur associé à la restriction |
4838 |
|
* 2. vérifie si les restrictions sont respectées. Si ce n'est pas le cas bloque l'ajout |
4839 |
|
* et / ou la modification et affiche un message d'erreur |
4840 |
|
* - |
4841 |
|
* - |
4842 |
|
* - |
4843 |
|
* - |
4844 |
|
* - |
4845 |
|
* - |
4846 |
|
* |
4847 |
|
* @param array val : tableau contenant les valeurs issues du formulaire. |
4848 |
|
* @param - dnu1 : Paramètre déprécié et non utilisé. |
4849 |
|
* @param - dnu2 : Paramètre déprécié et non utilisé. |
4850 |
* |
* |
4851 |
* @return [type] [description] |
* @return void |
4852 |
*/ |
*/ |
4853 |
function verifier($val = array(), &$db, $DEBUG) { |
function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
4854 |
parent::verifier($val, $db, $DEBUG); |
parent::verifier($val); |
4855 |
|
// |
4856 |
if ( isset($val['evenement']) && is_numeric($val['evenement'])){ |
if ( isset($val['evenement']) && is_numeric($val['evenement'])){ |
4857 |
$restriction = $this->get_restriction($val['evenement']); |
$restriction = $this->get_restriction($val['evenement']); |
4858 |
|
|
4859 |
//Test qu'une restriction est présente |
//Test qu'une restriction est présente |
4860 |
if ($restriction != "" ){ |
if ($restriction != "" ){ |
4861 |
|
|
4862 |
//Test si la restriction est valide |
// Vérifie le contexte de la modification et test si la restriction est valide. |
4863 |
|
// Si l'instruction est modifiée par une tache le dossier n'est pas impacté. |
4864 |
|
// Il n'est donc pas nécessaire de vérifier les restrictions. |
4865 |
$this->restriction_valid = $this->restrictionIsValid($restriction); |
$this->restriction_valid = $this->restrictionIsValid($restriction); |
4866 |
if ( !$this->restriction_valid ){ |
if ($this->getParameter("maj") != 176 |
4867 |
|
&& !$this->restriction_valid) { |
4868 |
|
|
4869 |
// Affichage du message si la restriction s'applique |
// Affichage du message si la restriction s'applique |
4870 |
$this->addToMessage( |
$this->addToMessage( |
4932 |
} |
} |
4933 |
|
|
4934 |
} |
} |
4935 |
|
|
4936 |
|
/** |
4937 |
|
* Récupère et stocket dans un tableau toutes les infos du pétitionnaire |
4938 |
|
* principal du dossier auquel appartiens l'instruction. |
4939 |
|
* Renvoie un tableau contenant les informations du pétitionnaire principal. |
4940 |
|
* |
4941 |
|
* Si l'identifiant de l'instruction n'a pas pu etre récupéré renvoie false |
4942 |
|
* et affiche un message dans les logs. |
4943 |
|
* En cas d'erreur de base de donnée renvoie false et affiche un message d'erreur. |
4944 |
|
* |
4945 |
|
* @param string identifiant du dossier |
4946 |
|
* @return array|boolean |
4947 |
|
*/ |
4948 |
|
protected function get_info_petitionnaire_principal_dossier($dossier = null) { |
4949 |
|
// Si l'identifiant de l'instruction n'a pas été fournit on récupère celui de |
4950 |
|
// l'objet courant |
4951 |
|
if (empty($dossier)) { |
4952 |
|
$dossier = $this->getVal('dossier'); |
4953 |
|
// Si la récupération de l'identifiant de l'instruction a échoué la méthode renvoie |
4954 |
|
// false et on affiche un message d'erreur dans les logs |
4955 |
|
if (empty($dossier)) { |
4956 |
|
$this->addToLog(__METHOD__.' : L\'identifiant du dossier n\'a pas pu être récupéré'); |
4957 |
|
return false; |
4958 |
|
} |
4959 |
|
} |
4960 |
|
|
4961 |
|
// Requête sql servant à récupérer toutes les informations relatives au demandeurs |
4962 |
|
// principal |
4963 |
|
$qres = $this->f->get_all_results_from_db_query( |
4964 |
|
sprintf( |
4965 |
|
'SELECT |
4966 |
|
-- Récupère toutes les informations du demandeur principal |
4967 |
|
demandeur.*, |
4968 |
|
CASE |
4969 |
|
WHEN demandeur.qualite=\'particulier\' |
4970 |
|
THEN TRIM(CONCAT(demandeur.particulier_nom, \' \', demandeur.particulier_prenom, \' \', demandeur.courriel)) |
4971 |
|
ELSE |
4972 |
|
TRIM(CONCAT(demandeur.personne_morale_raison_sociale, \' \', demandeur.personne_morale_denomination, \' \', demandeur.courriel)) |
4973 |
|
END AS destinataire |
4974 |
|
FROM |
4975 |
|
%1$sdossier |
4976 |
|
LEFT JOIN %1$slien_dossier_demandeur |
4977 |
|
ON lien_dossier_demandeur.dossier = dossier.dossier |
4978 |
|
LEFT JOIN %1$sdemandeur |
4979 |
|
ON demandeur.demandeur = lien_dossier_demandeur.demandeur |
4980 |
|
WHERE |
4981 |
|
dossier.dossier = \'%2$s\' |
4982 |
|
AND lien_dossier_demandeur.petitionnaire_principal IS TRUE', |
4983 |
|
DB_PREFIXE, |
4984 |
|
$this->f->db->escapeSimple($dossier) |
4985 |
|
), |
4986 |
|
array( |
4987 |
|
"origin" => __METHOD__, |
4988 |
|
) |
4989 |
|
); |
4990 |
|
if (is_array($qres["result"]) === true |
4991 |
|
&& array_key_exists(0, $qres["result"]) === true) { |
4992 |
|
// |
4993 |
|
return $qres["result"][0]; |
4994 |
|
} |
4995 |
|
return null; |
4996 |
|
} |
4997 |
|
|
4998 |
|
|
4999 |
|
|
5000 |
/** |
/** |
5001 |
* Finalisation des documents. |
* Finalisation des documents. |
5028 |
|
|
5029 |
// |
// |
5030 |
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
5031 |
|
|
5032 |
|
// |
5033 |
|
$params = array( |
5034 |
|
"specific" => array(), |
5035 |
|
); |
5036 |
|
// Si la rédaction libre est activée sur l'instruction |
5037 |
|
if ($this->getVal("flag_edition_integrale") == 't') { |
5038 |
|
$params["specific"]["corps"] = array( |
5039 |
|
"mode" => "set", |
5040 |
|
"value" => $this->getVal("corps_om_htmletatex"), |
5041 |
|
); |
5042 |
|
$params["specific"]["titre"] = array( |
5043 |
|
"mode" => "set", |
5044 |
|
"value" => $this->getVal("titre_om_htmletat"), |
5045 |
|
); |
5046 |
|
} |
5047 |
// Génération du PDF |
// Génération du PDF |
5048 |
$result = $this->compute_pdf_output('lettretype', $this->getVal('lettretype'), $collectivite); |
$result = $this->compute_pdf_output('lettretype', $this->getVal('lettretype'), $collectivite, null, $params); |
5049 |
$pdf_output = $result['pdf_output']; |
$pdf_output = $result['pdf_output']; |
5050 |
|
|
5051 |
//Métadonnées du document |
//Métadonnées du document |
5052 |
$metadata = array( |
$metadata = array( |
5053 |
'filename' => 'instruction_'.$id_inst.'.pdf', |
'filename' => 'instruction_'.$id_inst.'.pdf', |
5059 |
$spe_metadata = $this->getMetadata("om_fichier_instruction"); |
$spe_metadata = $this->getMetadata("om_fichier_instruction"); |
5060 |
|
|
5061 |
//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 |
5062 |
$sql = "SELECT type |
// TODO : A voir pour remplacer par une instanciation de l'événement. |
5063 |
FROM ".DB_PREFIXE."evenement |
// Voir également si l'événement ne dois pas être instancié en début de |
5064 |
WHERE evenement = ".$this->getVal("evenement"); |
// méthode pour pouvoir être réutilisé. |
5065 |
$typeEvenement = $this->db->getOne($sql); |
$qres = $this->f->get_one_result_from_db_query( |
5066 |
$this->addToLog(__METHOD__."(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
sprintf( |
5067 |
if ($this->f->isDatabaseError($typeEvenement, true) === true) { |
'SELECT |
5068 |
|
type |
5069 |
|
FROM |
5070 |
|
%1$sevenement |
5071 |
|
WHERE |
5072 |
|
evenement = \'%2$d\'', |
5073 |
|
DB_PREFIXE, |
5074 |
|
intval($this->getVal("evenement")) |
5075 |
|
), |
5076 |
|
array( |
5077 |
|
"origin" => __METHOD__, |
5078 |
|
"force_return" => true, |
5079 |
|
) |
5080 |
|
); |
5081 |
|
|
5082 |
|
if ($qres["code"] !== "OK") { |
5083 |
$this->correct = false; |
$this->correct = false; |
5084 |
$this->addToMessage($bdd_msg_error); |
$this->addToMessage($bdd_msg_error); |
5085 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
5088 |
//Initialisation de la variable |
//Initialisation de la variable |
5089 |
$arrete_metadata = array(); |
$arrete_metadata = array(); |
5090 |
// 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 |
5091 |
if ( $typeEvenement === 'arrete' ){ |
if ($qres['result'] === 'arrete'){ |
5092 |
$arrete_metadata = $this->getMetadata("arrete"); |
$arrete_metadata = $this->getMetadata("arrete"); |
5093 |
} |
} |
5094 |
|
|
5095 |
$metadata = array_merge($metadata, $spe_metadata, $arrete_metadata); |
$metadata = array_merge($metadata, $spe_metadata, $arrete_metadata); |
5096 |
|
|
5097 |
|
/* |
5098 |
|
// transforme le tableau de métadonnées en objet |
5099 |
|
$mdf = new MetadataFactory(); |
5100 |
|
$md = $mdf->build('Instruction', $metadata); |
5101 |
|
*/ |
5102 |
|
|
5103 |
// Si le document a déjà été finalisé on le met à jour |
// Si le document a déjà été finalisé on le met à jour |
5104 |
// en conservant son UID |
// en conservant son UID |
5105 |
if ($this->getVal("om_fichier_instruction") != ''){ |
if ($this->getVal("om_fichier_instruction") != ''){ |
5108 |
} |
} |
5109 |
// 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 |
5110 |
else { |
else { |
5111 |
$uid = $this->f->storage->create($pdf_output, $metadata); |
$uid = $this->f->storage->create($pdf_output, $metadata, "from_content", $this->table.".om_fichier_instruction"); |
5112 |
} |
} |
5113 |
} |
} |
5114 |
|
|
5125 |
if ($uid == '' || $uid == 'OP_FAILURE' ) { |
if ($uid == '' || $uid == 'OP_FAILURE' ) { |
5126 |
$this->correct = false; |
$this->correct = false; |
5127 |
$this->addToMessage($file_msg_error); |
$this->addToMessage($file_msg_error); |
5128 |
$this->addToLog(sprintf($log_msg_error, $id_inst, $uid)); |
$this->addToLog(sprintf($log_msg_error, $id_inst, $uid), DEBUG_MODE); |
5129 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
5130 |
} |
} |
5131 |
|
|
5162 |
$val['archive_date_retour_contradictoire'] = $this->dateDBToForm($val['archive_date_retour_contradictoire']); |
$val['archive_date_retour_contradictoire'] = $this->dateDBToForm($val['archive_date_retour_contradictoire']); |
5163 |
$val['archive_date_ait'] = $this->dateDBToForm($val['archive_date_ait']); |
$val['archive_date_ait'] = $this->dateDBToForm($val['archive_date_ait']); |
5164 |
$val['archive_date_transmission_parquet'] = $this->dateDBToForm($val['archive_date_transmission_parquet']); |
$val['archive_date_transmission_parquet'] = $this->dateDBToForm($val['archive_date_transmission_parquet']); |
5165 |
|
$val['archive_date_affichage'] = $this->dateDBToForm($val['archive_date_affichage']); |
5166 |
$this->setvalF($val); |
$this->setvalF($val); |
5167 |
|
|
5168 |
// Verification de la validite des donnees |
// Verification de la validite des donnees |
5169 |
$this->verifier($this->val, $this->db, DEBUG); |
$this->verifier($this->val); |
5170 |
// Si les verifications precedentes sont correctes, on procede a |
// Si les verifications precedentes sont correctes, on procede a |
5171 |
// la modification, sinon on ne fait rien et on retourne une erreur |
// la modification, sinon on ne fait rien et on retourne une erreur |
5172 |
if ($this->correct === true) { |
if ($this->correct === true) { |
5200 |
|
|
5201 |
// Execution de la requête de modification des donnees de l'attribut |
// Execution de la requête de modification des donnees de l'attribut |
5202 |
// valF de l'objet dans l'attribut table de l'objet |
// valF de l'objet dans l'attribut table de l'objet |
5203 |
$res = $this->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
$res = $this->f->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
5204 |
DB_AUTOQUERY_UPDATE, $this->getCle($id_inst)); |
DB_AUTOQUERY_UPDATE, $this->getCle($id_inst)); |
5205 |
$this->addToLog(__METHOD__."() : db->autoExecute(\"".DB_PREFIXE.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($id_inst)."\")", VERBOSE_MODE); |
$this->addToLog(__METHOD__."() : db->autoExecute(\"".DB_PREFIXE.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($id_inst)."\")", VERBOSE_MODE); |
5206 |
// |
// |
5221 |
} |
} |
5222 |
// L'appel de verifier() a déjà positionné correct à false |
// L'appel de verifier() a déjà positionné correct à false |
5223 |
// et défini un message d'erreur. |
// et défini un message d'erreur. |
5224 |
$this->addToLog(sprintf($log_msg_error, $id_inst, $uid)); |
$this->addToLog(sprintf($log_msg_error, $id_inst, $uid), DEBUG_MODE); |
5225 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
5226 |
} |
} |
5227 |
|
|
5229 |
* Récupération du numéro de dossier d'instruction à ajouter aux métadonnées |
* Récupération du numéro de dossier d'instruction à ajouter aux métadonnées |
5230 |
* @return string numéro de dossier d'instruction |
* @return string numéro de dossier d'instruction |
5231 |
*/ |
*/ |
5232 |
protected function getDossier() { |
protected function getDossier($champ = null) { |
5233 |
if(empty($this->specificMetadata)) { |
if(empty($this->specificMetadata)) { |
5234 |
$this->getSpecificMetadata(); |
$this->getSpecificMetadata(); |
5235 |
} |
} |
5326 |
} |
} |
5327 |
|
|
5328 |
// Requête sql |
// Requête sql |
5329 |
$sql = "SELECT libelle FROM ".DB_PREFIXE."evenement |
$evenement = $this->f->get_inst__om_dbform(array( |
5330 |
WHERE evenement=".$evenement; |
"obj" => "evenement", |
5331 |
$evenement_libelle = $this->db->getOne($sql); |
"idx" => $evenement |
5332 |
$this->addToLog("getTitle(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
)); |
|
if (database::isError($evenement_libelle)) { |
|
|
die(); |
|
|
} |
|
5333 |
|
|
5334 |
// Retourne le libelle de l'événement |
// Retourne le libelle de l'événement |
5335 |
return $evenement_libelle; |
return $evenement->getVal('libelle'); |
5336 |
} |
} |
5337 |
|
|
5338 |
|
|
5387 |
LEFT JOIN ".DB_PREFIXE."groupe |
LEFT JOIN ".DB_PREFIXE."groupe |
5388 |
ON dossier_autorisation_type.groupe = groupe.groupe |
ON dossier_autorisation_type.groupe = groupe.groupe |
5389 |
WHERE dossier.dossier = '".$dossier."'"; |
WHERE dossier.dossier = '".$dossier."'"; |
5390 |
$res = $this->db->query($sql); |
$res = $this->f->db->query($sql); |
5391 |
$this->f->addToLog("getSpecificMetadata() : db->query(".$sql.")", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
5392 |
if ( database::isError($res)){ |
$this->f->isDatabaseError($res); |
|
die(); |
|
|
} |
|
|
|
|
5393 |
//Le résultat est récupéré dans un objet |
//Le résultat est récupéré dans un objet |
5394 |
$row =& $res->fetchRow(DB_FETCHMODE_OBJECT); |
$row =& $res->fetchRow(DB_FETCHMODE_OBJECT); |
5395 |
|
|
5400 |
$inst_dossier = $this->get_inst_dossier($dossier); |
$inst_dossier = $this->get_inst_dossier($dossier); |
5401 |
|
|
5402 |
// Insère l'attribut version à l'objet |
// Insère l'attribut version à l'objet |
5403 |
$row->version = $inst_dossier->get_dossier_instruction_version(); |
$row->version = $inst_dossier->get_di_numero_suffixe(); |
5404 |
|
|
5405 |
//Alors on créé l'objet dossier_instruction |
//Alors on créé l'objet dossier_instruction |
5406 |
$this->specificMetadata = $row; |
$this->specificMetadata = $row; |
5422 |
|
|
5423 |
//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 |
5424 |
//dossier |
//dossier |
5425 |
$sql = "SELECT etat.statut |
$qres = $this->f->get_one_result_from_db_query( |
5426 |
FROM ".DB_PREFIXE."dossier |
sprintf( |
5427 |
LEFT JOIN |
'SELECT |
5428 |
".DB_PREFIXE."etat |
etat.statut |
5429 |
ON |
FROM |
5430 |
dossier.etat = etat.etat |
%1$sdossier |
5431 |
WHERE dossier ='".$idx."'"; |
LEFT JOIN |
5432 |
$statut = $this->db->getOne($sql); |
%1$setat |
5433 |
$this->f->addToLog("getStatutAutorisationDossier() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
ON |
5434 |
if ( database::isError($statut)){ |
dossier.etat = etat.etat |
5435 |
die(); |
WHERE |
5436 |
} |
dossier = \'%2$s\'', |
5437 |
|
DB_PREFIXE, |
5438 |
|
$this->f->db->escapeSimple($idx) |
5439 |
|
), |
5440 |
|
array( |
5441 |
|
"origin" => __METHOD__, |
5442 |
|
) |
5443 |
|
); |
5444 |
} |
} |
5445 |
return $statut; |
|
5446 |
|
return $qres['result']; |
5447 |
} |
} |
5448 |
|
|
5449 |
/** |
/** |
5458 |
// 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 |
5459 |
$sql = "SELECT * FROM ".DB_PREFIXE."dossier |
$sql = "SELECT * FROM ".DB_PREFIXE."dossier |
5460 |
WHERE dossier='".$this->valF['dossier']."'"; |
WHERE dossier='".$this->valF['dossier']."'"; |
5461 |
$res = $this->db->query($sql); |
$res = $this->f->db->query($sql); |
5462 |
$this->addToLog("get_dossier_actual(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
5463 |
$this->f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
5464 |
|
|
5465 |
// |
// |
5491 |
$return['archive_date_limite_incompletude'] = $row['date_limite_incompletude']; |
$return['archive_date_limite_incompletude'] = $row['date_limite_incompletude']; |
5492 |
$return['archive_delai_incompletude'] = $row['delai_incompletude']; |
$return['archive_delai_incompletude'] = $row['delai_incompletude']; |
5493 |
$return['archive_autorite_competente'] = $row['autorite_competente']; |
$return['archive_autorite_competente'] = $row['autorite_competente']; |
5494 |
|
$return['archive_dossier_instruction_type'] = $row['dossier_instruction_type']; |
5495 |
$return['duree_validite'] = $row['duree_validite']; |
$return['duree_validite'] = $row['duree_validite']; |
5496 |
$return['date_depot'] = $row['date_depot']; |
$return['date_depot'] = $row['date_depot']; |
5497 |
|
$return['date_depot_mairie'] = $row['date_depot_mairie']; |
5498 |
$return['archive_date_cloture_instruction'] = $row['date_cloture_instruction']; |
$return['archive_date_cloture_instruction'] = $row['date_cloture_instruction']; |
5499 |
$return['archive_date_premiere_visite'] = $row['date_premiere_visite']; |
$return['archive_date_premiere_visite'] = $row['date_premiere_visite']; |
5500 |
$return['archive_date_derniere_visite'] = $row['date_derniere_visite']; |
$return['archive_date_derniere_visite'] = $row['date_derniere_visite']; |
5502 |
$return['archive_date_retour_contradictoire'] = $row['date_retour_contradictoire']; |
$return['archive_date_retour_contradictoire'] = $row['date_retour_contradictoire']; |
5503 |
$return['archive_date_ait'] = $row['date_ait']; |
$return['archive_date_ait'] = $row['date_ait']; |
5504 |
$return['archive_date_transmission_parquet'] = $row['date_transmission_parquet']; |
$return['archive_date_transmission_parquet'] = $row['date_transmission_parquet']; |
5505 |
|
$return['archive_date_affichage'] = $row['date_affichage']; |
5506 |
|
$return['archive_pec_metier'] = $row['pec_metier']; |
5507 |
|
$return['archive_a_qualifier'] = $row['a_qualifier']; |
5508 |
} |
} |
5509 |
|
|
5510 |
// Retour de la fonction |
// Retour de la fonction |
5518 |
* @return boolean |
* @return boolean |
5519 |
*/ |
*/ |
5520 |
function checkEvenementNonVerrouillable($idx) { |
function checkEvenementNonVerrouillable($idx) { |
|
|
|
|
// Initialisation du résultat |
|
|
$non_verrouillable = false; |
|
|
|
|
5521 |
// Si la condition n'est pas vide |
// Si la condition n'est pas vide |
5522 |
if ($idx != "") { |
if ($idx != "") { |
5523 |
|
|
5524 |
// Requête SQL |
// Requête SQL |
5525 |
$sql = "SELECT evenement.non_verrouillable |
$qres = $this->f->get_one_result_from_db_query( |
5526 |
FROM ".DB_PREFIXE."evenement |
sprintf( |
5527 |
LEFT JOIN ".DB_PREFIXE."instruction |
'SELECT |
5528 |
ON instruction.evenement = evenement.evenement |
evenement.non_verrouillable |
5529 |
WHERE instruction.instruction = $idx"; |
FROM |
5530 |
$this->f->addToLog("checkEvenementNonVerrouillable() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
%1$sevenement |
5531 |
$res = $this->db->getOne($sql); |
LEFT JOIN %1$sinstruction |
5532 |
$this->f->isDatabaseError($res); |
ON instruction.evenement = evenement.evenement |
5533 |
|
WHERE |
5534 |
// Si le retour de la requête est true |
instruction.instruction = \'%2$s\'', |
5535 |
if ($res == 't') { |
DB_PREFIXE, |
5536 |
// |
intval($idx) |
5537 |
$non_verrouillable = true; |
), |
5538 |
} |
array( |
5539 |
|
"origin" => __METHOD__, |
5540 |
|
) |
5541 |
|
); |
5542 |
} |
} |
5543 |
|
|
5544 |
// Retourne résultat |
// Si on a un résultat et que ce résultat indique que l'événement n'est |
5545 |
return $non_verrouillable; |
// pas vérrouillable renvoie true, sinon renvoie false |
5546 |
|
return isset($qres) && isset($qres['result']) && $qres['result'] == 't'; |
5547 |
} |
} |
5548 |
|
|
5549 |
/** |
/** |
5620 |
if ($row['date_depot'] != '') { |
if ($row['date_depot'] != '') { |
5621 |
$this->valF['date_depot']= $row['date_depot']; |
$this->valF['date_depot']= $row['date_depot']; |
5622 |
} |
} |
5623 |
|
if ($row['date_depot_mairie'] != '') { |
5624 |
|
$this->valF['date_depot_mairie']= $row['date_depot_mairie']; |
5625 |
|
} |
5626 |
// Dates concernant les dossiers contentieux |
// Dates concernant les dossiers contentieux |
5627 |
if ($row['date_cloture_instruction'] != '') { |
if ($row['date_cloture_instruction'] != '') { |
5628 |
$this->valF['archive_date_cloture_instruction']= $row['date_cloture_instruction']; |
$this->valF['archive_date_cloture_instruction']= $row['date_cloture_instruction']; |
5645 |
if ($row['date_transmission_parquet'] != '') { |
if ($row['date_transmission_parquet'] != '') { |
5646 |
$this->valF['archive_date_transmission_parquet']= $row['date_transmission_parquet']; |
$this->valF['archive_date_transmission_parquet']= $row['date_transmission_parquet']; |
5647 |
} |
} |
5648 |
|
// |
5649 |
|
if ($row['dossier_instruction_type'] != '') { |
5650 |
|
$this->valF['archive_dossier_instruction_type']= $row['dossier_instruction_type']; |
5651 |
|
} |
5652 |
|
if ($row['date_affichage'] != '') { |
5653 |
|
$this->valF['archive_date_affichage']= $row['date_affichage']; |
5654 |
|
} |
5655 |
|
if (isset($row['pec_metier']) === true && $row['pec_metier'] != '') { |
5656 |
|
$this->valF['archive_pec_metier']= $row['pec_metier']; |
5657 |
|
} |
5658 |
|
if (isset($row['a_qualifier']) === true && $row['a_qualifier'] != '') { |
5659 |
|
$this->valF['archive_a_qualifier']= $row['a_qualifier']; |
5660 |
|
} |
5661 |
} |
} |
5662 |
|
|
5663 |
// {{{ |
// {{{ |
5789 |
"datecontrolelegalite"=>"", "ap_numrue"=>"", "ap_nomdelavoie"=>"", |
"datecontrolelegalite"=>"", "ap_numrue"=>"", "ap_nomdelavoie"=>"", |
5790 |
"ap_codepostal"=>"", "ap_ville"=>""); |
"ap_codepostal"=>"", "ap_ville"=>""); |
5791 |
|
|
5792 |
$sqlArrete = "SELECT signataire_arrete.nom as \"nomsignataire\", |
$sqlArrete = "SELECT |
5793 |
|
signataire_arrete.prenom || ' ' ||signataire_arrete.nom as \"nomsignataire\", |
5794 |
signataire_arrete.qualite as \"qualitesignataire\", |
signataire_arrete.qualite as \"qualitesignataire\", |
5795 |
instruction.etat as \"decisionarrete\", |
instruction.etat as \"decisionarrete\", |
5796 |
instruction.date_retour_rar as \"datenotification\", |
instruction.date_retour_rar as \"datenotification\", |
5808 |
LEFT JOIN ".DB_PREFIXE."donnees_techniques ON |
LEFT JOIN ".DB_PREFIXE."donnees_techniques ON |
5809 |
donnees_techniques.dossier_instruction = dossier.dossier |
donnees_techniques.dossier_instruction = dossier.dossier |
5810 |
WHERE instruction.instruction = ".$this->getVal("instruction"); |
WHERE instruction.instruction = ".$this->getVal("instruction"); |
5811 |
$resArrete = $this->db->query($sqlArrete); |
$resArrete = $this->f->db->query($sqlArrete); |
5812 |
$this->f->addToLog("getArreteMetadata(): db->query(\"".$sqlArrete."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->query(\"".$sqlArrete."\");", VERBOSE_MODE); |
5813 |
if ( database::isError($resArrete)){ |
$this->f->isDatabaseError($resArrete); |
|
die(); |
|
|
} |
|
|
|
|
5814 |
$this->metadonneesArrete = $resArrete->fetchRow(DB_FETCHMODE_ASSOC); |
$this->metadonneesArrete = $resArrete->fetchRow(DB_FETCHMODE_ASSOC); |
5815 |
} |
} |
5816 |
|
|
5825 |
// Récupère la valeur du champ lettretype |
// Récupère la valeur du champ lettretype |
5826 |
$lettretype = $this->getVal("lettretype"); |
$lettretype = $this->getVal("lettretype"); |
5827 |
// Si le champ est vide |
// Si le champ est vide |
5828 |
if (empty($lettretype)) { |
if ($lettretype !== '' && $lettretype !== null) { |
5829 |
// |
// |
5830 |
return false; |
return true; |
5831 |
} |
} |
5832 |
|
|
5833 |
// |
// |
5834 |
return true; |
return false; |
5835 |
|
} |
5836 |
|
|
5837 |
|
/** |
5838 |
|
* CONDITION - is_modifiable. |
5839 |
|
* |
5840 |
|
* Controle si l'évenement est modifiable. |
5841 |
|
* |
5842 |
|
* @return boolean |
5843 |
|
*/ |
5844 |
|
function is_evenement_modifiable() { |
5845 |
|
$evenement = $this->get_inst_evenement($this->getVal('evenement')); |
5846 |
|
return ! $this->get_boolean_from_pgsql_value($evenement->getVal('non_modifiable')); |
5847 |
} |
} |
5848 |
|
|
5849 |
/** |
/** |
5854 |
* @return boolean |
* @return boolean |
5855 |
*/ |
*/ |
5856 |
function is_editable() { |
function is_editable() { |
5857 |
|
|
5858 |
|
// XXX |
5859 |
|
// Identifier si l'instruction est lié à une tâche depuis le champ object_id (mais aussi voir le log car object_id peut être modifié) |
5860 |
|
// Si cette tâche identifiée est DONE alors la suppression/modification de cette intruction est impossible |
5861 |
|
|
5862 |
// Contrôle si l'utilisateur possède un bypass |
// Contrôle si l'utilisateur possède un bypass |
5863 |
$bypass = $this->f->isAccredited(get_class($this)."_modifier_bypass"); |
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_modifier_bypass"); |
5864 |
// |
// |
5865 |
if ($bypass == true) { |
if ($bypass == true) { |
5866 |
// |
// |
5883 |
return true; |
return true; |
5884 |
} |
} |
5885 |
|
|
|
// Si l'utilisateur est instructeur de la commune du dossier et que la |
|
|
// décision peut être changée par la commune. |
|
|
if ($this->is_instructeur_from_collectivite_dossier() === true and |
|
|
$this->isInstrCanChangeDecision($this->getVal('dossier')) === true) { |
|
|
return true; |
|
|
} |
|
|
|
|
5886 |
// Si l'utilisateur est instructeur de la commune du dossier et que |
// Si l'utilisateur est instructeur de la commune du dossier et que |
5887 |
// l'instruction est créée par un instructeur de la commune |
// l'instruction est créée par un instructeur de la commune |
5888 |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
5895 |
} |
} |
5896 |
|
|
5897 |
/** |
/** |
5898 |
|
* Vérifie si l'événement est supprimable ou pas. |
5899 |
|
* |
5900 |
|
* @return boolean |
5901 |
|
*/ |
5902 |
|
function is_evenement_supprimable() { |
5903 |
|
// Controle si l'évenement est supprimable |
5904 |
|
$evenement = $this->get_inst_evenement($this->getVal('evenement')); |
5905 |
|
return ! $this->get_boolean_from_pgsql_value($evenement->getVal('non_supprimable')); |
5906 |
|
} |
5907 |
|
|
5908 |
|
/** |
5909 |
* CONDITION - is_deletable. |
* CONDITION - is_deletable. |
5910 |
* |
* |
5911 |
* Condition pour lma modification. |
* Condition pour la suppression. |
5912 |
* |
* |
5913 |
* @return boolean |
* @return boolean |
5914 |
*/ |
*/ |
5915 |
function is_deletable() { |
function is_deletable() { |
5916 |
// Contrôle si l'utilisateur possède un bypass |
|
5917 |
$bypass = $this->f->isAccredited(get_class($this)."_supprimer_bypass"); |
// XXX |
5918 |
|
// Identifier si l'instruction est lié à une tâche depuis le champ object_id (mais aussi voir le log car object_id peut être modifié) |
5919 |
|
// Si cette tâche identifiée est DONE alors la suppression/modification de cette intruction est impossible |
5920 |
|
|
5921 |
|
// Contrôle si l'utilisateur possède un bypass intégral |
5922 |
|
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_supprimer_bypass"); |
5923 |
// |
// |
5924 |
if ($bypass == true) { |
if ($bypass == true) { |
5925 |
|
|
5928 |
} |
} |
5929 |
|
|
5930 |
// Si l'utilisateur est un intructeur qui ne correspond pas à la |
// Si l'utilisateur est un intructeur qui ne correspond pas à la |
5931 |
// division du dossier |
// division du dossier et si l'utilisateur n'a pas la permission bypass |
5932 |
if ($this->is_instructeur_from_division_dossier() !== true) { |
// de la division |
5933 |
|
if ($this->is_instructeur_from_division_dossier() === false |
5934 |
|
&& $this->f->isAccredited($this->get_absolute_class_name()."_supprimer_bypass_division") === false) { |
5935 |
|
|
5936 |
// |
// |
5937 |
return false; |
return false; |
5940 |
// l'événement est-il le dernier ? |
// l'événement est-il le dernier ? |
5941 |
$dernier_evenement = false; |
$dernier_evenement = false; |
5942 |
// instanciation dossier |
// instanciation dossier |
5943 |
require_once "../obj/dossier.class.php"; |
$dossier = $this->f->get_inst__om_dbform(array( |
5944 |
$dossier = new dossier($this->getVal('dossier'), $this->db, DEBUG); |
"obj" => "dossier", |
5945 |
|
"idx" => $this->getVal('dossier'), |
5946 |
|
)); |
5947 |
// récupération dernier événement |
// récupération dernier événement |
5948 |
$id_dernier_evenement = $dossier->get_dernier_evenement(); |
$id_dernier_evenement = $dossier->get_dernier_evenement(); |
5949 |
if ($id_dernier_evenement == $this->getVal($this->clePrimaire)) { |
if ($id_dernier_evenement == $this->getVal($this->clePrimaire)) { |
5994 |
*/ |
*/ |
5995 |
function is_addable() { |
function is_addable() { |
5996 |
// Contrôle si l'utilisateur possède un bypass |
// Contrôle si l'utilisateur possède un bypass |
5997 |
$bypass = $this->f->isAccredited(get_class($this)."_ajouter_bypass"); |
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_ajouter_bypass"); |
5998 |
// |
// |
5999 |
if ($bypass == true) { |
if ($bypass == true) { |
6000 |
|
|
6022 |
*/ |
*/ |
6023 |
function is_finalizable() { |
function is_finalizable() { |
6024 |
// Contrôle si l'utilisateur possède un bypass |
// Contrôle si l'utilisateur possède un bypass |
6025 |
$bypass = $this->f->isAccredited(get_class($this)."_finaliser_bypass"); |
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_finaliser_bypass"); |
6026 |
// |
// |
6027 |
if ($bypass == true) { |
if ($bypass == true) { |
6028 |
// |
// |
6045 |
return true; |
return true; |
6046 |
} |
} |
6047 |
|
|
|
// Si l'utilisateur est instructeur de la commune du dossier et que la |
|
|
// décision peut être changée par la commune. |
|
|
if ($this->is_instructeur_from_collectivite_dossier() === true and |
|
|
$this->isInstrCanChangeDecision($this->getVal('dossier')) === true) { |
|
|
return true; |
|
|
} |
|
|
|
|
6048 |
// Si l'utilisateur est instructeur de la commune du dossier et que |
// Si l'utilisateur est instructeur de la commune du dossier et que |
6049 |
// l'instruction est créée par un instructeur de la commune |
// l'instruction est créée par un instructeur de la commune |
6050 |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
6087 |
*/ |
*/ |
6088 |
function is_unfinalizable(){ |
function is_unfinalizable(){ |
6089 |
// Contrôle si l'utilisateur possède un bypass |
// Contrôle si l'utilisateur possède un bypass |
6090 |
$bypass = $this->f->isAccredited(get_class($this)."_definaliser_bypass"); |
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_definaliser_bypass"); |
6091 |
// |
// |
6092 |
if ($bypass == true) { |
if ($bypass == true) { |
6093 |
// |
// |
6110 |
return true; |
return true; |
6111 |
} |
} |
6112 |
|
|
|
// Si l'utilisateur est instructeur de la commune du dossier et que la |
|
|
// décision peut être changée par la commune. |
|
|
if ($this->is_instructeur_from_collectivite_dossier() === true and |
|
|
$this->isInstrCanChangeDecision($this->getVal('dossier')) === true) { |
|
|
return true; |
|
|
} |
|
|
|
|
6113 |
// Si l'utilisateur est instructeur de la commune du dossier et que |
// Si l'utilisateur est instructeur de la commune du dossier et que |
6114 |
// l'instruction est créée par un instructeur de la commune |
// l'instruction est créée par un instructeur de la commune |
6115 |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
6158 |
|
|
6159 |
|
|
6160 |
// Sinon on vérifie l'éligibilité du dossier au changement de décision |
// Sinon on vérifie l'éligibilité du dossier au changement de décision |
6161 |
$sql = |
// /!\ Requête lié à celles du widget indiquant les dossiers éligible au changement |
6162 |
"SELECT |
// de décision : |
6163 |
|
// * dossier_instruction.class.php : view_widget_dossiers_evenement_retour_finalise() |
6164 |
|
// * dossier_instruction.inc.php : si le paramètre filtre_decision = true |
6165 |
|
$sql = sprintf( |
6166 |
|
'SELECT |
6167 |
dossier.dossier |
dossier.dossier |
6168 |
FROM |
FROM |
6169 |
".DB_PREFIXE."dossier |
%1$sdossier |
6170 |
JOIN ".DB_PREFIXE."instruction ON instruction.instruction = ( |
JOIN %1$setat |
6171 |
SELECT instruction |
ON dossier.etat = etat.etat AND etat.statut = \'encours\' |
6172 |
FROM ".DB_PREFIXE."instruction |
JOIN %1$slien_dossier_demandeur |
6173 |
JOIN ".DB_PREFIXE."evenement on instruction.evenement=evenement.evenement |
ON dossier.dossier = lien_dossier_demandeur.dossier AND lien_dossier_demandeur.petitionnaire_principal IS TRUE |
6174 |
WHERE instruction.dossier = dossier.dossier |
JOIN %1$sdossier_instruction_type |
6175 |
AND evenement.retour IS FALSE |
ON dossier.dossier_instruction_type=dossier_instruction_type.dossier_instruction_type |
6176 |
ORDER BY date_evenement DESC, instruction DESC |
JOIN %1$sinstruction |
6177 |
LIMIT 1 |
-- Recherche de la dernière instruction qui ne soit pas liée à un événement retour |
6178 |
) |
ON instruction.instruction = ( |
6179 |
JOIN ".DB_PREFIXE."evenement ON instruction.evenement=evenement.evenement |
SELECT instruction |
6180 |
JOIN ".DB_PREFIXE."instructeur ON dossier.instructeur=instructeur.instructeur |
FROM %1$sinstruction |
6181 |
JOIN ".DB_PREFIXE."om_utilisateur ON instructeur.om_utilisateur=om_utilisateur.om_utilisateur |
JOIN %1$sevenement ON instruction.evenement=evenement.evenement |
6182 |
JOIN ".DB_PREFIXE."om_collectivite ON om_collectivite.om_collectivite=om_utilisateur.om_collectivite |
AND evenement.retour IS FALSE |
6183 |
JOIN ".DB_PREFIXE."etat ON dossier.etat = etat.etat |
WHERE instruction.dossier = dossier.dossier |
6184 |
|
ORDER BY date_evenement DESC, instruction DESC |
6185 |
|
LIMIT 1 |
6186 |
|
) |
6187 |
|
-- On ne garde que les dossiers pour lesquels la dernière instruction est finalisée |
6188 |
|
-- ou alors pour laquelle l instruction a été ajouté par la commune et est |
6189 |
|
-- non signée, non notifié, etc. |
6190 |
|
AND (instruction.om_final_instruction IS TRUE |
6191 |
|
OR instruction.created_by_commune IS TRUE) |
6192 |
|
AND instruction.date_retour_signature IS NULL |
6193 |
|
AND instruction.date_envoi_rar IS NULL |
6194 |
|
AND instruction.date_retour_rar IS NULL |
6195 |
|
AND instruction.date_envoi_controle_legalite IS NULL |
6196 |
|
AND instruction.date_retour_controle_legalite IS NULL |
6197 |
|
-- On vérifie que l instruction soit un arrêté ou un changement de décision |
6198 |
|
JOIN %1$sevenement |
6199 |
|
ON instruction.evenement=evenement.evenement |
6200 |
|
AND (evenement.type = \'arrete\' |
6201 |
|
OR evenement.type = \'changement_decision\') |
6202 |
|
-- Recherche les informations du pétitionnaire principal pour l affichage |
6203 |
|
JOIN %1$sdemandeur |
6204 |
|
ON lien_dossier_demandeur.demandeur = demandeur.demandeur |
6205 |
|
-- Recherche la collectivité rattachée à l instructeur |
6206 |
|
JOIN %1$sinstructeur |
6207 |
|
ON dossier.instructeur=instructeur.instructeur |
6208 |
|
JOIN %1$sdivision |
6209 |
|
ON instructeur.division=division.division |
6210 |
|
JOIN %1$sdirection |
6211 |
|
ON division.direction=direction.direction |
6212 |
|
JOIN %1$som_collectivite |
6213 |
|
ON direction.om_collectivite=om_collectivite.om_collectivite |
6214 |
WHERE |
WHERE |
6215 |
|
-- Vérification que la décision a été prise par l agglo |
6216 |
( |
om_collectivite.niveau = \'2\' |
6217 |
evenement.type = 'arrete' AND |
AND dossier.dossier = \'%2$s\' |
6218 |
( |
', |
6219 |
instruction.om_final_instruction IS TRUE |
DB_PREFIXE, |
6220 |
OR instruction.created_by_commune IS TRUE |
$this->f->db->escapeSimple($idx) |
6221 |
) OR |
); |
|
evenement.type = 'changement_decision' |
|
|
) |
|
|
AND evenement.retour IS FALSE |
|
|
AND instruction.date_retour_signature IS NULL |
|
|
AND instruction.date_envoi_rar IS NULL |
|
|
AND instruction.date_retour_rar IS NULL |
|
|
AND instruction.date_envoi_controle_legalite IS NULL |
|
|
AND instruction.date_retour_controle_legalite IS NULL |
|
|
AND etat.statut = 'encours' |
|
|
AND dossier.dossier = '".$idx."' |
|
|
AND om_collectivite.niveau = '2' |
|
|
"; |
|
6222 |
|
|
6223 |
|
|
6224 |
// Si collectivité de l'utilisateur niveau mono alors filtre sur celle-ci |
// Si collectivité de l'utilisateur niveau mono alors filtre sur celle-ci |
6225 |
if ($this->f->isCollectiviteMono($_SESSION['collectivite']) === true) { |
if ($this->f->isCollectiviteMono($_SESSION['collectivite']) === true) { |
6226 |
$sql .= " AND dossier.om_collectivite=".$_SESSION['collectivite']; |
$sql .= sprintf( |
6227 |
} |
' AND dossier.om_collectivite = %1$d', |
6228 |
$res = $this->db->getone($sql); |
intval($_SESSION['collectivite']) |
6229 |
if (database::isError($res)) { |
); |
|
die(); |
|
|
} |
|
|
// Si le dossier n'est pas sujet au changement de decision |
|
|
if($res == null) { |
|
|
return false; |
|
6230 |
} |
} |
6231 |
return true; |
$qres = $this->f->get_one_result_from_db_query( |
6232 |
|
$sql, |
6233 |
|
array( |
6234 |
|
"origin" => __METHOD__, |
6235 |
|
) |
6236 |
|
); |
6237 |
|
|
6238 |
|
return $qres['result'] !== null; |
6239 |
} |
} |
6240 |
|
|
6241 |
|
|
6257 |
} |
} |
6258 |
|
|
6259 |
// Contrôle si l'utilisateur possède un bypass |
// Contrôle si l'utilisateur possède un bypass |
6260 |
$bypass = $this->f->isAccredited(get_class($this)."_modification_dates_bypass"); |
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_modification_dates_bypass"); |
6261 |
if ($bypass === true) { |
if ($bypass === true) { |
6262 |
return true; |
return true; |
6263 |
} |
} |
6264 |
|
|
6265 |
// On vérifie en premier lieu que le DI n'est pas clôturé |
// Permission de modifier le suivi des dates sur un dossier cloturé pour |
6266 |
|
// un utilisateur lié à un instructeur |
6267 |
|
$perm_moni_dates_d_closed = $this->f->isAccredited($this->get_absolute_class_name()."_modification_dates_cloture"); |
6268 |
|
|
6269 |
|
// On vérifie en premier lieu que le DI n'est pas clôturé et que |
6270 |
|
// l'utilisateur ne possède pas la permission de modifier le suivi des |
6271 |
|
// dates sur un dossier clôturé |
6272 |
$inst_dossier = $this->get_inst_dossier(); |
$inst_dossier = $this->get_inst_dossier(); |
6273 |
if ($inst_dossier->getStatut() === 'cloture') { |
if ($inst_dossier->getStatut() === 'cloture' |
6274 |
|
&& $perm_moni_dates_d_closed === false) { |
6275 |
// |
// |
6276 |
return false; |
return false; |
6277 |
} |
} |
6320 |
|
|
6321 |
|
|
6322 |
/** |
/** |
6323 |
|
* CONDITION - is_finalized. |
6324 |
|
* |
6325 |
|
* Condition pour vérifier si une instruction est finalisée. |
6326 |
|
* |
6327 |
|
* @return boolean |
6328 |
|
*/ |
6329 |
|
public function is_finalized() { |
6330 |
|
|
6331 |
|
return $this->getVal('om_final_instruction') === "t"; |
6332 |
|
} |
6333 |
|
|
6334 |
|
/** |
6335 |
|
* CONDITION - is_not_date_retour_signature_set. |
6336 |
|
* |
6337 |
|
* Condition pour vérifier si une date de retour signature n'est pas définie. |
6338 |
|
* |
6339 |
|
* @return boolean |
6340 |
|
*/ |
6341 |
|
public function is_not_date_retour_signature_set() { |
6342 |
|
|
6343 |
|
return $this->getVal('date_retour_signature') == null; |
6344 |
|
|
6345 |
|
} |
6346 |
|
|
6347 |
|
|
6348 |
|
/** |
6349 |
* TREATMENT - finalize. |
* TREATMENT - finalize. |
6350 |
* |
* |
6351 |
* Permet de finaliser un enregistrement. |
* Permet de finaliser un enregistrement. |
6359 |
// 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 |
6360 |
// dites de TREATMENT. |
// dites de TREATMENT. |
6361 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
6362 |
|
$message = ''; |
6363 |
|
$ev = $this->get_inst_evenement($this->getVal('evenement')); |
6364 |
|
|
6365 |
|
// Controle du signataire |
6366 |
|
if (! $this->controle_signataire($ev)) { |
6367 |
|
$this->addToMessage(__("Le document ne peut pas être finalisé car aucun signataire n'a été sélectionné.")); |
6368 |
|
// Termine le traitement |
6369 |
|
return $this->end_treatment(__METHOD__, false); |
6370 |
|
} |
6371 |
|
|
6372 |
// Traitement de la finalisation |
// Traitement de la finalisation |
6373 |
$ret = $this->manage_finalizing("finalize", $val); |
$ret = $this->manage_finalizing("finalize", $val); |
6379 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
6380 |
} |
} |
6381 |
|
|
6382 |
|
// Envoi des notifications aux demandeurs si la notification est automatique |
6383 |
|
// et que la signature n'est pas requise |
6384 |
|
if ($ev->getVal('notification') === 'notification_automatique') { |
6385 |
|
// Préparation du message de log en cas d'erreur de notification |
6386 |
|
$msgLog = sprintf( |
6387 |
|
'%s %s : %d', |
6388 |
|
__('Erreur lors de la notification automatique du(des) pétitionnaire(s) suite à la finalisation de l\'instruction.'), |
6389 |
|
__('Instruction notifiée'), |
6390 |
|
$this->getVal($this->clePrimaire) |
6391 |
|
); |
6392 |
|
// Récupération de la catégorie et envoie des notifications au(x) demandeur(s) |
6393 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite($this->getVal('dossier')); |
6394 |
|
// Récupération de la liste des demandeurs à notifier et de la catégorie |
6395 |
|
$categorie = $this->f->get_param_option_notification($collectivite_di); |
6396 |
|
$isPortal = $categorie === PORTAL; |
6397 |
|
$demandeursANotifie = $this->get_demandeurs_notifiable( |
6398 |
|
$this->getVal('dossier'), |
6399 |
|
$isPortal |
6400 |
|
); |
6401 |
|
|
6402 |
|
// Création d'une notification et d'une tâche pour chaque demandeur à notifier |
6403 |
|
$demandeurPrincipalNotifie = false; |
6404 |
|
if (count($demandeursANotifie) > 0) { |
6405 |
|
foreach ($demandeursANotifie as $demandeur) { |
6406 |
|
// Identifie si le demandeur principal a été notifié ou pas |
6407 |
|
// et récupère ses informations |
6408 |
|
if ($demandeur['petitionnaire_principal'] == 't') { |
6409 |
|
$demandeurPrincipalNotifie = true; |
6410 |
|
// Si le demandeur principal est notifiable mais qu'il y a des erreurs dans |
6411 |
|
// son paramétrage, on effectue pas le traitement et on passe à l'itération |
6412 |
|
// suivante. On le considère également comme non notifié pour gérer l'envoie |
6413 |
|
// des messages d'erreurs |
6414 |
|
// Si la demande a été déposée via le portail alors le paramétrage n'a pas |
6415 |
|
// d'impact sur la notification |
6416 |
|
$erreursParam = $this->get_info_notification_fail(); |
6417 |
|
if (! $this->dossier_depose_sur_portail() && $erreursParam != array()) { |
6418 |
|
$demandeurPrincipalNotifie = false; |
6419 |
|
continue; |
6420 |
|
} |
6421 |
|
} |
6422 |
|
// Ajout de la notif et récupération de son id |
6423 |
|
$idNotif = $this->ajouter_notification( |
6424 |
|
$this->getVal($this->clePrimaire), |
6425 |
|
$this->f->get_connected_user_login_name(), |
6426 |
|
$demandeur, |
6427 |
|
$collectivite_di, |
6428 |
|
array(), |
6429 |
|
true |
6430 |
|
); |
6431 |
|
if ($idNotif === false) { |
6432 |
|
// Termine le traitement |
6433 |
|
$this->addToLog( |
6434 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
6435 |
|
DEBUG_MODE |
6436 |
|
); |
6437 |
|
return $this->end_treatment(__METHOD__, false); |
6438 |
|
} |
6439 |
|
$notification_by_task = $this->notification_by_task( |
6440 |
|
$idNotif, |
6441 |
|
$this->getVal('dossier'), |
6442 |
|
$categorie |
6443 |
|
); |
6444 |
|
if ($notification_by_task === false) { |
6445 |
|
$this->addToLog( |
6446 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
6447 |
|
DEBUG_MODE |
6448 |
|
); |
6449 |
|
$this->addToMessage( |
6450 |
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
6451 |
|
); |
6452 |
|
// Termine le traitement |
6453 |
|
return $this->end_treatment(__METHOD__, false); |
6454 |
|
} |
6455 |
|
$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."))); |
6456 |
|
} |
6457 |
|
} |
6458 |
|
// Pour la notification par mail ou la notification via portal si le dossier a |
6459 |
|
// été déposés via portal, si le demandeur principal n'est pas notifiable, |
6460 |
|
// on créé une nouvelle notification en erreur avec en commentaire la raison pour |
6461 |
|
// laquelle le demandeur principal n'a pas pu être notifié |
6462 |
|
$depotPortal = $this->dossier_depose_sur_portail(); |
6463 |
|
if (! $demandeurPrincipalNotifie && ($isPortal === false || $depotPortal === true)) { |
6464 |
|
// Préparation des logs pour indiquer que le pétitionnaire principale n'est pas notifiable |
6465 |
|
$msgLog .= sprintf(' %s', __('Le pétitionnaire principale n\'est pas notifiable.')); |
6466 |
|
// Analyse pour savoir pourquoi le demandeur principal n'est pas notifiable |
6467 |
|
$erreursParam = $this->get_info_notification_fail(); |
6468 |
|
$demandeurPrincipal = $this->get_info_petitionnaire_principal_dossier($this->getVal('dossier')); |
6469 |
|
// Ajout de la notif et récupération de son id |
6470 |
|
$idNotif = $this->ajouter_notification( |
6471 |
|
$this->valF[$this->clePrimaire], |
6472 |
|
$this->f->get_connected_user_login_name(), |
6473 |
|
$demandeurPrincipal, |
6474 |
|
$collectivite_di, |
6475 |
|
array(), |
6476 |
|
true, |
6477 |
|
'Echec', |
6478 |
|
implode(' ', $erreursParam) |
6479 |
|
); |
6480 |
|
if ($idNotif === false) { |
6481 |
|
$this->addToMessage( |
6482 |
|
__('Erreur : la création de la notification a échouée.'). |
6483 |
|
__("Veuillez contacter votre administrateur.") |
6484 |
|
); |
6485 |
|
$this->addToLog( |
6486 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
6487 |
|
DEBUG_MODE |
6488 |
|
); |
6489 |
|
return false; |
6490 |
|
} |
6491 |
|
// Prépare un message d'alerte à destination de l'instructeur pour l'informer |
6492 |
|
// de l'échec de la notification |
6493 |
|
$dossier_message = $this->get_inst_dossier_message(0); |
6494 |
|
$dossier_message_val = array( |
6495 |
|
'dossier' => $this->getVal('dossier'), |
6496 |
|
'type' => _('erreur expedition'), |
6497 |
|
'emetteur' => $this->f->get_connected_user_login_name(), |
6498 |
|
'login' => $_SESSION['login'], |
6499 |
|
'date_emission' => date('Y-m-d H:i:s'), |
6500 |
|
'contenu' => _('Échec lors de la notification de l\'instruction '). |
6501 |
|
$ev->getVal('libelle'). |
6502 |
|
'.<br>'. |
6503 |
|
implode("\n", $erreursParam). |
6504 |
|
'<br>'. |
6505 |
|
_('Veuillez corriger ces informations avant de renvoyer la notification.') |
6506 |
|
); |
6507 |
|
$add = $dossier_message->add_notification_message($dossier_message_val, true); |
6508 |
|
// Si une erreur se produit pendant l'ajout |
6509 |
|
if ($add !== true) { |
6510 |
|
$this->addToLog(__METHOD__."(): Le message d'alerte concernant l'echec de l'envoi de la notification n'a pas pu être envoyé.", DEBUG_MODE); |
6511 |
|
return false; |
6512 |
|
} |
6513 |
|
} |
6514 |
|
} |
6515 |
|
|
6516 |
// Termine le traitement |
// Termine le traitement |
6517 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
6518 |
} |
} |
6519 |
|
|
6520 |
/** |
/** |
6521 |
|
* Récupère l'instance de dossier message. |
6522 |
|
* |
6523 |
|
* @param string $dossier_message Identifiant du message. |
6524 |
|
* |
6525 |
|
* @return object |
6526 |
|
*/ |
6527 |
|
private function get_inst_dossier_message($dossier_message = null) { |
6528 |
|
// |
6529 |
|
return $this->get_inst_common("dossier_message", $dossier_message); |
6530 |
|
} |
6531 |
|
|
6532 |
|
/** |
6533 |
|
* Vérifie si le signataire est obligatoire pour finaliser |
6534 |
|
* le document apartir du paramétrage de l'événement. |
6535 |
|
* Si c'est le cas, vérifie si il y a bien un signataire |
6536 |
|
* renseigné. |
6537 |
|
* Si c'est le cas renvoie true, sinon renvoie false. |
6538 |
|
* |
6539 |
|
* @param evenement évenement de l'instruction permettant de |
6540 |
|
* récupérer le paramétrage |
6541 |
|
* @return boolean |
6542 |
|
*/ |
6543 |
|
protected function controle_signataire($evenement) { |
6544 |
|
// Vérifie si le signataire est obligatoire et si c'est le cas |
6545 |
|
// vérifie si il y a bien un signataire pour le document |
6546 |
|
if ($evenement->is_signataire_obligatoire() && |
6547 |
|
($this->getVal('signataire_arrete') === null || |
6548 |
|
$this->getVal('signataire_arrete') === '')) { |
6549 |
|
return false; |
6550 |
|
} |
6551 |
|
return true; |
6552 |
|
} |
6553 |
|
|
6554 |
|
/** |
6555 |
* TREATMENT - unfinalize. |
* TREATMENT - unfinalize. |
6556 |
* |
* |
6557 |
* Permet de définaliser un enregistrement. |
* Permet de définaliser un enregistrement. |
6594 |
&& $this->getVal("om_final_instruction") != null) { |
&& $this->getVal("om_final_instruction") != null) { |
6595 |
|
|
6596 |
// Ouvre le document |
// Ouvre le document |
6597 |
$lien = '../spg/file.php?obj='.$this->table.'&'. |
$lien = '../app/index.php?module=form&snippet=file&obj='.$this->table.'&'. |
6598 |
'champ=om_fichier_instruction&id='.$this->getVal($this->clePrimaire); |
'champ=om_fichier_instruction&id='.$this->getVal($this->clePrimaire); |
6599 |
// |
// |
6600 |
header("Location: ".$lien); |
header("Location: ".$lien); |
6613 |
"mode" => "previsualisation", |
"mode" => "previsualisation", |
6614 |
), |
), |
6615 |
); |
); |
6616 |
|
// Si la rédaction libre est activée sur l'instruction |
6617 |
|
if ($this->getVal("flag_edition_integrale") == 't') { |
6618 |
|
$params["specific"]["corps"] = array( |
6619 |
|
"mode" => "set", |
6620 |
|
"value" => $this->getVal("corps_om_htmletatex"), |
6621 |
|
); |
6622 |
|
$params["specific"]["titre"] = array( |
6623 |
|
"mode" => "set", |
6624 |
|
"value" => $this->getVal("titre_om_htmletat"), |
6625 |
|
); |
6626 |
|
} |
6627 |
|
|
6628 |
// Génération du PDF |
// Génération du PDF |
6629 |
$result = $this->compute_pdf_output('lettretype', $this->getVal("lettretype"), $collectivite, null, $params); |
$result = $this->compute_pdf_output('lettretype', $this->getVal("lettretype"), $collectivite, null, $params); |
6638 |
/** |
/** |
6639 |
* Récupère la collectivité du dossier d'instruction. |
* Récupère la collectivité du dossier d'instruction. |
6640 |
* |
* |
6641 |
|
* @param string $dossier_instruction_id Identifiant du DI. |
6642 |
|
* |
6643 |
* @return integer |
* @return integer |
6644 |
*/ |
*/ |
6645 |
function get_dossier_instruction_om_collectivite() { |
function get_dossier_instruction_om_collectivite($dossier_instruction_id = null) { |
6646 |
|
|
6647 |
|
// Si l'identifiant n'est pas renseigné |
6648 |
|
if ($dossier_instruction_id === null) { |
6649 |
|
// Récupère la valeur |
6650 |
|
if ($this->getVal('dossier') !== null && $this->getVal('dossier') !== '') { |
6651 |
|
$dossier_instruction_id = $this->getVal('dossier'); |
6652 |
|
} elseif ($this->getParameter('idxformulaire') !== null |
6653 |
|
&& $this->getParameter('idxformulaire') !== '') { |
6654 |
|
// |
6655 |
|
$dossier_instruction_id = $this->getParameter('idxformulaire'); |
6656 |
|
} elseif ($this->f->get_submitted_get_value('idxformulaire') !== null |
6657 |
|
&& $this->f->get_submitted_get_value('idxformulaire') !== '') { |
6658 |
|
// |
6659 |
|
$dossier_instruction_id = $this->f->get_submitted_get_value('idxformulaire'); |
6660 |
|
} |
6661 |
|
} |
6662 |
|
|
6663 |
// |
// |
6664 |
require_once "../obj/dossier_instruction.class.php"; |
$dossier_instruction = $this->f->get_inst__om_dbform(array( |
6665 |
$dossier_instruction = new dossier_instruction($this->getVal('dossier'), $this->f->db, false); |
"obj" => "dossier_instruction", |
6666 |
|
"idx" => $dossier_instruction_id, |
6667 |
|
)); |
6668 |
|
|
6669 |
// |
// |
6670 |
return $dossier_instruction->getVal('om_collectivite'); |
return $dossier_instruction->getVal('om_collectivite'); |
6681 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
6682 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
6683 |
|
|
|
// XXX APP |
|
|
|
|
|
$f = $this->f; |
|
|
|
|
6684 |
/** |
/** |
6685 |
* Affichage de la structure HTML |
* Affichage de la structure HTML |
6686 |
*/ |
*/ |
6687 |
// |
// |
6688 |
if ($f->isAjaxRequest()) { |
if ($this->f->isAjaxRequest()) { |
6689 |
// |
// |
6690 |
header("Content-type: text/html; charset=".HTTPCHARSET.""); |
header("Content-type: text/html; charset=".HTTPCHARSET.""); |
6691 |
} else { |
} else { |
6692 |
// |
// |
6693 |
$f->setFlag("htmlonly"); |
$this->f->setFlag("htmlonly"); |
6694 |
$f->display(); |
$this->f->display(); |
6695 |
} |
} |
6696 |
// |
// |
6697 |
$f->displayStartContent(); |
$this->f->displayStartContent(); |
6698 |
// |
// |
6699 |
$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")); |
6700 |
$f->displayTitle(); |
$this->f->displayTitle(); |
6701 |
|
|
6702 |
/** |
/** |
6703 |
* |
* |
6704 |
*/ |
*/ |
6705 |
// |
// |
6706 |
($f->get_submitted_get_value("ev") ? $evenement = $f->get_submitted_get_value("ev") : $evenement = ""); |
($this->f->get_submitted_get_value("ev") ? $evenement = $this->f->get_submitted_get_value("ev") : $evenement = ""); |
6707 |
$evenement = intval($evenement); |
$evenement = intval($evenement); |
6708 |
// |
// |
6709 |
($f->get_submitted_get_value("idx") ? $idx = $f->get_submitted_get_value("idx") : $idx = ""); |
($this->f->get_submitted_get_value("idx") ? $idx = $this->f->get_submitted_get_value("idx") : $idx = ""); |
6710 |
// Récupération du code du type de DA |
// Récupération du code du type de DA |
6711 |
$code_da_type = ''; |
$code_da_type = ''; |
6712 |
if (preg_match('/[A-Za-z]{2,3}/', $idx, $matches) !== false) { |
if (preg_match('/[A-Za-z]{2,3}/', $idx, $matches) !== false) { |
6713 |
$code_da_type = $matches[0]; |
$code_da_type = $matches[0]; |
6714 |
} |
} |
6715 |
// |
// |
6716 |
($f->get_submitted_get_value("complement") ? $complement = $f->get_submitted_get_value("complement") : $complement = "1"); |
($this->f->get_submitted_get_value("complement") ? $complement = $this->f->get_submitted_get_value("complement") : $complement = "1"); |
6717 |
|
|
6718 |
// Récupération de la collectivité du dossier |
// Récupération de la collectivité du dossier |
6719 |
require_once "../obj/dossier.class.php"; |
$dossier = $this->f->get_inst__om_dbform(array( |
6720 |
$dossier = new dossier($idx, $f->db, DEBUG); |
"obj" => "dossier", |
6721 |
|
"idx" => $idx, |
6722 |
|
)); |
6723 |
|
|
6724 |
/** |
/** |
6725 |
* |
* |
6731 |
ON bible.dossier_autorisation_type=dossier_autorisation_type.dossier_autorisation_type |
ON bible.dossier_autorisation_type=dossier_autorisation_type.dossier_autorisation_type |
6732 |
LEFT JOIN ".DB_PREFIXE."om_collectivite |
LEFT JOIN ".DB_PREFIXE."om_collectivite |
6733 |
ON bible.om_collectivite = om_collectivite.om_collectivite |
ON bible.om_collectivite = om_collectivite.om_collectivite |
6734 |
WHERE evenement=".$evenement." |
WHERE (evenement=".$evenement." OR evenement IS NULL) |
6735 |
AND complement=".$complement." |
AND (complement=".$complement." OR complement IS NULL) |
6736 |
AND (bible.dossier_autorisation_type IS NULL |
AND (bible.dossier_autorisation_type IS NULL |
6737 |
OR dossier_autorisation_type.code ='".$code_da_type."') |
OR dossier_autorisation_type.code ='".$code_da_type."') |
6738 |
AND (om_collectivite.niveau = '2' |
AND (om_collectivite.niveau = '2' |
6739 |
OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").") |
OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").") |
6740 |
ORDER BY bible_lib ASC"; |
ORDER BY bible_lib ASC"; |
6741 |
$res = $f->db->query($sql); |
$res = $this->f->db->query($sql); |
6742 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\");", VERBOSE_MODE); |
6743 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
6744 |
// |
// |
6745 |
echo "<form method=\"post\" name=\"f3\" action=\"#\">\n"; |
echo "<form method=\"post\" name=\"f3\" action=\"#\">\n"; |
6746 |
// |
// |
6772 |
echo "\t</table>\n"; |
echo "\t</table>\n"; |
6773 |
// |
// |
6774 |
echo "<div class=\"formControls\">\n"; |
echo "<div class=\"formControls\">\n"; |
6775 |
$f->layout->display_form_button(array( |
$this->f->layout->display_form_button(array( |
6776 |
"value" => _("Valider"), |
"value" => _("Valider"), |
6777 |
"onclick" => "bible_return('f2', 'complement".($complement == "1" ? "" : $complement)."_om_html'); return false;", |
"onclick" => "bible_return('f2', 'complement".($complement == "1" ? "" : $complement)."_om_html'); return false;", |
6778 |
)); |
)); |
6779 |
$f->displayLinkJsCloseWindow(); |
$this->f->displayLinkJsCloseWindow(); |
6780 |
echo "</div>\n"; |
echo "</div>\n"; |
6781 |
|
|
6782 |
} else { |
} else { |
6783 |
// |
// |
6784 |
$message_class = "error"; |
$message_class = "error"; |
6785 |
$message = _("Aucun element dans la bible pour l'evenement")." : ".$evenement; |
$message = _("Aucun element dans la bible pour l'evenement")." : ".$evenement; |
6786 |
$f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
6787 |
// |
// |
6788 |
echo "<div class=\"formControls\">\n"; |
echo "<div class=\"formControls\">\n"; |
6789 |
$f->displayLinkJsCloseWindow(); |
$this->f->displayLinkJsCloseWindow(); |
6790 |
echo "</div>\n"; |
echo "</div>\n"; |
6791 |
} |
} |
6792 |
// |
// |
6796 |
* Affichage de la structure HTML |
* Affichage de la structure HTML |
6797 |
*/ |
*/ |
6798 |
// |
// |
6799 |
$f->displayEndContent(); |
$this->f->displayEndContent(); |
6800 |
} |
} |
6801 |
|
|
6802 |
/** |
/** |
6809 |
function view_bible_auto() { |
function view_bible_auto() { |
6810 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
6811 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
|
|
|
|
// XXX APP |
|
|
|
|
|
$f = $this->f; |
|
|
|
|
6812 |
// |
// |
6813 |
$f->disableLog(); |
$this->f->disableLog(); |
6814 |
|
|
6815 |
$formatDate="AAAA-MM-JJ"; |
$formatDate="AAAA-MM-JJ"; |
6816 |
|
|
6817 |
// Récupération des paramètres |
// Récupération des paramètres |
6818 |
$idx = $f->get_submitted_get_value('idx'); |
$idx = $this->f->get_submitted_get_value('idx'); |
6819 |
$evenement = $f->get_submitted_get_value('ev'); |
$evenement = $this->f->get_submitted_get_value('ev'); |
6820 |
|
|
6821 |
// Initialisation de la variable de retour |
// Initialisation de la variable de retour |
6822 |
$retour['complement_om_html'] = ''; |
$retour['complement_om_html'] = ''; |
6823 |
$retour['complement2_om_html'] = ''; |
$retour['complement2_om_html'] = ''; |
6824 |
$retour['complement3_om_html'] = ''; |
$retour['complement3_om_html'] = ''; |
6825 |
$retour['complement4_om_html'] = ''; |
$retour['complement4_om_html'] = ''; |
6826 |
|
|
6827 |
// Vérification d'une consultation liée à l'événement |
// Vérification d'une consultation liée à l'événement |
6828 |
$consultation = $f->db->getOne( |
$instEvenement = $this->f->get_inst__om_dbform(array( |
6829 |
"select consultation from ".DB_PREFIXE."evenement where evenement=".$evenement |
"obj" => "evenement", |
6830 |
); |
"idx" => $evenement, |
6831 |
$f->isDatabaseError($consultation); |
)); |
6832 |
|
|
6833 |
// Si consultation liée, récupération du retour d'avis |
// Si consultation liée, récupération du retour d'avis |
6834 |
if($consultation=='Oui'){ |
if($instEvenement->getVal('consultation') == 'Oui'){ |
6835 |
$sql="select date_retour,avis_consultation.libelle as avis_consultation, |
$sql = sprintf( |
6836 |
service.libelle as service |
'(SELECT |
6837 |
from ".DB_PREFIXE."consultation inner join ".DB_PREFIXE."service |
date_retour, |
6838 |
on consultation.service =service.service |
avis_consultation.libelle as avis_consultation, |
6839 |
left join ".DB_PREFIXE."avis_consultation on |
COALESCE(service.libelle, tiers_consulte.libelle) as service |
6840 |
consultation.avis_consultation = avis_consultation.avis_consultation |
FROM |
6841 |
where dossier ='".$idx."'"; |
%1$sconsultation |
6842 |
$res = $f->db->query($sql); |
LEFT JOIN %1$stiers_consulte ON consultation.tiers_consulte = tiers_consulte.tiers_consulte |
6843 |
$f->isDatabaseError($res); |
LEFT JOIN %1$sservice ON consultation.service = service.service |
6844 |
|
LEFT JOIN %1$savis_consultation ON consultation.avis_consultation = avis_consultation.avis_consultation |
6845 |
|
WHERE |
6846 |
|
dossier = \'%2$s\' |
6847 |
|
AND consultation.visible)', |
6848 |
|
DB_PREFIXE, |
6849 |
|
$this->f->db->escapeSimple($idx) |
6850 |
|
); |
6851 |
|
$res = $this->f->db->query($sql); |
6852 |
|
$this->f->isDatabaseError($res); |
6853 |
// Récupération des consultations |
// Récupération des consultations |
6854 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
6855 |
$correct=false; |
$correct=false; |
6874 |
$temp=$temp." du ".$date_retour_f; |
$temp=$temp." du ".$date_retour_f; |
6875 |
} |
} |
6876 |
// Concaténation des retours d'avis de consultation |
// Concaténation des retours d'avis de consultation |
6877 |
$retour['complement_om_html'] .= $temp; |
$retour['complement_om_html'] .= $temp . "<br/><br/>"; |
6878 |
} // while |
} // while |
6879 |
|
|
6880 |
} // consultation |
} // consultation |
6881 |
// Récupération des bibles automatiques pour le champ complement_om_html |
// Récupération des bibles automatiques pour le champ complement_om_html |
6882 |
$retour['complement_om_html'] .= $this->getBible($f, $evenement, $idx, '1'); |
$retour['complement_om_html'] .= $this->getBible($evenement, $idx, '1'); |
6883 |
// Récupération des bibles automatiques pour le champ complement2_om_html |
// Récupération des bibles automatiques pour le champ complement2_om_html |
6884 |
$retour['complement2_om_html'] .= $this->getBible($f, $evenement, $idx, '2'); |
$retour['complement2_om_html'] .= $this->getBible($evenement, $idx, '2'); |
6885 |
// Récupération des bibles automatiques pour le champ complement3_om_html |
// Récupération des bibles automatiques pour le champ complement3_om_html |
6886 |
$retour['complement3_om_html'] .= $this->getBible($f, $evenement, $idx, '3'); |
$retour['complement3_om_html'] .= $this->getBible($evenement, $idx, '3'); |
6887 |
// Récupération des bibles automatiques pour le champ complement4_om_html |
// Récupération des bibles automatiques pour le champ complement4_om_html |
6888 |
$retour['complement4_om_html'] .= $this->getBible($f, $evenement, $idx, '4'); |
$retour['complement4_om_html'] .= $this->getBible($evenement, $idx, '4'); |
6889 |
|
|
6890 |
|
|
6891 |
|
|
6893 |
} |
} |
6894 |
|
|
6895 |
/** |
/** |
6896 |
|
* VIEW - view_pdf_temp |
6897 |
|
* |
6898 |
|
* @return void |
6899 |
|
*/ |
6900 |
|
function view_pdf_temp() { |
6901 |
|
$this->checkAccessibility(); |
6902 |
|
// Utilisation de $_POST pour ne pas que les textes soient altérés. |
6903 |
|
$this->f->set_submitted_value(); |
6904 |
|
$merge_fields = array(); |
6905 |
|
// |
6906 |
|
if (array_key_exists('c1', $_POST) === true) { |
6907 |
|
$merge_fields['[complement_instruction]'] = $_POST['c1']; |
6908 |
|
$merge_fields['[complement1_instruction]'] = $_POST['c1']; |
6909 |
|
} |
6910 |
|
if (array_key_exists('c2', $_POST) === true) { |
6911 |
|
$merge_fields['[complement2_instruction]'] = $_POST['c2']; |
6912 |
|
} |
6913 |
|
if (array_key_exists('c3', $_POST) === true) { |
6914 |
|
$merge_fields['[complement3_instruction]'] = $_POST['c3']; |
6915 |
|
} |
6916 |
|
if (array_key_exists('c4', $_POST) === true) { |
6917 |
|
$merge_fields['[complement4_instruction]'] = $_POST['c4']; |
6918 |
|
} |
6919 |
|
$params = array( |
6920 |
|
"watermark" => true, |
6921 |
|
"specific" => array( |
6922 |
|
"merge_fields" => $merge_fields, |
6923 |
|
), |
6924 |
|
); |
6925 |
|
// |
6926 |
|
if (array_key_exists('corps', $_POST) === true) { |
6927 |
|
$params["specific"]["corps"] = array( |
6928 |
|
"mode" => "set", |
6929 |
|
"value" => $_POST['corps'], |
6930 |
|
); |
6931 |
|
} |
6932 |
|
if (array_key_exists('titre', $_POST) === true) { |
6933 |
|
$params["specific"]["titre"] = array( |
6934 |
|
"mode" => "set", |
6935 |
|
"value" => $_POST['titre'], |
6936 |
|
); |
6937 |
|
} |
6938 |
|
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
6939 |
|
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
6940 |
|
$result = $this->compute_pdf_output('lettretype', $this->getVal('lettretype'), $collectivite, null, $params); |
6941 |
|
$retour = array( |
6942 |
|
'base' => base64_encode($result['pdf_output']), |
6943 |
|
); |
6944 |
|
echo json_encode($retour); |
6945 |
|
} |
6946 |
|
|
6947 |
|
/** |
6948 |
|
* Dans le contexte de prévisualisation des éditions, génère le rendu du |
6949 |
|
* PDF sans prise en compte de la valeur des compléments et le retourne en |
6950 |
|
* base 64. |
6951 |
|
* |
6952 |
|
* @return string Rendu PDF converti en base 64. |
6953 |
|
*/ |
6954 |
|
function init_pdf_temp() { |
6955 |
|
$params = array( |
6956 |
|
"watermark" => true, |
6957 |
|
); |
6958 |
|
// Si la rédaction libre est activée sur l'instruction |
6959 |
|
if ($this->getVal("flag_edition_integrale") == 't') { |
6960 |
|
$params["specific"]["corps"] = array( |
6961 |
|
"mode" => "set", |
6962 |
|
"value" => $this->getVal("corps_om_htmletatex"), |
6963 |
|
); |
6964 |
|
$params["specific"]["titre"] = array( |
6965 |
|
"mode" => "set", |
6966 |
|
"value" => $this->getVal("titre_om_htmletat"), |
6967 |
|
); |
6968 |
|
} |
6969 |
|
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
6970 |
|
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
6971 |
|
$result = $this->compute_pdf_output('lettretype', $this->getVal('lettretype'), $collectivite, null, $params); |
6972 |
|
|
6973 |
|
return base64_encode($result['pdf_output']); |
6974 |
|
} |
6975 |
|
|
6976 |
|
/** |
6977 |
* Récupération des éléments de bible. |
* Récupération des éléments de bible. |
6978 |
* |
* |
|
* @param utils $f handler de om_application |
|
6979 |
* @param integer $event id de l'événement |
* @param integer $event id de l'événement |
6980 |
* @param string $idx id du dossier |
* @param string $idx id du dossier |
6981 |
* @param integer $compnb numéro du champ complement |
* @param integer $compnb numéro du champ complement |
6982 |
* |
* |
6983 |
* @return string Chaîne de texte à insérer dans le champ complement |
* @return string Chaîne de texte à insérer dans le champ complement |
6984 |
*/ |
*/ |
6985 |
function getBible($f, $event, $idx, $compnb) { |
function getBible($event, $idx, $compnb) { |
6986 |
// Récupération de la collectivité du dossier |
// Récupération de la collectivité du dossier |
6987 |
require_once "../obj/dossier.class.php"; |
$dossier = $this->f->get_inst__om_dbform(array( |
6988 |
$dossier = new dossier($idx, $f->db, DEBUG); |
"obj" => "dossier", |
6989 |
|
"idx" => $idx, |
6990 |
|
)); |
6991 |
// Récupération du code du type de DA |
// Récupération du code du type de DA |
6992 |
$code_da_type = ''; |
$code_da_type = ''; |
6993 |
if (preg_match('/[A-Za-z]{2,3}/', $idx, $matches) !== false) { |
if (preg_match('/[A-Za-z]{2,3}/', $idx, $matches) !== false) { |
7001 |
LEFT JOIN |
LEFT JOIN |
7002 |
".DB_PREFIXE."om_collectivite |
".DB_PREFIXE."om_collectivite |
7003 |
ON bible.om_collectivite = om_collectivite.om_collectivite |
ON bible.om_collectivite = om_collectivite.om_collectivite |
7004 |
WHERE evenement =".$event." and |
WHERE (evenement =".$event." or evenement IS NULL) and |
7005 |
complement=".$compnb." and |
(complement=".$compnb." OR complement IS NULL) and |
7006 |
automatique='Oui' and |
automatique='Oui' and |
7007 |
(dossier_autorisation_type.code ='".$code_da_type."' or |
(dossier_autorisation_type.code ='".$code_da_type."' or |
7008 |
bible.dossier_autorisation_type IS NULL) and |
bible.dossier_autorisation_type IS NULL) and |
7009 |
(om_collectivite.niveau = '2' OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").")"; |
(om_collectivite.niveau = '2' OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").")"; |
7010 |
|
|
7011 |
$res = $f->db->query($sql); |
$res = $this->f->db->query($sql); |
7012 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
7013 |
$temp = ""; |
$temp = ""; |
7014 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
7015 |
// Remplacement des retours à la ligne par des br |
// Remplacement des retours à la ligne par des br |
7016 |
$temp .= preg_replace( |
$temp .= preg_replace( |
7017 |
'#(\\\r|\\\r\\\n|\\\n)#', '<br/>', $row['contenu'] |
'#(\\\r|\\\r\\\n|\\\n)#', '<br/>', $row['contenu'] |
7018 |
); |
); |
7019 |
|
// Ajout d'un saut de ligne entre chaque bible. |
7020 |
|
$temp .= '<br/>'; |
7021 |
} // fin while |
} // fin while |
7022 |
return $temp; |
return $temp; |
7023 |
} |
} |
7035 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
7036 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
7037 |
|
|
|
// XXX APP |
|
|
|
|
|
$f = $this->f; |
|
|
|
|
7038 |
/** |
/** |
7039 |
* Validation du formulaire |
* Validation du formulaire |
7040 |
*/ |
*/ |
7041 |
// Si le formulaire a été validé |
// Si le formulaire a été validé |
7042 |
if ($f->get_submitted_post_value("validation") !== null) { |
if ($this->f->get_submitted_post_value("validation") !== null) { |
7043 |
// Si un bordereau à été sélectionné |
// Si un bordereau à été sélectionné |
7044 |
if ($f->get_submitted_post_value("bordereau") !== null && $f->get_submitted_post_value("bordereau") == "" ) { |
if ($this->f->get_submitted_post_value("bordereau") !== null && $this->f->get_submitted_post_value("bordereau") == "" ) { |
7045 |
// Si aucun bordereau n'a été sélectionné |
// Si aucun bordereau n'a été sélectionné |
7046 |
$message_class = "error"; |
$message_class = "error"; |
7047 |
$message = _("Veuillez selectionner un bordereau."); |
$message = _("Veuillez selectionner un bordereau."); |
7048 |
} |
} |
7049 |
// Sinon si les dates ne sont pas valide |
// Sinon si les dates ne sont pas valide |
7050 |
elseif (($f->get_submitted_post_value("date_bordereau_debut") !== null |
elseif (($this->f->get_submitted_post_value("date_bordereau_debut") !== null |
7051 |
&& $f->get_submitted_post_value("date_bordereau_debut") == "") |
&& $this->f->get_submitted_post_value("date_bordereau_debut") == "") |
7052 |
|| ($f->get_submitted_post_value("date_bordereau_fin") !== null |
|| ($this->f->get_submitted_post_value("date_bordereau_fin") !== null |
7053 |
&& $f->get_submitted_post_value("date_bordereau_fin") == "")) { |
&& $this->f->get_submitted_post_value("date_bordereau_fin") == "")) { |
7054 |
// Si aucune date n'a été saisie |
// Si aucune date n'a été saisie |
7055 |
$message_class = "error"; |
$message_class = "error"; |
7056 |
$message = _("Veuillez saisir une date valide."); |
$message = _("Veuillez saisir une date valide."); |
7057 |
} |
} |
7058 |
|
// Sinon si les dates ne sont pas valides |
7059 |
|
elseif ($this->f->get_submitted_post_value("bordereau") === "bordereau_avis_maire_prefet" |
7060 |
|
&& $this->f->getParameter("id_evenement_bordereau_avis_maire_prefet") == null) { |
7061 |
|
// Si aucune date n'a été saisie |
7062 |
|
$message_class = "error"; |
7063 |
|
$message = _("Erreur de parametrage. Contactez votre administrateur."); |
7064 |
|
} |
7065 |
// Affiche le message de validation |
// Affiche le message de validation |
7066 |
else { |
else { |
7067 |
// 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 |
7068 |
$sql = "SELECT om_etat.libelle |
$etat = $this->f->get_inst__om_dbform(array( |
7069 |
FROM ".DB_PREFIXE."om_etat |
"obj" => "om_etat", |
7070 |
WHERE om_etat.id = '".$f->get_submitted_post_value("bordereau")."'"; |
"idx" => $this->f->get_submitted_post_value("bordereau") |
7071 |
$res = $f->db->getone($sql); |
)); |
7072 |
$f->addToLog(__METHOD__.": db->getone(\"".$sql."\")", VERBOSE_MODE); |
$qres = $this->f->get_one_result_from_db_query( |
7073 |
$f->isDatabaseError($res); |
sprintf( |
7074 |
|
'SELECT |
7075 |
|
om_etat.libelle |
7076 |
|
FROM |
7077 |
|
%som_etat |
7078 |
|
WHERE |
7079 |
|
om_etat.id = \'%s\'', |
7080 |
|
DB_PREFIXE, |
7081 |
|
$this->f->db->escapeSimple($this->f->get_submitted_post_value("bordereau")) |
7082 |
|
), |
7083 |
|
array( |
7084 |
|
"origin" => __METHOD__, |
7085 |
|
) |
7086 |
|
); |
7087 |
|
|
7088 |
// |
// |
7089 |
$message_class = "valid"; |
$message_class = "valid"; |
7090 |
$message = _("Cliquez sur le lien ci-dessous pour telecharger votre bordereau"); |
$message = _("Cliquez sur le lien ci-dessous pour telecharger votre bordereau"); |
7091 |
$message .= " : <br/><br/>"; |
$message .= " : <br/><br/>"; |
7092 |
$message .= "<a class='om-prev-icon pdf-16'"; |
$message .= "<a class='om-prev-icon pdf-16'"; |
7093 |
$message .= " title=\""._("Bordereau")."\""; |
$message .= " title=\""._("Bordereau")."\""; |
7094 |
$message .= "href='../scr/form.php?obj=instruction"; |
$message .= "href='".OM_ROUTE_FORM."&obj=instruction"; |
7095 |
$message .= "&action=220"; |
$message .= "&action=220"; |
7096 |
$message .= "&idx=0"; |
$message .= "&idx=0"; |
7097 |
$message .= "&type_bordereau=".$f->get_submitted_post_value("bordereau"); |
$message .= "&type_bordereau=".$this->f->get_submitted_post_value("bordereau"); |
7098 |
$message .= "&date_bordereau_debut=".$f->get_submitted_post_value("date_bordereau_debut"); |
$message .= "&date_bordereau_debut=".$this->f->get_submitted_post_value("date_bordereau_debut"); |
7099 |
$message .= "&date_bordereau_fin=".$f->get_submitted_post_value("date_bordereau_fin"); |
$message .= "&date_bordereau_fin=".$this->f->get_submitted_post_value("date_bordereau_fin"); |
7100 |
// Si l'utilisateur est MULTI alors on ajoute le paramètre collectivite |
// Si l'utilisateur est MULTI alors on ajoute le paramètre collectivite |
7101 |
if ($f->get_submitted_post_value("om_collectivite") !== null) { |
if ($this->f->get_submitted_post_value("om_collectivite") !== null) { |
7102 |
$message .= "&collectivite=".$f->get_submitted_post_value("om_collectivite"); |
$message .= "&collectivite=".$this->f->get_submitted_post_value("om_collectivite"); |
7103 |
} |
} |
7104 |
$message .= "'"." target='_blank'>"; |
$message .= "'"." target='_blank'>"; |
7105 |
$message .= $res." "._("du")." ".$f->get_submitted_post_value("date_bordereau_debut") |
$message .= $qres['result']." "._("du")." ".$this->f->get_submitted_post_value("date_bordereau_debut") |
7106 |
." "._("au")." ".$f->get_submitted_post_value("date_bordereau_fin"); |
." "._("au")." ".$this->f->get_submitted_post_value("date_bordereau_fin"); |
7107 |
$message .= "</a>"; |
$message .= "</a>"; |
7108 |
} |
} |
7109 |
} |
} |
7113 |
*/ |
*/ |
7114 |
// Affichage du message de validation ou d'erreur |
// Affichage du message de validation ou d'erreur |
7115 |
if (isset($message) && isset($message_class) && $message != "") { |
if (isset($message) && isset($message_class) && $message != "") { |
7116 |
$f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
7117 |
} |
} |
|
// Inclusion de la classe de gestion des formulaires |
|
|
require_once "../obj/om_formulaire.class.php"; |
|
7118 |
// Ouverture du formulaire |
// Ouverture du formulaire |
7119 |
printf("\t<form"); |
printf("\t<form"); |
7120 |
printf(" method=\"post\""); |
printf(" method=\"post\""); |
7123 |
printf(">\n"); |
printf(">\n"); |
7124 |
// Paramétrage des champs du formulaire |
// Paramétrage des champs du formulaire |
7125 |
$champs = array("date_bordereau_debut", "date_bordereau_fin", "bordereau"); |
$champs = array("date_bordereau_debut", "date_bordereau_fin", "bordereau"); |
7126 |
// Si l'utilisateur est d'une collectivité de niveau 2 on affiche un select |
// Si l'utilisateur est d'une collectivité de niveau 2 on affiche un select |
7127 |
// collectivité dans le formulaire |
// collectivité dans le formulaire |
7128 |
if($_SESSION["niveau"] == 2) { |
if ($_SESSION["niveau"] == 2) { |
7129 |
array_push($champs, "om_collectivite"); |
array_push($champs, "om_collectivite"); |
7130 |
} |
} |
7131 |
// Création d'un nouvel objet de type formulaire |
// Création d'un nouvel objet de type formulaire |
7132 |
$form = new formulaire(NULL, 0, 0, $champs); |
$form = $this->f->get_inst__om_formulaire(array( |
7133 |
|
"validation" => 0, |
7134 |
|
"maj" => 0, |
7135 |
|
"champs" => $champs, |
7136 |
|
)); |
7137 |
// Paramétrage du champ date_bordereau_debut |
// Paramétrage du champ date_bordereau_debut |
7138 |
$form->setLib("date_bordereau_debut", _("date_bordereau_debut")); |
$form->setLib("date_bordereau_debut", _("date_bordereau_debut")); |
7139 |
$form->setType("date_bordereau_debut", "date"); |
$form->setType("date_bordereau_debut", "date"); |
7155 |
$form->setType("bordereau", "select"); |
$form->setType("bordereau", "select"); |
7156 |
$form->setRequired("bordereau"); |
$form->setRequired("bordereau"); |
7157 |
// Valeurs des champs |
// Valeurs des champs |
7158 |
if ($f->get_submitted_post_value("validation") !== null) { |
if ($this->f->get_submitted_post_value("validation") !== null) { |
7159 |
$form->setVal("date_bordereau_debut", $f->get_submitted_post_value("date_bordereau_debut")); |
$form->setVal("date_bordereau_debut", $this->f->get_submitted_post_value("date_bordereau_debut")); |
7160 |
$form->setVal("date_bordereau_fin", $f->get_submitted_post_value("date_bordereau_fin")); |
$form->setVal("date_bordereau_fin", $this->f->get_submitted_post_value("date_bordereau_fin")); |
7161 |
$form->setVal("bordereau", $f->get_submitted_post_value("bordereau")); |
$form->setVal("bordereau", $this->f->get_submitted_post_value("bordereau")); |
7162 |
$form->setVal("om_collectivite", $f->get_submitted_post_value("om_collectivite")); |
$form->setVal("om_collectivite", $this->f->get_submitted_post_value("om_collectivite")); |
7163 |
} |
} |
7164 |
// 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 |
7165 |
// 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 |
7168 |
FROM ".DB_PREFIXE."om_etat |
FROM ".DB_PREFIXE."om_etat |
7169 |
WHERE om_etat.id LIKE 'bordereau_%' |
WHERE om_etat.id LIKE 'bordereau_%' |
7170 |
ORDER BY om_etat.id"; |
ORDER BY om_etat.id"; |
7171 |
$res = $f->db->query($sql); |
$res = $this->f->db->query($sql); |
7172 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
7173 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
7174 |
// Données du select |
// Données du select |
7175 |
$contenu = array( |
$contenu = array( |
7176 |
0 => array("", ), |
0 => array("", ), |
7181 |
$contenu[1][] = $row['libelle']; |
$contenu[1][] = $row['libelle']; |
7182 |
} |
} |
7183 |
$form->setSelect("bordereau", $contenu); |
$form->setSelect("bordereau", $contenu); |
7184 |
// |
// |
7185 |
if($_SESSION["niveau"] == 2) { |
if ($_SESSION["niveau"] == 2) { |
7186 |
$form->setLib("om_collectivite", _("collectivite")); |
$form->setLib("om_collectivite", _("collectivite")); |
7187 |
$form->setType("om_collectivite", "select"); |
$form->setType("om_collectivite", "select"); |
7188 |
|
|
7189 |
// 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 |
7190 |
// de niveau 1 |
// de niveau 1 |
7191 |
$sql = "SELECT om_collectivite, libelle |
$sql = "SELECT om_collectivite, libelle |
7192 |
FROM ".DB_PREFIXE."om_collectivite |
FROM ".DB_PREFIXE."om_collectivite |
7193 |
WHERE niveau = '1' ORDER BY libelle"; |
WHERE niveau = '1' ORDER BY libelle"; |
7194 |
$res = $f->db->query($sql); |
$res = $this->f->db->query($sql); |
7195 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
7196 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
7197 |
// La valeur par défaut du select est Toutes |
// La valeur par défaut du select est Toutes |
7198 |
$list_collectivites = array( |
$list_collectivites = array( |
7199 |
0 => array("", ), |
0 => array("", ), |
7200 |
1 => array(_("toutes")) |
1 => array(_("toutes")) |
7201 |
); |
); |
|
|
|
|
$id_colls = ""; |
|
|
// On stocke dans $id_colls l'id de toutes les collectivités de niveau 1 séparées |
|
|
// par des virgules, pour un traitement plus facile dans la requête de sous-état |
|
|
while ($row =& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
|
|
if ($id_colls != "") { |
|
|
$id_colls .= ","; |
|
|
} |
|
|
$id_colls .= $row['om_collectivite']; |
|
|
$list_collectivites[0][] = $row['om_collectivite']; |
|
|
$list_collectivites[1][] = $row['libelle']; |
|
|
} |
|
|
// On affecte la liste d'identifiants à l'option Toutes |
|
|
$list_collectivites[0][0] = $id_colls ; |
|
|
$form->setSelect("om_collectivite", $list_collectivites); |
|
|
} |
|
7202 |
|
|
7203 |
|
$id_colls = ""; |
7204 |
|
// On stocke dans $id_colls l'id de toutes les collectivités de niveau 1 séparées |
7205 |
|
// par des virgules, pour un traitement plus facile dans la requête de sous-état |
7206 |
|
while ($row =& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
7207 |
|
if ($id_colls != "") { |
7208 |
|
$id_colls .= ","; |
7209 |
|
} |
7210 |
|
$id_colls .= $row['om_collectivite']; |
7211 |
|
$list_collectivites[0][] = $row['om_collectivite']; |
7212 |
|
$list_collectivites[1][] = $row['libelle']; |
7213 |
|
} |
7214 |
|
// On affecte la liste d'identifiants à l'option Toutes |
7215 |
|
$list_collectivites[0][0] = $id_colls ; |
7216 |
|
$form->setSelect("om_collectivite", $list_collectivites); |
7217 |
|
} |
7218 |
// Affichage du formulaire |
// Affichage du formulaire |
7219 |
$form->entete(); |
$form->entete(); |
7220 |
$form->afficher($champs, 0, false, false); |
$form->afficher($champs, 0, false, false); |
7221 |
$form->enpied(); |
$form->enpied(); |
7222 |
// Affichage du bouton |
// Affichage du bouton |
7223 |
printf("\t<div class=\"formControls\">\n"); |
printf("\t<div class=\"formControls\">\n"); |
7224 |
$f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
$this->f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
7225 |
printf("\t</div>\n"); |
printf("\t</div>\n"); |
7226 |
// Fermeture du formulaire |
// Fermeture du formulaire |
7227 |
printf("\t</form>\n"); |
printf("\t</form>\n"); |
|
|
|
7228 |
} |
} |
7229 |
|
|
7230 |
|
|
7253 |
/** |
/** |
7254 |
* VIEW - view_suivi_envoi_lettre_rar. |
* VIEW - view_suivi_envoi_lettre_rar. |
7255 |
* |
* |
7256 |
* Vu pour imprimer les RAR. |
* Vue pour imprimer les AR. |
7257 |
* |
* |
7258 |
* @return void |
* @return void |
7259 |
*/ |
*/ |
7261 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
7262 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
7263 |
|
|
|
// XXX APP |
|
|
|
|
|
$f = $this->f; |
|
|
|
|
7264 |
// |
// |
7265 |
if ($f->get_submitted_post_value("date") !== null) { |
if ($this->f->get_submitted_post_value("date") !== null) { |
7266 |
$date = $f->get_submitted_post_value("date"); |
$date = $this->f->get_submitted_post_value("date"); |
7267 |
} else { |
} else { |
7268 |
$date = ""; |
$date = ""; |
7269 |
} |
} |
7270 |
// |
// |
7271 |
if ($f->get_submitted_post_value("liste_code_barres_instruction") !== null) { |
if ($this->f->get_submitted_post_value("liste_code_barres_instruction") !== null) { |
7272 |
$liste_code_barres_instruction = $f->get_submitted_post_value("liste_code_barres_instruction"); |
$liste_code_barres_instruction = $this->f->get_submitted_post_value("liste_code_barres_instruction"); |
7273 |
} else { |
} else { |
7274 |
$liste_code_barres_instruction = ""; |
$liste_code_barres_instruction = ""; |
7275 |
} |
} |
7295 |
* Validation du formulaire |
* Validation du formulaire |
7296 |
*/ |
*/ |
7297 |
// Si le formulaire a été validé |
// Si le formulaire a été validé |
7298 |
if ($f->get_submitted_post_value('validation') !== null) { |
if ($this->f->get_submitted_post_value('validation') !== null) { |
7299 |
// |
// |
7300 |
if (empty($date) || empty($liste_code_barres_instruction)) { |
if (empty($date) || empty($liste_code_barres_instruction)) { |
7301 |
// |
// |
7303 |
$message = _("Tous les champs doivent etre remplis."); |
$message = _("Tous les champs doivent etre remplis."); |
7304 |
} else { |
} else { |
7305 |
// Création d'un tableau d'instruction |
// Création d'un tableau d'instruction |
7306 |
$liste = explode("\r\n", $f->get_submitted_post_value("liste_code_barres_instruction")); |
$liste = explode("\r\n", $this->f->get_submitted_post_value("liste_code_barres_instruction")); |
7307 |
// |
// |
7308 |
foreach ($liste as $code_barres) { |
foreach ($liste as $code_barres) { |
7309 |
// On enlève les éventuels espaces saisis |
// On enlève les éventuels espaces saisis |
7325 |
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 |
7326 |
INNER JOIN ".DB_PREFIXE."groupe |
INNER JOIN ".DB_PREFIXE."groupe |
7327 |
ON dossier_autorisation_type.groupe = groupe.groupe |
ON dossier_autorisation_type.groupe = groupe.groupe |
|
AND groupe.code != 'CTX' |
|
7328 |
WHERE code_barres='".$this->f->db->escapesimple($code_barres)."'"; |
WHERE code_barres='".$this->f->db->escapesimple($code_barres)."'"; |
7329 |
$nbInstr = $f->db->getone($sql); |
|
7330 |
$f->addToLog(__METHOD__.": db->getone(\"".$sql."\")", VERBOSE_MODE); |
// Ajout d'un filtre sur les groupes auxquels l'utilisateur a accès |
7331 |
$f->isDatabaseError($nbInstr); |
$group_clause = array(); |
7332 |
// |
foreach ($_SESSION["groupe"] as $key => $value) { |
7333 |
if ($nbInstr == "1") { |
$group_clause[$key] = "(groupe.code = '".$key."'"; |
7334 |
|
if($value["confidentiel"] !== true) { |
7335 |
|
$group_clause[$key] .= " AND dossier_autorisation_type.confidentiel IS NOT TRUE"; |
7336 |
|
} |
7337 |
|
$group_clause[$key] .= ")"; |
7338 |
|
} |
7339 |
|
$conditions = implode(" OR ", $group_clause); |
7340 |
|
$sql .= " AND (" . $conditions . ")"; |
7341 |
|
|
7342 |
|
$qres = $this->f->get_one_result_from_db_query( |
7343 |
|
$sql, |
7344 |
|
array( |
7345 |
|
"origin" => __METHOD__, |
7346 |
|
) |
7347 |
|
); |
7348 |
|
|
7349 |
|
if ($qres['result'] == "1") { |
7350 |
// Récupération de la date d'envoi de l'instruction bippé |
// Récupération de la date d'envoi de l'instruction bippé |
7351 |
$sql = "SELECT to_char(date_envoi_rar,'DD/MM/YYYY') as date_envoi_rar, instruction FROM ".DB_PREFIXE."instruction WHERE code_barres='".$code_barres."'"; |
$sql = "SELECT to_char(date_envoi_rar,'DD/MM/YYYY') as date_envoi_rar, instruction FROM ".DB_PREFIXE."instruction WHERE code_barres='".$code_barres."'"; |
7352 |
$res = $f->db->query($sql); |
$res = $this->f->db->query($sql); |
7353 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
7354 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
7355 |
$row =& $res->fetchRow(DB_FETCHMODE_ASSOC); |
$row =& $res->fetchRow(DB_FETCHMODE_ASSOC); |
7356 |
// Si pas de date ou correspond à la date du formulaire on |
// Si pas de date ou correspond à la date du formulaire on |
7357 |
// effectue le traitement |
// effectue le traitement |
7358 |
if ($row["date_envoi_rar"] == "" || $row["date_envoi_rar"] == $date) { |
if ($row["date_envoi_rar"] == "" || $row["date_envoi_rar"] == $date) { |
7359 |
|
$instr = $this->f->get_inst__om_dbform(array( |
7360 |
require_once '../obj/instruction.class.php'; |
"obj" => "instruction", |
7361 |
require_once '../obj/dossier.class.php'; |
"idx" => $row['instruction'], |
7362 |
|
)); |
|
$instr = new instruction($row['instruction'], $f->db, DEBUG); |
|
7363 |
$valF = array(); |
$valF = array(); |
7364 |
foreach($instr->champs as $id => $champ) { |
foreach($instr->champs as $id => $champ) { |
7365 |
$valF[$champ] = $instr->val[$id]; |
$valF[$champ] = $instr->val[$id]; |
7368 |
# Si on peut consulter les dossiers et que le dossier n'existe pas déjà dans la liste |
# Si on peut consulter les dossiers et que le dossier n'existe pas déjà dans la liste |
7369 |
if ($isAccredited === true |
if ($isAccredited === true |
7370 |
&& array_key_exists($instr->getVal("dossier"), $dossierTab) === false) { |
&& array_key_exists($instr->getVal("dossier"), $dossierTab) === false) { |
7371 |
$dossier = new dossier($instr->getVal("dossier")); |
$dossier = $this->f->get_inst__om_dbform(array( |
7372 |
|
"obj" => "dossier", |
7373 |
|
"idx" => $instr->getVal("dossier"), |
7374 |
|
)); |
7375 |
if ($dossier->is_user_from_allowed_collectivite()){ |
if ($dossier->is_user_from_allowed_collectivite()){ |
7376 |
$dossierTab[$instr->getVal("dossier")] = $dossier; |
$dossierTab[$instr->getVal("dossier")] = $dossier; |
7377 |
} else { |
} else { |
7425 |
$instr->setParameter('maj', 1); |
$instr->setParameter('maj', 1); |
7426 |
$instr->class_actions[1]["identifier"] = |
$instr->class_actions[1]["identifier"] = |
7427 |
"envoi lettre RAR (depuis le menu suivi des pièces)"; |
"envoi lettre RAR (depuis le menu suivi des pièces)"; |
7428 |
if ($instr->modifier($valF, $f->db, DEBUG) == true) { |
if ($instr->modifier($valF) == true) { |
7429 |
$id4Gen[] = $code_barres; |
$id4Gen[] = $code_barres; |
7430 |
$nbLettres ++; |
$nbLettres ++; |
7431 |
} else { |
} else { |
7480 |
*/ |
*/ |
7481 |
// Affichage du message de validation ou d'erreur |
// Affichage du message de validation ou d'erreur |
7482 |
if (isset($message) && isset($message_class) && $message != "") { |
if (isset($message) && isset($message_class) && $message != "") { |
7483 |
$f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
7484 |
} |
} |
7485 |
// Affichage du message d'erreur |
// Affichage du message d'erreur |
7486 |
if(!empty($error)) { |
if(!empty($error)) { |
7487 |
$f->displayMessage("error", $error); |
$this->f->displayMessage("error", $error); |
7488 |
} |
} |
7489 |
// Affichage du message de validation de la saisie |
// Affichage du message de validation de la saisie |
7490 |
if ($nbLettres > 0) { |
if ($nbLettres > 0) { |
7496 |
echo _("Cliquez sur le lien ci-dessous pour telecharger votre document"); |
echo _("Cliquez sur le lien ci-dessous pour telecharger votre document"); |
7497 |
echo " : \n<br/><br/>"; |
echo " : \n<br/><br/>"; |
7498 |
echo "\n<a class='om-prev-icon pdf-16'"; |
echo "\n<a class='om-prev-icon pdf-16'"; |
7499 |
echo "\n title=\""._("imprimer les RAR")."\""; |
echo "\n title=\""._("imprimer les AR")."\""; |
7500 |
echo "\n href=\"../scr/form.php?obj=instruction&action=180&idx=0&liste=".implode(",",$id4Gen)."\""; |
echo "\n href=\"".OM_ROUTE_FORM."&obj=instruction&action=180&idx=0&liste=".implode(",",$id4Gen)."\""; |
7501 |
echo "\n target='_blank'>"; |
echo "\n target='_blank'>"; |
7502 |
echo _("Telecharger le document pour")." ".$nbLettres." "._("RAR"); |
echo _("Telecharger le document pour")." ".$nbLettres." "._("AR"); |
7503 |
echo "\n</a>"; |
echo "\n</a>"; |
7504 |
echo "\n</span>"; |
echo "\n</span>"; |
7505 |
echo "\n</p>"; |
echo "\n</p>"; |
7521 |
echo "\n<br/>"; |
echo "\n<br/>"; |
7522 |
} |
} |
7523 |
foreach ($dossierTab as $dossier) { |
foreach ($dossierTab as $dossier) { |
7524 |
|
|
7525 |
|
$inst_da = $this->get_inst_common("dossier_autorisation", $dossier->getVal('dossier_autorisation')); |
7526 |
|
$inst_datd = $this->get_inst_common("dossier_autorisation_type_detaille", $inst_da->getVal('dossier_autorisation_type_detaille')); |
7527 |
|
$code_datd = $inst_datd->getVal('code'); |
7528 |
|
|
7529 |
|
$obj = "dossier_instruction"; |
7530 |
|
if ($code_datd === 'REC' OR $code_datd === 'REG') { |
7531 |
|
$obj = "dossier_contentieux_tous_recours"; |
7532 |
|
} |
7533 |
|
if ($code_datd === 'IN') { |
7534 |
|
$obj = "dossier_contentieux_toutes_infractions"; |
7535 |
|
} |
7536 |
|
|
7537 |
echo "\n<div class=\"bloc group\">"; |
echo "\n<div class=\"bloc group\">"; |
7538 |
echo "\n<div class=\"field field-type-text\">"; |
echo "\n<div class=\"field field-type-text\">"; |
7539 |
|
|
7540 |
echo "\n<p>"; |
echo "\n<p>"; |
7541 |
echo "\n<span class='text'>"; |
echo "\n<span class='text'>"; |
7542 |
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') . "\""; |
7543 |
echo "\n href=\"../scr/form.php?obj=dossier_instruction&action=3&idx="; |
echo "\n href=\"".OM_ROUTE_FORM."&obj=dossier_instruction&action=3&idx="; |
7544 |
echo $dossier->getVal("dossier"); |
echo $dossier->getVal("dossier"); |
7545 |
echo "\">"; |
echo "\">"; |
7546 |
echo "\n</a>"; |
echo "\n</a>"; |
7547 |
|
|
7548 |
echo "\n<a title=\""._("Consulter")."\" style=\"vertical-align:middle;\""; |
echo "\n<a title=\""._("Consulter")."\" style=\"vertical-align:middle;\""; |
7549 |
echo " href=\"../scr/form.php?obj=dossier_instruction&action=3&idx="; |
echo " href=\"".OM_ROUTE_FORM."&obj="; |
7550 |
|
echo $obj; |
7551 |
|
echo "&action=3&idx="; |
7552 |
echo $dossier->getVal("dossier"); |
echo $dossier->getVal("dossier"); |
7553 |
echo "\">"; |
echo "\">"; |
7554 |
echo $dossier->getVal("dossier_libelle"); |
echo $dossier->getVal("dossier_libelle"); |
7565 |
echo "\n</div>"; |
echo "\n</div>"; |
7566 |
echo "\n</div>"; |
echo "\n</div>"; |
7567 |
} |
} |
|
// Inclusion de la classe de gestion des formulaires |
|
|
require_once "../obj/om_formulaire.class.php"; |
|
7568 |
// Ouverture du formulaire |
// Ouverture du formulaire |
7569 |
echo "\t<form"; |
echo "\t<form"; |
7570 |
echo " method=\"post\""; |
echo " method=\"post\""; |
7574 |
// Paramétrage des champs du formulaire |
// Paramétrage des champs du formulaire |
7575 |
$champs = array("date", "liste_code_barres_instruction"); |
$champs = array("date", "liste_code_barres_instruction"); |
7576 |
// Création d'un nouvel objet de type formulaire |
// Création d'un nouvel objet de type formulaire |
7577 |
$form = new formulaire(NULL, 0, 0, $champs); |
$form = $this->f->get_inst__om_formulaire(array( |
7578 |
|
"validation" => 0, |
7579 |
|
"maj" => 0, |
7580 |
|
"champs" => $champs, |
7581 |
|
)); |
7582 |
// Paramétrage du champ date du formulaire |
// Paramétrage du champ date du formulaire |
7583 |
$form->setLib("date", _("Date")."* :"); |
$form->setLib("date", _("Date")."* :"); |
7584 |
$form->setType("date", "date"); |
$form->setType("date", "date"); |
7598 |
$form->enpied(); |
$form->enpied(); |
7599 |
// Affichage du bouton |
// Affichage du bouton |
7600 |
echo "\t<div class=\"formControls\">\n"; |
echo "\t<div class=\"formControls\">\n"; |
7601 |
$f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
$this->f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
7602 |
echo "\t</div>\n"; |
echo "\t</div>\n"; |
7603 |
// Fermeture du formulaire |
// Fermeture du formulaire |
7604 |
echo "\t</form>\n"; |
echo "\t</form>\n"; |
7615 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
7616 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
7617 |
|
|
|
// XXX APP |
|
|
|
|
|
$f = $this->f; |
|
|
|
|
7618 |
// Récupération des valeur passées en POST ou GET |
// Récupération des valeur passées en POST ou GET |
7619 |
if($f->get_submitted_post_value("type_mise_a_jour") !== null) { |
if($this->f->get_submitted_post_value("type_mise_a_jour") !== null) { |
7620 |
$type_mise_a_jour = $f->get_submitted_post_value("type_mise_a_jour"); |
$type_mise_a_jour = $this->f->get_submitted_post_value("type_mise_a_jour"); |
7621 |
} elseif($f->get_submitted_get_value('type_mise_a_jour') !== null) { |
} elseif($this->f->get_submitted_get_value('type_mise_a_jour') !== null) { |
7622 |
$type_mise_a_jour = $f->get_submitted_get_value('type_mise_a_jour'); |
$type_mise_a_jour = $this->f->get_submitted_get_value('type_mise_a_jour'); |
7623 |
} else { |
} else { |
7624 |
$type_mise_a_jour = ""; |
$type_mise_a_jour = ""; |
7625 |
} |
} |
7626 |
if($f->get_submitted_post_value('date') !== null) { |
if($this->f->get_submitted_post_value('date') !== null) { |
7627 |
$date = $f->get_submitted_post_value('date'); |
$date = $this->f->get_submitted_post_value('date'); |
7628 |
} elseif($f->get_submitted_get_value('date') !== null) { |
} elseif($this->f->get_submitted_get_value('date') !== null) { |
7629 |
$date = $f->get_submitted_get_value('date'); |
$date = $this->f->get_submitted_get_value('date'); |
7630 |
} else { |
} else { |
7631 |
$date = ""; |
$date = ""; |
7632 |
} |
} |
7633 |
if($f->get_submitted_post_value('code_barres') !== null) { |
if($this->f->get_submitted_post_value('code_barres') !== null) { |
7634 |
$code_barres = $f->get_submitted_post_value('code_barres'); |
$code_barres = $this->f->get_submitted_post_value('code_barres'); |
7635 |
} elseif($f->get_submitted_get_value('code_barres') !== null) { |
} elseif($this->f->get_submitted_get_value('code_barres') !== null) { |
7636 |
$code_barres = $f->get_submitted_get_value('code_barres'); |
$code_barres = $this->f->get_submitted_get_value('code_barres'); |
7637 |
} else { |
} else { |
7638 |
$code_barres = ""; |
$code_barres = ""; |
7639 |
} |
} |
7645 |
$liste_champs=array(); |
$liste_champs=array(); |
7646 |
|
|
7647 |
// Si le formulaire a été validé |
// Si le formulaire a été validé |
7648 |
if ($f->get_submitted_post_value('validation') !== null) { |
if ($this->f->get_submitted_post_value('validation') !== null) { |
7649 |
if(!empty($type_mise_a_jour) and !empty($date) and !empty($code_barres)) { |
if(!empty($type_mise_a_jour) and !empty($date) and !empty($code_barres)) { |
7650 |
|
|
7651 |
// Vérification de l'existence de l'instruction |
// Vérification de l'existence de l'instruction |
7661 |
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 |
7662 |
INNER JOIN ".DB_PREFIXE."groupe |
INNER JOIN ".DB_PREFIXE."groupe |
7663 |
ON dossier_autorisation_type.groupe = groupe.groupe |
ON dossier_autorisation_type.groupe = groupe.groupe |
|
AND groupe.code != 'CTX' |
|
7664 |
WHERE code_barres='".$this->f->db->escapesimple($code_barres)."'"; |
WHERE code_barres='".$this->f->db->escapesimple($code_barres)."'"; |
7665 |
$res = $f->db->query($sql); |
|
7666 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
// Ajout d'un filtre sur les groupes auxquels l'utilisateur a accès |
7667 |
$f->isDatabaseError($res); |
$group_clause = array(); |
7668 |
|
foreach ($_SESSION["groupe"] as $key => $value) { |
7669 |
|
$group_clause[$key] = "(groupe.code = '".$key."'"; |
7670 |
|
if($value["confidentiel"] !== true) { |
7671 |
|
$group_clause[$key] .= " AND dossier_autorisation_type.confidentiel IS NOT TRUE"; |
7672 |
|
} |
7673 |
|
$group_clause[$key] .= ")"; |
7674 |
|
} |
7675 |
|
$conditions = implode(" OR ", $group_clause); |
7676 |
|
$sql .= " AND (" . $conditions . ")"; |
7677 |
|
|
7678 |
|
|
7679 |
|
$res = $this->f->db->query($sql); |
7680 |
|
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
7681 |
|
$this->f->isDatabaseError($res); |
7682 |
|
|
7683 |
if($res->numrows() == 1) { |
if($res->numrows() == 1) { |
7684 |
$liste_champs = explode(";", $type_mise_a_jour); |
$liste_champs = explode(";", $type_mise_a_jour); |
7685 |
|
$row =& $res->fetchRow(DB_FETCHMODE_ASSOC); |
7686 |
|
$instr = $this->f->get_inst__om_dbform(array( |
7687 |
|
"obj" => "instruction", |
7688 |
|
"idx" => $row['instruction'], |
7689 |
|
)); |
7690 |
// Mise à jour des dates après l'écran de verification |
// Mise à jour des dates après l'écran de verification |
7691 |
if($f->get_submitted_post_value('is_valid') !== null and $f->get_submitted_post_value('is_valid') == "true") { |
if($this->f->get_submitted_post_value('is_valid') !== null and $this->f->get_submitted_post_value('is_valid') == "true") { |
|
require_once '../obj/instruction.class.php'; |
|
|
$row =& $res->fetchRow(DB_FETCHMODE_ASSOC); |
|
|
$instr = new instruction($row['instruction'], $f->db, DEBUG); |
|
7692 |
$valF = array(); |
$valF = array(); |
7693 |
foreach($instr->champs as $id => $champ) { |
foreach($instr->champs as $id => $champ) { |
7694 |
$valF[$champ] = $instr->val[$id]; |
$valF[$champ] = $instr->val[$id]; |
7731 |
$code_barres = ""; |
$code_barres = ""; |
7732 |
|
|
7733 |
//Désactivation de l'autocommit |
//Désactivation de l'autocommit |
7734 |
$f->db->autoCommit(false); |
$this->f->db->autoCommit(false); |
7735 |
|
|
7736 |
//On modifie les valeurs de l'instruction |
//On modifie les valeurs de l'instruction |
7737 |
$instr->setParameter('maj', 170); |
$instr->setParameter('maj', 170); |
7738 |
$instr->class_actions[170]["identifier"] = |
$instr->class_actions[170]["identifier"] = |
7739 |
"mise à jour des dates (depuis le menu suivi des pièces)"; |
"mise à jour des dates (depuis le menu suivi des pièces)"; |
7740 |
$retour = $instr->modifier($valF, $f->db, DEBUG); |
$retour = $instr->modifier($valF); |
7741 |
|
|
7742 |
//Si une erreur s'est produite, on défait les modifications |
//Si une erreur s'est produite, on défait les modifications |
7743 |
//qui ont été faites |
//qui ont été faites |
7746 |
} |
} |
7747 |
//Sinon, on valide en base de données les modifications |
//Sinon, on valide en base de données les modifications |
7748 |
else { |
else { |
7749 |
$f->db->commit(); |
$this->f->db->commit(); |
7750 |
} |
} |
7751 |
|
|
7752 |
// Variable correct retourné depuis la classe instruction |
// Variable correct retourné depuis la classe instruction |
7787 |
INNER JOIN ".DB_PREFIXE."evenement ON |
INNER JOIN ".DB_PREFIXE."evenement ON |
7788 |
instruction.evenement=evenement.evenement |
instruction.evenement=evenement.evenement |
7789 |
WHERE code_barres='".$code_barres."'"; |
WHERE code_barres='".$code_barres."'"; |
7790 |
$resInfo = $f->db->query($sqlInfo); |
$resInfo = $this->f->db->query($sqlInfo); |
7791 |
$f->isDatabaseError($resInfo); |
$this->f->isDatabaseError($resInfo); |
7792 |
$infos = $resInfo->fetchRow(DB_FETCHMODE_ASSOC); |
$infos = $resInfo->fetchRow(DB_FETCHMODE_ASSOC); |
7793 |
|
|
7794 |
// Vérification de la non modification des dates de suivi |
// Vérification de la non modification des dates de suivi |
7795 |
foreach(explode(";", $type_mise_a_jour) as $champ) { |
foreach(explode(";", $type_mise_a_jour) as $champ) { |
7796 |
|
if ($champ === 'date_envoi_controle_legalite') { |
7797 |
|
if ($instr->is_sent_to_cl() === true) { |
7798 |
|
$error = __("Les dates de suivis ne peuvent etre modifiees"); |
7799 |
|
$date_error = true; |
7800 |
|
break; |
7801 |
|
} |
7802 |
|
} |
7803 |
if($infos[$champ] != "" AND $infos[$champ] != $date) { |
if($infos[$champ] != "" AND $infos[$champ] != $date) { |
7804 |
$error = _("Les dates de suivis ne peuvent etre modifiees"); |
$error = _("Les dates de suivis ne peuvent etre modifiees"); |
7805 |
$date_error = true; |
$date_error = true; |
7806 |
|
break; |
7807 |
} |
} |
7808 |
} |
} |
7809 |
} |
} |
7821 |
*/ |
*/ |
7822 |
// Affichage du message de validation ou d'erreur |
// Affichage du message de validation ou d'erreur |
7823 |
if (isset($message) && isset($message_class) && $message != "") { |
if (isset($message) && isset($message_class) && $message != "") { |
7824 |
$f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
7825 |
} |
} |
7826 |
// Affichage du message d'erreur |
// Affichage du message d'erreur |
7827 |
if(!empty($error)) { |
if(!empty($error)) { |
7828 |
$f->displayMessage("error", $error); |
$this->f->displayMessage("error", $error); |
7829 |
} |
} |
7830 |
|
|
7831 |
// Affichage du message de validation de la saisie |
// Affichage du message de validation de la saisie |
7832 |
if($correct === true) { |
if($correct === true) { |
7833 |
$f->displayMessage("ok", _("Saisie enregistree")); |
$this->f->displayMessage("ok", _("Saisie enregistree")); |
7834 |
} |
} |
|
// Inclusion de la classe de gestion des formulaires |
|
|
require_once "../obj/om_formulaire.class.php"; |
|
7835 |
// Ouverture du formulaire |
// Ouverture du formulaire |
7836 |
echo "\t<form"; |
echo "\t<form"; |
7837 |
echo " method=\"post\""; |
echo " method=\"post\""; |
7849 |
$champs = array("type_mise_a_jour", "date", "code_barres"); |
$champs = array("type_mise_a_jour", "date", "code_barres"); |
7850 |
} |
} |
7851 |
// Création d'un nouvel objet de type formulaire |
// Création d'un nouvel objet de type formulaire |
7852 |
$form = new formulaire(NULL, 0, 0, $champs); |
$form = $this->f->get_inst__om_formulaire(array( |
7853 |
|
"validation" => 0, |
7854 |
|
"maj" => 0, |
7855 |
|
"champs" => $champs, |
7856 |
|
)); |
7857 |
// Paramétrage des champs du formulaire |
// Paramétrage des champs du formulaire |
7858 |
// Parametrage du champ type_mise_a_jour |
// Parametrage du champ type_mise_a_jour |
7859 |
$form->setLib("type_mise_a_jour", _("Date a mettre a jour")."* :"); |
$form->setLib("type_mise_a_jour", _("Date a mettre a jour")."* :"); |
7883 |
$contenu[1][4] = _("date de retour de controle de legalite"); |
$contenu[1][4] = _("date de retour de controle de legalite"); |
7884 |
|
|
7885 |
$contenu[0][5] = "date_retour_rar"; |
$contenu[0][5] = "date_retour_rar"; |
7886 |
$contenu[1][5] = _("date de retour de l'AR"); |
$contenu[1][5] = __("date de notification du correspondant"); |
7887 |
|
|
7888 |
$form->setSelect("type_mise_a_jour", $contenu); |
$form->setSelect("type_mise_a_jour", $contenu); |
7889 |
|
|
7943 |
$form->setType("autorite_competente", "static"); |
$form->setType("autorite_competente", "static"); |
7944 |
$form->setVal("autorite_competente", $infos['autorite_competente']); |
$form->setVal("autorite_competente", $infos['autorite_competente']); |
7945 |
|
|
7946 |
// Parametrage des libellés d'envoi avec RAR |
// Parametrage des libellés d'envoi avec AR |
7947 |
$form->setLib("date_envoi_rar", _("date_envoi_rar")." :"); |
$form->setLib("date_envoi_rar", __("date_envoi_ar")." :"); |
7948 |
$form->setLib("date_retour_rar", _("date_retour_rar")." :"); |
$form->setLib("date_retour_rar", __("date_notification")." :"); |
7949 |
|
|
7950 |
$form->setLib("date_envoi_signature", _("date_envoi_signature")." :"); |
$form->setLib("date_envoi_signature", _("date_envoi_signature")." :"); |
7951 |
$form->setLib("date_retour_signature", _("date_retour_signature")." :"); |
$form->setLib("date_retour_signature", _("date_retour_signature")." :"); |
7979 |
echo "\t<div class=\"formControls\">\n"; |
echo "\t<div class=\"formControls\">\n"; |
7980 |
// |
// |
7981 |
if(!$date_error) { |
if(!$date_error) { |
7982 |
$f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
$this->f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
7983 |
} |
} |
7984 |
// Si pas sur l'écran de validation |
// Si pas sur l'écran de validation |
7985 |
if(isset($infos)) { |
if(isset($infos)) { |
7986 |
echo "<a class=\"retour\" href=\"../scr/form.php?obj=instruction_suivi_mise_a_jour_des_dates&action=170&idx=0"; |
echo "<a class=\"retour\" href=\"".OM_ROUTE_FORM."&obj=instruction_suivi_mise_a_jour_des_dates&action=170&idx=0"; |
7987 |
echo "&type_mise_a_jour=".$type_mise_a_jour."&date=".$date."&code_barres=".$code_barres; |
echo "&type_mise_a_jour=".$type_mise_a_jour."&date=".$date."&code_barres=".$code_barres; |
7988 |
echo "\">Retour</a>"; |
echo "\">Retour</a>"; |
7989 |
} |
} |
8000 |
function view_pdf_lettre_rar() { |
function view_pdf_lettre_rar() { |
8001 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
8002 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
8003 |
|
// |
8004 |
|
$this->f->disableLog(); |
8005 |
|
|
8006 |
// XXX APP |
if($this->f->get_submitted_get_value('liste') != null) { |
8007 |
|
$listeCodeBarres = explode(',',$this->f->get_submitted_get_value('liste')); |
|
$f = $this->f; |
|
|
|
|
|
$f->disableLog(); |
|
|
|
|
|
if($f->get_submitted_get_value('liste') != null) { |
|
|
$listeCodeBarres = explode(',',$f->get_submitted_get_value('liste')); |
|
8008 |
|
|
8009 |
// Classe permettant la mise en page de l'édition pdf |
// Classe permettant la mise en page de l'édition pdf |
8010 |
require_once "../obj/pdf_lettre_rar.class.php"; |
require_once "../obj/pdf_lettre_rar.class.php"; |
8011 |
$pdf_lettre_rar = new pdf_lettre_rar('P', 'mm', 'A4'); |
$pdf_lettre_rar = new pdf_lettre_rar('P', 'mm', 'A4'); |
8012 |
// Initialisation de la mise en page |
// Initialisation de la mise en page |
8013 |
$pdf_lettre_rar->init($f); |
$pdf_lettre_rar->init($this->f); |
8014 |
|
|
8015 |
foreach ($listeCodeBarres as $code_barres) { |
foreach ($listeCodeBarres as $code_barres) { |
8016 |
|
|
8017 |
|
// On récupère le dossier |
8018 |
|
$qres = $this->f->get_one_result_from_db_query( |
8019 |
|
sprintf( |
8020 |
|
'SELECT |
8021 |
|
dossier |
8022 |
|
FROM |
8023 |
|
%1$sinstruction |
8024 |
|
WHERE |
8025 |
|
code_barres = \'%2$s\'', |
8026 |
|
DB_PREFIXE, |
8027 |
|
$this->f->db->escapeSimple($code_barres) |
8028 |
|
), |
8029 |
|
array( |
8030 |
|
"origin" => __METHOD__, |
8031 |
|
) |
8032 |
|
); |
8033 |
|
|
8034 |
|
$inst_dossier = $this->f->get_inst__om_dbform(array( |
8035 |
|
"obj" => "dossier", |
8036 |
|
"idx" => $qres['result'], |
8037 |
|
)); |
8038 |
|
|
8039 |
|
// En fonction du type de dossier, on récupère un demandeur différent dans les requêtes |
8040 |
|
$groupe = $inst_dossier->get_type_affichage_formulaire(); |
8041 |
|
switch ($groupe) { |
8042 |
|
case 'CTX IN': |
8043 |
|
$sql_demandeur = "(lien_dossier_demandeur.petitionnaire_principal IS TRUE AND demandeur.type_demandeur='plaignant')"; |
8044 |
|
break; |
8045 |
|
case 'CTX RE': |
8046 |
|
$sql_demandeur = "(lien_dossier_demandeur.petitionnaire_principal IS TRUE AND demandeur.type_demandeur='requerant')"; |
8047 |
|
break; |
8048 |
|
case 'ADS': |
8049 |
|
case 'DPC': |
8050 |
|
case 'CONSULTATION ENTRANTE': |
8051 |
|
default: |
8052 |
|
$sql_demandeur = "((lien_dossier_demandeur.petitionnaire_principal IS TRUE AND demandeur.type_demandeur='petitionnaire') OR demandeur.type_demandeur='delegataire')"; |
8053 |
|
break; |
8054 |
|
} |
8055 |
|
|
8056 |
// 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é |
8057 |
$sql = "SELECT |
$sql = "SELECT |
8058 |
dossier.dossier_libelle, |
dossier.dossier_libelle, |
8078 |
inner join ".DB_PREFIXE."demandeur on |
inner join ".DB_PREFIXE."demandeur on |
8079 |
demandeur.demandeur=lien_dossier_demandeur.demandeur |
demandeur.demandeur=lien_dossier_demandeur.demandeur |
8080 |
WHERE code_barres='".$code_barres."' |
WHERE code_barres='".$code_barres."' |
8081 |
AND ((lien_dossier_demandeur.petitionnaire_principal IS TRUE AND demandeur.type_demandeur='petitionnaire') |
AND " . $sql_demandeur . " |
|
OR demandeur.type_demandeur='delegataire') |
|
8082 |
GROUP BY dossier.dossier_libelle, evenement.type, phase.code, division.libelle"; |
GROUP BY dossier.dossier_libelle, evenement.type, phase.code, division.libelle"; |
8083 |
|
|
8084 |
$res = $f->db->query($sql); |
$res = $this->f->db->query($sql); |
8085 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
8086 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
8087 |
$testDemandeur = $res->fetchrow(DB_FETCHMODE_ASSOC); |
$testDemandeur = $res->fetchrow(DB_FETCHMODE_ASSOC); |
8088 |
|
|
8089 |
|
|
8132 |
if($testDemandeur['type'] != 'arrete' AND $testDemandeur['nbdemandeur'] > 1) { |
if($testDemandeur['type'] != 'arrete' AND $testDemandeur['nbdemandeur'] > 1) { |
8133 |
$sqlAdresse .= " AND demandeur.type_demandeur='delegataire'"; |
$sqlAdresse .= " AND demandeur.type_demandeur='delegataire'"; |
8134 |
} else { |
} else { |
8135 |
$sqlAdresse .= " AND lien_dossier_demandeur.petitionnaire_principal IS TRUE AND demandeur.type_demandeur='petitionnaire'"; |
$sqlAdresse .= " AND demandeur.type_demandeur='petitionnaire' AND lien_dossier_demandeur.petitionnaire_principal IS TRUE"; |
8136 |
} |
} |
8137 |
|
|
8138 |
$resAdresse = $f->db->query($sqlAdresse); |
$resAdresse = $this->f->db->query($sqlAdresse); |
8139 |
$adresse_dest = $resAdresse->fetchrow(DB_FETCHMODE_ASSOC); |
$adresse_dest = $resAdresse->fetchrow(DB_FETCHMODE_ASSOC); |
8140 |
$f->addToLog(__METHOD__.": db->query(\"".$sqlAdresse."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->query(\"".$sqlAdresse."\")", VERBOSE_MODE); |
8141 |
$f->isDatabaseError($resAdresse); |
$this->f->isDatabaseError($resAdresse); |
8142 |
|
|
8143 |
// Création adresse destinataire sans ligne vide |
// Création adresse destinataire sans ligne vide |
8144 |
$adresse_destinataire = array(); |
$adresse_destinataire = array(); |
8168 |
$specifique_content[] = $testDemandeur['dossier_libelle']; |
$specifique_content[] = $testDemandeur['dossier_libelle']; |
8169 |
$specifique_content[] = "|||||".$adresse_dest['code_barres']."|||||"; |
$specifique_content[] = "|||||".$adresse_dest['code_barres']."|||||"; |
8170 |
unset($adresse_dest['code_barres']); |
unset($adresse_dest['code_barres']); |
|
|
|
8171 |
// Ajout d'une page aux pdf |
// Ajout d'une page aux pdf |
8172 |
$pdf_lettre_rar->addLetter($adresse_destinataire, $specifique_content, $testDemandeur['code_phase']); |
$pdf_lettre_rar->addLetter($adresse_destinataire, $specifique_content, $testDemandeur['code_phase']); |
8173 |
|
|
8174 |
} |
} |
8175 |
$pdf_output = $pdf_lettre_rar->output("lettre_rar".date("dmYHis").".pdf","S"); |
$pdf_output = $pdf_lettre_rar->output("lettre_rar".date("dmYHis").".pdf","S"); |
8176 |
require_once PATH_OPENMAIRIE."om_edition.class.php"; |
$om_edition = $this->f->get_inst__om_edition(); |
|
$om_edition = new edition(); |
|
8177 |
$om_edition->expose_pdf_output($pdf_output, "lettre_rar".date("dmYHis").".pdf"); |
$om_edition->expose_pdf_output($pdf_output, "lettre_rar".date("dmYHis").".pdf"); |
8178 |
} |
} |
8179 |
} |
} |
8236 |
$message .= "<a class='om-prev-icon pdf-16'"; |
$message .= "<a class='om-prev-icon pdf-16'"; |
8237 |
$message .= " id=\"generer_bordereau_envoi_maire\""; |
$message .= " id=\"generer_bordereau_envoi_maire\""; |
8238 |
$message .= " title=\""._("Bordereau")."\""; |
$message .= " title=\""._("Bordereau")."\""; |
8239 |
$message .= " href='../scr/form.php?obj=instruction"; |
$message .= " href='".OM_ROUTE_FORM."&obj=instruction"; |
8240 |
$message .= "&action=200"; |
$message .= "&action=200"; |
8241 |
$message .= "&idx=".$id_instruction."'"; |
$message .= "&idx=".$id_instruction."'"; |
8242 |
$message .= " target='_blank'>"; |
$message .= " target='_blank'>"; |
8277 |
$this->f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
8278 |
} |
} |
8279 |
|
|
|
// Inclusion de la classe de gestion des formulaires |
|
|
require_once "../obj/om_formulaire.class.php"; |
|
8280 |
// Ouverture du formulaire |
// Ouverture du formulaire |
8281 |
$datasubmit = $this->getDataSubmit(); |
$datasubmit = $this->getDataSubmit(); |
8282 |
echo "\n<!-- ########## START DBFORM ########## -->\n"; |
echo "\n<!-- ########## START DBFORM ########## -->\n"; |
8293 |
$champs = array("code_barres","date"); |
$champs = array("code_barres","date"); |
8294 |
|
|
8295 |
// Création d'un nouvel objet de type formulaire |
// Création d'un nouvel objet de type formulaire |
8296 |
$form = new formulaire(NULL, 0, 0, $champs); |
$form = $this->f->get_inst__om_formulaire(array( |
8297 |
|
"validation" => 0, |
8298 |
|
"maj" => 0, |
8299 |
|
"champs" => $champs, |
8300 |
|
)); |
8301 |
|
|
8302 |
$template_required_label = '%s *'; |
$template_required_label = '%s *'; |
8303 |
// Parametrage du champ code_barres |
// Parametrage du champ code_barres |
8356 |
} |
} |
8357 |
|
|
8358 |
/** |
/** |
8359 |
|
* VIEW - view_rapport_instruction. |
8360 |
|
* |
8361 |
|
* Ouvre le sous-formulaire en ajaxIt dans un overlay. |
8362 |
|
* Cette action est bindée pour utiliser la fonction popUpIt. |
8363 |
|
* |
8364 |
|
* @return void |
8365 |
|
*/ |
8366 |
|
function view_overlay_notification_manuelle() { |
8367 |
|
|
8368 |
|
// Vérification de l'accessibilité sur l'élément |
8369 |
|
$this->checkAccessibility(); |
8370 |
|
|
8371 |
|
printf( |
8372 |
|
'<script type="text/javascript" > |
8373 |
|
overlayIt(\'%1$s\',\'%2$s&objsf=%1$s&idxformulaire=%4$s&retourformulaire=dossier_instruction&obj=%1$s&action=411&idx=%3$s\', 1); |
8374 |
|
</script>', |
8375 |
|
'instruction_notification_manuelle', |
8376 |
|
OM_ROUTE_SOUSFORM, |
8377 |
|
$this->getVal($this->clePrimaire), |
8378 |
|
$this->getVal('dossier') |
8379 |
|
); |
8380 |
|
} |
8381 |
|
|
8382 |
|
/** |
8383 |
|
* VIEW - view_overlay_notification_service_consulte. |
8384 |
|
* |
8385 |
|
* Ouvre le sous-formulaire de notification des services consulte |
8386 |
|
* en ajaxIt dans un overlay. |
8387 |
|
* Cette action est bindée pour utiliser la fonction popUpIt. |
8388 |
|
* |
8389 |
|
* @return void |
8390 |
|
*/ |
8391 |
|
function view_overlay_notification_service_consulte() { |
8392 |
|
|
8393 |
|
// Vérification de l'accessibilité sur l'élément |
8394 |
|
$this->checkAccessibility(); |
8395 |
|
|
8396 |
|
printf( |
8397 |
|
'<script type="text/javascript" > |
8398 |
|
overlayIt(\'%1$s\',\'%2$s&objsf=%1$s&idxformulaire=%4$s&retourformulaire=dossier_instruction&obj=%1$s&action=420&idx=%3$s\', 1); |
8399 |
|
</script>', |
8400 |
|
'instruction_notification_manuelle', |
8401 |
|
OM_ROUTE_SOUSFORM, |
8402 |
|
$this->getVal($this->clePrimaire), |
8403 |
|
$this->getVal('dossier') |
8404 |
|
); |
8405 |
|
} |
8406 |
|
|
8407 |
|
/** |
8408 |
|
* VIEW - overlay_notification_tiers_consulte. |
8409 |
|
* |
8410 |
|
* Ouvre le sous-formulaire de notification des tiers consulte |
8411 |
|
* en ajaxIt dans un overlay. |
8412 |
|
* Cette action est bindée pour utiliser la fonction popUpIt. |
8413 |
|
* |
8414 |
|
* @return void |
8415 |
|
*/ |
8416 |
|
function view_overlay_notification_tiers_consulte() { |
8417 |
|
|
8418 |
|
// Vérification de l'accessibilité sur l'élément |
8419 |
|
$this->checkAccessibility(); |
8420 |
|
|
8421 |
|
printf( |
8422 |
|
'<script type="text/javascript" > |
8423 |
|
overlayIt(\'%1$s\',\'%2$s&objsf=%1$s&idxformulaire=%4$s&retourformulaire=dossier_instruction&obj=%1$s&action=430&idx=%3$s\', 1); |
8424 |
|
</script>', |
8425 |
|
'instruction_notification_manuelle', |
8426 |
|
OM_ROUTE_SOUSFORM, |
8427 |
|
$this->getVal($this->clePrimaire), |
8428 |
|
$this->getVal('dossier') |
8429 |
|
); |
8430 |
|
} |
8431 |
|
|
8432 |
|
/** |
8433 |
|
* VIEW - view_modale_selection_document_signe |
8434 |
|
* |
8435 |
|
* Ouvre le sous-formulaire de notification des services consulte |
8436 |
|
* en ajaxIt dans un overlay. |
8437 |
|
* Cette action est bindée pour utiliser la fonction popUpIt. |
8438 |
|
* |
8439 |
|
* @return void |
8440 |
|
*/ |
8441 |
|
function view_modale_selection_document_signe() { |
8442 |
|
|
8443 |
|
// Vérification de l'accessibilité sur l'élément |
8444 |
|
$this->checkAccessibility(); |
8445 |
|
|
8446 |
|
printf( |
8447 |
|
'<script type="text/javascript" > |
8448 |
|
overlayIt(\'%1$s\',\'%2$s&objsf=%1$s&idxformulaire=%4$s&retourformulaire=dossier_instruction&obj=%1$s&action=115&idx=%3$s\', 1); |
8449 |
|
</script>', |
8450 |
|
'instruction_modale', |
8451 |
|
OM_ROUTE_SOUSFORM, |
8452 |
|
$this->getVal($this->clePrimaire), |
8453 |
|
$this->getVal('dossier') |
8454 |
|
); |
8455 |
|
} |
8456 |
|
|
8457 |
|
/** |
8458 |
* 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 |
8459 |
* pour exclure les dossiers du groupe contentieux. |
* pour exclure les dossiers du groupe contentieux. |
8460 |
* |
* |
8464 |
function get_instruction_by_barcode($barcode) { |
function get_instruction_by_barcode($barcode) { |
8465 |
// Begin |
// Begin |
8466 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
8467 |
|
|
8468 |
// Vérification de l'existence de l'événement d'instruction |
// Vérification de l'existence de l'événement d'instruction |
8469 |
// 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 |
8470 |
$sql = "SELECT instruction |
$qres = $this->f->get_one_result_from_db_query( |
8471 |
FROM ".DB_PREFIXE."instruction |
sprintf( |
8472 |
INNER JOIN ".DB_PREFIXE."dossier |
'SELECT |
8473 |
|
instruction |
8474 |
|
FROM |
8475 |
|
%1$sinstruction |
8476 |
|
INNER JOIN %1$sdossier |
8477 |
ON dossier.dossier=instruction.dossier |
ON dossier.dossier=instruction.dossier |
8478 |
INNER JOIN ".DB_PREFIXE."dossier_instruction_type |
INNER JOIN %1$sdossier_instruction_type |
8479 |
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
8480 |
INNER JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille |
INNER JOIN %1$sdossier_autorisation_type_detaille |
8481 |
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 |
8482 |
INNER JOIN ".DB_PREFIXE."dossier_autorisation_type |
INNER JOIN %1$sdossier_autorisation_type |
8483 |
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 |
8484 |
INNER JOIN ".DB_PREFIXE."groupe |
INNER JOIN %1$sgroupe |
8485 |
ON dossier_autorisation_type.groupe = groupe.groupe |
ON dossier_autorisation_type.groupe = groupe.groupe |
8486 |
AND groupe.code != 'CTX' |
AND groupe.code != \'CTX\' |
8487 |
WHERE code_barres = '".$this->f->db->escapesimple($barcode)."'"; |
WHERE |
8488 |
$res = $this->f->db->getOne($sql); |
code_barres = \'%2$s\'', |
8489 |
$this->f->addToLog(__METHOD__." : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
DB_PREFIXE, |
8490 |
$this->f->isDatabaseError($res); |
$this->f->db->escapeSimple($barcode) |
8491 |
|
), |
8492 |
|
array( |
8493 |
|
"origin" => __METHOD__, |
8494 |
|
) |
8495 |
|
); |
8496 |
|
|
8497 |
// Retourne résultat |
// Retourne résultat |
8498 |
return $this->end_treatment(__METHOD__, $res); |
return $this->end_treatment(__METHOD__, $qres['result']); |
8499 |
} |
} |
8500 |
|
|
8501 |
/** |
/** |
8513 |
// Begin |
// Begin |
8514 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
8515 |
// Requête |
// Requête |
8516 |
$res = $this->db->autoExecute( |
$res = $this->f->db->autoexecute( |
8517 |
DB_PREFIXE.$this->table, |
DB_PREFIXE.$this->table, |
8518 |
$valF, |
$valF, |
8519 |
DB_AUTOQUERY_UPDATE, |
DB_AUTOQUERY_UPDATE, |
8520 |
$this->getCle($id) |
$this->getCle($id) |
8521 |
); |
); |
8522 |
// S'il y a eu une erreur |
$this->addToLog( |
8523 |
if (database::isError($res, true)) { |
__METHOD__."(): db->autoexecute(\"".DB_PREFIXE.'.'.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($id)."\");", |
8524 |
|
VERBOSE_MODE |
8525 |
|
); |
8526 |
|
if ($this->f->isDatabaseError($res, true) !== false) { |
8527 |
$this->end_treatment(__METHOD__, false); |
$this->end_treatment(__METHOD__, false); |
8528 |
} |
} |
8529 |
// |
// |
8535 |
* validation du formulaire d'ajout. |
* validation du formulaire d'ajout. |
8536 |
* @param array $val tableau des valeurs retournées par le formulaire |
* @param array $val tableau des valeurs retournées par le formulaire |
8537 |
*/ |
*/ |
8538 |
function setValFAjout($val) { |
function setValFAjout($val = array()) { |
8539 |
// Mise à jour du flag created_by_commune lors d'un changement de décision |
// Mise à jour du flag created_by_commune lors d'un changement de décision |
8540 |
// par un utilisateur de commune sur un dossier instruit par la comcom |
// par un utilisateur de commune sur un dossier instruit par la comcom |
8541 |
if ($this->isInstrCanChangeDecision($this->valF["dossier"])) { |
if ($this->isInstrCanChangeDecision($this->valF["dossier"])) { |
8542 |
$this->valF['created_by_commune'] = true; |
$this->valF['created_by_commune'] = true; |
8543 |
} |
} |
8544 |
|
|
8545 |
|
// |
8546 |
|
if ($this->evenement_has_an_edition($this->valF['evenement']) === false) { |
8547 |
|
if (isset($this->valF['flag_edition_integrale']) === true) { |
8548 |
|
unset($this->valF['flag_edition_integrale']); |
8549 |
|
} |
8550 |
|
if (isset($this->valF['signataire_arrete']) === true) { |
8551 |
|
unset($this->valF['signataire_arrete']); |
8552 |
|
} |
8553 |
|
} |
8554 |
} |
} |
8555 |
|
|
8556 |
|
|
8696 |
// 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 |
8697 |
// dites de TREATMENT. |
// dites de TREATMENT. |
8698 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
8699 |
// Définition des paramètres |
$message = __('Erreur de paramétrage :'); |
8700 |
$p_objet = 'param_courriel_de_notification_commune_objet_depuis_instruction'; |
$erreurParametrage = false; |
8701 |
$p_modele = 'param_courriel_de_notification_commune_modele_depuis_instruction'; |
// Récupération du paramétrage de la collectivité du dossier |
|
$p_courriel = 'param_courriel_de_notification_commune'; |
|
|
// Définition des variables de substitution |
|
8702 |
$id_di = $this->getVal('dossier'); |
$id_di = $this->getVal('dossier'); |
|
$id_inst = $this->getVal($this->clePrimaire); |
|
|
// Instanciation du DI |
|
8703 |
$di = $this->get_inst_dossier($id_di); |
$di = $this->get_inst_dossier($id_di); |
|
// Récupération du paramétrage de la collectivité du dossier |
|
8704 |
$collectivite_di = $di->getVal('om_collectivite'); |
$collectivite_di = $di->getVal('om_collectivite'); |
8705 |
$params_mono = $this->f->getCollectivite($collectivite_di); |
// Récupération de l'url permettant d'accèder à l'instruction et au dossier |
8706 |
// Récupération du paramétrage de la collectivité multi |
$urlAcces = $this->f->get_parametre_notification_url_acces($collectivite_di); |
8707 |
$collectivite_multi = $this->f->get_idx_collectivite_multi(); |
if (empty($urlAcces) && empty(PATH_BASE_URL)) { |
8708 |
$params_multi = $this->f->getCollectivite($collectivite_multi); |
$erreurParametrage = true; |
8709 |
// Vérification de l'objet (obligatoirement multi) |
$message .= '<br>'.__("* l'url de notification n'est pas correctement paramétré"); |
8710 |
$objet = null; |
} |
8711 |
if (isset($params_multi[$p_objet]) === true |
|
8712 |
&& $params_multi[$p_objet] !== '') { |
// Récupération de la liste des mails |
8713 |
$objet = $params_multi[$p_objet]; |
$adresses = $this->f->get_param_courriel_de_notification_commune($collectivite_di); |
8714 |
} |
if (empty($adresses)) { |
8715 |
// Vérification du modèle mono en priorité |
$erreurParametrage = true; |
8716 |
$modele = null; |
$message .= '<br>'.__("* aucun courriel valide de destinataire de la commune"); |
8717 |
if (isset($params_mono[$p_modele]) === true |
} |
8718 |
&& $params_mono[$p_modele] !== '') { |
|
8719 |
$modele = $params_mono[$p_modele]; |
// Vérification du paramétrage des mails |
8720 |
|
$paramMail = $this->f->get_notification_commune_parametre_courriel_type($collectivite_di); |
8721 |
} |
if (empty($paramMail) || empty($paramMail['parametre_courriel_type_message'])) { |
8722 |
// Sinon vérification du modèle multi |
$erreurParametrage = true; |
8723 |
if ($modele === null |
$message .= '<br>'.__("* le modèle du courriel envoyé aux communes est vide"); |
8724 |
&& isset($params_multi[$p_modele]) === true |
} |
8725 |
&& $params_multi[$p_modele] !== '') { |
if (empty($paramMail) || empty($paramMail['parametre_courriel_type_titre'])) { |
8726 |
$modele = $params_multi[$p_modele]; |
$erreurParametrage = true; |
8727 |
} |
$message .= '<br>'.__("* l'objet du courriel envoyé aux communes est vide"); |
8728 |
// Vérification des adresses de courriel mono |
} |
8729 |
$courriels_valides = array(); |
|
8730 |
$courriels_invalides = array(); |
// Si il y a des erreurs de paramétrage on ne déclenche pas la notification et |
8731 |
if (isset($params_mono[$p_courriel]) === true |
// un message a destination de l'utilisateur est affiché |
8732 |
&& $params_mono[$p_courriel] !== '') { |
if ($erreurParametrage) { |
8733 |
// Un mail par ligne |
$message .= '<br>'.__("Veuillez contacter votre administrateur."); |
8734 |
$adresses = explode("\n", $params_mono[$p_courriel]); |
$this->addToMessage($message); |
8735 |
// Vérification de la validité de chaque mail avec preg_match |
return $this->end_treatment(__METHOD__, false); |
|
foreach ($adresses as $adresse) { |
|
|
$adresse = trim($adresse); |
|
|
if ($this->f->checkValidEmailAddress($adresse) === 1) { |
|
|
$courriels_valides[] = $adresse; |
|
|
} else { |
|
|
$courriels_invalides[] = $adresse; |
|
|
} |
|
|
} |
|
8736 |
} |
} |
8737 |
// Vérification du paramétrage global : |
|
8738 |
// on stoppe le traitement si au moins un paramètre est incorrect |
// Création d'un notification et de sa tâche associé pour chaque mail |
8739 |
if ($objet === null |
foreach ($adresses as $adresse) { |
8740 |
|| $modele === null |
// Ajout de la notif et récupération de son id |
8741 |
|| count($courriels_valides) === 0 |
$destinataire = array( |
8742 |
|| count($courriels_invalides) > 0) { |
'destinataire' => $adresse, |
8743 |
// On construit le message d'erreur adéquat |
'courriel' => $adresse |
8744 |
$this->addToMessage(_('Erreur de paramétrage :')); |
); |
8745 |
if ($objet === null) { |
$idNotif = $this->ajouter_notification( |
8746 |
$this->addToMessage(_("* l'objet du courriel envoyé aux communes est vide")); |
$this->getVal($this->clePrimaire), |
8747 |
} |
$this->f->get_connected_user_login_name(), |
8748 |
if ($modele === null) { |
$destinataire, |
8749 |
$this->addToMessage(_("* le modèle du courriel envoyé aux communes est vide")); |
$collectivite_di |
8750 |
} |
); |
8751 |
if (count($courriels_valides) === 0) { |
if ($idNotif === false) { |
8752 |
$this->addToMessage(_("* aucun courriel valide de destinataire de la commune")); |
$this->addToMessage(__("Veuillez contacter votre administrateur.")); |
8753 |
|
return $this->end_treatment(__METHOD__, false); |
8754 |
} |
} |
8755 |
if (count($courriels_invalides) > 0) { |
// Création de la tache en lui donnant l'id de la notification |
8756 |
$courriels_invalides = implode(', ', $courriels_invalides); |
$notification_by_task = $this->notification_by_task( |
8757 |
$this->addToMessage(_("* un ou plusieurs courriels des destinataires de la commune sont invalides : ").$courriels_invalides); |
$idNotif, |
8758 |
|
$this->getVal('dossier'), |
8759 |
|
'mail', |
8760 |
|
'notification_commune' |
8761 |
|
); |
8762 |
|
if ($notification_by_task === false) { |
8763 |
|
$this->addToMessage(__("Erreur lors de la préparation de la notification des communes.")); |
8764 |
|
$this->addToMessage(__("Veuillez contacter votre administrateur.")); |
8765 |
|
return $this->end_treatment(__METHOD__, false); |
8766 |
} |
} |
|
$this->addToMessage(_("Veuillez contacter votre administrateur.")); |
|
|
return $this->end_treatment(__METHOD__, false); |
|
|
} |
|
|
// Remplacement des variables de substitution |
|
|
$objet = str_replace('<DOSSIER_INSTRUCTION>', $id_di, $objet); |
|
|
$modele = $this->formater_modele($modele, $id_di, $id_inst); |
|
|
// Exécution du traitement d'envoi du/des mail(s) |
|
|
$fails = array(); |
|
|
foreach ($courriels_valides as $email) { |
|
|
if ($this->f->sendMail( |
|
|
iconv("UTF-8", "CP1252", $objet), |
|
|
iconv("UTF-8", "CP1252", $modele), |
|
|
iconv("UTF-8", "CP1252", $email)) === false) { |
|
|
$fails[] = $email; |
|
|
} |
|
|
} |
|
|
// Si échec message d'erreur et arrêt du traitement |
|
|
if (count($fails) > 0) { |
|
|
$fails = implode(', ', $fails); |
|
|
$this->addToMessage(_("Erreur lors de l'envoi du courriel aux destinataires : ").$fails); |
|
|
$this->addToMessage(_("Veuillez contacter votre administrateur.")); |
|
|
return $this->end_treatment(__METHOD__, false); |
|
8767 |
} |
} |
8768 |
// Ajout du log |
$this->addToMessage(__('La commune a été notifiée.')); |
|
$this->setValFFromVal(); |
|
|
$val_inst = $this->valF; |
|
|
$val_inst['mails_destinataires'] = implode(', ', $courriels_valides); |
|
|
if ($this->add_log_to_dossier($id_inst, $val_inst) === false) { |
|
|
$this->addToMessage(_("Erreur lors de la notification.")); |
|
|
$this->addToMessage(_("Veuillez contacter votre administrateur.")); |
|
|
return $this->end_treatment(__METHOD__, false); |
|
|
} |
|
|
// Message de validation |
|
|
$this->addToMessage(_('La commune a été notifiée.')); |
|
8769 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
8770 |
} |
} |
8771 |
|
|
8772 |
/** |
/** |
|
* Formatte le corps du courriel notifié aux communes |
|
|
* |
|
|
* @param string $modele template du modèle du courriel |
|
|
* @param string $id_di clé primaire du DI |
|
|
* @param string $id_inst clé primaire de l'instruction |
|
|
* @return string corps du mail au format HTML |
|
|
*/ |
|
|
public function formater_modele($modele, $id_di, $id_inst) { |
|
|
// Création du lien d'accès direct à l'instruction |
|
|
$url_inst = PATH_BASE_URL.'spg/direct_link.php?obj=dossier_instruction&action=3'. |
|
|
'&direct_field=dossier&direct_form=instruction&direct_action=3&direct_idx='.$id_inst; |
|
|
$url_inst = '<a href="'.$url_inst.'">'.$url_inst.'</a>'; |
|
|
// Remplacement des champs de fusion |
|
|
$modele = str_replace('<DOSSIER_INSTRUCTION>', $id_di, $modele); |
|
|
$modele = str_replace('<URL_INSTRUCTION>', $url_inst, $modele); |
|
|
$modele = str_replace('<ID_INSTRUCTION>', $id_inst, $modele); |
|
|
// Encodage HTML des sauts de ligne |
|
|
$modele = preg_replace("/\r\n|\r|\n/",'<br/>',$modele); |
|
|
// |
|
|
return $modele; |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
8773 |
* Récupère l'instance de l'instructeur |
* Récupère l'instance de l'instructeur |
8774 |
* |
* |
8775 |
* @param integer $instructeur Identifiant de l'instructeur. |
* @param integer $instructeur Identifiant de l'instructeur. |
8857 |
$this->f->get_submitted_get_value('idxformulaire') : $id_dossier = ""); |
$this->f->get_submitted_get_value('idxformulaire') : $id_dossier = ""); |
8858 |
// |
// |
8859 |
if ($id_dossier !== "") { |
if ($id_dossier !== "") { |
8860 |
require_once "../obj/dossier_instruction.class.php"; |
$dossier = $this->f->get_inst__om_dbform(array( |
8861 |
$dossier = new dossier_instruction($id_dossier, $f->db, DEBUG); |
"obj" => "dossier_instruction", |
8862 |
|
"idx" => $id_dossier, |
8863 |
|
)); |
8864 |
// |
// |
8865 |
return $dossier->can_user_access_dossier(); |
return $dossier->can_user_access_dossier(); |
8866 |
} |
} |
8880 |
$id_dossier = $this->getVal('dossier'); |
$id_dossier = $this->getVal('dossier'); |
8881 |
// |
// |
8882 |
if ($id_dossier !== "" && $id_dossier !== null) { |
if ($id_dossier !== "" && $id_dossier !== null) { |
8883 |
require_once "../obj/dossier_instruction.class.php"; |
$dossier = $this->f->get_inst__om_dbform(array( |
8884 |
$dossier = new dossier_instruction($id_dossier, $f->db, DEBUG); |
"obj" => "dossier_instruction", |
8885 |
|
"idx" => $id_dossier, |
8886 |
|
)); |
8887 |
// |
// |
8888 |
return $dossier->can_user_access_dossier(); |
return $dossier->can_user_access_dossier(); |
8889 |
} |
} |
8890 |
return false; |
return false; |
8891 |
} |
} |
8892 |
|
|
8893 |
}// fin classe |
/** |
8894 |
|
* TREATMENT - envoyer_a_signature_sans_relecture |
8895 |
|
* |
8896 |
|
* Permet d'envoyer le document de l'instruction au parapheur pour signature sans relecture |
8897 |
|
* |
8898 |
|
* @return boolean true si l'envoi a été effectué avec succès false sinon |
8899 |
|
*/ |
8900 |
|
function envoyer_a_signature_sans_relecture() { |
8901 |
|
return $this->envoyer_a_signature(); |
8902 |
|
} |
8903 |
|
|
8904 |
|
/** |
8905 |
|
* TREATMENT - envoyer_a_signature_avec_relecture |
8906 |
|
* |
8907 |
|
* Permet d'envoyer le document de l'instruction au parapheur pour signature avec relecture |
8908 |
|
* |
8909 |
|
* @return boolean true si l'envoi a été effectué avec succès false sinon |
8910 |
|
*/ |
8911 |
|
function envoyer_a_signature_avec_relecture() { |
8912 |
|
$is_forced_view_files = true; |
8913 |
|
return $this->envoyer_a_signature($is_forced_view_files); |
8914 |
|
} |
8915 |
|
|
8916 |
|
/** |
8917 |
|
* TREATMENT - envoyer_a_signature |
8918 |
|
* |
8919 |
|
* Permet d'envoyer le document de l'instruction au parapheur pour signature |
8920 |
|
* |
8921 |
|
* @param boolean $is_forced_view_files Indique si il y a une relecture (true) ou non (false) |
8922 |
|
* |
8923 |
|
* @return boolean true si l'envoi a été effectué avec succès false sinon |
8924 |
|
*/ |
8925 |
|
function envoyer_a_signature($is_forced_view_files = false) { |
8926 |
|
$this->begin_treatment(__METHOD__); |
8927 |
|
$this->correct = true; |
8928 |
|
|
8929 |
|
// Instanciation de l'objet signataire_arrete |
8930 |
|
$inst_signataire_arrete = $this->f->get_inst__om_dbform(array( |
8931 |
|
'obj' => 'signataire_arrete', |
8932 |
|
'idx' => $this->getVal('signataire_arrete'), |
8933 |
|
)); |
8934 |
|
|
8935 |
|
// Instanciation de l'objet dossier |
8936 |
|
$inst_dossier = $this->f->get_inst__om_dbform(array( |
8937 |
|
'obj' => 'dossier', |
8938 |
|
'idx' => $this->getVal('dossier'), |
8939 |
|
)); |
8940 |
|
|
8941 |
|
// Récupération du document à signer |
8942 |
|
$file = $this->f->storage->get($this->getVal('om_fichier_instruction')); |
8943 |
|
if ($file === OP_FAILURE) { |
8944 |
|
$this->correct = false; |
8945 |
|
$this->addToMessage(__("Une erreur est survenue lors de la récupération du contenu du document de l'instruction.")); |
8946 |
|
// Termine le traitement |
8947 |
|
return $this->end_treatment(__METHOD__, false); |
8948 |
|
} |
8949 |
|
|
8950 |
|
// Initialisation des paramètre à passer pour l'envoi en signature |
8951 |
|
$data = array( |
8952 |
|
"om_utilisateur_email" => $this->f->om_utilisateur['email'], |
8953 |
|
"om_utilisateur_nom" => $this->f->om_utilisateur['nom'], |
8954 |
|
"signataire_arrete_email" => $inst_signataire_arrete->getVal('email'), |
8955 |
|
"signataire_arrete_nom" => $inst_signataire_arrete->getVal('nom'), |
8956 |
|
"signataire_arrete_prenom" => $inst_signataire_arrete->getVal('prenom'), |
8957 |
|
// Permet d'envoyer en signature l'instruction le jour de la date limite |
8958 |
|
"date_limite_instruction" => $this->compute_date_limite(1) != null ? $this->compute_date_limite(1) : null, |
8959 |
|
"dossier" => $this->getVal('dossier'), |
8960 |
|
"is_forced_view_files" => $is_forced_view_files, |
8961 |
|
'commentaire_signature' => $is_forced_view_files === true ? __('relecture demandee.') : null |
8962 |
|
); |
8963 |
|
|
8964 |
|
// Initialisation des métadonnées |
8965 |
|
$metadonnee_dossier = $file['metadata']; |
8966 |
|
// récupération de l'extension du fichier |
8967 |
|
$extension = substr($metadonnee_dossier['filename'], strrpos($metadonnee_dossier['filename'], '.')); |
8968 |
|
// Modification du libellé du document transmis au parapheur |
8969 |
|
// pour le mettre sous la forme : instruction_xxx_libelle_lettretype.extension |
8970 |
|
$metadonnee_dossier['filename'] = $this->getDocumentLibelle().$extension; |
8971 |
|
$metadonnee_dossier['titre_document'] = $this->getDocumentTitre(); |
8972 |
|
|
8973 |
|
$metadonnee_dossier['url_di'] = sprintf( |
8974 |
|
'%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', |
8975 |
|
$this->f->get_param_base_path_metadata_url_di() !== null ? $this->f->get_param_base_path_metadata_url_di() : PATH_BASE_URL, |
8976 |
|
$this->getVal($this->clePrimaire) |
8977 |
|
); |
8978 |
|
|
8979 |
|
$optional_data = null; |
8980 |
|
// Si il y a des paramètres supplémentaire spécifié dans le signataire alors on les récupère |
8981 |
|
if ($inst_signataire_arrete->getVal('parametre_parapheur') !== null && $inst_signataire_arrete->getVal('parametre_parapheur') !== '') { |
8982 |
|
$optional_data = json_decode($inst_signataire_arrete->getVal('parametre_parapheur'), true); |
8983 |
|
if (json_last_error() !== JSON_ERROR_NONE) { |
8984 |
|
$this->correct = false; |
8985 |
|
$this->addToMessage(__("Les paramètres supplémentaires envoyés au parapheur ne sont pas au bon format.")); |
8986 |
|
$this->addToLog(__METHOD__."(): ". |
8987 |
|
__("Erreur lors du décodage du format json des paramètres supplémentaires envoyé au parapheur. |
8988 |
|
Tableau : ").var_export($inst_signataire_arrete->getVal('parametre_parapheur'), true) |
8989 |
|
); |
8990 |
|
// Termine le traitement |
8991 |
|
return $this->end_treatment(__METHOD__, false); |
8992 |
|
} |
8993 |
|
} |
8994 |
|
|
8995 |
|
//Instanciation de la classe electronicsignature |
8996 |
|
$inst_es = $this->get_electronicsignature_instance(); |
8997 |
|
if ($inst_es === false) { |
8998 |
|
$this->correct = false; |
8999 |
|
return $this->end_treatment(__METHOD__, false); |
9000 |
|
} |
9001 |
|
|
9002 |
|
// Appel de la méthode de l'abstracteur send_for_signature() |
9003 |
|
// Cette méthode doit retourner un tableau de valeur |
9004 |
|
try { |
9005 |
|
$result = $inst_es->send_for_signature($data, $file['file_content'], $metadonnee_dossier, $optional_data); |
9006 |
|
} catch (electronicsignature_exception $e) { |
9007 |
|
$this->handle_electronicsignature_exception($e); |
9008 |
|
return $this->end_treatment(__METHOD__, false); |
9009 |
|
} |
9010 |
|
|
9011 |
|
// Après avoir reçu le résultat du parapheur, il faut mettre à jour les champs |
9012 |
|
$valF = array(); |
9013 |
|
|
9014 |
|
// Pour appeler la fonction modifier il faut traiter tous les champs de l'objet |
9015 |
|
foreach($this->champs as $identifiant => $champ) { |
9016 |
|
$valF[$champ] = $this->val[$identifiant]; |
9017 |
|
} |
9018 |
|
// On fait ensuite nos modifications spécifiques |
9019 |
|
$valF['id_parapheur_signature'] = $result['id_parapheur_signature']; |
9020 |
|
$valF['statut_signature'] = $result['statut']; |
9021 |
|
$valF['commentaire_signature'] = isset($result['commentaire_signature']) == true ? $result['commentaire_signature'] : null; |
9022 |
|
$valF['date_envoi_signature'] = date("Y-m-d", strtotime($result['date_envoi_signature'])); |
9023 |
|
$valF['historique_signature'] = $this->get_updated_historique_signature($result); |
9024 |
|
|
9025 |
|
$ret = $this->modifier($valF); |
9026 |
|
|
9027 |
|
if ($ret === false) { |
9028 |
|
$this->correct = false; |
9029 |
|
$this->addToMessage(__("Une erreur est survenue lors de la mise à jour des champs.")); |
9030 |
|
// Termine le traitement |
9031 |
|
return $this->end_treatment(__METHOD__, false); |
9032 |
|
} |
9033 |
|
|
9034 |
|
// Message |
9035 |
|
$this->addToMessage(__("Le document a été envoyé pour signature dans le parapheur.")); |
9036 |
|
if (array_key_exists('signature_page_url', $result) === true) { |
9037 |
|
$this->addToMessage(sprintf( |
9038 |
|
'<br> > <a href="%1$s" title="%2$s" target="_blank">%2$s</a>', |
9039 |
|
$result['signature_page_url'], |
9040 |
|
__("Signez directement le document") |
9041 |
|
)); |
9042 |
|
} |
9043 |
|
|
9044 |
|
// Tout s'est bien passé, on termine le traitement |
9045 |
|
return $this->end_treatment(__METHOD__, true); |
9046 |
|
} |
9047 |
|
|
9048 |
|
/** |
9049 |
|
* Permet de récupérer la bonne date limite en fonction de si l'instruction |
9050 |
|
* est en incomplet notifié ou non. |
9051 |
|
* On peut ajouter des jours à cette date grâce au paramètre "delay". |
9052 |
|
* Cette fonction est utilisée dans un cas spécifique où on veut envoyer |
9053 |
|
* l'instruction en signature le jour de la date limite. |
9054 |
|
* |
9055 |
|
* @param int $delay Le nombre de jour à ajouter à la date limite. |
9056 |
|
* |
9057 |
|
* @return string $date_limite la date limite calculé ou false |
9058 |
|
*/ |
9059 |
|
private function compute_date_limite($delay) { |
9060 |
|
// Instanciation de l'objet dossier |
9061 |
|
$inst_dossier = $this->f->get_inst__om_dbform(array( |
9062 |
|
'obj' => 'dossier', |
9063 |
|
'idx' => $this->getVal('dossier'), |
9064 |
|
)); |
9065 |
|
|
9066 |
|
$date_to_compute = null; |
9067 |
|
if ($inst_dossier->getVal('incomplet_notifie') === 't') { |
9068 |
|
$date_to_compute = $inst_dossier->getVal('date_limite_incompletude'); |
9069 |
|
} else { |
9070 |
|
$date_to_compute = $inst_dossier->getVal('date_limite'); |
9071 |
|
} |
9072 |
|
if ($date_to_compute != null) { |
9073 |
|
return date("Y-m-d", strtotime($date_to_compute."+ $delay days")); |
9074 |
|
} |
9075 |
|
|
9076 |
|
return null; |
9077 |
|
} |
9078 |
|
|
9079 |
|
/** |
9080 |
|
* Permet de récupérer la traduction de la valeur de statut_signature |
9081 |
|
* |
9082 |
|
* @return string la valeur de statut_signature traduite | false |
9083 |
|
*/ |
9084 |
|
function get_trad_for_statut($value_to_trad){ |
9085 |
|
$statut_signature_tab = array( |
9086 |
|
'waiting' => __('en préparation'), |
9087 |
|
'in_progress' => __('en cours de signature'), |
9088 |
|
'canceled' => __('signature annulée'), |
9089 |
|
'expired' => __('délai de signature expiré'), |
9090 |
|
'finished' => __('signé') |
9091 |
|
); |
9092 |
|
if (array_key_exists($value_to_trad, $statut_signature_tab) === true) { |
9093 |
|
return $statut_signature_tab[$value_to_trad]; |
9094 |
|
} |
9095 |
|
|
9096 |
|
return false; |
9097 |
|
} |
9098 |
|
|
9099 |
|
/** |
9100 |
|
* Permet de mettre à jour le tableau json sotcké dans le champ historique_signature |
9101 |
|
* |
9102 |
|
* @return string (json) la valeur de historique_signature mis à jour | false |
9103 |
|
*/ |
9104 |
|
function get_updated_historique_signature($historique_signature_values) { |
9105 |
|
|
9106 |
|
$historique_signature_value_tab = $this->get_historique_signature_decoded(); |
9107 |
|
|
9108 |
|
if ($historique_signature_value_tab === false) { |
9109 |
|
$this->addToLog(__METHOD__."(): erreur historique signature", DEBUG_MODE); |
9110 |
|
return false; |
9111 |
|
} |
9112 |
|
|
9113 |
|
$last_val_historique_signature = array(); |
9114 |
|
|
9115 |
|
// Si la tableau récupéré n'est pas vide alors |
9116 |
|
// on récupère la dernière ligne du tableau |
9117 |
|
if (empty($historique_signature_value_tab) === false) { |
9118 |
|
$last_val_historique_signature = end($historique_signature_value_tab); |
9119 |
|
} |
9120 |
|
|
9121 |
|
$format_date = ''; |
9122 |
|
$format_date_hour = ''; |
9123 |
|
$date_converted=array(); |
9124 |
|
|
9125 |
|
$date_to_convert = array( |
9126 |
|
'date_envoi_signature' => $historique_signature_values['date_envoi_signature'], |
9127 |
|
'date_limite_instruction' => $this->compute_date_limite(0), |
9128 |
|
'date_retour_signature' => $historique_signature_values['date_retour_signature'] |
9129 |
|
); |
9130 |
|
|
9131 |
|
// Conversion des dates en fonction de leur format |
9132 |
|
foreach ($date_to_convert as $key => $value) { |
9133 |
|
$date_converted[$key] = null; |
9134 |
|
if ($value != null) { |
9135 |
|
$format_date = 'd/m/Y'; |
9136 |
|
$format_date_hour = 'd/m/Y H:i:s'; |
9137 |
|
$date_converted[$key] = empty(date_parse($value)['hour']) === false ? date($format_date_hour, strtotime($value)) : date($format_date, strtotime($value)); |
9138 |
|
} |
9139 |
|
} |
9140 |
|
|
9141 |
|
// Ce tableau permet de lister les colonnes de historique_signature et de les rendre traduisibles. |
9142 |
|
// Il faut en effet mettre les gettext avec l'intitulé explicite au moins |
9143 |
|
// une fois afin qu'il puisse être reconnu par le logiciel de traduction. |
9144 |
|
$tab_for_columns_trad = array( |
9145 |
|
__('entry_date'), |
9146 |
|
__('id_parapheur_signature'), |
9147 |
|
__('emetteur'), |
9148 |
|
__('signataire'), |
9149 |
|
__('date_envoi'), |
9150 |
|
__('date_limite'), |
9151 |
|
__('date_retour'), |
9152 |
|
__('statut_signature'), |
9153 |
|
__('commentaire_signature') |
9154 |
|
); |
9155 |
|
|
9156 |
|
array_push($historique_signature_value_tab, array( |
9157 |
|
'entry_date' => date('d/m/Y H:i:s'), |
9158 |
|
'id_parapheur_signature' => $historique_signature_values['id_parapheur_signature'] == null ? (isset($last_val_historique_signature['id_parapheur_signature']) === true ? $last_val_historique_signature['id_parapheur_signature'] : null) : $historique_signature_values['id_parapheur_signature'], |
9159 |
|
'emetteur' => $historique_signature_values['om_utilisateur_email'] == null ? (isset($last_val_historique_signature['emetteur']) === true ? $last_val_historique_signature['emetteur'] : null) : $historique_signature_values['om_utilisateur_email'], |
9160 |
|
'signataire' => $historique_signature_values['signataire_arrete_email'] == null ? (isset($last_val_historique_signature['signataire']) === true ? $last_val_historique_signature['signataire'] : null) : $historique_signature_values['signataire_arrete_email'], |
9161 |
|
'date_envoi' => $historique_signature_values['date_envoi_signature'] == null ? (isset($last_val_historique_signature['date_envoi']) === true ? $last_val_historique_signature['date_envoi'] : null) : $date_converted['date_envoi_signature'], |
9162 |
|
'date_limite' => $historique_signature_values['date_limite_instruction'] == null ? (isset($last_val_historique_signature['date_limite']) === true ? $last_val_historique_signature['date_limite'] : null) : $date_converted['date_limite_instruction'], |
9163 |
|
'date_retour' => $historique_signature_values['date_retour_signature'] == null ? (isset($last_val_historique_signature['date_retour']) === true ? $last_val_historique_signature['date_retour'] : null) : $date_converted['date_retour_signature'], |
9164 |
|
'statut_signature' => $historique_signature_values['statut'] == null ? (isset($last_val_historique_signature['statut_signature']) === true ? $last_val_historique_signature['statut_signature'] : null) : $this->get_trad_for_statut($historique_signature_values['statut']), |
9165 |
|
'commentaire_signature' => isset($historique_signature_values['commentaire_signature']) === false || $historique_signature_values['commentaire_signature'] == null ? null : $historique_signature_values['commentaire_signature'], |
9166 |
|
)); |
9167 |
|
|
9168 |
|
return json_encode($historique_signature_value_tab, JSON_HEX_APOS); |
9169 |
|
} |
9170 |
|
|
9171 |
|
/** |
9172 |
|
* TREATMENT - annuler_envoi_en_signature |
9173 |
|
* |
9174 |
|
* Permet d'annuler l'envoi du document de l'instruction au parapheur pour signature |
9175 |
|
* |
9176 |
|
* @return boolean true si l'annulation a été effectué avec succès false sinon |
9177 |
|
*/ |
9178 |
|
function annuler_envoi_en_signature() { |
9179 |
|
$this->begin_treatment(__METHOD__); |
9180 |
|
$this->correct = true; |
9181 |
|
|
9182 |
|
//Instanciation de la classe electronicsignature |
9183 |
|
$inst_es = $this->get_electronicsignature_instance(); |
9184 |
|
if ($inst_es === false) { |
9185 |
|
$this->correct = false; |
9186 |
|
return $this->end_treatment(__METHOD__, false); |
9187 |
|
} |
9188 |
|
|
9189 |
|
$data = array(); |
9190 |
|
if (! empty($this->getVal('id_parapheur_signature'))) { |
9191 |
|
$data['id_parapheur_signature'] = $this->getVal('id_parapheur_signature'); |
9192 |
|
} else { |
9193 |
|
$this->correct = false; |
9194 |
|
$this->addToMessage(__("Il n'y a pas d'identifiant de parapheur.")); |
9195 |
|
return $this->end_treatment(__METHOD__, false); |
9196 |
|
} |
9197 |
|
|
9198 |
|
// Appel de la méthode de l'abstracteur cancel_send_for_signature() |
9199 |
|
// Cette méthode doit retourner un tableau de valeur |
9200 |
|
try { |
9201 |
|
$result = $inst_es->cancel_send_for_signature($data); |
9202 |
|
} catch (electronicsignature_exception $e) { |
9203 |
|
$this->handle_electronicsignature_exception($e); |
9204 |
|
return $this->end_treatment(__METHOD__, false); |
9205 |
|
} |
9206 |
|
|
9207 |
|
// Après avoir reçu le résultat du parapheur, il faut mettre à jour les champs |
9208 |
|
$valF = array(); |
9209 |
|
|
9210 |
|
// Pour appeler la fonction modifier il faut traiter tous les champs de l'objet |
9211 |
|
foreach($this->champs as $identifiant => $champ) { |
9212 |
|
$valF[$champ] = $this->val[$identifiant]; |
9213 |
|
} |
9214 |
|
// On fait ensuite nos modifications spécifiques |
9215 |
|
$valF['id_parapheur_signature'] = null; |
9216 |
|
$valF['statut_signature'] = $result['statut']; |
9217 |
|
$valF['commentaire_signature'] = isset($result['commentaire_signature']) == true ? $result['commentaire_signature'] : null; |
9218 |
|
$valF['date_envoi_signature'] = null; |
9219 |
|
$valF['historique_signature'] = $this->get_updated_historique_signature($result); |
9220 |
|
|
9221 |
|
$ret = $this->modifier($valF); |
9222 |
|
|
9223 |
|
if ($ret === false) { |
9224 |
|
$this->correct = false; |
9225 |
|
$this->addToMessage(__("Une erreur est survenue lors de la mise à jour des champs.")); |
9226 |
|
// Termine le traitement |
9227 |
|
return $this->end_treatment(__METHOD__, false); |
9228 |
|
} |
9229 |
|
|
9230 |
|
// Message |
9231 |
|
$this->addToMessage(__("L'annulation a été effectuée avec succès.")); |
9232 |
|
|
9233 |
|
// Tout s'est bien passé, on termine le traitement |
9234 |
|
return $this->end_treatment(__METHOD__, true); |
9235 |
|
} |
9236 |
|
|
9237 |
|
|
9238 |
|
/** |
9239 |
|
* Récupère le contenu du champ historique_signature et le converti en tableau |
9240 |
|
* |
9241 |
|
* @return array sinon false en cas d'erreur |
9242 |
|
*/ |
9243 |
|
protected function get_historique_signature_decoded() { |
9244 |
|
$val = str_replace("'", '"', $this->getVal('historique_signature')); |
9245 |
|
if ($val === '' || $val == 'false') { |
9246 |
|
$val = json_encode(array()); |
9247 |
|
} |
9248 |
|
if($this->isJson($val) === false) { |
9249 |
|
return false; |
9250 |
|
} |
9251 |
|
return json_decode($val, true); |
9252 |
|
} |
9253 |
|
|
9254 |
|
/** |
9255 |
|
* Récupère les informations à afficher dans le tableau de suivi à l'aide |
9256 |
|
* d'une requête sql. Stocke ces informations dans un tableau. |
9257 |
|
* Converti le tableau au format json et renvoi le json obtenu. |
9258 |
|
* |
9259 |
|
* Pour identifier quel suivi est affiché (notification des demandeurs, des services ou |
9260 |
|
* de tiers) ce sont les tâches liées aux notifications qui sont utilisés. |
9261 |
|
* La clause where de la requête est construite à partir du tableau contenant les types |
9262 |
|
* de tâches fourni en paramètre. |
9263 |
|
* Il est également possible d'afficher les notifications n'étant pas lié à des tâches. |
9264 |
|
* |
9265 |
|
* Si le suivi concerne la notification des demandeurs via le portail citoyen, |
9266 |
|
* la date de premier accès ne sera pas affichée. |
9267 |
|
* |
9268 |
|
* @param array liste des tâches permettant d'identifier quelles notification afficher |
9269 |
|
* @param boolean permet d'afficher les notifications non liées à des tâches |
9270 |
|
* @return json |
9271 |
|
*/ |
9272 |
|
protected function get_json_suivi_notification($typeTache, $nonLieTache = false) { |
9273 |
|
$whereTypeTache = ''; |
9274 |
|
$sqlTaskNull = ''; |
9275 |
|
|
9276 |
|
// Liste des champs à afficher. Permet également la traduction des noms de colonnes. |
9277 |
|
$listeChampsTrad = array( |
9278 |
|
__('emetteur'), |
9279 |
|
__('date_envoi'), |
9280 |
|
__('destinataire'), |
9281 |
|
__('date_premier_acces'), |
9282 |
|
__('instruction'), |
9283 |
|
__('annexes'), |
9284 |
|
__('statut'), |
9285 |
|
__('commentaire') |
9286 |
|
); |
9287 |
|
$listeChamps = array( |
9288 |
|
'emetteur', |
9289 |
|
'date_envoi', |
9290 |
|
'destinataire', |
9291 |
|
'date_premier_acces', |
9292 |
|
'instruction', |
9293 |
|
'annexes', |
9294 |
|
'statut', |
9295 |
|
'commentaire' |
9296 |
|
); |
9297 |
|
|
9298 |
|
// Défini si on veux que la requête récupère également les notifications qui n'ont pas |
9299 |
|
// de tâches associées. C'est le cas pour les notifications de demandeurs lorsque la |
9300 |
|
// notification du demandeur principal n'a pas pu être envoyée à cause d'un mauvais |
9301 |
|
// paramétrage |
9302 |
|
if(is_bool($nonLieTache) && $nonLieTache === true) { |
9303 |
|
$sqlTaskNull = 'OR task.type is null'; |
9304 |
|
} |
9305 |
|
// Prépare la clause where pour ne récupérer que les notifications liées à certain type de tâches |
9306 |
|
// Permet de différencier les notifications des demandeurs de celle des services et de celles des |
9307 |
|
// tiers consulté |
9308 |
|
if (is_array($typeTache) && $typeTache != array()) { |
9309 |
|
if (is_array($typeTache)) { |
9310 |
|
$whereTypeTache = sprintf( |
9311 |
|
'AND (task.type IN (%1$s) %2$s)', |
9312 |
|
"'".implode("', '", $typeTache)."'", |
9313 |
|
$sqlTaskNull |
9314 |
|
); |
9315 |
|
} |
9316 |
|
// La date de premier accès n'a pas besoin d'être renseigné pour |
9317 |
|
// les notifications des demandeurs via le portail citoyen. |
9318 |
|
// Les notifications des demandeurs sont liés à 3 types de tâches |
9319 |
|
// notification_recepisse, notification_instruction, notification_decision |
9320 |
|
// Si le suivi de la notification concerne un de ces types de tâches on |
9321 |
|
// considère que c'est une notification de demandeurs. |
9322 |
|
// Dans ce cas on vérifie si cette notification est paramétrée pour passer |
9323 |
|
// via le portail. Par défaut si rien n'est paramétré on considère que la |
9324 |
|
// notification est faite via le portail |
9325 |
|
if ((in_array('notification_recepisse', $typeTache) || |
9326 |
|
in_array('notification_instruction', $typeTache) || |
9327 |
|
in_array('notification_decision', $typeTache))) { |
9328 |
|
$dossier = $this->getVal('dossier'); |
9329 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite($dossier); |
9330 |
|
$modeNotification = $this->f->get_param_option_notification($collectivite_di); |
9331 |
|
if ($modeNotification === PORTAL) { |
9332 |
|
$listeChamps = array( |
9333 |
|
'emetteur', |
9334 |
|
'date_envoi', |
9335 |
|
'destinataire', |
9336 |
|
'instruction', |
9337 |
|
'annexes', |
9338 |
|
'statut', |
9339 |
|
'commentaire' |
9340 |
|
); |
9341 |
|
} |
9342 |
|
} |
9343 |
|
// Il n'y a pas d'annexe pour la notification des communes donc pas besoin |
9344 |
|
// de les afficher dans le suivi |
9345 |
|
if (in_array('notification_depot_demat', $typeTache)) { |
9346 |
|
$listeChamps = array( |
9347 |
|
'emetteur', |
9348 |
|
'date_envoi', |
9349 |
|
'destinataire', |
9350 |
|
'instruction', |
9351 |
|
'statut', |
9352 |
|
'commentaire' |
9353 |
|
); |
9354 |
|
} |
9355 |
|
} |
9356 |
|
|
9357 |
|
$valSuivi = array(); |
9358 |
|
// Récupération des infos nécessaires à l'affichage du tableau |
9359 |
|
$sql = sprintf( |
9360 |
|
'SELECT DISTINCT |
9361 |
|
instruction_notification.instruction_notification, |
9362 |
|
-- Affiche la mention automatique avec le nom de l emetteur si la notification a été envoyé automatiquement |
9363 |
|
CASE WHEN instruction_notification.automatique = TRUE |
9364 |
|
THEN TRIM(CONCAT(instruction_notification.emetteur, \' \', \'(automatique)\')) |
9365 |
|
ELSE instruction_notification.emetteur |
9366 |
|
END as emetteur, |
9367 |
|
date_envoi, |
9368 |
|
instruction_notification.destinataire, |
9369 |
|
instruction_notification.date_premier_acces, |
9370 |
|
evenement.libelle as instruction, |
9371 |
|
instruction_notification.statut, |
9372 |
|
instruction_notification.commentaire, |
9373 |
|
annexes.instruction_annexe as annexes |
9374 |
|
FROM |
9375 |
|
%1$sinstruction_notification |
9376 |
|
LEFT JOIN %1$sinstruction |
9377 |
|
ON instruction.instruction = instruction_notification.instruction |
9378 |
|
LEFT JOIN %1$sevenement |
9379 |
|
ON instruction.evenement = evenement.evenement |
9380 |
|
LEFT JOIN %1$sinstruction_notification_document |
9381 |
|
ON instruction_notification.instruction_notification = instruction_notification_document.instruction_notification |
9382 |
|
AND instruction_notification_document.annexe = true |
9383 |
|
-- Récupère les tâches liées au notification pour pouvoir par la suite identifier le type de notification |
9384 |
|
LEFT JOIN %1$stask |
9385 |
|
ON instruction_notification.instruction_notification::CHARACTER VARYING = task.object_id |
9386 |
|
-- Récupération de la liste des annexes sous la forme d une liste |
9387 |
|
LEFT JOIN ( |
9388 |
|
SELECT |
9389 |
|
instruction_notification, |
9390 |
|
-- Récupère la liste des annexes de la notification |
9391 |
|
-- sous la forme d un json pour récupérer toutes les informatiosn nécessaire |
9392 |
|
-- à l affichage du lien vers les annexes |
9393 |
|
CONCAT( |
9394 |
|
\'[\', |
9395 |
|
STRING_AGG( |
9396 |
|
-- Affiche le nom du fichier selon le type de document/pièce |
9397 |
|
CASE |
9398 |
|
WHEN instruction_notification_document.document_type = \'instruction\' |
9399 |
|
THEN CONCAT( |
9400 |
|
\'{ |
9401 |
|
"obj" : "instruction", |
9402 |
|
"champs" : "om_fichier_instruction", |
9403 |
|
"label" : "\', evenement.libelle, \'", |
9404 |
|
"id" : "\', instruction.instruction,\'" |
9405 |
|
}\' |
9406 |
|
) |
9407 |
|
WHEN instruction_notification_document.document_type = \'consultation\' |
9408 |
|
THEN CONCAT( |
9409 |
|
\'{ |
9410 |
|
"obj" : "consultation", |
9411 |
|
"champs" : "fichier", |
9412 |
|
"label" : "Avis - \', service.libelle, \'", |
9413 |
|
"id" : "\', consultation.consultation,\'" |
9414 |
|
}\' |
9415 |
|
) |
9416 |
|
ELSE |
9417 |
|
CONCAT( |
9418 |
|
\'{ |
9419 |
|
"obj" : "document_numerise", |
9420 |
|
"champs" : "uid", |
9421 |
|
"label" : "\', document_numerise.nom_fichier, \' - \', document_numerise_type.libelle, \'", |
9422 |
|
"id" : "\', document_numerise.document_numerise,\'" |
9423 |
|
}\' |
9424 |
|
) |
9425 |
|
END, |
9426 |
|
\', \'), |
9427 |
|
\']\' |
9428 |
|
) AS instruction_annexe |
9429 |
|
FROM |
9430 |
|
%1$sinstruction_notification_document |
9431 |
|
LEFT JOIN %1$sinstruction |
9432 |
|
ON instruction_notification_document.instruction = instruction.instruction |
9433 |
|
LEFT JOIN %1$sevenement |
9434 |
|
ON instruction.evenement = evenement.evenement |
9435 |
|
LEFT JOIN %1$sconsultation |
9436 |
|
ON instruction_notification_document.document_id = consultation.consultation |
9437 |
|
LEFT JOIN %1$sservice |
9438 |
|
ON consultation.service = service.service |
9439 |
|
LEFT JOIN %1$sdocument_numerise |
9440 |
|
ON instruction_notification_document.document_id = document_numerise.document_numerise |
9441 |
|
LEFT JOIN %1$sdocument_numerise_type |
9442 |
|
ON document_numerise.document_numerise_type = document_numerise_type.document_numerise_type |
9443 |
|
WHERE |
9444 |
|
instruction_notification_document.annexe = \'t\' |
9445 |
|
GROUP BY |
9446 |
|
instruction_notification |
9447 |
|
) AS annexes |
9448 |
|
ON |
9449 |
|
annexes.instruction_notification = instruction_notification.instruction_notification |
9450 |
|
WHERE |
9451 |
|
instruction.instruction = %2$s |
9452 |
|
%3$s |
9453 |
|
ORDER BY |
9454 |
|
date_envoi ASC, instruction_notification.destinataire ASC', |
9455 |
|
DB_PREFIXE, |
9456 |
|
$this->getVal('instruction'), |
9457 |
|
$whereTypeTache |
9458 |
|
); |
9459 |
|
$res = $this->f->db->query($sql); |
9460 |
|
$this->f->addToLog(__METHOD__."(): db->query(\"".$sql."\")", VERBOSE_MODE); |
9461 |
|
$this->f->isDatabaseError($res); |
9462 |
|
// Préparation du lien de téléchargement des annexes |
9463 |
|
$htmlList = |
9464 |
|
'<style> |
9465 |
|
#content .gridjs-td a.lien_annexe { |
9466 |
|
text-decoration : underline dotted 1px; |
9467 |
|
} |
9468 |
|
#content a.lien_annexe:hover { |
9469 |
|
text-decoration : underline solid 1px; |
9470 |
|
color : #46aede; |
9471 |
|
} |
9472 |
|
ol {padding-left : 10px;} |
9473 |
|
</style> |
9474 |
|
<ol>%1$s</ol>'; |
9475 |
|
$lienTelechargement = |
9476 |
|
'<a class="lien_annexe" href="../app/index.php?module=form&snippet=file&obj=%1$s&champ=%2$s&id=%3$s" target="blank" title="%4$s"> |
9477 |
|
Annexe |
9478 |
|
</a>'; |
9479 |
|
// Stockage des infos de chaque notification dans un tableau |
9480 |
|
while( $row =& $res->fetchrow(DB_FETCHMODE_ASSOC) ) { |
9481 |
|
$valNotif = array(); |
9482 |
|
foreach($listeChamps as $champ) { |
9483 |
|
$valNotif[$champ] = $row[$champ]; |
9484 |
|
if (($champ === 'date_envoi' |
9485 |
|
|| $champ === 'date_premier_acces') |
9486 |
|
&& $row[$champ] !== null |
9487 |
|
&& $row[$champ] !== '') { |
9488 |
|
// |
9489 |
|
$valNotif[$champ] = date('d/m/Y H:i:s', strtotime($row[$champ])); |
9490 |
|
} else if ($champ === 'annexes') { |
9491 |
|
$listeAnnexe = ''; |
9492 |
|
$infoAnnexes = json_decode($row[$champ], true); |
9493 |
|
if (! empty($infoAnnexes) && json_last_error() === JSON_ERROR_NONE) { |
9494 |
|
// A partir des infos récupérées prépare le code html du lien vers chacune |
9495 |
|
// des annexes et ajoute un élément de liste par annexe |
9496 |
|
foreach($infoAnnexes as $annexe) { |
9497 |
|
$listeAnnexe .= sprintf( |
9498 |
|
'<li>%s</li>', |
9499 |
|
sprintf($lienTelechargement, |
9500 |
|
$annexe['obj'], |
9501 |
|
$annexe['champs'], |
9502 |
|
$annexe['id'], |
9503 |
|
$annexe['label'] |
9504 |
|
) |
9505 |
|
); |
9506 |
|
} |
9507 |
|
// Construction de la liste des annexes |
9508 |
|
$valNotif[$champ] = sprintf( |
9509 |
|
$htmlList, |
9510 |
|
$listeAnnexe |
9511 |
|
); |
9512 |
|
} |
9513 |
|
} |
9514 |
|
} |
9515 |
|
array_push($valSuivi, $valNotif); |
9516 |
|
} |
9517 |
|
|
9518 |
|
// Passage du tableau au format json |
9519 |
|
return json_encode($valSuivi, JSON_HEX_APOS); |
9520 |
|
} |
9521 |
|
|
9522 |
|
/** |
9523 |
|
* Traitement des erreurs retournées par l'abstracteur electronicsignature. |
9524 |
|
* |
9525 |
|
* @param electronicsignature_exception $exception Exception retournée par l'abstracteur. |
9526 |
|
* |
9527 |
|
* @return void |
9528 |
|
*/ |
9529 |
|
public function handle_electronicsignature_exception(electronicsignature_exception $exception) { |
9530 |
|
$this->f->displayMessage('error', $exception->getMessage()); |
9531 |
|
} |
9532 |
|
|
9533 |
|
|
9534 |
|
/** |
9535 |
|
* Retourne une instance du connecteur electronicsignature, et la créer si elle n'existe pas. |
9536 |
|
* |
9537 |
|
* @param boolean $with_handle_error Flag pour afficher ou non le message d'erreur à l'utilisateur. |
9538 |
|
* @return electronicsignature Instance de l'abstracteur. |
9539 |
|
*/ |
9540 |
|
public function get_electronicsignature_instance($with_handle_error = true) { |
9541 |
|
if(isset($this->electronicsignature_instance)) { |
9542 |
|
return $this->electronicsignature_instance; |
9543 |
|
} |
9544 |
|
// Instanciation du connecteur electronicsignature |
9545 |
|
try { |
9546 |
|
require_once "electronicsignature.class.php"; |
9547 |
|
$collectivites = array("collectivite_idx" => $this->get_dossier_instruction_om_collectivite(), "collectivite_multi_idx" => $this->f->get_idx_collectivite_multi()); |
9548 |
|
$this->electronicsignature_instance = new electronicsignature($collectivites); |
9549 |
|
} catch (electronicsignature_exception $e) { |
9550 |
|
if ($with_handle_error === true) { |
9551 |
|
$this->handle_electronicsignature_exception($e); |
9552 |
|
} |
9553 |
|
return false; |
9554 |
|
} |
9555 |
|
return $this->electronicsignature_instance; |
9556 |
|
} |
9557 |
|
|
9558 |
|
/** |
9559 |
|
* TREATMENT - envoyer_au_controle_de_legalite |
9560 |
|
* |
9561 |
|
* Ajoute la tâche envoi_CL. |
9562 |
|
* C'est le traitement de la tâche qui mettra à jour la date d'envoi au contrôle de légalité. |
9563 |
|
* |
9564 |
|
* @return [type] [description] |
9565 |
|
*/ |
9566 |
|
function envoyer_au_controle_de_legalite() { |
9567 |
|
$this->begin_treatment(__METHOD__); |
9568 |
|
$this->correct = true; |
9569 |
|
|
9570 |
|
// |
9571 |
|
if ($this->can_be_sended_to_cl() === true) { |
9572 |
|
// Création de la task 'envoi_CL' |
9573 |
|
$inst_task = $this->f->get_inst__om_dbform(array( |
9574 |
|
"obj" => "task", |
9575 |
|
"idx" => 0, |
9576 |
|
)); |
9577 |
|
$task_val = array( |
9578 |
|
'type' => 'envoi_CL', |
9579 |
|
'object_id' => $this->getVal('instruction'), |
9580 |
|
'dossier' => $this->getVal('dossier'), |
9581 |
|
); |
9582 |
|
// Change l'état de la tâche de notification en fonction de l'état de |
9583 |
|
// transmission du dossier d'instruction |
9584 |
|
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
9585 |
|
if ($this->f->is_option_mode_service_consulte_enabled() === false |
9586 |
|
&& ($inst_di->getVal('etat_transmission_platau') == 'non_transmissible' |
9587 |
|
|| $inst_di->getVal('etat_transmission_platau') == 'transmis_mais_non_transmissible')) { |
9588 |
|
// |
9589 |
|
$task_val['state'] = $inst_task::STATUS_DRAFT; |
9590 |
|
} |
9591 |
|
$add_task = $inst_task->add_task(array('val' => $task_val)); |
9592 |
|
if ($add_task === false) { |
9593 |
|
$this->addToMessage(sprintf('%s %s', |
9594 |
|
__("Une erreur s'est produite lors de la création tâche."), |
9595 |
|
__("Veuillez contacter votre administrateur.") |
9596 |
|
)); |
9597 |
|
$this->correct = false; |
9598 |
|
return $this->end_treatment(__METHOD__, false); |
9599 |
|
} |
9600 |
|
// Mise à jour du champs 'envoye_cl_platau' |
9601 |
|
$instr_val = array( |
9602 |
|
'envoye_cl_platau' => 't', |
9603 |
|
); |
9604 |
|
$res = $this->f->db->autoExecute( |
9605 |
|
DB_PREFIXE.$this->table, |
9606 |
|
$instr_val, |
9607 |
|
DB_AUTOQUERY_UPDATE, |
9608 |
|
$this->getCle($this->getVal($this->clePrimaire)) |
9609 |
|
); |
9610 |
|
$this->addToLog(__METHOD__."(): db->autoexecute(\"".DB_PREFIXE.'.'.$this->table."\", ".print_r($instr_val, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($this->clePrimaire)."\");", VERBOSE_MODE); |
9611 |
|
if ($this->f->isDatabaseError($res, true) === true) { |
9612 |
|
$this->addToMessage(sprintf('%s %s', |
9613 |
|
__("Une erreur s'est produite lors de la mise à jour de l'instruction."), |
9614 |
|
__("Veuillez contacter votre administrateur.") |
9615 |
|
)); |
9616 |
|
$this->correct = false; |
9617 |
|
return $this->end_treatment(__METHOD__, false); |
9618 |
|
} |
9619 |
|
// Message de validation à l'utilisateur |
9620 |
|
$this->addToMessage(__('Votre demande de transfert au contrôle de légalité à bien été prise en compte.')); |
9621 |
|
$this->addToMessage(__("La date d'envoi au contrôle de légalité sera mise à jour ultérieurement.")); |
9622 |
|
} |
9623 |
|
// |
9624 |
|
return $this->end_treatment(__METHOD__, true); |
9625 |
|
} |
9626 |
|
|
9627 |
|
|
9628 |
|
/** |
9629 |
|
* Retourne le lien de retour (VIEW formulaire et VIEW sousformulaire). |
9630 |
|
* |
9631 |
|
* @param string $view Appel dans le contexte de la vue 'formulaire' ou de |
9632 |
|
* la vue 'sousformulaire'. |
9633 |
|
* |
9634 |
|
* @return string |
9635 |
|
*/ |
9636 |
|
function get_back_link($view = "formulaire") { |
9637 |
|
// |
9638 |
|
$href = parent::get_back_link($view); |
9639 |
|
// |
9640 |
|
$crud = $this->get_action_crud(); |
9641 |
|
|
9642 |
|
// Redirection vers le formulaire de modification à la validation du |
9643 |
|
// formulaire d'ajout si l'événement associé possède une lettre type |
9644 |
|
if (($crud === 'create' |
9645 |
|
|| ($crud === null |
9646 |
|
&& $this->getParameter('maj') == 0)) |
9647 |
|
&& $this->correct == true |
9648 |
|
&& $this->evenement_has_an_edition($this->valF['evenement']) === true) { |
9649 |
|
|
9650 |
|
// On instancie l'instruction |
9651 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
9652 |
|
"obj" => "instruction", |
9653 |
|
"idx" => $this->valF[$this->clePrimaire], |
9654 |
|
)); |
9655 |
|
|
9656 |
|
// Si l'instruction n'est pas finalisée automatiquement |
9657 |
|
if ($inst_instruction->getVal('om_final_instruction') !== 't') { |
9658 |
|
$href = str_replace("&action=3", "&action=1", $href); |
9659 |
|
// |
9660 |
|
if (strpos($href, "&retour=tab") !== false) { |
9661 |
|
$href = str_replace("&retour=tab", "&retour= form", $href); |
9662 |
|
} else { |
9663 |
|
$href .= "&retour=form"; |
9664 |
|
} |
9665 |
|
} |
9666 |
|
} |
9667 |
|
|
9668 |
|
// |
9669 |
|
return $href; |
9670 |
|
} |
9671 |
|
|
9672 |
|
public function view_json_data() { |
9673 |
|
$this->checkAccessibility(); |
9674 |
|
$this->f->disableLog(); |
9675 |
|
$view = $this->get_json_data(); |
9676 |
|
printf(json_encode($view)); |
9677 |
|
} |
9678 |
|
|
9679 |
|
public function get_json_data() { |
9680 |
|
$val = array_combine($this->champs, $this->val); |
9681 |
|
foreach ($val as $key => $value) { |
9682 |
|
$val[$key] = strip_tags($value); |
9683 |
|
} |
9684 |
|
$val['tacite'] = 'f'; |
9685 |
|
$inst_ad = $this->f->get_inst__om_dbform(array( |
9686 |
|
"obj" => "avis_decision", |
9687 |
|
"idx" => $val['avis_decision'], |
9688 |
|
)); |
9689 |
|
if (preg_match('/[tT]acite/', $inst_ad->getVal('libelle')) === 1) { |
9690 |
|
$val['tacite'] = 't'; |
9691 |
|
} |
9692 |
|
return $val; |
9693 |
|
} |
9694 |
|
|
9695 |
|
/** |
9696 |
|
* Permet de récupérer l'identifiant de l'instruction sur le dossier, ayant |
9697 |
|
* comme événement lié le suivant définit dans l'événement de l'instruction |
9698 |
|
* instanciée. |
9699 |
|
* |
9700 |
|
* @param string $next_type Correspond aux trois déclenchement automatique |
9701 |
|
* de création d'instruction paramétré sur un événement. |
9702 |
|
* @param integer $instruction Identifiant de l'instruction à instancier. |
9703 |
|
* @return mixed Identifiant de l'instruction recherchée ou false. |
9704 |
|
*/ |
9705 |
|
public function get_related_instructions_next($next_type = 'retour_signature', $instruction = null) { |
9706 |
|
if (in_array($next_type, array('retour_signature', 'retour_ar', 'suivant_tacite', )) === false) { |
9707 |
|
return false; |
9708 |
|
} |
9709 |
|
$result = array(); |
9710 |
|
$evenements = array(); |
9711 |
|
if ($instruction === null) { |
9712 |
|
$instruction = $this->getVal($this->clePrimaire); |
9713 |
|
$evenement = $this->getVal('evenement'); |
9714 |
|
$dossier = $this->getVal('dossier'); |
9715 |
|
} else { |
9716 |
|
$inst = $this->f->get_inst__om_dbform(array( |
9717 |
|
"obj" => "instruction", |
9718 |
|
"idx" => $instruction, |
9719 |
|
)); |
9720 |
|
$evenement = $inst->getVal('evenement'); |
9721 |
|
$dossier = $inst->getVal('dossier'); |
9722 |
|
} |
9723 |
|
// Récupération de l'identifiant de l'événement paramétré comme suivant |
9724 |
|
// sur l'instruction instanciée |
9725 |
|
$qres = $this->f->get_one_result_from_db_query( |
9726 |
|
sprintf( |
9727 |
|
'SELECT |
9728 |
|
evenement_%3$s |
9729 |
|
FROM |
9730 |
|
%1$sevenement |
9731 |
|
WHERE |
9732 |
|
evenement = %2$s', |
9733 |
|
DB_PREFIXE, |
9734 |
|
intval($evenement), |
9735 |
|
$next_type |
9736 |
|
), |
9737 |
|
array( |
9738 |
|
"origin" => __METHOD__, |
9739 |
|
"force_return" => true, |
9740 |
|
) |
9741 |
|
); |
9742 |
|
if ($qres["code"] !== "OK") { |
9743 |
|
return false; |
9744 |
|
} |
9745 |
|
$ev_next = $qres["result"]; |
9746 |
|
// Récupération de l'instruction dans le dossier utilisant l'événement |
9747 |
|
// suivant identifié dans la requête précédente |
9748 |
|
$qres = $this->f->get_one_result_from_db_query( |
9749 |
|
sprintf( |
9750 |
|
'SELECT |
9751 |
|
MAX(instruction.instruction) as instruction |
9752 |
|
FROM |
9753 |
|
%1$sinstruction |
9754 |
|
WHERE |
9755 |
|
dossier = \'%3$s\' |
9756 |
|
AND evenement = %2$s', |
9757 |
|
DB_PREFIXE, |
9758 |
|
intval($ev_next), |
9759 |
|
$this->f->db->escapeSimple($dossier) |
9760 |
|
), |
9761 |
|
array( |
9762 |
|
"origin" => __METHOD__, |
9763 |
|
"force_return" => true, |
9764 |
|
) |
9765 |
|
); |
9766 |
|
if ($qres["code"] !== "OK") { |
9767 |
|
return false; |
9768 |
|
} |
9769 |
|
return $qres["result"]; |
9770 |
|
} |
9771 |
|
|
9772 |
|
public function get_related_instructions($instruction = null) { |
9773 |
|
$result = array(); |
9774 |
|
$evenements = array(); |
9775 |
|
if ($instruction === null) { |
9776 |
|
$instruction = $this->getVal($this->clePrimaire); |
9777 |
|
$evenement = $this->getVal('evenement'); |
9778 |
|
$dossier = $this->getVal('dossier'); |
9779 |
|
} else { |
9780 |
|
$inst = $this->f->get_inst__om_dbform(array( |
9781 |
|
"obj" => "instruction", |
9782 |
|
"idx" => $instruction, |
9783 |
|
)); |
9784 |
|
$evenement = $inst->getVal('evenement'); |
9785 |
|
$dossier = $inst->getVal('dossier'); |
9786 |
|
} |
9787 |
|
// |
9788 |
|
$qres = $this->f->get_one_result_from_db_query( |
9789 |
|
sprintf( |
9790 |
|
'SELECT |
9791 |
|
evenement |
9792 |
|
FROM |
9793 |
|
%1$sevenement |
9794 |
|
WHERE |
9795 |
|
evenement_retour_ar = %2$s |
9796 |
|
OR evenement_retour_signature = %2$s', |
9797 |
|
DB_PREFIXE, |
9798 |
|
intval($evenement) |
9799 |
|
), |
9800 |
|
array( |
9801 |
|
"origin" => __METHOD__, |
9802 |
|
"force_return" => true, |
9803 |
|
) |
9804 |
|
); |
9805 |
|
if ($qres["code"] !== "OK") { |
9806 |
|
return false; |
9807 |
|
} |
9808 |
|
$ev_parent = $qres["result"]; |
9809 |
|
// |
9810 |
|
$qres = $this->f->get_one_result_from_db_query( |
9811 |
|
sprintf( |
9812 |
|
'SELECT |
9813 |
|
MAX(instruction.instruction) as instruction |
9814 |
|
FROM |
9815 |
|
%1$sinstruction |
9816 |
|
WHERE |
9817 |
|
dossier = \'%3$s\' |
9818 |
|
AND evenement = %2$s', |
9819 |
|
DB_PREFIXE, |
9820 |
|
intval($ev_parent), |
9821 |
|
$this->f->db->escapeSimple($dossier) |
9822 |
|
), |
9823 |
|
array( |
9824 |
|
"origin" => __METHOD__, |
9825 |
|
"force_return" => true, |
9826 |
|
) |
9827 |
|
); |
9828 |
|
if ($qres["code"] !== "OK") { |
9829 |
|
return false; |
9830 |
|
} |
9831 |
|
$result[] = $qres["result"]; |
9832 |
|
// |
9833 |
|
$qres = $this->f->get_one_result_from_db_query( |
9834 |
|
sprintf( |
9835 |
|
'SELECT |
9836 |
|
evenement_retour_ar |
9837 |
|
FROM |
9838 |
|
%1$sevenement |
9839 |
|
WHERE |
9840 |
|
evenement = %2$s |
9841 |
|
AND evenement_retour_ar != %3$s', |
9842 |
|
DB_PREFIXE, |
9843 |
|
intval($ev_parent), |
9844 |
|
intval($evenement) |
9845 |
|
), |
9846 |
|
array( |
9847 |
|
"origin" => __METHOD__, |
9848 |
|
"force_return" => true, |
9849 |
|
) |
9850 |
|
); |
9851 |
|
if ($qres["code"] !== "OK") { |
9852 |
|
return false; |
9853 |
|
} |
9854 |
|
$evenements[] = $qres["result"]; |
9855 |
|
// |
9856 |
|
$qres = $this->f->get_one_result_from_db_query( |
9857 |
|
sprintf( |
9858 |
|
'SELECT |
9859 |
|
evenement_retour_signature |
9860 |
|
FROM |
9861 |
|
%1$sevenement |
9862 |
|
WHERE |
9863 |
|
evenement = %2$s |
9864 |
|
AND evenement_retour_signature != %3$s |
9865 |
|
', |
9866 |
|
DB_PREFIXE, |
9867 |
|
intval($ev_parent), |
9868 |
|
intval($evenement) |
9869 |
|
), |
9870 |
|
array( |
9871 |
|
"origin" => __METHOD__, |
9872 |
|
"force_return" => true, |
9873 |
|
) |
9874 |
|
); |
9875 |
|
if ($qres["code"] !== "OK") { |
9876 |
|
return false; |
9877 |
|
} |
9878 |
|
$evenements[] = $qres["result"]; |
9879 |
|
foreach ($evenements as $value) { |
9880 |
|
if ($value !== null) { |
9881 |
|
$qres = $this->f->get_one_result_from_db_query( |
9882 |
|
sprintf( |
9883 |
|
'SELECT |
9884 |
|
MAX(instruction.instruction) as instruction |
9885 |
|
FROM |
9886 |
|
%1$sinstruction |
9887 |
|
WHERE |
9888 |
|
dossier = \'%3$s\' |
9889 |
|
AND evenement = %2$s', |
9890 |
|
DB_PREFIXE, |
9891 |
|
intval($value), |
9892 |
|
$this->f->db->escapeSimple($dossier) |
9893 |
|
), |
9894 |
|
array( |
9895 |
|
"origin" => __METHOD__, |
9896 |
|
"force_return" => true, |
9897 |
|
) |
9898 |
|
); |
9899 |
|
if ($qres["code"] !== "OK") { |
9900 |
|
return false; |
9901 |
|
} |
9902 |
|
$result[] = $qres["result"]; |
9903 |
|
} |
9904 |
|
} |
9905 |
|
return $result; |
9906 |
|
} |
9907 |
|
|
9908 |
|
protected function getDocumentType($champ = null) { |
9909 |
|
$evenementId = $this->getVal('evenement'); |
9910 |
|
if (! empty($evenementId)) { |
9911 |
|
$evenement = $this->f->findObjectById('evenement', $evenementId); |
9912 |
|
if (! empty($evenement)) { |
9913 |
|
return __("Instruction").':'.$evenement->getVal('libelle'); |
9914 |
|
} |
9915 |
|
} |
9916 |
|
return parent::getDocumentType(); |
9917 |
|
} |
9918 |
|
|
9919 |
|
/** |
9920 |
|
* Récupère à l'aide d'une requête sql la liste des demandeurs |
9921 |
|
* pouvant être notifié. C'est à dire les demandeurs acceptant |
9922 |
|
* les notifications et pour lesquels une adresse mail existe. |
9923 |
|
* |
9924 |
|
* Dans le cas, d'une notification pour le portail citoyen, seul |
9925 |
|
* le pétitionnaire principal doit être notifier et uniquement si |
9926 |
|
* il a une adress mail et qu'il accepte les notifications. |
9927 |
|
* |
9928 |
|
* @param string identifiant du dossier |
9929 |
|
* @param boolean true si il faut récupérer la liste des demandeurs notifiable |
9930 |
|
* pour une notification de categorie portail |
9931 |
|
* @return array liste des demandeurs pouvant être notifié |
9932 |
|
*/ |
9933 |
|
protected function get_demandeurs_notifiable($idDossier = null, $portail = false) { |
9934 |
|
if ($idDossier === null) { |
9935 |
|
$idDossier = $this->getVal('dossier'); |
9936 |
|
} |
9937 |
|
// Ajoute une condition sur le where pour ne récupérer que le pétitionnaire principal |
9938 |
|
// pour une notification depuis le portail citoyen |
9939 |
|
$sqlPetitionnairePrincipal = ''; |
9940 |
|
// Gestion des champs nécessaires pour la notification d'un demandeur |
9941 |
|
$condition_demandeur = "AND demandeur.notification = 't' |
9942 |
|
AND demandeur.courriel IS NOT NULL"; |
9943 |
|
if ($portail === true) { |
9944 |
|
$sqlPetitionnairePrincipal = 'AND lien_dossier_demandeur.petitionnaire_principal = true'; |
9945 |
|
$condition_demandeur = "AND ( |
9946 |
|
(notification = 't' AND courriel IS NOT NULL) |
9947 |
|
OR demande.source_depot = 'portal' |
9948 |
|
)"; |
9949 |
|
} |
9950 |
|
|
9951 |
|
$listeDemandeursNotifiable = array(); |
9952 |
|
|
9953 |
|
// Requête de récupération des demandeurs |
9954 |
|
$sql = sprintf( |
9955 |
|
'SELECT |
9956 |
|
demandeur.demandeur, |
9957 |
|
CASE |
9958 |
|
WHEN demandeur.qualite=\'particulier\' |
9959 |
|
THEN TRIM(CONCAT(demandeur.particulier_nom, \' \', demandeur.particulier_prenom, \' \', demandeur.courriel)) |
9960 |
|
ELSE |
9961 |
|
TRIM(CONCAT(demandeur.personne_morale_raison_sociale, \' \', demandeur.personne_morale_denomination, \' \', demandeur.courriel)) |
9962 |
|
END AS destinataire, |
9963 |
|
demandeur.courriel, |
9964 |
|
petitionnaire_principal |
9965 |
|
FROM |
9966 |
|
%1$sdossier |
9967 |
|
INNER JOIN %1$slien_dossier_demandeur |
9968 |
|
ON dossier.dossier = lien_dossier_demandeur.dossier |
9969 |
|
INNER JOIN %1$sdemandeur |
9970 |
|
ON lien_dossier_demandeur.demandeur = demandeur.demandeur |
9971 |
|
-- Récupération de la plus ancienne demande associée au dossier (la demande |
9972 |
|
-- de création du dossier) |
9973 |
|
INNER JOIN ( |
9974 |
|
SELECT |
9975 |
|
demande, |
9976 |
|
dossier_instruction, |
9977 |
|
source_depot |
9978 |
|
FROM |
9979 |
|
%1$sdemande |
9980 |
|
WHERE |
9981 |
|
dossier_instruction = \'%2$s\' |
9982 |
|
ORDER BY |
9983 |
|
demande ASC |
9984 |
|
LIMIT 1 |
9985 |
|
) as demande |
9986 |
|
ON dossier.dossier = demande.dossier_instruction |
9987 |
|
WHERE |
9988 |
|
dossier.dossier = \'%2$s\' |
9989 |
|
%3$s |
9990 |
|
%4$s', |
9991 |
|
DB_PREFIXE, |
9992 |
|
$idDossier, |
9993 |
|
$condition_demandeur, |
9994 |
|
$sqlPetitionnairePrincipal |
9995 |
|
); |
9996 |
|
$res = $this->f->db->query($sql); |
9997 |
|
$this->f->addToLog(__METHOD__."(): db->query(\"".$sql."\")", VERBOSE_MODE); |
9998 |
|
$this->f->isDatabaseError($res); |
9999 |
|
// Récupération des infos des demandeurs et stockage dans un tableau |
10000 |
|
// ayant pour clé les id des demandeurs |
10001 |
|
while($row = $res->fetchrow(DB_FETCHMODE_ASSOC)) { |
10002 |
|
$listeDemandeursNotifiable[$row['demandeur']] = $row; |
10003 |
|
} |
10004 |
|
|
10005 |
|
return $listeDemandeursNotifiable; |
10006 |
|
} |
10007 |
|
|
10008 |
|
/** |
10009 |
|
* Renvoie la liste des notifications liées à l'instruction |
10010 |
|
* |
10011 |
|
* @param integer id de l'instruction dont on cherche les notifications |
10012 |
|
* @return array liste des instruction_notification liés à l'instruction |
10013 |
|
*/ |
10014 |
|
public function get_instruction_notification($id_instruction, $typeNotification = null, $nonLieTache = false) { |
10015 |
|
$whereTypeTache = ''; |
10016 |
|
$sqlTaskNull = ''; |
10017 |
|
// Défini si on veux que la requête récupère également les notifications qui n'ont pas |
10018 |
|
// de tâches associées. C'est le cas pour les notifications de demandeurs lorsque la |
10019 |
|
// notification du demandeur principal n'a pas pu être envoyée à cause d'un mauvais |
10020 |
|
// paramétrage |
10021 |
|
if(is_bool($nonLieTache) && $nonLieTache === true) { |
10022 |
|
$sqlTaskNull = 'OR task.type is null'; |
10023 |
|
} |
10024 |
|
if ($typeNotification != null) { |
10025 |
|
if (is_array($typeNotification)) { |
10026 |
|
$whereTypeTache = sprintf( |
10027 |
|
'AND (task.type IN (%1$s) %2$s)', |
10028 |
|
"'".implode("', '", $typeNotification)."'", |
10029 |
|
$sqlTaskNull |
10030 |
|
); |
10031 |
|
} else { |
10032 |
|
$whereTypeTache = sprintf( |
10033 |
|
'AND (task.type = \'%1$s\' %2$s)', |
10034 |
|
$typeNotification, |
10035 |
|
$sqlTaskNull |
10036 |
|
); |
10037 |
|
} |
10038 |
|
} |
10039 |
|
$listeInstrNotif = array(); |
10040 |
|
$sql = sprintf(' |
10041 |
|
SELECT |
10042 |
|
instruction_notification.instruction_notification |
10043 |
|
FROM |
10044 |
|
%1$sinstruction_notification |
10045 |
|
LEFT JOIN %1$stask |
10046 |
|
ON instruction_notification.instruction_notification::CHARACTER VARYING = task.object_id |
10047 |
|
WHERE |
10048 |
|
instruction = %2$s |
10049 |
|
%3$s', |
10050 |
|
DB_PREFIXE, |
10051 |
|
intval($id_instruction), |
10052 |
|
$whereTypeTache |
10053 |
|
); |
10054 |
|
$res = $this->f->db->query($sql); |
10055 |
|
$this->f->addToLog(__METHOD__."(): db->query(\"".$sql."\")", VERBOSE_MODE); |
10056 |
|
$this->f->isDatabaseError($res); |
10057 |
|
while ($row = $res->fetchrow(DB_FETCHMODE_ASSOC)) { |
10058 |
|
$listeInstrNotif[] = $row['instruction_notification']; |
10059 |
|
} |
10060 |
|
return $listeInstrNotif; |
10061 |
|
} |
10062 |
|
|
10063 |
|
/** |
10064 |
|
* Crée une clé d'accès unique permettant à un utilisateur |
10065 |
|
* anonyme de récupérer le document. |
10066 |
|
* |
10067 |
|
* @return string clé d'accès du document |
10068 |
|
*/ |
10069 |
|
protected function getCleAccesDocument() { |
10070 |
|
// Initialisation d'un tableau |
10071 |
|
$number_list = array(); |
10072 |
|
|
10073 |
|
// Génération aléatoire d'un nombre sur 4 caractères, 4 fois |
10074 |
|
for ($i = 0; $i < 4; $i++) { |
10075 |
|
$number_list[] = str_pad(mt_rand(0, 9999), 4, 0, STR_PAD_LEFT); |
10076 |
|
} |
10077 |
|
|
10078 |
|
// Transformation en chaîne tout en séparant les nombres par un "-" |
10079 |
|
$result = implode('-', $number_list); |
10080 |
|
|
10081 |
|
// Vérifie si la clé existe déjà et si c'est le cas génére une nouvelle clé |
10082 |
|
if ($this->getUidDocumentInstructionWithKey($result) != null) { |
10083 |
|
return $this->getCleAccesDocument(); |
10084 |
|
} |
10085 |
|
|
10086 |
|
// |
10087 |
|
return $result; |
10088 |
|
} |
10089 |
|
|
10090 |
|
/** |
10091 |
|
* Récupère une clé et renvoie l'uid du document liée à cette |
10092 |
|
* clé. Si la clé n'existe pas renvoie null. |
10093 |
|
* |
10094 |
|
* @param string $cleGen clé dont on cherche l'instruction |
10095 |
|
* @return integer|null |
10096 |
|
*/ |
10097 |
|
protected function getUidDocumentInstructionWithKey($cleGen) { |
10098 |
|
$qres = $this->f->get_one_result_from_db_query( |
10099 |
|
sprintf( |
10100 |
|
'SELECT |
10101 |
|
instruction.om_fichier_instruction |
10102 |
|
FROM |
10103 |
|
%1$sinstruction_notification_document |
10104 |
|
LEFT JOIN %1$sinstruction |
10105 |
|
ON instruction_notification_document.instruction = instruction.instruction |
10106 |
|
WHERE |
10107 |
|
instruction_notification_document.cle = \'%2$s\'', |
10108 |
|
DB_PREFIXE, |
10109 |
|
$this->f->db->escapeSimple($cleGen) |
10110 |
|
), |
10111 |
|
array( |
10112 |
|
"origin" => __METHOD__, |
10113 |
|
) |
10114 |
|
); |
10115 |
|
|
10116 |
|
return $qres['result']; |
10117 |
|
} |
10118 |
|
|
10119 |
|
/** |
10120 |
|
* Récupère une clé, fait une requête pour récupérer l'id de la notification liée a cette clé. |
10121 |
|
* Récupère l'instance de instruction_notification dont l'id a été récupéré et la renvoie. |
10122 |
|
* |
10123 |
|
* @param string $cleGen |
10124 |
|
* @return instruction_notification |
10125 |
|
*/ |
10126 |
|
protected function getInstanceNotificationWithKey($key) { |
10127 |
|
$qres = $this->f->get_one_result_from_db_query( |
10128 |
|
sprintf( |
10129 |
|
'SELECT |
10130 |
|
instruction_notification |
10131 |
|
FROM |
10132 |
|
%1$sinstruction_notification_document |
10133 |
|
WHERE |
10134 |
|
cle = \'%2$s\'', |
10135 |
|
DB_PREFIXE, |
10136 |
|
$this->f->db->escapeSimple($key) |
10137 |
|
), |
10138 |
|
array( |
10139 |
|
"origin" => __METHOD__, |
10140 |
|
) |
10141 |
|
); |
10142 |
|
|
10143 |
|
// Récupération de l'instance de notification |
10144 |
|
$instNotif = $this->f->get_inst__om_dbform(array( |
10145 |
|
"obj" => "instruction_notification", |
10146 |
|
"idx" => $qres['result'], |
10147 |
|
)); |
10148 |
|
return $instNotif; |
10149 |
|
} |
10150 |
|
|
10151 |
|
|
10152 |
|
/** |
10153 |
|
* Affiche la page de téléchargement du document de la notification. |
10154 |
|
* |
10155 |
|
* @param boolean $content_only Affiche le contenu seulement. |
10156 |
|
* |
10157 |
|
* @return void |
10158 |
|
*/ |
10159 |
|
public function view_telecharger_document_anonym() { |
10160 |
|
// Par défaut on considère qu'on va afficher le formulaire |
10161 |
|
$idx = 0; |
10162 |
|
// Flag d'erreur |
10163 |
|
$error = false; |
10164 |
|
// Message d'erreur |
10165 |
|
$message = ''; |
10166 |
|
|
10167 |
|
// Paramètres GET : récupération de la clé d'accès |
10168 |
|
$cle_acces_document = $this->f->get_submitted_get_value('key'); |
10169 |
|
$cle_acces_document = $this->f->db->escapeSimple($cle_acces_document); |
10170 |
|
// Vérification de l'existence de la clé et récupération de l'uid du fichier |
10171 |
|
$uidFichier = $this->getUidDocumentInstructionWithKey($cle_acces_document); |
10172 |
|
if ($uidFichier != null) { |
10173 |
|
// Récupération du document |
10174 |
|
$file = $this->f->storage->get($uidFichier); |
10175 |
|
|
10176 |
|
// Headers |
10177 |
|
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 |
10178 |
|
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date dans le passé |
10179 |
|
header("Content-Type: ".$file['metadata']['mimetype']); |
10180 |
|
header("Accept-Ranges: bytes"); |
10181 |
|
header("Content-Disposition: inline; filename=\"".$file['metadata']['filename']."\";" ); |
10182 |
|
// Affichage du document |
10183 |
|
echo $file['file_content']; |
10184 |
|
|
10185 |
|
// Récupération de la date de premier accès et maj du suivi uniquement |
10186 |
|
// si la date de 1er accès n'a pas encore été remplis |
10187 |
|
$inst_notif = $this->getInstanceNotificationWithKey($cle_acces_document); |
10188 |
|
if ($inst_notif->getVal('date_premier_acces') == null || |
10189 |
|
$inst_notif->getVal('date_premier_acces') == '') { |
10190 |
|
$notif_val = array(); |
10191 |
|
foreach ($inst_notif->champs as $champ) { |
10192 |
|
$notif_val[$champ] = $inst_notif->getVal($champ); |
10193 |
|
} |
10194 |
|
$notif_val['date_premier_acces'] = date("d/m/Y H:i:s"); |
10195 |
|
$notif_val['statut'] = 'vu'; |
10196 |
|
$notif_val['commentaire'] = 'Le document a été vu'; |
10197 |
|
$suivi_notif = $inst_notif->modifier($notif_val); |
10198 |
|
} |
10199 |
|
|
10200 |
|
} else { |
10201 |
|
// Page vide 404 |
10202 |
|
printf('Ressource inexistante'); |
10203 |
|
header('HTTP/1.0 404 Not Found'); |
10204 |
|
} |
10205 |
|
} |
10206 |
|
|
10207 |
|
/** |
10208 |
|
* Récupère le titre du document envoyé au parapheur |
10209 |
|
*/ |
10210 |
|
protected function getDocumentTitre($champ = null) { |
10211 |
|
$title = $this->getTitle(); |
10212 |
|
$dossier = $this->getDossier(); |
10213 |
|
return $dossier.' '.$title; |
10214 |
|
} |
10215 |
|
|
10216 |
?> |
/** |
10217 |
|
* Compose le nom du document à transmettre au parapheur. |
10218 |
|
* Le nom ets composé de cette manière : |
10219 |
|
* instruction_xxx_libelle_de_la_lettre_type_associee |
10220 |
|
* ou xxx correspond au numéro de l'instruction |
10221 |
|
*/ |
10222 |
|
protected function getDocumentLibelle() { |
10223 |
|
// Récupère le champ instruction |
10224 |
|
$instruction = $this->getVal("instruction"); |
10225 |
|
|
10226 |
|
// Requête sql servant à récupérer le titre du document |
10227 |
|
// TO_CHAR() introduit un espace avant l'affichage du nombre |
10228 |
|
// comme les espaces sont remplacé par des '_' dans le retour de la fonction |
10229 |
|
// il n'est pas nécessaire de mettre un '_' après le mot instruction. |
10230 |
|
$documentLibelle = $this->f->get_one_result_from_db_query( |
10231 |
|
sprintf( |
10232 |
|
'SELECT |
10233 |
|
CONCAT( |
10234 |
|
\'instruction\', |
10235 |
|
TO_CHAR(instruction.instruction, \'000\'), |
10236 |
|
\'_\', |
10237 |
|
LOWER(om_lettretype.libelle) |
10238 |
|
) AS nom_fichier |
10239 |
|
FROM |
10240 |
|
%1$sinstruction |
10241 |
|
LEFT JOIN %1$som_lettretype |
10242 |
|
ON om_lettretype.id = instruction.lettretype |
10243 |
|
WHERE |
10244 |
|
instruction = %2$d', |
10245 |
|
DB_PREFIXE, |
10246 |
|
intval($instruction) |
10247 |
|
), |
10248 |
|
array( |
10249 |
|
"origin" => __METHOD__, |
10250 |
|
) |
10251 |
|
); |
10252 |
|
|
10253 |
|
$documentLibelle = $documentLibelle['result']; |
10254 |
|
|
10255 |
|
// Transforamtion des ' ' en '_', des accents en lettres sans accents et des |
10256 |
|
// caractères spéciaux en '_' |
10257 |
|
// La méthode normalize_string est utilisé pour gérer les accents |
10258 |
|
$documentLibelle = $this->f->normalize_string($documentLibelle); |
10259 |
|
// TODO : comparer cette liste et celle de la méthode normalize_string |
10260 |
|
// pour éviter les doublons + vérifier qu'il n'y a pas de doublons dans cette |
10261 |
|
// liste |
10262 |
|
$invalid = array('Œ'=>'oe', 'œ'=>'oe', 'Ÿ'=>'y', 'ü'=>'u', |
10263 |
|
'¢' => '_', 'ß' => '_', '¥' => '_', '£' => '_', '™' => '_', '©' => '_', |
10264 |
|
'®' => '_', 'ª' => '_', '×' => '_', '÷' => '_', '±' => '_', '²' => '_', |
10265 |
|
'³' => '_', '¼' => '_', '½' => '_', '¾' => '_', 'µ' => '_', '¿' => '_', |
10266 |
|
'¶' => '_', '·' => '_', '¸' => '_', 'º' => '_', '°' => '_', '¯' => '_', |
10267 |
|
'§' => '_', '…' => '_', '¤' => '_', '¦' => '_', '≠' => '_', '¬' => '_', |
10268 |
|
'ˆ' => '_', '¨' => '_', '‰' => '_', '¤' => '_', '€' => '_', '$' => '_', |
10269 |
|
'«' => '_', '»' => '_', '‹' => '_', '›' => '_', 'ƒ' => '_', '¥' => '_', |
10270 |
|
'‘‘' => '_', '‚' => '_', '!' => '_', '¡' => '_', '¢' => '_', '£' => '_', |
10271 |
|
'?' => '_', '[' => '_', ']' => '_', '´' => '_', '`' => '_', '^' => '_', |
10272 |
|
'~' => '_', '˜' => '_', '#' => '_', '*' => '_', '.' => '_', ':' => '_', |
10273 |
|
';' => '_', '•' => '_', '¯' => '_', '‾' => '_', '–' => '_', '–' => '_', |
10274 |
|
'—' => '_', '_' => '_', '|' => '_', '¦' => '_', '‡' => '_', '§' => '_', |
10275 |
|
'¶' => '_', '©' => '_', '®' => '_', '™' => '_', '&' => '_', '@' => '_', |
10276 |
|
'/' => '_', '\\' => '_', '◊' => '_', '♠' => '_', '♣' => '_', '♥' => '_', |
10277 |
|
'♦' => '_', '←' => '_', '↑' => '_', '→' => '_', '↓' => '_', '↔' => '_', |
10278 |
|
'°' => '_', 'µ' => '_', '<' => '_', '>' => '_', '≤' => '_', '≥' => '_', |
10279 |
|
'=' => '_', '≈' => '_', '≠' => '_', '≡' => '_', '±' => '_', '−' => '_', |
10280 |
|
'+' => '_', '×' => '_', '÷' => '_', '⁄' => '_', '%' => '_', '‰' => '_', |
10281 |
|
'¼' => '_', '½' => '_', '¾' => '_', '¹' => '_', '²' => '_', '³' => '_', |
10282 |
|
'' => '_', 'º' => '_', 'ª' => '_', 'ƒ' => '_', '′' => '_', '″' => '_', |
10283 |
|
'∂' => '_', '∏' => '_', '∑' => '_', '√' => '_', '∞' => '_', '¬' => '_', |
10284 |
|
'∩' => '_', '∫' => '_', 'α' => '_', 'Α' => '_', 'β' => '_', 'Β' => '_', |
10285 |
|
'γ' => '_', 'Γ' => '_', 'δ' => '_', 'Δ' => '_', 'ε' => '_', 'Ε' => '_', |
10286 |
|
'ζ' => '_', 'Ζ' => '_', 'η' => '_', 'Η' => '_', 'θ' => '_', 'Θ' => '_', |
10287 |
|
'ι' => '_', 'Ι' => '_', 'κ' => '_', 'Κ' => '_', 'λ' => '_', 'Λ' => '_', |
10288 |
|
'μ' => '_', 'Μ' => '_', 'ν' => '_', 'Ν' => '_', 'ξ' => '_', 'Ξ' => '_', |
10289 |
|
'ο' => '_', 'Ο' => '_', 'π' => '_', 'Π' => '_', 'ρ' => '_', 'Ρ' => '_', |
10290 |
|
'σ' => '_', 'ς' => '_', 'Σ' => '_', 'τ' => '_', 'Τ' => '_', 'υ' => '_', |
10291 |
|
'Υ' => '_', 'φ' => '_', 'Φ' => '_', 'χ' => '_', 'Χ' => '_', 'ψ' => '_', |
10292 |
|
'Ψ' => '_', 'ω' => '_', 'Ω' => '_', ',' => '_', ' ' => '_' |
10293 |
|
); |
10294 |
|
|
10295 |
|
return str_replace(array_keys($invalid), array_values($invalid), $documentLibelle); |
10296 |
|
} |
10297 |
|
|
10298 |
|
/** |
10299 |
|
* Surcharge permettant de ne pas afficher le fil d'Ariane dans |
10300 |
|
* l'overlay de notification des demandeurs. |
10301 |
|
*/ |
10302 |
|
function getSubFormTitle($ent) { |
10303 |
|
$actionSansPath = array('411', '420', '430'); |
10304 |
|
if (in_array($this->getParameter('maj'), $actionSansPath)) { |
10305 |
|
return ''; |
10306 |
|
} |
10307 |
|
return parent::getSubFormTitle($ent); |
10308 |
|
} |
10309 |
|
|
10310 |
|
/** |
10311 |
|
* Traitement de la notification automatique des tiers consulté. |
10312 |
|
* |
10313 |
|
* Récupère la liste des adresses mails des tiers notifiables. Pour chaque adresses |
10314 |
|
* récupérées ajoute une notification et une tâche de notification par mail. |
10315 |
|
* La création de la tâche de notification par mail déclenchera l'envoi du mail |
10316 |
|
* et la mise à jour du suivi. |
10317 |
|
* |
10318 |
|
* Les tiers notifiables sont ceux : |
10319 |
|
* - n’ayant pas un ID PLAT’AU correspondant à l’ID PLAT’AU du service consultant |
10320 |
|
* - ayant une habilitation dont le type est listé dans les paramètres de |
10321 |
|
* notification de l’événement, |
10322 |
|
* - intervenant sur la commune ou le département du dossier |
10323 |
|
* - ayant au moins une adresse mail valide |
10324 |
|
* |
10325 |
|
* @param evenement instance de l'événement associée à l'instruction |
10326 |
|
* @param dossier instance du dossier de l'instruction |
10327 |
|
* @return boolean indique si le traitement à réussi |
10328 |
|
*/ |
10329 |
|
protected function traitement_notification_automatique_tiers_consulte($evenement, $dossier) { |
10330 |
|
// Récupération de l'identifiant plat'au du service consultant |
10331 |
|
$consultationEntrante = $dossier->get_inst_consultation_entrante(); |
10332 |
|
// Récupération de la liste des types d'habilitations autorisées pour |
10333 |
|
// cette notification |
10334 |
|
$typesHabilitationsNotifiable = $evenement->get_types_habilitation_notifiable(); |
10335 |
|
// Récupération du département et de la commune du dossier |
10336 |
|
$commune = $dossier->getVal('commune'); |
10337 |
|
// Le département est récupéré à partir de la commune du dossier donc si la |
10338 |
|
// commune n'a pas pu être récupéré on ne récupère pas non plus le département. |
10339 |
|
$idDepartement = null; |
10340 |
|
if (! empty($commune)) { |
10341 |
|
$departement = $dossier->get_inst_departement_dossier(); |
10342 |
|
$idDepartement = $departement->getVal($departement->clePrimaire); |
10343 |
|
} |
10344 |
|
// Récupération des courriels des tiers notifiables |
10345 |
|
$tiersANotifier = $this->get_courriels_tiers_notifiable( |
10346 |
|
$typesHabilitationsNotifiable, |
10347 |
|
$consultationEntrante->getVal('service_consultant_id'), |
10348 |
|
$commune, |
10349 |
|
$idDepartement |
10350 |
|
); |
10351 |
|
// Traitement de chacune des listes de diffusion pour extraire les |
10352 |
|
// courriels, vérifier la validité des courriels et envoyer la |
10353 |
|
// notification |
10354 |
|
$notificationSend = false; |
10355 |
|
if (empty($tiersANotifier)) { |
10356 |
|
$this->addToLog( |
10357 |
|
sprintf( |
10358 |
|
'%s() : %s %s : ', |
10359 |
|
__METHOD__, |
10360 |
|
__("La récupération des tiers à échoué."), |
10361 |
|
__('Paramétrage'), |
10362 |
|
var_export( |
10363 |
|
array( |
10364 |
|
'types_habilitations_notifiable' => $typesHabilitationsNotifiable, |
10365 |
|
'service_consultant' => $consultationEntrante->getVal('service_consultant_id'), |
10366 |
|
'id_commune' => $commune, |
10367 |
|
'id_departement' => $idDepartement |
10368 |
|
), |
10369 |
|
true |
10370 |
|
) |
10371 |
|
), |
10372 |
|
DEBUG_MODE |
10373 |
|
); |
10374 |
|
return false; |
10375 |
|
} |
10376 |
|
foreach($tiersANotifier as $tierANotifier) { |
10377 |
|
// Découpe la liste de diffusion pour stocker les adresses mails |
10378 |
|
// des tiers dans un tableau |
10379 |
|
$courriels = |
10380 |
|
array_filter( |
10381 |
|
array_map( |
10382 |
|
'trim', |
10383 |
|
preg_split("/\r\n|\n|\r/", $tierANotifier['liste_diffusion']))); |
10384 |
|
|
10385 |
|
foreach ($courriels as $courriel) { |
10386 |
|
// Pour chaque adresse mail vérifie si l'adresse est valide |
10387 |
|
if (! $this->f->checkValidEmailAddress($courriel)) { |
10388 |
|
continue; |
10389 |
|
} |
10390 |
|
$destinataire = array( |
10391 |
|
'destinataire' => $tierANotifier['libelle'].' : '.$courriel, |
10392 |
|
'courriel' => $courriel |
10393 |
|
); |
10394 |
|
// Si l'adresse est valide ajoute une nouvelle notification |
10395 |
|
// et une tâche d'envoi de mails |
10396 |
|
$idNotif = $this->ajouter_notification( |
10397 |
|
$this->getVal($this->clePrimaire), |
10398 |
|
$this->f->get_connected_user_login_name(), |
10399 |
|
$destinataire, |
10400 |
|
$this->get_dossier_instruction_om_collectivite(), |
10401 |
|
array(), |
10402 |
|
true |
10403 |
|
); |
10404 |
|
if ($idNotif === false) { |
10405 |
|
$this->addToLog( |
10406 |
|
__METHOD__. |
10407 |
|
__("L'ajout de la notification a échoué."), |
10408 |
|
DEBUG_MODE |
10409 |
|
); |
10410 |
|
return false; |
10411 |
|
} |
10412 |
|
// Création de la tache en lui donnant l'id de la notification |
10413 |
|
$notification_by_task = $this->notification_by_task( |
10414 |
|
$idNotif, |
10415 |
|
$dossier->getVal('dossier'), |
10416 |
|
'mail', |
10417 |
|
'notification_tiers_consulte' |
10418 |
|
); |
10419 |
|
if ($notification_by_task === false) { |
10420 |
|
$this->addToLog( |
10421 |
|
__METHOD__. |
10422 |
|
__("L'ajout de la tâche de notification a échoué."), |
10423 |
|
DEBUG_MODE |
10424 |
|
); |
10425 |
|
$this->addToMessage( |
10426 |
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
10427 |
|
); |
10428 |
|
return false; |
10429 |
|
} |
10430 |
|
$notificationSend = true; |
10431 |
|
} |
10432 |
|
} |
10433 |
|
// Si aucune notification n'a été envoyé car il n'y a pas de courriels |
10434 |
|
// valide, affiche un message dans les logs pour avoir un suivi. |
10435 |
|
if (! $notificationSend) { |
10436 |
|
$this->addToLog( |
10437 |
|
sprintf( |
10438 |
|
'%s %s : %s %s : %s', |
10439 |
|
__METHOD__, |
10440 |
|
__("Il n'y a pas de tiers notifiable pour l'instruction"), |
10441 |
|
$evenement->getVal('libelle'), |
10442 |
|
__("du dossier"), |
10443 |
|
$this->getVal('dossier') |
10444 |
|
), |
10445 |
|
DEBUG_MODE |
10446 |
|
); |
10447 |
|
} |
10448 |
|
return true; |
10449 |
|
} |
10450 |
|
|
10451 |
|
/** |
10452 |
|
* Récupère, à l'aide d'une requête, la liste de diffusion des tiers |
10453 |
|
* respectant les conditions suvantes : |
10454 |
|
* - le tiers consulté dois accepté les notifications |
10455 |
|
* - la liste de diffusion ne dois pas être vide |
10456 |
|
* - l'uid du tiers consulté ne dois pas être celui passé en paramètre |
10457 |
|
* si pas d'uid passé en paramètre alors on ne filtre pas selon l'uid |
10458 |
|
* du tiers |
10459 |
|
* - le type d'habilitation des tiers dois appartenir à la liste |
10460 |
|
* fournie en paramètre |
10461 |
|
* - le tiers dois être associé à la commune ou au département passé |
10462 |
|
* en paramètre |
10463 |
|
* |
10464 |
|
* @param array $typesHabilitations tableau contenant la liste des types d'habilitation |
10465 |
|
* pouvant être notifiée |
10466 |
|
* @param integer $idPlautau uid de l'acteur plat'au du dossier qui ne dois pas être notifié |
10467 |
|
* @param integer $commune identifiant de la commune du dossier |
10468 |
|
* @param integer $departement identifiant du département du dossier |
10469 |
|
* |
10470 |
|
* @return array listes de diffusion des tiers notifiable |
10471 |
|
*/ |
10472 |
|
protected function get_courriels_tiers_notifiable(array $typesHabilitations, $idPlatau, $commune, $departement) { |
10473 |
|
// Si paramètre non renseigné alors ne renvoie rien |
10474 |
|
if (empty($typesHabilitations) || empty($commune) || empty($departement)) { |
10475 |
|
return false; |
10476 |
|
} |
10477 |
|
// Si il n'y a pas d'acteur associé au dossier alors on ne filtre pas sur l'uid de l'acteur |
10478 |
|
$filtreServiceConsulteDI = ''; |
10479 |
|
if (! empty($idPlatau)) { |
10480 |
|
$filtreServiceConsulteDI = sprintf( |
10481 |
|
"-- Filtre les tiers ayant une ligne correspondante a l uid platau du service |
10482 |
|
-- en charge du dossier |
10483 |
|
AND (tiers_consulte.uid_platau_acteur !~ ('\y' || '%s' || '\y') |
10484 |
|
OR tiers_consulte.uid_platau_acteur IS NULL)", |
10485 |
|
$this->f->db->escapeSimple($idPlatau) |
10486 |
|
); |
10487 |
|
} |
10488 |
|
$rst = $this->f->get_all_results_from_db_query( |
10489 |
|
sprintf( |
10490 |
|
'SELECT |
10491 |
|
-- Tiers notifiables lié à la commune du dossier |
10492 |
|
tiers_consulte.liste_diffusion, |
10493 |
|
tiers_consulte.libelle |
10494 |
|
FROM |
10495 |
|
%1$shabilitation_tiers_consulte |
10496 |
|
LEFT JOIN %1$stiers_consulte |
10497 |
|
ON habilitation_tiers_consulte.tiers_consulte = tiers_consulte.tiers_consulte |
10498 |
|
LEFT JOIN %1$slien_habilitation_tiers_consulte_commune |
10499 |
|
ON habilitation_tiers_consulte.habilitation_tiers_consulte = lien_habilitation_tiers_consulte_commune.habilitation_tiers_consulte |
10500 |
|
-- Conservation uniquement des tiers acteur de dossiers |
10501 |
|
JOIN %1$slien_dossier_tiers |
10502 |
|
ON tiers_consulte.tiers_consulte = lien_dossier_tiers.tiers |
10503 |
|
WHERE |
10504 |
|
tiers_consulte.accepte_notification_email IS TRUE |
10505 |
|
AND tiers_consulte.liste_diffusion IS NOT NULL |
10506 |
|
%3$s |
10507 |
|
AND habilitation_tiers_consulte.type_habilitation_tiers_consulte IN (%2$s) |
10508 |
|
AND lien_habilitation_tiers_consulte_commune.commune = %4$d |
10509 |
|
-- Filtre sur les tiers acteur du dossier |
10510 |
|
AND lien_dossier_tiers.dossier = \'%6$s\' |
10511 |
|
UNION |
10512 |
|
SELECT |
10513 |
|
-- Tiers notifiables lié au département du dossier |
10514 |
|
tiers_consulte.liste_diffusion, |
10515 |
|
tiers_consulte.libelle |
10516 |
|
FROM |
10517 |
|
%1$shabilitation_tiers_consulte |
10518 |
|
LEFT JOIN %1$stiers_consulte |
10519 |
|
ON habilitation_tiers_consulte.tiers_consulte = tiers_consulte.tiers_consulte |
10520 |
|
LEFT JOIN %1$slien_habilitation_tiers_consulte_departement |
10521 |
|
ON habilitation_tiers_consulte.habilitation_tiers_consulte = lien_habilitation_tiers_consulte_departement.habilitation_tiers_consulte |
10522 |
|
-- Conservation uniquement des tiers acteur de dossiers |
10523 |
|
JOIN %1$slien_dossier_tiers |
10524 |
|
ON tiers_consulte.tiers_consulte = lien_dossier_tiers.tiers |
10525 |
|
WHERE |
10526 |
|
tiers_consulte.accepte_notification_email IS TRUE |
10527 |
|
AND tiers_consulte.liste_diffusion IS NOT NULL |
10528 |
|
%3$s |
10529 |
|
AND habilitation_tiers_consulte.type_habilitation_tiers_consulte IN (%2$s) |
10530 |
|
AND lien_habilitation_tiers_consulte_departement.departement = %5$d |
10531 |
|
-- Filtre sur les tiers acteur du dossier |
10532 |
|
AND lien_dossier_tiers.dossier = \'%6$s\'', |
10533 |
|
DB_PREFIXE, |
10534 |
|
implode(', ', $typesHabilitations), |
10535 |
|
$filtreServiceConsulteDI, |
10536 |
|
intval($commune), |
10537 |
|
intval($departement), |
10538 |
|
$this->f->db->escapeSimple($this->getVal('dossier')) |
10539 |
|
), |
10540 |
|
array( |
10541 |
|
"origin" => __METHOD__ |
10542 |
|
) |
10543 |
|
); |
10544 |
|
// Faire un order by sur un union ne fonctionne pas. A la place |
10545 |
|
// c'est le tableau des résultats qui est ordonné. |
10546 |
|
usort($rst['result'], function($a, $b) { |
10547 |
|
return strcmp($a['libelle'], $b['libelle']); |
10548 |
|
}); |
10549 |
|
return $rst['result']; |
10550 |
|
} |
10551 |
|
} |