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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 242 - (show annotations)
Wed Nov 23 19:39:04 2011 UTC (13 years, 2 months ago) by fraynaud
File size: 5989 byte(s)
mise a niveau shema


1 <?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 function destination_shon($id,&$db,$debug) {
9 $this->constructeur($id,$db,$debug);
10 }// fin constructeur
11
12 function setvalF($val){
13 parent::setvalF($val);
14 // colone numerique
15
16 if(!is_numeric($val['shon'])) unset ($this->valF['shon']);
17 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 }
24
25
26 function setType(&$form,$maj) {
27 parent :: setType($form,$maj);
28 if ($maj < 2) { //ajouter et modifier
29 $form->setType('dossier', 'hiddenstatic');
30 $form->setType('shon', 'hiddenstatic');
31 }else
32 $form->setType('shon', 'text');
33 }
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 function triggerajouter($id,&$db,$val,$DEBUG){
50 $this->calculshon($val);
51 }
52
53
54 function triggerajouterapres($id,&$db,$val,$DEBUG){
55 /// calcul shon dossier [calculate shon dossier]
56 $sql ="select sum(shon) as shon from ".DB_PREFIXE.
57 "destination_shon where dossier ='".$val['dossier']."'" ;
58 $res=$db->query($sql);
59 if (database :: isError($res))
60 die($res->getMessage()."erreur ".$sql);
61 while ($row=& $res->fetchRow( DB_FETCHMODE_ASSOC)){
62 $cle= " dossier = '".$val['dossier']."'";
63 if(!is_numeric($row['shon']))
64 $surface=0;
65 else
66 $surface = $row['shon'];
67 $valF['shon_calcul']= $surface;
68 $res1= $db->autoExecute(DB_PREFIXE.'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 function triggermodifier($id,&$db,$val,$DEBUG){
81 $this->calculshon($val);
82 }
83
84
85 function triggermodifierapres($id,&$db,$val,$DEBUG)
86 {
87 // calcul shon dossier [calculate shon dossier]
88 $sql ="select sum(shon) as shon from ".DB_PREFIXE.
89 "destination_shon where dossier ='".$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 if(!is_numeric($row['shon']))
96 $surface=0;
97 else
98 $surface = $row['shon'];
99 $valF['shon_calcul']= $surface;
100 $res1= $db->autoExecute(DB_PREFIXE.'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 ".DB_PREFIXE."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 if(!is_numeric($row['shon']))
123 $surface=0;
124 else
125 $surface = $row['shon'];
126 $valF['shon_calcul']= $surface;
127 $res1= $db->autoExecute(DB_PREFIXE.'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 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 }// fin classe
155 ?>

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26