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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 585 - (show annotations)
Fri Nov 2 17:16:05 2012 UTC (12 years, 3 months ago) by nhaye
File size: 8640 byte(s)
Correction de l'affichage du formulaire des consultations,
focus auto sur le champs consultation du formulaire de retour de consultation,
redirection auto sur le formulaire de consultation en modification

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26