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

Contents of /trunk/app/sitadel.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 510 - (show annotations)
Wed Oct 17 11:02:35 2012 UTC (12 years, 3 months ago) by vpihour
File size: 20296 byte(s)
Mise à jour de la table service et du formulaire
Suppression des fichiers inutiles
Modification des etats pdf dans init.sql
Mise à jour des scripts concernant l'ancienne table avis

1 <?php
2 // $Id: 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_sitadel", _("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 $t10 = "||||||||||"; // 10 |
29
30 // parametres collectivite
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 ;
53 $t10 = "||||||||||"; // 10 |
54 $datedebut ='';
55 $datefin='';
56 if($_POST["datedebut"]=="")
57 $correct=false;
58 else
59 $datedebut = substr($_POST["datedebut"],6,4).
60 "-".substr($_POST["datedebut"],3,2)."-".
61 substr($_POST["datedebut"],0,2);
62 if($_POST["datefin"]=="")
63 $correct=false;
64 else
65 $datefin = substr($_POST["datefin"],6,4).
66 "-".substr($_POST["datefin"],3,2)."-".
67 substr($_POST["datefin"],0,2);
68 if ($correct==true){ // ***
69 // dossiers concern�s
70 $sql= "select * from ".DB_PREFIXE."dossier";
71 $sql.= " where (nature='PC' or nature = 'PD' or nature = 'PA' or nature = 'DP')";
72 $sql.= " AND ((date_depot >='".$datedebut."' AND date_depot<='".$datefin."')";
73 $sql.= " OR (date_decision>='".$datedebut."' AND date_decision<='".$datefin."')";
74 $sql.= " OR (date_chantier>='".$datedebut."' AND date_chantier<='".$datefin."'))";
75 $sql.= " order by date_depot";
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 ".DB_PREFIXE."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,$pf_departement);
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,$pf_departement);
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'
152 and $row['types']!='Transfert'
153 and (($row['date_depot'] >= $datedebut and $row['date_depot']<=$datefin)
154 or ($row['date_decision'] >= $datedebut and $row['date_decision']<=$datefin))){
155 $avis_sitadel="";
156 $avis_sitadel_motif="";
157 // enregistrement decision dans tous les cas
158 $decision.=$g->entete("DECISION",$departement,$commune,$pf_departement);
159 //if ($row['date_decision']== '0000-00-00'
160 // or !isset($row['date_decision'])){
161 //if(isset($row['date_decision']) and $row['date_decision']!=""){
162 // avis_sitadel et avis_sitadel_motif
163 if($row['avis_decision']!=''){
164 $avis_sitadel = "0";
165 $avis_sitadel_motif="0" ;
166 $sql="select sitadel, sitadel_motif from ".DB_PREFIXE."avis_decision where avis_decision ='".
167 $row['avis_decision']."'";
168 $res1 = $f->db -> query ($sql);
169 $f->isDatabaseError($res1);
170 while ($row1=& $res1->fetchRow(DB_FETCHMODE_ASSOC)){
171 $avis_sitadel = $row1['sitadel'];
172 $avis_sitadel_motif = $row1['sitadel_motif'];
173 }
174 $decision.= $g->decision_groupe1($avis_sitadel,$avis_sitadel_motif,$structure);
175 }else{
176 $decision.= $g->decision_groupe1("0","",$structure); // pas d avis
177 //$decision.= "***".$t10.$t10.$t10.$t10.$t10.$t10.$t10.$t10."|||"; //83
178 }
179 // si la decision est favorable, envoi des informations statistiques
180 if($avis_sitadel==2 or $avis_sitadel==4
181 or $avis_sitadel==5){
182 // si decision favorable, expresse ou tacite GROUPE 2
183 $decision.= $g->terrain();
184 $decision.= $g->amenagement();
185 if($row['travaux']!=''){
186 $sql= "select codelascot,libelle
187 from ".DB_PREFIXE."travaux where travaux=".$row['travaux'];
188 $res2 = $f->db -> query ($sql);
189 $f->isDatabaseError($res2);
190 $temp=$row['description'];
191 // enlever les RC
192 $temp = str_replace( chr(10), " ", $temp);
193 $temp = str_replace( chr(13), " ", $temp);
194 while ($row2=& $res2->fetchRow(DB_FETCHMODE_ASSOC)){
195 $travaux = $row2['libelle']." "; // ***
196 $lascot = $row2['codelascot'];
197 }
198 $travaux.=" ".$temp;
199 $decision.= $g->travaux($travaux,$lascot, $row['types']);
200 }
201 $sql3="select * from ".DB_PREFIXE."destination_shon where dossier = '".
202 $row['dossier']."' order by destination";
203 $res3 = $f->db -> query ($sql3);
204 $f->isDatabaseError($res3);
205 // ***
206 $temp = array();
207 $shonant = array();
208 $shondem = array();
209 $shonanttr = array();
210 $shonprojtr = array();
211 $shoncr1 = array();
212 $shoncr2 = array();
213 while ($row3=& $res3->fetchRow(DB_FETCHMODE_ASSOC)){
214 // round(8.5, 0, PHP_ROUND_HALF_DOWN);
215 if(isset($row3["shon_anterieure"]))
216 $shonant[$row3['destination']]=round($row3["shon_anterieure"], 0);
217 else
218 $shonant[$row3['destination']]=0;
219 if(isset($row3["shon_demolie"]))
220 $shondem[$row3['destination']]=round($row3["shon_demolie"], 0);
221 else
222 $shondem[$row3['destination']]=0;
223 if(isset($row3["shon_anterieure_supprimee"]))
224 $shonanttr[$row3['destination']]=round($row3["shon_anterieure_supprimee"], 0);
225 else
226 $shonanttr[$row3['destination']]=0;
227 if(isset($row3["shon_nouvelle_transformee"]))
228 $shonprojtr[$row3['destination']]=round($row3["shon_nouvelle_transformee"], 0);
229 else
230 $shonprojtr[$row3['destination']]=0;
231 if(isset($row3["shon_nouvelle"]))
232 $shoncr1[$row3['destination']]=round($row3["shon_nouvelle"], 0);
233 else
234 $shoncr1[$row3['destination']]=0;
235 if(isset($row3["shon_shob_transformee"]))
236 $shoncr2[$row3['destination']]=round($row3["shon_shob_transformee"], 0);
237 else
238 $shoncr2[$row3['destination']]=0;
239
240 //$shonant[$row3['destination']]=$row3["shon_anterieure"];
241 //$shondem[$row3['destination']]=$row3["shon_demolie"];
242 //$shonanttr[$row3['destination']]=$row3["shon_anterieure_supprimee"];
243 //$shonprojtr[$row3['destination']]=$row3["shon_nouvelle_transformee"];
244 //$shoncr1[$row3['destination']]=$row3["shon_nouvelle"];
245 //$shoncr2[$row3['destination']]=$row3["shon_shob_transformee"];
246
247 }
248 $decision.= $g->destination($shonant);
249 $decision.= $g->destination($shondem);
250 $decision.= $g->destination($shonanttr);
251 $decision.= $g->destination($shonprojtr);
252 $decision.= $g->destination($shoncr1);
253 $decision.= $g->destination($shoncr2);
254
255 $decision.= $g->descriptif($row['types']);
256 }else // decision defavorable ou pas de decision
257 $decision.= $t10.$t10.$t10.$t10.$t10.$t10.$t10.$t10."|||"; //83 | + 12 | = 95 | pour 96 zones
258 $decision.="\n";
259 }
260
261 // modificatif
262 $modificatif='';
263 if($row['types']=='Modificatif'
264 and $row['date_depot'] >= $datedebut
265 and $row['date_depot']<=$datefin){
266 $modificatif.=$g->entete("MODIFICATIF",$departement,$commune,$pf_departement);
267 if(isset($row['date_decision']) or $row['date_decision']==""){
268 // avis_sitadel et avis_sitadel_motif
269 if($row['avis_decision']!=''){
270 $avis_sitadel = 0;
271 $avis_sitadel_motif=0 ;
272 $sql="select sitadel, sitadel_motif from ".DB_PREFIXE."avis_decision where avis_decision ='".
273 $row['avis_decision']."'";
274 $res1 = $f->db -> query ($sql);
275 $f->isDatabaseError($res1);
276 while ($row1=& $res1->fetchRow(DB_FETCHMODE_ASSOC)){
277 $avis_sitadel = $row1['sitadel'];
278 $avis_sitadel_motif = $row1['sitadel_motif'];
279 }
280 $modificatif.= $g->decision_groupe1($avis_sitadel,$avis_sitadel_motif,$structure);
281 }
282 // si la decision est favorable, envoi des informations statistiques
283 if($avis_sitadel==2 or $avis_sitadel==4
284 or $avis_sitadel==5){
285 // si decision favorable, expresse ou tacite GROUPE 2
286 $modificatif.=$g->adresse_terrain(); //***
287 $modificatif.=$g->parcelle(); //***
288 $modificatif.=$g->terrain(); //***
289 // enlever les RC
290 $temp=$row['description'];
291 $temp = str_replace( chr(10), " ", $temp);
292 $temp = str_replace( chr(13), " ", $temp);
293 if($row['travaux']!=''){
294 $sql= "select codelascot,libelle
295 from ".DB_PREFIXE."travaux where travaux=".$row['travaux'];
296 $res2 = $f->db -> query ($sql);
297 $f->isDatabaseError($res2);
298 while ($row2=& $res2->fetchRow(DB_FETCHMODE_ASSOC)){
299 $travaux = $row2['libelle']." ".$row['description']; // ***;
300 $lascot = $row2['codelascot'];
301 }
302 $travaux.=" ".$temp;
303 $modificatif.= $g->travaux($travaux,$lascot, $row['types']);
304 }
305 $sql3="select * from ".DB_PREFIXE."destination_shon where dossier = '".
306 $row['dossier']."' order by destination";
307 $res3 = $f->db -> query ($sql3);
308 $f->isDatabaseError($res3);
309 $temp = array();
310 while ($row3=& $res3->fetchRow(DB_FETCHMODE_ASSOC)){
311 $shonant[$row3['destination']]=$row3["shon_anterieure"];
312 $shondem[$row3['destination']]=$row3["shon_demolie"];
313 $shonanttr[$row3['destination']]=$row3["shon_anterieure_supprimee"];
314 $shonprojtr[$row3['destination']]=$row3["shon_nouvelle_transformee"];
315 $shoncr1[$row3['destination']]=$row3["shon_nouvelle"];
316 $shoncr2[$row3['destination']]=$row3["shon_shob_transformee"];
317 }
318 $modificatif.= $g->destination($shonant);
319 $modificatif.= $g->destination($shondem);
320 $modificatif.= $g->destination($shonanttr);
321 $modificatif.= $g->destination($shonprojtr);
322 $modificatif.= $g->destination($shoncr1);
323 $modificatif.= $g->destination($shoncr2);
324
325 $modificatif.= $g->descriptif($row['types']);
326 $modificatif.="\n";
327 }
328 }
329 }
330
331 // suivi DOC
332 $suivi1="";
333 if($row['date_chantier'] >= $datedebut and $row['date_chantier']<=$datefin){
334 $suivi1.=$g->entete("SUIVI",$departement,$commune,$pf_departement);
335 $suivi1.=$g->chantier();
336 $suivi1.="\n";
337 }
338 // suivi DAT
339 $suivi2="";
340 if($row['date_achevement'] >= $datedebut and $row['date_achevement']<=$datefin){
341 $suivi2.=$g->entete("SUIVI",$departement,$commune,$pf_departement);
342 $suivi2.=$g->achevement();
343 $suivi2.="\n";
344 }
345 // export
346 $export.=$depot.$decision.$transfert.$modificatif.$suivi1.$suivi2;
347 } // fin while
348 // ***************************************
349 // entete de l enregistrement page 8 et 9
350 // ***************************************
351 // numero
352 // $numero= $db -> nextId('sitadel');
353 $numero=$_POST["numero"];
354 $fichiertransmis = date('ymj').$pf_departement.$departement.$commune;
355 $longueurenregistrement= 0 ; // a calculer *** enregistrement le plus long
356 $entete = "SITADEL|".$pf_departement.$departement."|".$commune."|".$region."|".$fichiertransmis."|".$numero."|";
357 // calcul enregistrement le plus long
358 if(DBCHARSET=='UTF8'){
359 $export=utf8_decode($export);
360 }
361 // nombreenrgistremment et longueurenregistrement
362 $nbenr = explode("\n",$export);
363 $tmp=array();
364 $cpt=0;
365 for($i=0;$i<sizeof($nbenr);$i++){
366 // mb_strlen( variable,encoding) PHP 4 >= 4.0.6, PHP 5
367 // Le param�tre encoding est l'encodage des caract�res.
368 // S'il est omis, l'encodage de caracteres interne sera utilis�.
369 $tmp[$i] = strlen($nbenr[$i]);
370 //echo strlen($nbenr[$i])." ".$nbenr[$i]."<br>";
371 $cpt++;
372 }
373 $longueurenregistrement=max($tmp);
374 $nombreenregistrement=$cpt; // + entete
375 // Date de modification
376 $datemodification = date('y').str_pad (DATE('m'), 2, "0", STR_PAD_LEFT).str_pad (DATE('j'), 2, "0", STR_PAD_LEFT);
377 // export
378 $version = substr($version,0,8);
379 $entete.= $longueurenregistrement."|".$datemodification."|".
380 $nombreenregistrement."|openFoncier|".$version."\n";
381 $export=$entete.$export;
382 // $str = htmlentities($str, ENT_QUOTES);
383 // ecriture des fichiers en tmp
384 $fichier = "../tmp/SITADEL".substr($_POST["datedebut"],3,2).
385 "".substr($_POST["datedebut"],8,4)."";
386 $inf = fopen($fichier,"w");
387 fwrite($inf,$export);
388 fclose($inf);
389 echo "<br>"._("Fichier")." ".$fichier." "._("sauvegarde")."<br /><br /><br />";
390 // affichage
391 echo "<br /><br />Pour telecharger le fichier, cliquer ici : <a href=\"".$fichier."\" target=\"_blank\">";
392 echo "<img src=\"../app/img/ico_trace.png\" alt=\"Telecharger le fichier CNEN\" title=\"Telecharger le fichier Sitadel\" />";
393 echo "</a>"._("avec le bouton droit et enregistrer la cible du lien sous.")."<br /><br />";
394 if($DEBUG==1){
395 $affiche="";
396 $affiche= str_replace("\n","<br>",$export);
397 echo $affiche;
398 }
399 }else // correct = false
400 echo _("remplissez les 2 dates");
401 }//validation
402 ?>

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26