420 lines
12 KiB
PHP
Executable File
420 lines
12 KiB
PHP
Executable File
<?php
|
|
$w = "35"; // first column width
|
|
$w3 = "35";
|
|
$w2 = "20"; // second column width
|
|
if($_REQUEST['pdf_type']==1){
|
|
$content='<p style="text-align: center;font-size: 12pt;"><b>'.$labels['LBL_PDF_CONTENT_NAME'].' '.$focus->document_no.'</b></center>';
|
|
} else if($_REQUEST['pdf_type']==0){
|
|
$content='<p style="text-align: center;font-size: 12pt;"><b>Proforma nr '.$focus->document_no.'</b></center>';
|
|
} else if($_REQUEST['pdf_type']==2){
|
|
$content='<p style="text-align: center;font-size: 12pt;"><b>Oferta nr '.$focus->document_no.'</b></center>';
|
|
}
|
|
$content.= '
|
|
<table style="width: 100%; font-size: 8pt;">
|
|
<tr>
|
|
<td style="width: ' . $w . '%">
|
|
<b>ZAMAWIAJĄCY</b>
|
|
</td>
|
|
<td style="width: ' . $w3 . '%">';
|
|
if($focus->shipping_address_name!=''){
|
|
$content.= '<b>'.$labels['LBL_PDF_CONTENT_DELIVERY'].'</b>';
|
|
}
|
|
$content.= '</td>
|
|
<td style="width: ' . $w2 . '%">
|
|
|
|
</td>
|
|
<td style="text-align: right">
|
|
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="width: ' . $w . '%">
|
|
' . $focus->parent_name . '
|
|
</td>
|
|
<td style="width: ' . $w3 . '%">
|
|
'.$focus->shipping_address_name.'
|
|
</td>
|
|
<td style="width: ' . $w2 . '%">
|
|
|
|
</td>
|
|
<td style="text-align: right">
|
|
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="width: ' . $w . '%">
|
|
' . $focus->parent_address_street . '
|
|
</td>
|
|
<td style="width: ' . $w3 . '%">
|
|
' . $focus->shipping_address_street . '
|
|
</td>
|
|
<td style="width: ' . $w2 . '%"></td>
|
|
<td style="text-align: right">
|
|
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="width: ' . $w . '%">
|
|
'. $focus->parent_address_postalcode . ' ' . $focus->parent_address_city;
|
|
if (!is_null($focus->parent_address_country) & $focus->parent_address_country!='')
|
|
$content.=', '.$focus->parent_address_country;
|
|
$content.='
|
|
</td>
|
|
<td style="width: ' . $w3 . '%">
|
|
'. $focus->shipping_address_postalcode . ' ' . $focus->shipping_address_city;
|
|
if (!is_null($focus->shipping_address_country) & $focus->shipping_address_country!='')
|
|
$content.=', '.$focus->shipping_address_country;
|
|
$content.='
|
|
</td>
|
|
<td style="width: ' . $w2 . '%">
|
|
|
|
</td>
|
|
<td style="text-align: right">
|
|
|
|
</td>
|
|
</tr>';
|
|
$content.='
|
|
<tr>
|
|
<td valign="top" style="width: ' . $w . '%">';
|
|
if (!is_null($focus->parent_nip) && $focus->parent_nip) {
|
|
$content.=$labels['LBL_PDF_CONTENT_NIP'].' '.$focus->parent_nip;
|
|
$nip = true;
|
|
}
|
|
if (!is_null($focus->parent_iln) && $focus->parent_iln) {
|
|
if ($nip) $content.'<br>'; $nip = false;
|
|
$content.=$labels['LBL_PDF_CONTENT_ILN'].' '.$focus->parent_iln;
|
|
}
|
|
$content.='
|
|
</td>';
|
|
$content.='
|
|
<td valign="top" style="width: ' . $w3 . '%">';
|
|
if (!is_null($focus->shipping_nip) && $focus->shipping_nip) {
|
|
$content.=$labels['LBL_PDF_CONTENT_NIP'].' '.$focus->shipping_nip;
|
|
$nip = true;
|
|
}
|
|
if (!is_null($focus->shipping_iln) && $focus->shipping_iln) {
|
|
if ($nip) $content.'<br>'; $nip = false;
|
|
$content.=$labels['LBL_PDF_CONTENT_ILN'].' '.$focus->shipping_iln;
|
|
}
|
|
$content.='
|
|
</td>
|
|
<td valign="top" style="width: ' . $w2 . '%"></td>
|
|
<td colspan="0" valign="top" style="text-align: right">
|
|
|
|
</td>
|
|
</tr>';
|
|
$content.='
|
|
</table><br>
|
|
';
|
|
if ($focus->name && $focus->name != '') {
|
|
$content .= '
|
|
<table style="width: 100%; text-align: center">
|
|
<tr><td>
|
|
<b>' . $focus->name . '</b>
|
|
</td></tr>
|
|
</table>
|
|
';
|
|
}
|
|
if($_REQUEST['pdf_type']==1){
|
|
|
|
$labels['LBL_PDF_CONTENT_DELIVERY_DATE']='<br>'.$labels['LBL_PDF_CONTENT_DELIVERY_DATE'];
|
|
$focus->delivery_date='<br><b>' . $focus->delivery_date . '</b>';
|
|
$width='44';
|
|
} else {
|
|
$labels['LBL_PDF_CONTENT_DELIVERY_DATE']='';
|
|
$focus->delivery_date='';
|
|
$width='12';
|
|
}
|
|
$content .= '<br><table width="100%" style="font-size: 7pt;text-align:right;vertical-align:top;">
|
|
<tr><td width="'.$width.'%" >'.$labels['LBL_PDF_CONTENT_REGISTER_DATE'].''.$labels['LBL_PDF_CONTENT_DELIVERY_DATE'].'</td>
|
|
<td style="text-align: left;" width="20%"><b>' . $focus->register_date . '</b>' . $focus->delivery_date . '</td>
|
|
<td rowspan="2" style="text-align: left;vertical-align:top;">';
|
|
|
|
if($focus->parent_document_no!=''){
|
|
$content .=$labels['LBL_PDF_CONTENT_PARENT_DOCUMENT_NO'].'<br>';
|
|
}
|
|
|
|
|
|
$content.='</td>
|
|
<td rowspan="2" style="vertical-align:top;">';
|
|
|
|
if($focus->parent_document_no!=''){
|
|
$content .='<b>' . $focus->parent_document_no.'</b><br>';
|
|
}
|
|
$content.='</td></tr></table>';
|
|
$content .= '<br>';
|
|
|
|
// start items table
|
|
$columns = array ();
|
|
|
|
$columns ['position'] = array (
|
|
'field' => array (
|
|
'position'
|
|
),
|
|
'label' => $labels['LBL_PDF_CONTENT_LIST_POSITION'],
|
|
'align' => 'center'
|
|
);
|
|
|
|
if ($_REQUEST['show_img']=='1') {
|
|
$columns ['image'] = array (
|
|
'field' => array (
|
|
'image'
|
|
),
|
|
'label' => $labels['LBL_PDF_CONTENT_LIST_IMAGE'],
|
|
'align' => 'center'
|
|
);
|
|
}
|
|
|
|
$columns ['name'] = array (
|
|
'field' => array (
|
|
'name',
|
|
'product_code'
|
|
),
|
|
'label' => $labels['LBL_PDF_CONTENT_LIST_NAME'].'<br>'.$labels['LBL_PDF_CONTENT_LIST_CODE'],
|
|
'align' => 'left'
|
|
);
|
|
|
|
if ($_REQUEST ['show_ean'] == '1' || $_REQUEST ['show_ean2'] == '1' || $_REQUEST ['show_recipient_code'] == '1') {
|
|
$columns ['codes'] = array (
|
|
'align' => 'center'
|
|
);
|
|
$columns ['codes'] ['label'] = '';
|
|
if ($_REQUEST ['show_ean']) {
|
|
$columns ['codes'] ['label'] .= $labels['LBL_PDF_CONTENT_LIST_EAN'].'<br>';
|
|
$columns ['codes'] ['field'] [] = 'ean';
|
|
}
|
|
if ($_REQUEST ['show_ean2']) {
|
|
$columns ['codes'] ['label'] .= $labels['LBL_PDF_CONTENT_LIST_EAN2'].'<br>';
|
|
$columns ['codes'] ['field'] [] = 'ean2';
|
|
}
|
|
if ($_REQUEST ['show_recipient_code']) {
|
|
$columns ['codes'] ['label'] .= $labels['LBL_PDF_CONTENT_LIST_RECIPIENT_CODE'];
|
|
$columns ['codes'] ['field'] [] = 'recipient_code';
|
|
}
|
|
|
|
$codes = true;
|
|
}
|
|
$columns ['qty'] = array (
|
|
'field' => array (
|
|
'quantity',
|
|
'unit_name'
|
|
),
|
|
'label' => $labels['LBL_PDF_CONTENT_LIST_QTY'].'<br>'.$labels['LBL_PDF_CONTENT_LIST_UNIT'],
|
|
'align' => 'right'
|
|
);
|
|
|
|
if ($_REQUEST['discount_show']==1) {
|
|
$columns ['price_start'] = array (
|
|
'field' => array (
|
|
'price_start'
|
|
),
|
|
'label' => $labels['LBL_PDF_CONTENT_LIST_PRICE_START'],
|
|
'align' => 'right'
|
|
);
|
|
|
|
$columns ['discount'] = array (
|
|
'field' => array (
|
|
'discount'
|
|
),
|
|
'label' => $labels['LBL_PDF_CONTENT_LIST_DISCOUNT'],
|
|
'align' => 'right'
|
|
);
|
|
|
|
$columns ['price_netto'] = array (
|
|
'field' => array (
|
|
'price_netto'
|
|
),
|
|
'label' => $labels['LBL_PDF_CONTENT_LIST_PRICE_NETTO'],
|
|
'align' => 'right'
|
|
);
|
|
|
|
$discounts = true;
|
|
} else
|
|
$columns ['price_netto'] = array (
|
|
'field' => array (
|
|
'price_netto'
|
|
),
|
|
'label' => $labels['LBL_PDF_CONTENT_LIST_PRICE_NETTO'],
|
|
'align' => 'right'
|
|
);
|
|
|
|
$columns ['total_netto'] = array (
|
|
'field' => array (
|
|
'total_netto'
|
|
),
|
|
'label' => $labels['LBL_PDF_CONTENT_LIST_TOTAL_NETTO'],
|
|
'align' => 'right'
|
|
);
|
|
|
|
//set widths
|
|
$totals = array();
|
|
//1: no picture, no codes, no discounts
|
|
if ($_REQUEST['show_img']=='0' && $codes==false && $discounts==false) {
|
|
$columns['position']['width'] = '5';
|
|
$columns['name']['width'] = '45';
|
|
$columns['qty']['width'] = '10';
|
|
$columns['price_netto']['width'] = '20';
|
|
$columns['total_netto']['width'] = '20';
|
|
}
|
|
//2: no picture, codes, no discounts
|
|
else if ($_REQUEST['show_img']=='0' && $codes==true && $discounts==false) {
|
|
$columns['position']['width'] = '5';
|
|
$columns['name']['width'] = '40';
|
|
$columns['codes']['width'] = '15';
|
|
$columns['qty']['width'] = '10';
|
|
$columns['price_netto']['width'] = '15';
|
|
$columns['total_netto']['width'] = '15';
|
|
}
|
|
//3: no picture, no codes, discounts
|
|
else if ($_REQUEST['show_img']=='0' && $codes==false && $discounts==true) {
|
|
$columns['position']['width'] = '5';
|
|
$columns['name']['width'] = '40';
|
|
$columns['qty']['width'] = '10';
|
|
$columns['price_netto']['width'] = '12.5';
|
|
$columns['price_start']['width'] = '12.5';
|
|
$columns['discount']['width'] = '12.5';
|
|
$columns['total_netto']['width'] = '12.5';
|
|
}
|
|
//4: no picture, codes, discounts
|
|
else if ($_REQUEST['show_img']=='0' && $codes==true && $discounts==true) {
|
|
$columns['position']['width'] = '5';
|
|
$columns['name']['width'] = '30';
|
|
$columns['codes']['width'] = '15';
|
|
$columns['qty']['width'] = '7';
|
|
$columns['price_netto']['width'] = '8';
|
|
$columns['price_start']['width'] = '10';
|
|
$columns['discount']['width'] = '10';
|
|
$columns['total_netto']['width'] = '10';
|
|
}
|
|
//5: picture, no codes, no discounts
|
|
else if ($_REQUEST['show_img']=='1' && $codes==false && $discounts==false) {
|
|
$columns['position']['width'] = '5';
|
|
$columns['name']['width'] = '45';
|
|
$columns['image']['width'] = '20';
|
|
$columns['qty']['width'] = '10';
|
|
$columns['price_netto']['width'] = '10';
|
|
$columns['total_netto']['width'] = '10';
|
|
}
|
|
//6: picture, codes, no discounts
|
|
else if ($_REQUEST['show_img']=='1' && $codes==true && $discounts==false) {
|
|
$columns['position']['width'] = '5';
|
|
$columns['name']['width'] = '35';
|
|
$columns['codes']['width'] = '15';
|
|
$columns['image']['width'] = '15';
|
|
$columns['qty']['width'] = '10';
|
|
$columns['price_netto']['width'] = '10';
|
|
$columns['total_netto']['width'] = '10';
|
|
}
|
|
//7: pictures, codes, discounts
|
|
else if ($_REQUEST['show_img']=='1' && $codes==true && $discounts==true) {
|
|
$columns['position']['width'] = '5';
|
|
$columns['name']['width'] = '35';
|
|
$columns['codes']['width'] = '15';
|
|
$columns['image']['width'] = '15';
|
|
$columns['qty']['width'] = '10';
|
|
$columns['price_start']['width'] = '10';
|
|
$columns['discount']['width'] = '10';
|
|
$columns['price_netto']['width'] = '10';
|
|
$columns['total_netto']['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; background: rgb(233,233,233); width: '.$col['width'].'%;">' . $col ['label'] . '</th>
|
|
';
|
|
}
|
|
$content .= '
|
|
</tr></thead><tbody>
|
|
';
|
|
|
|
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 ($f == 'image') {
|
|
$content.='<img width="40px" src="modules/EcmProducts/upload/images/'.$pos['image'].'"/>';
|
|
} else {
|
|
if (!$pos[$f] || $pos[$f]=='') $pos[$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: 350px; margin-left: 60%">
|
|
';
|
|
|
|
$content.='
|
|
<tr>
|
|
<td style="background: rgb(233,233,233); border: 0.5 solid black; width: 50%;">
|
|
'.$labels['LBL_PDF_CONTENT_TOTAL_NETTO'].'
|
|
</td>
|
|
<td style="border: 0.5 solid black; text-align: right;">
|
|
'.format_number($focus->total_netto).' '.$symbol.'
|
|
</td>
|
|
</tr>
|
|
';
|
|
|
|
if ($focus->no_tax=='0') {
|
|
$vats = explode(",", $focus->vats_summary);
|
|
foreach ($vats as $v) {
|
|
$vats2 = explode(":", $v);
|
|
if ($vats2[0]=='') continue;
|
|
$content.='
|
|
<tr>
|
|
<td style="background: rgb(233,233,233); border: 0.5 solid black; width: 50%;">
|
|
'.$vats2[0].'
|
|
</td>
|
|
<td style="border: 0.5 solid black; text-align: right;">
|
|
'.format_number($vats2[1]).' '.$symbol.'
|
|
</td>
|
|
</tr>
|
|
';
|
|
}
|
|
$content.='
|
|
<tr>
|
|
<td style="background: rgb(233,233,233); border: 0.5 solid black; width: 50%;">
|
|
'.$labels['LBL_PDF_CONTENT_TOTAL_BRUTTO'].'
|
|
</td>
|
|
<td style="border: 0.5 solid black; text-align: right;font-size: 8pt;">
|
|
<b>'.format_number($focus->total_brutto).' '.$symbol.'</b>
|
|
</td>
|
|
</tr>
|
|
';
|
|
}
|
|
$content.='
|
|
</table><br><p style="font-size: 7pt;">'.$labels['LBL_PDF_CONTENT_ISSUED_BY'].' <b>'.$user->full_name.'</b></p>
|
|
<br><br>
|
|
'.$focus->pdf_text.'
|
|
';
|
|
|
|
//echo $content; die();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|