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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3587 - (hide annotations)
Tue Jul 21 14:56:38 2015 UTC (9 years, 6 months ago) by nmeucci
File size: 37215 byte(s)
Correction de la permission nécessaire à l'affichage du menu gestion des commissions.
Amélioration de la recherche de pétitionnaire fréquent.
Amélioration de la construction de l'URL utilisée dans le script de mise à jour des DA.
Correction du traitement de la mise à jour des consultations via le web service.
Ajout/correction de commentaires.

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

Properties

Name Value
svn:keywords Id

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26