/[openfoncier]/trunk/app/export_pc.php
ViewVC logotype

Contents of /trunk/app/export_pc.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1184 - (show annotations)
Wed Jan 9 09:34:50 2013 UTC (12 years ago) by fmichon
File size: 9084 byte(s)
svn propset svn:keywords "Id" app/*.php

1 <?php
2 // $Id$
3 /*
4 transfert de dossier � la DGI Cadstre
5 */
6 require_once "../obj/utils.class.php";
7 $f = new utils(NULL, "export_pc", _("export PC"), "ico_export.png", "export");
8 $f->addHTMLHeadJs(array("../js/script.js"));
9 // GET ========================================================================
10 if (isset ($_GET['validation'])){
11 $validation=$_GET['validation'];
12 }else{
13 $validation=0;
14 }
15 if (isset ($_GET['idx'])){
16 $idx=$_GET['idx'];
17 }else{
18 $idx=0;
19 }
20 /**
21 * Description de la page
22 */
23 $description = _("Cette page vous permet de Transmettre les PC au cadastre DGI (procedure LASCOT.");
24 $f->displayDescription($description);
25 // =============================================================================
26 // validation = 0
27 // =============================================================================
28 if($validation==0){
29 $validation=1;
30 echo "<form method=\"POST\" action=\"export_pc.php?validation=".$validation."\" name=f1>";
31 echo " "._("DATE DEBUT DEPOT")." ";
32 echo "<input type='text' name='datedebut' id=\"datedebut\" value=\"";
33 echo "\" size=\"15\" class=\"champFormulaire datepicker\" onchange='fdate(this)' onkeyup=\"\" onclick=\"\" />";
34 echo " "._("DATE FIN DEPOT")." ";
35 echo "<input type='text' name='datefin' id=\"datefin\" value=\"";
36 echo "\" size=\"15\" class=\"champFormulaire datepicker\" onchange='fdate(this)' onkeyup=\"\" onclick=\"\" />";
37 echo " avis ";
38 echo "<select name='avis_decision' class='champFormulaire' >";
39 $sql = "SELECT distinct(typeavis) from ".DB_PREFIXE."avis_decision where typeavis <> ''";
40 $res = $f->db->query($sql);
41 $f->isDatabaseError($res);
42 echo "<option value='S'>Sans</option>";
43 echo "<option value='T'>Tous</option>";
44 while ($row=& $res->fetchRow()){
45 echo "<option value='".$row[0]."'>".$row[0]."</option>";
46 }
47 echo "</select>";
48 echo "<br><br><input type='submit' value='export PC' >";
49 echo "<br><br></form>";
50 }else { // ===================== extraction =================================
51 $correct=true;
52 if($_POST["datedebut"]=="") $correct=false;
53 if($_POST["datefin"]=="") $correct=false;
54 if (isset ($_POST['typeavis'])){ // ***
55 $typeavis=$_POST['typeavis'];
56 }else{
57 $typeavis="";
58 } // *
59 if ($correct==true){
60 $departement =$f->collectivite["departement"];
61 $commune =$f->collectivite["commune"];
62 $sql= "select date_depot,annee, dossier.dossier, demandeur_civilite,
63 demandeur_nom,demandeur_societe,demandeur_adresse,demandeur_ville,demandeur_cp,
64 parcelle, terrain_numero,terrain_numero_complement,
65 terrain_adresse,terrain_adresse_complement, terrain_ville,
66 shon,logement_nombre,codelascot
67 from ".DB_PREFIXE."dossier
68 INNER JOIN ".DB_PREFIXE."dossier_autorisation
69 ON dossier_autorisation.dossier_autorisation=dossier.dossier_autorisation
70 left join ".DB_PREFIXE."travaux on dossier.travaux=travaux.travaux";
71 if($typeavis!="" or $typeavis=='T'){ // ***
72 $sql.=" left join ".DB_PREFIXE."avis_decision on avis_decision.avis_decision = dossier.avis_decision";
73 } //*
74 $sql.= " where (dossier_autorisation.dossier_autorisation_type_detaille = 1
75 OR dossier_autorisation.dossier_autorisation_type_detaille = 2)";
76 if($typeavis!="" or $typeavis=='T'){ // ***
77 $sql.=" AND typeavis ='".$typeavis."'";
78 }//*
79 $sql.= " AND date_depot>='".substr($_POST["datedebut"],6,4).
80 "-".substr($_POST["datedebut"],3,2)."-".
81 substr($_POST["datedebut"],0,2)."'";
82 $sql.= " AND date_depot<='".substr($_POST["datefin"],6,4).
83 "-".substr($_POST["datefin"],3,2)."-".
84 substr($_POST["datefin"],0,2)."'";
85 $res = $f->db -> query ($sql);
86 $f->isDatabaseError($res);
87 $export="";
88 $bl="";
89 while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
90 $export.= $departement;
91 $export.= $commune;
92 $export.= $row['annee'];
93 $export.=substr($row['dossier'],4,5);// numero dossier 5
94 // modificatif sur 2 caracteres et non sur 1
95 $export.=str_pad(substr($row['dossier'],10,1),1," ", STR_PAD_RIGHT);// modificatif 9,2
96 // dossier precedent ? annee numero modificatif
97 $export.=" "." "." "; // 2-5-1
98 // maitre ouvrage
99 $export.= str_pad(substr($row['demandeur_civilite'],0,5),5," ", STR_PAD_RIGHT); //nom du maitre d ouvrage
100 $export.= str_pad(substr($row['demandeur_nom'],0,27),27," ", STR_PAD_RIGHT); //nom du maitre d ouvrage
101 $export.= str_pad(substr($row['demandeur_societe'],0,32),32," ", STR_PAD_RIGHT); //1ere ligne
102 $export.= str_pad(substr($row['demandeur_adresse'],0,32),32," ", STR_PAD_RIGHT); // adresse
103 $export.= str_pad($bl,32," ", STR_PAD_RIGHT); //2eme ligne
104 $export.= str_pad($bl,32," ", STR_PAD_RIGHT); //3eme Ligne
105 $export.= str_pad($row['demandeur_cp'],5," ", STR_PAD_RIGHT);
106 $export.= str_pad(substr($row['demandeur_ville'],0,26),26," ", STR_PAD_RIGHT);
107 $export.= str_pad ($bl, 20, " ", STR_PAD_RIGHT); // telephone
108 // terrain
109 $export.= str_pad(substr($row['parcelle'],0,7),7," ", STR_PAD_RIGHT); //nom du maitre d ouvrage
110 $export.= str_pad($bl,32," ", STR_PAD_RIGHT); //1ere ligne
111 $export.= str_pad(substr($row['terrain_numero'].
112 " ".$row['terrain_numero_complement']." ".
113 $row['terrain_adresse'],0,32),32," ", STR_PAD_RIGHT);
114 $export.= str_pad(substr($row['terrain_adresse_complement'],0,32),32," ", STR_PAD_RIGHT);
115 $export.= str_pad(substr($row['terrain_cp'],0,5),5," ", STR_PAD_RIGHT);
116 $export.= str_pad(substr($row['terrain_ville'],0,26),26," ", STR_PAD_RIGHT);
117 // decision format yyyymm
118 $temp= substr($row['date_depot'],0,4).substr($row['date_depot'],5,2);
119 if($temp=='000000') $temp=' '; // date vide si 0000/00/00
120 $export.=$temp;// numero dossier 5
121 // categorie
122 $export.= str_pad ($bl, 1, " ", STR_PAD_RIGHT);
123 // Nature de travaux
124 $export.= str_pad ($row['codelascot'], 1, " ", STR_PAD_RIGHT);
125 //type annexe habitation
126 $export.= str_pad ($bl, 1, " ", STR_PAD_RIGHT);
127 // shon total autoris�e ?
128 $export.= str_pad (substr($row['shon'],0,6), 6, " ", STR_PAD_LEFT);
129 // shon habitation autoris� ?
130 $export.= str_pad (substr($row['shon'],0,6), 6, " ", STR_PAD_LEFT);
131 // mode utilisation principal locaux hab
132 $export.= str_pad ($bl, 1, " ", STR_PAD_RIGHT);
133 // mode utilisation autre locaux autre que hab
134 $export.= str_pad ($bl, 1, " ", STR_PAD_RIGHT);
135 // destination principale des logements
136 // table destination 1 a plusieurs
137 $export.= str_pad ($bl, 1, " ", STR_PAD_RIGHT);
138 // nb logement
139 $export.= str_pad (substr($row['logement_nombre'],0,3), 3, " ", STR_PAD_LEFT);
140 // nb batiment individuel ?
141 $export.= str_pad ($bl, 3, " ", STR_PAD_LEFT);
142 // nb batiment collectif ?
143 $export.= str_pad ($bl, 3, " ", STR_PAD_LEFT);
144 // nb batiments autoris�s
145 $export.= str_pad (substr($row['batiment_nombre'],0,3), 3, " ", STR_PAD_LEFT);
146 // nb log 1 piece
147 $export.= str_pad ($bl, 3, " ", STR_PAD_LEFT);
148 // nb log 2 piece
149 $export.= str_pad ($bl, 3, " ", STR_PAD_LEFT);
150 // nb log 3 piece
151 $export.= str_pad ($bl, 3, " ", STR_PAD_LEFT);
152 // nb log 4 piece
153 $export.= str_pad ($bl, 3, " ", STR_PAD_LEFT);
154 // nb log 5 piece
155 $export.= str_pad ($bl, 3, " ", STR_PAD_LEFT);
156 // nb log 6 piece +
157 $export.= str_pad ($bl, 3, " ", STR_PAD_LEFT);
158 // shon non hab autorise
159 $export.= str_pad ($bl, 6, " ", STR_PAD_LEFT);
160 // 1er type d ouvrage
161 $export.= str_pad ($bl, 2, " ", STR_PAD_LEFT);
162 // shon ass au 1er type ouvrage
163 $export.= str_pad ($bl, 6, " ", STR_PAD_LEFT);
164 // code APET
165 $export.= str_pad ($bl, 4, " ", STR_PAD_LEFT);
166 // Nature des logements
167 $export.= str_pad ($bl, 1, " ", STR_PAD_RIGHT);
168 // capacite accueil locaux hebergt
169 $export.= str_pad ($bl, 3, " ", STR_PAD_LEFT);
170 $export.="\n";
171 }
172 }
173
174 // ecriture des fichiers en tmp
175 $fichier = "../tmp/LO".substr($_POST["datedebut"],3,2).
176 "".substr($_POST["datedebut"],8,4)."PC.132";
177 $inf = fopen($fichier,"w");
178 //$export=substr($export,0,strlen($export)-1); // un \n en trop
179 fwrite($inf,$export);
180 fclose($inf);
181 echo "<br>Fichier ".$fichier." sauvegarde<br><br><br>";
182 echo "<br /><br />Pour telecharger le fichier, cliquer ici : <a href=\"".$fichier."\" target=\"_blank\">";
183 echo "<img src=\"../app/img/ico_trace.png\" alt=\"Telecharger le fichier\" title=\"Telecharger le fichier\" />";
184 echo "</a> avec le bouton droit et enregistrer la cible du lien sous. <br /><br />";
185 }//validation
186 ?>

Properties

Name Value
svn:keywords Id

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26