18 |
- voir script_lang.js : bible ... |
- voir script_lang.js : bible ... |
19 |
*/ |
*/ |
20 |
require_once ("../gen/obj/instruction.class.php"); |
require_once ("../gen/obj/instruction.class.php"); |
21 |
|
require_once("../services/outgoing/messageenqueuer.php"); |
22 |
|
|
23 |
class instruction extends instruction_gen { |
class instruction extends instruction_gen { |
24 |
|
|
30 |
$this->constructeur($id,$db,$debug); |
$this->constructeur($id,$db,$debug); |
31 |
}// fin constructeur |
}// fin constructeur |
32 |
|
|
33 |
function setvalF($val){ |
// {{{ Gestion de la confidentialité des données spécifiques |
34 |
$this->valF['instruction'] = $val['instruction']; |
|
35 |
$this->valF['destinataire'] = $val['destinataire']; |
/** |
36 |
$this->valF['lettretype'] = $val['lettretype']; |
* Surcharge pour gérer les actions disponibles dans le portlet |
37 |
$this->valF['dossier'] = $val['dossier']; |
*/ |
38 |
if($val['datecourrier']!="") |
function checkAccessibility() { |
39 |
$this->valF['datecourrier'] = $this->dateDB($val['datecourrier']); |
// |
40 |
$this->valF['complement'] = $val['complement']; |
parent::checkAccessibility(); |
41 |
$this->valF['complement2'] = $val['complement2']; |
// Si l'utilisateur est un intructeur qui en correspond pas à la |
42 |
$this->valF['evenement'] = $val['evenement']; |
// division du dossier |
43 |
|
if ($this->f->isUserInstructeur() |
44 |
|
&& isset($this->f->om_utilisateur["division"]) |
45 |
|
&& $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier()) { |
46 |
|
// |
47 |
|
$this->actions_sup = array(); |
48 |
|
$this->setParameter("actions", array()); |
49 |
|
} |
50 |
|
// Si une action 'lu' est présente et que le champ lu est à true |
51 |
|
// on supprime l'action |
52 |
|
if (isset($this->actions_sup["lu"]) |
53 |
|
&& isset($this->val[array_search("lu", $this->champs)]) |
54 |
|
&& $this->val[array_search("lu", $this->champs)]== "t") { |
55 |
|
unset($this->actions_sup["lu"]); |
56 |
|
} |
57 |
|
} |
58 |
|
|
59 |
|
/** |
60 |
|
* Cette methode est à surcharger elle permet de tester dans chaque classe |
61 |
|
* des droits des droits spécifiques en fonction des données |
62 |
|
*/ |
63 |
|
function canAccess() { |
64 |
|
// Si l'utilisateur est un intructeur qui ne correspond pas à la |
65 |
|
// division du dossier |
66 |
|
if ($this->f->isUserInstructeur() |
67 |
|
&& $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier() |
68 |
|
&& $this->getParameter("maj") != 3) { |
69 |
|
// |
70 |
|
return false; |
71 |
|
} |
72 |
|
// |
73 |
|
return true; |
74 |
|
} |
75 |
|
|
76 |
|
/** |
77 |
|
* Cette méthode permet de récupérer la division d'un dossier |
78 |
|
*/ |
79 |
|
function getDivisionFromDossier() { |
80 |
|
// |
81 |
|
if (!isset($this->val[array_search("dossier", $this->champs)])) { |
82 |
|
return NULL; |
83 |
|
} |
84 |
|
// |
85 |
|
$sql = "select division from ".DB_PREFIXE."dossier "; |
86 |
|
$sql .= " where dossier='".$this->val[array_search("dossier", $this->champs)]."'"; |
87 |
|
// |
88 |
|
$division = $this->db->getOne($sql); |
89 |
|
$this->addToLog("getDivisionFromDossier(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
90 |
|
database::isError($division); |
91 |
|
// |
92 |
|
return $division; |
93 |
} |
} |
94 |
|
|
95 |
|
// }}} |
96 |
|
|
97 |
function cleSecondaire($id,&$db,$val,$DEBUG) { |
function cleSecondaire($id,&$db,$val,$DEBUG) { |
98 |
// controle suppression cle secondaire [secondary key delete control] |
parent::cleSecondaire($id,$db,$val,$DEBUG); |
99 |
// ------------------------------------------------------------------------------------ |
// controle suppression cle secondaire [secondary key delete control] |
100 |
// specifique detruire que le dernier [specific instruction : delete the last event ] |
// ------------------------------------------------------------------------------------ |
101 |
// ------------------------------------------------------------------------------------ |
// specifique detruire que le dernier [specific instruction : delete the last event ] |
102 |
|
// ------------------------------------------------------------------------------------ |
103 |
$dernierevenement=''; |
$dernierevenement=''; |
104 |
$sql="select max(instruction) from instruction where dossier ='". |
$sql="select max(instruction) from ".DB_PREFIXE."instruction where dossier ='". |
105 |
$this->idxformulaire."'"; |
$this->idxformulaire."'"; |
106 |
$dernierevenement = $db->getOne($sql); |
$dernierevenement = $db->getOne($sql); |
107 |
if($dernierevenement==$id){ |
if($dernierevenement==$id){ |
108 |
$this->correct=true; |
$this->correct=true; |
109 |
$this->msg="<br>"._('destruction_chronologique')." ok <br>"; |
$this->addToMessage(_('Destruction_chronologique')); |
110 |
}else{ |
}else{ |
111 |
$this->msg="<br>"._('destruction_evenement')." : ".$dernierevenement. |
$this->addToMessage(_('Destruction_evenement')." : ".$dernierevenement); |
112 |
"<br>"._('destruction_chronologique'); |
$this->addToMessage(_('Destruction_chronologique')); |
113 |
$this->correct=false; |
$this->correct=false; |
114 |
} |
} |
115 |
} |
} |
116 |
|
|
117 |
function verifier($val,&$db,$DEBUG){ |
// Sélectionne le signataire_arrete par défaut |
118 |
$this->correct=True; |
function setVal(&$form,$maj,$validation){ |
119 |
$imgv=""; |
|
120 |
$f=" ! "; |
// Ajout |
121 |
$imgv="<img src='../img/punaise.png' style='vertical-align:middle' hspace='2' border='0'>"; |
if($maj == 0) { |
122 |
// obligatoire |
|
123 |
if ($this->valF['destinataire']==""){ |
// Création de la requête |
124 |
$this->correct=false; |
$sql = "SELECT signataire_arrete |
125 |
$this->msg= $this->msg.$imgv." "._('instruction')." ". |
FROM ".DB_PREFIXE."signataire_arrete |
126 |
_('obligatoire').$f; |
WHERE defaut IS TRUE"; |
127 |
} |
|
128 |
if ($val['datecourrier']==""){ |
// Exécution de la requête |
129 |
$this->correct=false; |
$this->f->addToLog("deleteAllLienDossierInstructionTypeEvenementEvenement(): db->query(\"".$sql."\");", VERBOSE_MODE); |
130 |
$this->msg= $this->msg.$imgv." "._('datecourrier')." ". |
$res = $this->f->db->query($sql); |
131 |
_('obligatoire').$f; |
$this->f->isDatabaseError(); |
132 |
} |
|
133 |
if ($val['evenement']==""){ |
$row = $res->fetchrow(DB_FETCHMODE_ASSOC); |
134 |
$this->correct=false; |
|
135 |
$this->msg= $this->msg.$imgv." "._('evenement')." ". |
if ( isset($row['signataire_arrete']) && is_numeric($row['signataire_arrete'])){ |
136 |
_('obligatoire').$f; |
|
137 |
|
$form->setVal("signataire_arrete",$row['signataire_arrete']); |
138 |
|
} |
139 |
} |
} |
140 |
}//verifier |
} |
141 |
|
|
142 |
|
/*Met des valeurs par défaut dans certains des sous-formulaire*/ |
143 |
function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire){ |
function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire){ |
144 |
if ($validation==0) { |
if ($validation==0 and $maj<2) { |
145 |
if ($maj == 0){ |
if ($maj == 0){ |
146 |
$form->setVal("destinataire", $idxformulaire); |
$form->setVal("destinataire", $idxformulaire); |
147 |
$form->setVal("dossier", $idxformulaire); |
$form->setVal("dossier", $idxformulaire); |
148 |
$form->setVal("datecourrier", date('Y-m-d')); |
$form->setVal("date_evenement", date('Y-m-d')); |
149 |
} |
} |
150 |
$form->setVal("bible_auto","bible_auto()"); |
$form->setVal("bible_auto","bible_auto()"); |
151 |
$form->setVal("bible","bible()"); |
$form->setVal("bible","bible()"); |
155 |
$this->idxformulaire=$idxformulaire; |
$this->idxformulaire=$idxformulaire; |
156 |
} |
} |
157 |
|
|
158 |
|
/*Affecte un type à certains champs*/ |
159 |
function setType(&$form,$maj) { |
function setType(&$form,$maj) { |
160 |
if ($maj < 2) { //ajouter et modifier |
parent::setType($form,$maj); |
161 |
$form->setType('destinataire', 'hidden'); |
if ($maj < 2) { //ajouter et modifier |
162 |
$form->setType('lettretype', 'hiddenstatic'); |
$form->setType('destinataire', 'hidden'); |
163 |
$form->setType('complement', 'textarea'); |
$form->setType('lettretype', 'hiddenstatic'); |
164 |
$form->setType('complement2', 'textarea'); |
$form->setType('complement', 'textarea'); |
165 |
|
$form->setType('complement2', 'textarea'); |
166 |
|
$form->setType('bible_auto', 'httpclick'); |
167 |
|
$form->setType('bible', 'httpclick'); |
168 |
|
$form->setType('bible2', 'httpclick'); |
169 |
|
$form->setType('dossier', 'hidden'); |
170 |
|
$form->setType('libelle', 'hiddenstatic'); |
171 |
|
$form->setType('signataire_arrete','select'); |
172 |
|
if($maj==0){ // add |
173 |
|
$form->setType('instruction', 'hiddenstatic'); |
174 |
|
$form->setType('evenement', 'select'); |
175 |
|
$form->setType('date_evenement', 'date2'); |
176 |
|
}else{ // modify |
177 |
|
$form->setType('instruction', 'hiddenstatic'); |
178 |
|
$form->setType('evenement', 'hiddenstatic'); |
179 |
|
//$form->setType('date_evenement', 'hiddenstaticdate'); |
180 |
|
$form->setType('date_evenement', 'date2'); |
181 |
|
// necessaire pour calcul de date en modification |
182 |
|
$form->setType('delai', 'hiddenstatic'); |
183 |
|
} |
184 |
|
} elseif($maj==2){ |
185 |
|
$form->setType('dossier', 'hidden'); |
186 |
|
$form->setType('bible_auto', 'hidden'); |
187 |
|
$form->setType('bible', 'hidden'); |
188 |
|
$form->setType('bible2', 'hidden'); |
189 |
|
}else { |
190 |
|
$form->setType('destinataire', 'hidden'); |
191 |
|
$form->setType('dossier', 'hidden'); |
192 |
|
$form->setType('bible_auto', 'hidden'); |
193 |
|
$form->setType('bible', 'hidden'); |
194 |
|
$form->setType('bible2', 'hidden'); |
195 |
|
} |
196 |
$form->setType('complement3', 'hidden'); |
$form->setType('complement3', 'hidden'); |
197 |
$form->setType('bible3', 'hidden'); |
$form->setType('bible3', 'hidden'); |
198 |
$form->setType('complement4', 'hidden'); |
$form->setType('complement4', 'hidden'); |
219 |
$form->setType('bible14', 'hidden'); |
$form->setType('bible14', 'hidden'); |
220 |
$form->setType('complement15', 'hidden'); |
$form->setType('complement15', 'hidden'); |
221 |
$form->setType('bible15', 'hidden'); |
$form->setType('bible15', 'hidden'); |
|
$form->setType('bible_auto', 'httpclick'); |
|
|
$form->setType('bible', 'httpclick'); |
|
|
$form->setType('bible2', 'httpclick'); |
|
|
$form->setType('dossier', 'hiddenstatic'); |
|
222 |
$form->setType('delai', 'hidden'); |
$form->setType('delai', 'hidden'); |
223 |
$form->setType('etat', 'hidden'); |
$form->setType('etat', 'hidden'); |
224 |
$form->setType('accord_tacite', 'hidden'); |
$form->setType('accord_tacite', 'hidden'); |
225 |
$form->setType('action', 'hidden'); |
$form->setType('action', 'hidden'); |
226 |
$form->setType('delai_notification', 'hidden'); |
$form->setType('delai_notification', 'hidden'); |
227 |
$form->setType('avis', 'hidden'); |
$form->setType('avis_decision', 'hidden'); |
228 |
$form->setType('archive_delai', 'hidden'); |
$form->setType('archive_delai', 'hidden'); |
229 |
$form->setType('archive_etat', 'hidden'); |
$form->setType('archive_etat', 'hidden'); |
230 |
$form->setType('archive_accord_tacite', 'hidden'); |
$form->setType('archive_accord_tacite', 'hidden'); |
237 |
$form->setType('archive_date_validite', 'hidden'); |
$form->setType('archive_date_validite', 'hidden'); |
238 |
$form->setType('archive_date_achevement', 'hidden'); |
$form->setType('archive_date_achevement', 'hidden'); |
239 |
$form->setType('archive_date_conformite', 'hidden'); |
$form->setType('archive_date_conformite', 'hidden'); |
240 |
$form->setType('archive_date_chantier', 'hidden'); |
$form->setType('archive_date_chantier', 'hidden'); |
241 |
$form->setType('libelle', 'hiddenstatic'); |
$form->setType('numero_arrete', 'hidden'); |
|
if($maj==0){ // add |
|
|
$form->setType('instruction', 'hiddenstatic'); |
|
|
$form->setType('evenement', 'select'); |
|
|
$form->setType('datecourrier', 'date2'); |
|
|
}else{ // modify |
|
|
$form->setType('instruction', 'hiddenstatic'); |
|
|
$form->setType('evenement', 'hiddenstatic'); |
|
|
$form->setType('datecourrier', 'hiddenstaticdate'); |
|
|
} |
|
|
}else{ // supprimer [delete] |
|
|
$form->setType('instruction', 'hiddenstatic'); |
|
|
$form->setType('dossier', 'hiddenstatic'); |
|
|
$form->setType('archive_delai', 'hiddenstatic'); |
|
|
$form->setType('archive_etat', 'hiddenstatic'); |
|
|
$form->setType('archive_accord_tacite', 'hiddenstatic'); |
|
|
$form->setType('archive_avis', 'hiddenstatic'); |
|
|
$form->setType('archive_date_complet', 'hiddenstatic'); |
|
|
$form->setType('archive_date_rejet', 'hiddenstatic'); |
|
|
$form->setType('archive_date_limite', 'hiddenstatic'); |
|
|
$form->setType('archive_date_notification_delai', 'hiddenstatic'); |
|
|
$form->setType('archive_date_decision', 'hiddenstatic'); |
|
|
$form->setType('archive_date_validite', 'hiddenstatic'); |
|
|
$form->setType('archive_date_achevement', 'hiddenstatic'); |
|
|
} |
|
242 |
} |
} |
243 |
|
|
244 |
|
/*Met des valeurs choisies dans certains select du formulaire*/ |
245 |
|
function setSelect(&$form, $maj,&$db,$DEBUG) { |
246 |
|
if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php")) |
247 |
|
include ("../sql/".$db->phptype."/".$this->table.".form.inc.php"); |
248 |
|
|
249 |
function setTaille(&$form,$maj){ |
parent::setSelect($form, $maj, $db, $DEBUG); |
|
$form->setTaille('complement', 120); |
|
|
$form->setTaille('complement2', 120); |
|
|
$form->setTaille('datecourrier', 12); |
|
|
} |
|
|
|
|
|
function setMax(&$form,$maj){ |
|
|
$form->setMax('complement',12 ); |
|
|
$form->setMax('complement2',12 ); |
|
|
} |
|
250 |
|
|
251 |
//function setSelect(&$form, $maj,&$db,$DEBUG,$idxformulaire) { |
// *** evenement *** |
252 |
function setSelect(&$form, $maj,&$db,$DEBUG) { |
$contenu=array(); |
253 |
if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc")) |
// etat du dossier |
254 |
include ("../sql/".$db->phptype."/".$this->table.".form.inc"); |
$sql="select etat from ".DB_PREFIXE."dossier where dossier ='". |
255 |
if($maj<2){ |
$this->idxformulaire."'"; |
256 |
// *** evenement *** |
$etat_dossier = $db->getOne($sql); |
257 |
$contenu=array(); |
// nature du dossier d'autorisation |
258 |
// etat du dossier |
$sql="select code from ".DB_PREFIXE."dossier |
259 |
$sql="select etat from dossier where dossier ='". |
INNER JOIN ".DB_PREFIXE."dossier_autorisation ON |
260 |
$this->idxformulaire."'"; |
dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
261 |
$etat_dossier = $db->getOne($sql); |
INNER JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille ON |
262 |
$nature_dossier= substr($this->idxformulaire,0,2); |
dossier_autorisation.dossier_autorisation_type_detaille = |
263 |
// recherche des evenement de transition |
dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
264 |
$sql= $sql_transition." where transition.etat ='".$etat_dossier."' and (evenement.nature ='". |
WHERE dossier ='". |
265 |
$nature_dossier."' or (nature ='T' and nature !='CU')) order by evenement.action"; |
$this->idxformulaire."'"; |
266 |
//$sql= $sql_transition." where (evenement.nature ='". |
$nature_dossier = $db->getOne($sql); |
267 |
// $nature_dossier."' or (nature ='T' and nature !='CU')) order by evenement.action"; |
|
268 |
|
// recherche des evenement de transition |
269 |
|
// XXX modifier la requète après la modification de structure du workflow |
270 |
$res = $db->query($sql); |
$sql= $sql_transition." where transition.etat ='".$etat_dossier."' and dossier='". |
271 |
if (database::isError($res)) |
$this->idxformulaire."' order by evenement.action"; |
272 |
die($res->getMessage()); |
|
273 |
$contenu[0][0]=""; |
// *** attention en dur le CU |
274 |
$contenu[1][0]=_('choisir')." "._('evenement'); |
$this->addToLog("setSelect(): db->query(\"".$sql."\");", VERBOSE_MODE); |
275 |
$k=1; |
|
276 |
while ($row=& $res->fetchRow()){ |
$res = $db->query($sql); |
277 |
if($maj==0){ // ajouter |
if (database::isError($res)) |
278 |
$contenu[0][$k]=$row[0]; |
die($res->getMessage()); |
279 |
$contenu[1][$k]=$row[1]; |
$contenu[0][0]=""; |
280 |
$k++; |
$contenu[1][0]=_('choisir')." "._('evenement'); |
281 |
}else{ |
$k=1; |
282 |
// select hiddenstatic |
while ($row=& $res->fetchRow()){ |
283 |
$contenu[0][$k]=$row[0]; |
if($maj==0){ // ajouter |
284 |
$contenu[1][$k]=$row[1]; |
$contenu[0][$k]=$row[0]; |
285 |
$k++; |
$contenu[1][$k]=$row[1]; |
286 |
} |
$k++; |
287 |
} |
}else{ |
288 |
$form->setSelect("evenement",$contenu); |
// select hiddenstatic |
289 |
// lien bible_auto [link] |
$contenu[0][$k]=$row[0]; |
290 |
$contenu=array(); |
$contenu[1][$k]=$row[1]; |
291 |
$contenu[0]=" automatique "; |
$k++; |
292 |
$form->setSelect("bible_auto",$contenu); |
} |
|
// lien bible1 |
|
|
$contenu=array(); |
|
|
$contenu[0]=" Bible "; |
|
|
$form->setSelect("bible",$contenu); |
|
|
// lien bible2 |
|
|
$contenu=array(); |
|
|
$contenu[0]=" Bible "; |
|
|
$form->setSelect("bible2",$contenu); |
|
293 |
} |
} |
294 |
|
$form->setSelect("evenement",$contenu); |
295 |
|
// lien bible_auto [link] |
296 |
|
$contenu=array(); |
297 |
|
$contenu[0]=" automatique "; |
298 |
|
$form->setSelect("bible_auto",$contenu); |
299 |
|
// lien bible1 |
300 |
|
$contenu=array(); |
301 |
|
$contenu[0]=" Bible "; |
302 |
|
$form->setSelect("bible",$contenu); |
303 |
|
// lien bible2 |
304 |
|
$contenu=array(); |
305 |
|
$contenu[0]=" Bible "; |
306 |
|
$form->setSelect("bible2",$contenu); |
307 |
} // function select |
} // function select |
308 |
|
|
309 |
function setGroupe(&$form,$maj){ |
function setLayout(&$form, $maj){ |
310 |
$form->setGroupe('evenement','D'); |
if ( $maj < 2 OR $maj == 3 ) { |
311 |
$form->setGroupe('libelle','G'); |
/*Champ sur lequel s'ouvre le bloc 1 */ |
312 |
$form->setGroupe('datecourrier','G'); |
$form->setBloc('evenement','D',"","col_12"); |
313 |
$form->setGroupe('lettretype','F'); |
|
314 |
} |
$form->setFieldset('evenement','D',_('Evenement')); |
315 |
|
$form->setBloc('evenement','D',"","group col_12"); |
316 |
function setRegroupe(&$form,$maj){ |
$form->setBloc('date_evenement','F'); |
317 |
$form->setRegroupe('evenement','D',_('evenement'), "collapsible"); |
$form->setFieldset('lettretype','F',''); |
318 |
$form->setRegroupe('libelle','G',''); |
|
319 |
$form->setRegroupe('datecourrier','G',''); |
$form->setBloc('lettretype','F'); |
320 |
$form->setRegroupe('lettretype','F',''); |
|
321 |
$form->setRegroupe('complement','D',_('complement'), "startClosed"); |
$form->setBloc('date_finalisation_courrier','D',"","col_12"); |
322 |
$form->setRegroupe('bible_auto','G',''); |
|
323 |
$form->setRegroupe('bible','F',''); |
$form->setFieldset('date_finalisation_courrier','D',_('Dates')); |
324 |
$form->setRegroupe('complement2','D',_('complement2'), "startClosed"); |
$form->setBloc('date_finalisation_courrier','D',"","col_6"); |
325 |
$form->setRegroupe('bible2','F',''); |
$form->setBloc('date_envoi_controle_legalite','F'); |
326 |
|
|
327 |
|
$form->setBloc('signataire_arrete','D',"","col_6"); |
328 |
|
$form->setBloc('date_retour_controle_legalite','F'); |
329 |
|
$form->setFieldset('date_retour_controle_legalite','F',''); |
330 |
|
|
331 |
|
$form->setBloc('date_retour_controle_legalite','F'); |
332 |
|
|
333 |
|
$form->setBloc('complement','D',"","col_12"); |
334 |
|
$form->setFieldset('complement','D',_('Complement')); |
335 |
|
$form->setFieldset('bible','F',''); |
336 |
|
$form->setBloc('bible','F'); |
337 |
|
|
338 |
|
$form->setBloc('complement2','D',"","col_12"); |
339 |
|
$form->setFieldset('complement2','D',_('Complement 2')); |
340 |
|
$form->setFieldset('bible2','F',''); |
341 |
|
$form->setBloc('bible2','F'); |
342 |
|
} |
343 |
} |
} |
344 |
|
|
345 |
|
/*Change le libellé de certains champs*/ |
346 |
function setLib(&$form,$maj) { |
function setLib(&$form,$maj) { |
347 |
parent :: setLib($form,$maj); |
parent :: setLib($form,$maj); |
348 |
$form->setLib('libelle',' '); |
$form->setLib('libelle',' '); |
349 |
$form->setLib('bible_auto',""); |
$form->setLib('bible_auto',""); |
350 |
$form->setLib('bible',""); |
$form->setLib('bible',""); |
351 |
$form->setLib('bible2',""); |
$form->setLib('bible2',""); |
|
$form->setLib('lettretype',"->"._(" courrier ")); |
|
|
$form->setLib('datecourrier',_(" du ")); |
|
|
} |
|
|
|
|
|
function setOnchange(&$form,$maj){ |
|
|
$form->setOnchange("datecourrier","fdate(this)"); |
|
352 |
} |
} |
353 |
|
|
354 |
// ================================================================== |
// ================================================================== |
355 |
// trigger avant modification données [trigger before modify data] |
// trigger avant modification des données [trigger before modify data] |
356 |
// ================================================================== |
// ================================================================== |
357 |
function triggerajouter($id,&$db,$val,$DEBUG) { |
function triggerajouter($id,&$db,$val,$DEBUG) { |
358 |
// mise a jour instruction avec evenement |
// mise a jour instruction avec evenement |
359 |
// [modify instruction with evenement] |
// [modify instruction with evenement] |
360 |
$sql= "select * from evenement where evenement =".$this->valF['evenement']; |
$sql= "select * from ".DB_PREFIXE."evenement where evenement =".$this->valF['evenement']; |
361 |
|
|
362 |
$res = $db->query($sql); |
$res = $db->query($sql); |
363 |
if (database::isError($res)) |
if (database::isError($res)) die($res->getMessage()); |
364 |
die($res->getMessage()); |
|
365 |
if ($DEBUG == 1) |
if ($DEBUG == 1) |
366 |
echo " la requete ".$sql." est exécutée<br>"; |
echo " la requete ".$sql." est exécutée<br>"; |
367 |
|
|
368 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
369 |
$this->valF['action']=$row['action']; |
|
370 |
|
if(isset($row['action']) and !empty($row['action'])) { |
371 |
|
$this->valF['action']=$row['action']; |
372 |
|
} else { |
373 |
|
$this->valF['action']=NULL; |
374 |
|
} |
375 |
$this->valF['delai']=$row['delai']; |
$this->valF['delai']=$row['delai']; |
376 |
$this->valF['etat']=$row['etat']; |
if(isset($row['etat']) and !empty($row['etat'])) { |
377 |
|
$this->valF['etat']=$row['etat']; |
378 |
|
} else { |
379 |
|
$this->valF['etat']=NULL; |
380 |
|
} |
381 |
$this->valF['accord_tacite']=$row['accord_tacite']; |
$this->valF['accord_tacite']=$row['accord_tacite']; |
382 |
$this->valF['delai_notification']=$row['delai_notification']; |
$this->valF['delai_notification']=$row['delai_notification']; |
383 |
$this->valF['avis']=$row['avis']; |
if(isset($row['avis_decision']) and !empty($row['avis_decision'])) { |
384 |
|
$this->valF['avis_decision']=$row['avis_decision']; |
385 |
|
} else { |
386 |
|
$this->valF['avis_decision']=NULL; |
387 |
|
} |
388 |
if($row['lettretype']!="") |
if($row['lettretype']!="") |
389 |
$this->valF['lettretype']=$row['lettretype']; |
$this->valF['lettretype']=$row['lettretype']; |
390 |
else |
else |
391 |
$this->valF['lettretype']="standard"; |
$this->valF['lettretype']="standard"; |
392 |
|
|
393 |
} |
} |
394 |
$sql= "select * from dossier where dossier = '".$this->valF['dossier']."'"; |
$sql= "select * from ".DB_PREFIXE."dossier where dossier = '".$this->valF['dossier']."'"; |
395 |
$res = $db->query($sql); |
$res = $db->query($sql); |
396 |
if (database::isError($res)) |
if (database::isError($res)) |
397 |
die($res->getMessage()); |
die($res->getMessage()); |
404 |
$this->valF['archive_delai']=$row['delai']; |
$this->valF['archive_delai']=$row['delai']; |
405 |
$this->valF['archive_accord_tacite']=$row['accord_tacite']; |
$this->valF['archive_accord_tacite']=$row['accord_tacite']; |
406 |
$this->valF['archive_etat']=$row['etat']; |
$this->valF['archive_etat']=$row['etat']; |
407 |
$this->valF['archive_avis']=$row['avis']; |
$this->valF['archive_avis']=$row['avis_decision']; |
408 |
// compatibilite pgsql |
// compatibilite pgsql |
409 |
if($row['date_complet']!='') |
if($row['date_complet']!='') |
410 |
$this->valF['archive_date_complet']=$row['date_complet']; |
$this->valF['archive_date_complet']=$row['date_complet']; |
427 |
} |
} |
428 |
} |
} |
429 |
|
|
430 |
|
// Test si une restriction est valide |
431 |
|
// return boolean |
432 |
|
function restrictionIsValid($restriction){ |
433 |
|
|
434 |
|
/* Met des espace avant et après les opérateurs puis transforme la chaine en |
435 |
|
* un tableau */ |
436 |
|
$tabRestriction = str_replace(">="," >= ", |
437 |
|
str_replace("<="," <= ", |
438 |
|
str_replace("-"," - ", |
439 |
|
str_replace("+"," + ",$restriction)))); |
440 |
|
$tabRestriction = explode( " ", $tabRestriction); |
441 |
|
|
442 |
|
//Variables de résultat |
443 |
|
$res = array(); |
444 |
|
$i = 0; |
445 |
|
$comp = ""; |
446 |
|
|
447 |
|
|
448 |
|
//Test que le tableau n'est pas vide |
449 |
|
if ( count($tabRestriction) > 0 ){ |
450 |
|
|
451 |
|
$res[0] = $this->getRestrictionValue($tabRestriction[0]); |
452 |
|
|
453 |
|
//Calcul des variables |
454 |
|
for ( $j = 1 ; $j < count($tabRestriction) ; $j += 2 ) { |
455 |
|
|
456 |
|
//Variable de comparaison |
457 |
|
if ( strcmp( ">=", $tabRestriction[$j] ) == 0 || |
458 |
|
strcmp( "<=", $tabRestriction[$j]) ==0 ){ |
459 |
|
|
460 |
|
$comp = $tabRestriction[$j]; |
461 |
|
$res[++$i] = $this->getRestrictionValue($tabRestriction[$j+1]); |
462 |
|
} |
463 |
|
// Fait l'addition |
464 |
|
elseif ( strcmp( "+", $tabRestriction[$j]) == 0 ){ |
465 |
|
|
466 |
|
$res[$i] = $this->moisdate( $res[$i], $this->getRestrictionValue($tabRestriction[$j+1]) ); |
467 |
|
} |
468 |
|
} |
469 |
|
} |
470 |
|
|
471 |
|
// Effectue le test |
472 |
|
if ( strcmp($comp, ">=") == 0 ){ |
473 |
|
|
474 |
|
if ( $res[0] >= $res[1] || $res[0] == "" ){ |
475 |
|
|
476 |
|
return true; |
477 |
|
} |
478 |
|
else { |
479 |
|
|
480 |
|
return false; |
481 |
|
} |
482 |
|
} |
483 |
|
elseif ( strcmp($comp, "<=") == 0 ){ |
484 |
|
|
485 |
|
if ( $res[0] <= $res[1] || $res[1] == "" ){ |
486 |
|
|
487 |
|
return true; |
488 |
|
} |
489 |
|
else { |
490 |
|
|
491 |
|
return false; |
492 |
|
} |
493 |
|
} |
494 |
|
|
495 |
|
return true; |
496 |
|
} |
497 |
|
|
498 |
|
//Retourne la valeur de valF si $restrictionValue n'est pas un chiffre, le chiffre sinon |
499 |
|
function getRestrictionValue($restrictionValue){ |
500 |
|
|
501 |
|
return ( is_numeric($restrictionValue) ) ? |
502 |
|
$restrictionValue : |
503 |
|
$this->valF[$restrictionValue]; |
504 |
|
} |
505 |
|
|
506 |
|
function regle($regle){ |
507 |
|
$temp = explode ("+",$regle); |
508 |
|
//echo '|'.$regle; |
509 |
|
// cas rejet |
510 |
|
if($regle=="null") // 1 dimension -> null |
511 |
|
return null; |
512 |
|
if(sizeof($temp)==1) // 1 dimension |
513 |
|
if($temp[0]=="archive_date_depot") // initialisation avec le depot |
514 |
|
return $this->$regle; |
515 |
|
else // cas general |
516 |
|
return $this->valF[$regle]; |
517 |
|
if(sizeof($temp)==2){ // 2 dimensions |
518 |
|
if($temp[0]=="archive_date_depot") //initialisation avec le depot |
519 |
|
if(is_numeric($temp[1])) |
520 |
|
return $this->moisdate($this->$temp[0], $temp[1]); |
521 |
|
else |
522 |
|
return $this->moisdate($this->$temp[0], $this->valF[$temp[1]]); |
523 |
|
if($temp[0]=="archive_delai") // majoration de delai |
524 |
|
return $this->valF[$temp[0]]+$this->valF[$temp[1]]; |
525 |
|
// cas general 2 dimensions |
526 |
|
if(is_numeric($temp[1])) |
527 |
|
return $this->moisdate($this->valF[$temp[0]], $temp[1]); |
528 |
|
else |
529 |
|
return $this->moisdate($this->valF[$temp[0]], $this->valF[$temp[1]]); |
530 |
|
} |
531 |
|
if(sizeof($temp)==3){ // 3 dimensions |
532 |
|
// cas date de validite de sursis |
533 |
|
if(is_numeric($temp[1])) |
534 |
|
$temp1 = $this->moisdate($this->valF[$temp[0]], $temp[1]); |
535 |
|
else |
536 |
|
$temp1 = $this->moisdate($this->valF[$temp[0]], $this->valF[$temp[1]]); |
537 |
|
if(is_numeric($temp[2])) |
538 |
|
return $this->moisdate($temp1, $temp[2]); |
539 |
|
else |
540 |
|
return $this->moisdate($temp1, $this->valF[$temp[2]]); |
541 |
|
} |
542 |
|
} |
543 |
|
|
544 |
|
|
545 |
|
|
546 |
// ================================================================== |
// ================================================================== |
547 |
// valeur dossier apres modification [values dossier after action] |
// valeur dossier apres modification [values dossier after action] |
548 |
// ================================================================== |
// ================================================================== |
549 |
function triggerajouterapres($id,&$db,$val,$DEBUG) { |
function triggerajouterapres($id,&$db,$val,$DEBUG) { |
550 |
switch ($this->valF['action']) { |
// mise a null au lieu de "" / voir compatibilite mysql |
551 |
case "initialisation" : |
// voir parametrage CU en dur |
552 |
$valF['delai']= $this->valF['delai']; |
// voir parametrage des actions en dur |
553 |
$valF['etat']= $this->valF['etat']; |
$param=1; |
554 |
$valF['accord_tacite']= $this->valF['accord_tacite']; |
if($param==1){ |
555 |
// la date_complet est la date de depot |
$sql="select * from ".DB_PREFIXE."action where action = '".$this->valF['action']."'"; |
556 |
$valF['date_complet']= $this->archive_date_depot; |
$res = $db->query($sql); |
557 |
$valF['date_limite'] = $this->moisdate($valF['date_complet'],$valF['delai']); |
if (database::isError($res)) |
558 |
$valF['date_notification_delai'] = $this->moisdate($valF['date_complet'],1); |
die($res->getMessage()); |
559 |
break; |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
560 |
case "notification" : |
if($row['regle_etat']!=''){ |
561 |
$valF['delai']= $this->valF['delai']; |
$valF['etat']= $this->regle($row['regle_etat']); |
562 |
$valF['etat']= $this->valF['etat']; |
} |
563 |
$valF['accord_tacite']= $this->valF['accord_tacite']; |
if($row['regle_delai']!=''){ |
564 |
// la date_complet est celle precedemment saisie |
$valF['delai']= $this->regle($row['regle_delai']); |
565 |
$valF['date_complet']=$this->valF['archive_date_complet']; |
} |
566 |
$valF['date_limite'] = $this->moisdate($valF['date_complet'],$valF['delai']); |
if($row['regle_accord_tacite']!=''){ |
567 |
$valF['date_notification_delai'] = $this->moisdate($valF['date_complet'],1); |
$valF['accord_tacite']= $this->regle($row['regle_accord_tacite']); |
568 |
// la date du courrier ne doit pas etre depasse par rapport au delai de |
} |
569 |
// notification [verify notification date] |
if($row['regle_avis']!=''){ |
570 |
if($this->valF['archive_date_notification_delai']<$this->valF['datecourrier']) |
$valF['avis_decision']= $this->regle($row['regle_avis']); |
571 |
$this->msg=$this->msg."<br><img src='../img/erreur.gif'> "._("date_notification_delai")." ". |
} |
572 |
$this->valF['archive_date_notification_delai']." < "._('datecourrier'); |
if($row['regle_date_limite']!=''){ |
573 |
// |
$valF['date_limite']= $this->regle($row['regle_date_limite']); |
574 |
break; |
} |
575 |
case "retour" : |
if($row['regle_date_complet']!=''){ |
576 |
$valF['delai']= $this->valF['delai']; |
$valF['date_complet']= $this->regle($row['regle_date_complet']); |
577 |
$valF['etat']= $this->valF['etat']; |
} |
578 |
$valF['accord_tacite']= $this->valF['accord_tacite']; |
if($row['regle_date_notification_delai']!=''){ |
579 |
// la date_complet est celle de l evenement |
$valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']); |
580 |
$valF['date_complet']= $this->valF['datecourrier']; |
} |
581 |
$valF['date_limite'] = $this->moisdate($valF['date_complet'],$valF['delai']); |
if($row['regle_date_decision']!=''){ |
582 |
$valF['date_notification_delai'] = $this->moisdate($valF['date_complet'],1); |
$valF['date_decision']= $this->regle($row['regle_date_decision']); |
583 |
break; |
} |
584 |
case "rejet" : |
if($row['regle_date_rejet']!=''){ |
585 |
//$valF['delai']=0; // *** delai a garder pour etat dpc |
$valF['date_rejet']= $this->regle($row['regle_date_rejet']); |
586 |
$valF['etat']= $this->valF['etat']; |
} |
587 |
$valF['accord_tacite']= $this->valF['accord_tacite']; |
if($row['regle_date_validite']!=''){ |
588 |
// la date rejet est initialisee |
$valF['date_validite']= $this->regle($row['regle_date_validite']); |
589 |
$valF['date_rejet']= $this->valF['datecourrier']; |
} |
590 |
// les dates de depart et fin d instruction sont annulées |
if($row['regle_date_chantier']!=''){ |
591 |
$valF['date_limite'] =""; |
$valF['date_chantier']= $this->regle($row['regle_date_chantier']); |
592 |
$valF['date_notification_delai'] =""; |
} |
593 |
$valF['date_complet']=""; |
if($row['regle_date_achevement']!=''){ |
594 |
break; |
$valF['date_achevement']= $this->regle($row['regle_date_achevement']); |
595 |
case "majoration" : |
} |
596 |
$valF['delai']= $this->valF['archive_delai']+$this->valF['delai']; |
if($row['regle_date_conformite']!=''){ |
597 |
$valF['etat']= $this->valF['etat']; |
$valF['date_conformite']= $this->regle($row['regle_date_conformite']); |
598 |
$valF['accord_tacite']= $this->valF['accord_tacite']; |
} |
599 |
$valF['date_complet']=$this->valF['archive_date_complet']; |
|
600 |
// majoration de la date limite |
// Appel des méthode stockées dans le champ methode_trigger |
601 |
$valF['date_limite'] = $this->moisdate($valF['date_complet'],$valF['delai']); |
if($row['methode_trigger'] != "") { |
602 |
$valF['date_notification_delai'] = $this->moisdate($valF['date_complet'],1); |
foreach (explode(";", $row['methode_trigger']) as $methode) { |
603 |
// la date du courrier ne doit pas etre depasse par rapport au delai de |
if(method_exists($this, $methode)) { |
604 |
// notification |
$this->$methode(); |
605 |
if($this->valF['archive_date_notification_delai']<$this->valF['datecourrier']) |
} |
606 |
$this->msg=$this->msg."<br><img src='../img/erreur.gif'>"._("date_notification_delai"). |
|
607 |
$this->valF['archive_date_notification_delai']." < "._('datecourrier'); |
} |
608 |
break; |
} |
609 |
case "acceptation" : |
} |
610 |
$valF['etat']= $this->valF['etat']; |
}else{ |
611 |
$valF['date_decision']= $this->valF['datecourrier']; |
switch ($this->valF['action']) { |
612 |
$valF['avis']= $this->valF['avis']; |
case "initialisation" : |
613 |
// date de validite = date de l evenement + delai |
$valF['delai']= $this->valF['delai']; |
614 |
$valF['date_validite'] = $this->moisdate($this->valF['datecourrier'],$this->valF['delai']); |
$valF['etat']= $this->valF['etat']; |
615 |
break; |
$valF['accord_tacite']= $this->valF['accord_tacite']; |
616 |
case "refus" : |
// la date_complet est la date de depot |
617 |
$valF['etat']= $this->valF['etat']; |
$valF['date_complet']= $this->archive_date_depot; // **** |
618 |
$valF['date_decision']= $this->valF['datecourrier']; |
$valF['date_limite'] = $this->moisdate($valF['date_complet'],$valF['delai']); |
619 |
$valF['avis']= $this->valF['avis']; |
$valF['date_notification_delai'] = $this->moisdate($valF['date_complet'],1); |
620 |
break; |
break; |
621 |
case "prolongation" : |
case "notification" : |
622 |
$valF['date_validite'] = $this->moisdate($this->valF['archive_date_validite'],$this->valF['delai']); |
$valF['delai']= $this->valF['delai']; |
623 |
break; |
$valF['etat']= $this->valF['etat']; |
624 |
case "sursis" : |
$valF['accord_tacite']= $this->valF['accord_tacite']; |
625 |
$valF['date_limite'] = $this->moisdate($this->valF['datecourrier'],$this->valF['delai']); |
// la date_complet est celle precedemment saisie |
626 |
$valF['etat']= $this->valF['etat']; |
$valF['date_complet']=$this->valF['archive_date_complet']; |
627 |
$valF['accord_tacite']= $this->valF['accord_tacite']; |
$valF['date_limite'] = $this->moisdate($valF['date_complet'],$valF['delai']); |
628 |
$valF['avis']= $this->valF['avis']; |
$valF['date_notification_delai'] = $this->moisdate($valF['date_complet'],1); |
629 |
$valF['date_decision']= $this->valF['datecourrier']; |
// la date du courrier ne doit pas etre depasse par rapport au delai de |
630 |
$temp = $valF['date_limite']; |
// notification [verify notification date] |
631 |
$valF['date_validite']= $this->moisdate($temp,2); |
if($this->valF['archive_date_notification_delai']<$this->valF['date_evenement']) |
632 |
echo $valF['date_limite']."vvv" ; |
$this->msg=$this->msg."<br><img src='../img/erreur.gif'> "._("date_notification_delai")." ". |
633 |
break; |
$this->valF['archive_date_notification_delai']." < "._('date_evenement'); |
634 |
case "execution" : |
// |
635 |
$valF['etat']= $this->valF['etat']; |
break; |
636 |
$valF['date_chantier'] = $this->valF['datecourrier']; |
case "retour" : |
637 |
echo $this->msg=$this->msg.$valF['date_chantier']."***"; |
$valF['delai']= $this->valF['delai']; |
638 |
break; |
$valF['etat']= $this->valF['etat']; |
639 |
case "achevement" : |
$valF['accord_tacite']= $this->valF['accord_tacite']; |
640 |
$valF['etat']= $this->valF['etat']; |
// la date_complet est celle de l evenement |
641 |
$valF['date_achevement'] = $this->valF['datecourrier']; |
$valF['date_complet']= $this->valF['date_evenement']; |
642 |
break; |
$valF['date_limite'] = $this->moisdate($valF['date_complet'],$valF['delai']); |
643 |
case "archivage" : |
$valF['date_notification_delai'] = $this->moisdate($valF['date_complet'],1); |
644 |
$valF['etat']= $this->valF['etat']; |
break; |
645 |
$valF['date_conformite'] = $this->valF['datecourrier']; |
case "rejet" : |
646 |
break; |
//$valF['delai']=0; // *** delai a garder pour etat dpc |
647 |
/* |
$valF['etat']= $this->valF['etat']; |
648 |
case "abandon" : |
$valF['accord_tacite']= $this->valF['accord_tacite']; |
649 |
$valF['etat']= $this->valF['etat']; |
// la date rejet est initialisee |
650 |
break; |
$valF['date_rejet']= $this->valF['date_evenement']; |
651 |
*/ |
// les dates de depart et fin d instruction sont annulées |
652 |
default: |
$valF['date_limite'] =null; |
653 |
if ($this->valF['etat']!="") |
$valF['date_notification_delai'] =null; |
654 |
$valF['etat']= $this->valF['etat']; |
$valF['date_complet']=null; |
655 |
}// end switch |
break; |
656 |
|
case "majoration" : |
657 |
|
$valF['delai']= $this->valF['archive_delai']+$this->valF['delai']; |
658 |
|
$valF['etat']= $this->valF['etat']; |
659 |
|
$valF['accord_tacite']= $this->valF['accord_tacite']; |
660 |
|
$valF['date_complet']=$this->valF['archive_date_complet']; |
661 |
|
// majoration de la date limite |
662 |
|
$valF['date_limite'] = $this->moisdate($valF['date_complet'],$valF['delai']); |
663 |
|
$valF['date_notification_delai'] = $this->moisdate($valF['date_complet'],1); |
664 |
|
// la date du courrier ne doit pas etre depasse par rapport au delai de |
665 |
|
// notification |
666 |
|
if($this->valF['archive_date_notification_delai']<$this->valF['date_evenement']) |
667 |
|
$this->msg=$this->msg."<br><img src='../img/erreur.gif'>"._("date_notification_delai"). |
668 |
|
$this->valF['archive_date_notification_delai']." < "._('date_evenement'); |
669 |
|
break; |
670 |
|
case "acceptation" : |
671 |
|
$valF['etat']= $this->valF['etat']; |
672 |
|
$valF['date_decision']= $this->valF['date_evenement']; |
673 |
|
$valF['avis_decision']= $this->valF['avis_decision']; |
674 |
|
// date de validite = date de l evenement + delai |
675 |
|
$valF['date_validite'] = $this->moisdate($this->valF['date_evenement'],$this->valF['delai']); |
676 |
|
break; |
677 |
|
case "refus" : |
678 |
|
$valF['etat']= $this->valF['etat']; |
679 |
|
$valF['date_decision']= $this->valF['date_evenement']; |
680 |
|
$valF['avis_decision']= $this->valF['avis_decision']; |
681 |
|
break; |
682 |
|
case "prolongation" : |
683 |
|
$valF['date_validite'] = $this->moisdate($this->valF['archive_date_validite'],$this->valF['delai']); |
684 |
|
break; |
685 |
|
case "sursis" : |
686 |
|
$valF['date_limite'] = $this->moisdate($this->valF['date_evenement'],$this->valF['delai']); |
687 |
|
$valF['etat']= $this->valF['etat']; |
688 |
|
$valF['accord_tacite']= $this->valF['accord_tacite']; |
689 |
|
$valF['avis_decision']= $this->valF['avis_decision']; |
690 |
|
$valF['date_decision']= $this->valF['date_evenement']; |
691 |
|
$temp = $valF['date_limite']; |
692 |
|
$valF['date_validite']= $this->moisdate($temp,2); |
693 |
|
break; |
694 |
|
case "execution" : |
695 |
|
$valF['etat']= $this->valF['etat']; |
696 |
|
$valF['date_chantier'] = $this->valF['date_evenement']; |
697 |
|
//echo $this->msg=$this->msg.$valF['date_chantier'].""; |
698 |
|
break; |
699 |
|
case "achevement" : |
700 |
|
$valF['etat']= $this->valF['etat']; |
701 |
|
$valF['date_achevement'] = $this->valF['date_evenement']; |
702 |
|
break; |
703 |
|
case "archivage" : |
704 |
|
$valF['etat']= $this->valF['etat']; |
705 |
|
$valF['date_conformite'] = $this->valF['date_evenement']; |
706 |
|
break; |
707 |
|
|
708 |
// mise à jour dossier [modify dossier] |
default: |
709 |
|
if ($this->valF['etat']!="") |
710 |
|
$valF['etat']= $this->valF['etat']; |
711 |
|
}// end switch |
712 |
|
} // end param |
713 |
if($valF!=""){ |
if($valF!=""){ |
714 |
$cle= " dossier = '".$this->valF['dossier']."'"; |
$cle= " dossier = '".$this->valF['dossier']."'"; |
715 |
$res1= $db->autoExecute('dossier',$valF,DB_AUTOQUERY_UPDATE,$cle); |
$res1= $db->autoExecute(DB_PREFIXE.'dossier',$valF,DB_AUTOQUERY_UPDATE,$cle); |
716 |
if (database::isError($res1)) |
if (database::isError($res1)) |
717 |
die($res->getMessage()); |
die($res->getMessage()); |
718 |
if ($DEBUG == 1) |
if ($DEBUG == 1) |
722 |
$db->affectedRows()." "._('enregistrement'). |
$db->affectedRows()." "._('enregistrement'). |
723 |
" "._('mis_a_jour')."]" ; |
" "._('mis_a_jour')."]" ; |
724 |
} |
} |
725 |
|
// verification si envoi vers ERP est active |
726 |
|
if ($this->f->getParameter('option_erp') != "") { |
727 |
|
// la nature du dossier |
728 |
|
$nature_dossier = substr($this->idxformulaire,0,2); |
729 |
|
$dossier_erp = $this->getFromDB("SELECT erp FROM ".DB_PREFIXE."dossier WHERE dossier = '" . |
730 |
|
$this->valF['dossier'] . "'"); |
731 |
|
$evenement_libelle = $this->getFromDB( |
732 |
|
"SELECT libelle FROM ".DB_PREFIXE."evenement WHERE evenement = '" . |
733 |
|
$this->valF['evenement'] . "'"); |
734 |
|
if ($dossier_erp == 't') { |
735 |
|
// envoi du message en cas d'un PC qui est ERP et sur lequel un evenement |
736 |
|
// d'acceptation etait fait |
737 |
|
if ($nature_dossier == |
738 |
|
$this->f->getParameter('erp_evenement_accepter_dossier_PC') |
739 |
|
&& $this->valF['evenement'] == |
740 |
|
$this->f->getParameter('erp_evenement_accepter_sans_reserve')) { |
741 |
|
$msgenque = new MessageEnqueuer(); |
742 |
|
$msgenque->setDossierInstructionIdentifier($this->valF['dossier']); |
743 |
|
$msgenque->setDecision($evenement_libelle); |
744 |
|
$msgenque->enqueueMessage($msgenque::$ERP_ARRETE_PC_EFFECTUE); |
745 |
|
} |
746 |
|
if ($this->valF['evenement'] == |
747 |
|
$this->f->getParameter('erp_evenement_refuser_dossier')) { |
748 |
|
$msgenque = new MessageEnqueuer(); |
749 |
|
$msgenque->setDossierInstructionIdentifier($this->valF['dossier']); |
750 |
|
$msgenque->enqueueMessage($msgenque::$ERP_DECISION_CONFORMITE_EFFECTUE); |
751 |
|
} |
752 |
|
} |
753 |
|
} // fin de if ($this->f->getParameter('option_erp') != "") |
754 |
|
} |
755 |
|
|
756 |
|
|
757 |
|
/** |
758 |
|
* Fait une requette sql pour extraire la valeur d'un champ, et retourne |
759 |
|
* cette valeur |
760 |
|
* @param string $sql La requete sql a executer |
761 |
|
* @return La valeur du champs cherche, sinon NULL. En cas d'erreur de la BD |
762 |
|
* l'execution s'arrete. |
763 |
|
*/ |
764 |
|
function getFromDB($sql) { |
765 |
|
//$sql = "SELECT libelle FROM ".DB_PREFIXE."dossier WHERE dossier = '" . $dossier . "'"; |
766 |
|
$res = $this->db->limitquery($sql, 0, 1); |
767 |
|
$this->addToLog("getDossierERPSpecification(): db->limitquery(\"". |
768 |
|
str_replace(",",", ",$sql)."\", 0, 1);", VERBOSE_MODE); |
769 |
|
// Si une erreur survient on die |
770 |
|
if (database::isError($res, true)) { |
771 |
|
// Appel de la methode de recuperation des erreurs |
772 |
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), 'instruction'); |
773 |
|
} |
774 |
|
// retourne la nature du dossier |
775 |
|
while ($row =& $res->fetchRow()) { |
776 |
|
return $row[0]; |
777 |
|
} |
778 |
|
// la nature n'etait pas trouve, ce qui ne devrait pas se passer |
779 |
|
return NULL; |
780 |
|
|
781 |
} |
} |
782 |
|
|
783 |
|
|
784 |
|
function triggermodifierapres($id,&$db,$val,$DEBUG) { |
785 |
|
/* |
786 |
|
* cette fonction a pour objet de permettre de modifier la date courrier |
787 |
|
*/ |
788 |
|
$valF=array(); |
789 |
|
$sql= "select action from ".DB_PREFIXE."evenement where evenement =".$this->valF['evenement']; |
790 |
|
$action = $db->getOne($sql); |
791 |
|
if (database::isError($action)) die($action->getMessage().$sql); |
792 |
|
$sql="select * from ".DB_PREFIXE."action where action = '".$action."'"; |
793 |
|
$res = $db->query($sql); |
794 |
|
if (database::isError($res)) die($res->getMessage().$sql); |
795 |
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
796 |
|
// application des regles sur le courrier + delai |
797 |
|
if(preg_match("/date_evenement/",$row['regle_date_limite'])){ |
798 |
|
$valF['date_limite']= $this->regle($row['regle_date_limite']); |
799 |
|
} |
800 |
|
if(preg_match("/date_evenement/",$row['regle_date_complet'])){ |
801 |
|
$valF['date_complet']= $this->regle($row['regle_date_complet']); |
802 |
|
} |
803 |
|
if(preg_match("/date_evenement/",$row['regle_date_notification_delai'])){ |
804 |
|
$valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']); |
805 |
|
} |
806 |
|
if(preg_match("/date_evenement/",$row['regle_date_decision'])){ |
807 |
|
$valF['date_decision']= $this->regle($row['regle_date_decision']); |
808 |
|
} |
809 |
|
if(preg_match("/date_evenement/",$row['regle_date_rejet'])){ |
810 |
|
$valF['date_rejet']= $this->regle($row['regle_date_rejet']); |
811 |
|
} |
812 |
|
if(preg_match("/date_evenement/",$row['regle_date_validite'])){ |
813 |
|
$valF['date_validite']= $this->regle($row['regle_date_validite']); |
814 |
|
} |
815 |
|
if(preg_match("/date_evenement/",$row['regle_date_chantier'])){ |
816 |
|
$valF['date_chantier']= $this->regle($row['regle_date_chantier']); |
817 |
|
} |
818 |
|
if(preg_match("/date_evenement/",$row['regle_date_achevement'])){ |
819 |
|
$valF['date_achevement']= $this->regle($row['regle_date_achevement']); |
820 |
|
} |
821 |
|
if(preg_match("/date_evenement/",$row['regle_date_conformite'])){ |
822 |
|
$valF['date_conformite']= $this->regle($row['regle_date_conformite']); |
823 |
|
} |
824 |
|
} // while |
825 |
|
if($valF!=array()){ |
826 |
|
$cle= " dossier = '".$this->valF['dossier']."'"; |
827 |
|
$res1= $db->autoExecute(DB_PREFIXE.'dossier',$valF,DB_AUTOQUERY_UPDATE,$cle); |
828 |
|
if (database::isError($res1)) |
829 |
|
die($res->getMessage()); |
830 |
|
if ($DEBUG == 1) |
831 |
|
echo "La requête de mise à jour est effectuée.<br>"; |
832 |
|
$this->msg=$this->msg."<br>"._('enregistrement')." ". |
833 |
|
$this->valF['dossier']." "._('table')." dossier [". |
834 |
|
$db->affectedRows()." "._('enregistrement'). |
835 |
|
" "._('mis_a_jour')."]" ; |
836 |
|
} |
837 |
|
|
838 |
|
// Envoi des infos au |
839 |
|
if ($this->valF['date_retour_signature'] != $this->getVal('date_retour_signature')) { |
840 |
|
$msgenque = new MessageEnqueuer(); |
841 |
|
$sqlArrete = "SELECT instruction.signataire_arrete as \"ws_DA_In_Signataire\", |
842 |
|
signataire_arrete.nom as \"ws_DA_In_Sign_Nom\", |
843 |
|
signataire_arrete.prenom as \"ws_DA_In_Sign_Prenom\", |
844 |
|
signataire_arrete.qualite as \"ws_DA_In_Sign_Qualite\", |
845 |
|
instruction.date_evenement as \"ws_DA_In_Dte_Redac\", |
846 |
|
'' as \"ws_DA_In_lieu_Redac\", |
847 |
|
instruction.dossier as \"ws_DA_In_N_Doss_DAS\", |
848 |
|
'' as \"ws_DA_In_Sigle\", |
849 |
|
instruction.etat as \"ws_DA_In_Decision\", |
850 |
|
dossier.date_depot as \"ws_DA_In_Dte_Depot_Dem\", |
851 |
|
dossier.terrain_numero as \"ws_DA_In_N_Voie\", |
852 |
|
'' as \"ws_DA_In_Type_Voie\", |
853 |
|
dossier.complement as \"ws_DA_In_Adresse1\", |
854 |
|
dossier.terrain_adresse_lieu_dit as \"ws_DA_In_Adresse2\", |
855 |
|
dossier.terrain_adresse_code_postal as \"ws_DA_In_CP\", |
856 |
|
dossier.terrain_adresse_localite as \"ws_DA_In_Ville\", |
857 |
|
dossier.terrain_references_cadastrales as \"ws_DA_In_Nb_Parcelle\", |
858 |
|
'' as \"ws_DA_In_Detail_Parcelle\", |
859 |
|
CONCAT(donnees_techniques.am_projet_desc,' ',donnees_techniques.co_projet_desc) as \"ws_DA_In_Nature_Trvx\", |
860 |
|
'' as \"ws_DA_In_Destination_Trvx\", |
861 |
|
dossier_autorisation_type_detaille.code as \"ws_DA_In_Type_Dos_Autoris\", |
862 |
|
COALESCE(particulier_nom,personne_morale_raison_sociale) as \"ws_DA_In_Nom_Petition\", |
863 |
|
COALESCE(particulier_prenom, personne_morale_denomination) as \"ws_DA_In_Prenom_Petition\", |
864 |
|
'' as \"ws_DA_In_Piece_GED\", |
865 |
|
instruction.date_retour_signature as \"ws_DA_In_Dte_Signature\" |
866 |
|
FROM ".DB_PREFIXE."instruction |
867 |
|
LEFT JOIN ".DB_PREFIXE."signataire_arrete ON |
868 |
|
instruction.signataire_arrete = signataire_arrete.signataire_arrete |
869 |
|
LEFT JOIN ".DB_PREFIXE."dossier ON |
870 |
|
instruction.dossier = dossier.dossier |
871 |
|
LEFT JOIN ".DB_PREFIXE."lien_dossier_demandeur ON |
872 |
|
lien_dossier_demandeur.dossier = dossier.dossier |
873 |
|
LEFT JOIN ".DB_PREFIXE."demandeur ON |
874 |
|
lien_dossier_demandeur.demandeur = demandeur.demandeur |
875 |
|
LEFT JOIN ".DB_PREFIXE."dossier_instruction_type ON |
876 |
|
dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
877 |
|
LEFT JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille ON |
878 |
|
dossier_instruction_type.dossier_autorisation_type_detaille = |
879 |
|
dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
880 |
|
LEFT JOIN ".DB_PREFIXE."donnees_techniques ON |
881 |
|
donnees_techniques.dossier_instruction = dossier.dossier |
882 |
|
WHERE instruction.instruction = ".$this->valF['instruction']; |
883 |
|
$resArrete = $this->db->query($sqlArrete); |
884 |
|
$this->f->addToLog("triggerModifierApres(): db->query(\"".$sqlArrete."\");", VERBOSE_MODE); |
885 |
|
$this->f->isDatabaseError(); |
886 |
|
|
887 |
|
$rowArrete = $resArrete->fetchRow(DB_FETCHMODE_ASSOC); |
888 |
|
$msgenque->setArreteInfo($rowArrete); |
889 |
|
$msgenque->enqueueMessage($msgenque::$ARRETE_ENVOI); |
890 |
|
} |
891 |
|
} |
892 |
|
|
893 |
|
|
894 |
|
|
895 |
// trigger before delete |
// trigger before delete |
896 |
function triggersupprimer($id,&$db,$val,$DEBUG) { |
function triggersupprimer($id,&$db,$val,$DEBUG) { |
897 |
// archive en instruction (si suppression) [archive if delete instruction] |
// archive en instruction (si suppression) [archive if delete instruction] |
898 |
$valF['delai']=$val['archive_delai']; |
$valF['delai']=$val['archive_delai']; |
899 |
$valF['accord_tacite']=$val['archive_accord_tacite']; |
$valF['accord_tacite']=$val['archive_accord_tacite']; |
900 |
$valF['etat']=$val['archive_etat']; |
$valF['etat']=$val['archive_etat']; |
901 |
$valF['avis']=$val['archive_avis']; |
if($val['archive_avis']=='') |
902 |
|
$valF['avis_decision']= null; |
903 |
|
else |
904 |
|
$valF['avis_decision']=$val['archive_avis']; |
905 |
// if= compatibilite pgsql |
// if= compatibilite pgsql |
906 |
if($val['archive_date_complet']!='') |
if($val['archive_date_complet']!='') |
907 |
$valF['date_complet']=$val['archive_date_complet']; |
$valF['date_complet']=$val['archive_date_complet']; |
921 |
$valF['date_chantier']= $val['archive_date_chantier']; |
$valF['date_chantier']= $val['archive_date_chantier']; |
922 |
if($val['archive_date_conformite']!='') |
if($val['archive_date_conformite']!='') |
923 |
$valF['date_conformite']= $val['archive_date_conformite']; |
$valF['date_conformite']= $val['archive_date_conformite']; |
924 |
|
|
925 |
$cle= " dossier = '".$val['dossier']."'"; |
$cle= " dossier = '".$val['dossier']."'"; |
926 |
$res= $db->autoExecute('dossier',$valF,DB_AUTOQUERY_UPDATE,$cle); |
$res= $db->autoExecute(DB_PREFIXE.'dossier',$valF,DB_AUTOQUERY_UPDATE,$cle); |
927 |
if (database::isError($res)) |
if (database::isError($res)) |
928 |
die($res->getMessage()); |
die($res->getMessage()); |
929 |
else{ |
else{ |
982 |
return $annee."-".$mois."-".$jour ; |
return $annee."-".$mois."-".$jour ; |
983 |
} |
} |
984 |
|
|
985 |
|
// Vérifie la restriction sur l'événement |
986 |
|
function verifier($val = array(), &$db, $DEBUG){ |
987 |
|
parent::verifier($val, $db, $DEBUG); |
988 |
|
//Récupère la restriction |
989 |
|
$sql= "SELECT |
990 |
|
restriction |
991 |
|
FROM |
992 |
|
".DB_PREFIXE."evenement |
993 |
|
WHERE |
994 |
|
evenement =".$this->valF['evenement']; |
995 |
|
|
996 |
|
$res = $db->query($sql); |
997 |
|
$this->f->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE); |
998 |
|
$this->f->isDatabaseError(); |
999 |
|
|
1000 |
|
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
1001 |
|
|
1002 |
|
//Test qu'une restriction est présente |
1003 |
|
if ( isset($row['restriction']) && $row['restriction'] != "" ){ |
1004 |
|
|
1005 |
|
//Test si la restriction est valide |
1006 |
|
if ( !$this->restrictionIsValid($row['restriction']) ){ |
1007 |
|
|
1008 |
|
$this->correct=false; |
1009 |
|
$this->addToMessage(_("Restriction non valide")); |
1010 |
|
} |
1011 |
|
else { |
1012 |
|
|
1013 |
|
$this->correct = true; |
1014 |
|
} |
1015 |
|
} |
1016 |
|
} |
1017 |
|
|
1018 |
|
/** |
1019 |
|
* Méthode permettant de mettre à jour l'état d'un DA |
1020 |
|
*/ |
1021 |
|
function majEtatDA() { |
1022 |
|
if($this->valF['action'] == 'accepter' AND $this->valF['avis_decision'] == 8) { |
1023 |
|
$val['etat_dossier_autorisation']=5; |
1024 |
|
} elseif($this->valF['action'] == 'accepter' AND $this->valF['avis_decision'] == 15) { |
1025 |
|
$val['etat_dossier_autorisation']=3; |
1026 |
|
} elseif($this->valF['action'] == 'accepter') { |
1027 |
|
$val['etat_dossier_autorisation']=2; |
1028 |
|
} elseif($this->valF['action'] == 'rejeter') { |
1029 |
|
$val['etat_dossier_autorisation']=4; |
1030 |
|
} elseif($this->valF['action'] == 'terminer') { |
1031 |
|
$val['etat_dossier_autorisation']=8; |
1032 |
|
} elseif($this->valF['action'] == 'majorer') { |
1033 |
|
$val['etat_dossier_autorisation']=6; |
1034 |
|
} else { |
1035 |
|
$val['etat_dossier_autorisation']=7; |
1036 |
|
} |
1037 |
|
|
1038 |
|
//Récupération du numéro de dossier d'autorisation lié au dossier d'instruction |
1039 |
|
$IDdossier_autorisation = $this->getDossierAutorisation($this->valF['dossier']); |
1040 |
|
|
1041 |
|
// Mis à jour de l'état du dossier d'autorisation |
1042 |
|
require_once '../obj/dossier_autorisation.class.php'; |
1043 |
|
$dossier_autorisation = new dossier_autorisation($IDdossier_autorisation,$this->db,DEBUG); |
1044 |
|
|
1045 |
|
$dossier_autorisation->val[array_search("etat_dossier_autorisation", $dossier_autorisation->champs)] = $val['etat_dossier_autorisation']; |
1046 |
|
|
1047 |
|
//Récupération des données |
1048 |
|
$valDossierAutorisation = array(); |
1049 |
|
for ( $i=0 ; $i<count($dossier_autorisation->champs); $i++){ |
1050 |
|
|
1051 |
|
$valDossierAutorisation[$dossier_autorisation->champs[$i]]= |
1052 |
|
$dossier_autorisation->val[$i]; |
1053 |
|
} |
1054 |
|
|
1055 |
|
$dossier_autorisation->modifier($valDossierAutorisation, $this->db, DEBUG); |
1056 |
|
} |
1057 |
|
|
1058 |
|
/** |
1059 |
|
* Méthode permettant de mettre à jour les données d'un DA |
1060 |
|
*/ |
1061 |
|
function majDataDA() { |
1062 |
|
|
1063 |
|
//Récupération du numéro de dossier d'autorisation lié au dossier d'instruction |
1064 |
|
$IDdossier_autorisation = $this->getDossierAutorisation($this->valF['dossier']); |
1065 |
|
require_once '../obj/dossier_autorisation.class.php'; |
1066 |
|
$dossier_autorisation = new dossier_autorisation($IDdossier_autorisation,$this->db,DEBUG); |
1067 |
|
|
1068 |
|
require_once '../obj/dossier.class.php'; |
1069 |
|
$dossier = new dossier($this->valF['dossier'],$this->db,DEBUG); |
1070 |
|
|
1071 |
|
//Récupération des données |
1072 |
|
$valDossierAutorisation = array(); |
1073 |
|
for ( $i=0 ; $i<count($dossier_autorisation->champs); $i++){ |
1074 |
|
|
1075 |
|
if ( array_search($dossier_autorisation->champs[$i], $dossier->champs) ){ |
1076 |
|
|
1077 |
|
$valDossierAutorisation[$dossier_autorisation->champs[$i]]=$dossier->getVal($dossier_autorisation->champs[$i]); |
1078 |
|
} |
1079 |
|
else { |
1080 |
|
$valDossierAutorisation[$dossier_autorisation->champs[$i]]= |
1081 |
|
$dossier_autorisation->val[$i]; |
1082 |
|
} |
1083 |
|
} |
1084 |
|
|
1085 |
|
$dossier_autorisation->modifier($valDossierAutorisation, $this->db, DEBUG); |
1086 |
|
|
1087 |
|
// Suppression du liens entre les lots et le DA |
1088 |
|
$valLot['dossier_autorisation'] = NULL; |
1089 |
|
$this->db->autoExecute(DB_PREFIXE."lot", $valLot, DB_AUTOQUERY_UPDATE, "dossier_autorisation='".$IDdossier_autorisation."'"); |
1090 |
|
|
1091 |
|
// Liaison des lots du DI avec le DA |
1092 |
|
$sqlLot = "SELECT lot FROM ".DB_PREFIXE."lien_dossier_lot WHERE dossier='".$this->valF['dossier']."'"; |
1093 |
|
$res = $this->db->query($sqlLot); |
1094 |
|
$this->addToLog($sqlLot); |
1095 |
|
$this->f->isDatabaseError(); |
1096 |
|
while($rowLot = $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
1097 |
|
$valLot['dossier_autorisation'] = $IDdossier_autorisation; |
1098 |
|
$this->db->autoExecute(DB_PREFIXE."lot", $valLot, DB_AUTOQUERY_UPDATE, "lot=".$rowLot['lot']); |
1099 |
|
} |
1100 |
|
} |
1101 |
|
|
1102 |
|
// Récupération de l'identifiant du dossier d'autorisation lié au dossier d'instruction |
1103 |
|
function getDossierAutorisation($dossier_instruction){ |
1104 |
|
|
1105 |
|
$sql = "SELECT |
1106 |
|
dossier_autorisation.dossier_autorisation |
1107 |
|
FROM |
1108 |
|
".DB_PREFIXE."dossier_autorisation |
1109 |
|
LEFT JOIN |
1110 |
|
".DB_PREFIXE."dossier |
1111 |
|
ON |
1112 |
|
dossier_autorisation.dossier_autorisation = dossier.dossier_autorisation |
1113 |
|
WHERE |
1114 |
|
dossier.dossier = '".$dossier_instruction."'"; |
1115 |
|
|
1116 |
|
$IDdossier_autorisation = $this->db->getOne($sql); |
1117 |
|
$this->addToLog("getDossierAutorisation(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
1118 |
|
database::isError($IDdossier_autorisation); |
1119 |
|
|
1120 |
|
return $IDdossier_autorisation; |
1121 |
|
} |
1122 |
}// fin classe |
}// fin classe |
|
?> |
|
1123 |
|
?> |