extranet/www/pages/annonces.php
2009-09-23 14:37:18 +00:00

426 lines
13 KiB
PHP

<?php
if (!$_SESSION['connected']) die();
require_once 'cache/cache.php';
require_once 'partenaires/classMTva.php';
require_once 'partenaires/classMMap.php';
require_once 'partenaires/classMCoface.php';
require_once 'common/dates.php';
$siret = trim(preg_replace('/[^0-9]/', '', $_REQUEST['siret']));
if (strlen($siret)<>0 && strlen($siret)<>9 && strlen($siret)<>14) die('Paramètres incorrects !');
if (isset($_REQUEST['idan']) && $_REQUEST['idan']*1!=0) $idan = $_REQUEST['idan'];
else $idan = false;
if (($siret*1)==0 && $idan==0) die('Paramètres incorrects !');
$siren=substr($siret,0,9);
//annonces&action=logon&login=mederic&checkIp=only&siret=552144503&id=6415277&vue=bodacc
$idEntreprise = $_REQUEST['idEntreprise'];
isset($_REQUEST['vue'])? $vue = $_REQUEST['vue'] : $vue = '';
$action=$_REQUEST['action'];
$message='';
if ($action<>'' && $action<>'logon') die('Paramètres incorrects !');
//Générer un nom de fichier pour le cache et l'export des fichiers
if (($siret*1)==0 || ($siren*1)<100){ $fileName = $page2.'-'.$idEntreprise;
}else{ $fileName = $page2.'-'.$siret; }
if($vue!=''){$fileName.= '-'.$idan;}
cache_filename($fileName);
if( cache_exist() && !( preg_match('/saisie/i', $_SESSION['tabInfo']['droits']) || $_SESSION['tabInfo']['mode_edition']==1 ) ){
$annonces = cache_get('annonces');
//Affichage d'un message d'erreur
if($annonces === FALSE) exit;
$firephp->info('CACHE');
}else{
try {
if ($vue=='bodacc' || $_REQUEST['source']==1) $filtre=1;
elseif ($vue=='balo') $filtre=2;
elseif ($vue=='asso') $filtre=3;
else $filtre=0;
if ($_SESSION['tabInfo']['entrep']['fj']>9000 && $_SESSION['tabInfo']['entrep']['fj']<9999 && $siren==0)
{
$filtre=3;
}
$O = $client->getAnnonces($siren, $filtre, $idan);
$annonces = $O['result'];
cache_delete();
cache_add('annonces', $annonces);
$firephp->log($annonces, 'annonces');
if (count($annonces)==0) {
$idan = 0;
}
} catch (SoapFault $fault) {
require_once 'soaperror.php';
processSoapFault($client,$fault,$_SESSION['tabInfo']);
die();
}
}
if ($siren != $_SESSION['tabInfo']['entrep']['siren']) {
$O2 = $client->getIdentite($siret);
$etab = $O2['result'];
$tabEntrep = array();
$tabEntrep['raisonSociale'] = $etab['Nom'];
$tabEntrep['siren'] = $etab['Siren'];
$tabEntrep['siret'] = $etab['Siret'];
$tabEntrep['tva'] = $etab['TvaNumero'];
$tabEntrep['isin'] = $etab['Isin'];
$tabEntrep['AutreId'] = $etab['AutreId'];
$tabEntrep['active'] = $etab['Statut'];
$tabEntrep['Source'] = $etab['Source'];
$tabEntrep['SourceId'] = $etab['SourceId'];
$tabEntrep['codeCommune'] = $etab['Dept'].$etab['codeCommune'];
$tabEntrep['nafEn'] = $etab['NafEnt'];
$tabEntrep['nafEt'] = $etab['NafEtab'];
$tabEntrep['fj'] = $etab['FJ'];
$_SESSION['tabInfo']['entrep'] = $tabEntrep;
$raisonSociale = $etab['Nom'];
} else
$raisonSociale = $_SESSION['tabInfo']['entrep']['raisonSociale'];
?>
<div id="center">
<h1 class="titre">ANNONCES L&Eacute;GALES</h1>
<table>
<?php if ($message<>'') { ?>
<tr>
<td width="30">&nbsp;</td>
<td width="550" colspan="3" class="StyleInfoData"><h3><?=$message;?></h3></td>
</tr>
<?php }?>
<tr>
<td width="30">&nbsp;</td>
<td width="200" colspan="2" 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" colspan="2" class="StyleInfoLib">Raison Sociale</td>
<td width="350" class="StyleInfoData"><?=$raisonSociale?></td>
</tr>
</table>
<?php
if ($idan && ($vue=='bodacc' || $vue=='abod' || $vue=='balo' || $vue=='asso'))
{
$ann = $annonces[0];
/** AFFICHAGE D'UNE ANNONCE BODACC / BALO / ASSO **/
// Entête BALO
if ($vue=='balo')
{
?>
<h2>BALO</h2>
<table>
<tr>
<td width="30">&nbsp;</td>
<td width="550" colspan="3" class="StyleInfoData">
BALO n&deg;<?=$ann['BodaccNum']?>&nbsp;du <?=WDate::dateT('Y-m-d','d/m/Y',$ann['DateParution'])?>. Entr&eacute; n&deg;<?=$ann['NumAnnonce']?>. Entr&eacute;e en base S&amp;D : <?=WDate::dateT('Y-m-d','d/m/Y',$ann['dateInsertionSD'])?>.<br/>
<a href="/?page=annonces&siret=<?=$siret?>&idan=<?=$_REQUEST['idan']?>&vue=balo&mode=pdf" target="_blank">Cliquez ici pour voir cette annonce au format PDF&nbsp;(<?=adapteOCtets(@filesize(PATH_DATA.'/jo/balo/'.WDate::dateT('Y-m-d','Y',$ann['DateParution']).'/'. $ann['Lien_Annonce_Pdf']))?>)</a>
.</td>
</tr>
<tr>
<td width="30">&nbsp;</td>
<td width="550" colspan="3" class="StyleInfoLib"><b><?=$ann['Categorie']?></b></td>
</tr>
<tr>
</table>
<?php
$ann['texteAnnonce']=utf8_decode($ann['texteAnnonce']);
}
elseif ($vue=='bodacc' || $vue=='abod')
{
?>
<h2>&Eacute;V&Eacute;NEMENTS L&Eacute;GAUX</h2>
<table>
<tr>
<td width="30">&nbsp;</td>
<td width="550" colspan="3" class="StyleInfoData">
<?php
$tabSource=explode('-', $ann['BodaccCode']);
$source=$tabSource[0];
$idSource=@$tabSource[1];
if ($source[0] == 'B'){
if ($ann['BodaccNum']==0)
print '<img src="./img/logo_jo.png"/>&nbsp;&nbsp;Source BODACC '.substr($ann['BodaccCode'],-1).' du '.WDate::dateT('Y-m-d','d/m/Y',$ann['DateParution']);
else
print '<img src="./img/logo_jo.png"/>&nbsp;&nbsp;&nbsp;Source BODACC n&deg;'.$ann['BodaccNum'].'&nbsp;'.substr($ann['BodaccCode'],-1).' du '.WDate::dateT('Y-m-d','d/m/Y',$ann['DateParution']).'. D&eacute;partement n&deg;'.$ann['Departement'].'. <a href="/?page=competences&siret='.$siret.'&type=tri">'.$ann['Tribunal'].'</a>';
}elseif ($source[0] == 'G' || $source[0] == 'T'){
print '<img src="./img/logo_greffe.png"/>&nbsp;&nbsp;Source Greffe du Tribunal';
}elseif ($source[0] == 'P'){
print '<img src="./img/logo_inpi.png"/>&nbsp;&nbsp;Source Registre National du Commerce';
}else{
print '<img src="./img/logo_jal.png"/>&nbsp;&nbsp;Source Journal Annonces L&eacute;gales';
}
if ($ann['dateInsertionSD']<>'') echo ' Entr&eacute;e en base : '. WDate::dateT('Y-m-d','d/m/Y',$ann['dateInsertionSD']);
?>
</td>
</tr>
</table>
<?php
}
elseif ($vue=='asso')
{
?>
<h2>Associations</h2>
<table>
<tr>
<td width="30">&nbsp;</td>
<td width="550" colspan="3" class="StyleInfoData">J.O. ASSOCIATION n&deg;<?=$ann['BodaccNum']?>&nbsp;du <?=WDate::dateT('Y-m-d','d/m/Y',$ann['DateParution'])?>. Annonce n&deg;<?=$ann['NumAnnonce']?>. Entr&eacute;e en base S&amp;D : <?=WDate::dateT('Y-m-d','d/m/Y',$ann['dateInsertionSD'])?>.</td>
</tr>
</table>
<?php
}
?>
<table>
<tr>
<td width="30">&nbsp;</td>
<td width="550" colspan="3" class="StyleInfoLib">
<b>
<?php
foreach (@$ann['evenements'] as $i=>$even) { echo @$even['LibEven'].'<br/>'; }
?>
</b>
</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td width="30">&nbsp;</td>
<?php
/**Affichage du texte de l'annonce**/
$texte=preg_replace_callback("/((?:[0-9]{9,9})|(?:[0-9]{3,3} [0-9]{3,3} [0-9]{3,3})|(?:[0-9]{3,3}\.[0-9]{3,3}\.[0-9]{3,3})|(?:[0-9]{3,3}-[0-9]{3,3}-[0-9]{3,3}))/", replace_siren, $ann['texteAnnonce']);
?>
<td width="550" colspan="3"><code><?=$texte?></code></td>
</tr>
<tr><td colspan="4">&nbsp;</td></tr>
<tr>
<td colspan="4" align="center" class="StyleInfoData"><a href="Javascript:history.back()">Revenir à la liste des annonces</a></td>
</tr>
</table>
<?php
}
elseif (count($annonces)>0)
{
//Tri des annonces dans des tableaux différents
$annoncesBodacc = array();
$annoncesBalo = array();
$annoncesAsso = array();
foreach ($annonces as $i => $ann) {
if ($ann['BodaccCode']=='BODA' || $ann['BodaccCode']=='BODB' || $ann['BodaccCode']=='BODC') {
$annoncesBodacc[] = $ann;
}elseif ($ann['BodaccCode']=='BALO') {
$annoncesBalo[] = $ann;
}elseif ($ann['BodaccCode']=='ASSO') {
$annoncesAsso[] = $ann;
}else {
$annoncesBodacc[] = $ann;
}
}
/** Affichage de la liste des annonces **/
//Affiche annonces Bodacc
if (count($annoncesBodacc)>0)
{
?>
<h2>EV&Eacute;NEMENTS L&Eacute;GAUX</h2>
<table>
<?php
foreach($annoncesBodacc as $i => $ann)
{
?>
<tr>
<td width="30">&nbsp;</td>
<td width="140" class="StyleInfoLib">
<div id="annoncesDate"><p>Le <?=WDate::dateT('Y-m-d','d/m/Y',$ann['DateParution']);?></p></div>
<div id="annoncesImg">
<?php
$tabSource=explode('-', $ann['BodaccCode']);
$source=$tabSource[0];
$idSource=@$tabSource[1];
if ($source[0] == 'B'){
print '<img src="./img/logo_jo.png" title="Source BODACC '.$ann['BodaccNum'].' '.substr($source,-1).' '.substr($ann['DateParution'],0,4).'"/>';
}elseif ($source[0] == 'G' || $source[0] == 'T'){
print '<img src="./img/logo_greffe.png" title="Source Collecte Greffe"/>';
}elseif ($source[0] == 'P'){
print '<img src="./img/logo_inpi.png" title="Source Collecte RNCS"/>';
}else{
print '<img src="./img/logo_jal.png" title="Source Collecte JAL';
if ($idSource>0) print ' $idSource';
print '"/>';
}
?>
</div>
</td>
<td width="450" colspan="2" class="StyleInfoData">
<a href="/?page=annonces&siret=<?=$siret?>&idan=<?=$ann['id']?>&vue=bodacc">
<?php
foreach ($ann['evenements'] as $i=>$even) {
print $even['LibEven'];
$numEven=$even['CodeEven']*1;
if ($numEven>3000 && $numEven<3999) print ' (clôture au '.WDate::dateT('Y-m-d','d/m/Y',$ann['dateEffet']).')';
print '<br/>';
}
?>
</a>
</td>
</tr>
<?php
}
?>
</table>
<?php
}
//Affiche annonces Balo
if (count($annoncesBalo)>0)
{
?>
<h2>BALO</h2>
<table>
<?php
foreach($annoncesBalo as $i => $ann){?>
<tr>
<td width="30">&nbsp;</td>
<td width="140" class="StyleInfoLib">
<span id="annoncesDate">Le <?=WDate::dateT('Y-m-d','d/m/Y',$ann['DateParution']);?></span>
<span id="annoncesImg">
<?php
if ($ann['BodaccCode'] == 'BALO'){
print '<img src="./img/logo_jo.png" title="Source BALO n°'.$ann['BodaccNum'].'"/>';
}
?>
</span>
</td>
<td width="450" colspan="2" class="StyleInfoData">
<a href="/?page=annonces&siret=<?=$siret?>&idan=<?=$ann['id']?>&vue=balo">
<?php
foreach ($ann['evenements'] as $i=>$even) {
print $even['LibEven'];
$numEven=$even['CodeEven']*1;
if ($numEven>3000 && $numEven<3999) print ' (clôture au '.WDate::dateT('Y-m-d','d/m/Y',$ann['dateEffet']).')';
print '<br/>';
}
?>
</a></td>
</tr>
<?php
}
?>
</table>
<?php
}
//Affiche annonces Asso
if (count($annoncesAsso)>0)
{
?>
<h2>Associations</h2>
<table>
<?php
foreach($annoncesAsso as $i => $ann){ ?>
<tr>
<td width="30">&nbsp;</td>
<td width="140" class="StyleInfoLib">
<span id="annoncesDate">Le <?=WDate::dateT('Y-m-d','d/m/Y',$ann['DateParution']);?></span>
<span id="annoncesImg">
<?php
if ($ann['BodaccCode'] == 'ASSO'){
print '<img src="./img/logo_jo.png" title="Source JO ASSOCIATION n°'.$ann['BodaccNum'].'"/>';
}
?>
</span>
</td>
<td width="450" colspan="2" class="StyleInfoData">
<a href="/?page=annonces&siret=<?=$siret?>&idan=<?=$ann['id']?>&vue=asso">
<?php
foreach ($ann['evenements'] as $i=>$even) {
print $even['LibEven'];
$numEven=$even['CodeEven']*1;
if ($numEven>3000 && $numEven<3999) print ' (clôture au '.WDate::dateT('Y-m-d','d/m/Y',$ann['dateEffet']).')';
print '<br/>';
}
?>
</a></td>
</tr>
<?php
}
?>
</table>
<?php
}
}
else
{
/** Aucune annonce bodacc pour cette entreprise **/
?>
<h2>Evénements légaux</h2>
<table>
<tr>
<td width="30">&nbsp;</td>
<td width="100" class="StyleInfoLib">&nbsp;</td>
<td width="450" colspan="2" class="StyleInfoData">N&eacute;ant</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
</table>
<?php
}
require_once 'export.php';
$parseTab = new tabExport();
$parseTab->tab = $annonces;
$parseTab->notdisplay = array('id');
$parseTab->title = array(
'BodaccCode'=>'Code Bodacc',
'BodaccNum'=>'Numéro Bodacc',
'NumAnnonce'=>'Numéro annonce',
'DateParution'=>'Date de parution',
'TribunalSiret'=>'Siret du tribunal',
'typeAnnonce'=>'Type annonce',
'texteRectificatif'=>'Texte rectificatif',
'texteAnnonce'=>'Texte annonce',
'dateEffet'=>'Date effet',
'dateJugement'=>'Date jugement',
'dateInsertionSD'=>'Date insertion',
'evenements'=>'Evenements',
);
$parseTab->type = array();
$tabForExport = $parseTab->convertTable();
$array2csv = new ExportCSV();
$array2csv->records = $tabForExport;
$array2csv->writeCSV($fileName);
$tabForExport = $annonces;
$array2xml = new ExportXML();
$array2xml->rootName = $page.'s';
$array2xml->defaultTagName = $page;
$array2xml->records = $tabForExport;
$array2xml->writeXML($fileName);
if (!$idan)
{
?>
<table>
<tr>
<td width="30">&nbsp;</td>
<td colspan="3" width="550" class="StyleInfoData">
<?php
require_once 'surveillance/surveillance.php';
print getSurveillance($page, $siret);
?>
</td>
</tr>
</table>
<?php
}
?>
</div>