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

Contents of /trunk/app/sitadel.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 190 - (show annotations)
Wed Oct 12 10:33:29 2011 UTC (13 years, 3 months ago) by fraynaud
File size: 17405 byte(s)
modif sitadel



1 <?php
2 // $Id: export_sitadel.php,v 1.20 2010-11-15 14:50:40 fraynaud Exp $
3 /*
4 transfert de dossier à SITADEL
5 realisé ville arles par fr+jlb
6 voir parametrage trt/sitadel.inc
7 */
8 require_once "../obj/utils.class.php";
9 require_once "../app/sitadel.class.php";
10 require_once "../dyn/locales.inc.php";
11 require_once "../dyn/version.inc.php";
12 require_once "sitadel.inc";
13 $f = new utils(NULL, "export", _("export SITADEL"), "ico_reqmo.png", "export");
14 $f->addHTMLHeadJs(array("../js/script.js"));
15 // GET
16 if (isset ($_GET['validation'])){
17 $validation=$_GET['validation'];
18 }else{
19 $validation=0;
20 }
21 /**
22 * Description de la page
23 */
24 $description = _("Cette page vous permet de Transmettre les dossiers suivant la procedure SITADEL");
25 $f->displayDescription($description);
26 //controle
27 $DEBUG=1;
28
29 // parametres collectivite
30
31 // =============================================================================
32 // validation = 0
33 // =============================================================================
34 if($validation==0){
35 $validation=1;
36 echo "<form method=\"POST\" action=\"sitadel.php?validation=".$validation."\" name=f1>";
37 echo " "._("debut")." ";
38 echo "<input type='text' name='datedebut' id=\"datedebut\" value=\"";
39 echo "\" size=\"15\" class=\"champFormulaire datepicker\" onchange='fdate(this)' onkeyup=\"\" onclick=\"\" />";
40 echo " "._("fin")." ";
41 echo "<input type='text' name='datefin' id=\"datefin\" value=\"";
42 echo "\" size=\"15\" class=\"champFormulaire datepicker\" onchange='fdate(this)' onkeyup=\"\" onclick=\"\" />";
43 echo " "._("Numero d ordre d envoi")." : "."<SELECT name='numero'>";
44 for($i=1;$i<11;$i++){
45 echo "<option value ='".$i."'>".$i."</option>";
46 }
47 echo "</select>";
48 echo "<br><br><input type='submit' value='export SITADEL'>";
49 echo "<br><br></form>";
50 }else{ // ===================== extraction =================================
51 $correct=true;
52 $longueurenregistrement= 0 ; // a calculer
53 //$nombreenregistrement=1; // l entete est comptée dans le nombre enregistrement
54 if($_POST["datedebut"]=="")
55 $correct=false;
56 else
57 $datedebut = substr($_POST["datedebut"],6,4).
58 "-".substr($_POST["datedebut"],3,2)."-".
59 substr($_POST["datedebut"],0,2);
60 if($_POST["datefin"]=="")
61 $correct=false;
62 else
63 $datefin = substr($_POST["datefin"],6,4).
64 "-".substr($_POST["datefin"],3,2)."-".
65 substr($_POST["datefin"],0,2);
66 //$correct=true; // a enlever apres test
67 if ($correct==true){ // ***
68 // dossiers concernés
69 $sql= "select * from dossier";
70 $sql.= " where (nature='PC' or nature = 'PD' or nature = 'PA' or nature = 'DP')";
71 $sql.= " AND ((date_depot >='".$datedebut."' AND date_depot<='".$datefin."')";
72 $sql.= " OR (date_decision>='".$datedebut."' AND date_decision<='".$datefin."')";
73 $sql.= " OR (date_chantier>='".$datedebut."' AND date_chantier<='".$datefin."'))";
74 $sql.= " order by date_depot";
75 //$sql.= " and dossier = 'PC11R000402'";
76 $res = $f->db -> query ($sql);
77 $f->isDatabaseError($res);
78 $export="";
79 while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
80 // initialisation
81 $g = new sitadel($row['dossier']);
82 $g->row=$row;
83 // sitadel
84 $g->val=$val;
85 // parametre
86 $sql = "select parametre, valeur from statistique where dossier ='".$row['dossier']."'";
87 $res1 = $f->db -> query ($sql);
88 $f->isDatabaseError($res1);
89 while ($row1=& $res1->fetchRow(DB_FETCHMODE_ASSOC)){
90 $g->parametre[$row1['parametre']]=$row1['valeur'];
91 }
92 $departement =$f->collectivite["departement"];
93 $commune =$f->collectivite["commune"];
94 $region =$f->collectivite["region"];
95 // depot
96 $depot="";
97 // type different de transfert
98 if($row['types']!='Transfert'
99 and (($row['date_depot'] >= $datedebut
100 and $row['date_depot']<=$datefin)
101 or ($row['date_decision'] >= $datedebut
102 and $row['date_decision']<=$datefin))){
103 $depot.=$g->entete("DEPOT",$departement,$commune);
104 $depot.=$g->etatcivil();
105 $depot.=$g->adresse();
106 $depot.=$g->delegataire();
107 $depot.=$g->meltel($row['types']);
108 $depot.=$g->adresse_terrain();
109 $depot.=$g->parcelle();
110 // ===========================
111 // contrat maison individuelle
112 // ===========================
113 // sitadel : contrat|
114 // openfoncier : non renseigne
115 $depot.= $g->p('contrat')."|";
116 // ==========
117 // architecte
118 // ==========
119 // sitadel : architecte|
120 // openfoncier : architecte >0
121 if($row['architecte']>0)
122 $depot.= "1|";
123 else
124 $depot.= "0|";
125 // =====================
126 // utilisation data cnil
127 // ======================
128 // sitadel : cnil
129 // openfoncier : non renseigne
130 $depot.= $g->p('cnil');
131 // fin d enregistrement depot
132 $depot.="\n";
133 }
134
135 // transfert
136 $transfert ="";
137 if($row['types']=='Transfert'
138 and $row['date_depot'] >= $datedebut
139 and $row['date_depot']<=$datefin){
140 $transfert.=$g->entete("TRANSFERT",$departement,$commune);
141 $transfert.=$g->etatcivil();
142 $transfert.=$g->adresse();
143 $transfert.=$g->meltel($row['types']);
144 $transfert.="\n";
145 }
146
147
148 //decision
149 // type different de modificatif
150 $decision="";
151 if($row['types']!='Modificatif' and $row['types']!='Transfert'){
152 $avis_sitadel="";
153 $avis_sitadel_motif="";
154 // enregistrement decision dans tous les cas
155 $decision.=$g->entete("DECISION",$departement,$commune);
156 //if ($row['date_decision']== '0000-00-00'
157 // or !isset($row['date_decision'])){
158 //if(isset($row['date_decision']) and $row['date_decision']!=""){
159 // avis_sitadel et avis_sitadel_motif
160 if($row['avis']!=''){
161 $avis_sitadel = "0";
162 $avis_sitadel_motif="0" ;
163 $sql="select sitadel, sitadel_motif from avis where avis ='".
164 $row['avis']."'";
165 $res1 = $f->db -> query ($sql);
166 $f->isDatabaseError($res1);
167 while ($row1=& $res1->fetchRow(DB_FETCHMODE_ASSOC)){
168 $avis_sitadel = $row1['sitadel'];
169 $avis_sitadel_motif = $row1['sitadel_motif'];
170 }
171 $decision.= $g->decision_groupe1($avis_sitadel,$avis_sitadel_motif);
172 }else
173 $decision.= $g->decision_groupe1("0",""); // pas d avis
174 // si la decision est favorable, envoi des informations statistiques
175 if($avis_sitadel==2 or $avis_sitadel==4
176 or $avis_sitadel==5){
177 // si decision favorable, expresse ou tacite GROUPE 2
178 $decision.= $g->terrain();
179 $decision.= $g->amenagement();
180 if($row['travaux']!=''){
181 $sql= "select codelascot,libelle
182 from travaux where travaux=".$row['travaux'];
183 $res2 = $f->db -> query ($sql);
184 $f->isDatabaseError($res2);
185 while ($row2=& $res2->fetchRow(DB_FETCHMODE_ASSOC)){
186 $travaux = $row2['libelle'];
187 $lascot = $row2['codelascot'];
188 }
189 $decision.= $g->travaux($travaux,$lascot, $row['types']);
190 }
191 $sql3="select * from destination_shon where dossier = '".
192 $row['dossier']."' order by destination";
193 $res3 = $f->db -> query ($sql3);
194 $f->isDatabaseError($res3);
195 $temp = array();
196 while ($row3=& $res3->fetchRow(DB_FETCHMODE_ASSOC)){
197 $shonant[$row3['destination']]=$row3["shon_anterieure"];
198 $shondem[$row3['destination']]=$row3["shon_demolie"];
199 $shonanttr[$row3['destination']]=$row3["shon_anterieure_supprimee"];
200 $shonprojtr[$row3['destination']]=$row3["shon_nouvelle_transformee"];
201 $shoncr1[$row3['destination']]=$row3["shon_nouvelle"];
202 $shoncr2[$row3['destination']]=$row3["shon_shob_transformee"];
203 }
204 $decision.= $g->destination($shonant);
205 $decision.= $g->destination($shondem);
206 $decision.= $g->destination($shonanttr);
207 $decision.= $g->destination($shonprojtr);
208 $decision.= $g->destination($shoncr1);
209 $decision.= $g->destination($shoncr2);
210
211 $decision.= $g->descriptif($row['types']);
212 }
213 //}else
214 // $decison.= "|0***"; // avis = 0 si pas de decision
215 $decision.="\n";
216 }
217
218 // modificatif
219 $modificatif='';
220 if($row['types']=='Modificatif'
221 and $row['date_depot'] >= $datedebut
222 and $row['date_depot']<=$datefin){
223 $modificatif.=$g->entete("MODIFICATIF",$departement,$commune);
224 if(isset($row['date_decision']) or $row['date_decision']==""){
225 // avis_sitadel et avis_sitadel_motif
226 if($row['avis']!=''){
227 $avis_sitadel = 0;
228 $avis_sitadel_motif=0 ;
229 $sql="select sitadel, sitadel_motif from avis where avis ='".
230 $row['avis']."'";
231 $res1 = $f->db -> query ($sql);
232 $f->isDatabaseError($res1);
233 while ($row1=& $res1->fetchRow(DB_FETCHMODE_ASSOC)){
234 $avis_sitadel = $row1['sitadel'];
235 $avis_sitadel_motif = $row1['sitadel_motif'];
236 }
237 $modificatif.= $g->decision_groupe1($avis_sitadel,$avis_sitadel_motif);
238 }
239 // si la decision est favorable, envoi des informations statistiques
240 if($avis_sitadel==2 or $avis_sitadel==4
241 or $avis_sitadel==5){
242 // si decision favorable, expresse ou tacite GROUPE 2
243 $modificatif.=$g->adresse_terrain(); //***
244 $modificatif.=$g->parcelle(); //***
245 $modificatif.=$g->terrain(); //***
246 if($row['travaux']!=''){
247 $sql= "select codelascot,libelle
248 from travaux where travaux=".$row['travaux'];
249 $res2 = $f->db -> query ($sql);
250 $f->isDatabaseError($res2);
251 while ($row2=& $res2->fetchRow(DB_FETCHMODE_ASSOC)){
252 $travaux = $row2['libelle'];
253 $lascot = $row2['codelascot'];
254 }
255 $modificatif.= $g->travaux($travaux,$lascot, $row['types']);
256 }
257 $sql3="select * from destination_shon where dossier = '".
258 $row['dossier']."' order by destination";
259 $res3 = $f->db -> query ($sql3);
260 $f->isDatabaseError($res3);
261 $temp = array();
262 while ($row3=& $res3->fetchRow(DB_FETCHMODE_ASSOC)){
263 $shonant[$row3['destination']]=$row3["shon_anterieure"];
264 $shondem[$row3['destination']]=$row3["shon_demolie"];
265 $shonanttr[$row3['destination']]=$row3["shon_anterieure_supprimee"];
266 $shonprojtr[$row3['destination']]=$row3["shon_nouvelle_transformee"];
267 $shoncr1[$row3['destination']]=$row3["shon_nouvelle"];
268 $shoncr2[$row3['destination']]=$row3["shon_shob_transformee"];
269 }
270 $modificatif.= $g->destination($shonant);
271 $modificatif.= $g->destination($shondem);
272 $modificatif.= $g->destination($shonanttr);
273 $modificatif.= $g->destination($shonprojtr);
274 $modificatif.= $g->destination($shoncr1);
275 $modificatif.= $g->destination($shoncr2);
276
277 $modificatif.= $g->descriptif($row['types']);
278 $modificatif.="\n";
279 }
280 }
281 }
282
283 // suivi DOC
284 $suivi1="";
285 if($row['date_chantier'] >= $datedebut and $row['date_chantier']<=$datefin){
286 $suivi1.=$g->entete("SUIVI",$departement,$commune);
287 $suivi1.=$g->chantier();
288 $suivi1.="\n";
289 }
290 // suivi DAT
291 $suivi2="";
292 if($row['date_achevement'] >= $datedebut and $row['date_achevement']<=$datefin){
293 $suivi2.=$g->entete("SUIVI",$departement,$commune);
294 $suivi2.=$g->achevement();
295 $suivi2.="\n";
296 }
297 // export
298 $export.=$depot.$decision.$transfert.$modificatif.$suivi1.$suivi2;
299 } // fin while
300 // ***************************************
301 // entete de l enregistrement page 8 et 9
302 // ***************************************
303 // numero
304 // $numero= $db -> nextId('sitadel');
305 $numero=$_POST["numero"];
306 $fichiertransmis = date('ymj').$departement.$commune;
307 $longueurenregistrement= 0 ; // a calculer *** enregistrement le plus long
308 $entete = "SITADEL|".$departement."|".$commune."|".$region."|".$fichiertransmis."|".$numero."|";
309 // calcul enregistrement le plus long
310 if(CHARSET=='UTF8'){
311 $export=utf8_decode($export);
312 }
313 // nombreenrgistremment et longueurenregistrement
314 $nbenr = explode("\n",$export);
315 $tmp=array();
316 $cpt=0;
317 for($i=0;$i<sizeof($nbenr);$i++){
318 // mb_strlen( variable,encoding) PHP 4 >= 4.0.6, PHP 5
319 // Le paramètre encoding est l'encodage des caractères.
320 // S'il est omis, l'encodage de caracteres interne sera utilisé.
321 $tmp[$i] = strlen($nbenr[$i]);
322 //echo strlen($nbenr[$i])." ".$nbenr[$i]."<br>";
323 $cpt++;
324 }
325 $longueurenregistrement=max($tmp);
326 $nombreenregistrement=$cpt; // + entete
327 // Date de modification
328 $datemodification = date('y').str_pad (DATE('m'), 2, "0", STR_PAD_LEFT).str_pad (DATE('j'), 2, "0", STR_PAD_LEFT);
329 // export
330 $version = substr($version,0,8);
331 $entete.= $longueurenregistrement."|".$datemodification."|".$nombreenregistrement."|openFoncier|".$version."\n";
332 $export=$entete.$export;
333 //$str = htmlentities($str, ENT_QUOTES);
334 // ecriture des fichiers en tmp
335 $fichier = "../tmp/SITADEL".substr($_POST["datedebut"],3,2).
336 "".substr($_POST["datedebut"],8,4)."_test";
337 $inf = fopen($fichier,"w");
338 //$export=substr($export,0,strlen($export)-1); // un \n en trop
339 fwrite($inf,$export);
340 fclose($inf);
341 echo "<br>Fichier ".$fichier." sauvegarde<br><br><br>";
342
343 // affichage
344 echo "<br /><br />Pour telecharger le fichier, cliquer ici : <a href=\"".$fichier."\" target=\"_blank\">";
345 echo "<img src=\"../app/img/ico_trace.png\" alt=\"Telecharger le fichier CNEN\" title=\"Telecharger le fichier CNEN\" />";
346 echo "</a> avec le bouton droit et enregistrer la cible du lien sous. <br /><br />";
347
348 if($DEBUG==1){
349 $affiche="";
350 $affiche= str_replace("\n","<br>",$export);
351 echo $affiche;
352 }
353
354
355 }else // correct = false
356 echo "remplissez les 2 dates";
357 }//validation
358 ?>

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26