Ajout export de la liste des surveillances sous forme pdf

This commit is contained in:
Michael RICOIS 2009-06-16 14:19:33 +00:00
parent 1d854d1e43
commit d8d20a41a3
3 changed files with 236 additions and 183 deletions

95
www/html2pdf.php Normal file
View File

@ -0,0 +1,95 @@
<?php
session_start();
require_once 'common/dates.php';
require_once 'common/curl.php';
isset($_REQUEST['q'])? $nomFic = $_REQUEST['q'] : $nomFic = '';
if($nomFic == ''){
print 'Impossible de générer le document.';
}else{
require_once 'surveillance/survliste.php';
$client = new SoapClient(null, array( 'trace' => 1,
'soap_version' => SOAP_1_1,
'location' => WEBSERVICE_URL,
'uri' => WEBSERVICE_URI,
'login' => $_SESSION['tabInfo']['login'],
'password' => $_SESSION['tabInfo']['password'],
));
try {
$O = $client->getListeFichierSurv($_SESSION['tabInfo']['login'], $_SESSION['tabInfo']['prenom'], $nomFic);
$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);
}
} catch (SoapFault $fault) {
require_once 'soaperror.php';
processSoapFault($client,$fault,$tabInfo);
exit;
}
$annonces = readann($file, '');
$output = '';
$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: center; width: 67%">'.$nomFic.'</td>';
$output.= '<td style="text-align: right; width: 33%">'.date('d/m/Y').'</td>';
$output.= '</tr>';
$output.= '</table>';
$output.= '</page_header>';
$output.= '<page_footer>';
$output.= '<table style="width: 100%; border: solid 1px black;">';
$output.= '<tr>';
$output.= '<td style="text-align: left; width: 50%">&nbsp;</td>';
$output.= '<td style="text-align: right; width: 50%">page [[page_cu]]/[[page_nb]]</td>';
$output.= '</tr>';
$output.= '</table>';
$output.= '</page_footer>';
$count = 0;
foreach($annonces as $annonce){
if ($count>0) $output.= '<page>';
$output.= '<table width="580">'."\n";
$output.= '<tr><td width="30">&nbsp;</td>'."\n";
$output.= ' <td width="550" colspan="2" class="StyleInfoLib">Entreprise : '.$annonce['RaisonSociale'].' ('.$annonce['Siren'].')</td>'."\n";
$output.= '</tr>'."\n";
$output.= '<tr><td width="30">&nbsp;</td>'."\n";
$output.= ' <td width="200" class="StyleInfoData">Site : '.$annonce['SiteCnasea'].'</td>'."\n";
$output.= ' <td width="350" colspan="2" class="StyleInfoData">Référence : '.$annonce['Ref'].'</td>'."\n";
$output.= '</tr>'."\n";
$output.= '<tr><td width="30">&nbsp;</td>'."\n";
$output.= ' <td width="550" colspan="2" class="StyleInfoData">BODACC n&deg;'.$annonce['Parution'].'&nbsp;'.$annonce['Bodacc'].' du '.$annonce['DatePar'].' '.$annonce['Tribunal'].'.</td>'."\n";
$output.= '</tr>'."\n";
$output.= '<tr><td width="30">&nbsp;</td>'."\n";
$output.= ' <td width="550" colspan="2" class="StyleInfoLib"><b>'.$annonce['Even'].'</b></td>'."\n";
$output.= '</tr>'."\n";
$output.= '<tr><td colspan="4">&nbsp;</td></tr>'."\n";
$output.= '<tr><td width="30">&nbsp;</td>'."\n";
$output.= ' <td width="550" colspan="2">'.$annonce['TexteAnn'].'</td>'."\n";
$output.= '</tr>'."\n";
$output.= '</table>'."\n";
$output.= '</page>'."\n";
$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');
}
?>

View File

