extranet/www/html2pdf.php

97 lines
3.3 KiB
PHP
Raw Normal View History

<?php
require_once 'common/dates.php';
require_once 'common/curl.php';
isset($_REQUEST['q'])? $nomFic = $_REQUEST['q'] : $nomFic = '';
2009-06-23 13:21:46 +00:00
isset($_REQUEST['page'])? $page = $_REQUEST['page'] : $page = '';
(isset($_REQUEST['filtre']) && $_REQUEST['filtre']!='') ? $filtre = $_REQUEST['filtre'] : $filtre = '';
2009-06-23 13:21:46 +00:00
$nbAnnoncesMin = ($page-1)*100;
$nbAnnoncesMax = $nbAnnoncesMin+100;
if($nomFic == ''){
print 'Impossible de g<>n<EFBFBD>rer le document.';
}else{
require_once 'surveillance/survliste.php';
$file = PATH_DATA.'/survliste/'.$nomFic;
2009-06-23 13:21:46 +00:00
$file2 = $file.'.bz2';
if (!file_exists($file)) {
//G<>n<EFBFBD>ration du fichier
try {
$O = $client->getListeFichierSurv($_SESSION['tabInfo']['login'], $_SESSION['tabInfo']['prenom'], $nomFic);
} catch (SoapFault $fault) {
require_once 'soaperror.php';
processSoapFault($client,$fault,$tabInfo);
}
2009-06-23 13:21:46 +00:00
$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));
}
2009-06-23 13:21:46 +00:00
bzclose($bz);
}
$annonces = readann($file, $filtre);
$output = '';
$count = 0;
2009-06-23 13:26:42 +00:00
$nbAnnonces = count($annonces);
2009-07-07 09:24:04 +00:00
2009-06-23 13:26:42 +00:00
if($nbAnnonces>0){
foreach($annonces as $annonce){
2009-06-23 13:46:37 +00:00
if($count>$nbAnnoncesMax) break;
2009-07-07 09:24:04 +00:00
if($count>=$nbAnnoncesMin){
2009-06-23 13:26:42 +00:00
$output.= '<page backtop="10mm" backbottom="10mm">';
$output.= '<page_header>';
$output.= '<table style="width:100%; border:solid 1px black;">';
$output.= '<tr>';
2009-06-23 13:46:37 +00:00
$output.= '<td style="text-align:left; width:67%">Surveillance : '.$count.'/'.$nbAnnonces.'</td>';
2009-06-23 13:26:42 +00:00
$output.= '<td style="text-align:right; width:33%">'.date('d/m/Y').'</td>';
$output.= '</tr>';
$output.= '</table>';
$output.= '</page_header>';
2009-06-23 13:21:46 +00:00
$output.= '<table style="width:100%;">';
$output.= '<tr>';
$output.= '<td style="width:50%;">Entreprise : '.$annonce['RaisonSociale'].' ('.$annonce['Siren'].')</td>';
$output.= '<td style="width:50%;">&nbsp;</td>';
$output.= '</tr>';
$output.= '<tr>';
$output.= '<td style="width:50%;">Site : '.$annonce['SiteCnasea'].'</td>';
$output.= '<td style="width:50%;">R<>f<EFBFBD>rence : '.$annonce['Ref'].'</td>';
$output.= '</tr>';
$output.= '<tr>';
$output.= '<td style="width:100%;" colspan="2">BODACC n&deg;'.$annonce['Parution'].'&nbsp;'.$annonce['Bodacc'].' du '.$annonce['DatePar'].' '.$annonce['Tribunal'].'.</td>';
$output.= '</tr>';
$output.= '<tr><td style="width:100%;" colspan="2">&nbsp;</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++;
}
}else{
/*
* Fermenture la balise page lorsqu'il n'y a aucune annonce
* afin de g<EFBFBD>n<EFBFBD>rer un fichier pdf vide et non pas une erreur
*/
$output = '</page>';
}
// 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');
}
?>