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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 594 - (show annotations)
Mon Nov 5 14:08:18 2012 UTC (12 years, 3 months ago) by nhaye
File size: 9729 byte(s)
la date de retour est maintenant non modifiable pour le profil suivi

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 var $maj;
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->maj==0) {
36 $this->valF["date_reception"]=$this->valF["date_envoi"];
37 }
38 // Si un retour d'avis est modifie on passe "lu" a false
39 if($this->maj==1 AND ($this->val[array_search("avis_consultation",$this->champs)] != $val["avis_consultation"] OR
40 $this->val[array_search("date_retour",$this->champs)] != $val["date_retour"] OR
41 $this->val[array_search("motivation",$this->champs)] != $val["motivation"] OR
42 $this->val[array_search("fichier",$this->champs)] != $val["fichier"])) {
43 $this->valF["lu"]=FALSE;
44 $this->valF["date_retour"]=$this->dateDB(date('d/m/Y'));
45 }
46
47 }
48
49 function setType(&$form,$maj) {
50 parent::setType($form,$maj);
51 if ($maj < 2) { //ajouter et modifier [add and modify]
52 if($maj==0){ // add
53 $form->setType('date_envoi', 'date2');
54 $form->setType('service', 'select');
55 $form->setType('date_limite', 'hidden');
56 $form->setType('date_retour', 'hidden');
57 $form->setType('avis_consultation', 'hidden');
58 $form->setType('motivation', 'hidden');
59 $form->setType('fichier', 'hidden');
60 $form->setType('lu', 'hidden');
61 $form->setType('date_reception', 'hidden');
62 }else{ // modify
63 if($this->f->isAccredited('consultation_retour_avis_service')) {
64 $form->setType('dossier', 'hidden');
65 $form->setType('service', 'hidden');
66 $form->setType('date_envoi', 'hidden');
67 $form->setType('date_retour', 'hidden');
68 $form->setType('date_reception', 'hidden');
69 $form->setType('date_limite', 'hidden');
70 $form->setType('lu', 'hidden');
71 $form->setType('fichier', 'upload2');
72 } else {
73 $form->setType('dossier', 'hiddenstatic');
74 $form->setType('date_envoi', 'hiddenstaticdate');
75 $form->setType('date_limite', 'hiddenstaticdate');
76 if($this->f->isAccredited('consultation_modifier_date_reception')) {
77 $form->setType('date_reception', 'hiddenstaticdate');
78 } else {
79 $form->setType('date_reception', 'date2');
80 }
81 $form->setType('service', 'selecthiddenstatic');
82 $form->setType('date_retour', 'date2');
83 $form->setType('avis_consultation', 'select');
84 $form->setType('motivation', 'textarea');
85 if(!isset($this->parameters['retourformulaire'])) {
86 $form->setType('fichier', 'upload');
87 } else {
88 $form->setType('fichier', 'upload2');
89 }
90 //Affichage du champ en modification pour le prifil instructeur
91 if(!$this->f->isAccredited('consultation_modifier_lu')) {
92 $form->setType('lu', 'hidden');
93 }
94 }
95 }
96 }
97 $form->setType('consultation', 'hidden');
98 //setType pour profil service
99
100 }
101
102 // TRIGGER AVANT MODIFICATION DE DONNEES
103 // trigger before modification data
104 function triggerajouter($id,&$db,$val,$DEBUG) {
105 // mise a jour instruction avec evenement [return delay]
106 if ($this->valF['date_envoi']!=""){
107 $sql= "select delai from ".DB_PREFIXE."service where service ='".$this->valF['service']."'";
108 $delai = $db->getOne($sql);
109 $this->valF['date_limite'] = $this->moisdate($this->valF['date_envoi'],$delai);
110 $this->addToMessage(_("delai")." ".
111 _("retour")." ".$delai." "._("mois")." -> ".
112 _("retour")." ".$this->valF['date_limite']."<br>");
113 $this->valF['lu'] = true;
114 }
115
116 }
117
118 function triggerajouterapres($id,&$db,$val,$DEBUG) {
119
120 // Verification de la demande de notif par mail
121 $sql= "SELECT abrege, notification_email, email FROM ".DB_PREFIXE.
122 "service WHERE service ='".$this->valF['service']."'";
123 $res=$db->query($sql);
124 $notif = $res->fetchrow(DB_FETCHMODE_ASSOC);
125 if (database :: isError($sql))die($res->getMessage()."erreur ".$sql);
126 if ($notif['notification_email']=='t') {
127
128 // Recuperation des infos du dossier
129 $sql= "SELECT dossier, terrain_adresse, terrain_adresse_complement, terrain_cp, terrain_ville
130 FROM ".DB_PREFIXE."dossier WHERE dossier ='".$this->valF['dossier']."'";
131 $res=$db->query($sql);
132 $dossier = $res->fetchrow(DB_FETCHMODE_ASSOC);
133
134 // Definition des parametres d'envoi du mail
135 $title=_("Consultation de services : dossier no")." ".$dossier['dossier'];
136 $corps=_("Votre service est consulte concernant le dossier no")." ".$dossier['dossier']."<br/>".
137 _("Il concerne le terrain situe a l'adresse :")." ".utf8_decode($dossier['terrain_adresse']).
138 " ".utf8_decode($dossier['terrain_adresse_complement'])." ".utf8_decode($dossier['terrain_cp'])." ".$dossier['terrain_ville']."<br/>".
139 _("Vous pouvez y acceder et rendre votre avis a l'adresse")." <a href='".$this->f->getParameter('lien_interne_vdm').
140 "scr/form.php?obj=consultation&action=3&idx=".$this->valF['consultation']."' >".
141 _("Lien interne (services VDM)")."</a> "._("ou")." <a href='".$this->f->getParameter('lien_externe').
142 "scr/form.php?obj=consultation&action=3&idx=".$this->valF['consultation']."' >".
143 _("Lien externe (hors VDM)")."</a>";
144 // Envoi du mail avec message de retour
145 if($this->f->sendMail($title, $corps, $notif['email'])) {
146 $this->addToMessage(_("Envoi d'un mail de notification au service")." ".$notif['abrege']);
147 } else {
148 $this->addToMessage(_("L'envoi du mail de notification a echoue"));
149 }
150 }
151
152 }
153
154 // =============================================
155 // calcul de date avec ajout de mois (delais)
156 // [add months (delay) and calculation final date]
157 // limite ? => voir fonction instruction
158 // =============================================
159 function moisdate($date,$delaimois) {
160 // rajout de mois à une date (moins de 12)
161 $temp = explode("-" , $date);
162 $jour = (int) $temp[2];
163 $mois = (int) $temp[1];
164 $annee = (int) $temp[0];
165 $mois=$mois+$delaimois;
166 // calcul mois annee
167 if($mois>12){
168 $mois=$mois-12;
169 $annee=$annee+1;
170 }
171 // Calcul du nombre de jours dans le mois sélectionné
172 switch($mois) {
173 case "2":
174 if ($annee % 4 == 0 && $annee % 100 != 0 || $annee % 400 == 0)
175 $jourmax = 29;
176 else
177 $jourmax = 28;
178 break;
179 case "4":
180 case "6":
181 case "9":
182 case "11":
183 $jourmax = 30;
184 break;
185 default:
186 $jourmax = 31;
187 }
188 if ($jour > $jourmax)
189 $jour = $jourmax;
190 return $annee."-".$mois."-".$jour ;
191 }
192
193 // =============================================
194 // Ajout du fielset
195 // Add fieldset
196 // =============================================
197 function setLayout(&$form, $maj){
198 if ( $maj < 2 OR $maj == 3 ) {
199 if(!$this->f->isAccredited('consultation_retour_avis_service')) {
200 //Champs sur lequel s'ouvre le fieldset
201 $form->setBloc('dossier','D',"");
202 $form->setFieldset('dossier','D',_('Consultation'));
203
204 //Champs sur lequel se ferme le fieldset
205 $form->setFieldset('date_envoi','F','');
206 $form->setBloc('date_envoi','F');
207 }
208 if ( $maj == 1 OR $maj == 3 ){
209 //Champs sur lequel s'ouvre le fieldset
210 $form->setBloc('date_reception','D',"");
211 $form->setFieldset('date_reception','D',_('Retour d\'avis'));
212
213 //Champs sur lequel se ferme le fieldset
214 $form->setFieldset('lu','F','');
215 $form->setBloc('lu','F');
216 }
217 }
218 }
219
220 }// fin classe
221 ?>

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26