12 |
* var $idxformulaire; |
* var $idxformulaire; |
13 |
* - modification des données dans dossier trigger avant |
* - modification des données dans dossier trigger avant |
14 |
* [modify dossier data with trigger function] |
* [modify dossier data with trigger function] |
15 |
* - function moisdate : pour ajouter des mois a une date |
* - function mois_date : pour ajouter des mois a une date |
16 |
* [add months (delay) and calculation final date] |
* [add months (delay) and calculation final date] |
17 |
* - voir script_lang.js : bible ... |
* - voir script_lang.js : bible ... |
18 |
* |
* |
39 |
var $metadata = array( |
var $metadata = array( |
40 |
"om_fichier_instruction" => array( |
"om_fichier_instruction" => array( |
41 |
"dossier" => "getDossier", |
"dossier" => "getDossier", |
42 |
"dossier_autorisation" => "getDossierAutorisation", |
"dossier_version" => "getDossierVersion", |
43 |
"date_demande_initiale" => "getDateDemandeInitiale", |
"numDemandeAutor" => "getNumDemandeAutor", |
44 |
"dossier_instruction_type" => "getDossierInstructionType", |
"anneemoisDemandeAutor" => "getAnneemoisDemandeAutor", |
45 |
"statut" => "getStatut", |
"typeInstruction" => "getTypeInstruction", |
46 |
"dossier_autorisation_type" => "getDossierAutorisationType", |
"statutAutorisation" => "getStatutAutorisation", |
47 |
"date_creation" => "getDateEvenement", |
"typeAutorisation" => "getTypeAutorisation", |
48 |
"groupe_instruction" => 'getGroupeInstruction', |
"dateEvenementDocument" => "getDateEvenementDocument", |
49 |
), |
"groupeInstruction" => 'getGroupeInstruction', |
50 |
"document_arrete" => array( |
"title" => 'getTitle', |
|
"numArrete" => "getNumArrete", |
|
|
"specialiteArrete" => "getSpecialiteArrete", |
|
|
"decisionArrete" => "getDecisionArrete", |
|
|
"chketatReglementaire" => "getChketatReglementaire", |
|
|
"chkNotification" => "getChkNotification", |
|
|
"dateNotification" => "getDateNotification", |
|
|
"chkCreationdroit" => "getChkCreationdroit", |
|
|
"chkPublication" => "getChkPublication", |
|
|
"datePublication" => "getDatePublication", |
|
|
"chkControleLegalite" => "getChkControleLegalite", |
|
|
"dateSignatureArrete" => "getDateSignatureArrete", |
|
|
"nomSignataire" => "getNomSignataire", |
|
|
"qualiteSignataire" => "getQualiteSignataire", |
|
|
"chkDelegation" => "getChkDelegation", |
|
|
"ap_numRue" => "getAp_numRue", |
|
|
"ap_nomDeLaVoie" => "getAp_nomDeLaVoie", |
|
|
"ap_codePostal" => "getAp_codePostal", |
|
|
"ap_ville" => "getAp_ville", |
|
51 |
), |
), |
52 |
); |
); |
53 |
|
|
54 |
|
|
55 |
function instruction($id, &$db, $debug) { |
function __construct($id, &$db, $debug) { |
56 |
$this->constructeur($id, $db, $debug); |
$this->constructeur($id, $db, $debug); |
57 |
} |
} |
58 |
|
|
70 |
&& isset($this->f->om_utilisateur["division"]) |
&& isset($this->f->om_utilisateur["division"]) |
71 |
&& $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier()) { |
&& $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier()) { |
72 |
// |
// |
73 |
$this->actions_sup = array(); |
//On cache les liens d'action |
74 |
$this->setParameter("actions", array()); |
$this->parameters["actions"]["modifier"] = NULL; |
75 |
|
$this->parameters["actions"]["supprimer"] = NULL; |
76 |
|
$this->actions_sup["finalisation"] = NULL; |
77 |
} |
} |
78 |
// Si une action 'lu' est présente et que le champ lu est à true |
// Si une action 'lu' est présente et que le champ lu est à true |
79 |
// on supprime l'action |
// on supprime l'action |
89 |
if ( isset($this->actions_sup["finalisation"]) && |
if ( isset($this->actions_sup["finalisation"]) && |
90 |
$om_final_instruction== "t" ){ |
$om_final_instruction== "t" ){ |
91 |
|
|
92 |
|
//On cache les liens d'action |
93 |
|
$this->parameters["actions"]["modifier"] = NULL; |
94 |
|
$this->parameters["actions"]["supprimer"] = NULL; |
95 |
//On cache le lien de finalisation et on affiche le bon lien pour l'édition |
//On cache le lien de finalisation et on affiche le bon lien pour l'édition |
96 |
unset($this->actions_sup["finalisation"]); |
$this->actions_sup["finalisation"] = NULL; |
97 |
$this->actions_sup["pdfetat"]["lien"] = "../spg/file.php?id="; |
$this->actions_sup["pdfetat"]["lien"] = "../spg/file.php?id="; |
98 |
$this->actions_sup["pdfetat"]["id"] = |
$this->actions_sup["pdfetat"]["id"] = |
99 |
"&obj=instruction&champ=om_fichier_instruction"; |
"&obj=instruction&champ=om_fichier_instruction"; |
104 |
$om_final_instruction!= "t" ){ |
$om_final_instruction!= "t" ){ |
105 |
|
|
106 |
//On cache le lien de finalisation et on affiche le bon lien pour l'édition |
//On cache le lien de finalisation et on affiche le bon lien pour l'édition |
107 |
unset($this->actions_sup["definalisation"]); |
$this->actions_sup["definalisation"] = NULL; |
108 |
$this->actions_sup["pdfetat"]["lien"] = "../app/pdf_instruction.php?idx="; |
$this->actions_sup["pdfetat"]["lien"] = "../app/pdf_instruction.php?idx="; |
109 |
$this->actions_sup["pdfetat"]["id"] = ""; |
$this->actions_sup["pdfetat"]["id"] = ""; |
110 |
} |
} |
111 |
|
|
112 |
|
$idxformulaire = $this->getParameter("idxformulaire"); |
113 |
|
$retourformulaire = $this->getParameter("retourformulaire"); |
114 |
|
//Si le dossier d'instruction auquel est rattachée l'instruction est cloturé, |
115 |
|
//on affiche pas les liens du portlet |
116 |
|
if ( $idxformulaire != '' && |
117 |
|
( |
118 |
|
$retourformulaire == 'dossier' || |
119 |
|
$retourformulaire == 'dossier_instruction' || |
120 |
|
$retourformulaire == 'dossier_instruction_mes_encours' || |
121 |
|
$retourformulaire == 'dossier_instruction_tous_encours' || |
122 |
|
$retourformulaire == 'dossier_instruction_mes_clotures' || |
123 |
|
$retourformulaire == 'dossier_instruction_tous_clotures' |
124 |
|
)){ |
125 |
|
|
126 |
|
//On récuppère le statut du dossier d'instruction |
127 |
|
$statut = $this->getStatutAutorisationDossier($idxformulaire); |
128 |
|
// Si l'utilisateur est un instructeur, que le statut est clôturé |
129 |
|
// et que l'événement n'est pas identifié comme non verrouillable |
130 |
|
if ( $this->f->isUserInstructeur() && $statut == "cloture" |
131 |
|
&& $this->checkEvenementNonVerrouillable($this->getVal("instruction")) === false){ |
132 |
|
|
133 |
|
//On cache les liens du portlet |
134 |
|
$this->parameters["actions"]["modifier"] = NULL; |
135 |
|
$this->actions_sup["finalisation"] = NULL; |
136 |
|
$this->actions_sup["definalisation"] = NULL; |
137 |
|
} |
138 |
|
} |
139 |
} |
} |
140 |
|
|
141 |
/** |
/** |
152 |
$this->addToLog("canAccess(): utilisateur instructeur sur un dossier d'une autre division", EXTRA_VERBOSE_MODE); |
$this->addToLog("canAccess(): utilisateur instructeur sur un dossier d'une autre division", EXTRA_VERBOSE_MODE); |
153 |
return false; |
return false; |
154 |
} |
} |
155 |
|
|
156 |
|
$retourformulaire = $this->getParameter("retourformulaire"); |
157 |
|
// Si l'utilisateur est un instructeur, que le dossier est cloturé, |
158 |
|
// que l'utilisateur est dans un sous formulaire précis, que le |
159 |
|
// formulaire n'est pas en mode consulter ou ajouter et que l'événement |
160 |
|
// n'est pas identifié comme non verrouillable |
161 |
|
if ( $this->f->isUserInstructeur() && |
162 |
|
$this->getStatutAutorisationDossier($this->getParameter("idxformulaire")) == "cloture" |
163 |
|
&& ( |
164 |
|
$retourformulaire == 'dossier' || |
165 |
|
$retourformulaire == 'dossier_instruction' || |
166 |
|
$retourformulaire == 'dossier_instruction_mes_encours' || |
167 |
|
$retourformulaire == 'dossier_instruction_tous_encours' || |
168 |
|
$retourformulaire == 'dossier_instruction_mes_clotures' || |
169 |
|
$retourformulaire == 'dossier_instruction_tous_clotures' |
170 |
|
) |
171 |
|
&& $this->getParameter("maj") != 3 |
172 |
|
&& $this->getParameter("maj") != 0 |
173 |
|
&& $this->checkEvenementNonVerrouillable($this->getVal("instruction")) === false) { |
174 |
|
|
175 |
|
return false; |
176 |
|
} |
177 |
// |
// |
178 |
return true; |
return true; |
179 |
} |
} |
239 |
/** |
/** |
240 |
* Cette méthode permet de récupérer le dossier d'autorisation d'un dossier |
* Cette méthode permet de récupérer le dossier d'autorisation d'un dossier |
241 |
*/ |
*/ |
242 |
function getDossierAutorisationFromDossier($id) { |
function getNumDemandeAutorFromDossier($id) { |
243 |
// |
// |
244 |
if (!isset($id)) { |
if (!isset($id)) { |
245 |
return NULL; |
return NULL; |
249 |
$sql .= " where dossier='".$id."'"; |
$sql .= " where dossier='".$id."'"; |
250 |
// |
// |
251 |
$dossier_autorisation = $this->db->getOne($sql); |
$dossier_autorisation = $this->db->getOne($sql); |
252 |
$this->addToLog("getDossierAutorisationFromDossier(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
$this->addToLog("getNumDemandeAutorFromDossier(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
253 |
database::isError($dossier_autorisation); |
database::isError($dossier_autorisation); |
254 |
// |
// |
255 |
return $dossier_autorisation; |
return $dossier_autorisation; |
262 |
parent::setType($form, $maj); |
parent::setType($form, $maj); |
263 |
// On cache tous les champs |
// On cache tous les champs |
264 |
// XXX |
// XXX |
265 |
$form->setType('complement3', 'hidden'); |
$form->setType('complement3_om_html', 'hidden'); |
266 |
$form->setType('bible3', 'hidden'); |
$form->setType('bible3', 'hidden'); |
267 |
$form->setType('complement4', 'hidden'); |
$form->setType('complement4_om_html', 'hidden'); |
268 |
$form->setType('bible4', 'hidden'); |
$form->setType('bible4', 'hidden'); |
269 |
$form->setType('complement5', 'hidden'); |
$form->setType('complement5_om_html', 'hidden'); |
270 |
$form->setType('bible5', 'hidden'); |
$form->setType('bible5', 'hidden'); |
271 |
$form->setType('complement6', 'hidden'); |
$form->setType('complement6_om_html', 'hidden'); |
272 |
$form->setType('bible6', 'hidden'); |
$form->setType('bible6', 'hidden'); |
273 |
$form->setType('complement7', 'hidden'); |
$form->setType('complement7_om_html', 'hidden'); |
274 |
$form->setType('bible7', 'hidden'); |
$form->setType('bible7', 'hidden'); |
275 |
$form->setType('complement8', 'hidden'); |
$form->setType('complement8_om_html', 'hidden'); |
276 |
$form->setType('bible8', 'hidden'); |
$form->setType('bible8', 'hidden'); |
277 |
$form->setType('complement9', 'hidden'); |
$form->setType('complement9_om_html', 'hidden'); |
278 |
$form->setType('bible9', 'hidden'); |
$form->setType('bible9', 'hidden'); |
279 |
$form->setType('complement10', 'hidden'); |
$form->setType('complement10_om_html', 'hidden'); |
280 |
$form->setType('bible10', 'hidden'); |
$form->setType('bible10', 'hidden'); |
281 |
$form->setType('complement11', 'hidden'); |
$form->setType('complement11_om_html', 'hidden'); |
282 |
$form->setType('bible11', 'hidden'); |
$form->setType('bible11', 'hidden'); |
283 |
$form->setType('complement12', 'hidden'); |
$form->setType('complement12_om_html', 'hidden'); |
284 |
$form->setType('bible12', 'hidden'); |
$form->setType('bible12', 'hidden'); |
285 |
$form->setType('complement13', 'hidden'); |
$form->setType('complement13_om_html', 'hidden'); |
286 |
$form->setType('bible13', 'hidden'); |
$form->setType('bible13', 'hidden'); |
287 |
$form->setType('complement14', 'hidden'); |
$form->setType('complement14_om_html', 'hidden'); |
288 |
$form->setType('bible14', 'hidden'); |
$form->setType('bible14', 'hidden'); |
289 |
$form->setType('complement15', 'hidden'); |
$form->setType('complement15_om_html', 'hidden'); |
290 |
$form->setType('bible15', 'hidden'); |
$form->setType('bible15', 'hidden'); |
291 |
// |
// |
292 |
$form->setType('delai', 'hidden'); |
$form->setType('delai', 'hidden'); |
295 |
$form->setType('action', 'hidden'); |
$form->setType('action', 'hidden'); |
296 |
$form->setType('delai_notification', 'hidden'); |
$form->setType('delai_notification', 'hidden'); |
297 |
$form->setType('avis_decision', 'hidden'); |
$form->setType('avis_decision', 'hidden'); |
298 |
|
$form->setType('autorite_competente', 'hidden'); |
299 |
// |
// |
300 |
$form->setType('archive_delai', 'hidden'); |
$form->setType('archive_delai', 'hidden'); |
301 |
$form->setType('archive_etat', 'hidden'); |
$form->setType('archive_etat', 'hidden'); |
310 |
$form->setType('archive_date_validite', 'hidden'); |
$form->setType('archive_date_validite', 'hidden'); |
311 |
$form->setType('archive_date_achevement', 'hidden'); |
$form->setType('archive_date_achevement', 'hidden'); |
312 |
$form->setType('archive_date_conformite', 'hidden'); |
$form->setType('archive_date_conformite', 'hidden'); |
313 |
$form->setType('archive_date_chantier', 'hidden'); |
$form->setType('archive_date_chantier', 'hidden'); |
314 |
|
$form->setType('archive_autorite_competente','hidden'); |
315 |
// |
// |
316 |
$form->setType('numero_arrete', 'hidden'); |
$form->setType('numero_arrete', 'hidden'); |
317 |
// |
// |
324 |
$form->setType('archive_etat_pendant_incompletude','hidden'); |
$form->setType('archive_etat_pendant_incompletude','hidden'); |
325 |
$form->setType('archive_date_limite_incompletude','hidden'); |
$form->setType('archive_date_limite_incompletude','hidden'); |
326 |
$form->setType('archive_delai_incompletude','hidden'); |
$form->setType('archive_delai_incompletude','hidden'); |
327 |
|
|
328 |
|
// |
329 |
|
$form->setType('duree_validite','hidden'); |
330 |
|
$form->setType('duree_validite_parametrage','hidden'); |
331 |
if ($maj < 2) { //ajouter et modifier |
if ($maj < 2) { //ajouter et modifier |
332 |
$form->setType('destinataire', 'hidden'); |
$form->setType('destinataire', 'hidden'); |
333 |
$form->setType('lettretype', 'hiddenstatic'); |
$form->setType('lettretype', 'hiddenstatic'); |
334 |
$form->setType('complement', 'textarea'); |
$form->setType('complement_om_html', 'html'); |
335 |
$form->setType('complement2', 'textarea'); |
$form->setType('complement2_om_html', 'html'); |
336 |
$form->setType('bible_auto', 'httpclick'); |
$form->setType('bible_auto', 'httpclick'); |
337 |
$form->setType('bible', 'httpclick'); |
$form->setType('bible', 'httpclick'); |
338 |
$form->setType('bible2', 'httpclick'); |
$form->setType('bible2', 'httpclick'); |
345 |
$form->setType('date_retour_rar','datedisabled'); |
$form->setType('date_retour_rar','datedisabled'); |
346 |
$form->setType('date_envoi_controle_legalite','datedisabled'); |
$form->setType('date_envoi_controle_legalite','datedisabled'); |
347 |
$form->setType('date_retour_controle_legalite','datedisabled'); |
$form->setType('date_retour_controle_legalite','datedisabled'); |
348 |
|
$form->setType('date_finalisation_courrier','datedisabled'); |
349 |
|
|
350 |
|
|
351 |
|
|
352 |
if($maj==0){ // add |
if($maj==0){ // add |
353 |
$form->setType('instruction', 'hiddenstatic'); |
$form->setType('instruction', 'hidden'); |
354 |
|
$form->setType('lettretype', 'hidden'); |
355 |
$form->setType('evenement', 'select'); |
$form->setType('evenement', 'select'); |
356 |
$form->setType('date_evenement', 'date2'); |
$form->setType('date_evenement', 'date2'); |
357 |
}else{ // modify |
}else{ // modify |
361 |
$form->setType('date_evenement', 'date2'); |
$form->setType('date_evenement', 'date2'); |
362 |
// necessaire pour calcul de date en modification |
// necessaire pour calcul de date en modification |
363 |
//$form->setType('delai', 'hiddenstatic'); |
//$form->setType('delai', 'hiddenstatic'); |
364 |
|
// l'administrateur peut modifier les champs de retour de date |
365 |
|
if ($this->f->user_is_admin == true) { |
366 |
|
$form->setType('date_retour_signature','date'); |
367 |
|
$form->setType('date_retour_rar','date'); |
368 |
|
$form->setType('date_retour_controle_legalite','date'); |
369 |
|
} |
370 |
} |
} |
371 |
} elseif($maj==2){ |
} elseif($maj==2){ |
372 |
$form->setType('dossier', 'hidden'); |
$form->setType('dossier', 'hidden'); |
385 |
$form->setType('om_fichier_instruction', 'hidden'); |
$form->setType('om_fichier_instruction', 'hidden'); |
386 |
$form->setType('om_final_instruction', 'hidden'); |
$form->setType('om_final_instruction', 'hidden'); |
387 |
// Cache le document arrêté |
// Cache le document arrêté |
388 |
$form->setType('document_arrete', 'hidden'); |
$form->setType('document_numerise', 'hidden'); |
389 |
|
|
390 |
|
//Masquer les champs date_envoi_controle_legalite et |
391 |
|
//date_retour_controle_legalite si ce n'est pas un arrêté |
392 |
|
if ( !is_numeric($this->getVal("avis_decision"))){ |
393 |
|
|
394 |
|
$form->setType("date_envoi_controle_legalite", "hidden"); |
395 |
|
$form->setType("date_retour_controle_legalite", "hidden"); |
396 |
|
} |
397 |
} |
} |
398 |
|
|
399 |
function setSelect(&$form, $maj,&$db,$debug) { |
function setSelect(&$form, $maj,&$db,$debug) { |
446 |
// du dossier d'instruction en cours |
// du dossier d'instruction en cours |
447 |
$sql = "SELECT |
$sql = "SELECT |
448 |
evenement.evenement, |
evenement.evenement, |
449 |
(evenement.libelle||' ['||evenement.action||']') as lib |
CONCAT(evenement.libelle, ' ['||evenement.action||']') as lib |
450 |
FROM ".DB_PREFIXE."dossier |
FROM ".DB_PREFIXE."dossier |
451 |
INNER JOIN ".DB_PREFIXE."lien_dossier_instruction_type_evenement |
INNER JOIN ".DB_PREFIXE."lien_dossier_instruction_type_evenement |
452 |
ON dossier.dossier_instruction_type=lien_dossier_instruction_type_evenement.dossier_instruction_type |
ON dossier.dossier_instruction_type=lien_dossier_instruction_type_evenement.dossier_instruction_type |
456 |
ON evenement.evenement = transition.evenement |
ON evenement.evenement = transition.evenement |
457 |
AND dossier.etat=transition.etat |
AND dossier.etat=transition.etat |
458 |
WHERE dossier.dossier='".$this->idxformulaire."' |
WHERE dossier.dossier='".$this->idxformulaire."' |
459 |
ORDER BY evenement.action"; |
ORDER BY evenement.libelle, evenement.action"; |
460 |
$res = $db->query($sql); |
$res = $db->query($sql); |
461 |
$this->addToLog("setSelect(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog("setSelect(): db->query(\"".$sql."\");", VERBOSE_MODE); |
462 |
if (database::isError($res)) { |
if (database::isError($res)) { |
474 |
$form->setSelect("evenement", $contenu); |
$form->setSelect("evenement", $contenu); |
475 |
} else { |
} else { |
476 |
$sql = "SELECT |
$sql = "SELECT |
477 |
(evenement.libelle||' ['||evenement.action||']') as lib |
CONCAT(evenement.libelle, ' ['||evenement.action||']') as lib |
478 |
FROM ".DB_PREFIXE."evenement |
FROM ".DB_PREFIXE."evenement |
479 |
WHERE evenement.evenement=".$this->getVal("evenement").""; |
WHERE evenement.evenement=".$this->getVal("evenement").""; |
480 |
$res = $db->getone($sql); |
$res = $db->getone($sql); |
507 |
function cleSecondaire($id, &$db, $val, $DEBUG) { |
function cleSecondaire($id, &$db, $val, $DEBUG) { |
508 |
// |
// |
509 |
parent::cleSecondaire($id, $db, $val, $DEBUG); |
parent::cleSecondaire($id, $db, $val, $DEBUG); |
510 |
|
|
511 |
|
$id = $this->getVal($this->clePrimaire); |
512 |
|
|
513 |
/** |
|
514 |
* Vérification que l'élément supprimé est le dernier pour pouvoir |
//Requête de vérification que cet événement d'instruction n'est pas lié |
515 |
* remodifier les données de manière itérative. |
//à la création d'un dossier d'instruction |
516 |
*/ |
$sql = "SELECT demande_type.dossier_instruction_type |
517 |
// Initialisation |
FROM ".DB_PREFIXE."demande_type |
518 |
$dernierevenement = ""; |
LEFT JOIN ".DB_PREFIXE."demande |
519 |
// Récupération du dernier élément de la table d'instruction qui |
ON demande.demande_type = demande_type.demande_type |
520 |
// concerne le dossier en cours |
WHERE demande.instruction_recepisse = ".$id; |
521 |
$sql = "SELECT max(instruction) |
$res = $this->db->getOne($sql); |
522 |
FROM ".DB_PREFIXE."instruction |
$this->addToLog("cleSecondaire(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
523 |
WHERE dossier ='".$this->idxformulaire."'"; |
if (database::isError($res)) { |
524 |
$dernierevenement = $db->getOne($sql); |
die($res->getMessage()); |
525 |
$this->addToLog("setSelect(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
} |
526 |
if (database::isError($dernierevenement)) { |
|
527 |
die($dernierevenement->getMessage()); |
// Aucune clé secondaire n'a été trouvée ou c'est un événement sans |
528 |
} |
//création de dossier d'instruction, l'événement d'instruction peut être |
529 |
// Si on se trouve effectivement sur le dernier evenement d'instruction |
//supprimé |
530 |
if ($dernierevenement == $id) { |
if ( $this->correct !== false || $res == null || $res == ""){ |
531 |
// Alors on valide la suppression |
|
532 |
$this->correct = true; |
// Requête de vérification que cet événement d'instruction est lié |
533 |
$this->addToMessage(_('Destruction_chronologique')); |
// à une demande |
534 |
} else { |
$sql = "SELECT demande |
535 |
// Alors on annule la suppression |
FROM ".DB_PREFIXE."demande |
536 |
$this->correct = false; |
WHERE instruction_recepisse = ".$id; |
537 |
$this->addToMessage(_("Seul le dernier evenement d'instruction peut etre supprime.")); |
$res = $this->db->getOne($sql); |
538 |
|
$this->addToLog("cleSecondaire(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
539 |
|
if (database::isError($res)) { |
540 |
|
die($res->getMessage()); |
541 |
|
} |
542 |
|
|
543 |
|
//Si c'est un événement d'instruction lié à une demande |
544 |
|
if ($res != null || $res != ""){ |
545 |
|
|
546 |
|
require_once "../obj/demande.class.php"; |
547 |
|
$demande = new demande($res, $this->db, DEBUG); |
548 |
|
|
549 |
|
//On met à jour la demande en supprimant la liaison vers |
550 |
|
//l'événement d'instruction |
551 |
|
$demande->setParameter("maj", 1); |
552 |
|
$valF = array(); |
553 |
|
foreach($demande->champs as $identifiant => $champ) { |
554 |
|
$valF[$champ] = $demande->val[$identifiant]; |
555 |
|
} |
556 |
|
$valF['date_demande']=$demande->dateDBToForm($valF['date_demande']); |
557 |
|
$valF['instruction_recepisse']=NULL; |
558 |
|
$ret = $demande->modifier($valF, $this->db, DEBUG); |
559 |
|
} |
560 |
|
|
561 |
|
/** |
562 |
|
* Vérification que l'élément supprimé est le dernier pour pouvoir |
563 |
|
* remodifier les données de manière itérative. |
564 |
|
*/ |
565 |
|
// Initialisation |
566 |
|
$dernierevenement = ""; |
567 |
|
// Récupération du dernier élément de la table d'instruction qui |
568 |
|
// concerne le dossier en cours |
569 |
|
$sql = "SELECT max(instruction) |
570 |
|
FROM ".DB_PREFIXE."instruction |
571 |
|
WHERE dossier ='".$this->idxformulaire."'"; |
572 |
|
$dernierevenement = $db->getOne($sql); |
573 |
|
$this->addToLog("setSelect(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
574 |
|
if (database::isError($dernierevenement)) { |
575 |
|
die($dernierevenement->getMessage()); |
576 |
|
} |
577 |
|
// Si on se trouve effectivement sur le dernier evenement d'instruction |
578 |
|
if ($dernierevenement == $id) { |
579 |
|
// Alors on valide la suppression |
580 |
|
$this->correct = true; |
581 |
|
$this->addToMessage(_('Destruction_chronologique')); |
582 |
|
} else { |
583 |
|
// Alors on annule la suppression |
584 |
|
$this->correct = false; |
585 |
|
$this->addToMessage(_("Seul le dernier evenement d'instruction peut etre supprime.")); |
586 |
|
} |
587 |
} |
} |
588 |
} |
} |
589 |
|
|
590 |
// Vérification de la non modification des dates de suivi |
/** |
591 |
|
* Vérification de la possibilité ou non de modifier des dates de suivi |
592 |
|
* @param string $champ champ date à vérifier |
593 |
|
*/ |
594 |
function updateDate($champ) { |
function updateDate($champ) { |
595 |
if($this->valF[$champ] != "") { |
|
596 |
if($this->getVal($champ) != "" AND $this->getVal($champ) != $this->valF[$champ]) { |
//Si le retourformulaire est "dossier_instruction" |
597 |
$this->correct = false; |
if ($this->retourformulaire == "dossier_instruction") { |
598 |
$this->addToMessage(_("Les dates de suivis ne peuvent etre modifiees")); |
|
599 |
|
// Vérification de la possibilité de modifier les dates si déjà éditées |
600 |
|
if($this->valF[$champ] != "" AND !$this->f->user_is_admin) { |
601 |
|
// si l'utilisateur n'est pas un admin |
602 |
|
if($this->getVal($champ) != "" AND $this->getVal($champ) != $this->valF[$champ]) { |
603 |
|
$this->correct = false; |
604 |
|
$this->addToMessage(_("Les dates de suivis ne peuvent etre modifiees")); |
605 |
|
} |
606 |
} |
} |
607 |
} |
} |
608 |
|
|
609 |
|
// |
610 |
|
return true; |
611 |
} |
} |
612 |
|
|
613 |
// Sélectionne le signataire_arrete par défaut |
// Sélectionne le signataire_arrete par défaut |
623 |
|
|
624 |
// Exécution de la requête |
// Exécution de la requête |
625 |
$res = $this->f->db->query($sql); |
$res = $this->f->db->query($sql); |
626 |
$this->f->addToLog("deleteAllLienDossierInstructionTypeEvenementEvenement(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->f->addToLog("setVal(): db->query(\"".$sql."\");", VERBOSE_MODE); |
627 |
if ( database::isError($res)){ |
if ( database::isError($res)){ |
628 |
die(); |
die(); |
629 |
} |
} |
676 |
|
|
677 |
$form->setBloc('date_retour_controle_legalite','F'); |
$form->setBloc('date_retour_controle_legalite','F'); |
678 |
|
|
679 |
$form->setBloc('complement','D',"","col_12"); |
$form->setBloc('complement_om_html','D',"","col_12"); |
680 |
$form->setFieldset('complement','D',_('Complement')); |
$form->setFieldset('complement_om_html','D',_('Complement')); |
681 |
$form->setFieldset('bible','F',''); |
$form->setFieldset('bible','F',''); |
682 |
$form->setBloc('bible','F'); |
$form->setBloc('bible','F'); |
683 |
|
|
684 |
$form->setBloc('complement2','D',"","col_12"); |
$form->setBloc('complement2_om_html','D',"","col_12"); |
685 |
$form->setFieldset('complement2','D',_('Complement 2')); |
$form->setFieldset('complement2_om_html','D',_('Complement 2')); |
686 |
$form->setFieldset('bible2','F',''); |
$form->setFieldset('bible2','F',''); |
687 |
$form->setBloc('bible2','F'); |
$form->setBloc('bible2','F'); |
688 |
} |
} |
709 |
* - avis_decision |
* - avis_decision |
710 |
* - delai_notification |
* - delai_notification |
711 |
* - lettretype |
* - lettretype |
712 |
|
* - autorite_competente |
713 |
* DEPUIS LE DOSSIER D'INSTRUCTION |
* DEPUIS LE DOSSIER D'INSTRUCTION |
714 |
* - archive_delai |
* - archive_delai |
715 |
* - archive_accord_tacite |
* - archive_accord_tacite |
724 |
* - date_achevement |
* - date_achevement |
725 |
* - date_chantier |
* - date_chantier |
726 |
* - date_conformite |
* - date_conformite |
727 |
|
* - avis_decision |
728 |
* Il permet également de stocker la date_depot du dossier d'instruction |
* Il permet également de stocker la date_depot du dossier d'instruction |
729 |
* dans l'attribut $this->archive_date_depot de la classe. |
* dans l'attribut $this->archive_date_depot de la classe. |
730 |
*/ |
*/ |
761 |
if(isset($row['avis_decision']) and !empty($row['avis_decision'])) { |
if(isset($row['avis_decision']) and !empty($row['avis_decision'])) { |
762 |
$this->valF['avis_decision']=$row['avis_decision']; |
$this->valF['avis_decision']=$row['avis_decision']; |
763 |
} |
} |
764 |
|
// Récupération de la valeur de l'autorité compétente |
765 |
|
// si l'autorité compétente est paramétré dans l'événement |
766 |
|
$this->valF['autorite_competente'] = NULL; |
767 |
|
if(isset($row['autorite_competente']) and !empty($row['autorite_competente'])) { |
768 |
|
$this->valF['autorite_competente']=$row['autorite_competente']; |
769 |
|
} |
770 |
// Récupération de la valeur de la lettre type |
// Récupération de la valeur de la lettre type |
771 |
// Sinon on lui affecte lavaleur par défaut standard |
// Sinon on lui affecte lavaleur par défaut standard |
772 |
if ($row['lettretype'] != "") { |
if ($row['lettretype'] != "") { |
783 |
if (database::isError($res)) { |
if (database::isError($res)) { |
784 |
die($res->getMessage()); |
die($res->getMessage()); |
785 |
} |
} |
786 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
787 |
// XXX On stocke la date de dépôt actuelle du dossier d'instruction |
$this->updateArchiveData($row); |
788 |
// dans un attribut de la classe |
$this->archive_date_depot = $row['date_depot']; |
789 |
$this->archive_date_depot = $row['date_depot']; |
|
790 |
// Récupération de la valeur actuelle du délai, de l'accord tacite, |
// Récupération de la duree de validite du dossier d'autorisation |
791 |
// de l'état et de l'avis du dossier d'instruction |
$sql = "SELECT duree_validite_parametrage |
792 |
$this->valF['archive_delai']=$row['delai']; |
FROM ".DB_PREFIXE."dossier_autorisation_type_detaille |
793 |
$this->valF['archive_accord_tacite']=$row['accord_tacite']; |
LEFT JOIN ".DB_PREFIXE."dossier_autorisation |
794 |
$this->valF['archive_etat']=$row['etat']; |
ON dossier_autorisation.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
795 |
$this->valF['archive_avis']=$row['avis_decision']; |
LEFT JOIN ".DB_PREFIXE."dossier |
796 |
// Récupération de la valeur actuelle des 9 dates du dossier |
ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
797 |
// d'instruction |
WHERE dossier.dossier='".$this->valF['dossier']."'"; |
798 |
if ($row['date_complet'] != '') { |
$duree_validite_parametrage = $db->getOne($sql); |
799 |
$this->valF['archive_date_complet']=$row['date_complet']; |
$this->addToLog("triggerajouter(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
800 |
} |
database::isError($duree_validite_parametrage); |
801 |
if ($row['date_dernier_depot'] != '') { |
if ($duree_validite_parametrage != '') { |
802 |
$this->valF['archive_date_dernier_depot']=$row['date_dernier_depot']; |
$this->valF['duree_validite_parametrage']= $duree_validite_parametrage; |
|
} |
|
|
if ($row['date_rejet']!='') { |
|
|
$this->valF['archive_date_rejet']= $row['date_rejet']; |
|
|
} |
|
|
if ($row['date_limite']!='') { |
|
|
$this->valF['archive_date_limite']= $row['date_limite']; |
|
|
} |
|
|
if ($row['date_notification_delai']!='') { |
|
|
$this->valF['archive_date_notification_delai']= $row['date_notification_delai']; |
|
|
} |
|
|
if ($row['date_decision']!='') { |
|
|
$this->valF['archive_date_decision']= $row['date_decision']; |
|
|
} |
|
|
if ($row['date_validite']!='') { |
|
|
$this->valF['archive_date_validite']= $row['date_validite']; |
|
|
} |
|
|
if ($row['date_achevement']!='') { |
|
|
$this->valF['archive_date_achevement']= $row['date_achevement']; |
|
|
} |
|
|
if ($row['date_chantier']!='') { |
|
|
$this->valF['archive_date_chantier']= $row['date_chantier']; |
|
|
} |
|
|
if ($row['date_conformite']!='') { |
|
|
$this->valF['archive_date_conformite']= $row['date_conformite']; |
|
|
} |
|
|
if ($row['incompletude']!='') { |
|
|
$this->valF['archive_incompletude']= $row['incompletude']; |
|
|
} |
|
|
if ($row['evenement_suivant_tacite']!='') { |
|
|
$this->valF['archive_evenement_suivant_tacite']= $row['evenement_suivant_tacite']; |
|
|
} |
|
|
if ($row['evenement_suivant_tacite_incompletude']!='') { |
|
|
$this->valF['archive_evenement_suivant_tacite_incompletude']= $row['evenement_suivant_tacite_incompletude']; |
|
|
} |
|
|
if ($row['etat_pendant_incompletude']!='') { |
|
|
$this->valF['archive_etat_pendant_incompletude']= $row['etat_pendant_incompletude']; |
|
|
} |
|
|
if ($row['date_limite_incompletude']!='') { |
|
|
$this->valF['archive_date_limite_incompletude']= $row['date_limite_incompletude']; |
|
|
} |
|
|
if ($row['delai_incompletude']!='') { |
|
|
$this->valF['archive_delai_incompletude']= $row['delai_incompletude']; |
|
|
} |
|
803 |
} |
} |
804 |
|
|
805 |
// Identifiant du type de courrier |
// Identifiant du type de courrier |
812 |
// Test si une restriction est valide |
// Test si une restriction est valide |
813 |
// return boolean |
// return boolean |
814 |
function restrictionIsValid($restriction){ |
function restrictionIsValid($restriction){ |
815 |
|
|
816 |
|
// Liste des opérateurs possible |
817 |
|
$operateurs = array(">=", "<=", "+", "-"); |
818 |
|
// Liste des opérateurs avec espace |
819 |
|
$operateurs_blank = array(" >= ", " <= ", " + ", " - "); |
820 |
|
|
821 |
|
// Supprime tous les espaces de la chaîne de caractère |
822 |
|
$restriction = str_replace(' ', '', $restriction); |
823 |
|
|
824 |
/* Met des espace avant et après les opérateurs puis transforme la chaine en |
// Met des espace avant et après les opérateurs puis transforme la |
825 |
* un tableau */ |
// chaine en un tableau |
826 |
$tabRestriction = str_replace(">="," >= ", |
$tabRestriction = str_replace($operateurs, $operateurs_blank, |
827 |
str_replace("<="," <= ", |
$restriction); |
828 |
str_replace("-"," - ", |
$tabRestriction = explode(" ", $tabRestriction); |
829 |
str_replace("+"," + ",$restriction)))); |
|
830 |
$tabRestriction = explode( " ", $tabRestriction); |
// Tableau comprenant les résultat |
|
|
|
|
//Variables de résultat |
|
831 |
$res = array(); |
$res = array(); |
832 |
$i = 0; |
// Compteur pour les résultat |
833 |
$comp = ""; |
// commence à 1 car le 0 doit rester inchangé tout au long du traitement |
834 |
|
$j = 1; |
835 |
|
// Comparateur du calcul |
836 |
//Test que le tableau n'est pas vide |
$comparateur = ''; |
837 |
if ( count($tabRestriction) > 0 ){ |
// Booléen retourné |
838 |
|
$res_bool = true; |
839 |
$res[0] = $this->getRestrictionValue($tabRestriction[0]); |
|
840 |
|
// S'il y a un comparateur |
841 |
//Calcul des variables |
if (in_array(">=", $tabRestriction) |
842 |
for ( $j = 1 ; $j < count($tabRestriction) ; $j += 2 ) { |
|| in_array("<=", $tabRestriction)) { |
843 |
|
|
844 |
//Variable de comparaison |
// Si le tableau n'est pas vide |
845 |
if ( strcmp( ">=", $tabRestriction[$j] ) == 0 || |
if (count($tabRestriction) > 0) { |
846 |
strcmp( "<=", $tabRestriction[$j]) ==0 ){ |
|
847 |
|
// Boucle dans le tableau pour récupérer seulement les valeurs |
848 |
|
foreach ($tabRestriction as $key => $value) { |
849 |
|
|
850 |
$comp = $tabRestriction[$j]; |
// |
851 |
$res[++$i] = $this->getRestrictionValue($tabRestriction[$j+1]); |
if (!in_array($value, $operateurs)) { |
852 |
|
if ($this->getRestrictionValue($value) != false) { |
853 |
|
$res[] = $this->getRestrictionValue($value); |
854 |
|
} else { |
855 |
|
// Message d'erreur |
856 |
|
$error_message = sprintf(_("Le champ %s de l'instruction %s est vide"), "<span class='bold'>".$value."</span>", "<span class='bold'>".$this->valF["instruction"]."</span>"); |
857 |
|
$this->addToMessage($error_message); |
858 |
|
// Arrête le traitement |
859 |
|
return false; |
860 |
|
} |
861 |
|
} |
862 |
} |
} |
863 |
// Fait l'addition |
|
864 |
elseif ( strcmp( "+", $tabRestriction[$j]) == 0 ){ |
// Boucle dans le tableau |
865 |
|
// commence à 1 car le 0 doit rester inchangé tout au long du |
866 |
|
// traitement |
867 |
|
for ($i = 1; $i<count($tabRestriction); $i++) { |
868 |
|
|
869 |
$res[$i] = $this->moisdate( $res[$i], $this->getRestrictionValue($tabRestriction[$j+1]) ); |
// Récupère le comparateur |
870 |
|
if ($tabRestriction[$i] === ">=" |
871 |
|
|| $tabRestriction[$i] === "<=") { |
872 |
|
$comparateur = $tabRestriction[$i]; |
873 |
|
} |
874 |
|
|
875 |
|
// Si l'opérateur qui suit est un "+" |
876 |
|
if ($tabRestriction[$i] === "+") { |
877 |
|
$dateDep = $res[$j]; |
878 |
|
unset($res[$j]);$j++; |
879 |
|
$duree = $res[$j]; |
880 |
|
unset($res[$j]); |
881 |
|
$res[$j] = $this->f->mois_date($dateDep, $duree, "+"); |
882 |
|
} |
883 |
|
|
884 |
|
// Si l'opérateur qui suit est un "-" |
885 |
|
if ($tabRestriction[$i] === "-") { |
886 |
|
$dateDep = $res[$j]; |
887 |
|
unset($res[$j]);$j++; |
888 |
|
$duree = $res[$j]; |
889 |
|
unset($res[$j]); |
890 |
|
$res[$j] = $this->f->mois_date($dateDep, $duree, "-"); |
891 |
|
} |
892 |
} |
} |
|
} |
|
|
} |
|
893 |
|
|
|
// Effectue le test |
|
|
if ( strcmp($comp, ">=") == 0 ){ |
|
|
|
|
|
if ( $res[0] >= $res[1] || $res[0] == "" ){ |
|
|
|
|
|
return true; |
|
|
} |
|
|
else { |
|
|
|
|
|
return false; |
|
894 |
} |
} |
|
} |
|
|
elseif ( strcmp($comp, "<=") == 0 ){ |
|
895 |
|
|
896 |
if ( $res[0] <= $res[1] || $res[1] == "" ){ |
// Si les tableau des résultats n'est pas vide |
897 |
|
if (count($res) > 0) { |
898 |
|
// |
899 |
|
$res_bool = false; |
900 |
|
// Effectue le test |
901 |
|
if ($comparateur === ">=") { |
902 |
|
// |
903 |
|
if (strtotime($res[0]) >= strtotime($res[$j])) { |
904 |
|
$res_bool = true; |
905 |
|
} |
906 |
|
} |
907 |
|
if ($comparateur === "<=") { |
908 |
|
|
909 |
return true; |
if (strtotime($res[0]) <= strtotime($res[$j])) { |
910 |
|
$res_bool = true; |
911 |
|
} |
912 |
|
} |
913 |
} |
} |
914 |
else { |
// Sinon une erreur s'affiche |
915 |
|
} else { |
916 |
|
|
917 |
return false; |
// Message d'erreur |
918 |
} |
$error_message = _("La restriction est sans comparateur"); |
919 |
|
$this->addToMessage($error_message); |
920 |
|
// Arrête le traitement |
921 |
|
return false; |
922 |
} |
} |
923 |
|
|
924 |
return true; |
return $res_bool; |
925 |
|
|
926 |
} |
} |
927 |
|
|
928 |
//Retourne la valeur de valF si $restrictionValue n'est pas un chiffre, le chiffre sinon |
/** |
929 |
|
* Récupère la valeur du champ dans la restriction |
930 |
|
* @param string $restrictionValue Nom du champ |
931 |
|
* @return mixed Valeur du champ |
932 |
|
*/ |
933 |
function getRestrictionValue($restrictionValue){ |
function getRestrictionValue($restrictionValue){ |
934 |
|
|
935 |
return ( is_numeric($restrictionValue) ) ? |
// Initialisation de la valeur de retour |
936 |
$restrictionValue : |
$return = false; |
937 |
$this->valF[$restrictionValue]; |
|
938 |
|
// Récupére les valeurs du dossier |
939 |
|
$value_dossier = $this->get_dossier_actual(); |
940 |
|
|
941 |
|
// |
942 |
|
if (is_numeric($restrictionValue)) { |
943 |
|
$return = $restrictionValue; |
944 |
|
}elseif (isset($value_dossier[$restrictionValue])) { |
945 |
|
$return = $value_dossier[$restrictionValue]; |
946 |
|
}elseif (isset($this->valF[$restrictionValue])) { |
947 |
|
$return = $this->valF[$restrictionValue]; |
948 |
|
} |
949 |
|
|
950 |
|
// Retourne la valeur du champ |
951 |
|
return $return; |
952 |
} |
} |
953 |
|
|
954 |
function regle($regle){ |
/** |
955 |
$temp = explode ("+",$regle); |
* Calcul des règle d'action. |
956 |
//echo '|'.$regle; |
* @param string $rule Règle d'action |
957 |
// cas rejet |
* @param string $rule_name Nom de la règle |
958 |
if($regle=="null") // 1 dimension -> null |
* @param string $type Type de la règle |
959 |
|
* |
960 |
|
* @return mixed Résultat de la règle |
961 |
|
*/ |
962 |
|
function regle($rule, $rule_name, $type = null) { |
963 |
|
|
964 |
|
// Supprime tous les espaces de la chaîne de caractère |
965 |
|
$rule = str_replace(' ', '', $rule); |
966 |
|
// Coupe la chaîne au niveau de l'opérateur |
967 |
|
$operands = explode ("+", $rule); |
968 |
|
// Nombre d'opérande |
969 |
|
$nb_operands = count($operands); |
970 |
|
|
971 |
|
// Règle à null |
972 |
|
if ($rule == "null") { |
973 |
return null; |
return null; |
|
if(sizeof($temp)==1) // 1 dimension |
|
|
if($temp[0]=="archive_date_depot") // initialisation avec le depot |
|
|
return $this->$regle; |
|
|
else // cas general |
|
|
return $this->valF[$regle]; |
|
|
if(sizeof($temp)==2){ // 2 dimensions |
|
|
if($temp[0]=="archive_date_depot") //initialisation avec le depot |
|
|
if(is_numeric($temp[1])) |
|
|
return $this->moisdate($this->$temp[0], $temp[1]); |
|
|
else |
|
|
return $this->moisdate($this->$temp[0], $this->valF[$temp[1]]); |
|
|
if($temp[0]=="archive_delai") // majoration de delai |
|
|
return $this->valF[$temp[0]]+$this->valF[$temp[1]]; |
|
|
// cas general 2 dimensions |
|
|
if(is_numeric($temp[1])) |
|
|
return $this->moisdate($this->valF[$temp[0]], $temp[1]); |
|
|
else |
|
|
return $this->moisdate($this->valF[$temp[0]], $this->valF[$temp[1]]); |
|
|
} |
|
|
if(sizeof($temp)==3){ // 3 dimensions |
|
|
// cas date de validite de sursis |
|
|
if(is_numeric($temp[1])) |
|
|
$temp1 = $this->moisdate($this->valF[$temp[0]], $temp[1]); |
|
|
else |
|
|
$temp1 = $this->moisdate($this->valF[$temp[0]], $this->valF[$temp[1]]); |
|
|
if(is_numeric($temp[2])) |
|
|
return $this->moisdate($temp1, $temp[2]); |
|
|
else |
|
|
return $this->moisdate($temp1, $this->valF[$temp[2]]); |
|
974 |
} |
} |
975 |
|
|
976 |
|
// Si c'est une règle spécifique |
977 |
|
if ($rule_name == "regle_autorite_competente" |
978 |
|
|| $rule_name == "regle_etat" |
979 |
|
|| $rule_name == "regle_accord_tacite" |
980 |
|
|| $rule_name == "regle_avis") { |
981 |
|
// |
982 |
|
return $this->valF[$rule]; |
983 |
|
} |
984 |
|
|
985 |
|
// Tableau des champs de type date |
986 |
|
$rule_type_date = array( |
987 |
|
"regle_date_limite", |
988 |
|
"regle_date_notification_delai", |
989 |
|
"regle_date_complet", |
990 |
|
"regle_date_validite", |
991 |
|
"regle_date_decision", |
992 |
|
"regle_date_chantier", |
993 |
|
"regle_date_achevement", |
994 |
|
"regle_date_conformite", |
995 |
|
"regle_date_rejet", |
996 |
|
"regle_date_dernier_depot", |
997 |
|
"regle_date_limite_incompletude", |
998 |
|
); |
999 |
|
// Tableau des champs de type numérique |
1000 |
|
$rule_type_numeric = array( |
1001 |
|
"regle_delai", |
1002 |
|
"regle_delai_incompletude", |
1003 |
|
); |
1004 |
|
|
1005 |
|
// Définit le type du champ |
1006 |
|
if (in_array($rule_name, $rule_type_date) == true) { |
1007 |
|
$type = "date"; |
1008 |
|
} |
1009 |
|
if (in_array($rule_name, $rule_type_numeric) == true) { |
1010 |
|
$type = "numeric"; |
1011 |
|
} |
1012 |
|
|
1013 |
|
// Initialisation des variables |
1014 |
|
$key_date = 0; |
1015 |
|
$total_numeric = 0; |
1016 |
|
|
1017 |
|
// Pour chaque opérande |
1018 |
|
foreach ($operands as $key => $operand) { |
1019 |
|
|
1020 |
|
// Si c'est une règle de type date |
1021 |
|
if ($type == 'date') { |
1022 |
|
// Vérifie si au moins une des opérandes est une date |
1023 |
|
if (!is_numeric($operand) |
1024 |
|
&& isset($this->valF[$operand]) |
1025 |
|
&& $this->f->check_date($this->valF[$operand]) == true) { |
1026 |
|
// Récupère la position de la date |
1027 |
|
$key_date = $key; |
1028 |
|
} |
1029 |
|
// Les autres opérandes doivent être que des numériques |
1030 |
|
if (is_numeric($operand) == true) { |
1031 |
|
// Ajoute l'opérande au total |
1032 |
|
$total_numeric += $operand; |
1033 |
|
} |
1034 |
|
if (!is_numeric($operand) |
1035 |
|
&& isset($this->valF[$operand]) |
1036 |
|
&& is_numeric($this->valF[$operand]) == true) { |
1037 |
|
// Ajoute l'opérande au total |
1038 |
|
$total_numeric += $this->valF[$operand]; |
1039 |
|
} |
1040 |
|
} |
1041 |
|
|
1042 |
|
// Si c'est une règle de type numérique |
1043 |
|
if ($type == 'numeric') { |
1044 |
|
// Les opérandes doivent être que des numériques |
1045 |
|
if (is_numeric($operand) == true) { |
1046 |
|
// Ajoute l'opérande au total |
1047 |
|
$total_numeric += $operand; |
1048 |
|
} |
1049 |
|
if (!is_numeric($operand) |
1050 |
|
&& isset($this->valF[$operand]) |
1051 |
|
&& is_numeric($this->valF[$operand]) == true) { |
1052 |
|
// Ajoute l'opérande au total |
1053 |
|
$total_numeric += $this->valF[$operand]; |
1054 |
|
} |
1055 |
|
} |
1056 |
|
} |
1057 |
|
|
1058 |
|
// Résultat pour une règle de type date |
1059 |
|
if ($type == 'date') { |
1060 |
|
// Retourne le calcul de la date |
1061 |
|
return $this->f->mois_date($this->valF[$operands[$key_date]], |
1062 |
|
$total_numeric, "+"); |
1063 |
|
} |
1064 |
|
|
1065 |
|
// Résultat pour une règle de type numérique |
1066 |
|
if ($type == 'numeric') { |
1067 |
|
// Retourne le calcul |
1068 |
|
return $total_numeric; |
1069 |
|
} |
1070 |
|
|
1071 |
} |
} |
|
|
|
|
|
|
1072 |
|
|
1073 |
function triggerajouterapres($id,&$db,$val,$DEBUG) { |
function triggerajouterapres($id,&$db,$val,$DEBUG) { |
1074 |
/** |
/** |
1121 |
|
|
1122 |
// pour chacune des regles, on applique la regle |
// pour chacune des regles, on applique la regle |
1123 |
if($row['regle_delai']!=''){ |
if($row['regle_delai']!=''){ |
1124 |
$valF['delai'] = $this->regle($row['regle_delai']); |
$valF['delai'] = $this->regle($row['regle_delai'], 'regle_delai'); |
1125 |
} |
} |
1126 |
if($row['regle_accord_tacite']!=''){ |
if($row['regle_accord_tacite']!=''){ |
1127 |
$valF['accord_tacite'] = $this->regle($row['regle_accord_tacite']); |
$valF['accord_tacite'] = $this->regle($row['regle_accord_tacite'], 'regle_accord_tacite'); |
1128 |
} |
} |
1129 |
if($row['regle_avis']!=''){ |
if($row['regle_avis']!=''){ |
1130 |
$valF['avis_decision'] = $this->regle($row['regle_avis']); |
$valF['avis_decision'] = $this->regle($row['regle_avis'], 'regle_avis'); |
1131 |
} |
} |
1132 |
if($row['regle_date_limite']!=''){ |
if($row['regle_date_limite']!=''){ |
1133 |
$valF['date_limite']= $this->regle($row['regle_date_limite']); |
$valF['date_limite']= $this->regle($row['regle_date_limite'], 'regle_date_limite'); |
1134 |
} |
} |
1135 |
if($row['regle_date_complet']!=''){ |
if($row['regle_date_complet']!=''){ |
1136 |
$valF['date_complet']= $this->regle($row['regle_date_complet']); |
$valF['date_complet']= $this->regle($row['regle_date_complet'], 'regle_date_complet'); |
1137 |
} |
} |
1138 |
if($row['regle_date_dernier_depot']!=''){ |
if($row['regle_date_dernier_depot']!=''){ |
1139 |
$valF['date_dernier_depot']= $this->regle($row['regle_date_dernier_depot']); |
$valF['date_dernier_depot']= $this->regle($row['regle_date_dernier_depot'], 'regle_date_dernier_depot'); |
1140 |
} |
} |
1141 |
if($row['regle_date_notification_delai']!=''){ |
if($row['regle_date_notification_delai']!=''){ |
1142 |
$valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']); |
$valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai'], 'regle_date_notification_delai'); |
1143 |
} |
} |
1144 |
if($row['regle_date_decision']!=''){ |
if($row['regle_date_decision']!=''){ |
1145 |
$valF['date_decision']= $this->regle($row['regle_date_decision']); |
$valF['date_decision']= $this->regle($row['regle_date_decision'], 'regle_date_decision'); |
1146 |
} |
} |
1147 |
if($row['regle_date_rejet']!=''){ |
if($row['regle_date_rejet']!=''){ |
1148 |
$valF['date_rejet']= $this->regle($row['regle_date_rejet']); |
$valF['date_rejet']= $this->regle($row['regle_date_rejet'], 'regle_date_rejet'); |
1149 |
} |
} |
1150 |
if($row['regle_date_validite']!=''){ |
if($row['regle_date_validite']!=''){ |
1151 |
$valF['date_validite']= $this->regle($row['regle_date_validite']); |
$valF['date_validite']= $this->regle($row['regle_date_validite'], 'regle_date_validite'); |
1152 |
} |
} |
1153 |
if($row['regle_date_chantier']!=''){ |
if($row['regle_date_chantier']!=''){ |
1154 |
$valF['date_chantier']= $this->regle($row['regle_date_chantier']); |
$valF['date_chantier']= $this->regle($row['regle_date_chantier'], 'regle_date_chantier'); |
1155 |
} |
} |
1156 |
if($row['regle_date_achevement']!=''){ |
if($row['regle_date_achevement']!=''){ |
1157 |
$valF['date_achevement']= $this->regle($row['regle_date_achevement']); |
$valF['date_achevement']= $this->regle($row['regle_date_achevement'], 'regle_date_achevement'); |
1158 |
} |
} |
1159 |
if($row['regle_date_conformite']!=''){ |
if($row['regle_date_conformite']!=''){ |
1160 |
$valF['date_conformite']= $this->regle($row['regle_date_conformite']); |
$valF['date_conformite']= $this->regle($row['regle_date_conformite'], 'regle_date_conformite'); |
1161 |
} |
} |
1162 |
if($row['regle_date_limite_incompletude']!=''){ |
if($row['regle_date_limite_incompletude']!=''){ |
1163 |
$valF['date_limite_incompletude']= $this->regle($row['regle_date_limite_incompletude']); |
$valF['date_limite_incompletude']= $this->regle($row['regle_date_limite_incompletude'], 'regle_date_limite_incompletude'); |
1164 |
} |
} |
1165 |
if($row['regle_delai_incompletude']!=''){ |
if($row['regle_delai_incompletude']!=''){ |
1166 |
$valF['delai_incompletude']= $this->regle($row['regle_delai_incompletude']); |
$valF['delai_incompletude']= $this->regle($row['regle_delai_incompletude'], 'regle_delai_incompletude'); |
1167 |
|
} |
1168 |
|
if($row['regle_autorite_competente']!=''){ |
1169 |
|
$valF['autorite_competente']= $this->regle($row['regle_autorite_competente'], 'regle_autorite_competente'); |
1170 |
} |
} |
1171 |
if($row['regle_etat']!=''){ |
if($row['regle_etat']!=''){ |
1172 |
// Si on est dans le cas général ou qu'on est en incomplétude et |
// Si on est dans le cas général ou qu'on est en incomplétude et |
1173 |
// qu'on a un événement de type incomplétude alors : on stocke |
// qu'on a un événement de type incomplétude alors : on stocke |
1174 |
// l'état dans la variable courante |
// l'état dans la variable courante |
1175 |
if ($incompletude == FALSE OR $this->valEvenement['type'] == "incompletude") { |
if ($incompletude == FALSE OR $this->valEvenement['type'] == "incompletude") { |
1176 |
$valF['etat'] = $this->regle($row['regle_etat']); |
$valF['etat'] = $this->regle($row['regle_etat'], 'regle_etat'); |
1177 |
} else { |
} else { |
1178 |
$valF['etat_pendant_incompletude'] = $this->regle($row['regle_etat']); |
$valF['etat_pendant_incompletude'] = $this->regle($row['regle_etat'], 'regle_etat'); |
1179 |
} |
} |
1180 |
} |
} |
|
|
|
1181 |
if($this->valEvenement['evenement_suivant_tacite'] != '') { |
if($this->valEvenement['evenement_suivant_tacite'] != '') { |
1182 |
// Si on est pas en incomplétude on stocke l'événement tacite |
// Si on est pas en incomplétude on stocke l'événement tacite |
1183 |
//de l'événement dans la variable courante |
//de l'événement dans la variable courante |
1250 |
|
|
1251 |
// Mise à jour des données du dossier d'autorisation |
// Mise à jour des données du dossier d'autorisation |
1252 |
require_once "../obj/dossier_autorisation.class.php"; |
require_once "../obj/dossier_autorisation.class.php"; |
1253 |
$da = new dossier_autorisation($this->getDossierAutorisationFromDossier($this->valF['dossier']), $this->db, DEBUG); |
$da = new dossier_autorisation($this->getNumDemandeAutorFromDossier($this->valF['dossier']), $this->db, DEBUG); |
1254 |
$da->majDossierAutorisation(); |
if($da->majDossierAutorisation() === false) { |
1255 |
|
$this->addToMessage(_("Erreur lors de la mise a jour des donnees techniques. Contactez votre administrateur.")); |
1256 |
// Finalisation du document |
$this->correct = false; |
1257 |
$this->finaliserAjouter(); |
return false; |
|
} |
|
|
function triggermodifier($id,&$db,$val,$DEBUG) { |
|
|
// Ajout de l'arrêté dans la GED |
|
|
if ($this->valF['numero_arrete'] != $this->getVal('numero_arrete') |
|
|
AND $this->valF["om_fichier_instruction"] != "") { |
|
|
$file = $this->f->storage->get($this->valF["om_fichier_instruction"]); |
|
|
if(isset($file) and $file != null) { |
|
|
// Récupération des métadonnées calculées après validation |
|
|
$spe_metadata = $this->getMetadata("document_arrete"); |
|
|
$pdf_output = $file["file_content"]; |
|
|
//Métadonnées du document |
|
|
$metadata = array( |
|
|
'filename' => 'instruction_'.$this->valF[$this->clePrimaire].'.pdf', |
|
|
'mimetype' => 'application/pdf', |
|
|
'size' => strlen($pdf_output) |
|
|
); |
|
|
$metadata = array_merge($metadata, $spe_metadata); |
|
|
|
|
|
//Si le document a déjà été finalisé |
|
|
//on met à jour le document mais pas son uid |
|
|
if ( $this->getVal("document_arrete") != '' ){ |
|
|
$uid = $this->f->storage->update( |
|
|
$this->getVal("document_arrete"), $pdf_output, $metadata); |
|
|
} |
|
|
//Sinon, on joute le document et on récupère son uid |
|
|
else { |
|
|
//Stockage du PDF |
|
|
$uid = $this->f->storage->create($pdf_output, $metadata); |
|
|
} |
|
|
if($uid != OP_FAILURE) { |
|
|
$this->valF["document_arrete"] = $uid; |
|
|
} |
|
|
} |
|
|
|
|
1258 |
} |
} |
1259 |
} |
} |
1260 |
|
|
1261 |
function triggermodifierapres($id,&$db,$val,$DEBUG) { |
function triggermodifierapres($id,&$db,$val,$DEBUG) { |
1262 |
/** |
/** |
1263 |
* L'objectif ici est d'effectuer les recalculs de date dans le dossier |
* L'objectif ici est d'effectuer les recalculs de date dans le dossier |
1265 |
*/ |
*/ |
1266 |
// Initialisation |
// Initialisation |
1267 |
$valF = ""; |
$valF = ""; |
1268 |
|
// Initialisation du type d'événement |
1269 |
|
$type_evmt = ""; |
1270 |
// Récupération de l'action correspondante à l'événement |
// Récupération de l'action correspondante à l'événement |
1271 |
$sql = "SELECT action |
$sql = "SELECT action |
1272 |
FROM ".DB_PREFIXE."evenement |
FROM ".DB_PREFIXE."evenement |
1277 |
die($action->getMessage()); |
die($action->getMessage()); |
1278 |
} |
} |
1279 |
|
|
|
// Récupération de tous les paramètres de l'événement sélectionné |
|
|
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
|
|
WHERE evenement=".$this->valF['evenement']; |
|
|
$res = $db->query($sql); |
|
|
$this->addToLog("triggerajouter(): db->query(\"".$sql."\");", VERBOSE_MODE); |
|
|
if (database::isError($res)) { |
|
|
die($res->getMessage()); |
|
|
} |
|
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
|
|
// Si la date de retour signature est éditée on vérifie si il existe un événement automatique |
|
|
if ($this->getVal('date_retour_signature') == "" AND |
|
|
$this->valF['date_retour_signature'] != "" AND |
|
|
$row['evenement_retour_signature'] != "") { |
|
|
$new_instruction = new instruction("]", $db, $DEBUG); |
|
|
// Création d'un tableau avec la liste des champs de l'instruction |
|
|
foreach($new_instruction->champs as $champ) { |
|
|
$valNewInstr[$champ] = ""; |
|
|
} |
|
|
// Définition des valeurs de la nouvelle instruction |
|
|
$valNewInstr["evenement"] = $row['evenement_retour_signature']; |
|
|
$valNewInstr["destinataire"] = $this->valF['destinataire']; |
|
|
$valNewInstr["dossier"] = $this->valF['dossier']; |
|
|
$valNewInstr["date_evenement"] = date("d/m/Y"); |
|
|
$new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
|
|
} |
|
|
// Si la date de retour AR est éditée on vérifie si il existe un événement automatique |
|
|
if ($this->getVal('date_retour_rar') == "" AND |
|
|
$this->valF['date_retour_rar'] != "" AND |
|
|
$row['evenement_retour_ar'] != "" ) { |
|
|
$new_instruction = new instruction("]", $db, $DEBUG); |
|
|
// Création d'un tableau avec la liste des champs de l'instruction |
|
|
foreach($new_instruction->champs as $champ) { |
|
|
$valNewInstr[$champ] = ""; |
|
|
} |
|
|
// Définition des valeurs de la nouvelle instruction |
|
|
$valNewInstr["evenement"] = $row['evenement_retour_ar']; |
|
|
$valNewInstr["destinataire"] = $this->valF['destinataire']; |
|
|
$valNewInstr["dossier"] = $this->valF['dossier']; |
|
|
$valNewInstr["date_evenement"] = date("d/m/Y"); |
|
|
$new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
|
|
} |
|
|
} |
|
|
|
|
1280 |
// Récupération des paramètres de l'action |
// Récupération des paramètres de l'action |
1281 |
$sql = "SELECT * FROM ".DB_PREFIXE."action |
$sql = "SELECT * FROM ".DB_PREFIXE."action |
1282 |
WHERE action='".$action."'"; |
WHERE action='".$action."'"; |
1288 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
1289 |
// application des regles sur le courrier + delai |
// application des regles sur le courrier + delai |
1290 |
if(preg_match("/date_evenement/",$row['regle_date_limite'])){ |
if(preg_match("/date_evenement/",$row['regle_date_limite'])){ |
1291 |
$valF['date_limite']= $this->regle($row['regle_date_limite']); |
$valF['date_limite']= $this->regle($row['regle_date_limite'], 'regle_date_limite'); |
1292 |
} |
} |
1293 |
if(preg_match("/date_evenement/",$row['regle_date_complet'])){ |
if(preg_match("/date_evenement/",$row['regle_date_complet'])){ |
1294 |
$valF['date_complet']= $this->regle($row['regle_date_complet']); |
$valF['date_complet']= $this->regle($row['regle_date_complet'], 'regle_date_complet'); |
1295 |
} |
} |
1296 |
if(preg_match("/date_evenement/",$row['regle_date_dernier_depot'])){ |
if(preg_match("/date_evenement/",$row['regle_date_dernier_depot'])){ |
1297 |
$valF['date_dernier_depot']= $this->regle($row['regle_date_dernier_depot']); |
$valF['date_dernier_depot']= $this->regle($row['regle_date_dernier_depot'], 'regle_date_dernier_depot'); |
1298 |
} |
} |
1299 |
if(preg_match("/date_evenement/",$row['regle_date_notification_delai'])){ |
if(preg_match("/date_evenement/",$row['regle_date_notification_delai'])){ |
1300 |
$valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']); |
$valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai'], 'regle_date_notification_delai'); |
1301 |
} |
} |
1302 |
if(preg_match("/date_evenement/",$row['regle_date_decision'])){ |
if(preg_match("/date_evenement/",$row['regle_date_decision'])){ |
1303 |
$valF['date_decision']= $this->regle($row['regle_date_decision']); |
$valF['date_decision']= $this->regle($row['regle_date_decision'], 'regle_date_decision'); |
1304 |
} |
} |
1305 |
if(preg_match("/date_evenement/",$row['regle_date_rejet'])){ |
if(preg_match("/date_evenement/",$row['regle_date_rejet'])){ |
1306 |
$valF['date_rejet']= $this->regle($row['regle_date_rejet']); |
$valF['date_rejet']= $this->regle($row['regle_date_rejet'], 'regle_date_rejet'); |
1307 |
} |
} |
1308 |
if(preg_match("/date_evenement/",$row['regle_date_validite'])){ |
if(preg_match("/date_evenement/",$row['regle_date_validite'])){ |
1309 |
$valF['date_validite']= $this->regle($row['regle_date_validite']); |
$valF['date_validite']= $this->regle($row['regle_date_validite'], 'regle_date_validite'); |
1310 |
} |
} |
1311 |
if(preg_match("/date_evenement/",$row['regle_date_chantier'])){ |
if(preg_match("/date_evenement/",$row['regle_date_chantier'])){ |
1312 |
$valF['date_chantier']= $this->regle($row['regle_date_chantier']); |
$valF['date_chantier']= $this->regle($row['regle_date_chantier'], 'regle_date_chantier'); |
1313 |
} |
} |
1314 |
if(preg_match("/date_evenement/",$row['regle_date_achevement'])){ |
if(preg_match("/date_evenement/",$row['regle_date_achevement'])){ |
1315 |
$valF['date_achevement']= $this->regle($row['regle_date_achevement']); |
$valF['date_achevement']= $this->regle($row['regle_date_achevement'], 'regle_date_achevement'); |
1316 |
} |
} |
1317 |
if(preg_match("/date_evenement/",$row['regle_date_conformite'])){ |
if(preg_match("/date_evenement/",$row['regle_date_conformite'])){ |
1318 |
$valF['date_conformite']= $this->regle($row['regle_date_conformite']); |
$valF['date_conformite']= $this->regle($row['regle_date_conformite'], 'regle_date_conformite'); |
1319 |
} |
} |
1320 |
} |
} |
1321 |
// 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 |
1323 |
// On met à jour le dossier |
// On met à jour le dossier |
1324 |
$cle = " dossier='".$this->valF['dossier']."'"; |
$cle = " dossier='".$this->valF['dossier']."'"; |
1325 |
$res1 = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle); |
$res1 = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle); |
1326 |
$this->addToLog("triggerajouterapres(): db->autoexecute(\"".DB_PREFIXE."dossier\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
$this->addToLog("triggermodifierapres(): db->autoexecute(\"".DB_PREFIXE."dossier\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
1327 |
if (database::isError($res1)) { |
if (database::isError($res1)) { |
1328 |
die($res->getMessage()); |
die($res->getMessage()); |
1329 |
} |
} |
1331 |
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
1332 |
} |
} |
1333 |
|
|
1334 |
|
// Récupération de tous les paramètres de l'événement sélectionné |
1335 |
|
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
1336 |
|
WHERE evenement=".$this->valF['evenement']; |
1337 |
|
$res = $db->query($sql); |
1338 |
|
$this->addToLog("triggermodifierapres(): db->query(\"".$sql."\");", VERBOSE_MODE); |
1339 |
|
if (database::isError($res)) { |
1340 |
|
die($res->getMessage()); |
1341 |
|
} |
1342 |
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
1343 |
|
// Si la date de retour signature est éditée on vérifie si il existe un événement automatique |
1344 |
|
if ($this->getVal('date_retour_signature') == "" AND |
1345 |
|
$this->valF['date_retour_signature'] != "" AND |
1346 |
|
$row['evenement_retour_signature'] != "") { |
1347 |
|
$new_instruction = new instruction("]", $db, $DEBUG); |
1348 |
|
// Création d'un tableau avec la liste des champs de l'instruction |
1349 |
|
foreach($new_instruction->champs as $champ) { |
1350 |
|
$valNewInstr[$champ] = ""; |
1351 |
|
} |
1352 |
|
// Définition des valeurs de la nouvelle instruction |
1353 |
|
$valNewInstr["evenement"] = $row['evenement_retour_signature']; |
1354 |
|
$valNewInstr["destinataire"] = $this->valF['destinataire']; |
1355 |
|
$valNewInstr["dossier"] = $this->valF['dossier']; |
1356 |
|
$valNewInstr["date_evenement"] = $this->f->formatDate($this->valF['date_retour_signature']); |
1357 |
|
$valNewInstr["date_envoi_signature"] = $this->f->formatDate($this->valF['date_envoi_signature']); |
1358 |
|
$valNewInstr["date_retour_signature"] = $this->f->formatDate($this->valF['date_retour_signature']); |
1359 |
|
$valNewInstr["date_envoi_rar"] = $this->f->formatDate($this->valF['date_envoi_rar']); |
1360 |
|
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
1361 |
|
$valNewInstr["date_envoi_controle_legalite"] = $this->f->formatDate($this->valF['date_envoi_controle_legalite']); |
1362 |
|
$valNewInstr["date_retour_controle_legalite"] = $this->f->formatDate($this->valF['date_retour_controle_legalite']); |
1363 |
|
$new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
1364 |
|
} |
1365 |
|
// Si la date de retour AR est éditée on vérifie si il existe un événement automatique |
1366 |
|
if ($this->getVal('date_retour_rar') == "" AND |
1367 |
|
$this->valF['date_retour_rar'] != "" AND |
1368 |
|
$row['evenement_retour_ar'] != "" ) { |
1369 |
|
$new_instruction = new instruction("]", $db, $DEBUG); |
1370 |
|
// Création d'un tableau avec la liste des champs de l'instruction |
1371 |
|
foreach($new_instruction->champs as $champ) { |
1372 |
|
$valNewInstr[$champ] = ""; |
1373 |
|
} |
1374 |
|
// Définition des valeurs de la nouvelle instruction |
1375 |
|
$valNewInstr["evenement"] = $row['evenement_retour_ar']; |
1376 |
|
$valNewInstr["destinataire"] = $this->valF['destinataire']; |
1377 |
|
$valNewInstr["dossier"] = $this->valF['dossier']; |
1378 |
|
$valNewInstr["date_evenement"] = $this->f->formatDate($this->valF['date_retour_rar']); |
1379 |
|
$valNewInstr["date_envoi_signature"] = $this->f->formatDate($this->valF['date_envoi_signature']); |
1380 |
|
$valNewInstr["date_retour_signature"] = $this->f->formatDate($this->valF['date_retour_signature']); |
1381 |
|
$valNewInstr["date_envoi_rar"] = $this->f->formatDate($this->valF['date_envoi_rar']); |
1382 |
|
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
1383 |
|
$valNewInstr["date_envoi_controle_legalite"] = $this->f->formatDate($this->valF['date_envoi_controle_legalite']); |
1384 |
|
$valNewInstr["date_retour_controle_legalite"] = $this->f->formatDate($this->valF['date_retour_controle_legalite']); |
1385 |
|
$new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
1386 |
|
} |
1387 |
|
} |
1388 |
|
|
1389 |
/** |
/** |
1390 |
* REFERENTIEL ARRETE |
* REFERENTIEL ARRETE |
1391 |
*/ |
*/ |
1392 |
if ($this->f->getParameter('option_referentiel_arrete') != "") { |
// Si l'option référentiel arrêté est activé et l'événement est de type |
1393 |
|
// arrêté |
1394 |
|
if ($this->f->getParameter('option_referentiel_arrete') != "" AND |
1395 |
|
$type_evmt == "arrete") { |
1396 |
if ($this->valF['date_retour_signature'] != $this->getVal('date_retour_signature')) { |
if ($this->valF['date_retour_signature'] != $this->getVal('date_retour_signature')) { |
1397 |
$msgenque = new MessageEnqueuer(); |
$msgenque = new MessageEnqueuer(); |
1398 |
$sqlArrete = "SELECT instruction.signataire_arrete as \"ws_DA_In_Signataire\", |
$sqlArrete = "SELECT instruction.signataire_arrete as \"ws_DA_In_Signataire\", |
1405 |
'' as \"ws_DA_In_Sigle\", |
'' as \"ws_DA_In_Sigle\", |
1406 |
instruction.etat as \"ws_DA_In_Decision\", |
instruction.etat as \"ws_DA_In_Decision\", |
1407 |
dossier.date_depot as \"ws_DA_In_Dte_Depot_Dem\", |
dossier.date_depot as \"ws_DA_In_Dte_Depot_Dem\", |
1408 |
dossier.terrain_numero as \"ws_DA_In_N_Voie\", |
dossier.terrain_adresse_voie_numero as \"ws_DA_In_N_Voie\", |
1409 |
'' as \"ws_DA_In_Type_Voie\", |
'' as \"ws_DA_In_Type_Voie\", |
1410 |
dossier.complement as \"ws_DA_In_Adresse1\", |
dossier.terrain_adresse_voie as \"ws_DA_In_Adresse1\", |
1411 |
dossier.terrain_adresse_lieu_dit as \"ws_DA_In_Adresse2\", |
dossier.terrain_adresse_lieu_dit as \"ws_DA_In_Adresse2\", |
1412 |
dossier.terrain_adresse_code_postal as \"ws_DA_In_CP\", |
dossier.terrain_adresse_code_postal as \"ws_DA_In_CP\", |
1413 |
dossier.terrain_adresse_localite as \"ws_DA_In_Ville\", |
dossier.terrain_adresse_localite as \"ws_DA_In_Ville\", |
1438 |
donnees_techniques.dossier_instruction = dossier.dossier |
donnees_techniques.dossier_instruction = dossier.dossier |
1439 |
WHERE instruction.instruction = ".$this->valF['instruction']; |
WHERE instruction.instruction = ".$this->valF['instruction']; |
1440 |
$resArrete = $this->db->query($sqlArrete); |
$resArrete = $this->db->query($sqlArrete); |
1441 |
$this->f->addToLog("triggerModifierApres(): db->query(\"".$sqlArrete."\");", VERBOSE_MODE); |
$this->f->addToLog("triggermodifierapres(): db->query(\"".$sqlArrete."\");", VERBOSE_MODE); |
1442 |
if ( database::isError($resArrete)){ |
if ( database::isError($resArrete)){ |
1443 |
die(); |
die(); |
1444 |
} |
} |
1451 |
|
|
1452 |
// Mise à jour des données du dossier d'autorisation |
// Mise à jour des données du dossier d'autorisation |
1453 |
require_once "../obj/dossier_autorisation.class.php"; |
require_once "../obj/dossier_autorisation.class.php"; |
1454 |
$da = new dossier_autorisation($this->getDossierAutorisationFromDossier($this->valF['dossier']), $this->db, DEBUG); |
$da = new dossier_autorisation($this->getNumDemandeAutorFromDossier($this->valF['dossier']), $this->db, DEBUG); |
1455 |
$da->majDossierAutorisation(); |
if($da->majDossierAutorisation() === false) { |
1456 |
} |
$this->addToMessage(_("Erreur lors de la mise a jour des donnees techniques. Contactez votre administrateur.")); |
1457 |
|
$this->correct = false; |
|
/** |
|
|
* Méthode de récupération des métadonnées arrêtés dans la base de données, |
|
|
* les données sont stockés dans l'attribut $this->metadonneesArrete |
|
|
*/ |
|
|
function getArreteMetadata() { |
|
|
$sqlArrete = "SELECT signataire_arrete.nom as \"nomsignataire\", |
|
|
signataire_arrete.qualite as \"qualitesignataire\", |
|
|
instruction.date_evenement as \"datesignaturearrete\", |
|
|
instruction.etat as \"decisionarrete\", |
|
|
dossier.terrain_adresse_voie_numero as \"ap_numrue\", |
|
|
dossier.complement as \"ap_nomdelavoie\", |
|
|
dossier.terrain_adresse_code_postal as \"ap_codepostal\", |
|
|
dossier.terrain_adresse_localite as \"ap_ville\" |
|
|
FROM ".DB_PREFIXE."instruction |
|
|
LEFT JOIN ".DB_PREFIXE."signataire_arrete ON |
|
|
instruction.signataire_arrete = signataire_arrete.signataire_arrete |
|
|
LEFT JOIN ".DB_PREFIXE."dossier ON |
|
|
instruction.dossier = dossier.dossier |
|
|
LEFT JOIN ".DB_PREFIXE."donnees_techniques ON |
|
|
donnees_techniques.dossier_instruction = dossier.dossier |
|
|
WHERE instruction.instruction = ".$this->valF['instruction']; |
|
|
$resArrete = $this->db->query($sqlArrete); |
|
|
$this->f->addToLog("triggerModifierApres(): db->query(\"".$sqlArrete."\");", VERBOSE_MODE); |
|
|
if ( database::isError($resArrete)){ |
|
|
die(); |
|
|
} |
|
|
|
|
|
$this->metadonneesArrete = $resArrete->fetchRow(DB_FETCHMODE_ASSOC); |
|
|
} |
|
|
|
|
|
// Méthodes de récupération des métadonnées arrêté |
|
|
function getNumArrete() { |
|
|
return $this->valF['numero_arrete']; |
|
|
} |
|
|
function getSpecialiteArrete() { |
|
|
return "ADS"; |
|
|
} |
|
|
function getDecisionArrete() { |
|
|
if (empty($this->metadonneesArrete)) { |
|
|
$this->getArreteMetadata(); |
|
|
} |
|
|
return $this->metadonneesArrete["decisionarrete"]; |
|
|
} |
|
|
function getChketatReglementaire() { |
|
|
return ""; |
|
|
} |
|
|
function getChkNotification() { |
|
|
if( isset($this->valF["date_retour_rar"]) ) { |
|
|
return true; |
|
|
} else { |
|
|
return false; |
|
|
} |
|
|
} |
|
|
function getDateNotification() { |
|
|
return date("d/m/Y", strtotime($this->valF["date_retour_rar"])); |
|
|
} |
|
|
function getChkCreationdroit() { |
|
|
return ""; |
|
|
} |
|
|
function getChkPublication() { |
|
|
return ""; |
|
|
} |
|
|
function getDatePublication() { |
|
|
return ""; |
|
|
} |
|
|
function getChkControleLegalite() { |
|
|
if( isset($this->valF["date_retour_controle_legalite"]) ) { |
|
|
return true; |
|
|
} else { |
|
1458 |
return false; |
return false; |
|
} |
|
|
} |
|
|
function getDateSignatureArrete() { |
|
|
return date("d/m/Y", strtotime($this->valF['date_retour_signature'])); |
|
|
} |
|
|
function getNomSignataire() { |
|
|
if (empty($this->metadonneesArrete)) { |
|
|
$this->getArreteMetadata(); |
|
|
} |
|
|
return $this->metadonneesArrete["nomsignataire"]; |
|
|
} |
|
|
function getQualiteSignataire() { |
|
|
if (empty($this->metadonneesArrete)) { |
|
|
$this->getArreteMetadata(); |
|
|
} |
|
|
return $this->metadonneesArrete["qualitesignataire"]; |
|
|
} |
|
|
function getChkDelegation() { |
|
|
return ""; |
|
|
} |
|
|
function getAp_numRue() { |
|
|
if (empty($this->metadonneesArrete)) { |
|
|
$this->getArreteMetadata(); |
|
|
} |
|
|
return $this->metadonneesArrete["ap_numrue"]; |
|
|
} |
|
|
function getAp_nomDeLaVoie() { |
|
|
if (empty($this->metadonneesArrete)) { |
|
|
$this->getArreteMetadata(); |
|
|
} |
|
|
return $this->metadonneesArrete["ap_nomdelavoie"]; |
|
|
} |
|
|
function getAp_codePostal() { |
|
|
if (empty($this->metadonneesArrete)) { |
|
|
$this->getArreteMetadata(); |
|
1459 |
} |
} |
1460 |
return $this->metadonneesArrete["ap_codepostal"]; |
} |
|
} |
|
|
function getAp_ville() { |
|
|
if (empty($this->metadonneesArrete)) { |
|
|
$this->getArreteMetadata(); |
|
|
} |
|
|
return $this->metadonneesArrete["ap_ville"]; |
|
|
} |
|
|
|
|
|
// Fin des méthodes de récupération des métadonnées |
|
1461 |
|
|
1462 |
function triggersupprimer($id,&$db,$val,$DEBUG) { |
function triggersupprimer($id,&$db,$val,$DEBUG) { |
1463 |
/** |
/** |
1465 |
* archive dans le dossier d'instruction avant de supprimer l'événement |
* archive dans le dossier d'instruction avant de supprimer l'événement |
1466 |
* d'instruction |
* d'instruction |
1467 |
*/ |
*/ |
1468 |
// Mise à jour des 4 valeurs modifiées par l'action |
|
1469 |
$valF['delai'] = $val['archive_delai']; |
// Mise à jour des 4 valeurs modifiées par l'action |
1470 |
$valF['accord_tacite'] = $val['archive_accord_tacite']; |
$valF['delai'] = $val['archive_delai']; |
1471 |
$valF['etat'] = $val['archive_etat']; |
$valF['accord_tacite'] = $val['archive_accord_tacite']; |
1472 |
if ($val['archive_avis'] != '') { |
$valF['etat'] = $val['archive_etat']; |
1473 |
$valF['avis_decision'] = $val['archive_avis']; |
if ($val['archive_avis'] != '') { |
1474 |
} else { |
$valF['avis_decision'] = $val['archive_avis']; |
1475 |
$valF['avis_decision'] = NULL; |
} else { |
1476 |
} |
$valF['avis_decision'] = NULL; |
1477 |
// Mise à jour des 10 dates avec la valeur présente dans le formulaire |
} |
1478 |
// de suppression. Si la valeur de la date est vide alors on fixe |
// Mise à jour des 10 dates avec la valeur présente dans le formulaire |
1479 |
// à la valeur NULL |
// de suppression. Si la valeur de la date est vide alors on fixe |
1480 |
// |
// à la valeur NULL |
1481 |
if ($val['archive_date_complet'] != '') { |
// |
1482 |
$valF['date_complet'] = $val['archive_date_complet']; |
if ($val['archive_date_complet'] != '') { |
1483 |
} else { |
$valF['date_complet'] = $val['archive_date_complet']; |
1484 |
$valF['date_complet'] = NULL; |
} else { |
1485 |
} |
$valF['date_complet'] = NULL; |
1486 |
if ($val['archive_date_dernier_depot'] != '') { |
} |
1487 |
$valF['date_dernier_depot'] = $val['archive_date_dernier_depot']; |
if ($val['archive_date_dernier_depot'] != '') { |
1488 |
} else { |
$valF['date_dernier_depot'] = $val['archive_date_dernier_depot']; |
1489 |
$valF['date_dernier_depot'] = NULL; |
} else { |
1490 |
} |
$valF['date_dernier_depot'] = NULL; |
1491 |
if ($val['archive_date_rejet'] != '') { |
} |
1492 |
$valF['date_rejet'] = $val['archive_date_rejet']; |
if ($val['archive_date_rejet'] != '') { |
1493 |
} else { |
$valF['date_rejet'] = $val['archive_date_rejet']; |
1494 |
$valF['date_rejet'] = NULL; |
} else { |
1495 |
} |
$valF['date_rejet'] = NULL; |
1496 |
if ($val['archive_date_limite'] != '') { |
} |
1497 |
$valF['date_limite'] = $val['archive_date_limite']; |
if ($val['archive_date_limite'] != '') { |
1498 |
} else { |
$valF['date_limite'] = $val['archive_date_limite']; |
1499 |
$valF['date_limite'] = NULL; |
} else { |
1500 |
} |
$valF['date_limite'] = NULL; |
1501 |
if ($val['archive_date_notification_delai'] != '') { |
} |
1502 |
$valF['date_notification_delai'] = $val['archive_date_notification_delai']; |
if ($val['archive_date_notification_delai'] != '') { |
1503 |
} else { |
$valF['date_notification_delai'] = $val['archive_date_notification_delai']; |
1504 |
$valF['date_notification_delai'] = NULL; |
} else { |
1505 |
} |
$valF['date_notification_delai'] = NULL; |
1506 |
if ($val['archive_date_decision'] != '') { |
} |
1507 |
$valF['date_decision'] = $val['archive_date_decision']; |
if ($val['archive_date_decision'] != '') { |
1508 |
} else { |
$valF['date_decision'] = $val['archive_date_decision']; |
1509 |
$valF['date_decision'] = NULL; |
} else { |
1510 |
} |
$valF['date_decision'] = NULL; |
1511 |
if ($val['archive_date_validite'] != '') { |
} |
1512 |
$valF['date_validite'] = $val['archive_date_validite']; |
if ($val['archive_date_validite'] != '') { |
1513 |
} else { |
$valF['date_validite'] = $val['archive_date_validite']; |
1514 |
$valF['date_validite'] = NULL; |
} else { |
1515 |
} |
$valF['date_validite'] = NULL; |
1516 |
if ($val['archive_date_achevement'] != '') { |
} |
1517 |
$valF['date_achevement'] = $val['archive_date_achevement']; |
if ($val['archive_date_achevement'] != '') { |
1518 |
} else { |
$valF['date_achevement'] = $val['archive_date_achevement']; |
1519 |
$valF['date_achevement'] = NULL; |
} else { |
1520 |
} |
$valF['date_achevement'] = NULL; |
1521 |
if ($val['archive_date_chantier'] != '') { |
} |
1522 |
$valF['date_chantier'] = $val['archive_date_chantier']; |
if ($val['archive_date_chantier'] != '') { |
1523 |
} else { |
$valF['date_chantier'] = $val['archive_date_chantier']; |
1524 |
$valF['date_chantier'] = NULL; |
} else { |
1525 |
} |
$valF['date_chantier'] = NULL; |
1526 |
if ($val['archive_date_conformite'] != '') { |
} |
1527 |
$valF['date_conformite'] = $val['archive_date_conformite']; |
if ($val['archive_date_conformite'] != '') { |
1528 |
} else { |
$valF['date_conformite'] = $val['archive_date_conformite']; |
1529 |
$valF['date_conformite'] = NULL; |
} else { |
1530 |
} |
$valF['date_conformite'] = NULL; |
1531 |
if ($val['archive_incompletude'] != '') { |
} |
1532 |
$valF['incompletude'] = $val['archive_incompletude']; |
if ($val['archive_incompletude'] != '') { |
1533 |
} else { |
$valF['incompletude'] = $val['archive_incompletude']; |
1534 |
$valF['incompletude'] = NULL; |
} else { |
1535 |
} |
$valF['incompletude'] = NULL; |
1536 |
if ($val['archive_evenement_suivant_tacite'] != '') { |
} |
1537 |
$valF['evenement_suivant_tacite'] = $val['archive_evenement_suivant_tacite']; |
if ($val['archive_evenement_suivant_tacite'] != '') { |
1538 |
} else { |
$valF['evenement_suivant_tacite'] = $val['archive_evenement_suivant_tacite']; |
1539 |
$valF['evenement_suivant_tacite'] = NULL; |
} else { |
1540 |
} |
$valF['evenement_suivant_tacite'] = NULL; |
1541 |
if ($val['archive_evenement_suivant_tacite_incompletude'] != '') { |
} |
1542 |
$valF['evenement_suivant_tacite_incompletude'] = $val['archive_evenement_suivant_tacite_incompletude']; |
if ($val['archive_evenement_suivant_tacite_incompletude'] != '') { |
1543 |
} else { |
$valF['evenement_suivant_tacite_incompletude'] = $val['archive_evenement_suivant_tacite_incompletude']; |
1544 |
$valF['evenement_suivant_tacite_incompletude'] = NULL; |
} else { |
1545 |
} |
$valF['evenement_suivant_tacite_incompletude'] = NULL; |
1546 |
if ($val['archive_etat_pendant_incompletude'] != '') { |
} |
1547 |
$valF['etat_pendant_incompletude'] = $val['archive_etat_pendant_incompletude']; |
if ($val['archive_etat_pendant_incompletude'] != '') { |
1548 |
} else { |
$valF['etat_pendant_incompletude'] = $val['archive_etat_pendant_incompletude']; |
1549 |
$valF['etat_pendant_incompletude'] = NULL; |
} else { |
1550 |
} |
$valF['etat_pendant_incompletude'] = NULL; |
1551 |
if ($val['archive_date_limite_incompletude'] != '') { |
} |
1552 |
$valF['date_limite_incompletude'] = $val['archive_date_limite_incompletude']; |
if ($val['archive_date_limite_incompletude'] != '') { |
1553 |
} else { |
$valF['date_limite_incompletude'] = $val['archive_date_limite_incompletude']; |
1554 |
$valF['date_limite_incompletude'] = NULL; |
} else { |
1555 |
} |
$valF['date_limite_incompletude'] = NULL; |
1556 |
if ($val['archive_delai_incompletude'] != '') { |
} |
1557 |
$valF['delai_incompletude'] = $val['archive_delai_incompletude']; |
if ($val['archive_delai_incompletude'] != '') { |
1558 |
} else { |
$valF['delai_incompletude'] = $val['archive_delai_incompletude']; |
1559 |
$valF['delai_incompletude'] = NULL; |
} else { |
1560 |
} |
$valF['delai_incompletude'] = NULL; |
1561 |
// On met à jour le dossier |
} |
1562 |
$cle = " dossier='".$val['dossier']."'"; |
if ($val['archive_autorite_competente'] != '') { |
1563 |
$res = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle); |
$valF['autorite_competente'] = $val['archive_autorite_competente']; |
1564 |
$this->addToLog("triggersupprimer(): db->autoexecute(\"".DB_PREFIXE."dossier\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
} else { |
1565 |
if (database::isError($res)) { |
$valF['autorite_competente'] = NULL; |
1566 |
die($res->getMessage()); |
} |
1567 |
} |
// On met à jour le dossier |
1568 |
// Affichage d'informations à l'utilisateur |
$cle = " dossier='".$val['dossier']."'"; |
1569 |
$this->addToMessage(_("Suppression de l'instruction")." [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
$res = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle); |
1570 |
|
$this->addToLog("triggersupprimer(): db->autoexecute(\"".DB_PREFIXE."dossier\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
1571 |
|
if (database::isError($res)) { |
1572 |
|
die($res->getMessage()); |
1573 |
|
} |
1574 |
|
// Affichage d'informations à l'utilisateur |
1575 |
|
$this->addToMessage(_("Suppression de l'instruction")." [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
1576 |
|
|
1577 |
|
// Mise à jour de la demande si un récépissé d'instruction correspond à l'instruction à supprimer |
1578 |
} |
} |
1579 |
|
|
1580 |
function triggersupprimerapres($id,&$db,$val,$DEBUG) { |
function triggersupprimerapres($id,&$db,$val,$DEBUG) { |
1581 |
|
|
1582 |
// Mise à jour des données du dossier d'autorisation |
// Mise à jour des données du dossier d'autorisation |
1583 |
require_once "../obj/dossier_autorisation.class.php"; |
require_once "../obj/dossier_autorisation.class.php"; |
1584 |
$da = new dossier_autorisation($this->getDossierAutorisationFromDossier($val["dossier"]), $this->db, DEBUG); |
$da = new dossier_autorisation($this->getNumDemandeAutorFromDossier($val["dossier"]), $this->db, DEBUG); |
1585 |
$da->majDossierAutorisation(); |
if($da->majDossierAutorisation() === false) { |
1586 |
} |
$this->addToMessage(_("Erreur lors de la mise a jour des donnees techniques. Contactez votre administrateur.")); |
1587 |
|
$this->correct = false; |
1588 |
// ============================================= |
return false; |
1589 |
// calcul de date avec ajout de mois (delais) |
} |
|
// [add months (delay) and calculation final date] |
|
|
// LIMITE DE LA FONCTION si delai >24 MOIS |
|
|
// [limit : delay < 24 month] |
|
|
// ============================================= |
|
|
function moisdate($date,$delaimois) { |
|
|
$temp = explode("-" , $date); |
|
|
$jour = (int) $temp[2]; |
|
|
$mois = (int) $temp[1]; |
|
|
$annee = (int) $temp[0]; |
|
|
// calcul si delai superieur à 12 (limite 24) [delay > 24 month] |
|
|
if($delaimois>=12){ |
|
|
$delaimois=$delaimois-12; |
|
|
$annee=$annee+1; |
|
|
} |
|
|
if($delaimois>=12){ |
|
|
$delaimois=$delaimois-12; |
|
|
$annee=$annee+1; |
|
|
} |
|
|
// mois |
|
|
$mois=$mois+$delaimois; |
|
|
// calcul mois annee [calculation number of years if > 12 month] |
|
|
// nb de mois > à 12 |
|
|
if ($mois>12){ |
|
|
$mois=$mois-12; |
|
|
$annee=$annee+1; |
|
|
} |
|
|
// Calcul du nombre de jours dans le mois sélectionné [calculation number of days] |
|
|
switch($mois) { |
|
|
case "2": |
|
|
if ($annee % 4 == 0 && $annee % 100 != 0 || $annee % 400 == 0) |
|
|
$jourmax = 29; |
|
|
else |
|
|
$jourmax = 28; |
|
|
break; |
|
|
case "4": |
|
|
case "6": |
|
|
case "9": |
|
|
case "11": |
|
|
$jourmax = 30; |
|
|
break; |
|
|
default: |
|
|
$jourmax = 31; |
|
|
} |
|
|
if ($jour > $jourmax) |
|
|
$jour = $jourmax; |
|
|
//$dateretour=$annee."-".$mois."-".$jour; |
|
|
return $annee."-".$mois."-".$jour ; |
|
1590 |
} |
} |
1591 |
|
|
1592 |
// Vérifie la restriction sur l'événement |
// Vérifie la restriction sur l'événement |
1594 |
parent::verifier($val, $db, $DEBUG); |
parent::verifier($val, $db, $DEBUG); |
1595 |
|
|
1596 |
if ( isset($val['evenement']) && is_numeric($val['evenement'])){ |
if ( isset($val['evenement']) && is_numeric($val['evenement'])){ |
1597 |
//Récupère la restriction |
//Récupère la restriction |
1598 |
$sql= "SELECT |
$sql= "SELECT |
1599 |
restriction |
restriction |
1600 |
FROM |
FROM |
1611 |
|
|
1612 |
//Test qu'une restriction est présente |
//Test qu'une restriction est présente |
1613 |
if ( isset($row['restriction']) && $row['restriction'] != "" ){ |
if ( isset($row['restriction']) && $row['restriction'] != "" ){ |
1614 |
|
|
1615 |
|
$restriction = $row['restriction']; |
1616 |
|
|
1617 |
//Test si la restriction est valide |
//Test si la restriction est valide |
1618 |
if ( !$this->restrictionIsValid($row['restriction']) ){ |
if ( !$this->restrictionIsValid($restriction) ){ |
1619 |
|
|
1620 |
$this->correct=false; |
$this->correct=false; |
1621 |
$this->addToMessage(_("Restriction non valide")); |
$this->addToMessage(_("Restriction non valide")); |
1624 |
|
|
1625 |
$this->correct = true; |
$this->correct = true; |
1626 |
} |
} |
1627 |
|
|
1628 |
|
// Liste des opérateurs possible |
1629 |
|
$operateurs = array(">=", "<=", "+", "-"); |
1630 |
|
|
1631 |
|
// Supprime tous les espaces de la chaîne de caractère |
1632 |
|
$restriction = str_replace(' ', '', $restriction); |
1633 |
|
|
1634 |
|
// Met des espace avant et après les opérateurs puis transforme la |
1635 |
|
// chaine en un tableau |
1636 |
|
$tabRestriction = str_replace($operateurs, " ", $restriction); |
1637 |
|
// Tableau des champ |
1638 |
|
$tabRestriction = explode(" ", $tabRestriction); |
1639 |
|
// Supprime les numériques du tableau |
1640 |
|
foreach ($tabRestriction as $key => $value) { |
1641 |
|
if (is_numeric($value)) { |
1642 |
|
unset($tabRestriction[$key]); |
1643 |
|
} |
1644 |
|
} |
1645 |
|
|
1646 |
|
// Vérifie les champs utilisés pour la restriction |
1647 |
|
$check_field_exist = $this->f->check_field_exist($tabRestriction, 'instruction'); |
1648 |
|
if ($check_field_exist !== true) { |
1649 |
|
|
1650 |
|
// Liste des champs en erreur |
1651 |
|
$string_error_fields = implode(", ", $check_field_exist); |
1652 |
|
|
1653 |
|
// Message d'erreur |
1654 |
|
$error_message = _("Le champ %s n'est pas utilisable pour le champ %s"); |
1655 |
|
if (count($check_field_exist) > 1) { |
1656 |
|
$error_message = _("Les champs %s ne sont pas utilisable pour le champ %s"); |
1657 |
|
} |
1658 |
|
|
1659 |
|
// Affiche l'erreur |
1660 |
|
$this->correct=false; |
1661 |
|
$this->addToMessage(sprintf($error_message, $string_error_fields, _("restriction"))); |
1662 |
|
$this->addToMessage(_("Veuillez contacter votre administrateur.")); |
1663 |
|
} |
1664 |
} |
} |
1665 |
|
|
1666 |
|
} |
1667 |
|
if(!$this->updateDate("date_envoi_signature")) { |
1668 |
|
return false; |
1669 |
|
} |
1670 |
|
if(!$this->updateDate("date_retour_signature")) { |
1671 |
|
return false; |
1672 |
|
} |
1673 |
|
if(!$this->updateDate("date_envoi_rar")) { |
1674 |
|
return false; |
1675 |
|
} |
1676 |
|
if(!$this->updateDate("date_retour_rar")) { |
1677 |
|
return false; |
1678 |
|
} |
1679 |
|
if(!$this->updateDate("date_envoi_controle_legalite")) { |
1680 |
|
return false; |
1681 |
|
} |
1682 |
|
if(!$this->updateDate("date_retour_controle_legalite")) { |
1683 |
|
return false; |
1684 |
} |
} |
1685 |
|
|
|
$this->updateDate("date_envoi_signature"); |
|
|
$this->updateDate("date_retour_signature"); |
|
|
$this->updateDate("date_envoi_rar"); |
|
|
$this->updateDate("date_retour_rar"); |
|
|
$this->updateDate("date_envoi_controle_legalite"); |
|
|
$this->updateDate("date_retour_controle_legalite"); |
|
1686 |
} |
} |
1687 |
|
|
1688 |
/** |
/** |
1730 |
} |
} |
1731 |
|
|
1732 |
/** |
/** |
1733 |
* Finalisation des documents. |
* Finalisation des documents. |
1734 |
|
* @param string $champ champ du fichier à finaliser |
1735 |
|
* @param booleen $status permet de définir si on finalise ou définalise |
1736 |
|
* @param string $sousform permet de savoir si se trouve dans un sousformulaire (passé au javascript) |
1737 |
*/ |
*/ |
1738 |
function finaliser( $champ = '', $status, $sousform){ |
function finaliser( $champ = '', $status, $sousform, $retourformulaire){ |
1739 |
|
|
1740 |
//Si on finalise le document |
//Si on finalise le document |
1741 |
if ( $status == 1 ){ |
if ( $status == 1 ){ |
1773 |
$uid = $this->getVal("om_fichier_instruction"); |
$uid = $this->getVal("om_fichier_instruction"); |
1774 |
|
|
1775 |
//On dé-finalise avant de finaliser |
//On dé-finalise avant de finaliser |
1776 |
if ( $uid == '' ){ |
if ( $uid == '' || $uid == 'OP_FAILURE' ){ |
1777 |
return -1; |
return -1; |
1778 |
} |
} |
1779 |
} |
} |
1780 |
|
|
1781 |
//Mise à jour des données |
//Mise à jour des données |
1782 |
if ( $uid != '' ){ |
if ( $uid != '' && $uid != 'OP_FAILURE' ){ |
1783 |
// Logger |
// Logger |
1784 |
$this->addToLog("finaliser() - begin", EXTRA_VERBOSE_MODE); |
$this->addToLog("finaliser() - begin", EXTRA_VERBOSE_MODE); |
1785 |
// Recuperation de la valeur de la cle primaire de l'objet |
// Recuperation de la valeur de la cle primaire de l'objet |
1787 |
$id = $this->getVal($this->clePrimaire); |
$id = $this->getVal($this->clePrimaire); |
1788 |
else |
else |
1789 |
$id=$this->id; |
$id=$this->id; |
1790 |
|
|
1791 |
|
$actions = array(); |
1792 |
//Tableau contenant le lien vers le PDF et lien du portlet pour la mise |
//Tableau contenant le lien vers le PDF et lien du portlet pour la mise |
1793 |
//à jour de l'interface |
//à jour de l'interface |
1794 |
if ( $status == 0 ){ |
if ( $status == 0 ){ |
1795 |
$lien = '../app/pdf_instruction.php?idx='.$id; |
$lien = '../app/pdf_instruction.php?idx='.$id; |
1796 |
|
|
1797 |
|
//Ajout des actions |
1798 |
|
//Si l'utilisateur a le droit de modifier l'objet |
1799 |
|
if ( $this->f->isAccredited('instruction') || |
1800 |
|
$this->f->isAccredited('instruction_modifier') ){ |
1801 |
|
|
1802 |
|
$actions["modifier"] = ($sousform!='')? |
1803 |
|
'<li><a href="#" onclick="ajaxIt(\'instruction\', |
1804 |
|
\'../scr/sousform.php?obj=instruction&action=1&idx='. |
1805 |
|
$this->getVal($this->clePrimaire). |
1806 |
|
'&premiersf=0&trisf=&retourformulaire='.$retourformulaire.'&idxformulaire='. |
1807 |
|
$this->getVal("dossier"). |
1808 |
|
'&retour=form\');"> |
1809 |
|
<span class="om-prev-icon om-icon-16 edit-16" title="'. |
1810 |
|
_('Modifier').'">'. |
1811 |
|
_('Modifier'). |
1812 |
|
'</span></a></li>': |
1813 |
|
'<li> |
1814 |
|
<a href="form.php?obj=instruction&action=1'.'&idx='. |
1815 |
|
$this->getVal($this->clePrimaire). |
1816 |
|
'&premier=&advs_id=&recherche=&tricol=&selectioncol=&valide=&retour=form"> |
1817 |
|
<span class="om-prev-icon om-icon-16 edit-16" title="'. |
1818 |
|
_('Modifier').'">'. |
1819 |
|
_('Modifier'). |
1820 |
|
'</span></a></li>'; |
1821 |
|
} |
1822 |
|
//Si l'utilisateur a le droit de supprimer l'objet |
1823 |
|
if ( $this->f->isAccredited('instruction') || |
1824 |
|
$this->f->isAccredited('instruction_supprimer') ){ |
1825 |
|
|
1826 |
|
$actions["supprimer"] = ($sousform!='')? |
1827 |
|
'<li><a href="#" onclick="ajaxIt(\'instruction\', |
1828 |
|
\'../scr/sousform.php?obj=instruction&action=2&idx='. |
1829 |
|
$this->getVal($this->clePrimaire). |
1830 |
|
'&premiersf=0&trisf=&retourformulaire='.$retourformulaire.'&idxformulaire='. |
1831 |
|
$this->getVal("dossier"). |
1832 |
|
'&retour=form\');"> |
1833 |
|
<span class="om-prev-icon om-icon-16 delete-16" title="'. |
1834 |
|
_('Supprimer').'">'. |
1835 |
|
_('Supprimer'). |
1836 |
|
'</span></a></li>': |
1837 |
|
'<li> |
1838 |
|
<a href="form.php?obj=instruction&action=1'.'&idx='. |
1839 |
|
$this->getVal($this->clePrimaire). |
1840 |
|
'&premier=&advs_id=&recherche=&tricol=&selectioncol=&valide=&retour=form"> |
1841 |
|
<span class="om-prev-icon om-icon-16 delete-16" title="'. |
1842 |
|
_('Supprimer').'">'. |
1843 |
|
_('Supprimer'). |
1844 |
|
'</span></a></li>'; |
1845 |
|
} |
1846 |
} |
} |
1847 |
else { |
else { |
1848 |
$lien = '../spg/file.php?obj=instruction&'. |
$lien = '../spg/file.php?obj=instruction&'. |
1852 |
$retour = array( |
$retour = array( |
1853 |
"portlet"=> "<a href=\"#\" onclick=\"finalizeDocument(". |
"portlet"=> "<a href=\"#\" onclick=\"finalizeDocument(". |
1854 |
$id.", 'instruction', '".$sousform."', ".(($status==0)?1:0).")\"> |
$id.", 'instruction', '".$sousform."', ".(($status==0)?1:0).")\"> |
1855 |
<span class=\"om-prev-icon om-icon-16 om-icon-fix delete-16 " |
<span class=\"om-prev-icon om-icon-16 om-icon-fix " |
1856 |
.(($status==1)?"de":"")."finalise\" title=\"". |
.(($status==1)?"de":"")."finalise\" title=\"". |
1857 |
(($status==1)?_("Reprendre la redaction du document"):_("Finaliser le document"))."\">". |
(($status==1)?_("Reprendre la redaction du document"):_("Finaliser le document"))."\">". |
1858 |
(($status==1)?_("Reprendre la redaction du document"):_("Finaliser le document"))."</span> |
(($status==1)?_("Reprendre la redaction du document"):_("Finaliser le document"))."</span> |
1859 |
</a>", |
</a>", |
1860 |
"pdf" => $lien |
"pdf" => $lien, |
1861 |
|
"actions" => $actions |
1862 |
); |
); |
1863 |
|
|
1864 |
foreach ( $this->champs as $key=>$value ) |
foreach ( $this->champs as $key=>$value ) |
1896 |
$this->triggermodifier( $id, $this->db, $this->val, DEBUG); |
$this->triggermodifier( $id, $this->db, $this->val, DEBUG); |
1897 |
$valF = array( |
$valF = array( |
1898 |
"om_final_instruction"=> ($status==1)?TRUE:FALSE, |
"om_final_instruction"=> ($status==1)?TRUE:FALSE, |
1899 |
"om_fichier_instruction"=>$uid); |
"om_fichier_instruction"=>$uid, |
1900 |
|
"date_finalisation_courrier"=>date('Y-m-d')); |
1901 |
// Execution de la requête de modification des donnees de l'attribut |
// Execution de la requête de modification des donnees de l'attribut |
1902 |
// valF de l'objet dans l'attribut table de l'objet |
// valF de l'objet dans l'attribut table de l'objet |
1903 |
$res = $this->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
$res = $this->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
1927 |
} else { |
} else { |
1928 |
// Message d'echec (saut d'une ligne supplementaire avant le |
// Message d'echec (saut d'une ligne supplementaire avant le |
1929 |
// message pour qu'il soit mis en evidence) |
// message pour qu'il soit mis en evidence) |
1930 |
$this->addToLog("Finalisation non enregistree"); |
$this->addToLog(_("Finalisation non enregistree")); |
1931 |
return -1; |
return -1; |
1932 |
} |
} |
1933 |
} |
} |
1938 |
} |
} |
1939 |
|
|
1940 |
/** |
/** |
1941 |
* Finalisation du document lors de l'ajout d'une instruction |
* Récupération du numéro de dossier d'instruction à ajouter aux métadonnées |
1942 |
* |
* @return string numéro de dossier d'instruction |
1943 |
*/ |
*/ |
1944 |
function finaliserAjouter(){ |
protected function getDossier() { |
1945 |
|
if(empty($this->specificMetadata)) { |
1946 |
//Génération du PDF |
$this->getSpecificMetadata(); |
|
$_GET['output'] = "string"; |
|
|
$_GET['obj'] = "instruction"; |
|
|
$_GET['idx'] = $this->valF[$this->clePrimaire]; |
|
|
$f = $this->f; |
|
|
include '../app/pdf_instruction.php'; |
|
|
|
|
|
//Métadonnées du document |
|
|
$metadata = array( |
|
|
'filename' => 'instruction_'.$idx.'.pdf', |
|
|
'mimetype' => 'application/pdf', |
|
|
'size' => strlen($pdf_output) |
|
|
); |
|
|
|
|
|
// Récupération des métadonnées calculées après validation |
|
|
$spe_metadata = $this->getMetadata("om_fichier_instruction"); |
|
|
|
|
|
$metadata = array_merge($metadata, $spe_metadata); |
|
|
|
|
|
//On ajoute le document et on récupère son uid |
|
|
$uid = $this->f->storage->create($pdf_output, $metadata); |
|
|
|
|
|
//Mise à jour des données |
|
|
if ( $uid != '' ){ |
|
|
// Logger |
|
|
$this->addToLog("finaliserAjouter() - begin", EXTRA_VERBOSE_MODE); |
|
|
|
|
|
$valF = array( |
|
|
"om_final_instruction"=> TRUE, |
|
|
"om_fichier_instruction"=>$uid); |
|
|
|
|
|
// Execution de la requête de modification des donnees de l'attribut |
|
|
// valF de l'objet dans l'attribut table de l'objet |
|
|
$res = $this->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
|
|
DB_AUTOQUERY_UPDATE, $this->getCle($idx)); |
|
|
$this->addToLog("finaliserAjouter() : db->autoExecute(\"".DB_PREFIXE.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($idx)."\")", VERBOSE_MODE); |
|
|
// Si une erreur survient |
|
|
if (database::isError($res)) { |
|
|
// Appel de la methode de recuperation des erreurs |
|
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
|
|
} else { |
|
|
// Log |
|
|
$this->addToLog(_("Requete executee"), VERBOSE_MODE); |
|
|
// Log |
|
|
$message = _("Enregistrement")." ".$idx." "; |
|
|
$message .= _("de la table")." \"".$this->table."\" "; |
|
|
$message .= "[ ".$this->db->affectedRows()." "; |
|
|
$message .= _("enregistrement(s) mis a jour")." ]"; |
|
|
$this->addToLog($message, VERBOSE_MODE); |
|
|
} |
|
1947 |
} |
} |
1948 |
|
return $this->specificMetadata->dossier; |
1949 |
} |
} |
|
|
|
1950 |
/** |
/** |
1951 |
* Récupération du numéro de dossier d'instruction à ajouter aux métadonnées |
* Récupération la version du dossier d'instruction à ajouter aux métadonnées |
1952 |
* @return [type] [description] |
* @return int Version |
1953 |
*/ |
*/ |
1954 |
protected function getDossier() { |
protected function getDossierVersion() { |
1955 |
if(empty($this->specificMetadata)) { |
if(empty($this->specificMetadata)) { |
1956 |
$this->getSpecificMetadata(); |
$this->getSpecificMetadata(); |
1957 |
} |
} |
1958 |
return $this->specificMetadata->dossier; |
return $this->specificMetadata->version; |
1959 |
} |
} |
1960 |
/** |
/** |
1961 |
* Récupération du numéro de dossier d'autorisation à ajouter aux métadonnées |
* Récupération du numéro de dossier d'autorisation à ajouter aux métadonnées |
1962 |
* @return [type] [description] |
* @return string numéro de dossier d'autorisation |
1963 |
*/ |
*/ |
1964 |
protected function getDossierAutorisation() { |
protected function getNumDemandeAutor() { |
1965 |
if(empty($this->specificMetadata)) { |
if(empty($this->specificMetadata)) { |
1966 |
$this->getSpecificMetadata(); |
$this->getSpecificMetadata(); |
1967 |
} |
} |
1969 |
} |
} |
1970 |
/** |
/** |
1971 |
* Récupération de la date de demande initiale du dossier à ajouter aux métadonnées |
* Récupération de la date de demande initiale du dossier à ajouter aux métadonnées |
1972 |
* @return [type] [description] |
* @return date de la demande initiale |
1973 |
*/ |
*/ |
1974 |
protected function getDateDemandeInitiale() { |
protected function getAnneemoisDemandeAutor() { |
1975 |
if(empty($this->specificMetadata)) { |
if(empty($this->specificMetadata)) { |
1976 |
$this->getSpecificMetadata(); |
$this->getSpecificMetadata(); |
1977 |
} |
} |
1979 |
} |
} |
1980 |
/** |
/** |
1981 |
* Récupération du type de dossier d'instruction à ajouter aux métadonnées |
* Récupération du type de dossier d'instruction à ajouter aux métadonnées |
1982 |
* @return [type] [description] |
* @return string type du dossier d'instruction |
1983 |
*/ |
*/ |
1984 |
protected function getDossierInstructionType() { |
protected function getTypeInstruction() { |
1985 |
if(empty($this->specificMetadata)) { |
if(empty($this->specificMetadata)) { |
1986 |
$this->getSpecificMetadata(); |
$this->getSpecificMetadata(); |
1987 |
} |
} |
1989 |
} |
} |
1990 |
/** |
/** |
1991 |
* Récupération du statut du dossier d'autorisation à ajouter aux métadonnées |
* Récupération du statut du dossier d'autorisation à ajouter aux métadonnées |
1992 |
* @return [type] [description] |
* @return string avis |
1993 |
*/ |
*/ |
1994 |
protected function getStatut() { |
protected function getStatutAutorisation() { |
1995 |
if(empty($this->specificMetadata)) { |
if(empty($this->specificMetadata)) { |
1996 |
$this->getSpecificMetadata(); |
$this->getSpecificMetadata(); |
1997 |
} |
} |
1999 |
} |
} |
2000 |
/** |
/** |
2001 |
* Récupération du type de dossier d'autorisation à ajouter aux métadonnées |
* Récupération du type de dossier d'autorisation à ajouter aux métadonnées |
2002 |
* @return [type] [description] |
* @return string type du dossier d'autorisation |
2003 |
*/ |
*/ |
2004 |
protected function getDossierAutorisationType() { |
protected function getTypeAutorisation() { |
2005 |
if(empty($this->specificMetadata)) { |
if(empty($this->specificMetadata)) { |
2006 |
$this->getSpecificMetadata(); |
$this->getSpecificMetadata(); |
2007 |
} |
} |
2009 |
} |
} |
2010 |
/** |
/** |
2011 |
* Récupération de la date d'ajout de document à ajouter aux métadonnées |
* Récupération de la date d'ajout de document à ajouter aux métadonnées |
2012 |
* @return [type] [description] |
* @return date de l'évènement |
2013 |
*/ |
*/ |
2014 |
protected function getDateEvenement() { |
protected function getDateEvenementDocument() { |
2015 |
return date("d/m/Y"); |
return date("Y-m-d"); |
2016 |
} |
} |
2017 |
/** |
/** |
2018 |
* Récupération du groupe d'instruction à ajouter aux métadonnées |
* Récupération du groupe d'instruction à ajouter aux métadonnées |
2024 |
} |
} |
2025 |
return $this->specificMetadata->groupe_instruction; |
return $this->specificMetadata->groupe_instruction; |
2026 |
} |
} |
2027 |
|
/** |
2028 |
|
* Récupération du libellé du type du document à ajouter aux métadonnées |
2029 |
|
* @return string Groupe d'instruction |
2030 |
|
*/ |
2031 |
|
protected function getTitle() { |
2032 |
|
|
2033 |
|
// Récupère le champ événement |
2034 |
|
if (isset($this->valF["evenement"]) AND $this->valF["evenement"] != "") { |
2035 |
|
$evenement = $this->valF["evenement"]; |
2036 |
|
} else { |
2037 |
|
$evenement = $this->getVal("evenement"); |
2038 |
|
} |
2039 |
|
|
2040 |
|
// Requête sql |
2041 |
|
$sql = "SELECT libelle FROM ".DB_PREFIXE."evenement |
2042 |
|
WHERE evenement=".$evenement; |
2043 |
|
$evenement_libelle = $this->db->getOne($sql); |
2044 |
|
$this->addToLog("getTitle(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
2045 |
|
if (database::isError($evenement_libelle)) { |
2046 |
|
die(); |
2047 |
|
} |
2048 |
|
|
2049 |
|
// Retourne le libelle de l'événement |
2050 |
|
return $evenement_libelle; |
2051 |
|
} |
2052 |
|
|
2053 |
/** |
/** |
2054 |
* Cette méthode permet de stocker en attribut toutes les métadonnées |
* Cette méthode permet de stocker en attribut toutes les métadonnées |
2083 |
ON dossier_autorisation_type.groupe = groupe.groupe |
ON dossier_autorisation_type.groupe = groupe.groupe |
2084 |
WHERE dossier.dossier = '".$dossier."'"; |
WHERE dossier.dossier = '".$dossier."'"; |
2085 |
$res = $this->db->query($sql); |
$res = $this->db->query($sql); |
2086 |
$this->f->addToLog("obj/document_numerise.class.php : db->query(".$sql.")", VERBOSE_MODE); |
$this->f->addToLog("getSpecificMetadata() : db->query(".$sql.")", VERBOSE_MODE); |
2087 |
if ( database::isError($res)){ |
if ( database::isError($res)){ |
2088 |
die(); |
die(); |
2089 |
} |
} |
2093 |
|
|
2094 |
//Si il y a un résultat |
//Si il y a un résultat |
2095 |
if ($row !== null) { |
if ($row !== null) { |
2096 |
|
|
2097 |
|
//Génération du numéro de version |
2098 |
|
$sql = "SELECT |
2099 |
|
count(*) |
2100 |
|
FROM |
2101 |
|
".DB_PREFIXE."dossier |
2102 |
|
LEFT JOIN |
2103 |
|
".DB_PREFIXE."dossier_autorisation |
2104 |
|
ON |
2105 |
|
dossier_autorisation.dossier_autorisation = dossier.dossier_autorisation |
2106 |
|
LEFT JOIN |
2107 |
|
".DB_PREFIXE."dossier_instruction_type |
2108 |
|
ON |
2109 |
|
dossier_instruction_type.dossier_instruction_type = dossier.dossier_instruction_type |
2110 |
|
WHERE |
2111 |
|
dossier_autorisation.dossier_autorisation = '".$row->dossier_autorisation."' |
2112 |
|
AND |
2113 |
|
dossier_instruction_type.code = '".$row->dossier_instruction_type."'"; |
2114 |
|
$row->version = $this->db->getOne($sql); |
2115 |
|
$this->f->addToLog("getSpecificMetadata(): db->getOne(\"".$sql."\")", VERBOSE_MODE); |
2116 |
|
if ( database::isError($row->version)){ |
2117 |
|
$this->f->addToError("", $row->version, $row->version); |
2118 |
|
return false; |
2119 |
|
} |
2120 |
|
|
2121 |
|
//Formatage du numéro de version |
2122 |
|
$row->version = str_pad($row->version, 2, "0", STR_PAD_LEFT); |
2123 |
|
|
2124 |
//Alors on créé l'objet dossier_instruction |
//Alors on créé l'objet dossier_instruction |
2125 |
$this->specificMetadata = $row; |
$this->specificMetadata = $row; |
2126 |
|
|
2127 |
} |
} |
2128 |
} |
} |
2129 |
|
|
2130 |
|
/** |
2131 |
|
* Retourne le statut du dossier d'instruction |
2132 |
|
* @param string $idx Identifiant du dossier d'instruction |
2133 |
|
* @return string Le statut du dossier d'instruction |
2134 |
|
*/ |
2135 |
|
function getStatutAutorisationDossier($idx){ |
2136 |
|
|
2137 |
|
$statut = ''; |
2138 |
|
|
2139 |
|
//Si l'identifiant du dossier d'instruction fourni est correct |
2140 |
|
if ( $idx != '' ){ |
2141 |
|
|
2142 |
|
//On récupère le statut de l'état du dossier à partir de l'identifiant du |
2143 |
|
//dossier |
2144 |
|
$sql = "SELECT etat.statut |
2145 |
|
FROM ".DB_PREFIXE."dossier |
2146 |
|
LEFT JOIN |
2147 |
|
".DB_PREFIXE."etat |
2148 |
|
ON |
2149 |
|
dossier.etat = etat.etat |
2150 |
|
WHERE dossier ='".$idx."'"; |
2151 |
|
$statut = $this->db->getOne($sql); |
2152 |
|
$this->f->addToLog("getStatutAutorisationDossier() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
2153 |
|
if ( database::isError($statut)){ |
2154 |
|
die(); |
2155 |
|
} |
2156 |
|
} |
2157 |
|
return $statut; |
2158 |
|
} |
2159 |
|
|
2160 |
|
/** |
2161 |
|
* Récupère les données du dossier |
2162 |
|
* @return array |
2163 |
|
*/ |
2164 |
|
function get_dossier_actual() { |
2165 |
|
|
2166 |
|
// Initialisation de la valeur de retour |
2167 |
|
$return = array(); |
2168 |
|
|
2169 |
|
// Récupération de toutes les valeurs du dossier d'instruction en cours |
2170 |
|
$sql = "SELECT * FROM ".DB_PREFIXE."dossier |
2171 |
|
WHERE dossier='".$this->valF['dossier']."'"; |
2172 |
|
$res = $this->db->query($sql); |
2173 |
|
$this->addToLog("get_dossier_actual(): db->query(\"".$sql."\");", VERBOSE_MODE); |
2174 |
|
$this->f->isDatabaseError($res); |
2175 |
|
|
2176 |
|
// |
2177 |
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
2178 |
|
|
2179 |
|
// Récupération de la valeur actuelle du délai, de l'accord tacite, |
2180 |
|
// de l'état et de l'avis du dossier d'instruction |
2181 |
|
$return['archive_delai']=$row['delai']; |
2182 |
|
$return['archive_accord_tacite']=$row['accord_tacite']; |
2183 |
|
$return['archive_etat']=$row['etat']; |
2184 |
|
$return['archive_avis']=$row['avis_decision']; |
2185 |
|
// Récupération de la valeur actuelle des 9 dates du dossier |
2186 |
|
// d'instruction |
2187 |
|
$return['archive_date_complet']=$row['date_complet']; |
2188 |
|
$return['archive_date_dernier_depot']=$row['date_dernier_depot']; |
2189 |
|
$return['archive_date_rejet']= $row['date_rejet']; |
2190 |
|
$return['archive_date_limite']= $row['date_limite']; |
2191 |
|
$return['archive_date_notification_delai']= $row['date_notification_delai']; |
2192 |
|
$return['archive_date_decision']= $row['date_decision']; |
2193 |
|
$return['archive_date_validite']= $row['date_validite']; |
2194 |
|
$return['archive_date_achevement']= $row['date_achevement']; |
2195 |
|
$return['archive_date_chantier']= $row['date_chantier']; |
2196 |
|
$return['archive_date_conformite']= $row['date_conformite']; |
2197 |
|
$return['archive_incompletude']= $row['incompletude']; |
2198 |
|
$return['archive_evenement_suivant_tacite']= $row['evenement_suivant_tacite']; |
2199 |
|
$return['archive_evenement_suivant_tacite_incompletude']= $row['evenement_suivant_tacite_incompletude']; |
2200 |
|
$return['archive_etat_pendant_incompletude']= $row['etat_pendant_incompletude']; |
2201 |
|
$return['archive_date_limite_incompletude']= $row['date_limite_incompletude']; |
2202 |
|
$return['archive_delai_incompletude']= $row['delai_incompletude']; |
2203 |
|
$return['archive_autorite_competente']= $row['autorite_competente']; |
2204 |
|
$return['duree_validite']= $row['duree_validite']; |
2205 |
|
} |
2206 |
|
|
2207 |
|
// Retour de la fonction |
2208 |
|
return $return; |
2209 |
|
|
2210 |
|
} |
2211 |
|
|
2212 |
|
/** |
2213 |
|
* Permet de vérifier qu'un événement est verrouillable |
2214 |
|
* @param integer $idx Identifiant de l'instruction |
2215 |
|
* @return boolean |
2216 |
|
*/ |
2217 |
|
function checkEvenementNonVerrouillable($idx) { |
2218 |
|
|
2219 |
|
// Initialisation du résultat |
2220 |
|
$non_verrouillable = false; |
2221 |
|
|
2222 |
|
// Si la condition n'est pas vide |
2223 |
|
if ($idx != "") { |
2224 |
|
|
2225 |
|
// Requête SQL |
2226 |
|
$sql = "SELECT evenement.non_verrouillable |
2227 |
|
FROM ".DB_PREFIXE."evenement |
2228 |
|
LEFT JOIN ".DB_PREFIXE."instruction |
2229 |
|
ON instruction.evenement = evenement.evenement |
2230 |
|
WHERE instruction.instruction = $idx"; |
2231 |
|
$this->f->addToLog("checkEvenementNonVerrouillable() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
2232 |
|
$res = $this->db->getOne($sql); |
2233 |
|
$this->f->isDatabaseError($res); |
2234 |
|
|
2235 |
|
// Si le retour de la requête est true |
2236 |
|
if ($res == 't') { |
2237 |
|
// |
2238 |
|
$non_verrouillable = true; |
2239 |
|
} |
2240 |
|
} |
2241 |
|
|
2242 |
|
// Retourne résultat |
2243 |
|
return $non_verrouillable; |
2244 |
|
} |
2245 |
|
|
2246 |
|
/** |
2247 |
|
* Mise à jour des champs archive_* |
2248 |
|
* @param mixed $row La ligne de données |
2249 |
|
*/ |
2250 |
|
public function updateArchiveData($row){ |
2251 |
|
|
2252 |
|
// Récupération de la valeur actuelle du délai, de l'accord tacite, |
2253 |
|
// de l'état et de l'avis du dossier d'instruction |
2254 |
|
$this->valF['archive_delai']=$row['delai']; |
2255 |
|
$this->valF['archive_accord_tacite']=$row['accord_tacite']; |
2256 |
|
$this->valF['archive_etat']=$row['etat']; |
2257 |
|
$this->valF['archive_avis']=$row['avis_decision']; |
2258 |
|
// Récupération de la valeur actuelle des 9 dates du dossier |
2259 |
|
// d'instruction |
2260 |
|
if ($row['date_complet'] != '') { |
2261 |
|
$this->valF['archive_date_complet']=$row['date_complet']; |
2262 |
|
} |
2263 |
|
if ($row['date_dernier_depot'] != '') { |
2264 |
|
$this->valF['archive_date_dernier_depot']=$row['date_dernier_depot']; |
2265 |
|
} |
2266 |
|
if ($row['date_rejet']!='') { |
2267 |
|
$this->valF['archive_date_rejet']= $row['date_rejet']; |
2268 |
|
} |
2269 |
|
if ($row['date_limite']!='') { |
2270 |
|
$this->valF['archive_date_limite']= $row['date_limite']; |
2271 |
|
} |
2272 |
|
if ($row['date_notification_delai']!='') { |
2273 |
|
$this->valF['archive_date_notification_delai']= $row['date_notification_delai']; |
2274 |
|
} |
2275 |
|
if ($row['date_decision']!='') { |
2276 |
|
$this->valF['archive_date_decision']= $row['date_decision']; |
2277 |
|
} |
2278 |
|
if ($row['date_validite']!='') { |
2279 |
|
$this->valF['archive_date_validite']= $row['date_validite']; |
2280 |
|
} |
2281 |
|
if ($row['date_achevement']!='') { |
2282 |
|
$this->valF['archive_date_achevement']= $row['date_achevement']; |
2283 |
|
} |
2284 |
|
if ($row['date_chantier']!='') { |
2285 |
|
$this->valF['archive_date_chantier']= $row['date_chantier']; |
2286 |
|
} |
2287 |
|
if ($row['date_conformite']!='') { |
2288 |
|
$this->valF['archive_date_conformite']= $row['date_conformite']; |
2289 |
|
} |
2290 |
|
if ($row['incompletude']!='') { |
2291 |
|
$this->valF['archive_incompletude']= $row['incompletude']; |
2292 |
|
} |
2293 |
|
if ($row['evenement_suivant_tacite']!='') { |
2294 |
|
$this->valF['archive_evenement_suivant_tacite']= $row['evenement_suivant_tacite']; |
2295 |
|
} |
2296 |
|
if ($row['evenement_suivant_tacite_incompletude']!='') { |
2297 |
|
$this->valF['archive_evenement_suivant_tacite_incompletude']= $row['evenement_suivant_tacite_incompletude']; |
2298 |
|
} |
2299 |
|
if ($row['etat_pendant_incompletude']!='') { |
2300 |
|
$this->valF['archive_etat_pendant_incompletude']= $row['etat_pendant_incompletude']; |
2301 |
|
} |
2302 |
|
if ($row['date_limite_incompletude']!='') { |
2303 |
|
$this->valF['archive_date_limite_incompletude']= $row['date_limite_incompletude']; |
2304 |
|
} |
2305 |
|
if ($row['delai_incompletude']!='') { |
2306 |
|
$this->valF['archive_delai_incompletude']= $row['delai_incompletude']; |
2307 |
|
} |
2308 |
|
if ($row['autorite_competente']!='') { |
2309 |
|
$this->valF['archive_autorite_competente']= $row['autorite_competente']; |
2310 |
|
} |
2311 |
|
if ($row['duree_validite']!='') { |
2312 |
|
$this->valF['duree_validite']= $row['duree_validite']; |
2313 |
|
} |
2314 |
|
} |
2315 |
}// fin classe |
}// fin classe |
2316 |
?> |
?> |