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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 80 - (show annotations)
Mon Aug 22 15:54:28 2011 UTC (13 years, 5 months ago) by fraynaud
File size: 5188 byte(s)
wid + consultation retour + dossier limite -> TDB



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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26