1 |
<?php |
<?php |
2 |
//$Id$ |
/** |
3 |
//gen openMairie le 10/02/2011 20:34 |
* |
4 |
/* |
* |
5 |
$Id: instruction.class.php,v 1.29 2010-10-27 10:52:20 fraynaud Exp $ |
* specific : |
6 |
specific : |
* - cle secondaire |
7 |
- cle secondaire |
* destruction autorisée que pour le dernier evenement |
8 |
destruction autorisée que pour le dernier evenement |
* [delete the last event ] |
9 |
[delete the last event ] |
* - variable globale [global variables] |
10 |
- variable globale [global variables] |
* var $archive_date_depot; |
11 |
var $archive_date_depot; |
* var $retourformulaire; |
12 |
var $retourformulaire; |
* var $idxformulaire; |
13 |
var $idxformulaire; |
* - modification des données dans dossier trigger avant |
14 |
- modification des données dans dossier trigger avant |
* [modify dossier data with trigger function] |
15 |
[modify dossier data with trigger function] |
* - function moisdate : pour ajouter des mois a une date |
16 |
- function moisdate : pour ajouter des mois a une date |
* [add months (delay) and calculation final date] |
17 |
[add months (delay) and calculation final date] |
* - voir script_lang.js : bible ... |
18 |
- voir script_lang.js : bible ... |
* |
19 |
*/ |
* @package openfoncier |
20 |
require_once ("../gen/obj/instruction.class.php"); |
* @version SVN : $Id$ |
21 |
require_once("../services/outgoing/messageenqueuer.php"); |
*/ |
22 |
|
|
23 |
|
// |
24 |
|
require_once "../gen/obj/instruction.class.php"; |
25 |
|
|
26 |
|
// |
27 |
|
require_once "../services/outgoing/messageenqueuer.php"; |
28 |
|
|
29 |
|
// |
30 |
class instruction extends instruction_gen { |
class instruction extends instruction_gen { |
31 |
|
|
32 |
var $archive_date_depot; // specific |
var $archive_date_depot; // specific |
33 |
var $retourformulaire; // specific |
var $retourformulaire; // specific |
34 |
var $idxformulaire; // specific |
var $idxformulaire; // specific |
35 |
|
|
36 |
function instruction($id,&$db,$debug) { |
function instruction($id, &$db, $debug) { |
37 |
$this->constructeur($id,$db,$debug); |
$this->constructeur($id, $db, $debug); |
38 |
}// fin constructeur |
} |
39 |
|
|
40 |
// {{{ Gestion de la confidentialité des données spécifiques |
// {{{ Gestion de la confidentialité des données spécifiques |
41 |
|
|
45 |
function checkAccessibility() { |
function checkAccessibility() { |
46 |
// |
// |
47 |
parent::checkAccessibility(); |
parent::checkAccessibility(); |
48 |
// Si l'utilisateur est un intructeur qui en correspond pas à la |
// Si l'utilisateur est un intructeur qui ne correspond pas à la |
49 |
// division du dossier |
// division du dossier |
50 |
if ($this->f->isUserInstructeur() |
if ($this->f->isUserInstructeur() |
51 |
&& isset($this->f->om_utilisateur["division"]) |
&& isset($this->f->om_utilisateur["division"]) |
101 |
|
|
102 |
// }}} |
// }}} |
103 |
|
|
104 |
function cleSecondaire($id,&$db,$val,$DEBUG) { |
function setType(&$form, $maj) { |
105 |
parent::cleSecondaire($id,$db,$val,$DEBUG); |
// |
106 |
// controle suppression cle secondaire [secondary key delete control] |
parent::setType($form, $maj); |
107 |
// ------------------------------------------------------------------------------------ |
// On cache tous les champs |
108 |
// specifique detruire que le dernier [specific instruction : delete the last event ] |
// XXX |
|
// ------------------------------------------------------------------------------------ |
|
|
$dernierevenement=''; |
|
|
$sql="select max(instruction) from ".DB_PREFIXE."instruction where dossier ='". |
|
|
$this->idxformulaire."'"; |
|
|
$dernierevenement = $db->getOne($sql); |
|
|
if($dernierevenement==$id){ |
|
|
$this->correct=true; |
|
|
$this->addToMessage(_('Destruction_chronologique')); |
|
|
}else{ |
|
|
$this->addToMessage(_('Destruction_evenement')." : ".$dernierevenement); |
|
|
$this->addToMessage(_('Destruction_chronologique')); |
|
|
$this->correct=false; |
|
|
} |
|
|
} |
|
|
|
|
|
// Sélectionne le signataire_arrete par défaut |
|
|
function setVal(&$form,$maj,$validation){ |
|
|
|
|
|
// Ajout |
|
|
if($maj == 0) { |
|
|
|
|
|
// Création de la requête |
|
|
$sql = "SELECT signataire_arrete |
|
|
FROM ".DB_PREFIXE."signataire_arrete |
|
|
WHERE defaut IS TRUE"; |
|
|
|
|
|
// Exécution de la requête |
|
|
$this->f->addToLog("deleteAllLienDossierInstructionTypeEvenementEvenement(): db->query(\"".$sql."\");", VERBOSE_MODE); |
|
|
$res = $this->f->db->query($sql); |
|
|
$this->f->isDatabaseError(); |
|
|
|
|
|
$row = $res->fetchrow(DB_FETCHMODE_ASSOC); |
|
|
|
|
|
if ( isset($row['signataire_arrete']) && is_numeric($row['signataire_arrete'])){ |
|
|
|
|
|
$form->setVal("signataire_arrete",$row['signataire_arrete']); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
/*Met des valeurs par défaut dans certains des sous-formulaire*/ |
|
|
function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire){ |
|
|
if ($validation==0 and $maj<2) { |
|
|
if ($maj == 0){ |
|
|
$form->setVal("destinataire", $idxformulaire); |
|
|
$form->setVal("dossier", $idxformulaire); |
|
|
$form->setVal("date_evenement", date('Y-m-d')); |
|
|
} |
|
|
$form->setVal("bible_auto","bible_auto()"); |
|
|
$form->setVal("bible","bible()"); |
|
|
$form->setVal("bible2","bible2()"); |
|
|
} |
|
|
$this->retourformulaire=$retourformulaire; |
|
|
$this->idxformulaire=$idxformulaire; |
|
|
} |
|
|
|
|
|
/*Affecte un type à certains champs*/ |
|
|
function setType(&$form,$maj) { |
|
|
parent::setType($form,$maj); |
|
|
if ($maj < 2) { //ajouter et modifier |
|
|
$form->setType('destinataire', 'hidden'); |
|
|
$form->setType('lettretype', 'hiddenstatic'); |
|
|
$form->setType('complement', 'textarea'); |
|
|
$form->setType('complement2', 'textarea'); |
|
|
$form->setType('bible_auto', 'httpclick'); |
|
|
$form->setType('bible', 'httpclick'); |
|
|
$form->setType('bible2', 'httpclick'); |
|
|
$form->setType('dossier', 'hidden'); |
|
|
$form->setType('libelle', 'hiddenstatic'); |
|
|
$form->setType('signataire_arrete','select'); |
|
|
if($maj==0){ // add |
|
|
$form->setType('instruction', 'hiddenstatic'); |
|
|
$form->setType('evenement', 'select'); |
|
|
$form->setType('date_evenement', 'date2'); |
|
|
}else{ // modify |
|
|
$form->setType('instruction', 'hiddenstatic'); |
|
|
$form->setType('evenement', 'hiddenstatic'); |
|
|
//$form->setType('date_evenement', 'hiddenstaticdate'); |
|
|
$form->setType('date_evenement', 'date2'); |
|
|
// necessaire pour calcul de date en modification |
|
|
$form->setType('delai', 'hiddenstatic'); |
|
|
} |
|
|
} elseif($maj==2){ |
|
|
$form->setType('dossier', 'hidden'); |
|
|
$form->setType('bible_auto', 'hidden'); |
|
|
$form->setType('bible', 'hidden'); |
|
|
$form->setType('bible2', 'hidden'); |
|
|
}else { |
|
|
$form->setType('destinataire', 'hidden'); |
|
|
$form->setType('dossier', 'hidden'); |
|
|
$form->setType('bible_auto', 'hidden'); |
|
|
$form->setType('bible', 'hidden'); |
|
|
$form->setType('bible2', 'hidden'); |
|
|
} |
|
109 |
$form->setType('complement3', 'hidden'); |
$form->setType('complement3', 'hidden'); |
110 |
$form->setType('bible3', 'hidden'); |
$form->setType('bible3', 'hidden'); |
111 |
$form->setType('complement4', 'hidden'); |
$form->setType('complement4', 'hidden'); |
132 |
$form->setType('bible14', 'hidden'); |
$form->setType('bible14', 'hidden'); |
133 |
$form->setType('complement15', 'hidden'); |
$form->setType('complement15', 'hidden'); |
134 |
$form->setType('bible15', 'hidden'); |
$form->setType('bible15', 'hidden'); |
135 |
|
// |
136 |
$form->setType('delai', 'hidden'); |
$form->setType('delai', 'hidden'); |
137 |
$form->setType('etat', 'hidden'); |
$form->setType('etat', 'hidden'); |
138 |
$form->setType('accord_tacite', 'hidden'); |
$form->setType('accord_tacite', 'hidden'); |
139 |
$form->setType('action', 'hidden'); |
$form->setType('action', 'hidden'); |
140 |
$form->setType('delai_notification', 'hidden'); |
$form->setType('delai_notification', 'hidden'); |
141 |
$form->setType('avis_decision', 'hidden'); |
$form->setType('avis_decision', 'hidden'); |
142 |
|
// |
143 |
$form->setType('archive_delai', 'hidden'); |
$form->setType('archive_delai', 'hidden'); |
144 |
$form->setType('archive_etat', 'hidden'); |
$form->setType('archive_etat', 'hidden'); |
145 |
$form->setType('archive_accord_tacite', 'hidden'); |
$form->setType('archive_accord_tacite', 'hidden'); |
153 |
$form->setType('archive_date_achevement', 'hidden'); |
$form->setType('archive_date_achevement', 'hidden'); |
154 |
$form->setType('archive_date_conformite', 'hidden'); |
$form->setType('archive_date_conformite', 'hidden'); |
155 |
$form->setType('archive_date_chantier', 'hidden'); |
$form->setType('archive_date_chantier', 'hidden'); |
156 |
|
// |
157 |
$form->setType('numero_arrete', 'hidden'); |
$form->setType('numero_arrete', 'hidden'); |
158 |
|
|
159 |
|
// |
160 |
|
if ($maj < 2) { //ajouter et modifier |
161 |
|
$form->setType('destinataire', 'hidden'); |
162 |
|
$form->setType('lettretype', 'hiddenstatic'); |
163 |
|
$form->setType('complement', 'textarea'); |
164 |
|
$form->setType('complement2', 'textarea'); |
165 |
|
$form->setType('bible_auto', 'httpclick'); |
166 |
|
$form->setType('bible', 'httpclick'); |
167 |
|
$form->setType('bible2', 'httpclick'); |
168 |
|
$form->setType('dossier', 'hidden'); |
169 |
|
$form->setType('libelle', 'hiddenstatic'); |
170 |
|
$form->setType('signataire_arrete','select'); |
171 |
|
if($maj==0){ // add |
172 |
|
$form->setType('instruction', 'hiddenstatic'); |
173 |
|
$form->setType('evenement', 'select'); |
174 |
|
$form->setType('date_evenement', 'date2'); |
175 |
|
}else{ // modify |
176 |
|
$form->setType('instruction', 'hiddenstatic'); |
177 |
|
$form->setType('evenement', 'selecthiddenstatic'); |
178 |
|
//$form->setType('date_evenement', 'hiddenstaticdate'); |
179 |
|
$form->setType('date_evenement', 'date2'); |
180 |
|
// necessaire pour calcul de date en modification |
181 |
|
//$form->setType('delai', 'hiddenstatic'); |
182 |
|
} |
183 |
|
} elseif($maj==2){ |
184 |
|
$form->setType('dossier', 'hidden'); |
185 |
|
$form->setType('bible_auto', 'hidden'); |
186 |
|
$form->setType('bible', 'hidden'); |
187 |
|
$form->setType('bible2', 'hidden'); |
188 |
|
}else { |
189 |
|
$form->setType('destinataire', 'hidden'); |
190 |
|
$form->setType('dossier', 'hidden'); |
191 |
|
$form->setType('bible_auto', 'hidden'); |
192 |
|
$form->setType('bible', 'hidden'); |
193 |
|
$form->setType('bible2', 'hidden'); |
194 |
|
} |
195 |
} |
} |
196 |
|
|
197 |
/*Met des valeurs choisies dans certains select du formulaire*/ |
function setSelect(&$form, $maj,&$db,$debug) { |
198 |
function setSelect(&$form, $maj,&$db,$DEBUG) { |
/** |
199 |
|
* On ne surcharge pas la méthode parent car une requête sur la table |
200 |
|
* dossier est mauvaise pour les performances, car la requête qui |
201 |
|
* concerne evenement est plus complexe que celle générée et car les |
202 |
|
* champs action, avis_decision et etat ne sont pas utilisés comme des |
203 |
|
* select |
204 |
|
*/ |
205 |
if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php")) |
if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php")) |
206 |
include ("../sql/".$db->phptype."/".$this->table.".form.inc.php"); |
include ("../sql/".$db->phptype."/".$this->table.".form.inc.php"); |
207 |
|
elseif(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc")) |
208 |
|
include ("../sql/".$db->phptype."/".$this->table.".form.inc"); |
209 |
|
|
210 |
parent::setSelect($form, $maj, $db, $DEBUG); |
//// action |
211 |
|
//$this->init_select($form, $db, $maj, $debug, "action", |
212 |
// *** evenement *** |
// $sql_action, $sql_action_by_id, false); |
213 |
$contenu=array(); |
|
214 |
// etat du dossier |
//// avis_decision |
215 |
$sql="select etat from ".DB_PREFIXE."dossier where dossier ='". |
//$this->init_select($form, $db, $maj, $debug, "avis_decision", |
216 |
$this->idxformulaire."'"; |
// $sql_avis_decision, $sql_avis_decision_by_id, false); |
217 |
$etat_dossier = $db->getOne($sql); |
|
218 |
// nature du dossier d'autorisation |
//// dossier |
219 |
$sql="select code from ".DB_PREFIXE."dossier |
//$this->init_select($form, $db, $maj, $debug, "dossier", |
220 |
INNER JOIN ".DB_PREFIXE."dossier_autorisation ON |
// $sql_dossier, $sql_dossier_by_id, false); |
221 |
dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
|
222 |
INNER JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille ON |
//// etat |
223 |
dossier_autorisation.dossier_autorisation_type_detaille = |
//$this->init_select($form, $db, $maj, $debug, "etat", |
224 |
dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
// $sql_etat, $sql_etat_by_id, false); |
225 |
WHERE dossier ='". |
|
226 |
$this->idxformulaire."'"; |
//// evenement |
227 |
$nature_dossier = $db->getOne($sql); |
//$this->init_select($form, $db, $maj, $debug, "evenement", |
228 |
|
// $sql_evenement, $sql_evenement_by_id, false); |
229 |
// recherche des evenement de transition |
|
230 |
// XXX modifier la requète après la modification de structure du workflow |
// signataire_arrete |
231 |
$sql= $sql_transition." where transition.etat ='".$etat_dossier."' and dossier='". |
$this->init_select($form, $db, $maj, $debug, "signataire_arrete", |
232 |
$this->idxformulaire."' order by evenement.action"; |
$sql_signataire_arrete, $sql_signataire_arrete_by_id, true); |
233 |
|
|
234 |
// *** attention en dur le CU |
/** |
235 |
$this->addToLog("setSelect(): db->query(\"".$sql."\");", VERBOSE_MODE); |
* Gestion du filtre sur les événements de workflow disponibles |
236 |
|
* On récupère ici en fonction de l'état du dossier d'instruction en |
237 |
|
* cours et du type du dossier d'instruction en cours la liste |
238 |
|
* événements disponibles. |
239 |
|
*/ |
240 |
|
if ($maj == 0) { |
241 |
|
// Récupération des événements par une jointure entre la table dossier |
242 |
|
// et la table transition et la table evenement et la table |
243 |
|
// lien_dossier_instruction_type_evenement en fonction de l'identifiant |
244 |
|
// du dossier d'instruction en cours |
245 |
|
$sql = "SELECT |
246 |
|
evenement.evenement, |
247 |
|
(evenement.libelle||' ['||evenement.action||']') as lib |
248 |
|
FROM ".DB_PREFIXE."dossier |
249 |
|
INNER JOIN ".DB_PREFIXE."lien_dossier_instruction_type_evenement |
250 |
|
ON dossier.dossier_instruction_type=lien_dossier_instruction_type_evenement.dossier_instruction_type |
251 |
|
INNER JOIN ".DB_PREFIXE."evenement |
252 |
|
ON evenement.evenement=lien_dossier_instruction_type_evenement.evenement |
253 |
|
INNER JOIN ".DB_PREFIXE."transition |
254 |
|
ON evenement.evenement = transition.evenement |
255 |
|
AND dossier.etat=transition.etat |
256 |
|
WHERE dossier.dossier='".$this->idxformulaire."' |
257 |
|
ORDER BY evenement.action"; |
258 |
|
$res = $db->query($sql); |
259 |
|
$this->addToLog("setSelect(): db->query(\"".$sql."\");", VERBOSE_MODE); |
260 |
|
if (database::isError($res)) { |
261 |
|
die($res->getMessage()); |
262 |
|
} |
263 |
|
// Remplissage du tableau du select |
264 |
|
$contenu = array( |
265 |
|
0 => array("",), |
266 |
|
1 => array(_('choisir')." "._('evenement'),) |
267 |
|
); |
268 |
|
while ($row=& $res->fetchRow()) { |
269 |
|
$contenu[0][] = $row[0]; |
270 |
|
$contenu[1][] = $row[1]; |
271 |
|
} |
272 |
|
$form->setSelect("evenement", $contenu); |
273 |
|
} else { |
274 |
|
$sql = "SELECT |
275 |
|
(evenement.libelle||' ['||evenement.action||']') as lib |
276 |
|
FROM ".DB_PREFIXE."evenement |
277 |
|
WHERE evenement.evenement=".$this->getVal("evenement").""; |
278 |
|
$res = $db->getone($sql); |
279 |
|
$this->addToLog("setSelect(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
280 |
|
if (database::isError($res)) { |
281 |
|
die($res->getMessage()); |
282 |
|
} |
283 |
|
// |
284 |
|
$contenu = array( |
285 |
|
0 => array($this->getVal("evenement"),), |
286 |
|
1 => array($res,) |
287 |
|
); |
288 |
|
$form->setSelect("evenement", $contenu); |
289 |
|
} |
290 |
|
|
291 |
$res = $db->query($sql); |
/** |
292 |
if (database::isError($res)) |
* Gesion des liens vers la bible |
293 |
die($res->getMessage()); |
*/ |
294 |
$contenu[0][0]=""; |
// lien bible_auto |
295 |
$contenu[1][0]=_('choisir')." "._('evenement'); |
$contenu = array(_("automatique")); |
|
$k=1; |
|
|
while ($row=& $res->fetchRow()){ |
|
|
if($maj==0){ // ajouter |
|
|
$contenu[0][$k]=$row[0]; |
|
|
$contenu[1][$k]=$row[1]; |
|
|
$k++; |
|
|
}else{ |
|
|
// select hiddenstatic |
|
|
$contenu[0][$k]=$row[0]; |
|
|
$contenu[1][$k]=$row[1]; |
|
|
$k++; |
|
|
} |
|
|
} |
|
|
$form->setSelect("evenement",$contenu); |
|
|
// lien bible_auto [link] |
|
|
$contenu=array(); |
|
|
$contenu[0]=" automatique "; |
|
296 |
$form->setSelect("bible_auto",$contenu); |
$form->setSelect("bible_auto",$contenu); |
297 |
// lien bible1 |
// lien bible1 |
298 |
$contenu=array(); |
$contenu = array(_("bible")); |
|
$contenu[0]=" Bible "; |
|
299 |
$form->setSelect("bible",$contenu); |
$form->setSelect("bible",$contenu); |
300 |
// lien bible2 |
// lien bible2 |
301 |
$contenu=array(); |
$contenu = array(_("bible")); |
|
$contenu[0]=" Bible "; |
|
302 |
$form->setSelect("bible2",$contenu); |
$form->setSelect("bible2",$contenu); |
303 |
} // function select |
} |
304 |
|
|
305 |
|
function cleSecondaire($id, &$db, $val, $DEBUG) { |
306 |
|
// |
307 |
|
parent::cleSecondaire($id, $db, $val, $DEBUG); |
308 |
|
|
309 |
|
/** |
310 |
|
* Vérification que l'élément supprimé est le dernier pour pouvoir |
311 |
|
* remodifier les données de manière itérative. |
312 |
|
*/ |
313 |
|
// Initialisation |
314 |
|
$dernierevenement = ""; |
315 |
|
// Récupération du dernier élément de la table d'instruction qui |
316 |
|
// concerne le dossier en cours |
317 |
|
$sql = "SELECT max(instruction) |
318 |
|
FROM ".DB_PREFIXE."instruction |
319 |
|
WHERE dossier ='".$this->idxformulaire."'"; |
320 |
|
$dernierevenement = $db->getOne($sql); |
321 |
|
$this->addToLog("setSelect(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
322 |
|
if (database::isError($dernierevenement)) { |
323 |
|
die($dernierevenement->getMessage()); |
324 |
|
} |
325 |
|
// Si on se trouve effectivement sur le dernier evenement d'instruction |
326 |
|
if ($dernierevenement == $id) { |
327 |
|
// Alors on valide la suppression |
328 |
|
$this->correct = true; |
329 |
|
$this->addToMessage(_('Destruction_chronologique')); |
330 |
|
} else { |
331 |
|
// Alors on annule la suppression |
332 |
|
$this->correct = false; |
333 |
|
$this->addToMessage(_("Seul le dernier evenement d'instruction peut etre supprime.")); |
334 |
|
} |
335 |
|
} |
336 |
|
|
337 |
|
// Sélectionne le signataire_arrete par défaut |
338 |
|
function setVal(&$form,$maj,$validation){ |
339 |
|
|
340 |
|
// Ajout |
341 |
|
if($maj == 0) { |
342 |
|
|
343 |
|
// Création de la requête |
344 |
|
$sql = "SELECT signataire_arrete |
345 |
|
FROM ".DB_PREFIXE."signataire_arrete |
346 |
|
WHERE defaut IS TRUE"; |
347 |
|
|
348 |
|
// Exécution de la requête |
349 |
|
$this->f->addToLog("deleteAllLienDossierInstructionTypeEvenementEvenement(): db->query(\"".$sql."\");", VERBOSE_MODE); |
350 |
|
$res = $this->f->db->query($sql); |
351 |
|
$this->f->isDatabaseError(); |
352 |
|
|
353 |
|
$row = $res->fetchrow(DB_FETCHMODE_ASSOC); |
354 |
|
|
355 |
|
if ( isset($row['signataire_arrete']) && is_numeric($row['signataire_arrete'])){ |
356 |
|
|
357 |
|
$form->setVal("signataire_arrete",$row['signataire_arrete']); |
358 |
|
} |
359 |
|
} |
360 |
|
} |
361 |
|
|
362 |
|
/*Met des valeurs par défaut dans certains des sous-formulaire*/ |
363 |
|
function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire){ |
364 |
|
if ($validation==0 and $maj<2) { |
365 |
|
if ($maj == 0){ |
366 |
|
$form->setVal("destinataire", $idxformulaire); |
367 |
|
$form->setVal("dossier", $idxformulaire); |
368 |
|
$form->setVal("date_evenement", date('Y-m-d')); |
369 |
|
} |
370 |
|
$form->setVal("bible_auto","bible_auto()"); |
371 |
|
$form->setVal("bible","bible()"); |
372 |
|
$form->setVal("bible2","bible2()"); |
373 |
|
} |
374 |
|
$this->retourformulaire=$retourformulaire; |
375 |
|
$this->idxformulaire=$idxformulaire; |
376 |
|
} |
377 |
|
|
378 |
|
|
379 |
function setLayout(&$form, $maj){ |
function setLayout(&$form, $maj){ |
380 |
if ( $maj < 2 OR $maj == 3 ) { |
if ( $maj < 2 OR $maj == 3 ) { |
382 |
$form->setBloc('evenement','D',"","col_12"); |
$form->setBloc('evenement','D',"","col_12"); |
383 |
|
|
384 |
$form->setFieldset('evenement','D',_('Evenement')); |
$form->setFieldset('evenement','D',_('Evenement')); |
|
$form->setBloc('evenement','D',"","group col_12"); |
|
|
$form->setBloc('date_evenement','F'); |
|
385 |
$form->setFieldset('lettretype','F',''); |
$form->setFieldset('lettretype','F',''); |
386 |
|
|
387 |
$form->setBloc('lettretype','F'); |
$form->setBloc('lettretype','F'); |
410 |
} |
} |
411 |
} |
} |
412 |
|
|
413 |
/*Change le libellé de certains champs*/ |
function setLib(&$form, $maj) { |
414 |
function setLib(&$form,$maj) { |
// |
415 |
parent :: setLib($form,$maj); |
parent::setLib($form, $maj); |
416 |
$form->setLib('libelle',' '); |
// |
417 |
$form->setLib('bible_auto',""); |
$form->setLib('bible_auto', ""); |
418 |
$form->setLib('bible',""); |
$form->setLib('bible', ""); |
419 |
$form->setLib('bible2',""); |
$form->setLib('bible2', ""); |
420 |
} |
} |
421 |
|
|
422 |
// ================================================================== |
function triggerajouter($id, &$db, $val, $DEBUG) { |
423 |
// trigger avant modification des données [trigger before modify data] |
/** |
424 |
// ================================================================== |
* Le code suivant permet de récupérer des valeurs des tables evenement |
425 |
function triggerajouter($id,&$db,$val,$DEBUG) { |
* et dossier pour les stocker dans l'instruction : |
426 |
// mise a jour instruction avec evenement |
* DEPUIS L'EVENEMENT |
427 |
// [modify instruction with evenement] |
* - action |
428 |
$sql= "select * from ".DB_PREFIXE."evenement where evenement =".$this->valF['evenement']; |
* - delai |
429 |
|
* - accord_tacite |
430 |
|
* - etat |
431 |
|
* - avis_decision |
432 |
|
* - delai_notification |
433 |
|
* - lettretype |
434 |
|
* DEPUIS LE DOSSIER D'INSTRUCTION |
435 |
|
* - archive_delai |
436 |
|
* - archive_accord_tacite |
437 |
|
* - archive_etat |
438 |
|
* - archive_avis |
439 |
|
* - date_complet |
440 |
|
* - date_rejet |
441 |
|
* - date_limite |
442 |
|
* - date_notification_delai |
443 |
|
* - date_decision |
444 |
|
* - date_validite |
445 |
|
* - date_achevement |
446 |
|
* - date_chantier |
447 |
|
* - date_conformite |
448 |
|
* Il permet également de stocker la date_depot du dossier d'instruction |
449 |
|
* dans l'attribut $this->archive_date_depot de la classe. |
450 |
|
*/ |
451 |
|
// Récupération de tous les paramètres de l'événement sélectionné |
452 |
|
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
453 |
|
WHERE evenement=".$this->valF['evenement']; |
454 |
$res = $db->query($sql); |
$res = $db->query($sql); |
455 |
if (database::isError($res)) die($res->getMessage()); |
$this->addToLog("triggerajouter(): db->query(\"".$sql."\");", VERBOSE_MODE); |
456 |
|
if (database::isError($res)) { |
457 |
if ($DEBUG == 1) |
die($res->getMessage()); |
458 |
echo " la requete ".$sql." est exécutée<br>"; |
} |
459 |
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
460 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
// Récupération de l'identifiant de l'action |
461 |
|
// si une action est paramétrée dans l'événement |
462 |
if(isset($row['action']) and !empty($row['action'])) { |
$this->valF['action'] = NULL; |
463 |
|
if (isset($row['action']) and !empty($row['action'])) { |
464 |
$this->valF['action']=$row['action']; |
$this->valF['action']=$row['action']; |
|
} else { |
|
|
$this->valF['action']=NULL; |
|
465 |
} |
} |
466 |
$this->valF['delai']=$row['delai']; |
// Récupération de la valeur du délai |
467 |
if(isset($row['etat']) and !empty($row['etat'])) { |
$this->valF['delai'] = $row['delai']; |
468 |
|
// Récupération de l'identifiant de l'état |
469 |
|
// si un état est paramétré dans l'événement |
470 |
|
$this->valF['etat']=NULL; |
471 |
|
if (isset($row['etat']) and !empty($row['etat'])) { |
472 |
$this->valF['etat']=$row['etat']; |
$this->valF['etat']=$row['etat']; |
|
} else { |
|
|
$this->valF['etat']=NULL; |
|
473 |
} |
} |
474 |
|
// Récupération de la valeur d'accord tacite |
475 |
$this->valF['accord_tacite']=$row['accord_tacite']; |
$this->valF['accord_tacite']=$row['accord_tacite']; |
476 |
|
// Récupération de la valeur du délai de notification |
477 |
$this->valF['delai_notification']=$row['delai_notification']; |
$this->valF['delai_notification']=$row['delai_notification']; |
478 |
|
// Récupération de l'identifiant de l'avis |
479 |
|
// si un avis est paramétré dans l'événement |
480 |
|
$this->valF['avis_decision'] = NULL; |
481 |
if(isset($row['avis_decision']) and !empty($row['avis_decision'])) { |
if(isset($row['avis_decision']) and !empty($row['avis_decision'])) { |
482 |
$this->valF['avis_decision']=$row['avis_decision']; |
$this->valF['avis_decision']=$row['avis_decision']; |
|
} else { |
|
|
$this->valF['avis_decision']=NULL; |
|
483 |
} |
} |
484 |
if($row['lettretype']!="") |
// Récupération de la valeur de la lettre type |
485 |
|
// Sinon on lui affecte lavaleur par défaut standard |
486 |
|
if ($row['lettretype'] != "") { |
487 |
$this->valF['lettretype']=$row['lettretype']; |
$this->valF['lettretype']=$row['lettretype']; |
488 |
else |
} else { |
489 |
$this->valF['lettretype']="standard"; |
$this->valF['lettretype'] = "standard"; // XXX |
490 |
|
} |
491 |
} |
} |
492 |
$sql= "select * from ".DB_PREFIXE."dossier where dossier = '".$this->valF['dossier']."'"; |
// Récupération de toutes les valeurs du dossier d'instruction en cours |
493 |
|
$sql = "SELECT * FROM ".DB_PREFIXE."dossier |
494 |
|
WHERE dossier='".$this->valF['dossier']."'"; |
495 |
$res = $db->query($sql); |
$res = $db->query($sql); |
496 |
if (database::isError($res)) |
$this->addToLog("triggerajouter(): db->query(\"".$sql."\");", VERBOSE_MODE); |
497 |
|
if (database::isError($res)) { |
498 |
die($res->getMessage()); |
die($res->getMessage()); |
499 |
if ($DEBUG == 1) |
} |
500 |
echo " la requete ".$sql." est exécutée<br>"; |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
501 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
// XXX On stocke la date de dépôt actuelle du dossier d'instruction |
502 |
// |
// dans un attribut de la classe |
503 |
$this->archive_date_depot = $row['date_depot']; |
$this->archive_date_depot = $row['date_depot']; |
504 |
// archive en instruction (si suppression) |
// Récupération de la valeur actuelle du délai, de l'accord tacite, |
505 |
|
// de l'état et de l'avis du dossier d'instruction |
506 |
$this->valF['archive_delai']=$row['delai']; |
$this->valF['archive_delai']=$row['delai']; |
507 |
$this->valF['archive_accord_tacite']=$row['accord_tacite']; |
$this->valF['archive_accord_tacite']=$row['accord_tacite']; |
508 |
$this->valF['archive_etat']=$row['etat']; |
$this->valF['archive_etat']=$row['etat']; |
509 |
$this->valF['archive_avis']=$row['avis_decision']; |
$this->valF['archive_avis']=$row['avis_decision']; |
510 |
// compatibilite pgsql |
// Récupération de la valeur actuelle des 9 dates du dossier |
511 |
if($row['date_complet']!='') |
// d'instruction |
512 |
$this->valF['archive_date_complet']=$row['date_complet']; |
if ($row['date_complet'] != '') { |
513 |
if($row['date_rejet']!='') |
$this->valF['archive_date_complet']=$row['date_complet']; |
514 |
$this->valF['archive_date_rejet']= $row['date_rejet']; |
} |
515 |
if($row['date_limite']!='') |
if ($row['date_rejet']!='') { |
516 |
$this->valF['archive_date_limite']= $row['date_limite']; |
$this->valF['archive_date_rejet']= $row['date_rejet']; |
517 |
if($row['date_notification_delai']!='') |
} |
518 |
$this->valF['archive_date_notification_delai']= $row['date_notification_delai']; |
if ($row['date_limite']!='') { |
519 |
if($row['date_decision']!='') |
$this->valF['archive_date_limite']= $row['date_limite']; |
520 |
$this->valF['archive_date_decision']= $row['date_decision']; |
} |
521 |
if($row['date_validite']!='') |
if ($row['date_notification_delai']!='') { |
522 |
$this->valF['archive_date_validite']= $row['date_validite']; |
$this->valF['archive_date_notification_delai']= $row['date_notification_delai']; |
523 |
if($row['date_achevement']!='') |
} |
524 |
$this->valF['archive_date_achevement']= $row['date_achevement']; |
if ($row['date_decision']!='') { |
525 |
if($row['date_chantier']!='') |
$this->valF['archive_date_decision']= $row['date_decision']; |
526 |
$this->valF['archive_date_chantier']= $row['date_chantier']; |
} |
527 |
if($row['date_conformite']!='') |
if ($row['date_validite']!='') { |
528 |
$this->valF['archive_date_conformite']= $row['date_conformite']; |
$this->valF['archive_date_validite']= $row['date_validite']; |
529 |
|
} |
530 |
|
if ($row['date_achevement']!='') { |
531 |
|
$this->valF['archive_date_achevement']= $row['date_achevement']; |
532 |
|
} |
533 |
|
if ($row['date_chantier']!='') { |
534 |
|
$this->valF['archive_date_chantier']= $row['date_chantier']; |
535 |
|
} |
536 |
|
if ($row['date_conformite']!='') { |
537 |
|
$this->valF['archive_date_conformite']= $row['date_conformite']; |
538 |
|
} |
539 |
} |
} |
540 |
} |
} |
541 |
|
|
654 |
} |
} |
655 |
|
|
656 |
|
|
657 |
|
|
|
// ================================================================== |
|
|
// valeur dossier apres modification [values dossier after action] |
|
|
// ================================================================== |
|
658 |
function triggerajouterapres($id,&$db,$val,$DEBUG) { |
function triggerajouterapres($id,&$db,$val,$DEBUG) { |
659 |
// mise a null au lieu de "" / voir compatibilite mysql |
/** |
660 |
// voir parametrage CU en dur |
* Mise à jour des valeurs du dossier en fonction des valeurs calculées |
661 |
// voir parametrage des actions en dur |
* par l'action |
662 |
$param=1; |
*/ |
663 |
if($param==1){ |
// Initialisation |
664 |
$sql="select * from ".DB_PREFIXE."action where action = '".$this->valF['action']."'"; |
$valF = ""; |
665 |
$res = $db->query($sql); |
// Récupération des paramètres de l'action |
666 |
if (database::isError($res)) |
$sql = "SELECT * FROM ".DB_PREFIXE."action |
667 |
die($res->getMessage()); |
WHERE action='".$this->valF['action']."'"; |
668 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
$res = $db->query($sql); |
669 |
if($row['regle_etat']!=''){ |
$this->addToLog("triggerajouterapres(): db->query(\"".$sql."\");", VERBOSE_MODE); |
670 |
$valF['etat']= $this->regle($row['regle_etat']); |
if (database::isError($res)) { |
671 |
} |
die($res->getMessage()); |
672 |
if($row['regle_delai']!=''){ |
} |
673 |
$valF['delai']= $this->regle($row['regle_delai']); |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
674 |
} |
// pour chacune des regles, on applique la regle |
675 |
if($row['regle_accord_tacite']!=''){ |
if($row['regle_etat']!=''){ |
676 |
$valF['accord_tacite']= $this->regle($row['regle_accord_tacite']); |
$valF['etat'] = $this->regle($row['regle_etat']); |
677 |
} |
} |
678 |
if($row['regle_avis']!=''){ |
if($row['regle_delai']!=''){ |
679 |
$valF['avis_decision']= $this->regle($row['regle_avis']); |
$valF['delai'] = $this->regle($row['regle_delai']); |
680 |
} |
} |
681 |
if($row['regle_date_limite']!=''){ |
if($row['regle_accord_tacite']!=''){ |
682 |
$valF['date_limite']= $this->regle($row['regle_date_limite']); |
$valF['accord_tacite'] = $this->regle($row['regle_accord_tacite']); |
683 |
} |
} |
684 |
if($row['regle_date_complet']!=''){ |
if($row['regle_avis']!=''){ |
685 |
$valF['date_complet']= $this->regle($row['regle_date_complet']); |
$valF['avis_decision'] = $this->regle($row['regle_avis']); |
686 |
} |
} |
687 |
if($row['regle_date_notification_delai']!=''){ |
if($row['regle_date_limite']!=''){ |
688 |
$valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']); |
$valF['date_limite']= $this->regle($row['regle_date_limite']); |
689 |
} |
} |
690 |
if($row['regle_date_decision']!=''){ |
if($row['regle_date_complet']!=''){ |
691 |
$valF['date_decision']= $this->regle($row['regle_date_decision']); |
$valF['date_complet']= $this->regle($row['regle_date_complet']); |
692 |
} |
} |
693 |
if($row['regle_date_rejet']!=''){ |
if($row['regle_date_notification_delai']!=''){ |
694 |
$valF['date_rejet']= $this->regle($row['regle_date_rejet']); |
$valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']); |
695 |
} |
} |
696 |
if($row['regle_date_validite']!=''){ |
if($row['regle_date_decision']!=''){ |
697 |
$valF['date_validite']= $this->regle($row['regle_date_validite']); |
$valF['date_decision']= $this->regle($row['regle_date_decision']); |
698 |
} |
} |
699 |
if($row['regle_date_chantier']!=''){ |
if($row['regle_date_rejet']!=''){ |
700 |
$valF['date_chantier']= $this->regle($row['regle_date_chantier']); |
$valF['date_rejet']= $this->regle($row['regle_date_rejet']); |
701 |
} |
} |
702 |
if($row['regle_date_achevement']!=''){ |
if($row['regle_date_validite']!=''){ |
703 |
$valF['date_achevement']= $this->regle($row['regle_date_achevement']); |
$valF['date_validite']= $this->regle($row['regle_date_validite']); |
704 |
} |
} |
705 |
if($row['regle_date_conformite']!=''){ |
if($row['regle_date_chantier']!=''){ |
706 |
$valF['date_conformite']= $this->regle($row['regle_date_conformite']); |
$valF['date_chantier']= $this->regle($row['regle_date_chantier']); |
707 |
|
} |
708 |
|
if($row['regle_date_achevement']!=''){ |
709 |
|
$valF['date_achevement']= $this->regle($row['regle_date_achevement']); |
710 |
|
} |
711 |
|
if($row['regle_date_conformite']!=''){ |
712 |
|
$valF['date_conformite']= $this->regle($row['regle_date_conformite']); |
713 |
|
} |
714 |
|
// Appel des méthode stockées dans le champ methode_trigger |
715 |
|
if ($row['methode_trigger'] != "") { |
716 |
|
foreach (explode(";", $row['methode_trigger']) as $methode) { |
717 |
|
if (method_exists($this, $methode)) { |
718 |
|
$this->$methode(); |
719 |
|
} |
720 |
} |
} |
721 |
|
} |
722 |
// Appel des méthode stockées dans le champ methode_trigger |
} |
723 |
if($row['methode_trigger'] != "") { |
// Si des valeurs ont été calculées alors on met à jour l'enregistrement |
724 |
foreach (explode(";", $row['methode_trigger']) as $methode) { |
if ($valF != "") { |
725 |
if(method_exists($this, $methode)) { |
// On met à jour le dossier |
726 |
$this->$methode(); |
$cle = " dossier='".$this->valF['dossier']."'"; |
727 |
} |
$res1 = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle); |
728 |
|
$this->addToLog("triggerajouterapres(): db->autoexecute(\"".DB_PREFIXE."dossier\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
729 |
} |
if (database::isError($res1)) { |
|
} |
|
|
} |
|
|
}else{ |
|
|
switch ($this->valF['action']) { |
|
|
case "initialisation" : |
|
|
$valF['delai']= $this->valF['delai']; |
|
|
$valF['etat']= $this->valF['etat']; |
|
|
$valF['accord_tacite']= $this->valF['accord_tacite']; |
|
|
// la date_complet est la date de depot |
|
|
$valF['date_complet']= $this->archive_date_depot; // **** |
|
|
$valF['date_limite'] = $this->moisdate($valF['date_complet'],$valF['delai']); |
|
|
$valF['date_notification_delai'] = $this->moisdate($valF['date_complet'],1); |
|
|
break; |
|
|
case "notification" : |
|
|
$valF['delai']= $this->valF['delai']; |
|
|
$valF['etat']= $this->valF['etat']; |
|
|
$valF['accord_tacite']= $this->valF['accord_tacite']; |
|
|
// la date_complet est celle precedemment saisie |
|
|
$valF['date_complet']=$this->valF['archive_date_complet']; |
|
|
$valF['date_limite'] = $this->moisdate($valF['date_complet'],$valF['delai']); |
|
|
$valF['date_notification_delai'] = $this->moisdate($valF['date_complet'],1); |
|
|
// la date du courrier ne doit pas etre depasse par rapport au delai de |
|
|
// notification [verify notification date] |
|
|
if($this->valF['archive_date_notification_delai']<$this->valF['date_evenement']) |
|
|
$this->msg=$this->msg."<br><img src='../img/erreur.gif'> "._("date_notification_delai")." ". |
|
|
$this->valF['archive_date_notification_delai']." < "._('date_evenement'); |
|
|
// |
|
|
break; |
|
|
case "retour" : |
|
|
$valF['delai']= $this->valF['delai']; |
|
|
$valF['etat']= $this->valF['etat']; |
|
|
$valF['accord_tacite']= $this->valF['accord_tacite']; |
|
|
// la date_complet est celle de l evenement |
|
|
$valF['date_complet']= $this->valF['date_evenement']; |
|
|
$valF['date_limite'] = $this->moisdate($valF['date_complet'],$valF['delai']); |
|
|
$valF['date_notification_delai'] = $this->moisdate($valF['date_complet'],1); |
|
|
break; |
|
|
case "rejet" : |
|
|
//$valF['delai']=0; // *** delai a garder pour etat dpc |
|
|
$valF['etat']= $this->valF['etat']; |
|
|
$valF['accord_tacite']= $this->valF['accord_tacite']; |
|
|
// la date rejet est initialisee |
|
|
$valF['date_rejet']= $this->valF['date_evenement']; |
|
|
// les dates de depart et fin d instruction sont annulées |
|
|
$valF['date_limite'] =null; |
|
|
$valF['date_notification_delai'] =null; |
|
|
$valF['date_complet']=null; |
|
|
break; |
|
|
case "majoration" : |
|
|
$valF['delai']= $this->valF['archive_delai']+$this->valF['delai']; |
|
|
$valF['etat']= $this->valF['etat']; |
|
|
$valF['accord_tacite']= $this->valF['accord_tacite']; |
|
|
$valF['date_complet']=$this->valF['archive_date_complet']; |
|
|
// majoration de la date limite |
|
|
$valF['date_limite'] = $this->moisdate($valF['date_complet'],$valF['delai']); |
|
|
$valF['date_notification_delai'] = $this->moisdate($valF['date_complet'],1); |
|
|
// la date du courrier ne doit pas etre depasse par rapport au delai de |
|
|
// notification |
|
|
if($this->valF['archive_date_notification_delai']<$this->valF['date_evenement']) |
|
|
$this->msg=$this->msg."<br><img src='../img/erreur.gif'>"._("date_notification_delai"). |
|
|
$this->valF['archive_date_notification_delai']." < "._('date_evenement'); |
|
|
break; |
|
|
case "acceptation" : |
|
|
$valF['etat']= $this->valF['etat']; |
|
|
$valF['date_decision']= $this->valF['date_evenement']; |
|
|
$valF['avis_decision']= $this->valF['avis_decision']; |
|
|
// date de validite = date de l evenement + delai |
|
|
$valF['date_validite'] = $this->moisdate($this->valF['date_evenement'],$this->valF['delai']); |
|
|
break; |
|
|
case "refus" : |
|
|
$valF['etat']= $this->valF['etat']; |
|
|
$valF['date_decision']= $this->valF['date_evenement']; |
|
|
$valF['avis_decision']= $this->valF['avis_decision']; |
|
|
break; |
|
|
case "prolongation" : |
|
|
$valF['date_validite'] = $this->moisdate($this->valF['archive_date_validite'],$this->valF['delai']); |
|
|
break; |
|
|
case "sursis" : |
|
|
$valF['date_limite'] = $this->moisdate($this->valF['date_evenement'],$this->valF['delai']); |
|
|
$valF['etat']= $this->valF['etat']; |
|
|
$valF['accord_tacite']= $this->valF['accord_tacite']; |
|
|
$valF['avis_decision']= $this->valF['avis_decision']; |
|
|
$valF['date_decision']= $this->valF['date_evenement']; |
|
|
$temp = $valF['date_limite']; |
|
|
$valF['date_validite']= $this->moisdate($temp,2); |
|
|
break; |
|
|
case "execution" : |
|
|
$valF['etat']= $this->valF['etat']; |
|
|
$valF['date_chantier'] = $this->valF['date_evenement']; |
|
|
//echo $this->msg=$this->msg.$valF['date_chantier'].""; |
|
|
break; |
|
|
case "achevement" : |
|
|
$valF['etat']= $this->valF['etat']; |
|
|
$valF['date_achevement'] = $this->valF['date_evenement']; |
|
|
break; |
|
|
case "archivage" : |
|
|
$valF['etat']= $this->valF['etat']; |
|
|
$valF['date_conformite'] = $this->valF['date_evenement']; |
|
|
break; |
|
|
|
|
|
default: |
|
|
if ($this->valF['etat']!="") |
|
|
$valF['etat']= $this->valF['etat']; |
|
|
}// end switch |
|
|
} // end param |
|
|
if($valF!=""){ |
|
|
$cle= " dossier = '".$this->valF['dossier']."'"; |
|
|
$res1= $db->autoExecute(DB_PREFIXE.'dossier',$valF,DB_AUTOQUERY_UPDATE,$cle); |
|
|
if (database::isError($res1)) |
|
730 |
die($res->getMessage()); |
die($res->getMessage()); |
731 |
if ($DEBUG == 1) |
} |
732 |
echo "La requête de mise à jour est effectuée.<br>"; |
// Affichage d'informations à l'utilisateur |
733 |
$this->msg=$this->msg."<br>"._('enregistrement')." ". |
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
|
$this->valF['dossier']." "._('table')." dossier [". |
|
|
$db->affectedRows()." "._('enregistrement'). |
|
|
" "._('mis_a_jour')."]" ; |
|
734 |
} |
} |
735 |
|
|
736 |
|
/** |
737 |
|
* REFERENTIEL ERP |
738 |
|
*/ |
739 |
// verification si envoi vers ERP est active |
// verification si envoi vers ERP est active |
740 |
if ($this->f->getParameter('option_erp') != "") { |
if ($this->f->getParameter('option_erp') != "") { |
741 |
// la nature du dossier |
// la nature du dossier |
742 |
$nature_dossier = substr($this->idxformulaire,0,2); |
$nature_dossier = substr($this->idxformulaire,0,2); |
743 |
$dossier_erp = $this->getFromDB("SELECT erp FROM ".DB_PREFIXE."dossier WHERE dossier = '" . |
// |
744 |
$this->valF['dossier'] . "'"); |
$sql = "SELECT erp |
745 |
$evenement_libelle = $this->getFromDB( |
FROM ".DB_PREFIXE."dossier |
746 |
"SELECT libelle FROM ".DB_PREFIXE."evenement WHERE evenement = '" . |
WHERE dossier='".$this->valF['dossier']."'"; |
747 |
$this->valF['evenement'] . "'"); |
$dossier_erp = $this->db->getone($sql); |
748 |
|
$this->addToLog("triggerajouterapres(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
749 |
|
if (database::isError($res)) { |
750 |
|
die($res->getMessage()); |
751 |
|
} |
752 |
|
// |
753 |
|
$sql = "SELECT libelle |
754 |
|
FROM ".DB_PREFIXE."evenement |
755 |
|
WHERE evenement='".$this->valF['evenement']."'"; |
756 |
|
$evenement_libelle = $this->db->getone($sql); |
757 |
|
$this->addToLog("triggerajouterapres(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
758 |
|
if (database::isError($res)) { |
759 |
|
die($res->getMessage()); |
760 |
|
} |
761 |
|
// |
762 |
if ($dossier_erp == 't') { |
if ($dossier_erp == 't') { |
763 |
// envoi du message en cas d'un PC qui est ERP et sur lequel un evenement |
// envoi du message en cas d'un PC qui est ERP et sur lequel un evenement |
764 |
// d'acceptation etait fait |
// d'acceptation etait fait |
779 |
} |
} |
780 |
} |
} |
781 |
} // fin de if ($this->f->getParameter('option_erp') != "") |
} // fin de if ($this->f->getParameter('option_erp') != "") |
782 |
} |
} |
|
|
|
|
|
|
|
/** |
|
|
* Fait une requette sql pour extraire la valeur d'un champ, et retourne |
|
|
* cette valeur |
|
|
* @param string $sql La requete sql a executer |
|
|
* @return La valeur du champs cherche, sinon NULL. En cas d'erreur de la BD |
|
|
* l'execution s'arrete. |
|
|
*/ |
|
|
function getFromDB($sql) { |
|
|
//$sql = "SELECT libelle FROM ".DB_PREFIXE."dossier WHERE dossier = '" . $dossier . "'"; |
|
|
$res = $this->db->limitquery($sql, 0, 1); |
|
|
$this->addToLog("getDossierERPSpecification(): db->limitquery(\"". |
|
|
str_replace(",",", ",$sql)."\", 0, 1);", VERBOSE_MODE); |
|
|
// Si une erreur survient on die |
|
|
if (database::isError($res, true)) { |
|
|
// Appel de la methode de recuperation des erreurs |
|
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), 'instruction'); |
|
|
} |
|
|
// retourne la nature du dossier |
|
|
while ($row =& $res->fetchRow()) { |
|
|
return $row[0]; |
|
|
} |
|
|
// la nature n'etait pas trouve, ce qui ne devrait pas se passer |
|
|
return NULL; |
|
|
|
|
|
} |
|
|
|
|
783 |
|
|
784 |
function triggermodifierapres($id,&$db,$val,$DEBUG) { |
function triggermodifierapres($id,&$db,$val,$DEBUG) { |
785 |
/* |
/** |
786 |
* cette fonction a pour objet de permettre de modifier la date courrier |
* L'objectif ici est d'effectuer les recalculs de date dans le dossier |
787 |
*/ |
* si la date de l'evenement est modifiee |
788 |
$valF=array(); |
*/ |
789 |
$sql= "select action from ".DB_PREFIXE."evenement where evenement =".$this->valF['evenement']; |
// Initialisation |
790 |
|
$valF = ""; |
791 |
|
// Récupération de l'action correspondante à l'événement |
792 |
|
$sql = "SELECT action |
793 |
|
FROM ".DB_PREFIXE."evenement |
794 |
|
WHERE evenement=".$this->valF['evenement']; |
795 |
$action = $db->getOne($sql); |
$action = $db->getOne($sql); |
796 |
if (database::isError($action)) die($action->getMessage().$sql); |
$this->addToLog("triggermodifierapres(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
797 |
$sql="select * from ".DB_PREFIXE."action where action = '".$action."'"; |
if (database::isError($action)) { |
798 |
|
die($action->getMessage()); |
799 |
|
} |
800 |
|
// Récupération des paramètres de l'action |
801 |
|
$sql = "SELECT * FROM ".DB_PREFIXE."action |
802 |
|
WHERE action='".$action."'"; |
803 |
$res = $db->query($sql); |
$res = $db->query($sql); |
804 |
if (database::isError($res)) die($res->getMessage().$sql); |
$this->addToLog("triggermodifierapres(): db->query(\"".$sql."\");", VERBOSE_MODE); |
805 |
|
if (database::isError($res)) { |
806 |
|
die($res->getMessage()); |
807 |
|
} |
808 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
809 |
// application des regles sur le courrier + delai |
// application des regles sur le courrier + delai |
810 |
if(preg_match("/date_evenement/",$row['regle_date_limite'])){ |
if(preg_match("/date_evenement/",$row['regle_date_limite'])){ |
834 |
if(preg_match("/date_evenement/",$row['regle_date_conformite'])){ |
if(preg_match("/date_evenement/",$row['regle_date_conformite'])){ |
835 |
$valF['date_conformite']= $this->regle($row['regle_date_conformite']); |
$valF['date_conformite']= $this->regle($row['regle_date_conformite']); |
836 |
} |
} |
837 |
} // while |
} |
838 |
if($valF!=array()){ |
// Si des valeurs ont été calculées alors on met à jour l'enregistrement |
839 |
$cle= " dossier = '".$this->valF['dossier']."'"; |
if ($valF != "") { |
840 |
$res1= $db->autoExecute(DB_PREFIXE.'dossier',$valF,DB_AUTOQUERY_UPDATE,$cle); |
// On met à jour le dossier |
841 |
if (database::isError($res1)) |
$cle = " dossier='".$this->valF['dossier']."'"; |
842 |
|
$res1 = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle); |
843 |
|
$this->addToLog("triggerajouterapres(): db->autoexecute(\"".DB_PREFIXE."dossier\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
844 |
|
if (database::isError($res1)) { |
845 |
die($res->getMessage()); |
die($res->getMessage()); |
846 |
if ($DEBUG == 1) |
} |
847 |
echo "La requête de mise à jour est effectuée.<br>"; |
// Affichage d'informations à l'utilisateur |
848 |
$this->msg=$this->msg."<br>"._('enregistrement')." ". |
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
849 |
$this->valF['dossier']." "._('table')." dossier [". |
} |
|
$db->affectedRows()." "._('enregistrement'). |
|
|
" "._('mis_a_jour')."]" ; |
|
|
} |
|
|
|
|
|
// Envoi des infos au |
|
|
if ($this->valF['date_retour_signature'] != $this->getVal('date_retour_signature')) { |
|
|
$msgenque = new MessageEnqueuer(); |
|
|
$sqlArrete = "SELECT instruction.signataire_arrete as \"ws_DA_In_Signataire\", |
|
|
signataire_arrete.nom as \"ws_DA_In_Sign_Nom\", |
|
|
signataire_arrete.prenom as \"ws_DA_In_Sign_Prenom\", |
|
|
signataire_arrete.qualite as \"ws_DA_In_Sign_Qualite\", |
|
|
instruction.date_evenement as \"ws_DA_In_Dte_Redac\", |
|
|
'' as \"ws_DA_In_lieu_Redac\", |
|
|
instruction.dossier as \"ws_DA_In_N_Doss_DAS\", |
|
|
'' as \"ws_DA_In_Sigle\", |
|
|
instruction.etat as \"ws_DA_In_Decision\", |
|
|
dossier.date_depot as \"ws_DA_In_Dte_Depot_Dem\", |
|
|
dossier.terrain_numero as \"ws_DA_In_N_Voie\", |
|
|
'' as \"ws_DA_In_Type_Voie\", |
|
|
dossier.complement as \"ws_DA_In_Adresse1\", |
|
|
dossier.terrain_adresse_lieu_dit as \"ws_DA_In_Adresse2\", |
|
|
dossier.terrain_adresse_code_postal as \"ws_DA_In_CP\", |
|
|
dossier.terrain_adresse_localite as \"ws_DA_In_Ville\", |
|
|
dossier.terrain_references_cadastrales as \"ws_DA_In_Nb_Parcelle\", |
|
|
'' as \"ws_DA_In_Detail_Parcelle\", |
|
|
CONCAT(donnees_techniques.am_projet_desc,' ',donnees_techniques.co_projet_desc) as \"ws_DA_In_Nature_Trvx\", |
|
|
'' as \"ws_DA_In_Destination_Trvx\", |
|
|
dossier_autorisation_type_detaille.code as \"ws_DA_In_Type_Dos_Autoris\", |
|
|
COALESCE(particulier_nom,personne_morale_raison_sociale) as \"ws_DA_In_Nom_Petition\", |
|
|
COALESCE(particulier_prenom, personne_morale_denomination) as \"ws_DA_In_Prenom_Petition\", |
|
|
'' as \"ws_DA_In_Piece_GED\", |
|
|
instruction.date_retour_signature as \"ws_DA_In_Dte_Signature\" |
|
|
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."lien_dossier_demandeur ON |
|
|
lien_dossier_demandeur.dossier = dossier.dossier |
|
|
LEFT JOIN ".DB_PREFIXE."demandeur ON |
|
|
lien_dossier_demandeur.demandeur = demandeur.demandeur |
|
|
LEFT JOIN ".DB_PREFIXE."dossier_instruction_type ON |
|
|
dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
|
|
LEFT JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille ON |
|
|
dossier_instruction_type.dossier_autorisation_type_detaille = |
|
|
dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
|
|
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); |
|
|
$this->f->isDatabaseError(); |
|
850 |
|
|
851 |
$rowArrete = $resArrete->fetchRow(DB_FETCHMODE_ASSOC); |
/** |
852 |
$msgenque->setArreteInfo($rowArrete); |
* REFERENTIEL ARRETE |
853 |
$msgenque->enqueueMessage($msgenque::$ARRETE_ENVOI); |
*/ |
854 |
|
if ($this->f->getParameter('option_referentiel_arrete') != "") { |
855 |
|
if ($this->valF['date_retour_signature'] != $this->getVal('date_retour_signature')) { |
856 |
|
$msgenque = new MessageEnqueuer(); |
857 |
|
$sqlArrete = "SELECT instruction.signataire_arrete as \"ws_DA_In_Signataire\", |
858 |
|
signataire_arrete.nom as \"ws_DA_In_Sign_Nom\", |
859 |
|
signataire_arrete.prenom as \"ws_DA_In_Sign_Prenom\", |
860 |
|
signataire_arrete.qualite as \"ws_DA_In_Sign_Qualite\", |
861 |
|
instruction.date_evenement as \"ws_DA_In_Dte_Redac\", |
862 |
|
'' as \"ws_DA_In_lieu_Redac\", |
863 |
|
instruction.dossier as \"ws_DA_In_N_Doss_DAS\", |
864 |
|
'' as \"ws_DA_In_Sigle\", |
865 |
|
instruction.etat as \"ws_DA_In_Decision\", |
866 |
|
dossier.date_depot as \"ws_DA_In_Dte_Depot_Dem\", |
867 |
|
dossier.terrain_numero as \"ws_DA_In_N_Voie\", |
868 |
|
'' as \"ws_DA_In_Type_Voie\", |
869 |
|
dossier.complement as \"ws_DA_In_Adresse1\", |
870 |
|
dossier.terrain_adresse_lieu_dit as \"ws_DA_In_Adresse2\", |
871 |
|
dossier.terrain_adresse_code_postal as \"ws_DA_In_CP\", |
872 |
|
dossier.terrain_adresse_localite as \"ws_DA_In_Ville\", |
873 |
|
dossier.terrain_references_cadastrales as \"ws_DA_In_Nb_Parcelle\", |
874 |
|
'' as \"ws_DA_In_Detail_Parcelle\", |
875 |
|
CONCAT(donnees_techniques.am_projet_desc,' ',donnees_techniques.co_projet_desc) as \"ws_DA_In_Nature_Trvx\", |
876 |
|
'' as \"ws_DA_In_Destination_Trvx\", |
877 |
|
dossier_autorisation_type_detaille.code as \"ws_DA_In_Type_Dos_Autoris\", |
878 |
|
COALESCE(particulier_nom,personne_morale_raison_sociale) as \"ws_DA_In_Nom_Petition\", |
879 |
|
COALESCE(particulier_prenom, personne_morale_denomination) as \"ws_DA_In_Prenom_Petition\", |
880 |
|
'' as \"ws_DA_In_Piece_GED\", |
881 |
|
instruction.date_retour_signature as \"ws_DA_In_Dte_Signature\" |
882 |
|
FROM ".DB_PREFIXE."instruction |
883 |
|
LEFT JOIN ".DB_PREFIXE."signataire_arrete ON |
884 |
|
instruction.signataire_arrete = signataire_arrete.signataire_arrete |
885 |
|
LEFT JOIN ".DB_PREFIXE."dossier ON |
886 |
|
instruction.dossier = dossier.dossier |
887 |
|
LEFT JOIN ".DB_PREFIXE."lien_dossier_demandeur ON |
888 |
|
lien_dossier_demandeur.dossier = dossier.dossier |
889 |
|
LEFT JOIN ".DB_PREFIXE."demandeur ON |
890 |
|
lien_dossier_demandeur.demandeur = demandeur.demandeur |
891 |
|
LEFT JOIN ".DB_PREFIXE."dossier_instruction_type ON |
892 |
|
dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
893 |
|
LEFT JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille ON |
894 |
|
dossier_instruction_type.dossier_autorisation_type_detaille = |
895 |
|
dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
896 |
|
LEFT JOIN ".DB_PREFIXE."donnees_techniques ON |
897 |
|
donnees_techniques.dossier_instruction = dossier.dossier |
898 |
|
WHERE instruction.instruction = ".$this->valF['instruction']; |
899 |
|
$resArrete = $this->db->query($sqlArrete); |
900 |
|
$this->f->addToLog("triggerModifierApres(): db->query(\"".$sqlArrete."\");", VERBOSE_MODE); |
901 |
|
$this->f->isDatabaseError(); |
902 |
|
|
903 |
|
$rowArrete = $resArrete->fetchRow(DB_FETCHMODE_ASSOC); |
904 |
|
$msgenque->setArreteInfo($rowArrete); |
905 |
|
$msgenque->enqueueMessage($msgenque::$ARRETE_ENVOI); |
906 |
|
} |
907 |
} |
} |
908 |
} |
} |
909 |
|
|
|
|
|
|
|
|
|
// trigger before delete |
|
910 |
function triggersupprimer($id,&$db,$val,$DEBUG) { |
function triggersupprimer($id,&$db,$val,$DEBUG) { |
911 |
|
/** |
912 |
|
* L'objectif ici est de repositionner les valeurs récupérées en |
913 |
|
* archive dans le dossier d'instruction avant de supprimer l'événement |
914 |
|
* d'instruction |
915 |
|
*/ |
916 |
// archive en instruction (si suppression) [archive if delete instruction] |
// archive en instruction (si suppression) [archive if delete instruction] |
917 |
$valF['delai']=$val['archive_delai']; |
$valF['delai']=$val['archive_delai']; |
918 |
$valF['accord_tacite']=$val['archive_accord_tacite']; |
$valF['accord_tacite']=$val['archive_accord_tacite']; |
921 |
$valF['avis_decision']= null; |
$valF['avis_decision']= null; |
922 |
else |
else |
923 |
$valF['avis_decision']=$val['archive_avis']; |
$valF['avis_decision']=$val['archive_avis']; |
|
// if= compatibilite pgsql |
|
924 |
if($val['archive_date_complet']!='') |
if($val['archive_date_complet']!='') |
925 |
$valF['date_complet']=$val['archive_date_complet']; |
$valF['date_complet']=$val['archive_date_complet']; |
926 |
if($val['archive_date_rejet']!='') |
if($val['archive_date_rejet']!='') |
939 |
$valF['date_chantier']= $val['archive_date_chantier']; |
$valF['date_chantier']= $val['archive_date_chantier']; |
940 |
if($val['archive_date_conformite']!='') |
if($val['archive_date_conformite']!='') |
941 |
$valF['date_conformite']= $val['archive_date_conformite']; |
$valF['date_conformite']= $val['archive_date_conformite']; |
942 |
|
// On met à jour le dossier |
943 |
$cle= " dossier = '".$val['dossier']."'"; |
$cle = " dossier='".$val['dossier']."'"; |
944 |
$res= $db->autoExecute(DB_PREFIXE.'dossier',$valF,DB_AUTOQUERY_UPDATE,$cle); |
$res1 = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle); |
945 |
if (database::isError($res)) |
$this->addToLog("triggerajouterapres(): db->autoexecute(\"".DB_PREFIXE."dossier\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
946 |
|
if (database::isError($res1)) { |
947 |
die($res->getMessage()); |
die($res->getMessage()); |
|
else{ |
|
|
if ($DEBUG == 1) |
|
|
echo "La requête de mise à jour est effectuée.<br>"; |
|
948 |
} |
} |
949 |
|
// Affichage d'informations à l'utilisateur |
950 |
|
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
951 |
} |
} |
952 |
|
|
953 |
// ============================================= |
// ============================================= |
954 |
// calcul de date avec ajout de mois (delais) |
// calcul de date avec ajout de mois (delais) |
955 |
// [add months (delay) and calculation final date] |
// [add months (delay) and calculation final date] |