extranet/www/pages/bdf.php
2010-03-23 16:09:05 +00:00

135 lines
3.1 KiB
PHP

<?php
?>
<script>
$(document).ready(function(){
$('#listeModulesD').click(function(){
var display = $('#listeModules').css('display');
if(display=='none') $('#listeModules').css('display', 'block');
else $('#listeModules').css('display', 'none');
});
$('.lienModule').click(function(){
var value = $('input[name=req]').val();
var href = $(this).attr('href');
if(value!='') { $(this).attr('href', href+'&req='+value ); return true; }
else{ alert('Aucun identifiant saisi!'); return false; }
});
});
</script>
<div id="center">
<?php
if( $module=='autres' || $module=='' )
{
?>
<h1>Modules</h1>
<h2>Liste des modules FIBEN / FCC</h2>
<div class="blockh2">
<form name="rFibenM" method="post" action="#">
<label>Identifiant</label> <input type="text" name="req" value="<?=$req?>"/>
<span>SIREN ou clé BDF</span><br/>
<a href='#' id="listeModulesD">Afficher/masquer la liste des modules</a>
<ul id="listeModules">
<?php
$listModules = bdf_modules_fiben();
foreach ($listModules as $id => $module) {
if (isset($module['liste']) == false || $module['liste'] !== false) {
print '<li><a href="./?page=bdf'.
'&siret='.$siret.
'&module='.$id.
'" class="lienModule">'.$module['titre'].'</a></li>';
}
}
$listModules = bdf_modules_fcc();
foreach ($listModules as $id => $module) {
if (isset($module['liste']) == false || $module['liste'] !== false) {
print '<li><a href="./?page=bdf'.
'&siret='.$siret.
'&service=fcc'.
'&module='.$id.
'" class="lienModule">'.$module['titre'].'</a></li>';
}
}
?>
</ul>
</form>
</div>
<br/>
<h2>Recherche FICP</h2>
<div class="blockh2">
<form name="rFicp" method="post" action="./?page=bdf">
<input type="hidden" name="module" value="G"/>
<input type="hidden" name="service" value="ficp"/>
<label>Clé BDF</label>
<input type="text" name="req"/>
<input type="submit" name="rFicp" value="Ok"/>
</form>
</div>
<?php
}
else
{
$firephp->log($service, 'service');
$firephp->log($module, 'module');
$func_module = 'bdf_modules_'.$service;
$listModules = $func_module();
//Vérifier que le module existe
if(array_key_exists($module, $listModules))
{
$rech = array();
$rech = array(
'denom' => $denom,
'type' => $type,
'code' => $code,
'rechet' => $rechet,
'ape' => $ape,
);
$url = bdf_lien_module($module, $service, $req, $rech);
if($module=='07'){
$filename = false;
}
else
{
$filename = PATH_DATA.'/bdf/bdf_'.$service.'_'.$req.'_'.$module.'.html';
}
if($filename!==false && file_exists($filename))
{
$content = file_get_contents($filename);
}
else
{
$content = trim(bdf_loadpage($url));
if( !empty($content) && $filename!==false )
{
if(!file_exists(PATH_DATA.'/bdf')) mkdir(PATH_DATA.'/bdf');
file_put_contents($filename, $content);
}
}
}
$titreModule = $listModules[$module]['titre'];
?>
<h1>Module <?=$titreModule?></h1>
<div class="blockh2">
<?php
if(!empty($content))
{
echo $content;
}else{
echo 'ERREUR';
}
?>
</div>
<?php
}
?>
</div>
<?php