263 lines
13 KiB
PHP
Executable File
263 lines
13 KiB
PHP
Executable File
<?
|
||
error_reporting(0);
|
||
global $app_list_strings;
|
||
|
||
$pdf->SetAutoPageBreak(false,40);
|
||
$address = str_replace("<","<",str_replace(">",">",$this->parent_name));
|
||
if($this->parent_contact_name) {
|
||
$address .= "\n".$this->parent_contact_name;
|
||
if($this->parent_contact_title) {
|
||
$address .= "\n".$this->parent_contact_title;
|
||
}
|
||
$personplus=5;
|
||
}
|
||
else $personplus=0;
|
||
|
||
if($this->parent_address_street) $address .= "\n".str_replace("\n","",$this->parent_address_street);
|
||
if($this->parent_address_postalcode) $address .= "\n".$this->parent_address_postalcode;
|
||
if($this->parent_address_city) $address .= " ".$this->parent_address_city;
|
||
if($this->to_nip) $address .= "\n".$mod_strings['LBL_PDF_NIP'].": ".$this->to_nip;
|
||
elseif(!$this->to_nip && $this->to_vatid) $address .= "\n".
|
||
$mod_strings['LBL_PDF_NIP'].": ".$this->to_vatid;
|
||
//mz
|
||
if ($this->document_no=="018/E/2012")
|
||
$address .= "\nGermany\nVAT No:";
|
||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select iln from accounts where id='".$this->parent_id."'"));
|
||
if($r['iln'])$address .= "\nILN: ".$r['iln'];
|
||
|
||
//to address
|
||
$old_x=$pdf->GetX();
|
||
$old_y=$pdf->GetY();
|
||
|
||
$pdf->SetXY(25,43);
|
||
$pdf->SetFont('arialpl', 'B', 8);
|
||
$pdf->Cell(35,1,$mod_strings['LBL_PDF_OWNER2'],0,0,'L',1);
|
||
$pdf->Ln(3);
|
||
$pdf->SetX(25);
|
||
$pdf->SetFont('arialpl', '', 8);
|
||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select vatid from accounts where id='".$pdf->edt->account_id."'"));
|
||
if ($this->ecmlanguage!='pl_pl') $pdf->edt->header_text.=", Poland";
|
||
if($r['vatid'])$pdf->edt->header_text .= "\n".$mod_strings['LBL_PDF_VAT'].": ".$r['vatid'];
|
||
//mz
|
||
if ($this->document_no=="018/E/2012")
|
||
$pdf->edt->header_text .= "\nVendor number: 96026";
|
||
if($r['iln'])$pdf->edt->header_text .= "\nILN: ".$r['iln'];
|
||
$pdf->MultiCell(60,4,$pdf->edt->header_text,0,'L');
|
||
|
||
$pdf->SetXY(81,43);
|
||
$pdf->SetFont('arialpl', 'B', 8);
|
||
$pdf->Cell(35,1,$mod_strings['LBL_PDF_RECIEVER'],0,0,'L',1);
|
||
$pdf->Ln(3);
|
||
$pdf->SetX(81);
|
||
$pdf->SetFont('arialpl', '', 8);
|
||
$pdf->MultiCell(60,4,$address,0,'L');
|
||
|
||
//add mz shipping address
|
||
if ($this->parent_shipping_person) {
|
||
$pdf->SetXY(127,43);
|
||
$pdf->SetFont('arialpl', 'B', 8);
|
||
$pdf->Cell(35,1,$mod_strings['LBL_PDF_SHIPP_TO'],0,0,'L',1);
|
||
$shipping = $this->parent_shipping_person;
|
||
if ($this->parent_shipping_street) $shipping.="\n".$this->parent_shipping_street;
|
||
if ($this->parent_shipping_city) $shipping.="\n".$this->parent_shipping_city;
|
||
if ($this->parent_shipping_country) $shipping.="\n".$this->parent_shipping_country;
|
||
|
||
$pdf->Ln(3);
|
||
$pdf->SetX(127);
|
||
$pdf->SetFont('arialpl', '', 8);
|
||
$pdf->MultiCell(60,4,$shipping,0,'L');
|
||
}
|
||
|
||
$pdf->SetXY(160,$old_y+10+$personplus);
|
||
|
||
$table = array();
|
||
|
||
if($_SESSION['realisation']==1){
|
||
$table [0]['data'] = array('width' => 20, 'value' => "Do zam<61>wienia", 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 8);
|
||
$table [0]['data_value'] = array('width' => 36, 'value' => $this->document_no, 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 8, 'font-style' => 'b');
|
||
}
|
||
|
||
$table [2]['data'] = array('width' => 20, 'value' => $mod_strings['LBL_PDF_DATE_REGISTER'], 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 8);
|
||
$table [2]['data_value'] = array('width' => 36, 'value' => $this->register_date, 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 8, 'font-style'=>'b');
|
||
|
||
$next = 2;
|
||
if(isset($this->validtill_date) && $this->validtill_date != '') {
|
||
$table [3]['data'] = array('width' => 20, 'value' => $mod_strings['LBL_PDF_VALIDTILL_DATE'], 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 8);
|
||
$table [3]['data_value'] = array('width' => 36, 'value' => $this->validtill_date, 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 8, 'font-style'=>'b');
|
||
}
|
||
if(isset($this->delivery_date) && $this->delivery_date != '') {
|
||
$table [4]['data'] = array('width' => 20, 'value' => $mod_strings['LBL_PDF_DELIVERY_DATE'], 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 8);
|
||
$table [4]['data_value'] = array('width' => 36, 'value' => $this->delivery_date, 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 8, 'font-style'=>'b');
|
||
}
|
||
if($this->type=="complaint") {
|
||
$table [5]['data'] = array('width' => 20, 'value' => "Do dokumentu WZ", 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 8);
|
||
$table [5]['data_value'] = array('width' => 36, 'value' => $this->ecmstockdocout_name, 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 8, 'font-style'=>'b');
|
||
}
|
||
|
||
if($this->order_no){
|
||
$table [6]['order_no'] = array('width' => 20, 'value' => $mod_strings['LBL_PDF_ORDER_NO'], 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 8);
|
||
$table [6]['order_no_value'] = array('width' => 36, 'value' => $this->order_no, 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-style' => 'b', 'font-size' => 8);
|
||
}
|
||
if($this->order_qty){
|
||
$table [7]['order_qty'] = array('width' => 20, 'value' => $mod_strings['LBL_PDF_ORDER_QTY'], 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 8);
|
||
$table [7]['order_qty_value'] = array('width' => 36, 'value' => $this->order_qty, 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-style' => 'b', 'font-size' => 8);
|
||
}
|
||
if($this->supplier_code){
|
||
$table [8]['supplier_code'] = array('width' => 20, 'value' => $mod_strings['LBL_PDF_SUPPLIER_CODE'], 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 8);
|
||
$table [8]['supplier_code_value'] = array('width' => 36, 'value' => $this->supplier_code, 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-style' => 'b', 'font-size' => 8);
|
||
}
|
||
$table [9]['data'] = array('width' => 20, 'value' => $mod_strings['LBL_PDF_OWNER'], 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 8);
|
||
$table [9]['data_value'] = array('width' => 36, 'value' => $this->setUser()->full_name, 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 8, 'font-style'=>'b');
|
||
//mz
|
||
$pdf->SetXY(143,10);
|
||
if ($this->document_no=="018/E/2012") {
|
||
$table [10]['email'] = array('width' => 20, 'value' => "Email", 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 8);
|
||
$table [10]['email_value'] = array('width' => 36, 'value' => "dp@e5.pl", 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 8, 'font-style'=>'b');
|
||
$table [11]['email'] = array('width' => 20, 'value' => "Terms of Delivery", 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 8);
|
||
$table [11]['email_value'] = array('width' => 36, 'value' => "EXW PL-87-126 Obrowo", 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 8, 'font-style'=>'b');
|
||
|
||
$table [12]['email'] = array('width' => 20, 'value' => "Terms of Payment", 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 8);
|
||
$table [12]['email_value'] = array('width' => 36, 'value' => "45 days net", 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 8, 'font-style'=>'b');
|
||
$pdf->SetXY(137,10);
|
||
}
|
||
|
||
|
||
$pdf->DrawTable($table, null, 0.5, 0.5, 3);
|
||
|
||
$pdf->SetXY(143,$pdf->tMargin);
|
||
|
||
|
||
$pdf->Ln(9);
|
||
|
||
$pdf->SetFont('arialpl','','18');
|
||
$pdf->SetXY(60,$pdf->tMargin+10);
|
||
|
||
if($_SESSION['realisation']==1)$tit="Lista do realizacji";
|
||
else{
|
||
if($this->type=="sales_order")$tit=$mod_strings['LBL_PDF_DOCUMENT_NAME'];
|
||
elseif($this->type=="back")$tit="Zwrot Towaru";
|
||
elseif($this->type=="serwis_back")$tit="Zwrot Serwisowy";
|
||
elseif($this->type=="gratis")$tit="";
|
||
elseif($this->type=="complaint")$tit="Nota reklamacyjna";
|
||
else $tit=$mod_strings['LBL_PDF_DOCUMENT_NAME'];
|
||
}
|
||
$pdf->MultiCell(80,7,$tit." ".$this->document_no,0,'C');
|
||
$pdf->SetFont('arialpl', 'B', 7);
|
||
$pdf->Ln(3);
|
||
$pdf->SetX(60);
|
||
$pdf->Cell(80,1,$mod_strings['LBL_PDF_ORIGINAL_COPY'],0,0,'C',1);
|
||
|
||
$this->loadParser();
|
||
$this->header_text = $this->template->mfp->parseText($this->header_text);
|
||
$this->footer_text = $this->template->mfp->parseText($this->footer_text);
|
||
$this->ads_text = $this->template->mfp->parseText($this->ads_text);
|
||
|
||
$pdf->SetY($ynew);
|
||
|
||
|
||
|
||
|
||
|
||
|
||
$pdf->SetFont('arialpl','','7');
|
||
global $mod_strings;
|
||
|
||
|
||
$currency = new Currency();
|
||
$currency->retrieve($this->currency_id);
|
||
$this->currency_symbol=$currency->iso4217;
|
||
|
||
if(!isset($this->position_list) || !is_array($this->position_list))
|
||
$this->position_list = $this->getPositionList(true);
|
||
$calc = $this->calculate($this->position_list,true);
|
||
|
||
$calc['total'] .= ' '.$this->currency_symbol;
|
||
$calc['subtotal'] .= ' '.$this->currency_symbol;
|
||
if($calc['discount']) {
|
||
$calc['total2'] .= ' '.$this->currency_symbol;
|
||
$calc['discount']['value'] .= ' '.$this->currency_symbol;
|
||
}
|
||
|
||
if(isset($calc['vats']) && is_array($calc['vats']) && count($calc['vats']) > 0)
|
||
foreach($calc['vats'] as $key => $value) $calc['vats'][$key] .= ' '.$this->currency_symbol;
|
||
|
||
|
||
|
||
$pdf->Ln(15);
|
||
$name_w = 43;
|
||
$table = array();
|
||
|
||
$table [0]['position'] = array('width' => 5, 'value' => $mod_strings['LBL_PDF_LIST_POSITION'], 'border' => 1,'font-style' => 'b', 'overflow' => 1, 'align' => 'C');
|
||
$table [0]['code'] = array('width' => 12, 'value' => "Index", 'border' => 1,'font-style' => 'b', 'overflow' => 1, 'align' => 'C');
|
||
$table [0]['description'] = array('width' => $name_w, 'value' => $mod_strings['LBL_PDF_LIST_DESCRIPTION'], 'border' => 1, 'overflow' => 1, 'align' => 'C');
|
||
$table [0]['quantity'] = array('width' => 8, 'value' => $mod_strings['LBL_PDF_LIST_QUANTITY'], 'border' => 1,'font-style' => 'b', 'overflow' => 1, 'align' => 'C');
|
||
$table [0]['unit'] = array('width' => 5, 'value' => $mod_strings['LBL_PDF_LIST_UNIT'], 'border' => 1,'font-style' => 'b', 'overflow' => 1, 'align' => 'C');
|
||
$table [0]['unit_price'] = array('width' => 14, 'value' => $mod_strings['LBL_PDF_LIST_PRICE'], 'border' => 1,'font-style' => 'b', 'overflow' => 1, 'align' => 'C');
|
||
$table [0]['total'] = array('width' => 14, 'value' => $mod_strings['LBL_PDF_TOTAL'], 'border' => 1,'font-style' => 'b', 'overflow' => 1, 'align' => 'R');
|
||
$pdf->SetY(70);
|
||
$pdf->DrawTable($table,array(0));
|
||
$pdf->Ln(0);
|
||
|
||
$table=array();
|
||
$i = 1;
|
||
$lv=return_app_list_strings_language($this->ecmlanguage);
|
||
|
||
if($this->position_list != '')
|
||
foreach($this->position_list as $p) {
|
||
$table [$i]['position'] = array('width' => 5, 'value' => $i, 'border' => 1, 'align' => 'C', );
|
||
$table [$i]['code'] = array('width' => 12, 'value' => $p['code'], 'border' => 1, 'align' => 'C', );
|
||
$table [$i]['description'] = array('width' => $name_w, 'value' => htmlspecialchars_decode($p['name']), 'border' => 1, 'align' => 'L', );
|
||
$table [$i]['quantity'] = array('width' => 8, 'value' => $p['quantity'], 'border' => 1, 'align' => 'C', );
|
||
$table [$i]['unit'] = array('width' => 5, 'value' => $lv['ecmproducts_unit_dom'][$p['unit_id']], 'border' => 1, 'align' => 'C', 'font-size' => 7 );
|
||
$table [$i]['unit_price'] = array('width' => 14, 'value' => format_number($p['price']).' '.$this->currency_symbol, 'border' => 1, 'align' => 'C', );
|
||
$table [$i]['total'] = array('width' => 14, 'value' => format_number($p['total']).' '.$this->currency_symbol, 'border' => 1, 'align' => 'R', );
|
||
$i++;
|
||
}
|
||
$pdf->DrawTable($table,array(0));
|
||
|
||
|
||
$pdf->Ln(4);
|
||
$pr = ($pdf->fw-$pdf->lMargin-$pdf->rMargin)/100;
|
||
$table = array();
|
||
|
||
if($calc['vats']) {
|
||
$table [] = array(
|
||
'subtotal1' => array('width' => 13,'font-style' => 'b', 'value' => $mod_strings['LBL_PDF_TOTAL'], 'border' => 1, 'overflow' => 1, 'align' => 'L', 'font-size' => 9),
|
||
'subtotal2' => array('width' => 28, 'value' => $calc['subtotal'], 'border' => 1, 'overflow' => 1, 'align' => 'R', 'font-size' => 9),
|
||
);
|
||
|
||
foreach($calc['vats'] as $key => $value){
|
||
$r=mysql_fetch_array(mysql_query("select name from ecmvats where id='".$key."'"));
|
||
$vvn=$r['name'];
|
||
$table [] = array(
|
||
'vat1' => array('width' => 13,'font-style' => 'b', 'value' => $mod_strings['LBL_PDF_VAT'].' ('.$vvn.')','border' => 1, 'overflow' => 1, 'align' => 'L', 'font-size' => 9),
|
||
'vat2' => array('width' => 28, 'value' => $value, 'border' => 1, 'overflow' => 1, 'align' => 'R', 'font-size' => 9)
|
||
);
|
||
}
|
||
}
|
||
|
||
$table [] = array(
|
||
'total1' => array('width' => 13,'font-style' => 'b', 'value' => $mod_strings['LBL_PDF_END_TOTAL'],'border' => 1, 'overflow' => 1, 'align' => 'L', 'font-size' => 9, 'font-style' => 'b'),
|
||
'total2' => array('width' => 28, 'value' => $calc['total'], 'border' => 1, 'overflow' => 1, 'align' => 'R' , 'font-size' => 9, 'font-style' => 'b'),
|
||
);
|
||
|
||
if($pdf->GetY()+30>$pdf->fh-$pdf->bMargin)$pdf->AddPage();
|
||
$pdf->SetX(127);
|
||
$pdf->DrawTable($table);
|
||
|
||
$pdf->Ln(10);
|
||
|
||
$pdf->SetFont('arialpl','B','10');
|
||
|
||
$exp=explode("
|
||
",$this->ads_text);
|
||
if(count($exp)>0){
|
||
foreach($exp as $ee){
|
||
if($pdf->GetY()+10>$pdf->fh-$pdf->bMargin)$pdf->AddPage();
|
||
$pdf->MultiCell(0,4,$ee,0,'L');
|
||
}
|
||
}
|
||
|
||
|
||
|
||
?>
|