2009-07-20 16:17:33 +00:00
< ?
2009-03-05 16:19:38 +00:00
if ( ! $_SESSION [ 'connected' ]) die ();
2009-07-20 16:17:33 +00:00
require_once 'partenaires/classMTva.php' ;
require_once 'partenaires/classMMap.php' ;
require_once 'common/dates.php' ;
2009-08-27 07:28:00 +00:00
require_once 'cache/cache.php' ;
2009-07-20 16:17:33 +00:00
require_once 'cache.php' ;
2009-03-05 16:19:38 +00:00
2009-02-17 13:14:53 +00:00
$siret = trim ( preg_replace ( '/[^0-9]/' , '' , $_REQUEST [ 'siret' ]));
2010-02-10 17:27:03 +00:00
if ( strlen ( $siret ) <> 0 && strlen ( $siret ) <> 9 && strlen ( $siret ) <> 14 ) die ( 'Paramètres incorrects !' );
2009-02-17 13:14:53 +00:00
2010-02-10 17:27:03 +00:00
$idEntreprise = trim ( preg_replace ( '/[^0-9]/' , '' , $_REQUEST [ 'idEntreprise' ])) * 1 ; // Si id=0 alors non communiqué
if (( $siret * 1 ) == 0 && $idEntreprise == 0 ) die ( 'Paramètres incorrects !' );
2009-08-27 07:28:00 +00:00
$siren = substr ( $siret , 0 , 9 );
2010-03-18 16:27:18 +00:00
$raisonSociale = etabSession ( $siren , $idEntreprise );
2009-08-27 07:28:00 +00:00
$mil = false ;
2009-02-17 13:14:53 +00:00
2010-02-10 17:27:03 +00:00
//Générer un nom de fichier pour le cache et l'export des fichiers
2009-03-10 15:07:24 +00:00
if (( $siret * 1 ) == 0 && ( $siren * 1 ) < 100 ){
2009-03-05 16:19:38 +00:00
$fileName = $page2 . '-' . $idEntreprise ;
} else {
2009-03-10 15:07:24 +00:00
$fileName = $page2 . '-' . $siret ;
}
2009-08-27 07:28:00 +00:00
cache_filename ( $fileName );
2009-07-20 16:17:33 +00:00
2009-12-10 09:54:47 +00:00
if ( cache_exist () && ! ( preg_match ( '/\bsaisie\b/i' , $_SESSION [ 'tabInfo' ][ 'droits' ]) || $_SESSION [ 'tabInfo' ][ 'mode_edition' ] == 1 ) ){
2009-08-27 07:28:00 +00:00
$etabs = cache_get ( 'etabs' );
//Affichage d'un message d'erreur
if ( $etabs === FALSE ) exit ;
$firephp -> info ( 'CACHE' );
} else {
2009-03-05 16:19:38 +00:00
try {
$O = $client -> getListeEtablissements ( $siren );
2009-08-27 07:28:00 +00:00
$etabs = $O [ 'result' ];
cache_delete ();
cache_add ( 'etabs' , $etabs );
2009-03-05 16:19:38 +00:00
} catch ( SoapFault $fault ) {
2009-07-21 07:17:54 +00:00
require_once 'soaperror.php' ;
2009-08-27 07:28:00 +00:00
processSoapFault ( $client , $fault , $_SESSION [ 'tabInfo' ]);
2009-03-05 16:19:38 +00:00
die ();
}
2009-08-27 07:28:00 +00:00
}
2009-07-20 16:17:33 +00:00
2009-08-27 07:28:00 +00:00
$raisonSociale = $_SESSION [ 'tabInfo' ][ 'entrep' ][ 'raisonSociale' ];
2009-09-14 15:47:52 +00:00
2009-09-14 16:08:22 +00:00
/*
2009-09-14 15:47:52 +00:00
if ( count ( $etabs ) > 0 )
{
2009-08-27 07:28:00 +00:00
?>
2009-09-14 15:47:52 +00:00
< script type = " text/javascript " >
2009-09-14 15:40:12 +00:00
<!--
$ ( document ) . ready ( function (){
2009-09-14 15:47:52 +00:00
$ ( '#carte' ) . html ( 'Chargement de la carte...' );
$ ( '#carte' ) . load ( './?page=carte&siret=<?=$siren?>' );
2009-09-14 15:40:12 +00:00
});
//-->
</ script >
2010-03-18 16:27:18 +00:00
< ? php
2009-09-14 16:08:22 +00:00
} */
2009-09-14 15:47:52 +00:00
?>
2009-08-27 07:28:00 +00:00
< div id = " center " >
< h1 class = " titre " > LISTE DES & Eacute ; TABLISSEMENTS </ h1 >
2009-07-20 16:17:33 +00:00
2009-08-27 07:28:00 +00:00
< table >
< tr >
< td width = " 30 " >& nbsp ; </ td >
< td width = " 200 " class = " StyleInfoLib " > Num & eacute ; ro identifiant Siren </ td >
< td width = " 350 " class = " StyleInfoData " >< ? = substr ( $siren , 0 , 3 ) . ' ' . substr ( $siren , 3 , 3 ) . ' ' . substr ( $siren , 6 , 3 ) ?> </td>
</ tr >
< tr >
< td width = " 30 " >& nbsp ; </ td >
< td width = " 200 " class = " StyleInfoLib " > Raison Sociale </ td >
< td width = " 350 " class = " StyleInfoData " >< ? = $raisonSociale ?> </td>
</ tr >
</ table >
< h2 >& Eacute ; tablissements </ h2 >
< table >
< tr >
< td width = " 30 " >& nbsp ; </ td >
< td colspan = " 2 " width = " 550 " class = " StyleInfoData " >
< table >
< ? php
foreach ( $etabs as $i => $etab )
{
2010-02-10 17:27:03 +00:00
if ( $etab [ 'Siege' ] == 1 ) $type = 'siège ' ;
else $type = 'établissement ' ;
2009-08-27 07:28:00 +00:00
if ( $etab [ 'Actif' ] == 1 ) $type .= 'actif' ;
else $type .= 'inactif' ;
2010-03-18 16:27:18 +00:00
2009-12-23 14:40:36 +00:00
if ( $etab [ 'Nic' ] * 1 == 0 || $etab [ 'Nic' ] * 1 >= 99990 ) $type .= ' provisoire' ;
2010-03-18 16:27:18 +00:00
2010-02-10 17:27:03 +00:00
$lien = '<a title="Voir la fiche d\'identité" href="/?page=identite&siret=' . $siren . $etab [ 'Nic' ] . '&idEntreprise=' . $idEntreprise . '">' ;
2009-08-27 07:28:00 +00:00
?>
< tr >
2010-02-10 17:27:03 +00:00
< td class = " StyleInfoData " width = " 30 " >< b >< a title = " Voir la fiche d'identité " href = " /?page=identite&siret=<?= $siren . $etab['Nic'] ?>&idEntreprise=<?= $idEntreprise ?> " >< ? = $lien . $etab [ 'Nic' ] ?> </a></b></td>
2009-08-27 07:28:00 +00:00
< td class = " StyleInfoData " width = " 120 " >< ? = $type ?> </td>
< td class = " StyleInfoData " width = " 150 " >
< ? php
if ( $etab [ 'Enseigne' ] <> '' ) echo '<b>' . $etab [ 'Enseigne' ] . '</b><br/>' ;
echo $etab [ 'Adresse' ] . '<br/>' ;
if ( $etab [ 'Adresse2' ] <> '' ) echo $etab [ 'Adresse2' ] . '<br/>' ;
echo '<b>' . $etab [ 'CP' ] . ' ' . $etab [ 'Ville' ] . '</b>' ;
if ( $etab [ 'Tel' ] <> '' ) echo '<br/><i>Tél : ' . $etab [ 'Tel' ] . '</i> ' ;
if ( $etab [ 'Fax' ] <> '' ) echo '<br/><i>Fax : ' . $etab [ 'Fax' ] . '</i>' ;
?>
2009-03-05 16:19:38 +00:00
</ td >
2009-08-27 07:28:00 +00:00
< td class = " StyleInfoData " width = " 260 " >< ? = $etab [ 'NafEtab' ] . ' : ' . $etab [ 'NafEtabLib' ] ?> </td>
</ tr >
< ? php
}
2009-09-14 15:40:12 +00:00
?>
</ table >
</ td >
</ tr >
< tr >
2010-03-18 16:27:18 +00:00
< td width = " 30 " >& nbsp ; </ td >
< td colspan = " 2 " width = " 506 " class = " StyleInfoData " >
< ? php
if ( count ( $etabs ) == 0 ) {
print 'Aucun établissement n\'est présent dans notre base' ;
} else if ( preg_match ( '/\bCARTES\b/i' , $_SESSION [ 'tabInfo' ][ 'pref' ])) {
print '<iframe src="/?page=carte&siret=' . $siren .
'" width=506 height=505 marginheight="1" marginwidth="1"' .
' scrolling="No" frameborder=0></iframe>' ;
}
?>
</ td >
2009-08-27 07:28:00 +00:00
</ tr >
2009-09-14 15:40:12 +00:00
2009-08-27 07:28:00 +00:00
</ table >
</ div >
2009-03-05 16:19:38 +00:00
2010-03-18 16:27:18 +00:00
< ? php
2010-02-10 17:27:03 +00:00
//Exportation des données sous forme de fichier
2009-08-27 07:28:00 +00:00
function htmldecode ( $value ){
$value = is_array ( $value ) ? array_map ( 'htmldecode' , $value ) : html_entity_decode ( $value , ENT_QUOTES , 'UTF-8' );
return $value ;
}
$tabForExport = htmldecode ( $etabs );
//@TODO a tester
2009-07-20 16:17:33 +00:00
2009-08-27 07:28:00 +00:00
if ( count ( $tabForExport ) > 0 ){
require_once 'export.php' ;
2009-03-05 16:19:38 +00:00
2009-08-27 07:28:00 +00:00
$array2csv = new ExportCSV ();
$array2csv -> records = $tabForExport ;
$array2csv -> writeCSV ( $fileName );
2009-03-05 16:19:38 +00:00
2009-08-27 07:28:00 +00:00
$array2xml = new ExportXML ();
$array2xml -> rootName = $page . 's' ;
$array2xml -> defaultTagName = $page ;
$array2xml -> records = $tabForExport ;
$array2xml -> writeXML ( $fileName );
}
2009-03-05 16:19:38 +00:00
?>