289 lines
7.3 KiB
PHP
289 lines
7.3 KiB
PHP
<?php
|
|
$w = "70"; // first column width
|
|
$w2 = "15"; // second column width
|
|
$content = '
|
|
<table style="width: 100%; font-size: 8pt;">
|
|
<tr>
|
|
<td style="width: ' . $w . '%">
|
|
<b><h1>Rozchód Wewnętrzny</h1></b>
|
|
</td>
|
|
<td style="width: ' . $w2 . '%">
|
|
Numer:
|
|
</td>
|
|
<td style="text-align: right">
|
|
<b>' . $focus->document_no . '</b>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="width: ' . $w . '%">
|
|
|
|
</td>
|
|
<td style="width: ' . $w2 . '%">
|
|
</b>Data wystawienia:</b>
|
|
</td>
|
|
<td style="text-align: right">
|
|
<b>' . $focus->register_date . '</b>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="width: ' . $w . '%">
|
|
|
|
</td>
|
|
<td style="width: ' . $w2 . '%">
|
|
Wystawił:
|
|
</td>
|
|
<td style="text-align: right">
|
|
<b>' . $user->full_name . '</b>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="width: ' . $w . '%">
|
|
|
|
</td>
|
|
<td style="width: ' . $w2 . '%">
|
|
Z magazynu:
|
|
</td>
|
|
<td style="text-align: right">
|
|
<b>' . $focus->stock_name . '</b>
|
|
</td>
|
|
</tr>
|
|
</table><br>
|
|
';
|
|
if ($focus->name && $focus->name != '') {
|
|
$content .= '
|
|
<table style="width: 100%; text-align: center">
|
|
<tr><td>
|
|
<b>' . $focus->name . '</b>
|
|
</td></tr>
|
|
</table>
|
|
';
|
|
}
|
|
|
|
$content .= '<br>';
|
|
|
|
// start items table
|
|
$columns = array ();
|
|
|
|
$columns ['position'] = array (
|
|
'field' => array (
|
|
'position'
|
|
),
|
|
'label' => 'Lp.',
|
|
'align' => 'center'
|
|
);
|
|
|
|
$columns ['name'] = array (
|
|
'field' => array (
|
|
'name',
|
|
'product_code'
|
|
),
|
|
'label' => 'Nazwa<br>Indeks',
|
|
'align' => 'left'
|
|
);
|
|
$columns ['qty'] = array (
|
|
'field' => array (
|
|
'quantity',
|
|
'unit_name'
|
|
),
|
|
'label' => 'Ilość<br>J.m.',
|
|
'align' => 'right'
|
|
);
|
|
|
|
$columns ['price_netto'] = array (
|
|
'field' => array (
|
|
'price_netto'
|
|
),
|
|
'label' => 'Cena netto',
|
|
'align' => 'right'
|
|
);
|
|
|
|
$columns ['total_netto'] = array (
|
|
'field' => array (
|
|
'total_netto'
|
|
),
|
|
'label' => 'Wartość<br>netto',
|
|
'align' => 'right'
|
|
);
|
|
$columns ['ecmvat_value'] = array (
|
|
'field' => array (
|
|
'ecmvat_value'
|
|
),
|
|
'label' => 'VAT<br>(%)',
|
|
'align' => 'center'
|
|
);
|
|
$columns ['total_vat'] = array (
|
|
'field' => array (
|
|
'total_vat'
|
|
),
|
|
'label' => 'Wartość<br>VAT',
|
|
'align' => 'right'
|
|
);
|
|
$columns ['total_brutto'] = array (
|
|
'field' => array (
|
|
'total_brutto'
|
|
),
|
|
'label' => 'Wartość<br>brutto',
|
|
'align' => 'right'
|
|
);
|
|
// set widths
|
|
$totals = array ();
|
|
|
|
$columns ['position'] ['width'] = '5';
|
|
$columns ['name'] ['width'] = '41';
|
|
$columns ['qty'] ['width'] = '10';
|
|
$columns ['price_netto'] ['width'] = '10';
|
|
$columns ['total_netto'] ['width'] = '10';
|
|
$columns ['ecmvat_value'] ['width'] = '4';
|
|
$columns ['total_vat'] ['width'] = '10';
|
|
$columns ['total_brutto'] ['width'] = '10';
|
|
|
|
// rysujemy :)
|
|
$content .= '
|
|
<table style="width: 100%; font-size: 7pt; border: 0.5 solid black; border-collapse: collapse;"><thead>
|
|
<tr>
|
|
';
|
|
|
|
foreach ( $columns as $col ) {
|
|
$content .= '
|
|
<th style="border: 0.5 solid black; width: ' . $col ['width'] . '%;background-color: #E9E9E9;">' . $col ['label'] . '</th>
|
|
';
|
|
}
|
|
$content .= '
|
|
</tr></thead><tbody>
|
|
';
|
|
$counter=1;
|
|
if($focus->type=='normal'){
|
|
foreach ( $positions as $pos ) {
|
|
$content .= '<tr>';
|
|
foreach ( $columns as $col ) {
|
|
|
|
$content .= '<td style="border: 0.5 solid black; text-align: ' . $col ['align'] . ';">';
|
|
foreach ( $col ['field'] as $f ) {
|
|
|
|
if (! $pos [$f] || $pos [$f] == '')
|
|
$pos [$f] = '-';
|
|
$content .= $pos [$f] . '<br>';
|
|
|
|
}
|
|
$content .= '</td>';
|
|
}
|
|
$content .= '</tr>';
|
|
}
|
|
} else {
|
|
foreach ( $positions as $pos ) {
|
|
$content .= '<tr>';
|
|
$pos2= formatPDFPositionsCorrect ($focus->getCorrectedPosition($pos['ecminvoiceoutitem_id']), $focus );
|
|
$pos2['name']='było';
|
|
$pos2['position']='';
|
|
$pos2['product_code']=' ';
|
|
foreach ( $columns as $col ) {
|
|
|
|
$content .= '<td style="border: 0.5 solid black; text-align: ' . $col ['align'] . ';">';
|
|
foreach ( $col ['field'] as $f ) {
|
|
|
|
if (! $pos [$f] || $pos [$f] == '')
|
|
$pos [$f] = '-';
|
|
$content .= $pos [$f] . '<br>';
|
|
|
|
}
|
|
$content .= '</td>';
|
|
}
|
|
$content .= '</tr><tr>';
|
|
// old correct item
|
|
foreach ( $columns as $col ) {
|
|
|
|
$content .= '<td style="border: 0.5 solid black; text-align: ' . $col ['align'] . ';">';
|
|
foreach ( $col ['field'] as $f ) {
|
|
|
|
if (! $pos2 [$f] || $pos2 [$f] == '')
|
|
$pos2 [$f] = '-';
|
|
$content .= $pos2 [$f] . '<br>';
|
|
|
|
}
|
|
$content .= '</td>';
|
|
}
|
|
$content .= '</tr>';
|
|
}
|
|
}
|
|
$content .= '
|
|
</tbody></table>
|
|
';
|
|
// summary table
|
|
// get currency symbol
|
|
$c = new Currency ();
|
|
$c->retrieve ( $focus->currency_id );
|
|
$symbol = $c->symbol;
|
|
unset ( $c );
|
|
$content .= '
|
|
<br><br>
|
|
<table style="font-size: 9pt; border: 0.5 solid black; border-collapse: collapse; width: 300px; margin-left: 60%">
|
|
';
|
|
|
|
$content .= '
|
|
<tr>
|
|
<td style="font-size: 7pt; border: 0.5 solid black; width: 23%;text-align: center;">
|
|
<b>VAT (%)</b>
|
|
</td>
|
|
<td style="font-size: 7pt; border: 0.5 solid black; width: 25%;text-align: center;">
|
|
<b>Wartość netto</b>
|
|
</td>
|
|
<td style="font-size: 7pt; border: 0.5 solid black; width: 25%;text-align: center;">
|
|
<b>Wartość VAT</b>
|
|
</td>
|
|
<td style="font-size: 7pt; border: 0.5 solid black; width: 27%;text-align: center;">
|
|
<b>Wartość brutto</b>
|
|
</td>';
|
|
|
|
$content.='</tr>
|
|
';
|
|
$vats = explode(",", $focus->vats_summary);
|
|
foreach ($vats as $v){
|
|
if($v=='')continue;
|
|
$v2 = explode(":", $v);
|
|
$content .= '
|
|
<tr>
|
|
<td style="font-size: 7pt; border: 0.5 solid black; width: 23%;text-align: center;">
|
|
'.$v2[0].'
|
|
</td>
|
|
<td style="font-size: 7pt; border: 0.5 solid black; width: 25%;text-align: right;">
|
|
'.format_number($v2[1]).'
|
|
</td>
|
|
<td style="font-size: 7pt; border: 0.5 solid black; width: 25%;text-align: right;">
|
|
'.format_number($v2[2]).'
|
|
</td>
|
|
<td style="font-size: 7pt; border: 0.5 solid black; width: 27%;text-align: right;">
|
|
'.format_number($v2[3]).'
|
|
</td></tr>';
|
|
}
|
|
// totals
|
|
$content .= '
|
|
<tr>
|
|
<td style="font-size: 7pt; border: 0.5 solid black; width: 23%;text-align: center;background-color: #E9E9E9;">
|
|
<b>Razem</b>
|
|
</td>
|
|
<td style="font-size: 7pt; border: 0.5 solid black; width: 25%;text-align: right;background-color: #E9E9E9;">
|
|
<b>'.format_number($focus->total_netto).'</b>
|
|
</td>
|
|
<td style="font-size: 7pt; border: 0.5 solid black; width: 25%;text-align: right;background-color: #E9E9E9;">
|
|
<b>'.format_number($focus->total_vat).'</b>
|
|
</td>
|
|
<td style="font-size: 7pt; border: 0.5 solid black; width: 27%;text-align: right;background-color: #E9E9E9;">
|
|
<b>'.format_number($focus->total_brutto).'</b>
|
|
</td></tr>';
|
|
|
|
$content .= '
|
|
</table>
|
|
<br><br>
|
|
' . $focus->pdf_text . '
|
|
';
|
|
|
|
//echo $content; die();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|