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

Diff of /trunk/app/sitadel.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 190 by fraynaud, Wed Oct 12 10:33:29 2011 UTC revision 323 by fmichon, Fri May 11 10:44:40 2012 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: export_sitadel.php,v 1.20 2010-11-15 14:50:40 fraynaud Exp $  // $Id: sitadel.php,v 1.20 2010-11-15 14:50:40 fraynaud Exp $
3  /*  /*
4  transfert de dossier � SITADEL  transfert de dossier � SITADEL
5  realis� ville arles par fr+jlb  realis� ville arles par fr+jlb
# Line 25  $description = _("Cette page vous permet Line 25  $description = _("Cette page vous permet
25  $f->displayDescription($description);  $f->displayDescription($description);
26  //controle  //controle
27  $DEBUG=1;  $DEBUG=1;
28    $t10 = "||||||||||"; // 10 |
29    
30  // parametres collectivite  // parametres collectivite
   
31  // =============================================================================  // =============================================================================
32  // validation = 0  // validation = 0
33  // =============================================================================  // =============================================================================
# Line 49  if($validation==0){ Line 49  if($validation==0){
49      echo "<br><br></form>";      echo "<br><br></form>";
50  }else{   // ===================== extraction =================================  }else{   // ===================== extraction =================================
51      $correct=true;      $correct=true;
52      $longueurenregistrement= 0 ; // a calculer      $longueurenregistrement= 0 ;
53      //$nombreenregistrement=1; // l entete est compt�e dans le nombre enregistrement      $t10 = "||||||||||"; // 10 |
54        $datedebut ='';
55        $datefin='';
56      if($_POST["datedebut"]=="")      if($_POST["datedebut"]=="")
57          $correct=false;          $correct=false;
58      else      else
# Line 63  if($validation==0){ Line 65  if($validation==0){
65          $datefin = substr($_POST["datefin"],6,4).          $datefin = substr($_POST["datefin"],6,4).
66                      "-".substr($_POST["datefin"],3,2)."-".                      "-".substr($_POST["datefin"],3,2)."-".
67                      substr($_POST["datefin"],0,2);                      substr($_POST["datefin"],0,2);
     //$correct=true; // a enlever apres test  
68      if ($correct==true){ // ***      if ($correct==true){ // ***
69          // dossiers concern�s          // dossiers concern�s
70          $sql= "select * from dossier";          $sql= "select * from ".DB_PREFIXE."dossier";
71          $sql.= " where (nature='PC' or nature = 'PD' or nature = 'PA' or nature = 'DP')";          $sql.= " where (nature='PC' or nature = 'PD' or nature = 'PA' or nature = 'DP')";
72          $sql.= " AND ((date_depot >='".$datedebut."' AND date_depot<='".$datefin."')";          $sql.= " AND ((date_depot >='".$datedebut."' AND date_depot<='".$datefin."')";
73          $sql.= " OR (date_decision>='".$datedebut."' AND date_decision<='".$datefin."')";          $sql.= " OR (date_decision>='".$datedebut."' AND date_decision<='".$datefin."')";
74          $sql.= " OR (date_chantier>='".$datedebut."' AND date_chantier<='".$datefin."'))";          $sql.= " OR (date_chantier>='".$datedebut."' AND date_chantier<='".$datefin."'))";
75          $sql.= " order by date_depot";          $sql.= " order by date_depot";
         //$sql.= " and dossier = 'PC11R000402'";  
76          $res = $f->db -> query ($sql);          $res = $f->db -> query ($sql);
77          $f->isDatabaseError($res);          $f->isDatabaseError($res);
78          $export="";          $export="";
# Line 83  if($validation==0){ Line 83  if($validation==0){
83              // sitadel              // sitadel
84              $g->val=$val;              $g->val=$val;
85              // parametre              // parametre
86              $sql = "select parametre, valeur from statistique where dossier ='".$row['dossier']."'";              $sql = "select parametre, valeur from ".DB_PREFIXE."statistique where dossier ='".$row['dossier']."'";
87              $res1 = $f->db -> query ($sql);              $res1 = $f->db -> query ($sql);
88              $f->isDatabaseError($res1);              $f->isDatabaseError($res1);
89              while ($row1=& $res1->fetchRow(DB_FETCHMODE_ASSOC)){              while ($row1=& $res1->fetchRow(DB_FETCHMODE_ASSOC)){
# Line 100  if($validation==0){ Line 100  if($validation==0){
100                  and $row['date_depot']<=$datefin)                  and $row['date_depot']<=$datefin)
101                  or  ($row['date_decision'] >= $datedebut                  or  ($row['date_decision'] >= $datedebut
102                  and $row['date_decision']<=$datefin))){                  and $row['date_decision']<=$datefin))){
103                  $depot.=$g->entete("DEPOT",$departement,$commune);                  $depot.=$g->entete("DEPOT",$departement,$commune,$pf_departement);
104                  $depot.=$g->etatcivil();                  $depot.=$g->etatcivil();
105                  $depot.=$g->adresse();                  $depot.=$g->adresse();
106                  $depot.=$g->delegataire();                  $depot.=$g->delegataire();
# Line 137  if($validation==0){ Line 137  if($validation==0){
137              if($row['types']=='Transfert'              if($row['types']=='Transfert'
138                  and $row['date_depot'] >= $datedebut                  and $row['date_depot'] >= $datedebut
139                  and $row['date_depot']<=$datefin){                  and $row['date_depot']<=$datefin){
140                  $transfert.=$g->entete("TRANSFERT",$departement,$commune);                  $transfert.=$g->entete("TRANSFERT",$departement,$commune,$pf_departement);
141                  $transfert.=$g->etatcivil();                  $transfert.=$g->etatcivil();
142                  $transfert.=$g->adresse();                  $transfert.=$g->adresse();
143                  $transfert.=$g->meltel($row['types']);                  $transfert.=$g->meltel($row['types']);
# Line 148  if($validation==0){ Line 148  if($validation==0){
148              //decision              //decision
149              // type different de modificatif              // type different de modificatif
150              $decision="";              $decision="";
151              if($row['types']!='Modificatif' and $row['types']!='Transfert'){              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="";                  $avis_sitadel="";
156                  $avis_sitadel_motif="";                  $avis_sitadel_motif="";
157                  // enregistrement decision dans tous les cas                  // enregistrement decision dans tous les cas
158                  $decision.=$g->entete("DECISION",$departement,$commune);                  $decision.=$g->entete("DECISION",$departement,$commune,$pf_departement);
159                  //if ($row['date_decision']== '0000-00-00'                  //if ($row['date_decision']== '0000-00-00'
160                  //    or !isset($row['date_decision'])){                  //    or !isset($row['date_decision'])){
161                  //if(isset($row['date_decision']) and $row['date_decision']!=""){                  //if(isset($row['date_decision']) and $row['date_decision']!=""){
# Line 160  if($validation==0){ Line 163  if($validation==0){
163                      if($row['avis']!=''){                      if($row['avis']!=''){
164                          $avis_sitadel = "0";                          $avis_sitadel = "0";
165                          $avis_sitadel_motif="0" ;                          $avis_sitadel_motif="0" ;
166                          $sql="select sitadel, sitadel_motif from avis where avis ='".                          $sql="select sitadel, sitadel_motif from ".DB_PREFIXE."avis where avis ='".
167                                  $row['avis']."'";                                  $row['avis']."'";
168                          $res1 = $f->db -> query ($sql);                          $res1 = $f->db -> query ($sql);
169                          $f->isDatabaseError($res1);                          $f->isDatabaseError($res1);
# Line 168  if($validation==0){ Line 171  if($validation==0){
171                              $avis_sitadel = $row1['sitadel'];                              $avis_sitadel = $row1['sitadel'];
172                              $avis_sitadel_motif = $row1['sitadel_motif'];                              $avis_sitadel_motif = $row1['sitadel_motif'];
173                          }                          }
174                          $decision.= $g->decision_groupe1($avis_sitadel,$avis_sitadel_motif);                          $decision.= $g->decision_groupe1($avis_sitadel,$avis_sitadel_motif,$structure);
175                      }else                      }else{
176                          $decision.= $g->decision_groupe1("0",""); // pas d avis                          $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                      // si la decision est favorable, envoi des informations statistiques
180                      if($avis_sitadel==2  or $avis_sitadel==4                      if($avis_sitadel==2  or $avis_sitadel==4
181                             or $avis_sitadel==5){                             or $avis_sitadel==5){
# Line 179  if($validation==0){ Line 184  if($validation==0){
184                          $decision.= $g->amenagement();                          $decision.= $g->amenagement();
185                          if($row['travaux']!=''){                          if($row['travaux']!=''){
186                              $sql= "select codelascot,libelle                              $sql= "select codelascot,libelle
187                                  from travaux where travaux=".$row['travaux'];                                  from ".DB_PREFIXE."travaux where travaux=".$row['travaux'];
188                              $res2 = $f->db -> query ($sql);                              $res2 = $f->db -> query ($sql);
189                              $f->isDatabaseError($res2);                              $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)){                              while ($row2=& $res2->fetchRow(DB_FETCHMODE_ASSOC)){
195                                  $travaux = $row2['libelle'];                                  $travaux = $row2['libelle']." "; // ***
196                                  $lascot = $row2['codelascot'];                                  $lascot = $row2['codelascot'];
197                              }                              }
198                                $travaux.=" ".$temp;
199                              $decision.= $g->travaux($travaux,$lascot, $row['types']);                              $decision.= $g->travaux($travaux,$lascot, $row['types']);
200                          }                          }
201                          $sql3="select * from destination_shon where dossier = '".                          $sql3="select * from ".DB_PREFIXE."destination_shon where dossier = '".
202                                  $row['dossier']."' order by destination";                                  $row['dossier']."' order by destination";
203                          $res3 = $f->db -> query ($sql3);                          $res3 = $f->db -> query ($sql3);
204                          $f->isDatabaseError($res3);                          $f->isDatabaseError($res3);
205                          $temp = array();                 // ***
206                          while ($row3=& $res3->fetchRow(DB_FETCHMODE_ASSOC)){                 $temp = array();
207                              $shonant[$row3['destination']]=$row3["shon_anterieure"];                 $shonant = array();
208                              $shondem[$row3['destination']]=$row3["shon_demolie"];                 $shondem = array();
209                              $shonanttr[$row3['destination']]=$row3["shon_anterieure_supprimee"];                 $shonanttr = array();
210                              $shonprojtr[$row3['destination']]=$row3["shon_nouvelle_transformee"];                 $shonprojtr = array();
211                              $shoncr1[$row3['destination']]=$row3["shon_nouvelle"];                 $shoncr1 = array();
212                              $shoncr2[$row3['destination']]=$row3["shon_shob_transformee"];                 $shoncr2 = array();
213                          }                 while ($row3=& $res3->fetchRow(DB_FETCHMODE_ASSOC)){
214                          $decision.= $g->destination($shonant);                       // round(8.5, 0, PHP_ROUND_HALF_DOWN);    
215                          $decision.= $g->destination($shondem);                      if(isset($row3["shon_anterieure"]))
216                          $decision.= $g->destination($shonanttr);                                       $shonant[$row3['destination']]=round($row3["shon_anterieure"], 0);
217                          $decision.= $g->destination($shonprojtr);                      else
218                          $decision.= $g->destination($shoncr1);                         $shonant[$row3['destination']]=0;
219                          $decision.= $g->destination($shoncr2);                      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']);                         $decision.= $g->descriptif($row['types']);  
256                      }                      }else // decision defavorable ou pas de decision
257                  //}else                          $decision.= $t10.$t10.$t10.$t10.$t10.$t10.$t10.$t10."|||"; //83 | + 12 | = 95 | pour 96 zones
                 //    $decison.= "|0***"; // avis = 0 si pas de decision        
258              $decision.="\n";              $decision.="\n";
259              }              }
260            
# Line 220  if($validation==0){ Line 263  if($validation==0){
263              if($row['types']=='Modificatif'              if($row['types']=='Modificatif'
264                  and $row['date_depot'] >= $datedebut                  and $row['date_depot'] >= $datedebut
265                  and $row['date_depot']<=$datefin){                    and $row['date_depot']<=$datefin){  
266                  $modificatif.=$g->entete("MODIFICATIF",$departement,$commune);                  $modificatif.=$g->entete("MODIFICATIF",$departement,$commune,$pf_departement);
267                  if(isset($row['date_decision']) or $row['date_decision']==""){                  if(isset($row['date_decision']) or $row['date_decision']==""){
268                      // avis_sitadel et avis_sitadel_motif                      // avis_sitadel et avis_sitadel_motif
269                      if($row['avis']!=''){                      if($row['avis']!=''){
270                          $avis_sitadel = 0;                          $avis_sitadel = 0;
271                          $avis_sitadel_motif=0 ;                          $avis_sitadel_motif=0 ;
272                          $sql="select sitadel, sitadel_motif from avis where avis ='".                          $sql="select sitadel, sitadel_motif from ".DB_PREFIXE."avis where avis ='".
273                                  $row['avis']."'";                                  $row['avis']."'";
274                          $res1 = $f->db -> query ($sql);                          $res1 = $f->db -> query ($sql);
275                          $f->isDatabaseError($res1);                          $f->isDatabaseError($res1);
# Line 234  if($validation==0){ Line 277  if($validation==0){
277                              $avis_sitadel = $row1['sitadel'];                              $avis_sitadel = $row1['sitadel'];
278                              $avis_sitadel_motif = $row1['sitadel_motif'];                              $avis_sitadel_motif = $row1['sitadel_motif'];
279                          }                          }
280                          $modificatif.= $g->decision_groupe1($avis_sitadel,$avis_sitadel_motif);                          $modificatif.= $g->decision_groupe1($avis_sitadel,$avis_sitadel_motif,$structure);
281                      }                      }
282                      // si la decision est favorable, envoi des informations statistiques                      // si la decision est favorable, envoi des informations statistiques
283                      if($avis_sitadel==2  or $avis_sitadel==4                      if($avis_sitadel==2  or $avis_sitadel==4
# Line 243  if($validation==0){ Line 286  if($validation==0){
286                          $modificatif.=$g->adresse_terrain();    //***                          $modificatif.=$g->adresse_terrain();    //***
287                          $modificatif.=$g->parcelle();    //***                          $modificatif.=$g->parcelle();    //***
288                          $modificatif.=$g->terrain();    //***                          $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']!=''){                          if($row['travaux']!=''){
294                              $sql= "select codelascot,libelle                              $sql= "select codelascot,libelle
295                                  from travaux where travaux=".$row['travaux'];                                  from ".DB_PREFIXE."travaux where travaux=".$row['travaux'];
296                              $res2 = $f->db -> query ($sql);                              $res2 = $f->db -> query ($sql);
297                              $f->isDatabaseError($res2);                              $f->isDatabaseError($res2);
298                              while ($row2=& $res2->fetchRow(DB_FETCHMODE_ASSOC)){                              while ($row2=& $res2->fetchRow(DB_FETCHMODE_ASSOC)){
299                                  $travaux = $row2['libelle'];                                  $travaux = $row2['libelle']." ".$row['description']; // ***;
300                                  $lascot = $row2['codelascot'];                                  $lascot = $row2['codelascot'];
301                              }                              }
302                                $travaux.=" ".$temp;
303                              $modificatif.= $g->travaux($travaux,$lascot, $row['types']);                              $modificatif.= $g->travaux($travaux,$lascot, $row['types']);
304                          }                          }
305                          $sql3="select * from destination_shon where dossier = '".                          $sql3="select * from ".DB_PREFIXE."destination_shon where dossier = '".
306                                  $row['dossier']."' order by destination";                                  $row['dossier']."' order by destination";
307                          $res3 = $f->db -> query ($sql3);                          $res3 = $f->db -> query ($sql3);
308                          $f->isDatabaseError($res3);                          $f->isDatabaseError($res3);
# Line 280  if($validation==0){ Line 328  if($validation==0){
328                  }                    }  
329              }              }
330                            
331              // suivi DOC              // suivi DOC
332              $suivi1="";              $suivi1="";
333              if($row['date_chantier'] >= $datedebut and $row['date_chantier']<=$datefin){                if($row['date_chantier'] >= $datedebut and $row['date_chantier']<=$datefin){  
334                  $suivi1.=$g->entete("SUIVI",$departement,$commune);                  $suivi1.=$g->entete("SUIVI",$departement,$commune,$pf_departement);
335                  $suivi1.=$g->chantier();                  $suivi1.=$g->chantier();
336                  $suivi1.="\n";                  $suivi1.="\n";
337              }              }
338              // suivi DAT              // suivi DAT
339              $suivi2="";              $suivi2="";
340              if($row['date_achevement'] >= $datedebut and $row['date_achevement']<=$datefin){                if($row['date_achevement'] >= $datedebut and $row['date_achevement']<=$datefin){  
341                  $suivi2.=$g->entete("SUIVI",$departement,$commune);                  $suivi2.=$g->entete("SUIVI",$departement,$commune,$pf_departement);
342                  $suivi2.=$g->achevement();                  $suivi2.=$g->achevement();
343                  $suivi2.="\n";                  $suivi2.="\n";
344              }              }
# Line 303  if($validation==0){ Line 351  if($validation==0){
351          // numero          // numero
352          // $numero= $db -> nextId('sitadel');                  // $numero= $db -> nextId('sitadel');        
353          $numero=$_POST["numero"];          $numero=$_POST["numero"];
354          $fichiertransmis = date('ymj').$departement.$commune;          $fichiertransmis = date('ymj').$pf_departement.$departement.$commune;
355          $longueurenregistrement= 0 ; // a calculer ***  enregistrement le plus long          $longueurenregistrement= 0 ; // a calculer ***  enregistrement le plus long
356          $entete = "SITADEL|".$departement."|".$commune."|".$region."|".$fichiertransmis."|".$numero."|";          $entete = "SITADEL|".$pf_departement.$departement."|".$commune."|".$region."|".$fichiertransmis."|".$numero."|";
357          // calcul enregistrement le plus long                // calcul enregistrement le plus long      
358          if(CHARSET=='UTF8'){          if(DBCHARSET=='UTF8'){
359              $export=utf8_decode($export);              $export=utf8_decode($export);
360          }          }
361          // nombreenrgistremment et longueurenregistrement          // nombreenrgistremment et longueurenregistrement
# Line 328  if($validation==0){ Line 376  if($validation==0){
376          $datemodification = date('y').str_pad (DATE('m'), 2, "0", STR_PAD_LEFT).str_pad (DATE('j'), 2, "0", STR_PAD_LEFT);          $datemodification = date('y').str_pad (DATE('m'), 2, "0", STR_PAD_LEFT).str_pad (DATE('j'), 2, "0", STR_PAD_LEFT);
377          // export          // export
378          $version = substr($version,0,8);          $version = substr($version,0,8);
379          $entete.= $longueurenregistrement."|".$datemodification."|".$nombreenregistrement."|openFoncier|".$version."\n";          $entete.= $longueurenregistrement."|".$datemodification."|".
380                        $nombreenregistrement."|openFoncier|".$version."\n";
381          $export=$entete.$export;          $export=$entete.$export;
382          //$str = htmlentities($str, ENT_QUOTES);          // $str = htmlentities($str, ENT_QUOTES);
383          // ecriture des fichiers en tmp          // ecriture des fichiers en tmp
384          $fichier = "../tmp/SITADEL".substr($_POST["datedebut"],3,2).          $fichier = "../tmp/SITADEL".substr($_POST["datedebut"],3,2).
385                 "".substr($_POST["datedebut"],8,4)."_test";                 "".substr($_POST["datedebut"],8,4)."";
386          $inf = fopen($fichier,"w");          $inf = fopen($fichier,"w");
         //$export=substr($export,0,strlen($export)-1); // un \n en trop  
387          fwrite($inf,$export);          fwrite($inf,$export);
388          fclose($inf);          fclose($inf);
389          echo "<br>Fichier ".$fichier." sauvegarde<br><br><br>";          echo "<br>"._("Fichier")." ".$fichier." "._("sauvegarde")."<br /><br /><br />";
   
390          // affichage          // affichage
391          echo "<br /><br />Pour telecharger le fichier, cliquer ici : <a href=\"".$fichier."\" target=\"_blank\">";          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 CNEN\" />";          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 />";          echo "</a>"._("avec le bouton droit et enregistrer la cible du lien sous.")."<br /><br />";
           
394          if($DEBUG==1){          if($DEBUG==1){
395              $affiche="";              $affiche="";
396              $affiche= str_replace("\n","<br>",$export);              $affiche= str_replace("\n","<br>",$export);
397              echo $affiche;              echo $affiche;
398          }                        }              
   
   
399      }else // correct = false      }else // correct = false
400          echo "remplissez les 2 dates";          echo _("remplissez les 2 dates");
401  }//validation  }//validation
 ?>  
402    ?>

Legend:
Removed from v.190  
changed lines
  Added in v.323

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26