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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3333 - (show annotations)
Tue Mar 10 17:36:04 2015 UTC (9 years, 10 months ago) by vpihour
File size: 15612 byte(s)
Correction de la civilité du pétitionnaire affichée dans la visualisation du dossier.

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26