/[openfoncier]/trunk/obj/consultation.class.php
ViewVC logotype

Contents of /trunk/obj/consultation.class.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 637 - (show annotations)
Thu Nov 8 17:48:54 2012 UTC (12 years, 2 months ago) by nhaye
File size: 11652 byte(s)
Ajout d'une méthode de verification et d'ajout de retour d'avis de consultation.
Application de cette méthode à la validation de la modification d'une consultation.

1 <?php
2 //$Id$
3 //gen openMairie le 10/02/2011 20:32
4 require_once ("../gen/obj/consultation.class.php");
5
6 class consultation extends consultation_gen {
7
8 function consultation($id,&$db,$debug) {
9 $this->constructeur($id,$db,$debug);
10 }// fin constructeur
11
12 function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire){
13 if ($validation==0) {
14 if ($maj == 0){
15 $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 setvalF($val) {
34 parent::setValF($val);
35 if($this->getParameter('maj')==0) {
36 $this->valF["date_reception"]=$this->valF["date_envoi"];
37 }
38
39 // Si un retour d'avis est modifie on passe "lu" a false
40 if($this->getParameter('maj')==1 AND (
41 $this->val[array_search("avis_consultation",$this->champs)] != $val["avis_consultation"] OR
42 $this->val[array_search("date_retour",$this->champs)] != $val["date_retour"] OR
43 $this->val[array_search("motivation",$this->champs)] != $val["motivation"] OR
44 $this->val[array_search("fichier",$this->champs)] != $val["fichier"]
45 )
46 ) {
47 $this->valF["lu"]=false;
48 }
49 if($this->val[array_search("fichier",$this->champs)] != $val["fichier"] AND $this->valF['fichier']!="") {
50 $file_id = array_search($this->valF['fichier'],$_SESSION['file_upload']);
51 if($file_id!==false) {
52 if(file_exists("../tmp/".$this->valF['fichier'])) {
53 $contents=file_get_contents("../tmp/".$this->valF['fichier']);
54 $this->f->storeDecisionFile($contents, $this->valF['fichier'], $this->valF['dossier'], 'consultation_'.$this->valF['consultation']."_");
55 $this->f->displayMessages();
56 unlink("../tmp/".$this->valF['fichier']);
57 }
58 }
59 }
60 }
61
62 function setType(&$form,$maj) {
63 parent::setType($form,$maj);
64 if ($maj < 2) { //ajouter et modifier [add and modify]
65 if($maj==0){ // add
66 $form->setType('dossier', 'hiddenstatic');
67 $form->setType('date_envoi', 'date2');
68 $form->setType('service', 'select');
69 $form->setType('date_limite', 'hidden');
70 $form->setType('date_retour', 'hidden');
71 $form->setType('avis_consultation', 'hidden');
72 $form->setType('motivation', 'hidden');
73 $form->setType('fichier', 'hidden');
74 $form->setType('lu', 'hidden');
75 $form->setType('date_reception', 'hidden');
76 }else{ // modify
77 if($this->f->isAccredited('consultation_retour_avis_service')) {
78 $form->setType('dossier', 'hidden');
79 $form->setType('service', 'hidden');
80 $form->setType('date_envoi', 'hidden');
81 $form->setType('date_retour', 'hidden');
82 $form->setType('date_reception', 'hidden');
83 $form->setType('date_limite', 'hidden');
84 $form->setType('lu', 'hidden');
85 $form->setType('fichier', 'tmpUpload');
86 } else {
87 $form->setType('dossier', 'hiddenstatic');
88 $form->setType('date_envoi', 'hiddenstaticdate');
89 $form->setType('date_limite', 'hiddenstaticdate');
90 if(!$this->f->isAccredited('consultation_modifier_date_reception')) {
91 $form->setType('date_reception', 'hiddenstaticdate');
92 } else {
93 $form->setType('date_reception', 'date2');
94 }
95 $form->setType('service', 'selecthiddenstatic');
96 $form->setType('date_retour', 'date2');
97 $form->setType('avis_consultation', 'select');
98 $form->setType('motivation', 'textarea');
99 $form->setType('fichier', 'tmpUpload');
100 //Affichage du champ en modification pour le prifil instructeur
101 if(!$this->f->isAccredited('consultation_modifier_lu')) {
102 $form->setType('lu', 'hidden');
103 }
104 }
105 }
106 }
107 $form->setType('consultation', 'hidden');
108 //setType pour profil service
109
110 }
111
112 // TRIGGER AVANT MODIFICATION DE DONNEES
113 // trigger before modification data
114 function triggerajouter($id,&$db,$val,$DEBUG) {
115 // mise a jour instruction avec evenement [return delay]
116 if ($this->valF['date_envoi']!=""){
117 $sql= "select delai from ".DB_PREFIXE."service where service ='".$this->valF['service']."'";
118 $delai = $db->getOne($sql);
119 $this->valF['date_limite'] = $this->moisdate($this->valF['date_envoi'],$delai);
120 $this->addToMessage(_("delai")." ".
121 _("retour")." ".$delai." "._("mois")." -> ".
122 _("retour")." ".$this->valF['date_limite']."<br>");
123 $this->valF['lu'] = true;
124 }
125
126 }
127
128 function triggerajouterapres($id,&$db,$val,$DEBUG) {
129
130 // Verification de la demande de notif par mail
131 $sql= "SELECT abrege, notification_email, email FROM ".DB_PREFIXE.
132 "service WHERE service ='".$this->valF['service']."'";
133 $res=$db->query($sql);
134 $notif = $res->fetchrow(DB_FETCHMODE_ASSOC);
135 if (database :: isError($sql))die($res->getMessage()."erreur ".$sql);
136 if ($notif['notification_email']=='t') {
137
138 // Recuperation des infos du dossier
139 $sql= "SELECT dossier, terrain_adresse, terrain_adresse_complement, terrain_cp, terrain_ville
140 FROM ".DB_PREFIXE."dossier WHERE dossier ='".$this->valF['dossier']."'";
141 $res=$db->query($sql);
142 $dossier = $res->fetchrow(DB_FETCHMODE_ASSOC);
143
144 // Definition des parametres d'envoi du mail
145 $title=_("Consultation de services : dossier no")." ".$dossier['dossier'];
146 $corps=_("Votre service est consulte concernant le dossier no")." ".$dossier['dossier']."<br/>".
147 _("Il concerne le terrain situe a l'adresse :")." ".utf8_decode($dossier['terrain_adresse']).
148 " ".utf8_decode($dossier['terrain_adresse_complement'])." ".utf8_decode($dossier['terrain_cp'])." ".$dossier['terrain_ville']."<br/>".
149 _("Vous pouvez y acceder et rendre votre avis a l'adresse")." <a href='".$this->f->getParameter('lien_interne_vdm').
150 "scr/form.php?obj=consultation&action=3&idx=".$this->valF['consultation']."' >".
151 _("Lien interne (services VDM)")."</a> "._("ou")." <a href='".$this->f->getParameter('lien_externe').
152 "scr/form.php?obj=consultation&action=3&idx=".$this->valF['consultation']."' >".
153 _("Lien externe (hors VDM)")."</a>";
154 // Envoi du mail avec message de retour
155 if($this->f->sendMail($title, $corps, $notif['email'])) {
156 $this->addToMessage(_("Envoi d'un mail de notification au service")." ".$notif['abrege']);
157 } else {
158 $this->addToMessage(_("L'envoi du mail de notification a echoue"));
159 }
160 }
161
162 }
163
164 // =============================================
165 // calcul de date avec ajout de mois (delais)
166 // [add months (delay) and calculation final date]
167 // limite ? => voir fonction instruction
168 // =============================================
169 function moisdate($date,$delaimois) {
170 // rajout de mois à une date (moins de 12)
171 $temp = explode("-" , $date);
172 $jour = (int) $temp[2];
173 $mois = (int) $temp[1];
174 $annee = (int) $temp[0];
175 $mois=$mois+$delaimois;
176 // calcul mois annee
177 if($mois>12){
178 $mois=$mois-12;
179 $annee=$annee+1;
180 }
181 // Calcul du nombre de jours dans le mois sélectionné
182 switch($mois) {
183 case "2":
184 if ($annee % 4 == 0 && $annee % 100 != 0 || $annee % 400 == 0)
185 $jourmax = 29;
186 else
187 $jourmax = 28;
188 break;
189 case "4":
190 case "6":
191 case "9":
192 case "11":
193 $jourmax = 30;
194 break;
195 default:
196 $jourmax = 31;
197 }
198 if ($jour > $jourmax)
199 $jour = $jourmax;
200 return $annee."-".$mois."-".$jour ;
201 }
202
203 // =============================================
204 // Ajout du fielset
205 // Add fieldset
206 // =============================================
207 function setLayout(&$form, $maj){
208 if ( $maj < 2 OR $maj == 3 ) {
209 if(!$this->f->isAccredited('consultation_retour_avis_service')) {
210 //Champs sur lequel s'ouvre le fieldset
211 $form->setBloc('dossier','D',"");
212 $form->setFieldset('dossier','D',_('Consultation'));
213
214 //Champs sur lequel se ferme le fieldset
215 $form->setFieldset('date_envoi','F','');
216 $form->setBloc('date_envoi','F');
217 }
218 if ( $maj == 1 OR $maj == 3 ){
219 //Champs sur lequel s'ouvre le fieldset
220 $form->setBloc('date_reception','D',"");
221 $form->setFieldset('date_reception','D',_('Retour d\'avis'));
222
223 //Champs sur lequel se ferme le fieldset
224 $form->setFieldset('lu','F','');
225 $form->setBloc('lu','F');
226 }
227 }
228 }
229
230 /** Surcharge de la methode retour afin de retourner sur la page de saisie de
231 * code barre si besoin
232 **/
233 function retour($premier = 0, $recherche = "", $tricol = "") {
234 $params ="obj=".get_class($this);
235 if($this->getParameter("retour")=="form") {
236 $params .= "&amp;idx=".$this->getParameter("idx");
237 $params .= "&amp;action=3";
238 }
239 $params .= "&amp;premier=".$this->getParameter("premier");
240 $params .= "&amp;tricol=".$this->getParameter("tricol");
241 $params .= "&amp;recherche=".$this->getParameter("recherche");
242 $params .= "&amp;selectioncol=".$this->getParameter("selectioncol");
243 $params .= "&amp;advs_id=".$this->getParameter("advs_id");
244 $params .= "&amp;valide=".$this->getParameter("valide");
245 echo "\n<a class=\"retour\" ";
246 echo "href=\"";
247 //
248
249 if($this->getParameter("retour")=="form" AND !($this->getParameter("validation")>0 AND $this->getParameter("maj")==2 AND $this->correct)) {
250 echo "form.php?".$params;
251 } elseif($this->getParameter("retour")=="avis_code_barre") {
252 echo "../app/avis_code_barre.php";
253 } else {
254 echo "tab.php?".$params;
255 }
256 //
257 echo "\"";
258 echo ">";
259 //
260 echo _("Retour");
261 //
262 echo "</a>\n";
263
264 }
265
266 }// fin classe
267 ?>

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26