83 lines
2.7 KiB
PHP
83 lines
2.7 KiB
PHP
<?php
|
|
session_start();
|
|
require_once 'common/dates.php';
|
|
require_once 'common/curl.php';
|
|
|
|
isset($_REQUEST['q'])? $nomFic = $_REQUEST['q'] : $nomFic = '';
|
|
isset($_REQUEST['page'])? $page = $_REQUEST['page'] : $page = '';
|
|
|
|
$nbAnnoncesMin = ($page-1)*100;
|
|
$nbAnnoncesMax = $nbAnnoncesMin+100;
|
|
|
|
if($nomFic == ''){
|
|
print 'Impossible de générer le document.';
|
|
}else{
|
|
|
|
require_once 'surveillance/survliste.php';
|
|
$file = PATH_DATA.'/pdf/'.$nomFic;
|
|
$file2 = $file.'.bz2';
|
|
if (!file_exists($file)) {
|
|
$page = getUrl(WEBSERVICE_URI.'csv/'.$nomFic.'.bz2', '', '', '', false);
|
|
$body = $page['body'];
|
|
$fp=@fopen($file2, 'w');
|
|
@fwrite($fp, $body);
|
|
@fclose($fp);
|
|
$bz = bzopen($file2, "r") or die("Impossible d'ouvrir le fichier $file");
|
|
$fp=@fopen($file, 'w');
|
|
while (!feof($bz)) {
|
|
@fwrite($fp, bzread($bz, 4096));
|
|
}
|
|
bzclose($bz);
|
|
}
|
|
|
|
$annonces = readann($file, '');
|
|
|
|
$output = '';
|
|
$count = 0;
|
|
$nbAnnonces = count($annonces);
|
|
if($nbAnnonces>0){
|
|
foreach($annonces as $annonce){
|
|
if($count>$nbAnnoncesMax) break;
|
|
if($count>$nbAnnoncesMin){
|
|
$output.= '<page backtop="10mm" backbottom="10mm">';
|
|
$output.= '<page_header>';
|
|
$output.= '<table style="width:100%; border:solid 1px black;">';
|
|
$output.= '<tr>';
|
|
$output.= '<td style="text-align:left; width:67%">Surveillance : '.$count.'/'.$nbAnnonces.'</td>';
|
|
$output.= '<td style="text-align:right; width:33%">'.date('d/m/Y').'</td>';
|
|
$output.= '</tr>';
|
|
$output.= '</table>';
|
|
$output.= '</page_header>';
|
|
$output.= '<table style="width:100%;">';
|
|
$output.= '<tr>';
|
|
$output.= '<td style="width:50%;">Entreprise : '.$annonce['RaisonSociale'].' ('.$annonce['Siren'].')</td>';
|
|
$output.= '<td style="width:50%;"> </td>';
|
|
$output.= '</tr>';
|
|
$output.= '<tr>';
|
|
$output.= '<td style="width:50%;">Site : '.$annonce['SiteCnasea'].'</td>';
|
|
$output.= '<td style="width:50%;">Référence : '.$annonce['Ref'].'</td>';
|
|
$output.= '</tr>';
|
|
$output.= '<tr>';
|
|
$output.= '<td style="width:100%;" colspan="2">BODACC n°'.$annonce['Parution'].' '.$annonce['Bodacc'].' du '.$annonce['DatePar'].' '.$annonce['Tribunal'].'.</td>';
|
|
$output.= '</tr>';
|
|
$output.= '<tr><td style="width:100%;" colspan="2"> </td></tr>';
|
|
$output.= '<tr>';
|
|
$output.= '<td style="width:100%;" colspan="2"><b>'.$annonce['Even'].'</b></td>';
|
|
$output.= '</tr>';
|
|
$output.= '<tr>';
|
|
$output.= '<td style="width:100%;" colspan="2">'.$annonce['TexteAnn'].'</td>';
|
|
$output.= '</tr>';
|
|
$output.= '</table>';
|
|
$output.= '</page>';
|
|
}
|
|
$count++;
|
|
}
|
|
}
|
|
// conversion HTML => PDF
|
|
require_once 'html2pdf/html2pdf.class.php';
|
|
$html2pdf = new HTML2PDF('P','A4','fr');
|
|
$html2pdf->WriteHTML($output);
|
|
$html2pdf->Output(str_replace('.csv', '.pdf', $nomFic), 'D');
|
|
}
|
|
|
|
?>
|