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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 562 - (show annotations)
Wed Oct 31 10:20:27 2012 UTC (12 years, 3 months ago) by nhaye
File size: 7731 byte(s)
Ajout de commentaires

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26