1 |
<?php |
2 |
//$Id$ |
3 |
//gen openMairie le 28/06/2012 16:26 |
4 |
require_once ("../obj/om_dbform.class.php"); |
5 |
|
6 |
class travaux_gen extends om_dbform { |
7 |
var $table="travaux"; |
8 |
var $clePrimaire="travaux"; |
9 |
var $typeCle="N"; |
10 |
var $retourformulaire; |
11 |
|
12 |
function setvalF($val) { |
13 |
//affectation valeur formulaire |
14 |
if(!is_numeric($val['travaux'])) |
15 |
unset($this->valF['travaux']); |
16 |
else |
17 |
$this->valF['travaux'] = $val['travaux']; |
18 |
$this->valF['libelle'] = $val['libelle']; |
19 |
$this->valF['nature'] = $val['nature']; |
20 |
$this->valF['codelascot'] = $val['codelascot']; |
21 |
$this->valF['solde'] = $val['solde']; |
22 |
} |
23 |
|
24 |
//================================================= |
25 |
//cle primaire automatique [automatic primary key] |
26 |
//================================================== |
27 |
|
28 |
function setId(&$db) { |
29 |
//numero automatique |
30 |
$this->valF[$this->table] = $db->nextId(DB_PREFIXE.$this->table); |
31 |
} |
32 |
|
33 |
function setValFAjout($val) { |
34 |
//numero automatique -> pas de controle ajout cle primaire |
35 |
} |
36 |
|
37 |
function verifierAjout() { |
38 |
//numero automatique -> pas de verfication de cle primaire |
39 |
} |
40 |
|
41 |
//==================================== |
42 |
// verifier avant validation [verify] |
43 |
//===================================== |
44 |
/** |
45 |
* Methode verifier |
46 |
*/ |
47 |
function verifier($val = array(), &$db = NULL, $DEBUG = false) { |
48 |
// On appelle la methode de la classe parent |
49 |
parent::verifier($val, $db, $DEBUG); |
50 |
// On verifie si le champ n'est pas vide |
51 |
if ($this->valF['libelle'] == "") { |
52 |
$this->correct = false; |
53 |
$this->addToMessage(_("Le champ")." "._("libelle")." "._("est obligatoire")); |
54 |
} |
55 |
} |
56 |
|
57 |
|
58 |
//========================== |
59 |
// Formulaire [form] |
60 |
//========================== |
61 |
|
62 |
function setType(&$form,$maj) { |
63 |
//type |
64 |
if ($maj==0){ //ajout |
65 |
$form->setType('travaux','hidden');// cle automatique |
66 |
$form->setType('libelle','text'); |
67 |
if($this->retourformulaire=='nature') |
68 |
$form->setType('nature','hiddenstatic'); |
69 |
else |
70 |
$form->setType('nature','select'); |
71 |
$form->setType('codelascot','text'); |
72 |
$form->setType('solde','text'); |
73 |
}// fin ajout |
74 |
if ($maj==1){ //modifier |
75 |
$form->setType('travaux','hiddenstatic'); |
76 |
$form->setType('libelle','text'); |
77 |
if($this->retourformulaire=='nature') |
78 |
$form->setType('nature','hiddenstatic'); |
79 |
else |
80 |
$form->setType('nature','select'); |
81 |
$form->setType('codelascot','text'); |
82 |
$form->setType('solde','text'); |
83 |
}// fin modifier |
84 |
if ($maj==2){ //supprimer |
85 |
$form->setType('travaux','hiddenstatic'); |
86 |
$form->setType('libelle','hiddenstatic'); |
87 |
$form->setType('nature','hiddenstatic'); |
88 |
$form->setType('codelascot','hiddenstatic'); |
89 |
$form->setType('solde','hiddenstatic'); |
90 |
}//fin supprimer |
91 |
} |
92 |
|
93 |
function setOnchange(&$form,$maj) { |
94 |
//javascript controle client |
95 |
$form->setOnchange('travaux','VerifNum(this)'); |
96 |
} |
97 |
/** |
98 |
* Methode setTaille |
99 |
*/ |
100 |
function setTaille(&$form, $maj) { |
101 |
$form->setTaille("travaux", 11); |
102 |
$form->setTaille("libelle", 30); |
103 |
$form->setTaille("nature", 10); |
104 |
$form->setTaille("codelascot", 10); |
105 |
$form->setTaille("solde", 10); |
106 |
} |
107 |
|
108 |
/** |
109 |
* Methode setMax |
110 |
*/ |
111 |
function setMax(&$form, $maj) { |
112 |
$form->setMax("travaux", 11); |
113 |
$form->setMax("libelle", 80); |
114 |
$form->setMax("nature", 2); |
115 |
$form->setMax("codelascot", 1); |
116 |
$form->setMax("solde", 3); |
117 |
} |
118 |
|
119 |
|
120 |
function setLib(&$form,$maj) { |
121 |
//libelle des champs |
122 |
$form->setLib('travaux',_('travaux')); |
123 |
$form->setLib('libelle',_('libelle')); |
124 |
$form->setLib('nature',_('nature')); |
125 |
$form->setLib('codelascot',_('codelascot')); |
126 |
$form->setLib('solde',_('solde')); |
127 |
} |
128 |
|
129 |
function setSelect(&$form, $maj,&$db,$debug) { |
130 |
if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php")) |
131 |
include ("../sql/".$db->phptype."/".$this->table.".form.inc.php"); |
132 |
elseif(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc")) |
133 |
include ("../sql/".$db->phptype."/".$this->table.".form.inc"); |
134 |
if($maj<2){ |
135 |
// nature |
136 |
$contenu=array(); |
137 |
$res = $db->query($sql_nature); |
138 |
// Logger |
139 |
$this->addToLog("setSelect()[gen/obj]: db->query(\"".$sql_nature."\");", VERBOSE_MODE); |
140 |
if (database::isError($res)) |
141 |
die($res->getMessage().$sql_nature); |
142 |
else{ |
143 |
if ($debug == 1) |
144 |
echo " la requete ".$sql_nature." est executee<br>"; |
145 |
$contenu[0][0]=''; |
146 |
$contenu[1][0]=_('choisir')." "._('nature'); |
147 |
$k=1; |
148 |
while ($row=& $res->fetchRow()){ |
149 |
$contenu[0][$k]=$row[0]; |
150 |
$contenu[1][$k]=$row[1]; |
151 |
$k++; |
152 |
} |
153 |
$form->setSelect('nature',$contenu); |
154 |
}// fin error db |
155 |
}// fin maj |
156 |
}// fin select |
157 |
|
158 |
//================================== |
159 |
// sous Formulaire [subform] |
160 |
//================================== |
161 |
|
162 |
function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire,&$db,$DEBUG=null){ |
163 |
$this->retourformulaire = $retourformulaire; |
164 |
if($validation==0) { |
165 |
if($retourformulaire =='nature') |
166 |
$form->setVal('nature', $idxformulaire); |
167 |
}// fin validation |
168 |
}// fin setValsousformulaire |
169 |
|
170 |
//================================== |
171 |
// cle secondaire [secondary key] |
172 |
//================================== |
173 |
/** |
174 |
* Methode clesecondaire |
175 |
*/ |
176 |
function cleSecondaire($id, &$db = NULL, $val = array(), $DEBUG = false) { |
177 |
// On appelle la methode de la classe parent |
178 |
parent::cleSecondaire($id, $db, $val, $DEBUG); |
179 |
// Verification de la cle secondaire : dossier |
180 |
$this->rechercheTable($db, "dossier", "travaux", $id); |
181 |
} |
182 |
|
183 |
|
184 |
}// fin classe |
185 |
?> |