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

Annotation of /trunk/obj/destination_shon.class.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 174 - (hide annotations)
Wed Oct 5 08:18:30 2011 UTC (13 years, 4 months ago) by fraynaud
File size: 5908 byte(s)
calcul de la shon


1 fraynaud 3 <?php
2     //$Id$
3     //gen openMairie le 10/02/2011 20:32
4     require_once ("../gen/obj/destination_shon.class.php");
5    
6     class destination_shon extends destination_shon_gen {
7    
8 fraynaud 20 function destination_shon($id,&$db,$debug) {
9     $this->constructeur($id,$db,$debug);
10     }// fin constructeur
11 fraynaud 3
12 fraynaud 38 function setvalF($val){
13     parent::setvalF($val);
14     // colone numerique
15 fraynaud 169
16 fraynaud 38 if(!is_numeric($val['shon'])) unset ($this->valF['shon']);
17 fraynaud 169 if(!is_numeric($val['shon_anterieure'])) unset ($this->valF['shon_anterieure']);
18     if(!is_numeric($val['shon_demolie'])) unset ($this->valF['shon_demolie']);
19     if(!is_numeric($val['shon_anterieure_supprimee'])) unset ($this->valF['shon_anterieure_supprimee']);
20     if(!is_numeric($val['shon_nouvelle'])) unset ($this->valF['shon_nouvelle']);
21     if(!is_numeric($val['shon_shob_transformee'])) unset ($this->valF['shon_shob_transformee']);
22     if(!is_numeric($val['shon_nouvelle_transformee'])) unset ($this->valF['shon_nouvelle_transformee']);
23 fraynaud 38 }
24    
25    
26 fraynaud 20 function setType(&$form,$maj) {
27     parent :: setType($form,$maj);
28     if ($maj < 2) { //ajouter et modifier
29     $form->setType('dossier', 'hiddenstatic');
30 fraynaud 174 $form->setType('shon', 'hiddenstatic');
31 fraynaud 38 }else
32     $form->setType('shon', 'text');
33 fraynaud 20 }
34    
35     function setTaille(&$form,$maj){
36     $form->setTaille('destination_shon', 8);
37     $form->setTaille('shon', 12);
38     $form->setTaille('destination', 2);
39     $form->setTaille('dossier', 12);
40     }
41    
42     function setMax(&$form,$maj){
43     $form->setMax('destination_shon', 8);
44     $form->setMax('shon', 12);
45     $form->setMax('destination', 2);
46     $form->setMax('dossier', 12);
47     }
48    
49 fraynaud 174 function triggerajouter($id,&$db,$val,$DEBUG){
50     $this->calculshon($val);
51     }
52    
53    
54 fraynaud 20 function triggerajouterapres($id,&$db,$val,$DEBUG){
55     /// calcul shon dossier [calculate shon dossier]
56     $sql ="select sum(shon) as shon from destination_shon where dossier ='"
57     .$val['dossier']."'" ;
58     $res=$db->query($sql);
59 fraynaud 38 if (database :: isError($res))
60 fraynaud 20 die($res->getMessage()."erreur ".$sql);
61     while ($row=& $res->fetchRow( DB_FETCHMODE_ASSOC)){
62     $cle= " dossier = '".$val['dossier']."'";
63 fraynaud 38 if(!is_numeric($row['shon']))
64     $surface=0;
65     else
66     $surface = $row['shon'];
67     $valF['shon_calcul']= $surface;
68 fraynaud 20 $res1= $db->autoExecute('dossier',$valF,DB_AUTOQUERY_UPDATE,$cle);
69     if (database::isError($res1))
70     die($res1->getMessage());
71     if ($DEBUG == 1)
72     echo "La requête de mise à jour est effectuée.<br>";
73     $this->msg=$this->msg."<br>"._('enregistrement').
74     " ".$val['dossier']." "._('table')." dossier "
75     ." [".$db->affectedRows()." "._('enregistrement')." ".
76     _('mis_a_jour')."]" ;
77     }
78     }
79    
80 fraynaud 174 function triggermodifier($id,&$db,$val,$DEBUG){
81     $this->calculshon($val);
82     }
83 fraynaud 20
84 fraynaud 174
85 fraynaud 20 function triggermodifierapres($id,&$db,$val,$DEBUG)
86     {
87     // calcul shon dossier [calculate shon dossier]
88     $sql ="select sum(shon) as shon from destination_shon where dossier ='"
89     .$val['dossier']."'" ;
90     $res=$db->query($sql);
91     if (database::isError($res))
92     die($res->getMessage());
93     while ($row=& $res->fetchRow( DB_FETCHMODE_ASSOC)){
94     $cle= " dossier = '".$val['dossier']."'";
95 fraynaud 38 if(!is_numeric($row['shon']))
96     $surface=0;
97     else
98     $surface = $row['shon'];
99     $valF['shon_calcul']= $surface;
100 fraynaud 20 $res1= $db->autoExecute('dossier',$valF,DB_AUTOQUERY_UPDATE,$cle);
101     if (database::isError($res1))
102     die($res1->getMessage());
103     if ($DEBUG == 1)
104     echo "La requête de mise à jour est effectuée.<br>";
105     $this->msg=$this->msg."<br>"._('enregistrement').
106     " ".$val['dossier']." "._('table')." dossier ".
107     " [".$db->affectedRows()." "._('enregistrement')." ".
108     _('mis_a_jour')."]" ;
109     }
110     }
111    
112     function triggersupprimerapres($id,&$db,$val,$DEBUG)
113     {
114     // calcul shon dossier [calculate shon dossier]
115     $sql ="select sum(shon) as shon from destination_shon where dossier ='"
116     .$val['dossier']."'" ;
117     $res=$db->query($sql);
118     if (database::isError($res))
119     die($res->getMessage());
120     while ($row=& $res->fetchRow( DB_FETCHMODE_ASSOC)){
121     $cle= " dossier = '".$val['dossier']."'";
122 fraynaud 38 if(!is_numeric($row['shon']))
123     $surface=0;
124     else
125     $surface = $row['shon'];
126     $valF['shon_calcul']= $surface;
127 fraynaud 20 $res1= $db->autoExecute('dossier',$valF,DB_AUTOQUERY_UPDATE,$cle);
128     if (database::isError($res1))
129     die($res1->getMessage());
130     if ($DEBUG == 1)
131     echo "La requête de mise à jour est effectuée.<br>";
132     $this->msg=$this->msg."<br>"._('enregistrement').
133     " ".$val['dossier']." "._('table')." dossier ".
134     " [".$db->affectedRows()." "._('enregistrement')." ".
135     _('mis_a_jour')."]" ;
136     }
137     }
138    
139     function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire){
140     if ($validation==0) {
141     if ($maj == 0){
142     $form->setVal("dossier", $idxformulaire);
143     }
144     }
145     }
146    
147 fraynaud 174 function calculshon($val){
148     $this->valF['shon']= $val['shon_nouvelle']+$val['shon_shob_transformee']+$val['shon_nouvelle_transformee']
149     - $val['shon_demolie']- $val['shon_anterieure_supprimee'];
150     //$val['shon']."***";
151     }
152    
153    
154 fraynaud 3 }// fin classe
155     ?>

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26