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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 497 - (show annotations)
Fri Oct 12 15:35:11 2012 UTC (12 years, 3 months ago) by vpihour
File size: 7687 byte(s)
Ajout des modifications pour les consultations

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 setValFAjout($val){
13 $this->valF['service'] = $val['service'];
14 }
15 function setvalF($val){
16 parent::setvalF($val);
17 // cles secondaires numerique (contrainte integrite pgsql)
18 if($val['avis_consultation']=='') $this->valF['avis_consultation']= null;
19 }
20 function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire){
21 if ($validation==0) {
22 if ($maj == 0){
23 $form->setVal("dossier", $idxformulaire);
24 $form->setVal("date_envoi",date('d/m/Y'));
25 }
26 else
27 if ( $maj == 1 )
28 $form->setVal("date_retour",date('d/m/Y'));
29 }
30 }
31
32 function setType(&$form,$maj) {
33 parent::setType($form,$maj);
34 if ($maj < 2) { //ajouter et modifier [add and modify]
35 if($maj==0){ // add
36 $form->setType('date_envoi', 'date2');
37 $form->setType('service', 'select');
38 $form->setType('date_limite', 'hidden');
39 $form->setType('date_retour', 'hidden');
40 $form->setType('avis_consultation', 'hidden');
41 $form->setType('motivation', 'hidden');
42 $form->setType('fichier', 'hidden');
43 $form->setType('lu', 'hidden');
44 $form->setType('date_reception', 'hidden');
45 }else{ // modify
46 $form->setType('date_envoi', 'hiddenstaticdate');
47 $form->setType('date_limite', 'hiddenstaticdate');
48 $form->setType('service', 'selectdisabled');
49 $form->setType('date_retour', 'date2');
50 $form->setType('avis_consultation', 'select');
51 $form->setType('motivation', 'textarea');
52 $form->setType('fichier', 'upload');
53 }
54 $form->setType('consultation', 'hiddenstatic');
55 $form->setType('dossier', 'hiddenstatic');
56 }
57 else {
58 $form->setType('date_limite', 'hidden');
59 $form->setType('date_retour', 'hidden');
60 $form->setType('avis_consultation', 'hidden');
61 $form->setType('motivation', 'hidden');
62 $form->setType('fichier', 'hidden');
63 $form->setType('lu', 'hidden');
64 $form->setType('date_reception', 'hidden');
65 }
66 }
67
68 // TRIGGER AVANT MODIFICATION DE DONNEES
69 // trigger before modification data
70 function triggerajouter($id,&$db,$val,$DEBUG) {
71 // mise a jour instruction avec evenement [return delay]
72 if (!$this->valF['date_envoi']==""){
73 $sql= "select delai from ".DB_PREFIXE."service where service ='".$this->valF['service']."'";
74 $delai = $db->getOne($sql);
75 $this->valF['date_limite'] = $this->moisdate($this->valF['date_envoi'],$delai);
76 $this->msg=$this->msg."<br>"._("delai")." ".
77 _("retour")." ".$delai." "._("mois")." -> ".
78 _("retour")." ".$this->valF['date_limite']."<br>";
79 $this->valF['lu'] = true;
80
81 /*require("../php/phpmailer/class.phpmailer.php");
82
83 $mail = new PHPMailer();
84
85 $mail->IsSMTP(); // set mailer to use SMTP
86 $mail->Host = "smtp.gmail.com"; // specify main and backup server
87 $mail->SMTPAuth = true; // turn on SMTP authentication
88 $mail->Username = ""; // SMTP username
89 $mail->Password = ""; // SMTP password
90
91 $mail->From = "[email protected]";
92 $mail->FromName = "Mailer";
93 $mail->AddAddress("[email protected]", "Vi");
94 $mail->AddReplyTo("[email protected]", "Information");
95
96 $mail->WordWrap = 50; // set word wrap to 50 characters
97 $mail->IsHTML(true); // set email format to HTML
98
99 $mail->Subject = "Here is the subject";
100 $mail->Body = "This is the HTML message body <b>in bold!</b>";
101 $mail->AltBody = "This is the body in plain text for non-HTML mail clients";
102
103 if(!$mail->Send())
104 {
105 echo "Message could not be sent. <p>";
106 echo "Mailer Error: " . $mail->ErrorInfo;
107 exit;
108 }
109
110 echo "Message has been sent";*/
111 }
112 }
113
114 // =============================================
115 // calcul de date avec ajout de mois (delais)
116 // [add months (delay) and calculation final date]
117 // limite ? => voir fonction instruction
118 // =============================================
119 function moisdate($date,$delaimois) {
120 // rajout de mois à une date (moins de 12)
121 $temp = explode("-" , $date);
122 $jour = (int) $temp[2];
123 $mois = (int) $temp[1];
124 $annee = (int) $temp[0];
125 $mois=$mois+$delaimois;
126 // calcul mois annee
127 if($mois>12){
128 $mois=$mois-12;
129 $annee=$annee+1;
130 }
131 // Calcul du nombre de jours dans le mois sélectionné
132 switch($mois) {
133 case "2":
134 if ($annee % 4 == 0 && $annee % 100 != 0 || $annee % 400 == 0)
135 $jourmax = 29;
136 else
137 $jourmax = 28;
138 break;
139 case "4":
140 case "6":
141 case "9":
142 case "11":
143 $jourmax = 30;
144 break;
145 default:
146 $jourmax = 31;
147 }
148 if ($jour > $jourmax)
149 $jour = $jourmax;
150 return $annee."-".$mois."-".$jour ;
151 }
152
153 // =============================================
154 // Ajout du fielset
155 // Add fieldset
156 // =============================================
157 function setLayout(&$form, $maj){
158 if ( $maj < 2 ) {
159 //Champs sur lequel s'ouvre le fieldset
160 $form->setBloc('dossier','D',"");
161 $form->setFieldset('dossier','D',_('Consultation'));
162
163 //Champs sur lequel se ferme le fieldset
164 $form->setFieldset('date_envoi','F','');
165 $form->setBloc('date_envoi','F');
166 if ( $maj == 1 ){
167 //Champs sur lequel s'ouvre le fieldset
168 $form->setBloc('date_reception','D',"");
169 $form->setFieldset('date_reception','D',_('Retour d\'avis'));
170
171 //Champs sur lequel se ferme le fieldset
172 $form->setFieldset('lu','F','');
173 $form->setBloc('lu','F');
174 }
175 }
176
177 }
178
179 function setSelect(&$form, $maj,&$db,$debug) {
180 parent::setSelect($form, $maj,$db,$debug);
181 if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php"))
182 include ("../sql/".$db->phptype."/".$this->table.".form.inc.php");
183 if($maj<2){
184 $contenu=array();
185 $sql = " SELECT service, abrege, libelle FROM ".DB_PREFIXE."service";
186 $res = $db->query($sql);
187 if (database::isError($res))
188 die($res->getMessage());
189 $contenu[0][0]="";
190 $contenu[1][0]=_('choisir')." "._('service');
191 $k=1;
192 while ($row=& $res->fetchRow()){
193 if($maj==0){ // ajouter
194 $contenu[0][$k]=$row[0];
195 $contenu[1][$k]=$row[1]." ".$row[2];
196 $k++;
197 }else{
198 // select hiddenstatic
199 $contenu[0][$k]=$row[0];
200 $contenu[1][$k]=$row[1]." ".$row[2];
201 $k++;
202 }
203 }
204 $form->setSelect("service",$contenu);
205 }
206 }
207
208 //Formatage des intitulés des champs.
209 function setLib(&$form,$maj) {
210 parent::setLib($form,$maj);
211 $form->setLib('date_reception','date de reception');
212 $form->setLib('avis_consultation','avis');
213 $form->setLib('fichier','retour d\'avis');
214 }
215 }// fin classe
216 ?>

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26