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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 502 - (show annotations)
Mon Oct 15 16:22:36 2012 UTC (12 years, 3 months ago) by vpihour
File size: 6564 byte(s)
Ajout du type de consulation dans les services

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 }
82
83 // =============================================
84 // calcul de date avec ajout de mois (delais)
85 // [add months (delay) and calculation final date]
86 // limite ? => voir fonction instruction
87 // =============================================
88 function moisdate($date,$delaimois) {
89 // rajout de mois à une date (moins de 12)
90 $temp = explode("-" , $date);
91 $jour = (int) $temp[2];
92 $mois = (int) $temp[1];
93 $annee = (int) $temp[0];
94 $mois=$mois+$delaimois;
95 // calcul mois annee
96 if($mois>12){
97 $mois=$mois-12;
98 $annee=$annee+1;
99 }
100 // Calcul du nombre de jours dans le mois sélectionné
101 switch($mois) {
102 case "2":
103 if ($annee % 4 == 0 && $annee % 100 != 0 || $annee % 400 == 0)
104 $jourmax = 29;
105 else
106 $jourmax = 28;
107 break;
108 case "4":
109 case "6":
110 case "9":
111 case "11":
112 $jourmax = 30;
113 break;
114 default:
115 $jourmax = 31;
116 }
117 if ($jour > $jourmax)
118 $jour = $jourmax;
119 return $annee."-".$mois."-".$jour ;
120 }
121
122 // =============================================
123 // Ajout du fielset
124 // Add fieldset
125 // =============================================
126 function setLayout(&$form, $maj){
127 if ( $maj < 2 ) {
128 //Champs sur lequel s'ouvre le fieldset
129 $form->setBloc('dossier','D',"");
130 $form->setFieldset('dossier','D',_('Consultation'));
131
132 //Champs sur lequel se ferme le fieldset
133 $form->setFieldset('date_envoi','F','');
134 $form->setBloc('date_envoi','F');
135 if ( $maj == 1 ){
136 //Champs sur lequel s'ouvre le fieldset
137 $form->setBloc('date_reception','D',"");
138 $form->setFieldset('date_reception','D',_('Retour d\'avis'));
139
140 //Champs sur lequel se ferme le fieldset
141 $form->setFieldset('lu','F','');
142 $form->setBloc('lu','F');
143 }
144 }
145
146 }
147
148 function setSelect(&$form, $maj,&$db,$debug) {
149 parent::setSelect($form, $maj,$db,$debug);
150 if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php"))
151 include ("../sql/".$db->phptype."/".$this->table.".form.inc.php");
152 if($maj<2){
153 $contenu=array();
154 $sql = " SELECT service, abrege, libelle FROM ".DB_PREFIXE."service";
155 $res = $db->query($sql);
156 if (database::isError($res))
157 die($res->getMessage());
158 $contenu[0][0]="";
159 $contenu[1][0]=_('choisir')." "._('service');
160 $k=1;
161 while ($row=& $res->fetchRow()){
162 if($maj==0){ // ajouter
163 $contenu[0][$k]=$row[0];
164 $contenu[1][$k]=$row[1]." ".$row[2];
165 $k++;
166 }else{
167 // select hiddenstatic
168 $contenu[0][$k]=$row[0];
169 $contenu[1][$k]=$row[1]." ".$row[2];
170 $k++;
171 }
172 }
173 $form->setSelect("service",$contenu);
174 }
175 }
176
177 //Formatage des intitulés des champs.
178 function setLib(&$form,$maj) {
179 parent::setLib($form,$maj);
180 $form->setLib('date_reception','date de reception');
181 $form->setLib('avis_consultation','avis');
182 $form->setLib('fichier','retour d\'avis');
183 }
184
185
186 }// fin classe
187 ?>

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26