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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1777 - (show annotations)
Tue Apr 23 10:37:14 2013 UTC (11 years, 9 months ago) by vpihour
File size: 15463 byte(s)
Correction des erreurs de base de données non gérées

1 <?php
2 //$Id$
3 //gen openMairie le 08/11/2012 14:59
4
5 require_once ("../gen/obj/demandeur.class.php");
6
7 class demandeur extends demandeur_gen {
8
9 var $required_tag = array("particulier_nom",
10 "personne_morale_denomination",
11 "personne_morale_raison_sociale");
12 function demandeur($id,&$db,$debug) {
13 $this->constructeur($id,$db,$debug);
14 }// fin constructeur
15
16 /*
17 * Pays par défaut : France
18 */
19 function setVal(&$form, $maj, $validation, &$db) {
20 if($maj == 0) {
21 $form->setVal("pays",'France');
22 }
23 }
24
25 /*
26 * Pays par défaut : France
27 */
28 function setValSousFormulaire(&$form, $maj, $validation, &$db) {
29 if($maj == 0) {
30 $form->setVal("pays",'France');
31 }
32 }
33
34 /**
35 * Surcharge de la méthode de vérification
36 **/
37 function verifier($val, &$db, $DEBUG) {
38 parent::verifier($val, $db, $DEBUG);
39 // le nom du particulier est obligatoire
40 if($this->valF['qualite'] == "particulier" AND $this->valF['particulier_nom'] == "") {
41 $this->correct = false;
42 $this->addToMessage(_("Le champ")." <span class=\"bold\">".
43 _("particulier_nom")."</span> "._("est obligatoire."));
44 }
45
46 // la dénomination ou la raison sociale est obligatoire pour une personne morale
47 if($this->valF['qualite'] == "personne_morale"
48 AND $this->valF['personne_morale_denomination'] == ""
49 AND $this->valF['personne_morale_raison_sociale'] == "") {
50 $this->correct = false;
51 $this->addToMessage(_("Un des champs")." <span class=\"bold\">".
52 _("personne_morale_denomination")."</span> ou <span class=\"bold\">".
53 _("personne_morale_raison_sociale")."</span> "._("doit etre rempli."));
54 }
55
56 }
57
58 /*
59 * Select pour les champs qualite et type_demandeur
60 */
61 function setType(&$form,$maj) {
62 parent::setType($form,$maj);
63 if ($maj < 2) { //ajouter et modifier
64
65 $form->setType('type_demandeur', 'select');
66 $form->setType('qualite', 'select');
67 if($maj == 0 AND $this->getParameter("idx_demandeur") != "") {
68 $form->setType('frequent','hidden');
69 $form->setType('qualite','selectdisabled');
70 $form->setType('particulier_nom','textdisabled');
71 $form->setType('particulier_prenom','textdisabled');
72 $form->setType('particulier_date_naissance','datedisabled');
73 $form->setType('particulier_commune_naissance','textdisabled');
74 $form->setType('particulier_departement_naissance','textdisabled');
75 $form->setType('personne_morale_denomination','textdisabled');
76 $form->setType('personne_morale_raison_sociale','textdisabled');
77 $form->setType('personne_morale_siret','textdisabled');
78 $form->setType('personne_morale_categorie_juridique','textdisabled');
79 $form->setType('personne_morale_nom','textdisabled');
80 $form->setType('personne_morale_prenom','textdisabled');
81 $form->setType('particulier_civilite','selectdisabled');
82 $form->setType('personne_morale_civilite','selectdisabled');
83 $form->setType('telephone_fixe','textdisabled');
84 $form->setType('telephone_mobile','textdisabled');
85 $form->setType('indicatif','textdisabled');
86 $form->setType('courriel','textdisabled');
87
88 }
89 // XXX
90 // Champs disabled pour la modif de petitionnaires frequents
91 // Solution temporaire
92 if ($maj==1){ //modifier
93 if($this->getVal('frequent') == 't') {
94 $form->setType('qualite','selecthiddenstatic');
95 $form->setType('particulier_nom','static');
96 $form->setType('particulier_prenom','static');
97 $form->setType('particulier_date_naissance','datestatic');
98 $form->setType('particulier_commune_naissance','static');
99 $form->setType('particulier_departement_naissance','static');
100 $form->setType('personne_morale_denomination','static');
101 $form->setType('personne_morale_raison_sociale','static');
102 $form->setType('personne_morale_siret','static');
103 $form->setType('personne_morale_categorie_juridique','static');
104 $form->setType('personne_morale_nom','static');
105 $form->setType('personne_morale_prenom','static');
106 $form->setType('numero','static');
107 $form->setType('voie','static');
108 $form->setType('complement','static');
109 $form->setType('lieu_dit','static');
110 $form->setType('localite','static');
111 $form->setType('code_postal','static');
112 $form->setType('bp','static');
113 $form->setType('cedex','static');
114 $form->setType('pays','static');
115 $form->setType('division_territoriale','static');
116 $form->setType('telephone_fixe','static');
117 $form->setType('telephone_mobile','static');
118 $form->setType('indicatif','static');
119 $form->setType('courriel','static');
120 $form->setType('notification','checkboxstatic');
121 $form->setType('frequent','checkboxstatic');
122 $form->setType('particulier_civilite','selecthiddenstatic');
123 $form->setType('personne_morale_civilite','selecthiddenstatic');
124 }
125 }// fin modifier
126 }
127 $form->setType('demandeur', 'hidden');
128
129 }
130
131 /*
132 * Select pour le type_demandeur et qualite
133 */
134 function setSelect(&$form, $maj,&$db,$debug) {
135 parent::setSelect($form, $maj,$db,$debug);
136
137 /*Lors d'un ajout ou d'une modification*/
138 if( $maj < 2 ){
139
140 /* type_demandeur*/
141 $contenu=array();
142
143 $contenu[0][0]="";
144 $contenu[1][0]=_('choisir')." "._('type_demandeur');
145 $contenu[0][1]="petitionnaire";
146 $contenu[1][1]=_('petitionnaire');
147 $contenu[0][2]="delegataire";
148 $contenu[1][2]=_('delegataire');
149
150 $form->setSelect("type_demandeur",$contenu);
151
152 /* qualite*/
153 $contenu=array();
154
155 $contenu[0][0]="particulier";
156 $contenu[1][0]=_('particulier');
157 $contenu[0][1]="personne_morale";
158 $contenu[1][1]=_('personne morale');
159
160 $form->setSelect("qualite",$contenu);
161 }
162 }
163
164 /*
165 * Ajoute l'action javascript sur le select de la qualité
166 */
167 function setOnchange(&$form,$maj){
168 parent::setOnchange($form,$maj);
169
170 $form->setOnchange("qualite","changeDemandeurType('qualite');");
171 }
172
173 /**
174 * Ajout d'un champs caché permettant de linker l'id du demandeur
175 * recement ajouté
176 **/
177 function sousFormSpecificContent($maj) {
178 $id_demandeur = $this->getVal("demandeur");
179 if(isset($this->valF["demandeur"]) AND !empty($this->valF["demandeur"])) {
180 echo "<input id=\"id_retour\" name=\"idRetour\" type=\"hidden\" value=\"".
181 $this->valF["demandeur"]."\" />";
182 } elseif(isset($id_demandeur) AND !empty($id_demandeur) AND $maj == 1) {
183 echo "<input id=\"id_retour\" name=\"idRetour\" type=\"hidden\" value=\"".
184 $this->getVal("demandeur")."\" />";
185 }
186 }
187 /**
188 * Surcharge du lien de retour permettant de linker l'id du demandeur
189 * recement ajouté
190 **/
191 function retoursousformulaire($idxformulaire, $retourformulaire, $val,
192 $objsf, $premiersf, $tricolsf, $validation,
193 $idx, $maj, $retour) {
194 if($retourformulaire === "demande") {
195 echo "\n<a class=\"retour\" ";
196 echo "href=\"#\">";
197 //
198 echo _("Retour");
199 //
200 echo "</a>\n";
201 } else {
202 parent::retoursousformulaire($idxformulaire, $retourformulaire, $val,
203 $objsf, $premiersf, $tricolsf, $validation,
204 $idx, $maj, $retour);
205 }
206 }
207
208 /**
209 * Ajout du paramètre principal
210 */
211 function getDataSubmitSousForm() {
212 /*Création du lien de validation du sous-formulaire*/
213 $datasubmit = "";
214 $datasubmit .= "../scr/sousform.php";
215 $datasubmit .= "?";
216 $datasubmit .= "obj=".get_class($this);
217 $datasubmit .= "&amp;validation=".$this->getParameter("validation");
218 if ($this->getParameter("idx") != "]") {
219 //
220 if ($this->getParameter("maj") == 1) { // modifier
221 $datasubmit .= "&amp;action=1";
222 $datasubmit .= "&amp;idx=".$this->getParameter("idx");
223 } else { // supprimer
224 $datasubmit .= "&amp;action=2";
225 $datasubmit .= "&amp;idx=".$this->getParameter("idx");
226 }
227 }
228 $datasubmit .= "&amp;premiersf=".$this->getParameter("premiersf");
229 $datasubmit .= "&amp;retourformulaire=".$this->getParameter("retourformulaire");
230 $datasubmit .= "&amp;trisf=".$this->getParameter("tricolsf");
231 $datasubmit .= "&amp;idxformulaire=".$this->getParameter("idxformulaire");
232 $datasubmit .= "&amp;principal=".$this->getParameter("principal");
233 //
234 return $datasubmit;
235 }
236
237 /**
238 * Synthèse des demandeurs pour le formulaire de la demande
239 */
240 function afficherSynthese($type, $linkable) {
241 switch ($type) {
242 case 'petitionnaire_principal':
243 $legend = _("Petitionnaire principal :");
244 break;
245
246 case 'delegataire':
247 $legend = _("Delegataire :");
248 break;
249
250 case 'petitionnaire':
251 $legend = _("Petitionnaire :");
252 break;
253 }
254
255 // Conteneur du demandeur
256 echo "<div class=\"".$type." col_3\" id=\"".$type."_".$this->val[array_search('demandeur', $this->champs)]."\">\n";
257 echo "<div class=\"legend_synthese_demandeur\">\n";
258 echo $legend;
259 echo "</div>\n";
260 echo "<div class=\"synthese_demandeur\">\n";
261 if($linkable) {
262 echo "<a href=\"#\" onclick=\"removeDemandeur('".
263 $type."_".$this->val[array_search('demandeur', $this->champs)].
264 "'); return false;\">
265 <span class=\"demandeur_del om-icon om-icon-16 om-icon-fix delete-16\" title=\"".
266 _("Supprimer le demandeur")."\">"._("Supprimer le demandeur")."</span>
267 </a>";
268 }
269
270 // Valeur de formulaire à retourner
271 echo "<input type=\"hidden\" class=\"demandeur_id\" name=\"".$type.
272 (($type == "petitionnaire")? "[]":"" ).
273 "\" value=\"".$this->val[array_search('demandeur', $this->champs)]."\" />\n";
274
275 // Lien de modification du demandeur
276 if($linkable) {
277 echo "<a class=\"edit_demandeur\" href=\"#\"
278 onclick=\"editDemandeur('".$this->val[array_search('type_demandeur', $this->champs)]."',".
279 $this->val[array_search('demandeur', $this->champs)].",'".
280 $type."',".
281 $type."_".$this->val[array_search('demandeur', $this->champs)].
282 ");return false;\">\n";
283 }
284
285 // Affichage des infos du demandeur
286 if($this->val[array_search('qualite', $this->champs)] == 'particulier') {
287 if(!empty($this->val[array_search('civilite', $this->champs)])) {
288 $sql = "SELECT libelle FROM ".DB_PREFIXE."civilite WHERE civilite=".
289 $this->val[array_search('civilite', $this->champs)];
290 $civilite = $this->db->getone($sql);
291 $this->f->addToLog("afficherSynthese() : db->getone(\"".$sql."\");", VERBOSE_MODE);
292 if ( database::isError($civilite)){
293 die();
294 }
295 echo $civilite." ";
296 }
297 echo $this->val[array_search('particulier_nom', $this->champs)]." ".
298 $this->val[array_search('particulier_prenom', $this->champs)]."<br/>\n";
299 } else {
300 echo $this->val[array_search('personne_morale_raison_sociale', $this->champs)]." ".
301 $this->val[array_search('personne_morale_denomination', $this->champs)]."<br/>\n";
302 if(!empty($this->val[array_search('personne_morale_civilite', $this->champs)])) {
303 $sql = "SELECT libelle FROM ".DB_PREFIXE."civilite WHERE civilite=".
304 $this->val[array_search('personne_morale_civilite', $this->champs)];
305 $civilite = $this->f->db->getone($sql);
306 $this->f->addToLog("afficherSynthese() : db->getone(\"".$sql."\");", VERBOSE_MODE);
307 if ( database::isError($civilite)){
308 die();
309 }
310 echo $civilite." ";
311 }
312 echo $this->val[array_search('personne_morale_nom', $this->champs)]." ".
313 $this->val[array_search('personne_morale_nom', $this->champs)]."<br/>\n";
314 }
315 echo (($this->val[array_search('numero', $this->champs)] != "")?
316 $this->val[array_search('numero', $this->champs)]." " : "").
317 (($this->val[array_search('voie', $this->champs)] != "")?
318 $this->val[array_search('voie', $this->champs)]." " : "").
319 (($this->val[array_search('complement', $this->champs)] != "")?
320 $this->val[array_search('complement', $this->champs)]." " : "")."<br/>\n".
321 (($this->val[array_search('code_postal', $this->champs)] != "")?
322 $this->val[array_search('code_postal', $this->champs)]." " : "").
323 (($this->val[array_search('localite', $this->champs)] != "")?
324 $this->val[array_search('localite', $this->champs)]." " : "").
325 (($this->val[array_search('bp', $this->champs)] != "")?
326 $this->val[array_search('bp', $this->champs)]." " : "").
327 (($this->val[array_search('cedex', $this->champs)] != "")?
328 $this->val[array_search('cedex', $this->champs)]." " : "")."<br/>\n".
329 (($this->val[array_search('telephone_fixe', $this->champs)] != "")?
330 $this->val[array_search('telephone_fixe', $this->champs)]." " : "").
331 (($this->val[array_search('telephone_mobile', $this->champs)] != "")?
332 $this->val[array_search('telephone_mobile', $this->champs)]." " : "");
333 if($linkable) {
334 echo "</a>\n";
335 }
336 echo "</div>\n";
337 echo "</div>\n";
338 }
339
340 }// fin classe
341 ?>

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26