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

Contents of /trunk/app/sitadel.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 187 - (show annotations)
Tue Oct 11 15:01:43 2011 UTC (13 years, 3 months ago) by fraynaud
File size: 16511 byte(s)
mise au point 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"]=="")$correct=false;
55 if($_POST["datefin"]=="") $correct=false;
56 $correct=true; // a enlever apres test
57 if ($correct==true){ // ***
58 // dossiers concernés
59 $sql= "select * from dossier";
60 $sql.= " where (nature='PC' or nature = 'PD' or nature = 'PA' or nature = 'DP')";
61 //$sql.= " AND ((date_depot>='".$this->datedebut."' AND date_depot<='".$this->datefin."')";
62 //$sql.= " OR (date_decision>='".$this->datedebut."' AND date_decision<='".$this->datefin."'))";
63 $sql.= " and dossier = 'PC11R000402'";
64 $res = $f->db -> query ($sql);
65 $f->isDatabaseError($res);
66 while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
67 // initialisation
68 $g = new sitadel($row['dossier']);
69 $g->row=$row;
70 // sitadel
71 $g->val=$val;
72 // parametre
73 $sql = "select parametre, valeur from statistique where dossier ='".$row['dossier']."'";
74 $res1 = $f->db -> query ($sql);
75 $f->isDatabaseError($res1);
76 while ($row1=& $res1->fetchRow(DB_FETCHMODE_ASSOC)){
77 $g->parametre[$row1['parametre']]=$row1['valeur'];
78 }
79 $departement =$f->collectivite["departement"];
80 $commune =$f->collectivite["commune"];
81 $region =$f->collectivite["region"];
82 // depot
83 $depot="";
84 // type different de transfert
85 if($row['types']!='Transfert'){
86 $depot.=$g->entete("DEPOT",$departement,$commune);
87 $depot.=$g->etatcivil();
88 $depot.=$g->adresse();
89 $depot.=$g->delegataire();
90 $depot.=$g->meltel($row['types']);
91 $depot.=$g->adresse_terrain();
92 $depot.=$g->parcelle();
93 // ===========================
94 // contrat maison individuelle
95 // ===========================
96 // sitadel : contrat|
97 // openfoncier : non renseigne
98 $depot.= $g->p('contrat')."|";
99 // ==========
100 // architecte
101 // ==========
102 // sitadel : architecte|
103 // openfoncier : architecte >0
104 if($row['architecte']>0)
105 $depot.= "1|";
106 else
107 $depot.= "0|";
108 // =====================
109 // utilisation data cnil
110 // ======================
111 // sitadel : cnil
112 // openfoncier : non renseigne
113 $depot.= $g->p('cnil');
114 // fin d enregistrement depot
115 $depot.="\n";
116 }
117
118 // transfert
119 $transfert ="";
120 if($row['types']=='Transfert'){
121 $transfert.=$g->entete("TRANSFERT",$departement,$commune);
122 $transfert.=$g->etatcivil();
123 $transfert.=$g->adresse();
124 $transfert.=$g->meltel($row['types']);
125 $transfert.="\n";
126 }
127
128
129 //decision
130 // type different de modificatif
131 $decision="";
132 if($row['types']!='Modificatif'){
133 $avis_sitadel="";
134 $avis_sitadel_motif="";
135 // enregistrement decision dans tous les cas
136 $decision.=$g->entete("DECISION",$departement,$commune);
137 //if ($row['date_decision']== '0000-00-00'
138 // or !isset($row['date_decision'])){
139 if(isset($row['date_decision']) or $row['date_decision']==""){
140 // avis_sitadel et avis_sitadel_motif
141 if($row['avis']!=''){
142 $avis_sitadel = 0;
143 $avis_sitadel_motif=0 ;
144 $sql="select sitadel, sitadel_motif from avis where avis ='".
145 $row['avis']."'";
146 $res1 = $f->db -> query ($sql);
147 $f->isDatabaseError($res1);
148 while ($row1=& $res1->fetchRow(DB_FETCHMODE_ASSOC)){
149 $avis_sitadel = $row1['sitadel'];
150 $avis_sitadel_motif = $row1['sitadel_motif'];
151 }
152 $decision.= $g->decision_groupe1($avis_sitadel,$avis_sitadel_motif);
153 }
154 // si la decision est favorable, envoi des informations statistiques
155 if($avis_sitadel==2 or $avis_sitadel==4
156 or $avis_sitadel==5){
157 // si decision favorable, expresse ou tacite GROUPE 2
158 $decision.= $g->terrain();
159 $decision.= $g->amenagement();
160 if($row['travaux']!=''){
161 $sql= "select codelascot,libelle
162 from travaux where travaux=".$row['travaux'];
163 $res2 = $f->db -> query ($sql);
164 $f->isDatabaseError($res2);
165 while ($row2=& $res2->fetchRow(DB_FETCHMODE_ASSOC)){
166 $travaux = $row2['libelle'];
167 $lascot = $row2['codelascot'];
168 }
169 $decision.= $g->travaux($travaux,$lascot, $row['types']);
170 }
171 $sql3="select * from destination_shon where dossier = '".
172 $row['dossier']."' order by destination";
173 $res3 = $f->db -> query ($sql3);
174 $f->isDatabaseError($res3);
175 $temp = array();
176 while ($row3=& $res3->fetchRow(DB_FETCHMODE_ASSOC)){
177 $shonant[$row3['destination']]=$row3["shon_anterieure"];
178 $shondem[$row3['destination']]=$row3["shon_demolie"];
179 $shonanttr[$row3['destination']]=$row3["shon_anterieure_supprimee"];
180 $shonprojtr[$row3['destination']]=$row3["shon_nouvelle_transformee"];
181 $shoncr1[$row3['destination']]=$row3["shon_nouvelle"];
182 $shoncr2[$row3['destination']]=$row3["shon_shob_transformee"];
183 }
184 $decision.= $g->destination($shonant);
185 $decision.= $g->destination($shondem);
186 $decision.= $g->destination($shonanttr);
187 $decision.= $g->destination($shonprojtr);
188 $decision.= $g->destination($shoncr1);
189 $decision.= $g->destination($shoncr2);
190
191 $decision.= $g->descriptif($row['types']);
192 }
193 }
194 $decision.="\n";
195 }
196
197 // modificatif
198 $modificatif='';
199 if($row['types']=='Modificatif'){
200 $modificatif.=$g->entete("MODIFICATIF",$departement,$commune);
201 if(isset($row['date_decision']) or $row['date_decision']==""){
202 // avis_sitadel et avis_sitadel_motif
203 if($row['avis']!=''){
204 $avis_sitadel = 0;
205 $avis_sitadel_motif=0 ;
206 $sql="select sitadel, sitadel_motif from avis where avis ='".
207 $row['avis']."'";
208 $res1 = $f->db -> query ($sql);
209 $f->isDatabaseError($res1);
210 while ($row1=& $res1->fetchRow(DB_FETCHMODE_ASSOC)){
211 $avis_sitadel = $row1['sitadel'];
212 $avis_sitadel_motif = $row1['sitadel_motif'];
213 }
214 $modificatif.= $g->decision_groupe1($avis_sitadel,$avis_sitadel_motif);
215 }
216 // si la decision est favorable, envoi des informations statistiques
217 if($avis_sitadel==2 or $avis_sitadel==4
218 or $avis_sitadel==5){
219 // si decision favorable, expresse ou tacite GROUPE 2
220 $modificatif.=$g->adresse_terrain(); //***
221 $modificatif.=$g->parcelle(); //***
222 $modificatif.=$g->terrain(); //***
223 if($row['travaux']!=''){
224 $sql= "select codelascot,libelle
225 from travaux where travaux=".$row['travaux'];
226 $res2 = $f->db -> query ($sql);
227 $f->isDatabaseError($res2);
228 while ($row2=& $res2->fetchRow(DB_FETCHMODE_ASSOC)){
229 $travaux = $row2['libelle'];
230 $lascot = $row2['codelascot'];
231 }
232 $modificatif.= $g->travaux($travaux,$lascot, $row['types']);
233 }
234 $sql3="select * from destination_shon where dossier = '".
235 $row['dossier']."' order by destination";
236 $res3 = $f->db -> query ($sql3);
237 $f->isDatabaseError($res3);
238 $temp = array();
239 while ($row3=& $res3->fetchRow(DB_FETCHMODE_ASSOC)){
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 $modificatif.= $g->destination($shonant);
248 $modificatif.= $g->destination($shondem);
249 $modificatif.= $g->destination($shonanttr);
250 $modificatif.= $g->destination($shonprojtr);
251 $modificatif.= $g->destination($shoncr1);
252 $modificatif.= $g->destination($shoncr2);
253
254 $modificatif.= $g->descriptif($row['types']);
255 $modificatif.="\n";
256 }
257 }
258 }
259
260 // suivi DOC
261 $suivi1="";
262 // test
263 // enregistrement decision dans tous les cas
264 // $nombreenregistrement++;
265 $suivi1.=$g->entete("SUIVI",$departement,$commune);
266 $suivi1.=$g->chantier();
267 $suivi1.="\n";
268
269 // suivi DAT
270 $suivi2="";
271 // test
272 // enregistrement decision dans tous les cas
273 // $nombreenregistrement++;
274 $suivi2.=$g->entete("SUIVI",$departement,$commune);
275 $suivi2.=$g->achevement();
276 $suivi2.="\n";
277
278 // ***************************************
279 // entete de l enregistrement page 8 et 9
280 // ***************************************
281 // numero
282 // $numero= $db -> nextId('sitadel');
283 $numero=$_POST["numero"];
284 $fichiertransmis = date('ymj').$departement.$commune;
285 $longueurenregistrement= 0 ; // a calculer *** enregistrement le plus long
286 $entete = "SITADEL|".$departement."|".$commune."|".$region."|".$fichiertransmis."|".$numero."|";
287 // calcul enregistrement le plus long
288 $export="";
289 $export=$depot.$decision.$transfert.$modificatif.$suivi1.$suivi2;
290 if(CHARSET=='UTF8'){
291 $export=utf8_decode($export);
292 }
293 // nombreenrgistremment et longueurenregistrement
294 $nbenr = explode("\n",$export);
295 $tmp=array();
296 $cpt=0;
297 for($i=0;$i<sizeof($nbenr);$i++){
298 // mb_strlen( variable,encoding) PHP 4 >= 4.0.6, PHP 5
299 // Le paramètre encoding est l'encodage des caractères.
300 // S'il est omis, l'encodage de caracteres interne sera utilisé.
301 $tmp[$i] = strlen($nbenr[$i]);
302 //echo strlen($nbenr[$i])." ".$nbenr[$i]."<br>";
303 $cpt++;
304 }
305 $longueurenregistrement=max($tmp);
306 $nombreenregistrement=$cpt; // + entete
307 // Date de modification
308 $datemodification = date('y').str_pad (DATE('m'), 2, "0", STR_PAD_LEFT).str_pad (DATE('j'), 2, "0", STR_PAD_LEFT);
309 // export
310 $version = substr($version,0,8);
311 $entete.= $longueurenregistrement."|".$datemodification."|".$nombreenregistrement."|openFoncier|".$version."\n";
312 $export=$entete.$export;
313 //$str = htmlentities($str, ENT_QUOTES);
314 // ecriture des fichiers en tmp
315 $fichier = "../tmp/SITADEL".substr($_POST["datedebut"],3,2).
316 "".substr($_POST["datedebut"],8,4)."_test";
317 $inf = fopen($fichier,"w");
318 //$export=substr($export,0,strlen($export)-1); // un \n en trop
319 fwrite($inf,$export);
320 fclose($inf);
321 echo "<br>Fichier ".$fichier." sauvegarde<br><br><br>";
322
323 // affichage
324 echo "<br /><br />Pour telecharger le fichier, cliquer ici : <a href=\"".$fichier."\" target=\"_blank\">";
325 echo "<img src=\"../app/img/ico_trace.png\" alt=\"Telecharger le fichier CNEN\" title=\"Telecharger le fichier CNEN\" />";
326 echo "</a> avec le bouton droit et enregistrer la cible du lien sous. <br /><br />";
327
328 if($DEBUG==1){
329 $affiche="";
330 $affiche= str_replace("\n","<br>",$export);
331 echo $affiche;
332 }
333 } // fin while
334 }else // correct = false
335 echo "remplissez les 2 dates";
336 }//validation
337 ?>

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26