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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 587 - (show annotations)
Fri Nov 2 17:44:04 2012 UTC (12 years, 3 months ago) by nhaye
File size: 9075 byte(s)
La date de retour de consultation est maintenant prédéfinie

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26