1 |
<?php |
2 |
//$Id$ |
3 |
//gen openMairie le 02/09/2011 11:08 |
4 |
require_once (PATH_OPENMAIRIE."dbformdyn.class.php"); |
5 |
|
6 |
class proprietaire_gen extends dbForm { |
7 |
var $table="proprietaire"; |
8 |
var $clePrimaire="proprietaire"; |
9 |
var $typeCle="A"; |
10 |
var $retourformulaire; |
11 |
|
12 |
function setvalF($val) { |
13 |
//affectation valeur formulaire |
14 |
$this->valF['proprietaire'] = $val['proprietaire']; |
15 |
$this->valF['civilite'] = $val['civilite']; |
16 |
$this->valF['nom'] = $val['nom']; |
17 |
$this->valF['prenom'] = $val['prenom']; |
18 |
$this->valF['adresse1'] = $val['adresse1']; |
19 |
$this->valF['adresse2'] = $val['adresse2']; |
20 |
$this->valF['cp'] = $val['cp']; |
21 |
$this->valF['ville'] = $val['ville']; |
22 |
} |
23 |
|
24 |
//==================================== |
25 |
// verifier avant validation [verify] |
26 |
//===================================== |
27 |
/** |
28 |
* Methode verifier |
29 |
*/ |
30 |
function verifier($val = array(), &$db = NULL, $DEBUG = false) { |
31 |
// On appelle la methode de la classe parent |
32 |
parent::verifier($val, $db, $DEBUG); |
33 |
// On verifie si le champ n'est pas vide |
34 |
if ($this->valF['civilite'] == "") { |
35 |
$this->correct = false; |
36 |
$this->addToMessage(_("Le champ")." "._("civilite")." "._("est obligatoire")); |
37 |
} |
38 |
} |
39 |
|
40 |
|
41 |
//========================== |
42 |
// Formulaire [form] |
43 |
//========================== |
44 |
|
45 |
function setType(&$form,$maj) { |
46 |
//type |
47 |
if ($maj==0){ //ajout |
48 |
$form->setType('proprietaire','text'); |
49 |
if($this->retourformulaire=='civilite') |
50 |
$form->setType('civilite','hiddenstatic'); |
51 |
else |
52 |
$form->setType('civilite','select'); |
53 |
$form->setType('nom','text'); |
54 |
$form->setType('prenom','text'); |
55 |
$form->setType('adresse1','text'); |
56 |
$form->setType('adresse2','text'); |
57 |
$form->setType('cp','text'); |
58 |
$form->setType('ville','text'); |
59 |
}// fin ajout |
60 |
if ($maj==1){ //modifier |
61 |
$form->setType('proprietaire','hiddenstatic'); |
62 |
if($this->retourformulaire=='civilite') |
63 |
$form->setType('civilite','hiddenstatic'); |
64 |
else |
65 |
$form->setType('civilite','select'); |
66 |
$form->setType('nom','text'); |
67 |
$form->setType('prenom','text'); |
68 |
$form->setType('adresse1','text'); |
69 |
$form->setType('adresse2','text'); |
70 |
$form->setType('cp','text'); |
71 |
$form->setType('ville','text'); |
72 |
}// fin modifier |
73 |
if ($maj==2){ //supprimer |
74 |
$form->setType('proprietaire','hiddenstatic'); |
75 |
$form->setType('civilite','hiddenstatic'); |
76 |
$form->setType('nom','hiddenstatic'); |
77 |
$form->setType('prenom','hiddenstatic'); |
78 |
$form->setType('adresse1','hiddenstatic'); |
79 |
$form->setType('adresse2','hiddenstatic'); |
80 |
$form->setType('cp','hiddenstatic'); |
81 |
$form->setType('ville','hiddenstatic'); |
82 |
}//fin supprimer |
83 |
} |
84 |
|
85 |
function setOnchange(&$form,$maj) { |
86 |
//javascript controle client |
87 |
} |
88 |
|
89 |
function setTaille(&$form,$maj) { |
90 |
//taille des champs affiches (text) |
91 |
$form->setTaille('proprietaire',20); |
92 |
$form->setTaille('civilite',20); |
93 |
$form->setTaille('nom',20); |
94 |
$form->setTaille('prenom',20); |
95 |
$form->setTaille('adresse1',20); |
96 |
$form->setTaille('adresse2',20); |
97 |
$form->setTaille('cp',20); |
98 |
$form->setTaille('ville',20); |
99 |
} |
100 |
|
101 |
function setMax(&$form,$maj) { |
102 |
//longueur max en saisie (text) |
103 |
$form->setMax('proprietaire',20); |
104 |
$form->setMax('civilite',20); |
105 |
$form->setMax('nom',20); |
106 |
$form->setMax('prenom',20); |
107 |
$form->setMax('adresse1',20); |
108 |
$form->setMax('adresse2',20); |
109 |
$form->setMax('cp',20); |
110 |
$form->setMax('ville',20); |
111 |
} |
112 |
|
113 |
function setLib(&$form,$maj) { |
114 |
//libelle des champs |
115 |
$form->setLib('proprietaire',_('proprietaire')); |
116 |
$form->setLib('civilite',_('civilite')); |
117 |
$form->setLib('nom',_('nom')); |
118 |
$form->setLib('prenom',_('prenom')); |
119 |
$form->setLib('adresse1',_('adresse1')); |
120 |
$form->setLib('adresse2',_('adresse2')); |
121 |
$form->setLib('cp',_('cp')); |
122 |
$form->setLib('ville',_('ville')); |
123 |
} |
124 |
|
125 |
function setSelect(&$form, $maj,&$db,$debug) { |
126 |
if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc")) |
127 |
include ("../sql/".$db->phptype."/".$this->table.".form.inc"); |
128 |
if($maj<2){ |
129 |
// civilite |
130 |
$contenu=array(); |
131 |
$res = $db->query($sql_civilite); |
132 |
if (database::isError($res)) |
133 |
die($res->getMessage().$sql_civilite); |
134 |
else{ |
135 |
if ($debug == 1) |
136 |
echo " la requete ".$sql_civilite." est executee<br>"; |
137 |
$contenu[0][0]=''; |
138 |
$contenu[1][0]=_('choisir')." "._('civilite'); |
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('civilite',$contenu); |
146 |
}// fin error db |
147 |
}// fin maj |
148 |
}// fin select |
149 |
|
150 |
//================================== |
151 |
// sous Formulaire [subform] |
152 |
//================================== |
153 |
|
154 |
function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire,&$db,$DEBUG=null){ |
155 |
$this->retourformulaire = $retourformulaire; |
156 |
if($validation==0) { |
157 |
if($retourformulaire =='civilite') |
158 |
$form->setVal('civilite', $idxformulaire); |
159 |
}// fin validation |
160 |
}// fin setValsousformulaire |
161 |
|
162 |
//================================== |
163 |
// cle secondaire [secondary key] |
164 |
//================================== |
165 |
/** |
166 |
* Methode clesecondaire |
167 |
*/ |
168 |
function cleSecondaire($id, &$db = NULL, $val = array(), $DEBUG = false) { |
169 |
// On appelle la methode de la classe parent |
170 |
parent::cleSecondaire($id, $db, $val, $DEBUG); |
171 |
// Verification de la cle secondaire : parcelle |
172 |
$this->rechercheTable($db, "parcelle", "proprietaire", $id); |
173 |
} |
174 |
|
175 |
|
176 |
}// fin classe |
177 |
?> |