1 |
<?php |
2 |
// $Id: export_dp.php,v 1.6 2010-03-16 19:45:04 fraynaud Exp $ |
3 |
/* |
4 |
transfert de dossier à la DGI Cadstre |
5 |
*/ |
6 |
require_once "../obj/utils.class.php"; |
7 |
$f = new utils(NULL, "export_dp", _("export DP"), "ico_dossier.png", "dossier"); |
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 DP 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_dp.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 "<br><br><input type='submit' value='export DT et PD' ><br><br>"; |
38 |
echo "</form>"; |
39 |
}else { // ===================== extraction ================================= |
40 |
$correct=true; |
41 |
if($_POST["datedebut"]=="") $correct=false; |
42 |
if($_POST["datefin"]=="") $correct=false; |
43 |
if ($correct==true){ |
44 |
$departement =$f->collectivite["departement"]; |
45 |
$commune =$f->collectivite["commune"]; |
46 |
$sql= "select date_depot,annee, dossier.dossier, demandeur_civilite, dossier.nature, |
47 |
demandeur_nom,demandeur_societe,demandeur_adresse,demandeur_ville,demandeur_cp, |
48 |
parcelle, terrain_numero,terrain_numero_complement, |
49 |
terrain_adresse,terrain_adresse_complement, terrain_ville, |
50 |
shon,logement_nombre,travaux.libelle from ".DB_PREFIXE."dossier |
51 |
left join ".DB_PREFIXE."travaux on dossier.travaux=travaux.travaux"; |
52 |
$sql.= " where (dossier.nature = 'DP' or dossier.nature = 'PD')"; |
53 |
$sql.= " AND date_depot>='".substr($_POST["datedebut"],6,4). |
54 |
"-".substr($_POST["datedebut"],3,2)."-". |
55 |
substr($_POST["datedebut"],0,2)."'"; |
56 |
$sql.= " AND date_depot<='".substr($_POST["datefin"],6,4). |
57 |
"-".substr($_POST["datefin"],3,2)."-". |
58 |
substr($_POST["datefin"],0,2)."'"; |
59 |
$res = $f->db -> query ($sql); |
60 |
$f->isDatabaseError($res); |
61 |
$export=""; |
62 |
$bl=""; |
63 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
64 |
$export.= $departement; |
65 |
$export.= $commune; |
66 |
$export.= $row['annee']; |
67 |
$export.=substr($row['dossier'],4,5);// numero dossier 5 |
68 |
// decision format yyyymm |
69 |
$temp= substr($row['date_depot'],0,4).substr($row['date_depot'],5,2); |
70 |
if($temp=='000000') $temp=' '; // date vide si 0000/00/00 |
71 |
$export.=$temp;// |
72 |
// label |
73 |
$export.= str_pad($row['nature'],2," ", STR_PAD_RIGHT); //label DP ou PD |
74 |
// maitre ouvrage |
75 |
$export.= str_pad(substr($row['demandeur_civilite'],0,5),5," ", STR_PAD_RIGHT); //nom du maitre d ouvrage |
76 |
$export.= str_pad(substr($row['demandeur_nom'],0,27),27," ", STR_PAD_RIGHT); //nom du maitre d ouvrage |
77 |
|
78 |
$export.= str_pad(substr($row['demandeur_societe'],0,32),32," ", STR_PAD_RIGHT); //1ere ligne |
79 |
$export.= str_pad(substr($row['demandeur_adresse'],0,32),32," ", STR_PAD_RIGHT); // adresse |
80 |
$export.= str_pad($bl,32," ", STR_PAD_RIGHT); //2eme ligne |
81 |
$export.= str_pad($bl,32," ", STR_PAD_RIGHT); //3eme Ligne |
82 |
$export.= str_pad($row['demandeur_cp'],5," ", STR_PAD_RIGHT); |
83 |
$export.= str_pad(substr($row['demandeur_ville'],0,26),26," ", STR_PAD_RIGHT); |
84 |
// terrain |
85 |
$export.= str_pad($bl,32," ", STR_PAD_RIGHT); |
86 |
$export.= str_pad(substr($row['terrain_numero']. |
87 |
" ".$row['terrain_numero_complement']." ". |
88 |
$row['terrain_adresse'],0,32),32," ", STR_PAD_RIGHT); |
89 |
$export.= str_pad(substr($row['terrain_adresse_complement'],0,32),32," ", STR_PAD_RIGHT); |
90 |
$export.= str_pad(substr($row['terrain_cp'],0,5),5," ", STR_PAD_RIGHT); |
91 |
$export.= str_pad(substr($row['terrain_ville'],0,26),26," ", STR_PAD_RIGHT); |
92 |
$export.= str_pad(substr($row['parcelle'],0,7),7," ", STR_PAD_RIGHT); //nom du maitre d ouvrage |
93 |
|
94 |
// destination = travaux libelle |
95 |
$export.= str_pad (substr($row['libelle'],0,30), 30, " ", STR_PAD_RIGHT); |
96 |
|
97 |
$export.="\n"; |
98 |
} |
99 |
} |
100 |
// ecriture des fichiers en tmp |
101 |
$fichier = "../tmp/LO".substr($_POST["datedebut"],3,2). |
102 |
"".substr($_POST["datedebut"],8,4)."DT.132"; |
103 |
$inf = fopen($fichier,"w"); |
104 |
//$export=substr($export,0,strlen($export)-1); // un \n en trop |
105 |
fwrite($inf,$export); |
106 |
fclose($inf); |
107 |
echo "<table class='dossier' width='95%'>"; |
108 |
echo "<tr class='dossier'><td>"; |
109 |
echo "<br><br>Fichier ".$fichier."<br><br><br>"; |
110 |
//$affiche= str_replace("\n","<br>",$export); |
111 |
echo "<br /><br />Pour telecharger le fichier, cliquer ici : <a href=\"".$fichier."\" target=\"_blank\">"; |
112 |
echo "<img src=\"../app/img/ico_trace.png\" alt=\"Telecharger le fichier CNEN\" title=\"Telecharger le fichier CNEN\" />"; |
113 |
echo "</a> avec le bouton droit et enregistrer la cible du lien sous. <br /><br />"; |
114 |
echo "</td></tr></table>"; |
115 |
}//validation |
116 |
?> |