<?php
if (!$_SESSION['connected'])
	echo ('Vous devez être connecté afin de pouvoir utiliser cette fonctionnalité');
else
{

$tabInfo = $_SESSION['tabInfo'];
$siret = trim(preg_replace('/[^0-9]/', '', $_REQUEST['siret']));
if (strlen($siret)<>0 && strlen($siret)<>9 && strlen($siret)<>14)	die('Paramètres incorrects !');

$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 !');
$siren=substr($siret,0,9);

if (isset($_REQUEST['idEntreprise']) && $_REQUEST['idEntreprise']*1<>0)	$idCom=$_REQUEST['idEntreprise'];
else												$idCom=false;

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';

if (($siret*1)==0 || ($siren*1)<100){ $fileName = $page2.'-'.$idEntreprise;
}else{ $fileName = $page2.'-'.$siret; }

cache_filename($fileName);
if( cache_exist() && !( preg_match('/\bsaisie\b/i', $_SESSION['tabInfo']['droits']) || $_SESSION['tabInfo']['mode_edition']==1 ) ){
	$conventions = cache_get('conventions');
	$firephp->info('CACHE');
}else{
	try {
		$O = $client->getListeConventions($siren);
		$conventions = $O['result'];
		cache_delete();
		cache_add('conventions', $conventions);
	} catch (SoapFault $fault) {
		require_once 'soaperror.php';
		processSoapFault($client,$fault,$tabInfo);
	    die();
	}
}

$raisonSociale=$tabInfo['entrep']['raisonSociale'];
?>
<div id="center">
<h1 class="titre">CONVENTIONS COLLECTIVES APPLICABLES</h1>

<table border="0" align="left">
<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>
<tr>
	<td width="30">&nbsp;</td>
	<td width="550" colspan="3">&nbsp;</td>
</tr>
</table>

<h2>Conventions collectives</h2>
<table>
<?

if (count($conventions)>0)
{
	foreach ($conventions as $i=>$conv)
	{
?>
<tr>
	<td colspan="4">
	<table>
	<tr>
		<td width="20">&nbsp;</td>
		<td width="90"  class="StyleInfoData"><u><a href="http://www.legifrance.gouv.fr/rechConvColl.do?champActivite=&champIDCC=&champNumeroBrochure=<?=substr($conv['idCC'],0,4)?>&bouton=Rechercher" target="_blank">Brochure <?=substr($conv['idCC'],0,4)?></a></u></td>
		<td width="300" class="StyleInfoData"><b><?=$conv['nomCC']?></b>
		</td>
		<td class="StyleInfoData"><font size="1"><i>Journal Officiel
		<?php
		if (trim($conv['dateCC'])<>'')	echo ', '.$conv['dateCC'];
		if (trim($conv['nbPageCC'])*1>0)	echo ', '.$conv['nbPageCC'].' pages.';
		if (trim($conv['isbnCC'])<>'')	echo '<br/>ISBN '.$conv['isbnCC'];
		?>
		</i></font></td>
	</tr>
	</table>
	<hr width="80%"/>
	</td>
</tr>
<?
	}
} else {
	/** Aucune Info Réglementée pour cette entreprise **/
?>
<tr>
	<td width="30">&nbsp;</td>
	<td width="100" class="StyleInfoLib">&nbsp;</td>
	<td colspan="2" class="StyleInfoData">N&eacute;ant</td>
</tr>
<tr>
	<td colspan="4">&nbsp;</td>
</tr>
<?
}
}
?>
<tr>
	<td colspan="4">&nbsp;</td>
</tr>
</table>
</div>