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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 29 - (show annotations)
Tue Jul 19 16:31:13 2011 UTC (13 years, 6 months ago) by fraynaud
File size: 5351 byte(s)
om4 postgresql structuration de la base


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
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
16 function setvalF($val){
17 parent::setvalF($val);
18
19 // cles secondaires numerique (contrainte integrite pgsql)
20 if(!is_numeric($val['avis'])) $this->valF['avis']= null;
21 }
22
23
24
25 function verifierAjout(){
26 $this->correct=True;
27 $imgv="";
28 $f="&nbsp!&nbsp;&nbsp;&nbsp;&nbsp;";
29 $imgv="<img src='../img/punaise.png' style='vertical-align:middle' hspace='2' border='0'>";
30 if ($this->valF['service']==""){
31 $this->correct=false;
32 $this->msg= $this->msg.$imgv." "._("service")." ".
33 _("obligatoire").$f;
34 }
35 }
36
37 function verifier(){
38 $this->correct=True;
39 $imgv="";
40 $f="&nbsp!&nbsp;&nbsp;&nbsp;&nbsp;";
41 $imgv="<img src='../img/punaise.png' style='vertical-align:middle' hspace='2' border='0'>";
42 if ($this->valF['dossier']==""){
43 $this->correct=false;
44 $this->msg= $this->msg.$imgv." "._("dossier")." ".
45 _("obligatoire").$f;
46 }
47 if ($this->valF['date_envoi']==""){
48 $this->correct=false;
49 $this->msg= $this->msg.$imgv." "._("date_envoi")." ".
50 _("obligatoire").$f;
51 }
52 }
53
54 function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire){
55 if ($validation==0) {
56 if ($maj == 0){
57 $form->setVal("dossier", $idxformulaire);
58 }
59 }
60 }
61
62 function setType(&$form,$maj) {
63 if ($maj < 2) { //ajouter et modifier [add and modify]
64 if($maj==0){ // add
65 $form->setType('date_envoi', 'date2');
66 $form->setType('service', 'select');
67 $form->setType('date_limite', 'hidden');
68 $form->setType('date_retour', 'hidden');
69 $form->setType('avis', 'hidden');
70 }else{ // modify
71 $form->setType('date_envoi', 'hiddenstaticdate');
72 $form->setType('service', 'selectdisabled');
73 $form->setType('date_limite', 'date2');
74 $form->setType('date_retour', 'date2');
75 $form->setType('avis', 'select');
76 }
77 $form->setType('consultation', 'hiddenstatic');
78 $form->setType('dossier', 'hiddenstatic');
79 }else{ // supprimer
80 $form->setType('consultation', 'hiddenstatic');
81 $form->setType('dossier', 'hiddenstatic');
82 }
83 }
84
85 function setTaille(&$form,$maj){
86 $form->setTaille('consultation', 8);
87 $form->setTaille('dossier', 12);
88 $form->setTaille('service', 5);
89 $form->setTaille('date_envoi', 12);
90 $form->setTaille('date_retour', 12);
91 $form->setTaille('avis', 2);
92 $form->setTaille('date_limite', 12);
93 }
94
95 function setMax(&$form,$maj){
96 $form->setMax('consultation', 8);
97 $form->setMax('dossier', 12);
98 $form->setMax('service', 5);
99 $form->setMax('date_envoi', 12);
100 $form->setMax('date_retour', 12);
101 $form->setMax('avis', 2);
102 $form->setMax('date_limite', 12);
103 }
104
105
106 // TRIGGER AVANT MODIFICATION DE DONNEES
107 // trigger before modification data
108 function triggerajouter($id,&$db,$val,$DEBUG) {
109 // mise a jour instruction avec evenement [return delay]
110 $sql= "select delai from service where service ='".$this->valF['service']."'";
111 $delai = $db->getOne($sql);
112 $this->valF['date_limite'] = $this->moisdate($this->valF['date_envoi'],$delai);
113 $this->msg=$this->msg."<br>"._("delai")." ".
114 _("retour")." ".$delai." "._("mois")." -> ".
115 _("retour")." ".$this->valF['date_limite']."<br>";
116 }
117
118 // =============================================
119 // calcul de date avec ajout de mois (delais)
120 // [add months (delay) and calculation final date]
121 // limite ? => voir fonction instruction
122 // =============================================
123 function moisdate($date,$delaimois) {
124 // rajout de mois à une date (moins de 12)
125 $temp = explode("-" , $date);
126 $jour = (int) $temp[2];
127 $mois = (int) $temp[1];
128 $annee = (int) $temp[0];
129 $mois=$mois+$delaimois;
130 // calcul mois annee
131 if($mois>12){
132 $mois=$mois-12;
133 $annee=$annee+1;
134 }
135 // Calcul du nombre de jours dans le mois sélectionné
136 switch($mois) {
137 case "2":
138 if ($annee % 4 == 0 && $annee % 100 != 0 || $annee % 400 == 0)
139 $jourmax = 29;
140 else
141 $jourmax = 28;
142 break;
143 case "4":
144 case "6":
145 case "9":
146 case "11":
147 $jourmax = 30;
148 break;
149 default:
150 $jourmax = 31;
151 }
152 if ($jour > $jourmax)
153 $jour = $jourmax;
154 return $annee."-".$mois."-".$jour ;
155 }
156
157 }// fin classe
158 ?>

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26