219 lines
12 KiB
PHP
Executable File
219 lines
12 KiB
PHP
Executable File
<?
|
|
|
|
global $app_list_strings;
|
|
//echo __LINE__;exit;
|
|
|
|
$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".$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_vatid) $address .= "\n".$mod_strings['LBL_PDF_VATID']." ".$this->to_vatid;
|
|
if($this->to_nip) $address .= "\nNip: ".$this->to_nip;
|
|
elseif(!$this->to_nip && $this->to_vatid) $address .= "\nNip: ".$this->to_vatid;
|
|
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select iln,to_nip 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,"WYSTAWCA:",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($r['vatid'])$pdf->edt->header_text .= "\nNip: ".$r['vatid'];
|
|
if($r['iln'])$pdf->edt->header_text .= "\nILN: ".$r['iln'];
|
|
|
|
//$this->loadParser();
|
|
//$pdf->header_text = $pdf->template->mfp->parseText($pdf->header_text);
|
|
$pdf->MultiCell(60,4,$pdf->edt->header_text,0,'L');
|
|
|
|
$pdf->SetXY(81,43);
|
|
$pdf->SetFont('arialpl', 'B', 8);
|
|
$pdf->Cell(35,1,"ODBIORCA:",0,0,'L',1);
|
|
$pdf->Ln(3);
|
|
$pdf->SetX(81);
|
|
$pdf->SetFont('arialpl', '', 8);
|
|
$pdf->MultiCell(60,4,$address,0,'L');
|
|
|
|
$address="";
|
|
$address = str_replace("<","<",str_replace(">",">",$r['parent_name']));
|
|
if($r['parent_address_street']) $address .= "\n".$r['parent_address_street'];
|
|
if($r['parent_address_postalcode']) $address .= "\n".$r['parent_address_postalcode'];
|
|
if($r['parent_address_city']) $address .= " ".$r['parent_address_city'];
|
|
if($r['to_nip']) $address .= "\nNip: ".$r['to_nip'];
|
|
elseif(!$r['to_nip'] && $r['to_vatid']) $address .= "\nNip: ".$r['to_vatid'];
|
|
$rr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select iln from accounts where id='".$r['parent_id']."'"));
|
|
if($rr['iln'])$address .= "\nILN: ".$rr['iln'];
|
|
|
|
$ynew=$pdf->GetY()+12;
|
|
|
|
|
|
|
|
if($this->ecmpaymentcondition_id){
|
|
require_once("modules/EcmPaymentConditions/EcmPaymentCondition.php");
|
|
$pc=new EcmPaymentCondition();
|
|
$pc->retrieve($this->ecmpaymentcondition_id);
|
|
}
|
|
|
|
$pdf->SetXY(160,$old_y+10+$personplus);
|
|
|
|
$table = array();
|
|
|
|
$table [0]['date_reg'] = array('width' => 20, 'value' => "Data wystawienia", 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 8);
|
|
$table [0]['date_reg_value'] = array('width' => 36, 'value' => $this->register_date, 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-style' => 'b', 'font-size' => 8);
|
|
$table [1]['date_reg1'] = array('width' => 20, 'value' => "Data przedpłaty", 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 8);
|
|
$table [1]['date_reg1_value'] = array('width' => 36, 'value' => $this->register_date, 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-style' => 'b', 'font-size' => 8);
|
|
|
|
|
|
|
|
if($this->ecmpaymentcondition_id){
|
|
$table [2]['payment_method'] = array('width' => 20, 'value' => "Metoda płatności", 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 8);
|
|
$table [2]['payment_method_value'] = array('width' => 25, 'value' => $app_list_strings['ecmpaymentconditions_payment_method_dom'][$pc->payment_method], 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-style' => 'b', 'font-size' => 8);
|
|
}
|
|
|
|
$pdf->SetXY(143,$pdf->tMargin);
|
|
$pdf->DrawTable($table, null, 0.5, 0.5, 3);
|
|
|
|
|
|
$pdf->Ln(5);
|
|
|
|
$pdf->SetFont('arialpl','','18');
|
|
$pdf->SetXY(60,$pdf->tMargin+10);
|
|
|
|
$pdf->MultiCell(80,7,"Faktura VAT"." ".$this->document_no,0,'C');
|
|
$pdf->SetFont('arialpl', 'B', 7);
|
|
$pdf->Ln(3);
|
|
$pdf->SetX(60);
|
|
|
|
$pdf->SetY($ynew);
|
|
|
|
$table = array();
|
|
if(!$this->currency_value)$this->currency_value=1;
|
|
$table [0][] = array('width' => 4, 'value' => "Lp.", 'border' => 1,'font-style' => 'b', 'overflow' => 1, 'align' => 'L');
|
|
$table [0][] = array('width' => 32, 'value' => "Nazwa", 'border' => 1,'font-style' => 'b', 'overflow' => 1, 'align' => 'L');
|
|
$table [0][] = array('width' => 7, 'value' => "Ilość", 'border' => 1, 'overflow' => 1,'font-style' => 'b', 'align' => 'L');
|
|
$table [0][] = array('width' => 5, 'value' => "J.M.", 'border' => 1,'font-style' => 'b', 'overflow' => 1, 'align' => 'L');
|
|
$table [0][] = array('width' => 12, 'value' => "Cena Netto", 'border' => 1,'font-style' => 'b', 'overflow' => 1, 'align' => 'L');
|
|
$table [0][] = array('width' => 12, 'value' => "Wartość Netto", 'border' => 1,'font-style' => 'b', 'overflow' => 1, 'align' => 'L');
|
|
$table [0][] = array('width' => 8, 'value' => "VAT", 'border' => 1,'font-style' => 'b', 'overflow' => 1, 'align' => 'L');
|
|
$table [0][] = array('width' => 11, 'value' => "Wartość Vat", 'border' => 1,'font-style' => 'b', 'overflow' => 1, 'align' => 'L');
|
|
$table [0][] = array('width' => 11, 'value' => "Wartośc Brutto", 'border' => 1,'font-style' => 'b', 'overflow' => 1, 'align' => 'L');
|
|
$table [1][] = array('width' => 4, 'value' => "1", 'border' => 1,'font-style' => 'b', 'overflow' => 1, 'align' => 'L');
|
|
$table [1][] = array('width' => 32, 'value' => $this->description, 'border' => 1,'font-style' => '', 'overflow' => 1, 'align' => 'L');
|
|
$table [1][] = array('width' => 7, 'value' => "1", 'border' => 1, 'overflow' => 1,'font-style' => '', 'align' => 'L');
|
|
$table [1][] = array('width' => 5, 'value' => "SZT.", 'border' => 1,'font-style' => '', 'overflow' => 1, 'align' => 'L');
|
|
$table [1][] = array('width' => 12, 'value' => number_format(($this->inv_value/(1+$this->ecmvat_value/100))*$this->currency_value,2,",",".").$this->currency_id, 'border' => 1,'font-style' => '', 'overflow' => 1, 'align' => 'L');
|
|
$table [1][] = array('width' => 12, 'value' => number_format(($this->inv_value/(1+$this->ecmvat_value/100))*$this->currency_value,2,",",".").$this->currency_id, 'border' => 1,'font-style' => '', 'overflow' => 1, 'align' => 'L');
|
|
$table [1][] = array('width' => 8, 'value' => $this->ecmvat_name, 'border' => 1,'font-style' => '', 'overflow' => 1, 'align' => 'L');
|
|
$table [1][] = array('width' => 11, 'value' => number_format(($this->inv_value-($this->inv_value/(1+$this->ecmvat_value/100)))*$this->currency_value,2,",",".")." ".$this->currency_id, 'border' => 1,'font-style' => '', 'overflow' => 1, 'align' => 'L');
|
|
$table [1][] = array('width' => 11, 'value' => $this->inv_value, 'border' => 1,'font-style' => '', 'overflow' => 1, 'align' => 'L');
|
|
$pdf->DrawTable($table,array(0));
|
|
$pdf->Ln(0);
|
|
|
|
|
|
$pdf->SetFont('arialpl','','7');
|
|
global $mod_strings;
|
|
|
|
|
|
$currency = new Currency();
|
|
$currency->retrieve($this->currency_id);
|
|
$this->currency_symbol=$currency->iso4217;
|
|
|
|
|
|
|
|
$lv=return_app_list_strings_language($this->ecmlanguage);
|
|
if($this->ecmsale_id){
|
|
include_once("modules/EcmSales/EcmSale.php");
|
|
$sale=new EcmSale();
|
|
$sale->retrieve($this->ecmsale_id);
|
|
$this->position_list=$sale->getPositionList(true);
|
|
$calc = $sale->calculate($this->position_list,true);
|
|
}
|
|
$pdf->Ln(5);
|
|
$name_w = 43;
|
|
|
|
|
|
|
|
$pdf->Ln(10);
|
|
|
|
|
|
|
|
|
|
$y=$pdf->GetY();
|
|
|
|
$rzal=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select date_entered from ecmprepaymentinvoices where id='".$this->id."'"));
|
|
$wi=$GLOBALS['db']->query("select document_no,register_date,inv_value,date_entered,currency_value from ecmprepaymentinvoices where deleted='0' and ecmsale_id='".$this->ecmsale_id."' and date_entered<'".$rzal['date_entered']."'");
|
|
|
|
if (mysql_num_rows($wi) > 0) {
|
|
$table = array();
|
|
|
|
$table [0]['position'] = array('width' => 4, 'value' => "Lp.", 'border' => 1,'font-style' => 'b', 'overflow' => 1, 'align' => 'L');
|
|
$table [0]['number'] = array('width' => 13, 'value' => "Numer faktury", 'border' => 1,'font-style' => 'b', 'overflow' => 1, 'align' => 'L');
|
|
$table [0]['date'] = array('width' => 11, 'value' => "Data", 'border' => 1, 'overflow' => 1,'font-style' => 'b', 'align' => 'L');
|
|
$table [0]['value'] = array('width' => 17, 'value' => "Wartość brutto", 'border' => 1,'font-style' => 'b', 'overflow' => 1, 'align' => 'R');
|
|
$pdf->MultiCell(80,7,"Poprzednie zaliczki:",0,'L');
|
|
$pdf->DrawTable($table,array(0));
|
|
$pdf->Ln(0);
|
|
|
|
$table=array();
|
|
$i = 1;
|
|
$lv=return_app_list_strings_language($this->ecmlanguage);
|
|
$rzal=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select date_entered from ecmprepaymentinvoices where id='".$this->id."'"));
|
|
$wi=$GLOBALS['db']->query("select document_no,register_date,inv_value,date_entered,currency_value from ecmprepaymentinvoices where deleted='0' and ecmsale_id='".$this->ecmsale_id."' and date_entered<'".$rzal['date_entered']."'");
|
|
while($ri=$GLOBALS['db']->fetchByAssoc($wi)){
|
|
$m++;
|
|
if(!$ri['currency_value'])$ri['currency_value']=1;
|
|
$sum+=$ri['inv_value']*$ri['currency_value'];
|
|
$table [$m]['position'] = array('width' => 4, 'value' => $m, 'border' => 1, 'align' => 'L', );
|
|
$table [$m]['number'] = array('width' => 13, 'value' => $ri['document_no'], 'border' => 1, 'align' => 'L', );
|
|
$table [$m]['date'] = array('width' => 11, 'value' => $ri['register_date'], 'border' => 1, 'align' => 'L', );
|
|
$table [$m]['value'] = array('width' => 17, 'value' => number_format($ri['inv_value'],2,",",".")." PLN", 'border' => 1, 'align' => 'C', );
|
|
}
|
|
$table [$m+1]['position'] = array('width' => 4, 'value' => "", 'border' => 1, 'align' => 'L', );
|
|
$table [$m+1]['number'] = array('width' => 13, 'value' => "", 'border' => 1, 'align' => 'L', );
|
|
$table [$m+1]['date'] = array('width' => 11, 'value' => "Razem", 'border' => 1, 'align' => 'L', );
|
|
$table [$m+1]['value'] = array('width' => 17, 'value' => number_format($sum,2,",",".")." PLN", 'border' => 1, 'align' => 'C', );
|
|
$pdf->DrawTable($table);
|
|
}
|
|
$pdf->SetXY(114,$y);
|
|
$table = array();
|
|
|
|
$table [0]['rate'] = array('width' => 8, 'value' => "Stawka", 'border' => 1,'font-style' => 'b', 'overflow' => 1, 'align' => 'L');
|
|
$table [0]['netto'] = array('width' => 16, 'value' => "Wartość netto", 'border' => 1,'font-style' => 'b', 'overflow' => 1, 'align' => 'L');
|
|
$table [0]['vat'] = array('width' => 10, 'value' => "Vat", 'border' => 1, 'overflow' => 1,'font-style' => 'b', 'align' => 'L');
|
|
$table [0]['brutto'] = array('width' => 16, 'value' => "Wartość brutto", 'border' => 1,'font-style' => 'b', 'overflow' => 1, 'align' => 'R');
|
|
$pdf->MultiCell(80,7,"Rozliczenie zaliczki wg stawek:",0,'L');
|
|
$pdf->SetX(114);
|
|
$pdf->DrawTable($table,array(0));
|
|
$pdf->Ln(0);
|
|
|
|
$this->currency_value=1;
|
|
$table=array();
|
|
$i=1;
|
|
$table [$i]['rate'] = array('width' => 8, 'value' => $this->ecmvat_name, 'border' => 1, 'align' => 'L', );
|
|
$table [$i]['netto'] = array('width' => 16, 'value' => number_format(($this->inv_value/(1+$this->ecmvat_value/100))*$this->currency_value,2,",",".").$this->currency_id, 'border' => 1, 'align' => 'L', );
|
|
$table [$i]['vat'] = array('width' => 10, 'value' => number_format(($this->inv_value-($this->inv_value/(1+$this->ecmvat_value/100)))*$this->currency_value,2,",",".")." ".$this->currency_id, 'border' => 1, 'align' => 'L', );
|
|
$table [$i]['brutto'] = array('width' => 16, 'value' => number_format(($this->inv_value)*$this->currency_value,2,",",".")." PLN", 'border' => 1, 'align' => 'R', );
|
|
|
|
|
|
|
|
|
|
|
|
//$table=array();
|
|
$pdf->SetX(114);
|
|
$pdf->DrawTable($table);
|
|
|
|
?>
|