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