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