backoffice/html/sirenbod/chargements.php
2011-06-21 13:28:10 +00:00

226 lines
9.0 KiB
PHP

<?php
if (isset($_REQUEST['code']) && trim($_REQUEST['code'])<>'') $code=$_REQUEST['code'];
else $code='T';
if (isset($_REQUEST['annee']) && trim($_REQUEST['annee'])<>'') $annee=$_REQUEST['annee'];
else $annee=0;
/**
* Inclusion du fichier de configuration des includes Métiers de S&D
*/
include '/var/www/includes/config.php';
/**
* Inclusion du Framework
*/
if( !defined('FWK_PATH') )
include '/var/www/framework/fwk.php';
$t1=microtime_float();
include_once(INCLUDE_PATH.'insee/classMInsee.php');
include_once(INCLUDE_PATH.'bodacc/classMBodacc.php');
include_once(FWK_PATH.'common/dates.php');
$iDb=new WDB('jo');
$iDb2=new WDB('sdv1');
session_start();
$tabSirenPC=array();
$authorized = false;
if(isset($_GET['logout']) && ($_SESSION['auth'])) {
$_SESSION['auth'] = null;
session_destroy();
echo "logging out...";
}
if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
$user=addslashes(trim($_SERVER['PHP_AUTH_USER']));
$pwd =addslashes(trim($_SERVER['PHP_AUTH_PW']));
$tabTmp=$iDb2->select( 'utilisateurs',
'id, login, email',
"login='$user' AND password='$pwd' AND idClient=1 AND actif=1 AND deleted=0");
$_SESSION['userId']=$tabTmp[0]['id'];
$_SESSION['userMail']=$tabTmp[0]['login'];
if ( $_SESSION['userId'] ) {//&& $_SESSION['auth']) {
$authorized = true;
}
} else {
//if (isset($_GET["login"]) && (! $authorized)) {
header('WWW-Authenticate: Basic Realm="Login please"');
header('HTTP/1.0 401 Unauthorized');
$_SESSION['auth'] = true;
print('Login now or forever hold your clicks...');
exit;
}
if (!$authorized) {
?><h1>you have <? echo ($authorized) ? '' : 'not'; ?> logged!</h1><?
} else {
//echo '<!--';
$nomAncre='';
if (isset($_POST['envoyer'])) {
foreach ($_POST['envoyer'] as $idEnv=>$env) {
$nomAncre='#n'.$idEnv;
}}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html" />
<title>Gestion des informations de la base de donn&eacute;es</title>
<link rel="stylesheet" type="text/css" href="../nonimg/gestion.css" />
<script language='javascript' src='../nonimg/calendar.js'></script>
</head>
<?
$iInsee=new MInsee();
$iBodacc=new MBodacc();
?>
<h3 align="center">Chargement des Bodacc en base</h3>
<h4 align="center">
<select name="code" onChange="window.location='./chargements.php?annee=<?=$annee?>&code=' + this.value;" style="font-family:arial; font-size:11;">
<option value="T" <?if($code=='T') echo 'selected';?>>Tous les Bodacc</option>
<option value="A" <?if($code=='A') echo 'selected';?>>Bodacc A</option>
<option value="B" <?if($code=='B') echo 'selected';?>>Bodacc B</option>
<option value="C" <?if($code=='C') echo 'selected';?>>Bodacc C</option>
<option value="ASSO" <?if($code=='ASSO') echo 'selected';?>>JO Asso</option>
<option value="BOMP A" <?if($code=='BOMP A') echo 'selected';?>>BoAmp A</option>
<option value="BOMP B" <?if($code=='BOMP B') echo 'selected';?>>BoAmp B</option>
<option value="BOMP C" <?if($code=='BOMP C') echo 'selected';?>>BoAmp C</option>
<option value="MAPA" <?if($code=='MAPA') echo 'selected';?>>MAPA</option>
</select>
<select name="annee" onChange="window.location='./chargements.php?code=<?=$code?>&annee=' + this.value;" style="font-family:arial; font-size:11;">
<option value="0" <?if($annee==0) echo 'selected';?>>Toutes les années</option>
<? for ($i=2005; $i<=date('Y'); $i++) { ?>
<option value="<?=$i?>" <?if($i==$annee) echo 'selected';?>><?=$i?></option>
<? } ?>
</select>
<a href="../">RETOUR</a>
</h4>
<? $strCJ='';
if (isset($_REQUEST['cj']) && trim($_REQUEST['cj'])<>'') {
if ($_REQUEST['cj']==1) $strCJ=' AND e.cj BETWEEN 1000 AND 1999 ';
elseif ($_REQUEST['cj']==5) $strCJ=' AND e.cj BETWEEN 5000 AND 5999 ';
elseif ($_REQUEST['cj']==9) $strCJ=' AND e.cj BETWEEN 9000 AND 9999 ';
elseif ($_REQUEST['cj']=='A') $strCJ=' AND ( e.cj BETWEEN 2000 AND 4999 OR e.cj BETWEEN 6000 AND 8999) ';
elseif ($_REQUEST['cj']==0) $strCJ='';
}
?>
<table BgColor="#177AE9" cellspacing="1" cellpadding="2" border="0" align="center" BorderColor="#000020">
<tr><td><b><font color="Black">Année<!--['Bodacc_Annee_Parution']--></font></b></td>
<td><b><font color="Black">Code<!--['Bodacc_Code']--></font></b></td>
<td><b><font color="Black">Numéro<!--['Bodacc_Num']--></font></b></td>
<td><b><font color="Black">Parution<!--['Bodacc_Date_Parution']--></font></b></td>
<td><b><font color="Black">Dispo<!--['DateDispo']--></font></b></td>
<td><b><font color="Black">Chargement<!--['dateDownload']--></font></b></td>
<td><b><font color="Black">Delta<!--$format--></font></b></td>
<td><b><font color="Black">Format<!--$format--></font></b></td>
<td><b><font color="Black">Annonces<!--['Num_Annonce_Deb] ['Num_Annonce_Fin']--></font></b></td>
<td><b><font color="Black">Taille<!--['taille]--></font></b></td>
<td><b><font color="Black">Fichier<!--['NomFichier']--></font></b></td>
</tr>
<?//SELECT b.siren, b.Bodacc_Date_Parution, b.raisonSociale, b.Capital, b.adresseSiege, b.codePostalSiege, b.villeSiege, b.activite, e.cj, e.rang FROM bodacc_detail b, etablissements e WHERE b.idSirenage >0 and b.siren >100 and b.siren = e.siren and e.siege =1 ORDER BY b.Bodacc_Date_Parution DESC;
$strCode=$strAnnee='';
if ($code=='A' || $code=='B' || $code=='C' || $code=='ASSO' ||
$code=='BOMP A' || $code=='BOMP B' || $code=='BOMP C' || $code=='MAPA')
$strCode =" AND Bodacc_Code='$code' ";
if ($annee>2004 && $annee<=date('Y'))
$strAnnee=" AND Bodacc_Annee_Parution=$annee ";
$tabTmp=$iDb->select( 'chargements',
'NomFichier, Bodacc_Date_Parution, DateDispo, dateDownload, taille, Bodacc_Code, Bodacc_Annee_Parution, Bodacc_Num, Num_Annonce_Deb, Num_Annonce_Fin, annomalieVerifiee, dateInsert, DATEDIFF(DateDispo,Bodacc_Date_Parution) as nbJours',
"1 $strCode $strAnnee ORDER BY Bodacc_Annee_Parution, Bodacc_Code, Bodacc_Num, Num_Annonce_Deb",false,MYSQL_ASSOC);
// die(print_r($tabTmp));
$iDb2=new WDB('insee');
$numPre=$numAnnPre=0;
foreach ($tabTmp as $i=>$tabAnn) {
$bgcolor='#E2EEFC'; // Couleur OK
// Les fichiers RCS et PCL sont gérés sur une même ligne
if ($tabAnn['Bodacc_Code']=='A' && substr($tabAnn['NomFichier'],0,3)=='PCL' &&
substr($tabTmp[$i-1]['NomFichier'],0,3)=='RCS') continue;
if ( $tabAnn['Bodacc_Num']<>($numPre+1) && $tabAnn['Bodacc_Code']==@$tabTmp[$i-1]['Bodacc_Code'])
$bgcolor='#E2E0FC';
if ($tabAnn['Bodacc_Code']=='A' && substr($tabAnn['NomFichier'],0,3)=='RCS')
$numAnnPre=$tabAnn['Num_Annonce_Fin'];
if (substr($tabAnn['NomFichier'],-3)=='TLS') $format='TLS';
elseif (substr($tabAnn['NomFichier'],-3)=='taz') $format='xml';
else $format='&nbsp;';
if ($tabAnn['Bodacc_Code']=='A' && ( substr($tabAnn['NomFichier'],0,3)=='RCS' || substr($tabAnn['NomFichier'],0,3)=='PCL') ) {
if (substr($tabAnn['NomFichier'],0,3)=='RCS') {
$tabAnnPcl=$tabTmp[$i+1];
if (substr($tabAnnPcl['NomFichier'],0,3)<>'PCL')
$tabAnnPcl=array( 'Bodacc_Date_Parution'=>'Néant',
'DateDispo'=>'Néant',
'dateDownload'=>'Néant',
'nbJours'=>'Néant',
'Num_Annonce_Deb'=>'Néant',
'Num_Annonce_Fin'=>'Néant',
'taille'=>'Néant',
'NomFichier'=>'Néant');
} elseif (substr($tabAnn['NomFichier'],0,3)=='PCL') {
$tabAnnPcl=$tabAnn;
$tabAnn=array( 'Bodacc_Annee_Parution'=>$tabAnnPcl['Bodacc_Annee_Parution'],
'Bodacc_Code'=>$tabAnnPcl['Bodacc_Code'],
'Bodacc_Num'=>$tabAnnPcl['Bodacc_Num'],
'Bodacc_Date_Parution'=>'Néant',
'DateDispo'=>'Néant',
'dateDownload'=>'Néant',
'nbJours'=>'Néant',
'Num_Annonce_Deb'=>'Néant',
'Num_Annonce_Fin'=>'Néant',
'taille'=>'Néant',
'NomFichier'=>'Néant');
}
?>
<tr BgColor="<?=$bgcolor?>"><td><?=$tabAnn['Bodacc_Annee_Parution']?></td>
<td><?=$tabAnn['Bodacc_Code']?></td>
<td><?=$tabAnn['Bodacc_Num']?></td>
<td><?=$tabAnn['Bodacc_Date_Parution'].'<br/>'.$tabAnnPcl['Bodacc_Date_Parution']?></td>
<td><?=$tabAnn['DateDispo'].'<br/>'.$tabAnnPcl['DateDispo']?></td>
<td><?=$tabAnn['dateDownload'].'<br/>'.$tabAnnPcl['dateDownload']?></td>
<td><?=$tabAnn['nbJours'].'<br/>'.$tabAnnPcl['nbJours']?></td>
<td><?=$format?></td>
<td><?=$tabAnn['Num_Annonce_Deb'].' - '.$tabAnn['Num_Annonce_Fin'].'<br/>'.
$tabAnnPcl['Num_Annonce_Deb'].' - '.$tabAnnPcl['Num_Annonce_Fin']?></td>
<td><?=$tabAnn['taille'].'<br/>'.$tabAnnPcl['taille']?></td>
<td><?=$tabAnn['NomFichier'].'<br/>'.$tabAnnPcl['NomFichier']?></td>
</tr>
<? } else {
?>
<tr BgColor="<?=$bgcolor?>"><td><?=$tabAnn['Bodacc_Annee_Parution']?></td>
<td><?=$tabAnn['Bodacc_Code']?></td>
<td><?=$tabAnn['Bodacc_Num']?></td>
<td><?=$tabAnn['Bodacc_Date_Parution']?></td>
<td><?=$tabAnn['DateDispo']?></td>
<td><?=$tabAnn['dateDownload']?></td>
<td><?=$tabAnn['nbJours']?></td>
<td><?=$format?></td>
<td><?=$tabAnn['Num_Annonce_Deb'].' - '.$tabAnn['Num_Annonce_Fin']?></td>
<td><?=$tabAnn['taille']?></td>
<td><?=$tabAnn['NomFichier']?></td>
</tr>
<?
}
$numPre=$tabAnn['Bodacc_Num'];
}
?>
</table>
<a name="end"></a>
<?
}
?>