73 lines
2.4 KiB
PHP
73 lines
2.4 KiB
PHP
<?php
|
|
|
|
//ini_set('display_errors', '1');
|
|
//ini_set('display_startup_errors', '1');
|
|
//error_reporting(E_ALL);
|
|
|
|
if (!$_REQUEST['record'] || $_REQUEST['record'] == '')
|
|
die('Brak rekordu');
|
|
else
|
|
$record = $_REQUEST['record'];
|
|
|
|
include_once("modules/EcmPrepaymentInvoices/PDFTemplate/helper.php");
|
|
include_once("modules/EcmPrepaymentInvoices/EcmPrepaymentInvoice.php");
|
|
include_once("modules/EcmSales/EcmSale.php");
|
|
|
|
$focus = new EcmPrepaymentInvoice();
|
|
$focus->retrieve($record);
|
|
|
|
$user = new User();
|
|
$user->retrieve($focus->assigned_user_id);
|
|
$labels = return_module_language($focus->ecmlanguage, 'EcmPrepaymentInvoices');
|
|
include_once("include/MPDF57/mpdf.php");
|
|
$p = new mPDF('', 'A4', null, 'helvetica', 10, 10, 30, 45, 5, 5);
|
|
$mpdf->mirrorMargins = 1;
|
|
|
|
$db = $GLOBALS['db'];
|
|
|
|
$header = '';
|
|
$footer = '';
|
|
$content = '';
|
|
|
|
$positions = array();
|
|
$positions[0]['position'] = "1";
|
|
$positions[0]['name'] = $focus->description;
|
|
$positions[0]['unit_name'] = "szt.";
|
|
$positions[0]['quantity'] = "1";
|
|
$positions[0]['ecmvat_name'] = $focus->ecmvat_name;
|
|
$positions[0]['total_brutto'] = format_number($focus->inv_value);
|
|
$netto = $focus->inv_value * 100 / (100 + $focus->ecmvat_value);
|
|
$positions[0]['total_netto'] = format_number($netto);
|
|
$positions[0]['price_netto'] = format_number($netto);
|
|
$vat = $focus->inv_value - $netto;
|
|
$positions[0]['total_vat'] = format_number($vat);
|
|
|
|
$sale = new EcmSale();
|
|
$sale->retrieve($focus->ecmsale_id);
|
|
$sale_positions = $sale->getPositionList(true);
|
|
$result = array();
|
|
foreach ($sale_positions as $pos) {
|
|
$pos['position'] = $pos['position']+1;
|
|
$pos['total_vat'] = format_number($pos['total_brutto']-$pos['total_netto']);
|
|
$pos['total_netto'] = format_number($pos['total_netto']);
|
|
$pos['price_netto'] = format_number($pos['price_netto']);
|
|
$pos['total_brutto'] = format_number($pos['total_brutto']);
|
|
$result[] = $pos;
|
|
}
|
|
$sale_positions = $result;
|
|
//var_dump($sale_positions);
|
|
|
|
include_once("modules/EcmPrepaymentInvoices/PDFTemplate/tpl/header.php");
|
|
include_once("modules/EcmPrepaymentInvoices/PDFTemplate/tpl/footer.php");
|
|
include_once("modules/EcmPrepaymentInvoices/PDFTemplate/tpl/content.php");
|
|
|
|
|
|
global $current_user, $app_list_strings;
|
|
$p->SetHTMLHeader($header);
|
|
$p->SetHTMLFooter($footer);
|
|
$p->WriteHTML($content);
|
|
//echo $content;
|
|
// draw PDF
|
|
$filename = str_replace(" ", "_", str_replace("/", "_", $focus->document_no));
|
|
$p->Output($filename . '.pdf', 'I');
|