Probléme avec html2pdf et php
Posté : 15 août 2013, 18:26
Bonjour à tous,
je viens chercher un peu d'aide car j'avoue que je bute .....
Voila j'utilise html2pdf pour réaliser des pdf pour de la gestion de commandes ( la c'est le cas ou c'est du regroupement pour le conditionnement par département )
j'ai déjà un début de code mais j'arrive pas à réaliser l'affichage des contenus par page
genre 1ere page département 66 ( avec la liste des commandes 66 ) page 2 département 11 ( avec la liste des commandes pour le département 11 ) etc ....
voici mon code : ( pas très propre en effet mais je teste )
http://www.letoutweb.com/pdf/test.pdf
Si une âme charitable veut bien m'aider
Merci par avance
je viens chercher un peu d'aide car j'avoue que je bute .....
Voila j'utilise html2pdf pour réaliser des pdf pour de la gestion de commandes ( la c'est le cas ou c'est du regroupement pour le conditionnement par département )
j'ai déjà un début de code mais j'arrive pas à réaliser l'affichage des contenus par page
genre 1ere page département 66 ( avec la liste des commandes 66 ) page 2 département 11 ( avec la liste des commandes pour le département 11 ) etc ....
voici mon code : ( pas très propre en effet mais je teste )
<?php
ob_start();
include ('config/config.php');
$semaine_plan_va = $_GET['semaine'];
$annee_plan_va = $_GET['annee'];
$semaine = $semaine_plan_va;
$année = $annee_plan_va;
?>
<page backtop="15mm" backbottom="10mm" backleft="20mm" backright="20mm">
<page_header>
<table style="width: 100%; border: solid 1px black;">
<tr>
<td style="text-align: center; width: 43%"><b>PLANNING DEPART</b></td>
<td style="text-align: left; width: 43%"><b>SEMAINE: <?php echo $semaine ;?> Année : <?php echo $année;?></b></td>
<td style="text-align: right; width: 14%"><?php echo date('d/m/Y'); ?></td>
</tr>
</table>
</page_header>
<br>
<page_footer>
<table style="width: 100%; border: solid 1px black;">
<tr>
<td style="text-align: left; width: 50%">SCD ALU PLANNING Semaine : <?php echo $semaine?> Année : <?php echo $année?></td>
<td style="text-align: right; width: 50%">page [[page_cu]]/[[page_nb]]</td>
</tr>
</table>
</page_footer>
<tbody>
<?php
$sql = "SELECT * FROM planning_scd WHERE plan_s_fab = '".$semaine_plan_va."' AND plan_annee = '".$annee_plan_va."' ORDER BY plan_dep ASC";
$req = mysql_query($sql) or die ($sql.' '.mysql_error());
$temp = '';
while ($data = mysql_fetch_array($req)) {
if ($temp != $data['plan_dep']) {
echo'<div align="center"> <table style="width: 95%; border: solid 1px black;">
<tr>
<td style="text-align: center; width: 43%"><b>CHARGEMENT DEPARTEMENT '.$data['plan_dep'].'</b></td>
</tr>
</table> </div>';
$temp = $data['plan_dep'];
}
$info_complementaire = htmlentities(trim($data['inf_comp']));
$detail_chassis_composé = htmlentities(trim($data['comp_com']));
?>
<br>
<TABLE width=80% style="border: solid 1px black;">
<TR>
<TD>
<TABLE width=100%>
<TR>
<TD colspan=3 bgcolor="#C0C0C0" ><b>
<?php echo'
Client : ', htmlentities(trim($data['plan_client'])) ,' |
Référence : ', htmlentities(trim($data['plan_ref'])) ,' |
Couleur : ',htmlentities(trim($data['plan_couleur'])),' |
Département : ',htmlentities(trim($data['plan_dep'])),'
';?>
</b></TD>
</TR>
<TR>
<TD width="13%" bgcolor="#C0C0C0" ><b>Détails de commande :</b></TD>
<TD width="87%" > </TD>
</TR>
</TABLE>
<TABLE width=90% >
<?php
if (htmlentities(trim($data['gbi_2vtx'])) > '0' or htmlentities(trim($data['gbi_3vtx'])) > '0' or htmlentities(trim($data['gbi_4vtx'])) > '0' or htmlentities(trim($data['gbi_gal_1vtl'])) > '0' or htmlentities(trim($data['gbi_gal_2vtx'])) > '0' )
{
echo'<tr><td>';
if (htmlentities(trim($data['gbi_2vtx'])) > '0'){ echo'GBI 2 VTX Qté: ', htmlentities(trim($data['gbi_2vtx'])),' | ';}
if (htmlentities(trim($data['gbi_3vtx'])) > '0'){ echo'GBI 3 VTX Qté: ', htmlentities(trim($data['gbi_3vtx'])),' | ';}
if (htmlentities(trim($data['gbi_4vtx'])) > '0'){ echo'GBI 4 VTX Qté: ', htmlentities(trim($data['gbi_4vtx'])),' | ';}
if (htmlentities(trim($data['gbi_gal_1vtl'])) > '0'){ echo'GBI Galandage 1 VTL Qté: ', htmlentities(trim($data['gbi_gal_1vtl'])),' | ';}
if (htmlentities(trim($data['gbi_gal_2vtx'])) > '0'){ echo'GBI Galandage 2 VTX Qté: ', htmlentities(trim($data['gbi_gal_2vtx'])),' ';}
echo'</td></tr>';
}
if (htmlentities(trim($data['gy_2vtx'])) > '0' or htmlentities(trim($data['gy_3vtx'])) > '0' or htmlentities(trim($data['gy_4vtx'])) > '0' or htmlentities(trim($data['gy_gal_1vtl'])) > '0' or htmlentities(trim($data['gy_gal_2vtx'])) > '0' )
{
echo'<tr><td>';
if (htmlentities(trim($data['gy_2vtx'])) > '0'){ echo'GY 2 VTX Qté: ', htmlentities(trim($data['gy_2vtx'])),' | ';}
if (htmlentities(trim($data['gy_3vtx'])) > '0'){ echo'GY 3 VTX Qté: ', htmlentities(trim($data['gy_3vtx'])),' | ';}
if (htmlentities(trim($data['gy_4vtx'])) > '0'){ echo'GY 4 VTX Qté: ', htmlentities(trim($data['gy_4vtx'])),' | ';}
if (htmlentities(trim($data['gy_gal_1vtl'])) > '0'){ echo'GY Galandage 1 VTL Qté: ', htmlentities(trim($data['gy_gal_1vtl'])),' | ';}
if (htmlentities(trim($data['gy_gal_2vtx'])) > '0'){ echo'GY Galandage 2 VTX Qté: ', htmlentities(trim($data['gy_gal_2vtx'])),' ';}
echo'</td></tr>';
}
if (htmlentities(trim($data['gam_2vtx'])) > '0' or htmlentities(trim($data['gam_3vtx'])) > '0' or htmlentities(trim($data['gam_4vtx'])) > '0' or htmlentities(trim($data['gam_gal_1vtl'])) > '0' or htmlentities(trim($data['gam_gal_2vtx'])) > '0' )
{
echo'<tr><td>';
if (htmlentities(trim($data['gam_2vtx'])) > '0'){ echo'GAM 2 VTX Qté: ', htmlentities(trim($data['gam_2vtx'])),' | ';}
if (htmlentities(trim($data['gam_3vtx'])) > '0'){ echo'GAM 3 VTX Qté: ', htmlentities(trim($data['gam_3vtx'])),' | ';}
if (htmlentities(trim($data['gam_4vtx'])) > '0'){ echo'GAM 4 VTX Qté: ', htmlentities(trim($data['gam_4vtx'])),' | ';}
if (htmlentities(trim($data['gam_gal_1vtl'])) > '0'){ echo'GAM Galandage 1 VTL Qté: ', htmlentities(trim($data['gam_gal_1vtl'])),' | ';}
if (htmlentities(trim($data['gam_gal_2vtx'])) > '0'){ echo'GAM Galandage 2 VTX Qté: ', htmlentities(trim($data['gam_gal_2vtx'])),' ';}
echo'</td></tr>';
}
if (htmlentities(trim($data['fy_fixe'])) > '0' or htmlentities(trim($data['fy_1vtl'])) > '0' or htmlentities(trim($data['fy_2vtx'])) > '0' or htmlentities(trim($data['fy_1vtl_ob'])) > '0' or htmlentities(trim($data['fy_2vtx_ob'])) > '0' )
{
echo'<tr><td>';
if (htmlentities(trim($data['fy_fixe'])) > '0'){ echo'FY Fixe Qté: ', htmlentities(trim($data['fy_fixe'])),' | ';}
if (htmlentities(trim($data['fy_1vtl'])) > '0'){ echo'FY 1 VTL Qté: ', htmlentities(trim($data['fy_1vtl'])),' | ';}
if (htmlentities(trim($data['fy_2vtx'])) > '0'){ echo'FY 2 VTX Qté: ', htmlentities(trim($data['fy_2vtx'])),' | ';}
if (htmlentities(trim($data['fy_1vtl_ob'])) > '0'){ echo'FY 1 VTL OB Qté: ', htmlentities(trim($data['fy_1vtl_ob'])),' | ';}
if (htmlentities(trim($data['fy_2vtx_ob'])) > '0'){ echo'FY 2 VTX OB Qté: ', htmlentities(trim($data['fy_2vtx_ob'])),' ';}
echo'</td></tr>';
}
if (htmlentities(trim($data['fd_fixe'])) > '0' or htmlentities(trim($data['fd_1vtl'])) > '0' or htmlentities(trim($data['fd_2vtx'])) > '0' or htmlentities(trim($data['fd_1vtl_ob'])) > '0' or htmlentities(trim($data['fd_2vtx_ob'])) > '0' )
{
echo'<tr><td>';
if (htmlentities(trim($data['fd_fixe'])) > '0'){ echo'FD Fixe Qté: ', htmlentities(trim($data['fd_fixe'])),' | ';}
if (htmlentities(trim($data['fd_1vtl'])) > '0'){ echo'FD 1 VTL Qté: ', htmlentities(trim($data['fd_1vtl'])),' | ';}
if (htmlentities(trim($data['fd_2vtx'])) > '0'){ echo'FD 2 VTX Qté: ', htmlentities(trim($data['fd_2vtx'])),' | ';}
if (htmlentities(trim($data['fd_1vtl_ob'])) > '0'){ echo'FD 1 VTL OB Qté: ', htmlentities(trim($data['fd_1vtl_ob'])),' | ';}
if (htmlentities(trim($data['fd_2vtx_ob'])) > '0'){ echo'FD 2 VTX OB Qté: ', htmlentities(trim($data['fd_2vtx_ob'])),' ';}
echo'</td></tr>';
}
if (htmlentities(trim($data['py_1vtl'])) > '0' or htmlentities(trim($data['py_2vtx'])) > '0' )
{
echo'<tr><td>';
if (htmlentities(trim($data['py_1vtl'])) > '0'){ echo'PY 1 VTL Qté: ', htmlentities(trim($data['py_1vtl'])),' | ';}
if (htmlentities(trim($data['py_2vtx'])) > '0'){ echo'PY 2 VTX Qté: ', htmlentities(trim($data['py_2vtx'])),' ';}
echo'</td></tr>';
}
if (htmlentities(trim($data['comp_coul'])) > '0' or htmlentities(trim($data['com_frap'])) > '0' )
{
echo'<tr><td>';
echo'<b>Chassis Composés : </b>';
echo'</td></tr>';
echo'<tr><td>';
if (htmlentities(trim($data['comp_coul'])) > '0'){ echo'Composé Coulissant Qté: ', htmlentities(trim($data['comp_coul'])),' | ';}
if (htmlentities(trim($data['comp_frap'])) > '0'){ echo'Composé Frappe Qté: ', htmlentities(trim($data['comp_frap'])),' ';}
echo'</td></tr>';
echo'<tr><td>';
echo'<b>Description Des Composés : </b>';
echo'</td></tr>';
echo'<tr><td>';
echo html_entity_decode($detail_chassis_composé);
echo'</td></tr>';
}
if (htmlentities(trim($data['vr'])) > '0' or htmlentities(trim($data['vr_frap'])) > '0')
{
echo'<tr><td>';
echo'<b>Vr ( compris dans le lot Coulissant et Frappe ) :</b>';
echo'</td></tr>';
echo'<tr><td>';
if (htmlentities(trim($data['vr'])) > '0'){ echo'Volets Sur coulissant Qté: ', htmlentities(trim($data['vr'])),' | ';}
if (htmlentities(trim($data['vr_frap'])) > '0'){ echo'Volets Sur Frappe Qté: ', htmlentities(trim($data['vr_frap'])),' ';}
echo'</td></tr>';
echo'<tr><td>';
echo'<b>Détails des châssis avec Vr :</b>';
echo'</td></tr>';
echo'<tr><td>';
echo html_entity_decode($info_complementaire);
echo'</td></tr>';
}
?>
</TABLE>
</TD>
</TR>
</TABLE>
<?php
echo'<br><br>';
}
mysql_free_result($req);
mysql_close($connexion);
?>
</tbody>
</page>
<?php
$content = ob_get_clean();
// convert to PDF
require_once(dirname(__FILE__).'/html2pdf/html2pdf.class.php');
try
{
$html2pdf = new HTML2PDF('L', 'A4', 'fr',false,'ISO-8859-15');
$html2pdf->pdf->SetDisplayMode('fullpage');
$html2pdf->setDefaultFont('Arial');
$html2pdf->writeHTML($content);
$html2pdf->Output('test.pdf');
}
catch(HTML2PDF_exception $e) {
echo $e;
exit;
}
?>
et le résultat en pdf :http://www.letoutweb.com/pdf/test.pdf
Si une âme charitable veut bien m'aider
Merci par avance