@ -1,5 +1,5 @@
<? <?
include_once(FWK_PATH.'/common/dates.php'); require_once 'common/dates.php';
$siret=trim(preg_replace('/[^0-9]/', '', $_REQUEST['siret'])); $siret=trim(preg_replace('/[^0-9]/', '', $_REQUEST['siret']));
$idEntreprise=trim(preg_replace('/[^0-9]/', '', $_REQUEST['idEntreprise']))*1; // Si id=0 alors non communiqué $idEntreprise=trim(preg_replace('/[^0-9]/', '', $_REQUEST['idEntreprise']))*1; // Si id=0 alors non communiqué
@ -8,74 +8,70 @@ $siren=substr($siret,0,9);
if (!$_SESSION['connected']) if (!$_SESSION['connected'])
echo ('Vous devez être connecté afin de pouvoir utiliser cette fonctionnalité'); echo ('Vous devez être connecté afin de pouvoir utiliser cette fonctionnalité');
else { else {
if (isset($_REQUEST['nomFic'])) $nomFic = $_REQUEST['nomFic'];
else $nomFic = ''; isset($_REQUEST['nomFic'])? $nomFic = $_REQUEST['nomFic'] : $nomFic='' ;
$ref=$_SESSION['tabInfo']['prenom']; //Génération liste surveillance
if (strtolower($_SESSION['tabInfo']['login'])=='cnasea95' || $ref = $_SESSION['tabInfo']['prenom'];
strtolower($_SESSION['tabInfo']['login'])=='cnasea96' || if ( strtolower($_SESSION['tabInfo']['login'])=='cnasea95' ||
$_SESSION['tabInfo']['idClient']==32) strtolower($_SESSION['tabInfo']['login'])=='cnasea96' ||
$ref='*'; $_SESSION['tabInfo']['idClient']==32
/* ) $ref='*';
if ($_SERVER['REMOTE_ADDR']=='83.206.102.217')
$ref='*';*/
try { try {
$O = $client->getListeFichierSurv($_SESSION['tabInfo']['login'], $ref, $nomFic); $O = $client->getListeFichierSurv($_SESSION['tabInfo']['login'], $ref, $nomFic);
//if ($O['result']==1) $message='Informations mises à jour !';
//print_r($O);
$tabFichier=$O['results']; $tabFichier=$O['results'];
} catch (SoapFault $fault) { } catch (SoapFault $fault) {
include_once(realpath(dirname(__FILE__).'/../../').'/includes/soaperror.php'); require_once 'soaperror.php';
processSoapFault($client,$fault,$tabInfo); processSoapFault($client,$fault,$tabInfo);
} }
echo '<!--';print_r($tabInfos);echo '-->';
} }
?> ?>
<table width="580" border="0" align="left" bgcolor="#FFFFFF"> <table width="580" border="0" align="left" bgcolor="#FFFFFF">
<tr> <tr><td colspan="3"><img src="./img/rub_identite.png" width="577" height="36"></td></tr>
<td colspan="3"><img src="./img/rub_identite.png" width="577" height="36"></td> <tr>
</tr> <td width="30">&nbsp;</td>
<tr> <td width="200" class="StyleInfoLib">Mon identifiant</td>
<td width="30">&nbsp;</td> <td width="350" class="StyleInfoData"><i><?=$_SESSION['tabInfo']['login']?></i></td>
<td width="200" class="StyleInfoLib">Mon identifiant</td> </tr>
<td width="350" class="StyleInfoData"><i><?=$_SESSION['tabInfo']['login']?></i></td> <tr>
</tr> <td width="30">&nbsp;</td>
<tr> <td width="200" class="StyleInfoLib">Mon identité</td>
<td width="30">&nbsp;</td> <td width="350" class="StyleInfoData"><i><?=$_SESSION['tabInfo']['nom']?></i></td>
<td width="200" class="StyleInfoLib">Mon identité</td> </tr>
<td width="350" class="StyleInfoData"><i><?=$_SESSION['tabInfo']['nom']?></i></td> <tr>
</tr> <td colspan="3">&nbsp;</td>
</tr>
<tr>
<td colspan="3"><img src="./img/srub_surveillance.png" width="576" height="27"></td>
</tr>
<?php foreach ($tabFichier as $nomFic) {?>
<tr>
<td width="30">&nbsp;</td>
<?php
$tabTmp=explode('_', $nomFic);// surveillanceBodacc_SURBODTSTFTSCNASEA_20081223.csv html
$dateFic=Wdate::dateT('Ymd','d/m/Y', substr($tabTmp[2],0,8));
$localfile = PATH_DATA.'/pdf/'.$nomFic;
if (!file_exists($localfile)) {
$dejaLu1='<b>';
$dejaLu2='</b>';
} else {
$dejaLu1='';
$dejaLu2='';
}
?>
<td width="200" colspan="2" class="lienNormal">
<?=$dejaLu1?>
Liste des annonces du <?=$dateFic?>
au format <a href="./?page=fichier&nomFic=<?=$nomFic?>" title="<?=$nomFic?>">CSV</a>
ou au format <a href="./?page=survlisteann&nomFic=<?=$nomFic?>">HTML</a>
ou au format <a href="./html2pdf.php?q=<?=$nomFic?>" target="_blank">PDF</a>
<?=$dejaLu2?>
</td>
</tr>
<? } ?>
<tr> <tr>
<td colspan="3">&nbsp;</td> <td colspan="3">&nbsp;</td>
</tr> </tr>
<tr> </table>
<td colspan="3"><img src="./img/srub_surveillance.png" width="576" height="27"></td>
</tr>
<?foreach ($tabFichier as $nomFic) {?>
<tr>
<td width="30">&nbsp;</td>
<?
$tabTmp=explode('_', $nomFic);// surveillanceBodacc_SURBODTSTFTSCNASEA_20081223.csv html
$dateFic=Wdate::dateT('Ymd','d/m/Y', substr($tabTmp[2],0,8));
$localfile = PATH_DATA.'/pdf/'.$nomFic;
if (!file_exists($localfile)) {
$dejaLu1='<b>';
$dejaLu2='</b>';
} else {
$dejaLu1='';
$dejaLu2='';
}
?>
<td width="200" colspan="2" class="lienNormal"><?=$dejaLu1?>Liste des annonces du <?=$dateFic?> au format <a href="./?page=fichier&nomFic=<?=$nomFic?>" title="<?=$nomFic?>">CSV</a><?/*if ($_SERVER['REMOTE_ADDR']=='83.206.102.217') { */?> ou au format <a href="./?page=survlisteann&nomFic=<?=$nomFic?>">HTML</a><?/*}*/?><?=$dejaLu2?>
</td>
</tr>
<?}?>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
</table>
<?php
//}
?>

View File

@ -1,14 +1,15 @@
<?php <?php
include_once(FWK_PATH.'/common/dates.php'); require_once 'common/dates.php';
include_once(FWK_PATH.'/common/curl.php'); require_once 'common/curl.php';
if (!$_SESSION['connected']) if (!$_SESSION['connected'])
echo ('Vous devez être connecté afin de pouvoir utiliser cette fonctionnalité'); echo ('Vous devez être connecté afin de pouvoir utiliser cette fonctionnalité');
else else{
{
require_once 'surveillance/survliste.php';
if (isset($_REQUEST['nomFic'])) $nomFic = $_REQUEST['nomFic']; isset($_REQUEST['vue'])? $vue = $_REQUEST['vue'] : $vue='' ;
else $nomFic = ''; isset($_REQUEST['nomFic'])? $nomFic = $_REQUEST['nomFic'] : $nomFic='' ;
$filtre = ''; $filtre = '';
if (isset($_REQUEST['filtre'])) { if (isset($_REQUEST['filtre'])) {
@ -28,12 +29,11 @@ else
$file = PATH_DATA.'/pdf/'.$nomFic; $file = PATH_DATA.'/pdf/'.$nomFic;
$file2 = $file.'.bz2'; $file2 = $file.'.bz2';
if (!file_exists($file)) { if (!file_exists($file)) {
$page=getUrl(WEBSERVICE_URI.'csv/'.$nomFic.'.bz2', '', '', '', false); $page = getUrl(WEBSERVICE_URI.'csv/'.$nomFic.'.bz2', '', '', '', false);
$body=$page['body']; $body = $page['body'];
$fp=@fopen($file2, 'w'); $fp=@fopen($file2, 'w');
@fwrite($fp, $body); @fwrite($fp, $body);
@fclose($fp); @fclose($fp);
$bz = bzopen($file2, "r") or die("Impossible d'ouvrir le fichier $file"); $bz = bzopen($file2, "r") or die("Impossible d'ouvrir le fichier $file");
$fp=@fopen($file, 'w'); $fp=@fopen($file, 'w');
while (!feof($bz)) { while (!feof($bz)) {
@ -42,121 +42,83 @@ else
bzclose($bz); bzclose($bz);
} }
} catch (SoapFault $fault) { } catch (SoapFault $fault) {
include_once(realpath(dirname(__FILE__).'/../../').'/includes/soaperror.php'); require_once 'soaperror.php';
processSoapFault($client,$fault,$tabInfo); processSoapFault($client,$fault,$tabInfo);
exit;
} }
?>
<table width="580" border="0" align="left" bgcolor="#FFFFFF"> $annonces = readann($file, $filtre);
<tr>
<td colspan="3"><img src="./img/rub_identite.png" width="577" height="36"></td>
</tr>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Mon identifiant</td>
<td width="350" class="StyleInfoData"><?=$_SESSION['tabInfo']['login']?></td>
</tr>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Mon identité</td>
<td width="350" class="StyleInfoData"><?=$_SESSION['tabInfo']['nom']?></td>
</tr>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Afficher uniquement les annonces</td>
<td width="350" class="StyleInfoData"><form name="form_filtre" action="./?page=survlisteann&nomFic=<?=$nomFic?>" method="GET" enctype="multipart/form-data">
<input type="hidden" name="page" value="survlisteann" />
<input type="hidden" name="nomFic" value="<?=$nomFic?>" />
<select name="filtre" onchange="document.form_filtre.submit()">
<option value="-" <?if ($filtre=='') echo 'selected';?>>-</option>
<option value="procol" <?if ($filtre=='procol') echo 'selected';?>>Proc&eacute;dures collectives</option>
<option value="radiations" <?if ($filtre=='radiations') echo 'selected';?>>Radiations</option>
<option value="ventes" <?if ($filtre=='ventes') echo 'selected';?>>Ventes/Cessions</option>
<option value="mmd" <?if ($filtre=='mmd') echo 'selected';?>>Modifications diverses</option>
</select></form></td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td colspan="3"><img src="./img/srub_surveillance.png" width="576" height="27"></td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<?php
$row = 0;
$handle = fopen($file, "r");
while (($ann = fgetcsv($handle, 3000, ';')) !== FALSE) {
$row++;
if ($row==1) {
// Ligne d'entête, on repère les colonnes
$num = count($ann);
for ($i=0; $i<$num; $i++) {
if ($ann[$i]=='SITE_CNASEA') $colSiteCnasea=$i;
elseif($ann[$i]=='Siren') $colSiren=$i;
elseif($ann[$i]=='Nic') $colNic=$i;
elseif($ann[$i]=='Référence') $colRef=$i;
elseif($ann[$i]=='Parution') $colParution=$i;
elseif($ann[$i]=='Bodacc') $colBodacc=$i;
elseif($ann[$i]=='Date parution') $colDatePar=$i;
elseif($ann[$i]=='Numéro Annonce') $colNumAnn=$i;
elseif($ann[$i]=='Type Annonce') $colTypeAnn=$i;
elseif($ann[$i]=='Tribunal') $colTribunal=$i;
elseif($ann[$i]=='Numéro RCS') $colNumRCS=$i;
elseif($ann[$i]=='Raison sociale') $colRaisonSociale=$i;
elseif($ann[$i]=='Chapitre') $colChapitre=$i;
elseif($ann[$i]=='Evènement(s)') $colEven=$i;
elseif($ann[$i]=='Texte Annonce') $colTexteAnn=$i;
elseif($ann[$i]=='Date évènement') $colDateEven=$i;
}
// On n'affiche pas d'annonce car il s'agit de la ligne d'entête
continue;
} elseif ($filtre<>'' && $ann[$colChapitre]<>$filtre)
continue;
//
// echo "<p> $num champs à la ligne $row: <br /></p>\n";
?> ?>
<tr> <table width="580" border="0" align="left" bgcolor="#FFFFFF">
<td width="30">&nbsp;</td> <tr>
<td width="550" colspan="2" class="StyleInfoLib">Entreprise : <?=$ann[$colRaisonSociale].' ('.$ann[$colSiren]?>)</td> <td colspan="3"><img src="./img/rub_identite.png" width="577" height="36"></td>
</tr> </tr>
<tr> <tr>
<td width="30">&nbsp;</td> <td width="30">&nbsp;</td>
<td width="200" class="StyleInfoData">Site : <?=$ann[$colSiteCnasea]?></td> <td width="200" class="StyleInfoLib">Mon identifiant</td>
<td width="350" colspan="2" class="StyleInfoData">Référence : <?=$ann[$colRef]?></td> <td width="350" class="StyleInfoData"><?=$_SESSION['tabInfo']['login']?></td>
</tr> </tr>
<tr> <tr>
<td width="30">&nbsp;</td> <td width="30">&nbsp;</td>
<td width="550" colspan="2" class="StyleInfoData">BODACC n&deg;<?=$ann[$colParution].'&nbsp;'.$ann[$colBodacc].' du '.WDate::dateT('Ymd','d/m/Y',$ann[$colDatePar]);?>. <?=$ann[$colTribunal]?>.</td> <td width="200" class="StyleInfoLib">Mon identité</td>
</tr> <td width="350" class="StyleInfoData"><?=$_SESSION['tabInfo']['nom']?></td>
<tr> </tr>
<td width="30">&nbsp;</td> <tr>
<td width="550" colspan="2" class="StyleInfoLib"><b><?=str_replace(', ','<br/>',$ann[$colEven])?></b></td> <td width="30">&nbsp;</td>
</tr> <td width="200" class="StyleInfoLib">Afficher uniquement les annonces</td>
<tr> <td width="350" class="StyleInfoData"><form name="form_filtre" action="./?page=survlisteann&nomFic=<?=$nomFic?>" method="GET" enctype="multipart/form-data">
<td colspan="4">&nbsp;</td> <input type="hidden" name="page" value="survlisteann" />
</tr> <input type="hidden" name="nomFic" value="<?=$nomFic?>" />
<tr> <select name="filtre" onchange="document.form_filtre.submit()">
<td width="30">&nbsp;</td><? <option value="-" <?if ($filtre=='') echo 'selected';?>>-</option>
/** <option value="procol" <?if ($filtre=='procol') echo 'selected';?>>Proc&eacute;dures collectives</option>
** Affichage du texte de l'annonce <option value="radiations" <?if ($filtre=='radiations') echo 'selected';?>>Radiations</option>
**/ <option value="ventes" <?if ($filtre=='ventes') echo 'selected';?>>Ventes/Cessions</option>
//$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[14]); <option value="mmd" <?if ($filtre=='mmd') echo 'selected';?>>Modifications diverses</option>
$texte=$ann[$colTexteAnn]; </select></form></td>
?><td width="550" colspan="2"><code><?=$texte?></code></td> </tr>
</tr> <tr>
<tr> <td colspan="3">&nbsp;</td>
<td colspan="3">&nbsp;</td> </tr>
</tr> <tr>
<tr> <td colspan="3"><img src="./img/srub_surveillance.png" width="576" height="27"></td>
<td colspan="3"><hr width="80%"></td> </tr>
</tr> <tr>
<?php <td colspan="3">&nbsp;</td>
} </tr>
?> <?php
</table> foreach($annonces as $annonce){
<?php ?>
fclose($handle); <tr>
} <td width="30">&nbsp;</td>
?> <td width="550" colspan="2" class="StyleInfoLib">Entreprise : <?=$annonce['RaisonSociale'].' ('.$annonce['Siren']?>)</td>
</tr>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoData">Site : <?=$annonce['SiteCnasea']?></td>
<td width="350" colspan="2" class="StyleInfoData">Référence : <?=$annonce['Ref']?></td>
</tr>
<tr>
<td width="30">&nbsp;</td>
<td width="550" colspan="2" class="StyleInfoData">BODACC n&deg;<?=$annonce['Parution'].'&nbsp;'.$annonce['Bodacc'].' du '.$annonce['DatePar'];?>. <?=$annonce['Tribunal']?>.</td>
</tr>
<tr>
<td width="30">&nbsp;</td>
<td width="550" colspan="2" class="StyleInfoLib"><b><?=$annonce['Even']?></b></td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td width="30">&nbsp;</td><td width="550" colspan="2"><code><?=$annonce['TexteAnn']?></code></td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td colspan="3"><hr width="80%"></td>
</tr>
<?php }?>
</table>
<?php }?>