Pagina 1 di 1

foreach nidificati

Inviato: 05 feb 2020, 11:08
da Giampiero
buongiorno, in parte ho modifcato l'esempio di tcpdf 48 e l'ho inserita in una blank ho un grosso problema non riesco a fare ciclare il secondo foreach non capisco dove sbaglio
grazie

sc_lookup(tB,"SELECT
ID,
Committente,
Contratto,
Nominativo,
Indirizzo,
CAP,
Localita,
Prov,
Gestore,
Proroga,
DataImportazione,
StatodellaPratica,
CodiceFiscale,
CodiceEsito,
Resa,
Esito
FROM
Stampe WHERE ID < 10");
sc_include_lib('tcpdf');
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
foreach($tB as $row){
// set document information
//$pdf->SetCreator(PDF_CREATOR);
//$pdf->SetAuthor($row[0]);
//$pdf->SetTitle('$row[3]');
//$pdf->SetSubject('TCPDF Tutorial');
//$pdf->SetKeywords('TCPDF, PDF, example, test, guide');


// set default header data
//$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 049', PDF_HEADER_STRING);

// set header and footer fonts
//$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
//$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

// set margins
//$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
//$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
//$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
require_once(dirname(__FILE__).'/lang/eng.php');
$pdf->setLanguageArray($l);
}

// ---------------------------------------------------------

// set font
$pdf->SetFont('helvetica', 'B', 20);

// add a page
$pdf->AddPage();
$pdf->Write(5, $row[2], '', 0, 'L', true, 0, false, false, 0);
$pdf->SetFont('helvetica', 'B', 10);

// -----------------------------------------------------------------------------

$tbl = <<<EOD
<table cellspacing="0" cellpadding="1" border="0">
<tr>
<td rowspan="1" border="1" align="center">Sede</td>
<td border="1" align="center">Filiale</td>
<td border="1" align="center">Contratto</td>

</tr>

<tr>
<td border="1" align="center"><!--mstheme--><font face="trebuchet ms, arial, helvetica"><font color="#000000" size="8">$row[3]</font><!--mstheme--></font></td>
//<td rowspan="1" border="1" align="center"><b>Committente</b></td>
<td border="1" align="center"><!--mstheme--><font face="trebuchet ms, arial, helvetica"><font color="#000000" size="8">$row[4]</font><!--mstheme--></font></td>
//<td border="1"><!--mstheme--><font face="trebuchet ms, arial, helvetica">$row[5]<!--mstheme--></font></td>
<td border="1" align="center"><!--mstheme--><font face="trebuchet ms, arial, helvetica"><font color="#000000" size="8">$row[5]</font><!--mstheme--></font></td>
//<td border="1" bgcolor="#E3FFE3"><!--mstheme--><font face="trebuchet ms, arial, helvetica"><small><a href="notizie.htm">Mappe stradali</a></small><!--mstheme--></font></td>
</tr>

</table>
EOD;

$pdf->writeHTML($tbl, true, false, false, false, '');
$pdf->SetFont('helvetica', '', 8);
// -----------------------------------------------------------------------------

$tbl = <<<EOD
<table cellspacing="0" cellpadding="1" border="1">
<tr>
<td rowspan="7">COL 1 - ROW 1<br />COLSPAN 3<br />text line<br />text line<br />text line<br />text line<br />text line<br />text line</td>
<td rowspan="5">$row[4]</td>
<td border="0"><!--mstheme--><font face="trebuchet ms, arial, helvetica"><font color="#000000" size="12">$row[8]</font><!--mstheme--></font></td>

</tr>
<tr>
<td border="0"><!--mstheme--><font face="trebuchet ms, arial, helvetica"><font color="#000000" size="8">$row[9]</font><!--mstheme--></font></td>
</tr>
<tr>
<td border="0"><!--mstheme--><font face="trebuchet ms, arial, helvetica"><font color="#000000" size="8">$row[10] $row[11] $row[12]</font><!--mstheme--></font><br /></td>
</tr>
<tr>
//<td rowspan="2"><!--mstheme--><font face="trebuchet ms, arial, helvetica"><font color="#000000" size="8">Cellulare</font><!--mstheme--></font><br /></td>
<td><!--mstheme--><font face="trebuchet ms, arial, helvetica"><font color="#000000" size="12">Telefono</font><!--mstheme--></font><br /></td>
</tr>
<tr>
<td><!--mstheme--><font face="trebuchet ms, arial, helvetica"><font color="#000000" size="12">Cellulare</font><!--mstheme--></font><br /></td>
</tr>
</table>
EOD;

$pdf->writeHTML($tbl, true, false, false, false, '');

// -----------------------------------------------------------------------------

$tbl = <<<EOD
<table cellspacing="0" cellpadding="1" border="1">
<tr>
<td rowspan="3">COL 1 - ROW 1<br />COLSPAN 3<br />text line<br />text line<br />text line<br />text line<br />text line<br />text line</td>
<td>$row[4]</td>
<td>$row[5]</td>
</tr>
<tr>
<td rowspan="2">COL 2 - ROW 2 - COLSPAN 2<br />text line<br />text line<br />text line<br />text line</td>
<td>COL 3 - ROW 2<br />text line<br />text line</td>
</tr>
<tr>
<td>COL 3 - ROW 3</td>
</tr>

</table>
EOD;

$pdf->writeHTML($tbl, true, false, false, false, '');

sc_lookup(rs,"SELECT IDINC, SCADENZAdet FROM fatture WHERE IDINC = $row[0]");

$tbl = <<<EOD
<table border="1">
$righe = '';

foreach($rs as $roww){
$SCADE = sc_date_conv($roww[1], "db_format", "dd/mm/yyyy");
$Numero = $roww[0];
$righe.='
<tr>
<td width=102>'.$Numero.'</td>
<td width=80>'.$DEL.'</td>
'; }
// <td width=80>'.$SCADE.'</td>
// <td width=80>'.$row[5].'</td>
</tr>

<tr>
<th rowspan="3">DETTAGLIO SULLO SCADUTO SCADENZA</th>
<th colspan="5">test</th>
<th colspan="9">test1</th>
</tr>
<tr>
<td>ttest</td>
<td>yttest1</td>
</tr>

</table>

EOD;






$pdf->writeHTML($tbl, true, false, false, false, '');
}
// -----------------------------------------------------------------------------

//Close and output PDF document
$pdf->Output('example_048.pdf', 'I');

Risolto foreach nidificati

Inviato: 12 feb 2020, 21:26
da Giampiero
Risolto con un semplice if
grazie