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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3197 - (hide annotations)
Fri Dec 5 17:24:53 2014 UTC (10 years, 1 month ago) by vpihour
File size: 35031 byte(s)
* Amélioration - Si une commune est divisée en arrondissement, ce n'est pas le 
  code INSEE de la commune qu'il faut mettre en entête mais, le code impôt de 
  l'arrondissement du dossier d'autorisation.
* Amélioration - Si on essayait de générer un export SITADEL et qu'une erreur 
  étaient détectée dans les données, seul un fichier d'erreur était généré. 
  Dorénavant, la gestion des erreurs est moins restrive. Deux fichiers sont 
  générés en cas d'erreur : le fichier d'export et le fichier d'erreurs.
* Bug - Si on essayait de générer un export SITADEL contenant des mouvements
  modificatif, une erreur se produisait. C'est corrigé.

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

Properties

Name Value
svn:keywords Id

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26