/[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 459 by nhaye, Thu Sep 27 09:06:12 2012 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        function setvalF($val){
16            parent::setvalF($val);      
17            // cles secondaires numerique (contrainte integrite  pgsql)
18            if($val['avis']=='') $this->valF['avis']= 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                }
25            }
26        }
27    
28        function setType(&$form,$maj) {
29            parent::setType($form,$maj);
30            if ($maj < 2) { //ajouter et modifier [add and modify]
31                if($maj==0){ // add
32                    $form->setType('date_envoi', 'date2');
33                    $form->setType('service', 'select');
34                    $form->setType('date_limite', 'hidden');
35                    $form->setType('date_retour', 'hidden');
36                    $form->setType('avis', 'hidden');
37                }else{   // modify
38                    $form->setType('date_envoi', 'hiddenstaticdate');
39                    $form->setType('service', 'selectdisabled');
40                    $form->setType('date_limite', 'date2');
41                    $form->setType('date_retour', 'date2');
42                    $form->setType('avis', 'select');
43                }
44                $form->setType('consultation', 'hiddenstatic');
45                $form->setType('dossier', 'hiddenstatic');
46            }
47        }
48    
49        // TRIGGER AVANT MODIFICATION DE DONNEES
50        // trigger before modification data
51        function triggerajouter($id,&$db,$val,$DEBUG) {
52            // mise a jour instruction avec evenement [return delay]
53            if (!$this->valF['date_envoi']==""){
54                $sql= "select delai from ".DB_PREFIXE."service where service ='".$this->valF['service']."'";
55                $delai = $db->getOne($sql);
56                $this->valF['date_limite'] =  $this->moisdate($this->valF['date_envoi'],$delai);
57                $this->msg=$this->msg."<br>"._("delai")." ".
58                   _("retour")." ".$delai." "._("mois")." -> ".
59                   _("retour")." ".$this->valF['date_limite']."<br>";
60            }
61        }
62    
63        // =============================================
64        // calcul de date avec ajout de mois (delais)
65        // [add months (delay) and calculation final date]
66        // limite ? => voir fonction instruction
67        // =============================================
68        function moisdate($date,$delaimois) {
69            // rajout de mois à une date (moins de 12)
70            $temp = explode("-" , $date);
71            $jour = (int) $temp[2];
72            $mois = (int) $temp[1];
73            $annee = (int) $temp[0];
74            $mois=$mois+$delaimois;
75            // calcul mois annee
76            if($mois>12){
77                $mois=$mois-12;
78                $annee=$annee+1;
79            }
80             // Calcul du nombre de jours dans le mois sélectionné
81             switch($mois) {
82                case "2":
83                    if ($annee % 4 == 0 && $annee % 100 != 0 || $annee % 400 == 0)
84                        $jourmax = 29;
85                    else
86                        $jourmax = 28;
87                break;
88                case "4":
89                case "6":
90                case "9":
91                case "11":
92                    $jourmax = 30;
93                    break;
94                default:
95                    $jourmax = 31;
96            }
97            if ($jour > $jourmax)
98                $jour = $jourmax;
99            return $annee."-".$mois."-".$jour ;
100        }
101    
102  }// fin classe  }// fin classe
103  ?>  ?>

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26