/[openfoncier]/trunk/app/sitadel.class.php
ViewVC logotype

Contents of /trunk/app/sitadel.class.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1834 - (show annotations)
Mon May 6 09:38:05 2013 UTC (11 years, 9 months ago) by nhaye
File size: 34694 byte(s)
Suppression de debug, moidufication de la clause where de la requête et correction des tests sur les types de mouvement

1 <?php
2 /**
3 * Classe permettant la mise en forme de chaque ligne de l'export SITADEL
4 * Les méthode retourne des morceaux de lignes en faisant correspondre les valeurs
5 * du dossier avec les valeurs définie pour l'export SITADEL
6 *
7 * @package openfoncier
8 * @version SVN : $Id$
9 */
10
11 class sitadel {
12
13 private $dossier; // identifiant du dossier à insérer dans l'export
14 private $row; // Valeurs du dossier
15 private $val; // parametre par defaut
16 private $parametre; //parametre dossier
17 private $DEBUG=0; // 1 = valeur
18
19 /**
20 * Constructeur, initialisation de l'attribut dossier
21 *
22 * @param dossier string identifiant du dossier à traiter
23 */
24 function sitadel($dossier) {
25 $this->dossier=$dossier;
26 }// fin constructeur
27
28 /**
29 * Mutateur pour le tableau de données du dossier
30 *
31 * @param $row Le tableau de données du dossier
32 * @return void
33 * */
34 public function setRow($row){
35 $this->row = $row;
36 }
37
38 /**
39 * Mutateur pour le paramètre par défaut
40 *
41 * @param $val Le paramètre par défaut
42 * @return void
43 * */
44 public function setVal($val){
45 $this->val = $val;
46 }
47
48 /**
49 * Permet de mettre en forme le début de chaque la ligne
50 *
51 * @param mouvement string DEPOT, DECISION, SUIVI, TRANSFERT, MODIFICATIF, SUPPRESSION
52 * @param departement string non utilisé
53 * @param commune string code commune du dossier
54 * @param pf_departement string code du département du dossier
55 *
56 * @return string entete de la ligne
57 */
58 function entete($mouvement, $departement, $commune,$pf_departement){
59 // sitadel : mouv|typpermis|equivalence|dep|commune|andepnumpc|indmod
60 // l'equivalence n'est pas utilisée
61 $entete=$mouvement."|".$this->row['code']."|Vm|".$pf_departement.$departement."|".$commune."|".substr($this->dossier,8,2).
62 "|".substr($this->dossier,10,5)."|".$this->row['version']."|";
63 return $entete;
64 }
65
66 /**
67 * Permet de mettre en forme l'état civil :
68 * personne morale / physique
69 * société, siret, civilité, nom, prénom / civilité, nom, prénom
70 *
71 * @return string demandeur désigné
72 */
73 function etatcivil(){
74 // etat civil demandeur
75 // codemo|
76 if ($this->row['qualite'] == "particulier") {
77 $codemo=1;// personne physique
78 } else {
79 $codemo=2;// personne morale
80 }
81 $etatcivil=$codemo."|"; // 1 personne physique ; 2 sinon
82 // openfoncier civilite (5/8 ok), nom (80/30-> substr), societe (80/50->substr)
83 // civpart|prenompart|nompart|denopm|rspm|siret|catjur|civrep|prenomrep|nomrep|
84 // suivant codemo = 1 (personne physique) ou 2 (personne morale)
85 // demandeur_civilite n est pas normalise Madame ou Monsieur
86 if ($codemo == 1) {
87 // *civpart*|*prenompart*|nompart||||||
88 $etatcivil.= $this->maj(substr($this->row['civilite_pp'],0,8))."|";
89 $etatcivil.= $this->maj(substr($this->row['pp_particulier_prenom'],0,30))."|";
90
91 $etatcivil.= $this->maj(substr($this->row['pp_particulier_nom'],0,30))."|Vm|Vm|Vm|Vm|Vm|Vm|Vm|";
92 } else {
93 //denopm|*rspm*|*siret*|*catjur*|*civrep*|*prenomrep*|nomrep|
94 $etatcivil.="Vm|Vm|Vm|"; // codemo=1
95 $etatcivil.=$this->maj(substr($this->row['pp_personne_morale_denomination'],0,50))."|";
96 $etatcivil.=$this->maj(substr($this->row['pp_personne_morale_raison_sociale'],0,30))."|";
97 $etatcivil.=$this->maj(substr($this->row['pp_personne_morale_siret'],0,14))."|";
98 $etatcivil.=$this->maj(substr($this->row['pp_personne_morale_categorie_juridique'],0,4))."|";
99 $etatcivil.=$this->maj(substr($this->row['civilite_pm_libelle'],0,8))."|";
100 $etatcivil.=$this->maj(substr($this->row['pp_personne_morale_prenom'],0,30))."|";
101 $etatcivil.=$this->maj(substr($this->row['pp_personne_morale_nom'],0,30))."|";
102 }
103 return $etatcivil;
104 }
105
106 function adresse(){
107 // openfoncier : adresse (80/ 26+38 -> substr sur 2 zones) - cp (5/5 OK) - ville (30/36 -> OK)
108 // *numvoiemo*|*typvoiemo*|libvoiemo|lieuditmo(+)|communemo|codposmo|*bpmo*|*cedexmo*|*paysmo*|*divetermo|
109 $adresse="";
110 $adresse.= $this->maj(substr($this->row['pp_numero'],0,5))."|";
111 $adresse.= $this->maj(substr("",0,5))."|";
112 $adresse.= $this->maj(substr($this->row['pp_voie'],0,26))."|";
113 $adresse.= $this->maj(substr($this->row['pp_lieu_dit'],0,38))."|";
114 $adresse.= $this->maj(substr($this->row['pp_localite'],0,32))."|";
115 $adresse.= $this->maj(substr($this->row['pp_code_postal'],0,5))."|";
116 $adresse.= $this->maj(substr($this->row['pp_bp'],0,5))."|";
117 $adresse.= $this->maj(substr($this->row['pp_cedex'],0,5))."|";
118 $adresse.= $this->maj(substr($this->row['pp_pays'],0,3))."|";
119 $adresse.= $this->maj(substr($this->row['pp_division_territoriale'],0,38))."|";
120
121 return $adresse;
122 }
123
124
125 function delegataire(){
126 // openFoncier civilite (non normalise monsieur/madame), nom (80/30 substr)
127 // openfoncier : adresse (80/ 26+38 -> substr sur 2 zones) - cp (5/5 OK) - ville (30/32 -> OK)
128 // *civtiers*|*prenomtier*|nomtier|*numvoietiers*|*typvoietiers*|
129 // libvoietiers|lieudittier|communetier|codpostier
130 // |*bptier*|*cedextier*|*paystier*|*divtertier*|
131 $delegataire="";
132 $delegataire.= $this->maj(substr($this->row['civilite_delegataire_libelle'],0,8))."|";
133 $delegataire.= $this->maj(substr($this->row['delegataire_particulier_prenom'],0,30))."|";
134 $delegataire.= $this->maj(substr($this->row['delegataire_particulier_nom'],0,30))."|";
135 $delegataire.= $this->maj(substr($this->row['delegataire_numero'],0,5))."|";
136 $delegataire.= $this->maj(substr("",0,5))."|";
137 $delegataire.= $this->maj(substr($this->row['delegataire_voie'],0,26))."|";
138 $delegataire.= $this->maj(substr($this->row['delegataire_lieu_dit'],0,38))."|";
139 $delegataire.= $this->maj(substr($this->row['delegataire_localite'],0,32))."|";
140 $delegataire.= $this->maj(substr($this->row['delegataire_code_postal'],0,5))."|";
141 $delegataire.= $this->maj(substr($this->row['delegataire_bp'],0,5))."|";
142 $delegataire.= $this->maj(substr($this->row['delegataire_cedex'],0,5))."|";
143 $delegataire.= $this->maj(substr($this->row['delegataire_pays'],0,3))."|";
144 $delegataire.= $this->maj(substr($this->row['delegataire_division_territoriale'],0,38))."|";
145 return $delegataire;
146 }
147
148 function meltel($mouvement){
149 // openfoncier telephone_fixe (14/20), courriel(40, 50) pas de suivi
150 // sitadel : telmo|melmo|suivi
151 $meltel="";
152 if($mouvement != "TRANSFERT")
153 $meltel.=$this->maj($this->row['pp_telephone_fixe'])."|";
154 $meltel.= $this->maj($this->row['pp_courriel'])."|";
155 // suivi electronique
156 // Il n'y a pas de notification par mail gérée dans l'appli
157 $meltel.= "0";
158
159 // suivi -> fin enr pour transfert (sans |)
160 if($mouvement != "TRANSFERT")
161 $meltel.= "|";
162 return $meltel;
163 }
164
165 function adresse_terrain(){
166 // openfoncier numero (4/5 substr), adresse(80, 26 +38 -> substr), complement (non utilise (80)), cp (5/5 ok), ville (30/32 ok)
167 // sitadel : |numvoiete|*typvoiete*|libvoiete|lieudite|communete|codposte|*bpte*|*cedexte*|
168 // mettre le | en debut pour info du 2eme groupe (suite 1er groupe)
169 $adresse="";
170 $adresse.= $this->maj(substr($this->row['dossier_terrain_adresse_voie_numero'],0,5))."|";
171 $adresse.= $this->maj(substr("",0,5))."|";
172 $adresse.= $this->maj(substr($this->row['dossier_complement'],0,26))."|";
173 $adresse.= $this->maj(substr($this->row['dossier_terrain_adresse_lieu_dit'],0,38))."|";
174 $adresse.= $this->maj(substr($this->row['dossier_terrain_adresse_localite'],0,32))."|";
175 $adresse.= $this->maj(substr($this->row['dossier_terrain_adresse_code_postal'],0,5))."|";
176 $adresse.= $this->maj(substr($this->row['dossier_terrain_adresse_bp'],0,5))."|";
177 $adresse.= $this->maj(substr($this->row['dossier_terrain_adresse_cedex'],0,5))."|";
178
179 return $adresse;
180 }
181
182 /**
183 * Formalise la parcelle à partir de la référence cadastrale
184 *
185 * @return string la chaine formatée
186 */
187 function parcelle(){
188 // ========
189 // parcelle
190 // ========
191 // cadastre 3 parcelles + 3 sections
192 // openfoncier = 1 seule parcelle (6/3+5)
193 // sitadel : scadastre1|ncadastre1|*scadastre2*|*ncadastre2*|*scadastre3*|*ncadastre3*|
194 $parcelle = "";
195 if ($this->row['dossier_terrain_references_cadastrales'] != "" ) {
196 $tab_parcelles = $this->parseParcelles($this->row['dossier_terrain_references_cadastrales']);
197
198 $parcelle .= ( isset($tab_parcelles[0]) && count($tab_parcelles[0]) == 3 )
199 ? $this->maj(substr($tab_parcelles[0]['section'],0,3))."|".
200 $this->maj(substr($tab_parcelles[0]['parcelle'],0,5))."|"
201 : "Vm|Vm|";
202 $parcelle .= ( isset($tab_parcelles[1]) && count($tab_parcelles[1]) == 3 )
203 ? $this->maj(substr($tab_parcelles[1]['section'],0,3))."|".
204 $this->maj(substr($tab_parcelles[1]['parcelle'],0,5))."|"
205 : "Vm|Vm|";
206 $parcelle .= ( isset($tab_parcelles[2]) && count($tab_parcelles[2]) == 3 )
207 ? $this->maj(substr($tab_parcelles[2]['section'],0,3))."|".
208 $this->maj(substr($tab_parcelles[2]['parcelle'],0,5))."|"
209 : "Vm|Vm|";
210 } else {
211 $parcelle= "Vm|Vm|Vm|Vm|Vm|Vm|";
212 }
213
214 return $parcelle;
215 }
216
217 /**
218 * Permet de calculer la liste des parcelles à partir de la chaîne passée en paramètre
219 * et la retourner sous forme d'un tableau associatif
220 * @param string $strParcelles chaîne de la parcelles
221 * @return array (array(quartier, section, parcelle), ...)
222 */
223 function parseParcelles($strParcelles) {
224
225 // Séparation des lignes
226 $references = explode(";", $strParcelles);
227 $liste_parcelles = array();
228
229 // On boucle sur chaque ligne pour ajouter la liste des parcelles de chaque ligne
230 foreach ($references as $parcelles) {
231
232 // On transforme la chaîne de la ligne de parcelles en tableau
233 $ref = str_split($parcelles);
234 // Les 1er caractères sont numériques
235 $num = true;
236
237 // Tableau des champs de la ligne de références cadastrales
238 $reference_tab = array();
239 $temp = "";
240 foreach ($ref as $carac) {
241
242 // Permet de tester si le caractère courant est de même type que le précédent
243 if(is_numeric($carac) === $num) {
244 $temp .= $carac;
245 } else {
246 // Bascule
247 $num = !$num;
248 // On stock le champ
249 $reference_tab[] = $temp;
250 // re-init de la valeur temporaire pour le champ suivant
251 $temp = $carac;
252 }
253 }
254 // Stockage du dernier champ sur lequel il n'y a pas eu de bascule
255 $reference_tab[] = $temp;
256 // Calcul des parcelles
257 $quartier = $reference_tab[0];
258 $sect = $reference_tab[1];
259
260 $ancien_ref_parc = "";
261 for ($i=2; $i < count($reference_tab); $i+=2) {
262 $parc["quartier"] = $quartier;
263 $parc["section"] = $sect;
264 if( $ancien_ref_parc == "" OR $reference_tab[$i-1] == "/") {
265 // 1ere parcelle ou parcelle individuelle
266 $parc["parcelle"] = $reference_tab[$i];
267 // Ajout d'une parcelle à la liste
268 $liste_parcelles[] = $parc;
269 } elseif ($reference_tab[$i-1] == "A") {
270 // Interval de parcelles
271 for ($j=$ancien_ref_parc+1; $j <= $reference_tab[$i]; $j++) {
272 $parc["parcelle"] = $j;
273 // Ajout d'une parcelle à la liste
274 $liste_parcelles[] = $parc;
275 }
276 }
277 //Gestion des erreurs
278 else{
279
280 echo _("Une erreur de formattage a ete detecte dans la reference cadastrale du dossier ").$this->row['dossier'];
281 }
282 // Sauvegarde de la référence courante de parcelle
283 $ancien_ref_parc = $reference_tab[$i];
284 }
285 }
286
287 return $liste_parcelles;
288 }
289
290 /**
291 * Données pour le groupe 1 du mouvement décision
292 *
293 * @return string la chaine de données du groupe 1
294 */
295 function decision_groupe1(){
296 // openfoncier autorite_competente (integer/1), sitadel(integer, 1)
297 // date_limite (date, 8)| date_notification_delai (date, 8),
298 // sitadel_motif (integer, 1)
299 // sitadel : collectivite|natdec|datredec|motifann
300
301 $decision = $this->maj(substr($this->row['autorite_competente'],0,1))."|";
302 $decision.= $this->maj(substr($this->row['sitadel'],0,1))."|";
303
304 $datredec = "";
305 //Choix de la date
306 if ( $this->row['sitadel'] == 1 || $this->row['sitadel'] == 2 || $this->row['sitadel'] == 3 ){
307
308 $datredec = $this->row['date_limite'];
309 }
310 elseif( $this->row['sitadel'] != "" ){
311
312 $datredec = $this->row['date_notification_delai'];
313 }
314 // date au format francais 8 caracteres
315 $decision.= $this->maj(substr($datredec,8,2).''.
316 substr($datredec,5,2)."".
317 substr($datredec,0,4))."|";
318
319 $decision.= $this->maj(substr($this->row['sitadel_motif'],0,1));
320 $decision.= ($this->row['sitadel'] == 2 ||
321 $this->row['sitadel'] == 4 ||
322 $this->row['sitadel'] == 5) ? "|" : "";
323
324 return $decision;
325 }
326
327 /**
328 * Données pour le groupe 2 du mouvement décision concernant les aménagements et
329 * le terrain
330 *
331 * @return string la chaine de données du groupe 2
332 */
333 function amenagement_terrain(){
334 // openfoncier am_terr_surf (numeric/7) am_lotiss (bool/1) terr_juri_afu (20/1)
335 // co_cstr_nouv (20/1) co_cstr_exist (text/1000) co_modif_aspect (bool/1)
336 // co_modif_struct (bool/1) co_cloture (bool/1) co_trx_exten (bool/1)
337 // co_trx_surelev (bool/1) co_trx_nivsup (bool/1) co_trx_amgt (bool/1)
338 // co_anx_pisc (bool/1) co_anx_gara (bool/1) co_anx_veran (bool/1)
339 // co_anx_abri (bool/1) co_anx_autr (bool/1) co_bat_niv_nb (integer/3)
340 // sitadel : terrain|lotissement|ZAC|AFU|libnattrav|natproj|natdp|nattrav|
341 // annexe|nivmax
342 $amenagement_terrain="";
343
344 //Terrain
345 $amenagement_terrain .= ((isset($this->row['am_terr_surf'])) ? $this->maj(substr(floor($this->row['am_terr_surf']),0,7)) : 0)."|";
346
347 //Lotissement
348 $amenagement_terrain .= ((isset($this->row['am_lotiss']) && $this->maj($this->row['am_lotiss']) == 't') ? 1 : 0)."|";
349 //ZAC
350 $amenagement_terrain .= ((isset($this->row['terr_juri_zac']) && $this->maj($this->row['terr_juri_zac']) != '') ? 1 : 0)."|";
351 //AFU
352 $amenagement_terrain .= ((isset($this->row['terr_juri_afu']) && $this->maj($this->row['terr_juri_afu']) != '') ? 1 : 0)."|";
353 //Libnattrav
354 $amenagement_terrain .= (isset($this->row['terr_desc'])) ? $this->maj(substr($this->row['terr_desc'],0,1000))."|" : "Vm|";
355
356 // Nouvelle co,nstruction et travaux sur construction
357 //natproj
358 if ( isset($this->row['co_cstr_nouv']) && isset($this->row['co_cstr_exist']) &&
359 $this->maj($this->row['co_cstr_nouv']) == 't' &&
360 $this->maj($this->row['co_cstr_exist']) == 't' ){
361
362 $amenagement_terrain .= "3|";
363 }
364 //Nouvelle construction
365 elseif ( isset($this->row['co_cstr_nouv']) && $this->maj($this->row['co_cstr_nouv']) == 't' ) {
366
367 $amenagement_terrain .= "1|";
368 }
369 //Travaux sur construction existante
370 elseif ( isset($this->row['co_cstr_exist']) && $this->maj($this->row['co_cstr_exist']) == 't' ) {
371
372 $amenagement_terrain .= "2|";
373 }
374 //Sinon
375 else{
376
377 $amenagement_terrain .= "Vm|";
378 }
379
380 //Nature du projet dans le cas d'un DP
381 //natdp
382 if ( $this->row['code'] == "DP" ){
383
384 $amenagement_terrain .= ((isset($this->row['co_cstr_nouv']) && $this->maj($this->row['co_cstr_nouv']) == 't') ? 1 : 0);
385 $amenagement_terrain .= ((isset($this->row['co_cstr_exist']) && $this->maj($this->row['co_cstr_exist']) == 't') ? 1 : 0);
386 $amenagement_terrain .= ((isset($this->row['co_modif_aspect']) && $this->maj($this->row['co_modif_aspect']) == 't') ? 1 : 0);
387 $amenagement_terrain .= ((isset($this->row['co_modif_struct']) && $this->maj($this->row['co_modif_struct']) == 't') ? 1 : 0);
388 $amenagement_terrain .= ((isset($this->row['co_cloture']) && $this->maj($this->row['co_cloture']) == 't') ? 1 : 0)."|";
389 }
390 else {
391
392 $amenagement_terrain .= "Vm|";
393 }
394
395 //Nature des travaux sur construction existante
396 //nattrav
397 $amenagement_terrain .= ((isset($this->row['co_trx_exten']) && $this->maj($this->row['co_trx_exten']) == 't') ? 1 : 0);
398 $amenagement_terrain .= ((isset($this->row['co_trx_surelev']) && $this->maj($this->row['co_trx_surelev']) == 't') ? 1 : 0);
399 $amenagement_terrain .= ((isset($this->row['co_trx_niv_sup']) && $this->maj($this->row['co_trx_niv_sup']) == 't') ? 1 : 0);
400 $amenagement_terrain .= ((isset($this->row['co_trx_amgt']) && $this->maj($this->row['co_trx_amgt']) == 't') ? 1 : 0)."|";
401
402 //Annexe
403 $amenagement_terrain .= ((isset($this->row['co_anx_pisc']) && $this->maj($this->row['co_anx_pisc']) == 't') ? 1 : 0);
404 $amenagement_terrain .= ((isset($this->row['co_anx_gara']) && $this->maj($this->row['co_anx_gara']) == 't') ? 1 : 0);
405 $amenagement_terrain .= ((isset($this->row['co_anxveran']) && $this->maj($this->row['co_anxveran']) == 't') ? 1 : 0);
406 $amenagement_terrain .= ((isset($this->row['co_anx_abri']) && $this->maj($this->row['co_anx_abri']) == 't') ? 1 : 0);
407 $amenagement_terrain .= ((isset($this->row['co_anx_autr']) && $this->maj($this->row['co_anx_autr']) == 't') ? 1 : 0)."|";
408
409 //nivmax
410 $amenagement_terrain .= isset($this->row['co_bat_niv_nb']) && $this->maj(substr($this->row['co_bat_niv_nb'],0,3))."|";
411
412 return $amenagement_terrain;
413 }
414
415 /**
416 * Données pour le groupe 2 du mouvement décision concernant les SHON
417 *
418 * @return string la chaine de données du groupe 2
419 */
420 function shon($nom){
421 // openfoncier (numeric/7)
422
423 $shon = "";
424
425 $shon .= ((isset($this->row[$nom.'1'])) ? $this->maj(substr(floor($this->row[$nom.'1']),0,7)) : 0)."|";
426 $shon .= ((isset($this->row[$nom.'2'])) ? $this->maj(substr(floor($this->row[$nom.'2']),0,7)) : 0)."|";
427 $shon .= ((isset($this->row[$nom.'3'])) ? $this->maj(substr(floor($this->row[$nom.'3']),0,7)) : 0)."|";
428 $shon .= ((isset($this->row[$nom.'4'])) ? $this->maj(substr(floor($this->row[$nom.'4']),0,7)) : 0)."|";
429 $shon .= ((isset($this->row[$nom.'5'])) ? $this->maj(substr(floor($this->row[$nom.'5']),0,7)) : 0)."|";
430 $shon .= ((isset($this->row[$nom.'6'])) ? $this->maj(substr(floor($this->row[$nom.'6']),0,7)) : 0)."|";
431 $shon .= ((isset($this->row[$nom.'7'])) ? $this->maj(substr(floor($this->row[$nom.'7']),0,7)) : 0)."|";
432 $shon .= ((isset($this->row[$nom.'8'])) ? $this->maj(substr(floor($this->row[$nom.'8']),0,7)) : 0)."|";
433 $shon .= ((isset($this->row[$nom.'9'])) ? $this->maj(substr(floor($this->row[$nom.'9']),0,7)) : 0)."|";
434
435 return $shon;
436 }
437
438 function travaux($travaux, $lascot,$mouvement){
439 // libnattrav| ou libmotif dans MODIFICATIF
440 $contenu=$this->maj($travaux)."|";
441 // natproj| innexistant en MODIFICATIF
442 if($mouvement != "MODIFICATIF"){
443 if($lascot=='1'
444 or $lascot=='2'
445 or $lascot=='3')
446 $contenu.= $lascot."|"; // natproj 1:construction 2:extension ou 3:surelevation
447 else
448 $contenu.= "|";
449 }
450 // INITIAL (ou TRANSFERT)natdp|nattrav|*annexe*|*nivmax*
451 // MODIFICATIF nattrav|*annexe*|*nivmax*
452 if($mouvement != "MODIFICATIF"){
453 $natdp='00000';
454 if($lascot=='1') $natdp="10000"; // nouvelle construction
455 if($lascot=='2') $natdp="01000"; // travaux sur construction existante
456 if($lascot=='3') $natdp="01000"; //
457 if($lascot=='X') $natdp="00001"; // cloture
458 $contenu.= $natdp."|";
459 }
460 // nattrav
461 $nattrav = "0000";
462 if($lascot=='2') $nattrav="1000";
463 if($lascot=='3') $nattrav="0100";
464 $contenu.= $nattrav."|";
465 // annexe non renseigner defaut 00000
466 $contenu.= $this->p('annexe')."|";
467 //nivmax non saisi
468 $contenu.=$this->p('nivmax')."|";
469 return $contenu;
470 }
471
472 /**
473 * Données pour le groupe 2 du mouvement décision concernant les destinations
474 *
475 * @return string la chaine de données du groupe 2
476 */
477 function destination(){
478
479 $destination = "";
480
481 $destination .= ((isset($this->row['co_sp_transport']) && $this->row['co_sp_transport'] == 't') ? 1 : 0);
482 $destination .= ((isset($this->row['co_sp_enseign']) && $this->row['co_sp_enseign'] == 't') ? 1 : 0);
483 $destination .= ((isset($this->row['co_sp_sante']) && $this->row['co_sp_sante'] == 't') ? 1 : 0);
484 $destination .= ((isset($this->row['co_sp_act_soc']) && $this->row['co_sp_act_soc'] == 't') ? 1 : 0);
485 $destination .= ((isset($this->row['co_sp_ouvr_spe']) && $this->row['co_sp_ouvr_spe'] == 't') ? 1 : 0);
486 $destination .= ((isset($this->row['co_sp_culture']) && $this->row['co_sp_culture'] == 't') ? 1 : 0)."|";
487
488 $destination .= ((isset($this->row['dm_tot_log_nb']) && !empty($this->row['dm_tot_log_nb'])) ? $this->row['dm_tot_log_nb'] : 0)."|";
489 $destination .= ((isset($this->row['co_tot_ind_nb']) && !empty($this->row['co_tot_ind_nb'])) ? $this->row['co_tot_ind_nb'] : 0)."|";
490 $destination .= ((isset($this->row['co_tot_coll_nb']) && !empty($this->row['co_tot_coll_nb'])) ? $this->row['co_tot_coll_nb'] : 0)."|";
491 $destination .= ((isset($this->row['co_tot_log_nb']) && !empty($this->row['co_tot_log_nb'])) ? $this->row['co_tot_log_nb'] : 0)."|";
492
493 $destination .= ((isset($this->row['co_resid_agees']) && $this->row['co_resid_agees']) ? 1 : 0);
494 $destination .= ((isset($this->row['co_resid_etud']) && $this->row['co_resid_etud']) ? 1 : 0);
495 $destination .= ((isset($this->row['co_resid_tourism']) && $this->row['co_resid_tourism']) ? 1 : 0);
496 $destination .= ((isset($this->row['co_resid_hot_soc']) && $this->row['co_resid_hot_soc']) ? 1 : 0);
497 $destination .= ((isset($this->row['co_resid_soc']) && $this->row['co_resid_soc']) ? 1 : 0);
498 $destination .= ((isset($this->row['co_resid_hand']) && $this->row['co_resid_hand']) ? 1 : 0);
499 $destination .= ((isset($this->row['co_resid_autr']) && $this->row['co_resid_autr']) ? 1 : 0)."|";
500
501 $destination .= (isset($this->row['co_resid_autr_desc']) ? $this->maj($this->row['co_resid_autr_desc']) : "")."|";
502
503 $destination .= ((isset($this->row['co_uti_pers']) && $this->row['co_uti_pers']) ? 1 : 0);
504 $destination .= ((isset($this->row['co_uti_princ']) && $this->row['co_uti_princ']) ? 1 : 0);
505 $destination .= ((isset($this->row['co_uti_secon']) && $this->row['co_uti_secon']) ? 1 : 0);
506 $destination .= ((isset($this->row['co_uti_vente']) && $this->row['co_uti_vente']) ? 1 : 0);
507 $destination .= ((isset($this->row['co_uti_loc']) && $this->row['co_uti_loc']) ? 1 : 0)."|";
508
509 $destination .= ((isset($this->row['co_foyer_chamb_nb']) && !empty($this->row['co_foyer_chamb_nb'])) ? $this->row['co_foyer_chamb_nb'] : 0)."|";
510
511 return $destination;
512 }
513
514 /**
515 * Données pour le groupe 2 du mouvement décision concernant la répartition des
516 * logements créées par type de financement
517 *
518 * @return string la chaine de données du groupe 2
519 */
520 function repartitionFinan(){
521
522 $repartitionFinan = "";
523
524 $repartitionFinan .= ((isset($this->row['co_fin_lls_nb']) && $this->row['co_fin_lls_nb']) ? $this->row['co_fin_lls_nb'] : 0)."|";
525 $repartitionFinan .= ((isset($this->row['co_fin_aa_nb']) && $this->row['co_fin_aa_nb']) ? $this->row['co_fin_aa_nb'] : 0)."|";
526 $repartitionFinan .= ((isset($this->row['co_fin_ptz_nb']) && $this->row['co_fin_ptz_nb']) ? $this->row['co_fin_ptz_nb'] : 0)."|";
527 $repartitionFinan .= ((isset($this->row['co_fin_autr_nb']) && $this->row['co_fin_autr_nb']) ? $this->row['co_fin_autr_nb'] : 0)."|";
528
529 return $repartitionFinan;
530 }
531
532 /**
533 * Données pour le groupe 2 du mouvement décision concernant la répartition des
534 * logements créées par nombre de pièces
535 *
536 * @return string la chaine de données du groupe 2
537 */
538 function repartitionNbPiece(){
539
540 $repartitionFinan = "";
541
542 $repartitionFinan .= ((isset($this->row['co_mais_piece_nb']) && $this->maj($this->row['co_mais_piece_nb']) == 't') ? 1 : 0)."|";
543 $repartitionFinan .= ((isset($this->row['co_log_1p_nb']) && $this->maj($this->row['co_log_1p_nb']) == 't') ? 1 : 0)."|";
544 $repartitionFinan .= ((isset($this->row['co_log_2p_nb']) && $this->maj($this->row['co_log_2p_nb']) == 't') ? 1 : 0)."|";
545 $repartitionFinan .= ((isset($this->row['co_log_3p_nb']) && $this->maj($this->row['co_log_3p_nb']) == 't') ? 1 : 0)."|";
546 $repartitionFinan .= ((isset($this->row['co_log_4p_nb']) && $this->maj($this->row['co_log_4p_nb']) == 't') ? 1 : 0)."|";
547 $repartitionFinan .= ((isset($this->row['co_log_5p_nb']) && $this->maj($this->row['co_log_5p_nb']) == 't') ? 1 : 0)."|";
548 $repartitionFinan .= ((isset($this->row['co_log_6p_nb']) && $this->maj($this->row['co_log_6p_nb']) == 't') ? 1 : 0);
549
550 return $repartitionFinan;
551 }
552
553 function descriptif($mouvement){
554 // cpublic : non renseignee N par defaut
555 // O/N transport/enseignement/sante/social/special/culture
556
557 $contenu= $this->p('cpublic')."|"; //* supp|
558 // nblogdem
559 if($mouvement != "MODIFICATIF"){
560 $contenu.= $this->row['logement_nombre']."|";
561 }
562 // nbmaison : nombre de maison
563 $contenu.= $this->p('nbmaison')."|";
564 // nblogcoll : nombre de logement collectif
565 $contenu.= $this->p('nblogcoll')."|";
566 // nbtotlog : nombre de logement total
567 $contenu.= $this->p('nbtotlog')."|";
568 // natres : nature des residences
569 // O/N 1=ages, 2=etudiant, 3=tourisme, 4=hotel, 5=social, 6= handicap, 7=autres
570 $contenu.= $this->p('natres')."|";
571 // libres= si autre residence (long max 1000 c)
572 $contenu.= $this->p('libres')."|";
573 // util : O/N personnel, principale, secondaire, vente, location
574 $contenu.= $this->p('util')."|";
575 //chambre
576 $contenu.= $this->p('chambre')."|";
577 // nb logement sociaux
578 $contenu.= $this->p('finis')."|";
579 // nb logt financt aides
580 $contenu.= $this->p('finaa')."|";
581 // nb de logt pret a taux 0
582 $contenu.= $this->p('finptz')."|";
583 // nb de logt finances autrt
584 $contenu.= $this->p('finaf')."|";
585 // nb pieces en maison individuelle
586 if($mouvement != "MODIFICATIF")
587 $contenu.= $this->row['piece_nombre']."|"; // voir si 0
588 // chambre (num capacite accueil locaux hebergement)
589 // $contenu.= "|";
590 // nb de logement 1piece
591 $contenu.= $this->p('piec1')."|";
592 // nb de logement 2 pieces
593 $contenu.= $this->p('piec2')."|";
594 // nb de logement 3 pieces
595 $contenu.= $this->p('piec3')."|";
596 // nb de logement 4 pieces
597 $contenu.= $this->p('piec4')."|";
598 // nb de logement 5 pieces
599 $contenu.= $this->p('piec5')."|";
600 // nb de logement 6 pieces
601 $contenu.= $this->p('piec6');
602 // (derniere zone decision et modificatif)
603 return $contenu;
604 }
605
606 /**
607 * Permet de mettre en forme les données du mouvement suivi pour une ouverture de chantier
608 * @return string chaîne en forme
609 */
610 function chantier(){
611
612 $chantier="";
613
614 if(isset($this->row['doc_date'])) {
615 $chantier .= substr($this->row['doc_date'],8,2).substr($this->row['doc_date'],5,2).
616 substr($this->row['doc_date'],0,4)."|"; // *** au format francais
617 } else {
618 $chantier .= "|";
619 }
620 $chantier .= ((isset($this->row['doc_nb_log']) AND $this->row['doc_nb_log'] != "" ) ? $this->row['doc_nb_log'] : "vm")."|";
621 $chantier .= ((isset($this->row['doc_nb_log_indiv']) AND $this->row['doc_nb_log_indiv'] != "" ) ? $this->row['doc_nb_log_indiv'] : "vm")."|";
622 $chantier .= ((isset($this->row['doc_nb_log_coll']) AND $this->row['doc_nb_log_coll'] != "" ) ? $this->row['doc_nb_log_coll'] : "vm")."|";
623 $chantier .= ((isset($this->row['doc_surf']) AND $this->row['doc_surf'] != "" ) ? substr(floor($this->row['doc_surf']),0,7) : "vm")."|";
624 $chantier .= ((isset($this->row['doc_nb_log_lls']) AND $this->row['doc_nb_log_lls'] != "" ) ? $this->row['doc_nb_log_lls'] : "vm")."|";
625 $chantier .= ((isset($this->row['doc_nb_log_aa']) AND $this->row['doc_nb_log_aa'] != "" ) ? $this->row['doc_nb_log_aa'] : "vm")."|";
626 $chantier .= ((isset($this->row['doc_nb_log_ptz']) AND $this->row['doc_nb_log_ptz'] != "" ) ? $this->row['doc_nb_log_ptz'] : "vm")."|";
627 $chantier .= ((isset($this->row['doc_nb_log_autre']) AND $this->row['doc_nb_log_autre'] != "" ) ? $this->row['doc_nb_log_autre'] : "vm")."|";
628 // indice de la tranche commencée
629 $chantier .= "vm|";
630
631 $chantier.="|||||||||||"; // achevement 11|
632 return $chantier;
633 }
634
635 function achevement(){
636 $achevement="||||||||||"; // chantier 10 |
637 if(isset($this->row['daact_date'])) {
638 $achevement .= substr($this->row['daact_date'],8,2).substr($this->row['daact_date'],5,2).
639 substr($this->row['daact_date'],0,4)."|"; // *** au format francais
640 } else {
641 $achevement .= "|";
642 }
643 $achevement .= ((isset($this->row['daact_nb_log']) AND $this->row['daact_nb_log'] != "" ) ? $this->row['daact_nb_log'] : "vm")."|";
644 $achevement .= ((isset($this->row['daact_nb_log_indiv']) AND $this->row['daact_nb_log_indiv'] != "" ) ? $this->row['daact_nb_log_indiv'] : "vm")."|";
645 $achevement .= ((isset($this->row['daact_nb_log_coll']) AND $this->row['daact_nb_log_coll'] != "" ) ? $this->row['daact_nb_log_coll'] : "vm")."|";
646 $achevement .= ((isset($this->row['daact_surf']) AND $this->row['daact_surf'] != "" ) ? substr(floor($this->row['daact_surf']),0,7) : "vm")."|";
647 $achevement .= ((isset($this->row['daact_nb_log_lls']) AND $this->row['daact_nb_log_lls'] != "" ) ? $this->row['daact_nb_log_lls'] : "vm")."|";
648 $achevement .= ((isset($this->row['daact_nb_log_aa']) AND $this->row['daact_nb_log_aa'] != "" ) ? $this->row['daact_nb_log_aa'] : "vm")."|";
649 $achevement .= ((isset($this->row['daact_nb_log_ptz']) AND $this->row['daact_nb_log_ptz'] != "" ) ? $this->row['daact_nb_log_ptz'] : "vm")."|";
650 $achevement .= ((isset($this->row['daact_nb_log_autre']) AND $this->row['daact_nb_log_autre'] != "" ) ? $this->row['daact_nb_log_autre'] : "vm")."|";
651 // indice de la tranche complétée
652 $achevement .= "vm|";
653 // Finchantier 1 si etat=cloturer sinon 0
654 if ($this->row['statut_di']=="cloture"){
655 $achevement.="1|";
656 }else{
657 $achevement.="0|";
658 }
659 // indique la provenance de l'info d'achèvement des travaux (déclaration/DGI)
660 $achevement .= "vm|";
661 return $achevement;
662 }
663
664 function p($champ){
665 if($this->DEBUG==2) return $champ;
666 if(isset($this->parametre[$champ])){
667 return $this->parametre[$champ];
668 }else
669 return $this->val[$champ];
670 }
671
672 /**
673 * Normalise la chaine de caractère ou renvoit "valeur manquant".
674 *
675 * @param $val La valeur du champ
676 * @return string la chaine formatée ou "vm"
677 */
678 function maj($val) {
679 $val = strtoupper($val);
680 $val=str_replace(chr(195), "", $val); // supprime le premier code des accents en UTF-8
681 $s = array('/[âàäÀ]/', '/[éêèëÉÈ]/', '/[îï]/', '/[ôöÔ]/', '/[ûùü]/', '/[çÇ]/', '/\'|\"|^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\-\s\r/');
682 $r = array('A', 'E', 'I', 'O', 'U', 'C', ' ');
683 $val = preg_replace($s , $r, $val);
684 // Formatage des valeurs manquantes
685 return $this->testVM($val);
686 }
687
688 /**
689 * Permet de tester si la valeur est manquante et retourner Vm
690 * sinon retourne le champ
691 *
692 * @param string $champ champ à tester
693 * @return string valeur à insérer dans l'export
694 */
695 function testVM($champ) {
696 if ( $champ == "" ) {
697 return "vm";
698 } else {
699 return $champ;
700 }
701 }
702 }
703
704 ?>

Properties

Name Value
svn:keywords Id

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26