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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3 by fraynaud, Thu Feb 10 20:46:18 2011 UTC revision 20 by fraynaud, Mon Jul 18 15:27:17 2011 UTC
# Line 5  require_once ("../gen/obj/consultation.c Line 5  require_once ("../gen/obj/consultation.c
5    
6  class consultation extends consultation_gen {  class consultation extends consultation_gen {
7    
8  function consultation($id,&$db,$debug) {      function consultation($id,&$db,$debug) {
9          $this->constructeur($id,$db,$debug);          $this->constructeur($id,$db,$debug);
10  }// fin constructeur      }// fin constructeur
11        
12        function setValFAjout($val){
13            $this->valF['service'] = $val['service'];
14        }
15    
16    
17        function verifierAjout(){
18            $this->correct=True;
19            $imgv="";
20            $f="&nbsp!    ";
21            $imgv="<img src='../img/punaise.png' style='vertical-align:middle' hspace='2' border='0'>";
22            if ($this->valF['service']==""){
23               $this->correct=false;
24               $this->msg= $this->msg.$imgv." "._("service")." ".
25               _("obligatoire").$f;
26            }
27        }
28    
29        function verifier(){
30            $this->correct=True;
31            $imgv="";
32            $f="&nbsp!&nbsp;&nbsp;&nbsp;&nbsp;";
33            $imgv="<img src='../img/punaise.png' style='vertical-align:middle' hspace='2' border='0'>";
34            if ($this->valF['dossier']==""){
35               $this->correct=false;
36               $this->msg= $this->msg.$imgv." "._("dossier")." ".
37               _("obligatoire").$f;
38            }
39            if ($this->valF['date_envoi']==""){
40               $this->correct=false;
41               $this->msg= $this->msg.$imgv." "._("date_envoi")." ".
42               _("obligatoire").$f;
43            }
44        }
45    
46        function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire){
47            if ($validation==0) {
48                if ($maj == 0){
49                  $form->setVal("dossier", $idxformulaire);
50                }
51            }
52        }
53    
54        function setType(&$form,$maj) {
55            if ($maj < 2) { //ajouter et modifier [add and modify]
56                if($maj==0){ // add
57                    $form->setType('date_envoi', 'date2');
58                    $form->setType('service', 'select');
59                    $form->setType('date_limite', 'hidden');
60                    $form->setType('date_retour', 'hidden');
61                    $form->setType('avis', 'hidden');
62                }else{   // modify
63                    $form->setType('date_envoi', 'hiddenstaticdate');
64                    $form->setType('service', 'selectdisabled');
65                    $form->setType('date_limite', 'date2');
66                    $form->setType('date_retour', 'date2');
67                    $form->setType('avis', 'select');
68                }
69                $form->setType('consultation', 'hiddenstatic');
70                $form->setType('dossier', 'hiddenstatic');
71            }else{ // supprimer
72                $form->setType('consultation', 'hiddenstatic');
73                $form->setType('dossier', 'hiddenstatic');
74            }
75        }
76    
77        function setTaille(&$form,$maj){
78            $form->setTaille('consultation', 8);
79            $form->setTaille('dossier', 12);
80            $form->setTaille('service', 5);
81            $form->setTaille('date_envoi', 12);
82            $form->setTaille('date_retour', 12);
83            $form->setTaille('avis', 2);
84            $form->setTaille('date_limite', 12);
85        }
86    
87        function setMax(&$form,$maj){
88            $form->setMax('consultation', 8);
89            $form->setMax('dossier', 12);
90            $form->setMax('service', 5);
91            $form->setMax('date_envoi', 12);
92            $form->setMax('date_retour', 12);
93            $form->setMax('avis', 2);
94            $form->setMax('date_limite', 12);
95        }
96    
97    
98        // TRIGGER AVANT MODIFICATION DE DONNEES
99        // trigger before modification data
100        function triggerajouter($id,&$db,$val,$DEBUG) {
101            // mise a jour instruction avec evenement [return delay]
102            $sql= "select delai from service where service ='".$this->valF['service']."'";
103            $delai = $db->getOne($sql);
104            $this->valF['date_limite'] =  $this->moisdate($this->valF['date_envoi'],$delai);
105            $this->msg=$this->msg."<br>"._("delai")." ".
106               _("retour")." ".$delai." "._("mois")." -> ".
107               _("retour")." ".$this->valF['date_limite']."<br>";
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  }// fin classe
150  ?>  ?>

Legend:
Removed from v.3  
changed lines
  Added in v.20

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26