Files
crm.twinpol.com/modules/EcmStockDocCorrects/PDFTemplate/content.php

264 lines
5.9 KiB
PHP
Raw Normal View History

2025-05-12 15:44:39 +00:00
<?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>Dokument KS</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 . '%">
&nbsp;
</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 . '%">
&nbsp;
</td>
<td style="width: ' . $w2 . '%">
Wystawił:
</td>
<td style="text-align: right">
<b>' . $user->full_name . '</b>
</td>
</tr>
<tr>
<td style="width: ' . $w . '%">
&nbsp;
</td>
<td style="width: ' . $w2 . '%">
Magazyn:
</td>
<td style="text-align: right">
<b>' . $focus->stock_name . '</b>
</td>
</tr>
<tr>
<td style="width: ' . $w . '%">
&nbsp;
</td>
<td style="width: ' . $w2 . '%">
Typ:
</td>
<td style="text-align: right">
<b>' . $app_list_strings['ecmstockdoccorrects_type_dom'][$focus->type] . '</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 ();
if($focus->type == '6ed5b076-ddd1-9809-b236-54e5b2bcbd97'){
//Przecena
$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'] = array (
'field' => array (
'price',
'old_price',
),
'label' => 'Cena',
'align' => 'right'
);
$columns ['total'] = array (
'field' => array (
'total',
'old_total',
'total_diff',
),
'label' => '<table style="width: 100%; font-size: 7pt; border: 0.5 solid black; border-collapse: collapse;margin:0px; padding:0px">
<tr>
<td colspan="3" style=";text-align:center"><b>Wartość</b></td>
</tr>
<tr>
<td style="width:33%;text-align:right">Jest</td>
<td style="width:33%;text-align:right">Było</td>
<td style="width:33%;text-align:right">Różnica</td>
</tr>
</table>',
'align' => 'right',
);
}else{
$columns ['position'] = array (
'field' => array (
'position'
),
'label' => 'Lp.',
'align' => 'center'
);
$columns ['name'] = array (
'field' => array (
'name',
'product_code'
),
'label' => 'Nazwa<br>Indeks / Partia',
'align' => 'left'
);
$columns ['qty'] = array (
'field' => array (
'quantity',
'unit_name'
),
'label' => 'Ilość<br>J.m.',
'align' => 'right'
);
$columns ['price'] = array (
'field' => array (
'price',
),
'label' => 'Cena',
'align' => 'right'
);
$columns ['total'] = array (
'field' => array (
'total',
),
'label' => 'Wartość',
'align' => 'right'
);
}
// set widths
$totals = array ();
$columns ['position'] ['width'] = '5';
$columns ['name'] ['width'] = '45';
$columns ['qty'] ['width'] = '10';
$columns ['price'] ['width'] = '20';
$columns ['total'] ['width'] = '20';
// rysujemy :)
if($focus->type == '7bb903d0-c296-7d1b-6e50-54c209e30850' || $focus->type == '8a6b804b-fac7-5cc2-de19-54c209116b19'){
//Korekta plus i minus
$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'] . '%;">' . $col ['label'] . '</th>';
}
$content .= '
</tr>
</thead>
<tbody>';
foreach ( $positions as $pos ) {
//var_dump($pos); die();
if ($pos['product_consignment_doc'])
$pos['product_code'].= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . $pos['product_consignment_doc'];
$content .= '<tr>';
foreach ( $columns as $col ) {
$content .= '<td style="border: 0.5 solid black; text-align: ' . $col ['align'] . ';">';
foreach ( $col ['field'] as $f ) {
$content .= $pos [$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: 215px; margin-left: 70%">
<tr>
<td style="border: 0.5 solid black; width: 50%;">
Suma
</td>
<td style="border: 0.5 solid black; text-align: right;">
' . format_number ( $focus->total) . ' ' . $symbol . '
</td>
</tr>
</table>';
}else if($focus->type == '6ed5b076-ddd1-9809-b236-54e5b2bcbd97'){
//PRZECENA
$smarty = new Sugar_Smarty ();
$smarty->assign("positions", $positions);
//$smarty->assign("app_list_strings", $app_list_strings);
$content .= $smarty->fetch('modules/EcmStockDocCorrects/PDFTemplate/przecena_lista_pozycji.tpl');
// 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: 215px; margin-left: 70%">
<tr>
<td style="border: 0.5 solid black; width: 50%;">
Suma
</td>
<td style="border: 0.5 solid black; text-align: right;">
' . format_number ( $focus->total) . ' ' . $symbol . '
</td>
</tr>
</table>';
}
$content .= '<br><br>' . $focus->pdf_text;
//echo $content; die();