9 |
$this->constructeur($id,$db,$debug); |
$this->constructeur($id,$db,$debug); |
10 |
}// fin constructeur |
}// fin constructeur |
11 |
|
|
|
function setValFAjout($val){ |
|
|
$this->valF['service'] = $val['service']; |
|
|
} |
|
|
|
|
|
function setvalF($val){ |
|
|
parent::setvalF($val); |
|
|
// cles secondaires numerique (contrainte integrite pgsql) |
|
|
if($val['avis']=='') $this->valF['avis']= null; |
|
|
} |
|
|
|
|
|
function verifier(){ |
|
|
$this->correct=True; |
|
|
$imgv=""; |
|
|
$f=" ! "; |
|
|
$imgv="<img src='../img/punaise.png' style='vertical-align:middle' hspace='2' border='0'>"; |
|
|
if ($this->valF['service']==""){ |
|
|
$this->correct=false; |
|
|
$this->msg= $this->msg.$imgv." "._("service")." ". |
|
|
_("obligatoire").$f; |
|
|
} |
|
|
if ($this->valF['dossier']==""){ |
|
|
$this->correct=false; |
|
|
$this->msg= $this->msg.$imgv." "._("dossier")." ". |
|
|
_("obligatoire").$f; |
|
|
} |
|
|
if ($this->valF['date_envoi']==""){ |
|
|
$this->correct=false; |
|
|
$this->msg= $this->msg.$imgv." "._("date_envoi")." ". |
|
|
_("obligatoire").$f; |
|
|
} |
|
|
} |
|
|
|
|
12 |
function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire){ |
function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire){ |
13 |
if ($validation==0) { |
if ($validation==0) { |
14 |
if ($maj == 0){ |
if ($maj == 0){ |
15 |
$form->setVal("dossier", $idxformulaire); |
$form->setVal("dossier", $idxformulaire); |
16 |
|
$form->setVal("date_envoi",date('d/m/Y')); |
17 |
|
} |
18 |
|
if($maj == 1) { |
19 |
|
if($this->f->isAccredited('consultation_retour_avis_suivi') OR |
20 |
|
$this->f->isAccredited('consultation_retour_avis_service')) { |
21 |
|
$form->setVal("date_retour",date('d/m/Y')); |
22 |
|
} |
23 |
} |
} |
24 |
} |
} |
25 |
} |
} |
26 |
|
|
27 |
|
function setVal(&$form, $maj, $validation, &$db) { |
28 |
|
if($maj == 1) { |
29 |
|
$form->setVal("date_retour",date('d/m/Y')); |
30 |
|
} |
31 |
|
} |
32 |
|
|
33 |
function setType(&$form,$maj) { |
function setvalF($val) { |
34 |
if ($maj < 2) { //ajouter et modifier [add and modify] |
parent::setValF($val); |
35 |
if($maj==0){ // add |
if($this->getParameter('maj')==0) { |
36 |
$form->setType('date_envoi', 'date2'); |
$this->valF["date_reception"]=$this->valF["date_envoi"]; |
37 |
$form->setType('service', 'select'); |
} |
38 |
$form->setType('date_limite', 'hidden'); |
|
39 |
$form->setType('date_retour', 'hidden'); |
// Si un retour d'avis est modifie on passe "lu" a false |
40 |
$form->setType('avis', 'hidden'); |
if($this->getParameter('maj')==1 AND ( |
41 |
}else{ // modify |
$this->val[array_search("avis_consultation",$this->champs)] != $val["avis_consultation"] OR |
42 |
$form->setType('date_envoi', 'hiddenstaticdate'); |
$this->val[array_search("date_retour",$this->champs)] != $val["date_retour"] OR |
43 |
$form->setType('service', 'selectdisabled'); |
$this->val[array_search("motivation",$this->champs)] != $val["motivation"] OR |
44 |
$form->setType('date_limite', 'date2'); |
$this->val[array_search("fichier",$this->champs)] != $val["fichier"]) |
45 |
$form->setType('date_retour', 'date2'); |
) { |
46 |
$form->setType('avis', 'select'); |
$this->valF["lu"]=false; |
47 |
|
} |
48 |
|
} |
49 |
|
|
50 |
|
function verifier($val, &$db, $DEBUG) { |
51 |
|
parent::verifier($val, $db, $DEBUG); |
52 |
|
// Si le fichier envoye est different de l'existant |
53 |
|
if (isset($this->val[array_search("fichier",$this->champs)]) |
54 |
|
&& $this->val[array_search("fichier",$this->champs)] != $val["fichier"] |
55 |
|
&& $this->valF['fichier']!="") { |
56 |
|
// Si le fichier existe dans tmp |
57 |
|
if(file_exists("../tmp/".$this->valF['fichier'])) { |
58 |
|
$contents=file_get_contents("../tmp/".$this->valF['fichier']); |
59 |
|
// On essaye de l'enregistrer |
60 |
|
$res = $this->f->storeDecisionFile($contents, $this->valF['fichier'], |
61 |
|
$this->valF['dossier'], |
62 |
|
'consultation_'.$this->valF['consultation']."_"); |
63 |
|
// Si l'enregistrement s'est bien deroule |
64 |
|
// on supprime le fichier dans tmp |
65 |
|
// on met a jour valF avec le nouveau nom du fichier |
66 |
|
if($res===true){ |
67 |
|
$this->addToMessage(_("Sauvegarde du fichier reussi")); |
68 |
|
unlink("../tmp/".$this->valF['fichier']); |
69 |
|
$this->valF['fichier']='consultation_'.$this->valF['consultation']."_".$this->valF['fichier']; |
70 |
|
// Sinon on supprime le fichier dans tmp |
71 |
|
// on reinitialise le nom du fichier a l'ancienne valeur |
72 |
|
} else { |
73 |
|
$this->correct = false; |
74 |
|
$this->addToMessage($res); |
75 |
|
unlink("../tmp/".$this->valF['fichier']); |
76 |
|
$this->valF['fichier']=$this->val[array_search("fichier",$this->champs)]; |
77 |
|
} |
78 |
} |
} |
|
$form->setType('consultation', 'hiddenstatic'); |
|
|
$form->setType('dossier', 'hiddenstatic'); |
|
|
}else{ // supprimer |
|
|
$form->setType('consultation', 'hiddenstatic'); |
|
|
$form->setType('dossier', 'hiddenstatic'); |
|
79 |
} |
} |
80 |
} |
} |
81 |
|
|
82 |
|
function setType(&$form,$maj) { |
83 |
|
// Appel du parent |
84 |
|
parent::setType($form,$maj); |
85 |
|
// MODE - AJOUTER |
86 |
|
if ($maj == 0) { |
87 |
|
// On cache alors tous les champs que nous ne voulons pas voir |
88 |
|
// apparaître dans le formulaire d'ajout (principalement les |
89 |
|
// informations sur le retour d'avis) |
90 |
|
$form->setType('date_retour', 'hidden'); |
91 |
|
$form->setType('date_reception', 'hidden'); |
92 |
|
$form->setType('date_limite', 'hidden'); |
93 |
|
$form->setType('avis_consultation', 'hidden'); |
94 |
|
$form->setType('motivation', 'hidden'); |
95 |
|
$form->setType('fichier', 'hidden'); |
96 |
|
$form->setType('lu', 'hidden'); |
97 |
|
// On permet la modification de certains champs |
98 |
|
$form->setType('dossier', 'hiddenstatic'); |
99 |
|
$form->setType('service', 'select'); |
100 |
|
$form->setType('date_envoi', 'date2'); |
101 |
|
} |
102 |
|
// MODE - MODIFIER |
103 |
|
if ($maj == 1) { |
104 |
|
|
105 |
function setTaille(&$form,$maj){ |
// On affiche en statique les informations qui ne sont plus |
106 |
$form->setTaille('consultation', 8); |
// modifiables |
107 |
$form->setTaille('dossier', 12); |
$form->setType('dossier', 'hiddenstatic'); |
108 |
$form->setTaille('service', 5); |
$form->setType('date_envoi', 'hiddenstaticdate'); |
109 |
$form->setTaille('date_envoi', 12); |
$form->setType('date_limite', 'hiddenstaticdate'); |
110 |
$form->setTaille('date_retour', 12); |
$form->setType('service', 'selecthiddenstatic'); |
111 |
$form->setTaille('avis', 2); |
|
112 |
$form->setTaille('date_limite', 12); |
// La date de réception ne peut être modifiée que par un |
113 |
} |
// utilisateur en ayant spécifiquement la permission |
114 |
|
if($this->f->isAccredited('consultation_modifier_date_reception')) { |
115 |
function setMax(&$form,$maj){ |
$form->setType('date_reception', 'date2'); |
116 |
$form->setMax('consultation', 8); |
} else { |
117 |
$form->setMax('dossier', 12); |
$form->setType('date_reception', 'hiddenstaticdate'); |
118 |
$form->setMax('service', 5); |
} |
119 |
$form->setMax('date_envoi', 12); |
|
120 |
$form->setMax('date_retour', 12); |
// Le marqueur lu/non lu ne peut être modifié que par un |
121 |
$form->setMax('avis', 2); |
// utilisateur en ayant spécifiquement la permission |
122 |
$form->setMax('date_limite', 12); |
if ($this->f->isAccredited('consultation_modifier_lu')) { |
123 |
} |
$form->setType('lu', 'checkbox'); |
124 |
|
} else { |
125 |
|
$form->setType('lu', 'hidden'); |
126 |
|
} |
127 |
|
|
128 |
|
// Gestion du type du widget sur le champ fichier |
129 |
|
if($this->val[array_search("fichier",$this->champs)]=="" OR |
130 |
|
$this->f->isAccredited('consultation_modifier_fichier')) { |
131 |
|
// Si il n'y a jamais eu de fichier enregistré ou que |
132 |
|
// l'utilisateur a spécifiquement les droits pour modifier |
133 |
|
// un fichier déjà enregistré alors on positionne un type |
134 |
|
// de widget modifiable |
135 |
|
$form->setType('fichier', 'tmpUpload'); |
136 |
|
} else { |
137 |
|
// Si non on affiche uniquement le nom du fichier |
138 |
|
$form->setType('fichier', 'tmpUploadStatic'); |
139 |
|
} |
140 |
|
|
141 |
|
// Modification layout : écran de retour d'avis permettant |
142 |
|
// uniquement la saisie des trois champs : avis, motivation et fichier |
143 |
|
if (!$this->f->isAccredited('consultation_consulter_autre_que_retour_avis')) { |
144 |
|
|
145 |
|
// On cache alors tous les champs que nous ne voulons pas voir |
146 |
|
$form->setType('dossier', 'hidden'); |
147 |
|
$form->setType('service', 'hidden'); |
148 |
|
$form->setType('date_envoi', 'hidden'); |
149 |
|
$form->setType('date_retour', 'hidden'); |
150 |
|
$form->setType('date_reception', 'hidden'); |
151 |
|
$form->setType('date_limite', 'hidden'); |
152 |
|
$form->setType('lu', 'hidden'); |
153 |
|
|
154 |
|
} |
155 |
|
|
156 |
|
} |
157 |
|
// MODE - CONSULTER |
158 |
|
if ( $maj == 3 ) { |
159 |
|
$form->setType('fichier', 'tmpUploadStatic'); |
160 |
|
} |
161 |
|
//// On cache la clé primaire |
162 |
|
//$form->setType('consultation', 'hidden'); |
163 |
|
} |
164 |
|
|
165 |
// TRIGGER AVANT MODIFICATION DE DONNEES |
// TRIGGER AVANT MODIFICATION DE DONNEES |
166 |
// trigger before modification data |
// trigger before modification data |
167 |
function triggerajouter($id,&$db,$val,$DEBUG) { |
function triggerajouter($id,&$db,$val,$DEBUG) { |
168 |
// mise a jour instruction avec evenement [return delay] |
// mise a jour instruction avec evenement [return delay] |
169 |
if (!$this->valF['date_envoi']==""){ |
if ($this->valF['date_envoi']!=""){ |
170 |
$sql= "select delai from service where service ='".$this->valF['service']."'"; |
$sql= "select delai from ".DB_PREFIXE."service where service ='".$this->valF['service']."'"; |
171 |
$delai = $db->getOne($sql); |
$delai = $db->getOne($sql); |
172 |
$this->valF['date_limite'] = $this->moisdate($this->valF['date_envoi'],$delai); |
$this->valF['date_limite'] = $this->moisdate($this->valF['date_envoi'],$delai); |
173 |
$this->msg=$this->msg."<br>"._("delai")." ". |
$this->addToMessage(_("delai")." ". |
174 |
_("retour")." ".$delai." "._("mois")." -> ". |
_("retour")." ".$delai." "._("mois")." -> ". |
175 |
_("retour")." ".$this->valF['date_limite']."<br>"; |
_("retour")." ".$this->valF['date_limite']."<br>"); |
176 |
|
$this->valF['lu'] = true; |
177 |
} |
} |
178 |
|
|
179 |
|
} |
180 |
|
|
181 |
|
function triggerajouterapres($id,&$db,$val,$DEBUG) { |
182 |
|
|
183 |
|
// Verification de la demande de notif par mail |
184 |
|
$sql= "SELECT abrege, notification_email, email FROM ".DB_PREFIXE. |
185 |
|
"service WHERE service ='".$this->valF['service']."'"; |
186 |
|
$res=$db->query($sql); |
187 |
|
$notif = $res->fetchrow(DB_FETCHMODE_ASSOC); |
188 |
|
if (database :: isError($sql))die($res->getMessage()."erreur ".$sql); |
189 |
|
if ($notif['notification_email']=='t') { |
190 |
|
|
191 |
|
// Recuperation des infos du dossier |
192 |
|
$sql= "SELECT dossier, terrain_adresse, terrain_adresse_complement, terrain_cp, terrain_ville |
193 |
|
FROM ".DB_PREFIXE."dossier WHERE dossier ='".$this->valF['dossier']."'"; |
194 |
|
$res=$db->query($sql); |
195 |
|
$dossier = $res->fetchrow(DB_FETCHMODE_ASSOC); |
196 |
|
|
197 |
|
// Definition des parametres d'envoi du mail |
198 |
|
$title=_("Consultation de services : dossier no")." ".$dossier['dossier']; |
199 |
|
$corps=_("Votre service est consulte concernant le dossier no")." ".$dossier['dossier']."<br/>". |
200 |
|
_("Il concerne le terrain situe a l'adresse :")." ".utf8_decode($dossier['terrain_adresse']). |
201 |
|
" ".utf8_decode($dossier['terrain_adresse_complement'])." ".utf8_decode($dossier['terrain_cp'])." ".$dossier['terrain_ville']."<br/>". |
202 |
|
_("Vous pouvez y acceder et rendre votre avis a l'adresse")." <a href='".$this->f->getParameter('services_consultes_lien_interne'). |
203 |
|
"scr/form.php?obj=consultation&action=3&idx=".$this->valF['consultation']."' >". |
204 |
|
_("Lien interne (services VDM)")."</a> "._("ou")." <a href='".$this->f->getParameter('services_consultes_lien_externe'). |
205 |
|
"scr/form.php?obj=consultation&action=3&idx=".$this->valF['consultation']."' >". |
206 |
|
_("Lien externe (hors VDM)")."</a>"; |
207 |
|
// Envoi du mail avec message de retour |
208 |
|
if($this->f->sendMail($title, $corps, $notif['email'])) { |
209 |
|
$this->addToMessage(_("Envoi d'un mail de notification au service")." ".$notif['abrege']); |
210 |
|
} else { |
211 |
|
$this->addToMessage(_("L'envoi du mail de notification a echoue")); |
212 |
|
} |
213 |
|
} |
214 |
|
|
215 |
} |
} |
216 |
|
|
217 |
// ============================================= |
// ============================================= |
253 |
return $annee."-".$mois."-".$jour ; |
return $annee."-".$mois."-".$jour ; |
254 |
} |
} |
255 |
|
|
256 |
|
// ============================================= |
257 |
|
// Ajout du fielset |
258 |
|
// Add fieldset |
259 |
|
// ============================================= |
260 |
|
function setLayout(&$form, $maj){ |
261 |
|
|
262 |
|
// Modification layout : écran de retour d'avis permettant |
263 |
|
// uniquement la saisie des trois champs : avis, motivation et fichier |
264 |
|
if ($this->f->isAccredited('consultation_consulter_autre_que_retour_avis')) { |
265 |
|
|
266 |
|
//Champs sur lequel s'ouvre le fieldset |
267 |
|
$form->setBloc('dossier','D',""); |
268 |
|
$form->setFieldset('dossier','D',_('Consultation')); |
269 |
|
|
270 |
|
//Champs sur lequel se ferme le fieldset |
271 |
|
$form->setFieldset('date_envoi','F',''); |
272 |
|
$form->setBloc('date_envoi','F'); |
273 |
|
|
274 |
|
} |
275 |
|
|
276 |
|
// MODE - autre que AJOUTER alors on affiche un fieldset retour |
277 |
|
// d'avis |
278 |
|
if ($maj != 0) { |
279 |
|
|
280 |
|
//Champs sur lequel s'ouvre le fieldset |
281 |
|
$form->setBloc('date_reception','D',""); |
282 |
|
$form->setFieldset('date_reception','D',_('Retour d\'avis')); |
283 |
|
|
284 |
|
//Champs sur lequel se ferme le fieldset |
285 |
|
$form->setFieldset('lu','F',''); |
286 |
|
$form->setBloc('lu','F'); |
287 |
|
|
288 |
|
} |
289 |
|
} |
290 |
|
|
291 |
|
/** Surcharge de la methode retour afin de retourner sur la page de saisie de |
292 |
|
* code barre si besoin |
293 |
|
**/ |
294 |
|
function retour($premier = 0, $recherche = "", $tricol = "") { |
295 |
|
$params ="obj=".get_class($this); |
296 |
|
if($this->getParameter("retour")=="form") { |
297 |
|
$params .= "&idx=".$this->getParameter("idx"); |
298 |
|
$params .= "&action=3"; |
299 |
|
} |
300 |
|
$params .= "&premier=".$this->getParameter("premier"); |
301 |
|
$params .= "&tricol=".$this->getParameter("tricol"); |
302 |
|
$params .= "&recherche=".$this->getParameter("recherche"); |
303 |
|
$params .= "&selectioncol=".$this->getParameter("selectioncol"); |
304 |
|
$params .= "&advs_id=".$this->getParameter("advs_id"); |
305 |
|
$params .= "&valide=".$this->getParameter("valide"); |
306 |
|
echo "\n<a class=\"retour\" "; |
307 |
|
echo "href=\""; |
308 |
|
// |
309 |
|
|
310 |
|
if($this->getParameter("retour")=="form" AND !($this->getParameter("validation")>0 AND $this->getParameter("maj")==2 AND $this->correct)) { |
311 |
|
echo "form.php?".$params; |
312 |
|
} elseif($this->getParameter("retour")=="avis_code_barre") { |
313 |
|
echo "../app/avis_code_barre.php"; |
314 |
|
} else { |
315 |
|
echo "tab.php?".$params; |
316 |
|
} |
317 |
|
// |
318 |
|
echo "\""; |
319 |
|
echo ">"; |
320 |
|
// |
321 |
|
echo _("Retour"); |
322 |
|
// |
323 |
|
echo "</a>\n"; |
324 |
|
|
325 |
|
} |
326 |
|
|
327 |
}// fin classe |
}// fin classe |
|
?> |
|
328 |
|
?> |