1 |
<?php |
<?php |
2 |
/** |
/** |
|
* |
|
|
* |
|
3 |
* specific : |
* specific : |
4 |
* - cle secondaire |
* - cle secondaire |
5 |
* destruction autorisée que pour le dernier evenement |
* destruction autorisée que pour le dernier evenement |
6 |
* [delete the last event ] |
* [delete the last event ] |
7 |
* - variable globale [global variables] |
* - variable globale [global variables] |
|
* var $archive_date_depot; |
|
8 |
* var $retourformulaire; |
* var $retourformulaire; |
9 |
* var $idxformulaire; |
* var $idxformulaire; |
10 |
* - modification des données dans dossier trigger avant |
* - modification des données dans dossier trigger avant |
31 |
"om_fichier_instruction" => "file", |
"om_fichier_instruction" => "file", |
32 |
); |
); |
33 |
|
|
|
var $archive_date_depot; // specific |
|
34 |
var $retourformulaire; // specific |
var $retourformulaire; // specific |
35 |
var $idxformulaire; // specific |
var $idxformulaire; // specific |
36 |
var $valEvenement; |
var $valEvenement; |
38 |
// Tableau contenant une partie des métadonnées arrêtés |
// Tableau contenant une partie des métadonnées arrêtés |
39 |
var $metadonneesArrete; |
var $metadonneesArrete; |
40 |
|
|
41 |
|
/** |
42 |
|
* Instance de la classe dossier |
43 |
|
* |
44 |
|
* @var mixed |
45 |
|
*/ |
46 |
|
var $inst_dossier = null; |
47 |
|
|
48 |
var $metadata = array( |
var $metadata = array( |
49 |
"om_fichier_instruction" => array( |
"om_fichier_instruction" => array( |
50 |
"dossier" => "getDossier", |
"dossier" => "getDossier", |
369 |
$form->setType('archive_date_conformite', 'hiddendate'); |
$form->setType('archive_date_conformite', 'hiddendate'); |
370 |
$form->setType('archive_date_chantier', 'hiddendate'); |
$form->setType('archive_date_chantier', 'hiddendate'); |
371 |
$form->setType('archive_autorite_competente','hidden'); |
$form->setType('archive_autorite_competente','hidden'); |
372 |
|
$form->setType('date_depot','hidden'); |
373 |
// |
// |
374 |
$form->setType('numero_arrete', 'hidden'); |
$form->setType('numero_arrete', 'hidden'); |
375 |
// |
// |
447 |
$form->setType('date_finalisation_courrier', 'date'); |
$form->setType('date_finalisation_courrier', 'date'); |
448 |
// suivi des dates |
// suivi des dates |
449 |
if ($maj == 125) { |
if ($maj == 125) { |
450 |
|
$form->setType('date_evenement', 'hiddenstaticdate'); |
451 |
$form->setType('complement_om_html', 'hiddenstatic'); |
$form->setType('complement_om_html', 'hiddenstatic'); |
452 |
$form->setType('complement2_om_html', 'hiddenstatic'); |
$form->setType('complement2_om_html', 'hiddenstatic'); |
453 |
$form->setType('complement3_om_html', 'hiddenstatic'); |
$form->setType('complement3_om_html', 'hiddenstatic'); |
908 |
* - date_chantier |
* - date_chantier |
909 |
* - date_conformite |
* - date_conformite |
910 |
* - avis_decision |
* - avis_decision |
|
* Il permet également de stocker la date_depot du dossier d'instruction |
|
|
* dans l'attribut $this->archive_date_depot de la classe. |
|
911 |
*/ |
*/ |
912 |
// 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é |
913 |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
961 |
} |
} |
962 |
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
963 |
$this->updateArchiveData($row); |
$this->updateArchiveData($row); |
|
$this->archive_date_depot = $row['date_depot']; |
|
964 |
|
|
965 |
// Récupération de la duree de validite du dossier d'autorisation |
// Récupération de la duree de validite du dossier d'autorisation |
966 |
$sql = "SELECT duree_validite_parametrage |
$sql = "SELECT duree_validite_parametrage |
994 |
$this->restriction_valid = true; |
$this->restriction_valid = true; |
995 |
return $this->restriction_valid; |
return $this->restriction_valid; |
996 |
} |
} |
997 |
// Liste des opérateurs possible |
// Liste des opérateurs possibles sans espace |
998 |
$operateurs = array(">=", "<=", "+", "-"); |
$operateurs = array(">=", "<=", "+", "-", "&&", "||", "==", "!="); |
999 |
// Liste des opérateurs avec espace |
// Liste identique mais avec le marqueur § |
1000 |
$operateurs_blank = array(" >= ", " <= ", " + ", " - "); |
$mark = "§"; |
1001 |
|
$operateurs_marked = array(); |
1002 |
|
foreach ($operateurs as $operateur) { |
1003 |
|
$operateurs_marked[] = $mark.$operateur.$mark; |
1004 |
|
} |
1005 |
|
|
1006 |
// Supprime tous les espaces de la chaîne de caractère |
// Supprime tous les espaces de la chaîne de caractère |
1007 |
$restriction = str_replace(' ', '', $restriction); |
$restriction = preg_replace('/\s+/', '', $restriction); |
1008 |
|
|
1009 |
// Met des espace avant et après les opérateurs puis transforme la |
// Met un marqueur avant et après les opérateurs |
1010 |
// chaine en un tableau |
// puis transforme la chaine en un tableau |
1011 |
$tabRestriction = str_replace($operateurs, $operateurs_blank, |
$restriction = str_replace($operateurs, $operateurs_marked, |
1012 |
$restriction); |
$restriction); |
|
$tabRestriction = explode(" ", $tabRestriction); |
|
1013 |
|
|
1014 |
|
// Pour chaque opérateur logique |
1015 |
|
foreach (array('&&', '||') as $operator) { |
1016 |
|
|
1017 |
|
// S'il est absent on ne fait aucun traitement |
1018 |
|
if (strpos($restriction, $mark.$operator.$mark) === false) { |
1019 |
|
continue; |
1020 |
|
} |
1021 |
|
// Sinon on vérifie les deux conditions avec le OU/ET logique |
1022 |
|
$restrictions = explode($mark.$operator.$mark, $restriction); |
1023 |
|
$restrictions[0] = explode($mark, $restrictions[0]); |
1024 |
|
$restrictions[1] = explode($mark, $restrictions[1]); |
1025 |
|
$res_bool = false; |
1026 |
|
if ($operator == '&&') { |
1027 |
|
if ($this->is_restriction_satisfied($restrictions[0], $operateurs) |
1028 |
|
&& $this->is_restriction_satisfied($restrictions[1], $operateurs)) { |
1029 |
|
$res_bool = true; |
1030 |
|
} |
1031 |
|
} |
1032 |
|
if ($operator == '||') { |
1033 |
|
if ($this->is_restriction_satisfied($restrictions[0], $operateurs) |
1034 |
|
|| $this->is_restriction_satisfied($restrictions[1], $operateurs)) { |
1035 |
|
$res_bool = true; |
1036 |
|
} |
1037 |
|
} |
1038 |
|
return $res_bool; |
1039 |
|
} |
1040 |
|
$tabRestriction = explode($mark, $restriction); |
1041 |
|
return $this->is_restriction_satisfied($tabRestriction, $operateurs); |
1042 |
|
|
1043 |
|
} |
1044 |
|
|
1045 |
|
function is_restriction_satisfied($restriction, $operateurs) { |
1046 |
// Tableau comprenant les résultat |
// Tableau comprenant les résultat |
1047 |
$res = array(); |
$res = array(); |
1048 |
// Compteur pour les résultat |
// Compteur pour les résultat |
1054 |
$res_bool = true; |
$res_bool = true; |
1055 |
|
|
1056 |
// S'il y a un comparateur |
// S'il y a un comparateur |
1057 |
if (in_array(">=", $tabRestriction) |
if (in_array(">=", $restriction) |
1058 |
|| in_array("<=", $tabRestriction)) { |
|| in_array("<=", $restriction) |
1059 |
|
|| in_array("==", $restriction) |
1060 |
|
|| in_array("!=", $restriction)) { |
1061 |
|
|
1062 |
// Si le tableau n'est pas vide |
// Si le tableau n'est pas vide |
1063 |
if (count($tabRestriction) > 0) { |
if (count($restriction) > 0) { |
1064 |
|
|
1065 |
// Boucle dans le tableau pour récupérer seulement les valeurs |
// Boucle dans le tableau pour récupérer seulement les valeurs |
1066 |
foreach ($tabRestriction as $key => $value) { |
foreach ($restriction as $key => $value) { |
|
|
|
1067 |
// |
// |
1068 |
if (!in_array($value, $operateurs)) { |
if (!in_array($value, $operateurs)) { |
1069 |
if ($this->getRestrictionValue($value) != false) { |
if ($this->getRestrictionValue($value) != false) { |
1081 |
// Boucle dans le tableau |
// Boucle dans le tableau |
1082 |
// commence à 1 car le 0 doit rester inchangé tout au long du |
// commence à 1 car le 0 doit rester inchangé tout au long du |
1083 |
// traitement |
// traitement |
1084 |
for ($i = 1; $i<count($tabRestriction); $i++) { |
for ($i = 1; $i<count($restriction); $i++) { |
1085 |
|
|
1086 |
// Récupère le comparateur |
// Récupère le comparateur |
1087 |
if ($tabRestriction[$i] === ">=" |
if ($restriction[$i] === ">=" |
1088 |
|| $tabRestriction[$i] === "<=") { |
|| $restriction[$i] === "<=" |
1089 |
$comparateur = $tabRestriction[$i]; |
|| $restriction[$i] === "==" |
1090 |
|
|| $restriction[$i] === "!=") { |
1091 |
|
$comparateur = $restriction[$i]; |
1092 |
} |
} |
1093 |
|
|
1094 |
// Si l'opérateur qui suit est un "+" |
// Si l'opérateur qui suit est un "+" |
1095 |
if ($tabRestriction[$i] === "+") { |
if ($restriction[$i] === "+") { |
1096 |
$dateDep = $res[$j]; |
$dateDep = $res[$j]; |
1097 |
unset($res[$j]);$j++; |
unset($res[$j]);$j++; |
1098 |
$duree = $res[$j]; |
$duree = $res[$j]; |
1101 |
} |
} |
1102 |
|
|
1103 |
// Si l'opérateur qui suit est un "-" |
// Si l'opérateur qui suit est un "-" |
1104 |
if ($tabRestriction[$i] === "-") { |
if ($restriction[$i] === "-") { |
1105 |
$dateDep = $res[$j]; |
$dateDep = $res[$j]; |
1106 |
unset($res[$j]);$j++; |
unset($res[$j]);$j++; |
1107 |
$duree = $res[$j]; |
$duree = $res[$j]; |
1124 |
} |
} |
1125 |
} |
} |
1126 |
if ($comparateur === "<=") { |
if ($comparateur === "<=") { |
1127 |
|
// |
1128 |
if (strtotime($res[0]) <= strtotime($res[$j])) { |
if (strtotime($res[0]) <= strtotime($res[$j])) { |
1129 |
$res_bool = true; |
$res_bool = true; |
1130 |
} |
} |
1131 |
} |
} |
1132 |
|
if ($comparateur === "==") { |
1133 |
|
// |
1134 |
|
if (strtotime($res[0]) == strtotime($res[$j])) { |
1135 |
|
$res_bool = true; |
1136 |
|
} |
1137 |
|
} |
1138 |
|
if ($comparateur === "!=") { |
1139 |
|
// |
1140 |
|
if (strtotime($res[0]) != strtotime($res[$j])) { |
1141 |
|
$res_bool = true; |
1142 |
|
} |
1143 |
|
} |
1144 |
} |
} |
1145 |
// Sinon une erreur s'affiche |
// Sinon une erreur s'affiche |
1146 |
} else { |
} else { |
1575 |
$this->correct = false; |
$this->correct = false; |
1576 |
return false; |
return false; |
1577 |
} |
} |
1578 |
} |
return $this->add_log_to_dossier($id, array_merge($val, $this->valF)); |
1579 |
|
} |
1580 |
|
|
1581 |
function triggermodifierapres($id,&$db,$val,$DEBUG) { |
function triggermodifierapres($id,&$db,$val,$DEBUG) { |
1582 |
/** |
/** |
1663 |
if (database::isError($res)) { |
if (database::isError($res)) { |
1664 |
die($res->getMessage()); |
die($res->getMessage()); |
1665 |
} |
} |
1666 |
|
$current_id = $this->getVal($this->clePrimaire); |
1667 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
1668 |
// 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 |
1669 |
if ($this->getVal('date_retour_signature') == "" AND |
if ($this->getVal('date_retour_signature') == "" AND |
1685 |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
1686 |
$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']); |
1687 |
$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']); |
1688 |
|
$new_instruction->setParameter("maj", 0); |
1689 |
|
$new_instruction->class_actions[0]["identifier"] = |
1690 |
|
"retour signature de l'instruction $current_id"; |
1691 |
$retour = $new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
$retour = $new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
1692 |
|
|
1693 |
//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 |
1727 |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
1728 |
$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']); |
1729 |
$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']); |
1730 |
$new_instruction->setParameter("maj", $this->getParameter("maj")); |
$new_instruction->setParameter("maj", 0); |
1731 |
|
$new_instruction->class_actions[0]["identifier"] = |
1732 |
|
"retour RAR de l'instruction $current_id"; |
1733 |
$retour = $new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
$retour = $new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
1734 |
|
|
1735 |
//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 |
1877 |
$this->correct = false; |
$this->correct = false; |
1878 |
return false; |
return false; |
1879 |
} |
} |
1880 |
|
return $this->add_log_to_dossier($id, $val); |
1881 |
} |
} |
1882 |
|
|
1883 |
function triggersupprimer($id,&$db,$val,$DEBUG) { |
function triggersupprimer($id,&$db,$val,$DEBUG) { |
2013 |
$this->correct = false; |
$this->correct = false; |
2014 |
return false; |
return false; |
2015 |
} |
} |
2016 |
|
$val['evenement'] = $this->getVal('evenement'); |
2017 |
|
return $this->add_log_to_dossier($id, $val); |
2018 |
} |
} |
2019 |
|
|
2020 |
/** |
/** |
2086 |
} |
} |
2087 |
|
|
2088 |
// Liste des opérateurs possible |
// Liste des opérateurs possible |
2089 |
$operateurs = array(">=", "<=", "+", "-"); |
$operateurs = array(">=", "<=", "+", "-", "&&", "||", "==", "!="); |
|
|
|
2090 |
// Supprime tous les espaces de la chaîne de caractère |
// Supprime tous les espaces de la chaîne de caractère |
2091 |
$restriction = str_replace(' ', '', $restriction); |
$restriction = str_replace(' ', '', $restriction); |
2092 |
|
|
2385 |
$this->msg = ""; |
$this->msg = ""; |
2386 |
$this->addToMessage(sprintf(_("La %s du document s'est effectuee avec succes."), $etat)); |
$this->addToMessage(sprintf(_("La %s du document s'est effectuee avec succes."), $etat)); |
2387 |
|
|
2388 |
return true; |
return $this->add_log_to_dossier($id, $val); |
2389 |
} |
} |
2390 |
} else { |
} else { |
2391 |
// Message d'echec (saut d'une ligne supplementaire avant le |
// Message d'echec (saut d'une ligne supplementaire avant le |
2555 |
|
|
2556 |
//Si il y a un résultat |
//Si il y a un résultat |
2557 |
if ($row !== null) { |
if ($row !== null) { |
2558 |
|
|
2559 |
//Génération du numéro de version |
// Instrance de la classe dossier |
2560 |
$sql = "SELECT |
$inst_dossier = $this->get_inst_dossier($dossier); |
2561 |
count(*) |
|
2562 |
FROM |
// Insère l'attribut version à l'objet |
2563 |
".DB_PREFIXE."dossier |
$row->version = $inst_dossier->get_dossier_instruction_version(); |
|
LEFT JOIN |
|
|
".DB_PREFIXE."dossier_autorisation |
|
|
ON |
|
|
dossier_autorisation.dossier_autorisation = dossier.dossier_autorisation |
|
|
LEFT JOIN |
|
|
".DB_PREFIXE."dossier_instruction_type |
|
|
ON |
|
|
dossier_instruction_type.dossier_instruction_type = dossier.dossier_instruction_type |
|
|
WHERE |
|
|
dossier_autorisation.dossier_autorisation = '".$row->dossier_autorisation."' |
|
|
AND |
|
|
dossier_instruction_type.code = '".$row->dossier_instruction_type."'"; |
|
|
$row->version = $this->db->getOne($sql); |
|
|
$this->f->addToLog("getSpecificMetadata(): db->getOne(\"".$sql."\")", VERBOSE_MODE); |
|
|
if ( database::isError($row->version)){ |
|
|
$this->f->addToError("", $row->version, $row->version); |
|
|
return false; |
|
|
} |
|
|
|
|
|
//Formatage du numéro de version |
|
|
$row->version = str_pad($row->version, 2, "0", STR_PAD_LEFT); |
|
2564 |
|
|
2565 |
//Alors on créé l'objet dossier_instruction |
//Alors on créé l'objet dossier_instruction |
2566 |
$this->specificMetadata = $row; |
$this->specificMetadata = $row; |
2644 |
$return['archive_delai_incompletude']= $row['delai_incompletude']; |
$return['archive_delai_incompletude']= $row['delai_incompletude']; |
2645 |
$return['archive_autorite_competente']= $row['autorite_competente']; |
$return['archive_autorite_competente']= $row['autorite_competente']; |
2646 |
$return['duree_validite']= $row['duree_validite']; |
$return['duree_validite']= $row['duree_validite']; |
2647 |
|
$return['date_depot']= $row['date_depot']; |
2648 |
} |
} |
2649 |
|
|
2650 |
// Retour de la fonction |
// Retour de la fonction |
2757 |
if ($row['duree_validite']!='') { |
if ($row['duree_validite']!='') { |
2758 |
$this->valF['duree_validite']= $row['duree_validite']; |
$this->valF['duree_validite']= $row['duree_validite']; |
2759 |
} |
} |
2760 |
|
if ($row['date_depot']!='') { |
2761 |
|
$this->valF['date_depot']= $row['date_depot']; |
2762 |
|
} |
2763 |
} |
} |
2764 |
|
|
2765 |
// {{{ |
// {{{ |
4086 |
|
|
4087 |
//On modifie les valeurs de l'instruction |
//On modifie les valeurs de l'instruction |
4088 |
$instr->setParameter('maj', 170); |
$instr->setParameter('maj', 170); |
4089 |
|
$instr->class_actions[170]["identifier"] = |
4090 |
|
"modifier (via le menu suivi des pièces)"; |
4091 |
$retour = $instr->modifier($valF, $f->db, DEBUG); |
$retour = $instr->modifier($valF, $f->db, DEBUG); |
4092 |
|
|
4093 |
//Si une erreur s'est produite, on défait les modifications |
//Si une erreur s'est produite, on défait les modifications |
4363 |
$sql = "SELECT |
$sql = "SELECT |
4364 |
dossier.dossier_libelle, |
dossier.dossier_libelle, |
4365 |
evenement.type, |
evenement.type, |
4366 |
count(lien_dossier_demandeur) as nbdemandeur |
count(lien_dossier_demandeur) as nbdemandeur, |
4367 |
|
CASE |
4368 |
|
WHEN division.libelle IS NOT NULL AND phase.code IS NOT NULL |
4369 |
|
THEN CONCAT(phase.code, ' - ', division.libelle) |
4370 |
|
ELSE |
4371 |
|
phase.code |
4372 |
|
END AS code_phase |
4373 |
FROM ".DB_PREFIXE."instruction |
FROM ".DB_PREFIXE."instruction |
4374 |
LEFT JOIN ".DB_PREFIXE."dossier |
LEFT JOIN ".DB_PREFIXE."dossier |
4375 |
ON instruction.dossier = dossier.dossier |
ON instruction.dossier = dossier.dossier |
4376 |
|
LEFT JOIN ".DB_PREFIXE."division |
4377 |
|
ON dossier.division = division.division |
4378 |
INNER JOIN ".DB_PREFIXE."evenement ON |
INNER JOIN ".DB_PREFIXE."evenement ON |
4379 |
instruction.evenement=evenement.evenement |
instruction.evenement=evenement.evenement |
4380 |
|
LEFT JOIN ".DB_PREFIXE."phase |
4381 |
|
ON evenement.phase = phase.phase |
4382 |
inner JOIN ".DB_PREFIXE."lien_dossier_demandeur ON |
inner JOIN ".DB_PREFIXE."lien_dossier_demandeur ON |
4383 |
instruction.dossier=lien_dossier_demandeur.dossier |
instruction.dossier=lien_dossier_demandeur.dossier |
4384 |
inner join ".DB_PREFIXE."demandeur on |
inner join ".DB_PREFIXE."demandeur on |
4386 |
WHERE code_barres='".$code_barres."' |
WHERE code_barres='".$code_barres."' |
4387 |
AND ((lien_dossier_demandeur.petitionnaire_principal IS TRUE AND demandeur.type_demandeur='petitionnaire') |
AND ((lien_dossier_demandeur.petitionnaire_principal IS TRUE AND demandeur.type_demandeur='petitionnaire') |
4388 |
OR demandeur.type_demandeur='delegataire') |
OR demandeur.type_demandeur='delegataire') |
4389 |
GROUP BY dossier.dossier_libelle, evenement.type"; |
GROUP BY dossier.dossier_libelle, evenement.type, phase.code, division.libelle"; |
4390 |
|
|
4391 |
$res = $f->db->query($sql); |
$res = $f->db->query($sql); |
4392 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
4477 |
unset($adresse_dest['code_barres']); |
unset($adresse_dest['code_barres']); |
4478 |
|
|
4479 |
// Ajout d'une page aux pdf |
// Ajout d'une page aux pdf |
4480 |
$pdf_lettre_rar->addLetter($adresse_destinataire, $specifique_content); |
$pdf_lettre_rar->addLetter($adresse_destinataire, $specifique_content, $testDemandeur['code_phase']); |
4481 |
|
|
4482 |
} |
} |
4483 |
$pdf_output = $pdf_lettre_rar->output("lettre_rar".date("dmYHis").".pdf","S"); |
$pdf_output = $pdf_lettre_rar->output("lettre_rar".date("dmYHis").".pdf","S"); |
4724 |
$this->valF['created_by_commune'] = true; |
$this->valF['created_by_commune'] = true; |
4725 |
} |
} |
4726 |
} |
} |
4727 |
|
|
4728 |
|
/** |
4729 |
|
* Récupère l'instance du dossier d'instruction |
4730 |
|
* |
4731 |
|
* @param mixed Identifiant du dossier d'instruction |
4732 |
|
* |
4733 |
|
* @return object |
4734 |
|
*/ |
4735 |
|
function get_inst_dossier($dossier = null) { |
4736 |
|
// |
4737 |
|
return $this->get_inst_common("dossier", $dossier); |
4738 |
|
} |
4739 |
|
|
4740 |
|
/** |
4741 |
|
* Logue l'action de l'instruction dans son DI |
4742 |
|
* |
4743 |
|
* @param string $id clé primaire de l'instruction |
4744 |
|
* @param array $val valeurs de l'instruction |
4745 |
|
* @return bool vrai si traitement effectué avec succès |
4746 |
|
*/ |
4747 |
|
private function add_log_to_dossier($id, $val) { |
4748 |
|
$maj = $this->getParameter("maj"); |
4749 |
|
// Action = Trace par défaut |
4750 |
|
$action = $this->get_backtrace(); |
4751 |
|
// Action = Identifant de l'action si contexte connu |
4752 |
|
if (empty($maj) === false |
4753 |
|
|| (empty($maj) === true && $maj === 0)) { |
4754 |
|
$action = $this->get_action_param($maj, 'identifier'); |
4755 |
|
if ($action === 'modifier_suivi') { |
4756 |
|
$action = "modifier (via l'action suivi des dates)"; |
4757 |
|
} |
4758 |
|
} |
4759 |
|
// Création du log |
4760 |
|
$log = array( |
4761 |
|
'date' => date('Y-m-d H:i:s'), |
4762 |
|
'user' => $_SESSION['login'], |
4763 |
|
'action' => $action, |
4764 |
|
'values' => array( |
4765 |
|
'date_evenement' => $this->dateDB($val['date_evenement']), |
4766 |
|
'date_retour_rar' => $this->dateDB($val['date_retour_rar']), |
4767 |
|
'date_retour_signature' => $this->dateDB($val['date_retour_signature']), |
4768 |
|
'evenement' => $val['evenement'], |
4769 |
|
'action' => $val['action'], |
4770 |
|
'instruction' => $id, |
4771 |
|
'etat' => $val['etat'], |
4772 |
|
), |
4773 |
|
); |
4774 |
|
// Ajout du log |
4775 |
|
$di = $this->get_inst_common("dossier", $val['dossier']); |
4776 |
|
$ret = $di->add_log_instructions($log); |
4777 |
|
if ($ret === false) { |
4778 |
|
$this->correct = false; |
4779 |
|
$this->msg = ''; |
4780 |
|
$this->addToMessage($di->msg); |
4781 |
|
} |
4782 |
|
return $ret; |
4783 |
|
} |
4784 |
|
|
4785 |
|
/** |
4786 |
|
* Retourne le contexte de déboguage formaté en HTML |
4787 |
|
* |
4788 |
|
* @return string une ligne par trace |
4789 |
|
*/ |
4790 |
|
private function get_backtrace() { |
4791 |
|
$trace = debug_backtrace(); |
4792 |
|
$backtrace = ''; |
4793 |
|
$i = 1; |
4794 |
|
foreach ($trace as $key => $value) { |
4795 |
|
$func = $trace[$key]['function']; |
4796 |
|
// On ne s'autolog pas |
4797 |
|
if ($func === 'get_backtrace' |
4798 |
|
|| $func === 'add_log_to_dossier') { |
4799 |
|
continue; |
4800 |
|
} |
4801 |
|
$backtrace .= $i.') '; |
4802 |
|
// Si dans une classe |
4803 |
|
if (isset($trace[$key]['class']) === true |
4804 |
|
&& empty($trace[$key]['class']) === false) { |
4805 |
|
$backtrace .= $trace[$key]['class'].'->'.$func; |
4806 |
|
} |
4807 |
|
// Si procédural |
4808 |
|
else { |
4809 |
|
$file = $trace[$key]['file']; |
4810 |
|
$line = $trace[$key]['line']; |
4811 |
|
$truncated_file = $this->get_relative_path($file); |
4812 |
|
if ($truncated_file !== false) { |
4813 |
|
$file = $truncated_file; |
4814 |
|
} |
4815 |
|
$backtrace .= $func.' IN<br/> '.$file.':'.$line; |
4816 |
|
} |
4817 |
|
$backtrace .= '<br/>'; |
4818 |
|
$i++; |
4819 |
|
} |
4820 |
|
return $backtrace; |
4821 |
|
} |
4822 |
|
|
4823 |
|
/** |
4824 |
|
* Pour un path absolu donné, retourne le relatif à la racine de l'application |
4825 |
|
* |
4826 |
|
* @param string $path chemin absolu |
4827 |
|
* @return mixed false si échec sinon chemin relatif |
4828 |
|
*/ |
4829 |
|
private function get_relative_path($absolute) { |
4830 |
|
if ($this->get_path_app() === false) { |
4831 |
|
return false; |
4832 |
|
} |
4833 |
|
$path_app = $this->get_path_app(); |
4834 |
|
return str_replace($path_app, '', $absolute); |
4835 |
|
} |
4836 |
|
|
4837 |
|
/** |
4838 |
|
* Retourne le path absolu de la racine de l'application |
4839 |
|
* |
4840 |
|
* @return mixed false si échec sinon chemin absolu |
4841 |
|
*/ |
4842 |
|
private function get_path_app() { |
4843 |
|
$match = array(); |
4844 |
|
preg_match( '/(.*)\/[a-zA-Z0-9]+\/\.\.\/core\/$/', PATH_OPENMAIRIE, $match); |
4845 |
|
// On vérifie qu'il n'y a pas d'erreur |
4846 |
|
if (isset($match[1]) === false) { |
4847 |
|
return false; |
4848 |
|
} |
4849 |
|
return $match[1]; |
4850 |
|
} |
4851 |
}// fin classe |
}// fin classe |
4852 |
|
|
4853 |
?> |
?> |