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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1118 - (show annotations)
Fri Dec 21 16:22:39 2012 UTC (12 years, 1 month ago) by nhaye
File size: 15036 byte(s)
Amélioration de l'érgonomie de l'ajout des demandeurs à la demande ainsi que du formulaire des demandeurs

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 OR $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 // Champs disabled pour la modif de petitionnaires frequents
90 // Solution temporaire
91 if ($maj==1){ //modifier
92 if($this->getVal('frequent') == 't') {
93 $form->setType('qualite','selecthiddenstatic');
94 $form->setType('particulier_nom','static');
95 $form->setType('particulier_prenom','static');
96 $form->setType('particulier_date_naissance','datestatic');
97 $form->setType('particulier_commune_naissance','static');
98 $form->setType('particulier_departement_naissance','static');
99 $form->setType('personne_morale_denomination','static');
100 $form->setType('personne_morale_raison_sociale','static');
101 $form->setType('personne_morale_siret','static');
102 $form->setType('personne_morale_categorie_juridique','static');
103 $form->setType('personne_morale_nom','static');
104 $form->setType('personne_morale_prenom','static');
105 $form->setType('numero','static');
106 $form->setType('voie','static');
107 $form->setType('complement','static');
108 $form->setType('lieu_dit','static');
109 $form->setType('localite','static');
110 $form->setType('code_postal','static');
111 $form->setType('bp','static');
112 $form->setType('cedex','static');
113 $form->setType('pays','static');
114 $form->setType('division_territoriale','static');
115 $form->setType('telephone_fixe','static');
116 $form->setType('telephone_mobile','static');
117 $form->setType('indicatif','static');
118 $form->setType('courriel','static');
119 $form->setType('notification','checkboxstatic');
120 $form->setType('frequent','checkboxstatic');
121 $form->setType('particulier_civilite','selecthiddenstatic');
122 $form->setType('personne_morale_civilite','selecthiddenstatic');
123 }
124 }// fin modifier
125 }
126 $form->setType('demandeur', 'hidden');
127
128 }
129
130 /*
131 * Select pour le type_demandeur et qualite
132 */
133 function setSelect(&$form, $maj,&$db,$debug) {
134 parent::setSelect($form, $maj,$db,$debug);
135
136 /*Lors d'un ajout ou d'une modification*/
137 if( $maj < 2 ){
138
139 /* type_demandeur*/
140 $contenu=array();
141
142 $contenu[0][0]="";
143 $contenu[1][0]=_('choisir')." "._('type_demandeur');
144 $contenu[0][1]="petitionnaire";
145 $contenu[1][1]=_('petitionnaire');
146 $contenu[0][2]="delegataire";
147 $contenu[1][2]=_('delegataire');
148
149 $form->setSelect("type_demandeur",$contenu);
150
151 /* qualite*/
152 $contenu=array();
153
154 $contenu[0][0]="particulier";
155 $contenu[1][0]=_('particulier');
156 $contenu[0][1]="personne_morale";
157 $contenu[1][1]=_('personne morale');
158
159 $form->setSelect("qualite",$contenu);
160 }
161 }
162
163 /*
164 * Ajoute l'action javascript sur le select de la qualité
165 */
166 function setOnchange(&$form,$maj){
167 parent::setOnchange($form,$maj);
168
169 $form->setOnchange("qualite","changeDemandeurType('qualite');");
170 }
171
172 /**
173 * Ajout d'un champs caché permettant de linker l'id du demandeur
174 * recement ajouté
175 **/
176 function sousFormSpecificContent($maj) {
177 if(isset($this->valF['demandeur']) AND !empty($this->valF['demandeur'])) {
178 echo "<input id=\"id_retour\" name=\"idRetour\" type=\"hidden\" value=\"".
179 $this->valF['demandeur']."\" />";
180 }
181 }
182 /**
183 * Surcharge du lien de retour permettant de linker l'id du demandeur
184 * recement ajouté
185 **/
186 function retoursousformulaire($idxformulaire, $retourformulaire, $val,
187 $objsf, $premiersf, $tricolsf, $validation,
188 $idx, $maj, $retour) {
189 if($retourformulaire === "demande") {
190 echo "\n<a class=\"retour\" ";
191 echo "href=\"#\">";
192 //
193 echo _("Retour");
194 //
195 echo "</a>\n";
196 } else {
197 parent::retoursousformulaire($idxformulaire, $retourformulaire, $val,
198 $objsf, $premiersf, $tricolsf, $validation,
199 $idx, $maj, $retour);
200 }
201 }
202
203 /**
204 * Ajout du paramètre principal
205 */
206 function getDataSubmitSousForm() {
207 /*Création du lien de validation du sous-formulaire*/
208 $datasubmit = "";
209 $datasubmit .= "../scr/sousform.php";
210 $datasubmit .= "?";
211 $datasubmit .= "obj=".get_class($this);
212 $datasubmit .= "&amp;validation=".$this->getParameter("validation");
213 if ($this->getParameter("idx") != "]") {
214 //
215 if ($this->getParameter("maj") == 1) { // modifier
216 $datasubmit .= "&amp;action=1";
217 $datasubmit .= "&amp;idx=".$this->getParameter("idx");
218 } else { // supprimer
219 $datasubmit .= "&amp;action=2";
220 $datasubmit .= "&amp;idx=".$this->getParameter("idx");
221 }
222 }
223 $datasubmit .= "&amp;premiersf=".$this->getParameter("premiersf");
224 $datasubmit .= "&amp;retourformulaire=".$this->getParameter("retourformulaire");
225 $datasubmit .= "&amp;trisf=".$this->getParameter("tricolsf");
226 $datasubmit .= "&amp;idxformulaire=".$this->getParameter("idxformulaire");
227 $datasubmit .= "&amp;principal=".$this->getParameter("principal");
228 //
229 return $datasubmit;
230 }
231
232 /**
233 * Synthèse des demandeurs pour le formulaire de la demande
234 */
235 function afficherSynthese($type, $linkable) {
236 switch ($type) {
237 case 'petitionnaire_principal':
238 $legend = _("Petitionnaire principal :");
239 break;
240
241 case 'delegataire':
242 $legend = _("Delegataire :");
243 break;
244
245 case 'petitionnaire':
246 $legend = _("Petitionnaire :");
247 break;
248 }
249
250 // Conteneur du demandeur
251 echo "<div class=\"".$type." col_3\" id=\"".$type."_".$this->val[array_search('demandeur', $this->champs)]."\">\n";
252 echo "<div class=\"legend_synthese_demandeur\">\n";
253 echo $legend;
254 echo "</div>\n";
255 echo "<div class=\"synthese_demandeur\">\n";
256 if($linkable) {
257 echo "<a href=\"#\" onclick=\"removeDemandeur('".
258 $type."_".$this->val[array_search('demandeur', $this->champs)].
259 "'); return false;\">
260 <span class=\"demandeur_del om-icon om-icon-16 om-icon-fix delete-16\" title=\"".
261 _("Supprimer le demandeur")."\">"._("Supprimer le demandeur")."</span>
262 </a>";
263 }
264
265 // Valeur de formulaire à retourner
266 echo "<input type=\"hidden\" class=\"demandeur_id\" name=\"".$type.
267 (($type == "petitionnaire")? "[]":"" ).
268 "\" value=\"".$this->val[array_search('demandeur', $this->champs)]."\" />\n";
269
270 // Lien de modification du demandeur
271 if($linkable) {
272 echo "<a class=\"edit_demandeur\" href=\"#\"
273 onclick=\"editDemandeur('".$this->val[array_search('type_demandeur', $this->champs)]."',".
274 $this->val[array_search('demandeur', $this->champs)].",'".
275 $type."',".
276 $type."_".$this->val[array_search('demandeur', $this->champs)].
277 ");return false;\">\n";
278 }
279
280 // Affichage des infos du demandeur
281 if($this->val[array_search('qualite', $this->champs)] == 'particulier') {
282 if(!empty($this->val[array_search('civilite', $this->champs)])) {
283 $sql = "SELECT libelle FROM ".DB_PREFIXE."civilite WHERE civilite=".
284 $this->val[array_search('civilite', $this->champs)];
285 $civilite = $this->f->db->getone($sql);
286 $this->f->addToLog("db->getone(\"".$sql."\");", VERBOSE_MODE);
287 $this->f->isDatabaseError($civilite);
288 echo $civilite." ";
289 }
290 echo $this->val[array_search('particulier_nom', $this->champs)]." ".
291 $this->val[array_search('particulier_prenom', $this->champs)]."<br/>\n";
292 } else {
293 echo $this->val[array_search('personne_morale_raison_sociale', $this->champs)]." ".
294 $this->val[array_search('personne_morale_denomination', $this->champs)]."<br/>\n";
295 if(!empty($this->val[array_search('personne_morale_civilite', $this->champs)])) {
296 $sql = "SELECT libelle FROM ".DB_PREFIXE."civilite WHERE civilite=".
297 $this->val[array_search('personne_morale_civilite', $this->champs)];
298 $civilite = $this->f->db->getone($sql);
299 $this->f->addToLog("db->getone(\"".$sql."\");", VERBOSE_MODE);
300 $this->f->isDatabaseError($civilite);
301 echo $civilite." ";
302 }
303 echo $this->val[array_search('personne_morale_nom', $this->champs)]." ".
304 $this->val[array_search('personne_morale_nom', $this->champs)]."<br/>\n";
305 }
306 echo (($this->val[array_search('numero', $this->champs)] != "")?
307 $this->val[array_search('numero', $this->champs)]." " : "").
308 (($this->val[array_search('voie', $this->champs)] != "")?
309 $this->val[array_search('voie', $this->champs)]." " : "").
310 (($this->val[array_search('complement', $this->champs)] != "")?
311 $this->val[array_search('complement', $this->champs)]." " : "")."<br/>\n".
312 (($this->val[array_search('code_postal', $this->champs)] != "")?
313 $this->val[array_search('code_postal', $this->champs)]." " : "").
314 (($this->val[array_search('localite', $this->champs)] != "")?
315 $this->val[array_search('localite', $this->champs)]." " : "").
316 (($this->val[array_search('bp', $this->champs)] != "")?
317 $this->val[array_search('bp', $this->champs)]." " : "").
318 (($this->val[array_search('cedex', $this->champs)] != "")?
319 $this->val[array_search('cedex', $this->champs)]." " : "")."<br/>\n".
320 (($this->val[array_search('telephone_fixe', $this->champs)] != "")?
321 $this->val[array_search('telephone_fixe', $this->champs)]." " : "").
322 (($this->val[array_search('telephone_mobile', $this->champs)] != "")?
323 $this->val[array_search('telephone_mobile', $this->champs)]." " : "");
324 if($linkable) {
325 echo "</a>\n";
326 }
327 echo "</div>\n";
328 echo "</div>\n";
329 }
330
331 }// fin classe
332 ?>

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26