extranet/www/pages/etablissements.php

129 lines
4.8 KiB
PHP
Raw Normal View History

2009-03-05 16:19:38 +00:00
<?
if (!$_SESSION['connected']) die();
2009-04-01 12:45:45 +00:00
$tabInfo = $_SESSION['tabInfo'];
2009-03-05 16:19:38 +00:00
include_once(INCLUDE_PATH.'/partenaires/classMTva.php');
include_once(INCLUDE_PATH.'/partenaires/classMMap.php');
//include_once(INCLUDE_PATH.'partenaires/classMCoface.php');
include_once(FWK_PATH.'/common/dates.php');
require_once(realpath(dirname(__FILE__).'/../../includes/').'/cache.php');
$siret=trim(preg_replace('/[^0-9]/', '', $_REQUEST['siret']));
if (strlen($siret)<>0 && strlen($siret)<>9 && strlen($siret)<>14) die('Param<61>tres incorrects !');
2009-03-11 07:51:18 +00:00
$idEntreprise=trim(preg_replace('/[^0-9]/', '', $_REQUEST['idEntreprise']))*1; // Si id=0 alors non communiqu<71>
if (($siret*1)==0 && $idEntreprise==0) die('Param<61>tres incorrects !');
$siren=substr($siret,0,9);
$mil=false;
2009-03-05 16:19:38 +00:00
//G<>n<EFBFBD>rer un nom de fichier pour le cache et l'export des fichiers
if (($siret*1)==0 && ($siren*1)<100){
2009-03-05 16:19:38 +00:00
$fileName = $page2.'-'.$idEntreprise;
}else{
$fileName = $page2.'-'.$siret;
}
//Mise en Cache
2009-03-05 16:19:38 +00:00
$cache = new Cache();
//Forcer la cr<63>ation de la page dans le cache lorsque l'utilisateur a le mode saisie
if( preg_match('/saisie/i', $_SESSION['tabInfo']['droits']) || $_SESSION['tabInfo']['mode_edition']==1) {
$cache->disable = TRUE;
$cache->forceStart = TRUE;
}
if ( $cache->startCapture($fileName.'.html') == FALSE){
2009-03-05 16:19:38 +00:00
print $cache->displayCache();
}else{
2009-04-02 09:54:01 +00:00
2009-03-05 16:19:38 +00:00
try {
$O = $client->getListeEtablissements($siren);
$etabs=$O['result'];
} catch (SoapFault $fault) {
include_once(realpath(dirname(__FILE__).'/../../').'/includes/soaperror.php');
processSoapFault($client,$fault,$tabInfo);
die();
}
2009-03-05 16:19:38 +00:00
$raisonSociale=$tabInfo['entrep']['raisonSociale'];
?>
<table width="580" border="0" align="left" bgcolor="#FFFFFF">
<tr>
<td colspan="3" align="center"><img src="./img/rub_etablissements.png" width="577" height="36" /></td>
</tr>
<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>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td colspan="3"><img src="./img/srub_etablissements.png" width="576" height="27" /></td>
</tr>
<tr>
<td width="30">&nbsp;</td>
<td colspan="2" width="550" class="StyleInfoData"><table><?foreach ($etabs as $i=>$etab) {
if ($etab['Siege']==1) $type='si<73>ge ';
else $type='<27>tablissement ';
if ($etab['Actif']==1) $type.='actif';
else $type.='inactif';
2009-03-11 08:47:54 +00:00
$lien='<a title="Voir la fiche d\'identit<69>" href="/?page=identite&siret='.$siren.$etab['Nic'].'&idEntreprise='.$idEntreprise.'">';
2009-03-05 16:19:38 +00:00
?><tr><td class="StyleInfoData" width="30"><b><?=$lien.$etab['Nic']?></a></b></td>
<td class="StyleInfoData" width="120"><?=$type?></td>
<td class="StyleInfoData" width="150"><?
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&eacute;l : '.$etab['Tel'].'</i>&nbsp;&nbsp;&nbsp;';
if ($etab['Fax']<>'') echo '<br/><i>Fax : '.$etab['Fax'].'</i>';
?></td>
<td class="StyleInfoData" width="260"><?=$etab['NafEtab'].' : '.$etab['NafEtabLib']?></td>
</tr><?
}
if (count($etabs)==0)
echo '<tr><td class="StyleInfoData" width="580">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Aucun &eacute;tablissement n\'est pr&eacute;sente dans notre base</td></tr>';
elseif (preg_match('/CARTES/i', $_SESSION['tabInfo']['pref']))
echo '<tr><td colspan="4">&nbsp;</td></tr><tr><td class="StyleInfoData" colspan="4" width="580" align="center"><iframe src="/?page=carte&siret='.$siren.'" width=505 height=505 marginheight="1" marginwidth="1" scrolling="No" frameborder=1></iframe></td></tr>';
?></table></td>
</tr>
</td>
</tr>
<tr>
</table>
<?php
//Exportation des donn<6E>es sous forme de fichier
function htmldecode($value){
$value = is_array($value) ? array_map('htmldecode', $value) : html_entity_decode($value, ENT_QUOTES, 'UTF-8');
return $value;
}
2009-03-05 16:19:38 +00:00
$firephp->log($etabs,'Etablissements');
$tabForExport = htmldecode($etabs);
//@TODO a tester
2009-03-06 17:12:26 +00:00
if(count($tabForExport)>0){
require_once(realpath(dirname(__FILE__).'/../../includes/').'/export.php');
$array2csv = new ExportCSV();
$array2csv->records = $tabForExport;
$array2csv->writeCSV($fileName);
$array2xml = new ExportXML();
$array2xml->rootName = $page.'s';
$array2xml->defaultTagName = $page;
2009-03-06 17:12:26 +00:00
$array2xml->records = $tabForExport;
$array2xml->writeXML($fileName);
}
2009-03-05 16:19:38 +00:00
}//Fin test mise en cache
$cache->stopCapture(); //On arrete la capture pour le cache
?>