|
' . $labels['LBL_PDF_CONTENT_INVOICE_FOR'] . '
|
';
if ($focus->parent_shipping_address_name != '') {
$content .= '' . $labels['LBL_PDF_CONTENT_DELIVERY'] . '';
}
$content .= ' |
';
if ($focus->parent_payer_address_name != '') {
$content .= '' . $labels['LBL_PDF_CONTENT_PAYER'] . '';
}
$content .= ' |
|
|
' . $focus->parent_name . '
|
' . $focus->parent_shipping_address_name . '
|
' . $focus->parent_payer_address_name . ' |
|
|
' . $focus->parent_address_street . '
|
' . $focus->parent_shipping_address_street . '
|
' . $focus->parent_payer_address_street . '
|
|
|
' . $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 .= '
|
' . $focus->parent_shipping_address_postalcode . ' ' . $focus->parent_shipping_address_city;
if (!is_null($focus->parent_shipping_address_country) & $focus->parent_shipping_address_country != '')
$content .= ', ' . $focus->parent_shipping_address_country;
$content .= '
|
' . $focus->parent_payer_address_postalcode . ' ' . $focus->parent_payer_address_city;
if (!is_null($focus->parent_payer_address_country) & $focus->parent_payer_address_country != '')
$content .= ', ' . $focus->parent_payer_address_country;
$content .= '
|
|
';
$content .= '
';
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 .= ' ';
$nip = false;
$content .= 'ILN: ' . $focus->parent_iln;
}
$content .= '
| ';
$content .= '
';
if (!is_null($focus->parent_shipping_address_nip) && $focus->parent_shipping_address_nip) {
$content .= $labels['LBL_PDF_CONTENT_NIP'] . ' ' . $focus->parent_shipping_address_nip;
$nip = true;
}
if (!is_null($focus->parent_shipping_iln) && $focus->parent_shipping_iln) {
if ($nip) $content .= ' ';
$nip = false;
$content .= 'ILN: ' . $focus->parent_shipping_iln;
}
$content .= '
| ';
$content .= '
';
if (!is_null($focus->parent_payer_address_nip) && $focus->parent_payer_address_nip) {
$content .= $labels['LBL_PDF_CONTENT_NIP'] . ' ' . $focus->parent_payer_address_nip;
$nip = true;
}
if (!is_null($focus->parent_payer_iln) && $focus->parent_payer_iln) {
if ($nip) $content .= ' ';
$nip = false;
$content .= 'ILN: ' . $focus->parent_payer_iln;
}
$content .= ' |
|
';
$content .= '
';
if ($focus->name && $focus->name != '') {
$content .= '
';
}
$content .= '
' . $labels['LBL_PDF_CONTENT_REGISTER_DATE'] . ' ' . $labels['LBL_PLACE_PDF'] . ' ' . $labels['LBL_PDF_CONTENT_SELL_DATE'] . ' ' . $corl . ' |
' . $focus->register_date . ' Warszawa ' . $focus->sell_date . '' . $korekta . ' |
';
if ($focus->wz_name != '') {
$content .= $labels['LBL_PDF_CONTENT_PARENT_DOCUMENT_WZ'] . ': ';
}
if ($focus->order_no != '') {
$content .= $labels['LBL_PDF_CONTENT_PARENT_DOCUMENT_NO'] . ': ';
}
if ($focus->supplier_code != '') {
$content .= $labels['LBL_SUPPLIER_CODE'] . ': ';
}
if ($focus->payment_date != '') {
$content .= $labels['LBL_PAYMENT_DATE_PDF'] . ': ';
}
if ($focus->ecmpaymentcondition_id != '') {
$content .= $labels['LBL_PAYMENT_METHOD_PDF'] . ': ';
}
$pay = new EcmPaymentCondition();
$pay->retrieve($focus->ecmpaymentcondition_id);
$content .= ' |
';
if ($focus->wz_name != '') {
$content .= '' . $focus->wz_name . ' ';
}
if ($focus->order_no != '') {
$content .= '' . $focus->order_no . ' ';
}
if ($focus->supplier_code != '') {
$content .= '' . $focus->supplier_code . ' ';
}
if ($focus->payment_date != '') {
$content .= '' . date('d.m.Y', strtotime($focus->payment_date)) . ' ';
}
if ($focus->ecmpaymentcondition_id != '') {
$content .= '' . $GLOBALS['app_list_strings']['ecmpaymentconditions_payment_method_dom'][$pay->payment_method] . ' ';
}
$content .= ' |
';
// 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
Indeks',
'align' => 'left'
);
if ($recipient_code == 1) {
$columns['recipient_code'] = array(
'field' => array(
'recipient_code'
),
'label' => 'Kod Tow.',
'align' => 'center'
);
}
$columns['qty'] = array(
'field' => array(
'quantity',
'unit_name'
),
'label' => 'Ilość
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ść
netto',
'align' => 'right'
);
$columns['ecmvat_name'] = array(
'field' => array(
'ecmvat_name'
),
'label' => 'VAT
(%)',
'align' => 'center'
);
$columns['total_vat'] = array(
'field' => array(
'total_vat'
),
'label' => 'Wartość
VAT',
'align' => 'right'
);
$columns['total_brutto'] = array(
'field' => array(
'total_brutto'
),
'label' => 'Wartość
brutto',
'align' => 'right'
);
// set widths
$totals = array();
$columns['position']['width'] = '5';
$columns['name']['width'] = '41';
if ($recipient_code == 1) {
$columns['recipient_code']['width'] = '10';
}
$columns['qty']['width'] = '10';
$columns['price_netto']['width'] = '10';
$columns['total_netto']['width'] = '10';
$columns['ecmvat_name']['width'] = '4';
$columns['total_vat']['width'] = '10';
$columns['total_brutto']['width'] = '10';
// rysujemy :)
$content .= '
';
foreach ($columns as $col) {
$content .= '
| ' . $col['label'] . ' |
';
}
$content .= '
';
$counter = 1;
foreach ($positions as $pos) {
$content .= '';
foreach ($columns as $col) {
$content .= '';
foreach ($col['field'] as $f) {
if (!$pos[$f] || $pos[$f] == '')
$pos[$f] = '-';
$content .= $pos[$f] . ' ';
}
$content .= ' | ';
}
$content .= '
';
}
$content .= '
';
// summary table
// get currency symbol
$c = new Currency();
$c->retrieve($focus->currency_id);
$symbol = $c->symbol;
unset($c);
$content .= '
';
$content .= '
|
VAT (%)
|
Wartość netto
|
Wartość VAT
|
Wartość brutto
| ';
$content .= '
';
$vats = explode(",", $focus->vats_summary);
foreach ($vats as $v) {
if ($v == '') continue;
$v2 = explode(":", $v);
$content .= '
|
' . $v2[0] . '
|
' . format_number($v2[1]) . '
|
' . format_number($v2[2]) . '
|
' . format_number($v2[3]) . '
|
';
}
$total_paid_vat = 0;
$total_paid_netto = 0;
if ($focus->prepaid != '') {
$vat_value = substr($k,0,-1)+'';
if (strlen($vat_value) == 1) $vat_value = '0'.$vat_value;
$paid_netto = round($focus->prepaid / 1.23,2);
$paid_vat = $focus->prepaid - $paid_netto;
$total_paid_netto += $paid_netto;
$total_paid_vat += $paid_vat;
$content .= '
|
23%
|
-' .format_number($paid_netto). '
|
-' .format_number($paid_vat). '
|
-' . format_number($focus->prepaid) . '
|
';
}
// totals
$content .= '
|
Razem
|
' . format_number($focus->total_netto-$total_paid_netto) . '
|
' . format_number($focus->total_vat-$total_paid_vat) . '
|
' . format_number($focus->total_brutto-$focus->prepaid) . '
|
';
$left_to_paid = $focus->total_brutto - $focus->paid_val - $focus->prepaid;
$content .= '
';
if ($focus->prepaid != '') {
$content .= '| FV przedpłatowa: | ' . $focus->prepaid_nr . ' | |
';
}
$content .= '| ' . $labels['LBL_PDF_TO_PAY'] . ' | ' . format_number($focus->total_brutto) . ' ' . $symbol . ' | |
';
if ($focus->prepaid != '') {
$content .= '| Przedpłata | ' . format_number($focus->prepaid) . ' ' . $symbol . ' | |
';
}
if ($focus->paid_val != '') {
if ($focus->paid_val != 0) $pay_text = $GLOBALS['app_list_strings']['ecmpaymentconditions_payment_method_dom'][$focus->payment_method_paid];
$content .= '| ' . $labels['LBL_PDF_PAID'] . ' | ' . format_number($focus->paid_val) . ' ' . $symbol . ' | ' . $pay_text . ' |
';
}
if ($focus->ecmpaymentcondition_id != '') {
$q = $db->query("select name from ecmpaymentconditions where id='$focus->ecmpaymentcondition_id'");
$r = $db->fetchByAssoc($q);
//$paid_text='w Terminie '.$r['name'].' do '.date('d.m.Y',strtotime($focus->payment_date)).' '.$GLOBALS['app_list_strings']['payment_method_dom'][$focus->payment_method];
} else {
if ($focus->payment_date != '') {
$dni = (strtotime($focus->payment_date) - strtotime($focus->sell_date)) / (3600 * 24);
//$paid_text='w Terminie '.$dni.' dni do '.date('d.m.Y',strtotime($focus->payment_date)).' '.$GLOBALS['app_list_strings']['payment_method_dom'][$focus->payment_method];
}
}
$content .= '| ' . $labels['LBL_PDF_LEFT_TO_PAID'] . ' | ' . format_number($left_to_paid) . ' ' . $symbol . ' | ' . $paid_text . ' |
';
if ($focus->currency_id != 'PLN') {
//get currency date
$dd = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("SELECT date, value FROM currency_nbp_archive WHERE currency_id='" . $focus->currency_id . "' AND nbp_table_name='" . $focus->currency_table . "' "));
$content .= "Wartość VAT w zł: " . format_number(($focus->total_vat * $dd['value'])) . ". Przeliczowo wg. kursu NBP (" . $focus->currency_table . ": " . format_number($dd['value'], 4, 4) . " zł) z dnia " . $dd['date'] . '
';
}
$content .= '' . $labels['LBL_PDF_CONTENT_ISSUED_BY'] . ' ' . $user->full_name . '
' . $focus->pdf_text . '
';