This commit is contained in:
2024-04-27 09:23:34 +02:00
commit 11e713ca6f
11884 changed files with 3263371 additions and 0 deletions

View File

@@ -0,0 +1,343 @@
<?php
$pdf->WriteHtml('</table>');
$pdf->SetAutoPageBreak(true, 20);
//$pdf->AddFont('arialgr', '', 'arialgr.php');
//$pdf->SetFont('arialgr','','8');
//$pdf->MultiCell(0,4,"TEST",0,'J');
$lv = return_app_list_strings_language($this->ecmlanguage);
//echo $this->invoice_type . ' - ' . $this->currency_symbol;
//exit;
//if ($this->currency_symbol != 'EUR') {
$c = new Currency();
$c->retrieve('6336d9a0-ee5f-52e3-7d0c-4e6f1472b2bf');
if ($this->invoice_type == 'K') {
if($this->currency_symbol != 'EUR') {
$pdf->SetFont('arialpl', '', 8);
$pdf->setX(11);
$pdf->WriteHtml(sprintf('Podana wartość zamówienia wg aktualnego kursu sprzedaży walut w banku Citi Handlowym: 1 EUR = %s %s.', format_number($c->conversion_rate, 4, 4), $this->currency_symbol));
$pdf->Ln(4);
$pdf->setX(11);
$pdf->WriteHtml('Ceny zostaną przeliczone wg odpowiedniego kursu obowiązującego w chwili wystawienia faktury.');
$pdf->Ln(4);
} else {
$pdf->SetFont('arialpl', '', 8);
$pdf->setX(11);
$pdf->WriteHtml('Faktura zostanie wystawiona w walucie EURO i płatność nastąpi w walucie EURO.');
$pdf->Ln(4);
}
}
if ($this->payment_method && $this->payment_method != 'INNY') {
$table = array();
$pm = $lv['payment_method_dom'][$this->payment_method];
if ($this->payment_deadline && $this->payment_deadline != '')
$pm.=', ' . $this->payment_deadline . ' dni';
$table [0][] = array(
'width' => 30,
'value' => $mod_strings['LBL_PDF_PAYMENT'],
'border' => 0,
'overflow' => 1,
'align' => 'L',
'font-style' => 'b',
'font-size' => 9,
);
$table [0][] = array(
'width' => 70,
'value' => $pm,
'border' => 0,
'overflow' => 1,
'align' => 'L',
'font-style' => '',
'font-size' => 9,
);
$pdf->Ln(5);
$pdf->DrawTable($table, null, 0, 0, 3);
} elseif ($this->payment_description != '' && $this->payment_method == '') {
$table = array();
$table [0][] = array(
'width' => 30,
'value' => $mod_strings['LBL_PDF_PAYMENT'],
'border' => 0,
'overflow' => 1,
'align' => 'L',
'font-style' => 'b',
'font-size' => 9,
);
$table [0][] = array(
'width' => 70,
'value' => $this->payment_description,
'border' => 0,
'overflow' => 1,
'align' => 'L',
'font-style' => '',
'font-size' => 9,
);
$pdf->Ln(5);
$pdf->DrawTable($table, null, 0, 0, 3);
}
if ($this->realization_description && $this->realization_description != '') {
$table = array();
$table [0][] = array('width' => 30, 'value' => $mod_strings['LBL_PDF_REALIZATION'], 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-style' => 'b', 'font-size' => 9);
$table [0][] = array('width' => 70, 'value' => $this->realization_description, 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-style' => '', 'font-size' => 9);
$pdf->Ln(1);
$pdf->DrawTable($table, null, 0, 0, 3);
}
if ($this->delivery_description && $this->delivery_description != '') {
$table = array();
$table [0][] = array('width' => 30, 'value' => $mod_strings['LBL_PDF_DELIVERY'], 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-style' => 'b', 'font-size' => 9);
$table [0][] = array('width' => 70, 'value' => $this->delivery_description, 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-style' => '', 'font-size' => 9);
$pdf->Ln(1);
$pdf->DrawTable($table, null, 0, 0, 3);
}
//check delivery address
$q = "
select
shipping_address_street,
shipping_address_city,
shipping_address_postalcode,
shipping_address_state,
shipping_address_country
from accounts where
(shipping_address_street!=billing_address_street OR
shipping_address_city!=billing_address_city OR
shipping_address_postalcode!=billing_address_postalcode OR
shipping_address_state!=billing_address_state OR
shipping_address_country!=billing_address_country) AND
id='" . $this->parent_id . "';
";
$res = $GLOBALS['db']->query($q);
if (mysql_num_rows($res) > 0) {
$r = $GLOBALS['db']->fetchByAssoc($res);
$table = array();
$table [0][] = array('width' => 30, 'value' => $mod_strings['LBL_PDF_SHIP_TO'], 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-style' => 'b', 'font-size' => 9);
$table [0][] = array('width' => 100, 'value' => html_entity_decode($r['shipping_address_street']) . ', ' . html_entity_decode($r['shipping_address_postalcode']) . ' ' . html_entity_decode($r['shipping_address_city']), 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-style' => '', 'font-size' => 9);
$pdf->Ln(1);
$pdf->DrawTable($table, null, 0, 0, 3);
}
//echo '<pre>'. var_export($this->currency_symbol, true); exit;
/*
$pdf->SetX(10);
$pdf->SetFont('arialpl', 'b', 8);
$pdf->Cell(25, 4, 'Metoda płatności: ', 0, 0, 'L', 1);
global $app_list_strings;
$pdf->SetFont('arialpl', '', 8);
//echo '<pre>' . var_export($this->payment_method, true);
//echo '<pre>' . var_export($app_list_strings['payment_method_dom'], true);exit;
if($this->payment_method != '' && $this->payment_method != 'INNY') {
$pdf->Cell(50, 4, $app_list_strings['payment_method_dom'][$this->payment_method] . ($this->payment_deadline ? (', ' . $this->payment_deadline . ' dni') : '') , 0, 0, 'L', 1);
} else {
$pdf->Cell(50, 4, $this->payment_description, 0, 0, 'L', 1);
}
$pdf->Ln(4);
*/
if ($this->footer_text != '') {
//footer text
$pdf->Ln(4);
$pdf->SetFont('arialpl', '', '8');
$pdf->MultiCell(0, 4, $this->footer_text, 0, 'J');
}
//payment conditions
$pdf->SetFont('arialpl', 'B', '8');
/*
// if($this->payment_method)$pm.=$mod_strings['LBL_PDF_PAYMENT_METHOD'].$GLOBALS['app_list_strings']['payment_method_dom'][$this->payment_method]." ";
// if($this->payment_deadline)$pm.=$mod_strings['LBL_PDF_PAYMENT_DEADLINE'].$this->payment_deadline.$mod_strings['LBL_PDF_PAYMENT_DEADLINE2']." ";
$pm.="\n";
// if($this->payment_description)$pm.=$mod_strings['LBL_PDF_PAYMENT_DESCRIPTION'].$this->payment_description." ";
if($pm){
$pdf->Ln();
$pdf->MultiCell(0,4,$pm,0,'L');
}
if($this->validtill_date){
$pdf->Ln();
$pdf->MultiCell(0,4,$mod_strings['LBL_PDF_VALIDTILL_DATE'].": ".$this->validtill_date,0,'L');
}
*/
if ($this->ads_text != '') {
//ads text
$pdf->Ln(4);
$pdf->SetFont('arialpl', '', '8');
$pdf->MultiCell(0, 4, $this->ads_text, 0, 'J');
}
/*
if($this->show_primary_params){
$pdf->AddPage();
$pdf->SetFont('arialpl','B','14');
$pdf->MultiCell(0,8,$mod_strings['LBL_PDF_PARAMS_HEADER'],0,'J');
$pdf->Ln(6);
$tab_header = array(
'name' => array(
'width' => 44,
'value' => $mod_strings['LBL_PDF_PARAMS_HEADER_NAME'],
'background' => array(233,233,233),
'border' => 0,
'overflow' => 1,
'align' => 'L',
'font-size' => 7,
'font-style' => 'b'
),
'symbol' => array(
'width' => 30,
'value' => $mod_strings['LBL_PDF_PARAMS_HEADER_SYMBOL'],
'background' => array(233,233,233),
'border' => 0,
'overflow' => 1,
'align' => 'C',
'font-size' => 7,
'font-style' => 'b'
),
'value' => array(
'width' => 12,
'value' => $mod_strings['LBL_PDF_PARAMS_HEADER_VALUE'],
'background' => array(233,233,233),
'border' => 0,
'overflow' => 1,
'align' => 'C',
'font-size' => 7,
'font-style' => 'b'
),
'unit' => array(
'width' => 12,
'value' => $mod_strings['LBL_PDF_PARAMS_HEADER_UNIT'],
'background' => array(233,233,233),
'border' => 0,
'overflow' => 1,
'align' => 'C',
'font-size' => 7,
'font-style' => 'b'
),
);
$i=0;
foreach($this->position_list as $p) {
$i++;
$pdf->SetFont('arialpl','B','11');
$lv=return_app_list_strings_language($this->ecmlanguage);
$tablen = array();
$tablen [0]['position'] = array('width' => 5, 'value' => $mod_strings['LBL_PDF_LIST_POSITION'], 'background' => array(233,233,233), 'border' => 0, 'overflow' => 1, 'align' => 'C');
$tablen [0]['description'] = array('width' => 95, 'value' => $mod_strings['LBL_PDF_LIST_DESCRIPTION'], 'background' => array(233,233,233), 'border' => 0, 'overflow' => 1, 'align' => 'C');
$tablen [1]['position'] = array('width' => 5, 'value' => $i, 'border' => 0, 'align' => 'C' );
$tablen [1]['description'] = array('width' => 95, 'value' => htmlspecialchars_decode($p['name']), 'border' => 0, 'align' => 'L' );
//$pdf->SetFont('arialpl','B','9');
$pdf->SetFont('arialgr','','8');
//$pdf->Ln();
$table = array();
$table_advanced = array();
$table[]=$tab_header;
$table_advanced[]=$tab_header;
$w_p=$GLOBALS['db']->query("select * from ecmquoteitemsparams where ecmquote_id='".$this->id."' and item_id='".$p['iid']."' and deleted='0' order by position asc");
$pom=0;
while($r_p=$GLOBALS['db']->fetchByAssoc($w_p)){
$pom=1;
$tab_item=array(
'name' => array(
'width' => 44,
'value' => $r_p['name'],
'background' => array(255,255,255),
'border' => 0,
'overflow' => 1,
'align' => 'L',
'font-size' => 7,
'font-style' => ''
),
'symbol' => array(
'width' => 30,
'value' => $r_p['symbol'],
'background' => array(255,255,255),
'border' => 0,
'overflow' => 1,
'align' => 'C',
'font-size' => 7,
'font-style' => ''
),
'value' => array(
'width' => 12,
'value' => $r_p['value'],
'background' => array(255,255,255),
'border' => 0,
'overflow' => 1,
'align' => 'C',
'font-size' => 7,
'font-style' => ''
),
'unit' => array(
'width' => 12,
'value' => $r_p['unit'],
'background' => array(255,255,255),
'border' => 0,
'overflow' => 1,
'align' => 'C',
'font-size' => 7,
'font-style' => ''
),
);
if ($r_p['value']!='') {
if($r_p['type']=="P" || $r_p['type']==""){
$table[]=$tab_item;
$table_advanced[]=$tab_item;
}
else $table_advanced[]=$tab_item;
}
}
if($pom){
$pdf->DrawTable($tablen);
if(!$this->show_advanced_params)$pdf->DrawTable($table);
if($this->show_advanced_params){
$pdf->SetFont('arialpl','B','9');
$pdf->DrawTable($table_advanced);
}
$pdf->Ln(10);
}
}
}
*/

View File

@@ -0,0 +1,670 @@
<?php
global $db;
$mod_strings['LBL_PDF_FOOTER_DOCUMENT_NAME'] = 'Potwierdzenie zamówienia';
$pdf->focus = $this;
$pdf->Ln(2);
$pdf->SetY($pdf->GetY() + 2);
$current = $pdf->GetY();
$pdf->SetFont('arialpl', '', 9);
//$p_name = html_entity_decode($this->parent_name);
//$p_name = explode(' ', $p_name);
//
//$name = array();
//
//if (sizeof($p_name) > 4) {
// for ($i = 0; $i < sizeof($p_name); $i++) {
// $n.=$p_name[$i] . ' ';
// //$pdf->Cell(40,5, $n,0,1,'L');
// if (($i % 5 == 0) && ($i != 0)) {
// $name[] = $n;
// $n = '';
// }
// }
// $name[] = $n;
//}
//
//if ($this->parent_name) {
// if (sizeof($p_name) > 4)
// foreach ($name as $n)
// $pdf->Cell(40, 5, $n, 0, 1, 'L');
// else
// $pdf->Cell(40, 5, html_entity_decode($this->parent_name), 0, 1, 'L');
//}
$pdf->MultiCell(100, 5, html_entity_decode($this->parent_name), 0, 1, 'L');
//$pdf->SetFont('arialpl', '', 10);
if ($this->parent_address_street)
$pdf->Cell(20, 5, html_entity_decode($this->parent_address_street), 0, 1, 'L');
if (($this->parent_address_postalcode) || ($this->parent_address_city))
$pdf->Cell(20, 5, html_entity_decode($this->parent_address_postalcode) . ' ' . html_entity_decode($this->parent_address_city), 0, 1, 'L');
if ($this->to_vatid)
$pdf->Cell(20, 5, $mod_strings['LBL_PDF_VATID'] . ' ' . html_entity_decode($this->to_vatid), 0, 1, 'L');
$title = '';
if ($this->parent_contact_title) {
$title.=$this->parent_contact_title . ' ';
}
if ($this->parent_contact_name) {
$pdf->SetFont('arialpl', 'b', 10);
$pdf->Cell(20, 5, $title . $this->parent_contact_name, 0, 1, 'L');
$pdf->SetFont('arialpl', 'b', 10);
}
if ($this->parent_shipping_address_name || $this->parent_shipping_address_street) {
$x = $pdf->getX();
$y = $pdf->getY();
$pdf->setY($current);
$pdf->setX(100);
$pdf->Cell(100, 5, $mod_strings['LBL_PDF_DELIVERY_TO'], 0, 1, 'L');
$pdf->setX(100);
$pdf->MultiCell(100, 5, html_entity_decode($this->parent_shipping_address_name), 0, 1, 'L');
$pdf->setX(100);
if ($this->parent_shipping_address_street)
$pdf->Cell(100, 5, html_entity_decode($this->parent_shipping_address_street), 0, 1, 'L');
$pdf->setX(100);
if (($this->parent_shipping_address_postalcode) || ($this->parent_shipping_address_city))
$pdf->Cell(20, 5, html_entity_decode($this->parent_address_postalcode) . ' ' . html_entity_decode($this->parent_address_city), 0, 1, 'L');
$pdf->setY($y);
$pdf->setX($x);
}
//if ($this->name) {
// $pdf->Cell(20, 5, '', 0, 1, 'L');
// $pdf->SetFont('arialpl', 'b', 10);
// $pdf->Cell(20, 5, $mod_strings['LBL_PDF_NAME'], 0, 1, 'L');
// $pdf->SetFont('arialpl', '', 10);
// $pdf->Cell(20, 5, html_entity_decode($this->name), 0, 1, 'L');
//}
$pdf->SetFont('arialpl', '', 10);
$pdf->Ln(2);
//$current = $pdf->GetY();
//$pdf->MultiCell(120,4,$address,0,'L');
//$pdf->SetFont('arialpl','B','10');
//$pdf->MultiCell(0,4,$address_cnt,0,'L');
if ($this->parent_type = "Contacts")
$pdf->Ln(14);
$current2 = $pdf->GetY();
$pdf->SetFont('arialpl', '', '10');
$subFontSizeold = $pdf->FontSizePt;
$pdf->SetFontSize($subFontSize);
//// reposition y
//$subOffset = ((($subFontSize - $subFontSizeold) / $pdf->k) * 0.3) + ($subOffset / $pdf->k);
//$subX = $pdf->x;
//$subY = $pdf->y;
//$pdf->SetXY($subX, $subY - $subOffset);
//
////Output text
//$pdf->Write(5, 'test', '');
//
//// restore y position
//$subX = $pdf->x;
//$subY = $pdf->y;
//$pdf->SetXY($subX, $subY + $subOffset);
//
//// restore font size
//$pdf->SetFontSize($subFontSizeold);
//$pdf->Ln(7);
$pdf->SetXY($pdf->fw - $pdf->rMargin - 37, $current);
$table = array();
$table[0]['data'] = array(
'width' => 30,
'value' => $mod_strings['LBL_PDF_DATE_REGISTER'],
'border' => 0,
'overflow' => 1,
'align' => 'L',
'font-style' => 'b',
'font-size' => 9,
);
$table[1]['data'] = array(
'width' => 30,
'value' => date("d.m.Y"),
'border' => 0,
'overflow' => 1,
'align' => 'L',
);
$table[2]['data'] = array(
'width' => 30,
'value' => "",
'border' => 0,
'overflow' => 1,
'align' => 'L',
);
$r_created_by = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select first_name, last_name from users where id='" . $this->modified_user_id . "'"));
$table[4]['data'] = array(
'width' => 30,
'value' => $mod_strings['LBL_PDF_OWNER'],
'border' => 0,
'overflow' => 1,
'align' => 'L',
'font-style' => 'b',
'font-size' => 9,
);
$table[4]['data'] = array(
'width' => 30,
'value' => $mod_strings['LBL_PDF_OWNER'],
'border' => 0,
'overflow' => 1,
'align' => 'L',
'font-style' => 'b',
'font-size' => 9,
);
$table[5]['data'] = array(
'width' => 30,
'value' => $r_created_by['first_name'] . " " . $r_created_by['last_name'],
'border' => 0,
'overflow' => 1,
'align' => 'L',
);
$table[6]['data'] = array(
'width' => 30,
'value' => $mod_strings['LBL_PDF_ASSIGNED_TO'],
'border' => 0,
'overflow' => 1,
'align' => 'L',
'font-style' => 'b',
'font-size' => 9,
);
$tmp = '';
$tmp .= $this->setUser()->full_name . PHP_EOL;
$tmp .= 'tel.: ' . $this->setUser()->phone_work . PHP_EOL;
$tmp .= 'kom.: ' . $this->setUser()->phone_mobile . PHP_EOL;
$tmp .= 'e-mail: ' . $this->setUser()->email1;
$table[7]['data'] = array(
'width' => 30,
'value' => $tmp,
'border' => 0,
'overflow' => 1,
'align' => 'L',
);
$pdf->DrawTable($table, null, 0, 0, 3);
$pdf->SetY($current2 - 10);
$pdf->Ln(2);
$pdf->SetFont('arialpl', '', '14');
$pdf->MultiCell(0, 0, $mod_strings['LBL_PDF_CONFIRM'] . " " . $this->document_no, 0, 'L');
$pdf->SetFont('arialpl', '', '9');
$pdf->Ln(7);
$table = array();
$table[0][0] = array(
'width' => 30,
'value' => $mod_strings['LBL_PDF_PARENT_DOCUMENT_NO'],
'background' => array(255, 255, 255),
'border' => 0,
'overflow' => '1',
'align' => 'L',
);
$table[0][1] = array(
'width' => 80,
'value' => $this->parent_document_no,
'background' => array(255, 255, 255),
'border' => 0,
'overflow' => '1',
'align' => 'L',
);
$pdf->DrawTable($table);
//$pdf->MultiCell(0,0,'Szablon dokumentu jest aktualnie przebudowywany.',0,'L');
//$pdf->SetY($current2 + 5);
//$pdf->MultiCell(0,0,'Spróbuj za 30 min.',0,'L');
$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);
//header text
if ($this->header_text) {
$pdf->Ln(4);
$pdf->SetFont('arialpl', '', '10');
$pdf->MultiCell(0, 4, $this->header_text, 0, 'J');
}
$pdf->Ln(4);
//**************************************************
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);
}
//echo '<pre>' . var_export($this->currency_id, true) . '</pre>'; exit;
// $calc = $this->calculate_currency($this->position_list, $this->currency_symbol, null);
$calc = $this->calculate_currency($this->position_list, $this->currency_id, $this->currency_value);
//$this->position_list = $this->formatPositions($this->position_list, $this->currency_id, $this->currency_value);
//$this->position_list = $this->getPositionList(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;
$widths = array(
'position' => 5,
'description' => 64,
'quantity' => 8,
'unit_price' => 15,
'discount' => 7,
'total' => 15,
//
'fix' => 73 - 8 +4,
'subtotal1' => 15 + 8, // 66
'subtotal2' => 15, // 34
);
//$calc['draw_discount'] = false;
//echo '<pre>' . var_export($calc, true); exit;
$image_w = 10;
$recipient_code_w = 10;
if ($this->show_images_on_offers) {
$widths['description'] -= $image_w;
}
if ($this->show_recipient_code) {
$widths['description'] -= $recipient_code_w;
}
/*
if ($calc['draw_discount']) {
$widths['description'] -= 8;
}
if ($calc['draw_vat']) {
$widths['description'] -= 8;
}
*/
//jest rabat?
$rabat = false;
foreach ($this->position_list as $p) {
if ($p['discount'] != 0)
$rabat = true;
}
if($rabat) {
$widths['description'] -= $widths['discount'];
$widths['fix'] -= $widths['discount'];
$widths['subtotal2'] += $widths['discount'];
}
if ($this->total_netto != '')
$widths['description'] +=35;
$table = array();
$table[0]['position'] = array(
'width' => $widths['position'],
'value' => $mod_strings['LBL_PDF_LIST_POSITION'],
'background' => array(233, 233, 233),
'border' => 1,
'overflow' => 1,
'align' => 'C',
);
$table[0]['description'] = array(
'width' => $widths['description'],
'value' => $mod_strings['LBL_PDF_LIST_DESCRIPTION'],
'background' => array(233, 233, 233),
'border' => 1,
'overflow' => 1,
'align' => 'C',
);
$table[0]['quantity'] = array(
'width' => $widths['quantity'],
'value' => $mod_strings['LBL_PDF_LIST_QUANTITY'],
'background' => array(233, 233, 233),
'border' => 1,
'overflow' => 1,
'align' => 'C',
);
if ($this->total_netto == '') {
$table[0]['unit_price'] = array(
'width' => $widths['unit_price'],
'value' => $mod_strings['LBL_PDF_LIST_PRICE'],
'background' => array(233, 233, 233),
'border' => 1,
'overflow' => 1,
'align' => 'C',
);
if ($rabat == true) {
$table[0]['discount'] = array(
'width' => $widths['discount'],
'value' => 'Rabat (%)', $mod_strings['LBL_PDF_LIST_DISCOUNT'],
'background' => array(233, 233, 233),
'border' => 1,
'overflow' => 1,
'align' => 'C',
);
}
$table[0]['total'] = array(
'width' => $widths['total'],
'value' => $mod_strings['LBL_PDF_LIST_TOTAL'],
'background' => array(233, 233, 233),
'border' => 1,
'overflow' => 1,
'align' => 'R',
);
}
$i = 1;
$netto_weight = $brutto_weight = 0;
$lv = return_app_list_strings_language($this->ecmlanguage);
if ($this->position_list != '') {
//$p = array_pop($this->position_list);
//$this->position_list = array_fill(0, 100, $p);
//$result = $db->query("SELECT total_netto from ecmquotes where id=$p['id']");
foreach ($this->position_list as $p) {
//$p['price'] = unformat_number(substr($p['price'], 0, -4));
//$p['total'] = unformat_number(substr($p['total'], 0, -4));
//echo '<pre>' . var_export($p, true); exit;
$table[$i]['position'] = array(
'width' => $widths['position'],
'value' => $i,
'border' => 1,
'align' => 'C',
);
$name = str_replace('', '-', htmlspecialchars_decode($p['name']));
$table[$i]['description'] = array(
'width' => $widths['description'],
'value' => $name,
'border' => 1,
'align' => 'L',
);
$netto_weight += $p['netto_weight'];
//$brutto_weight += $p['brutto_weight'];
$brutto_weight += ($p['quantity'] * $p['netto_weight']);
$table[$i]['quantity'] = array(
'width' => $widths['quantity'],
'value' => format_number($p['quantity']),
'border' => 1,
'align' => 'C',
);
$price_total = $p['price'] * $p['quantity'];
$discount = ((100 * $p['price']) / (100 - $p['discount']));
//echo '<pre>' . var_export($price_total, true);
//echo '<pre>' . var_export($discount, true);
//exit;
if ($this->total_netto == '') {
$table[$i]['unit_price'] = array(
'width' => $widths['unit_price'],
// 'value' => format_number($p['price']). ' ' . $this->currency_symbol,
'value' => format_number($p['price']). ' ' . $p['currency_name'],
'border' => 1,
'align' => 'R',
);
if ($rabat == true) {
if ($p['discount'] == 0) {
$tmp = '---';
} else {
$tmp = format_number($p['discount']) . '%';
}
$table[$i]['discount'] = array(
'width' => $widths['discount'],
'value' => $tmp,
'border' => 1,
'align' => 'C',
);
}
$table[$i]['total'] = array(
'width' => $widths['total'],
// 'value' => format_number($p['total']) . ' '. $this->currency_symbol,
'value' => format_number($p['total']) . ' '. $p['currency_name'],
'border' => 1,
'align' => 'R',
);
}
$tmp_sep = ereg_replace('[^0-9.,]', '', $p['total']);
$len = strlen($tmp_sep);
$separator = substr($tmp_sep, $len - 3, 1);
if ($separator == '.') {
$tmp = (float) ereg_replace('[^0-9.]', '', $p['total']);
}
if ($separator == ',') {
$tmp = (float) ereg_replace('[^0-9,]', '', $p['total']);
}
if ($p['currency_id'] == 'PLN') {
if (isset($total_price_pln)) {
$total_price_pln += $tmp;
} else {
$total_price_pln = $tmp;
}
}
if ($p['currency_id'] == '6336d9a0-ee5f-52e3-7d0c-4e6f1472b2bf') {
if (isset($total_price_eur)) {
$total_price_eur+= $tmp;
} else {
$total_price_eur = $tmp;
}
}
$i++;
}
}
$starttab = $pdf->GetY() + 10;
$pdf->DrawTable($table, array(0));
$endtab = $pdf->GetY();
$pdf->SetY($endtab);
//mz
$table = array();
//echo '<pre>'. var_export($calc, true); exit;
//EURO
if ($calc['vats']) {
$table[] = array(
'fix' => array(
'width' => $widths['fix'],
'value' => '',
'border' => 0,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
),
'subtotal1' => array(
'width' => $widths['subtotal1'],
'value' => $mod_strings['LBL_PDF_TOTAL'],
'background' => array(255, 255, 255),
'border' => 1,
'overflow' => 1,
'align' => 'L',
'font-size' => 9,
),
'subtotal2' => array(
'width' => $widths['subtotal2'],
// 'value' => format_number($calc['subtotal']) . ' ' . $calc['currency_symbol'],
'value' => format_number($calc['subtotal']) . ' ' . $this->currency_symbol,
//'value' => 'test',
'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(
'fix' => array(
'width' => $widths['fix'],
'value' => '',
'border' => 0,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
),
'subtotal1' => array(
'width' => $widths['subtotal1'],
'value' => $mod_strings['LBL_PDF_VAT'] . ' (' . $vvn . ')',
'background' => array(255, 255, 255),
'border' => 1,
'overflow' => 1,
'align' => 'L',
'font-size' => 9),
'subtotal2' => array(
'width' => $widths['subtotal2'],
// 'value' => format_number($value) . ' ' . $calc['currency_symbol'],
'value' => format_number($value) . ' ' . $this->currency_symbol,
'border' => 1,
'overflow' => 1,
'align' => 'R',
'font-size' => 9,
),
);
}
}
$table[] = array(
'fix' => array(
'width' => $widths['fix'],
'value' => '',
'border' => 0,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
),
'total1' => array(
'width' => $widths['subtotal1'],
'value' => $mod_strings['LBL_PDF_END_TOTAL'],
'background' => array(233, 233, 233),
'border' => 1,
'overflow' => 1,
'align' => 'L',
'font-size' => 9,
'font-style' => 'b',
),
'total2' => array(
'width' => $widths['subtotal2'],
// 'value' => format_number(unformat_number($calc['total'])) . ' ' . $calc['currency_symbol'],
'value' => format_number(unformat_number($calc['total'])) . ' ' . $this->currency_symbol,
'border' => 1,
'background' => array(233, 233, 233),
'overflow' => 1,
'align' => 'R',
'font-size' => 9,
'font-style' => 'b',
),
);
//echo '<pre>' . var_export($widths['subtotal2'], true); exit;
$pdf->Ln(4);
$pdf->DrawTable($table);
//PLN
//$starttab = $pdf->GetY() + 1;
//$pdf->SetY($starttab);
//
//$table = array();
//if ($calc['vats_pln']) {
// $table[] = array(
// 'subtotal1' => array('width' => 66, 'value' => $mod_strings['LBL_PDF_TOTAL'], 'background' => array(255, 255, 255), 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 9),
// 'subtotal2' => array('width' => 34, 'value' => $calc['subtotal_pln'] . ' PLN', 'border' => 0, 'overflow' => 1, 'align' => 'R', 'font-size' => 9),);
//
// foreach ($calc['vats_pln'] as $key => $value) {
// $r = mysql_fetch_array(mysql_query("select name from ecmvats where id='" . $key . "'"));
// $vvn = $r['name'];
// $table[] = array(
// 'vat1' => array('width' => 66, 'value' => $mod_strings['LBL_PDF_VAT'] . ' (' . $vvn . ')', 'background' => array(255, 255, 255), 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 9),
// 'vat2' => array('width' => 34, 'value' => $value . ' PLN', 'border' => 0, 'overflow' => 1, 'align' => 'R', 'font-size' => 9),);
// }
//}
//
//$table[] = array(
// 'total1' => array('width' => 66, 'value' => $mod_strings['LBL_PDF_END_TOTAL'], 'background' => array(233, 233, 233), 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 9, 'font-style' => 'b'),
// 'total2' => array('width' => 34, 'value' => $calc['subtotal_pln'] . ' PLN', 'border' => 0, 'background' => array(233, 233, 233), 'overflow' => 1, 'align' => 'R', 'font-size' => 9, 'font-style' => 'b'),);
//
//$pdf->DrawTable($table);

View File

@@ -0,0 +1,334 @@
<?php
global $db;
$pdf->focus=$this;
$pdf->Ln(2);
$pdf->SetY($pdf->GetY()+2);
$current = $pdf->GetY();
$pdf->SetFont('arialpl', '', 9);
/*
$p_name = html_entity_decode($this->parent_name);
$p_name = explode(' ', $p_name);
$name = array();
if (sizeof($p_name)>4) {
for ($i=0; $i<sizeof($p_name); $i++) {
$n.=$p_name[$i].' ';
//$pdf->Cell(40,5, $n,0,1,'L');
if (($i%5==0) && ($i!=0)) {
$name[] = $n;
$n='';
}
}
$name[] = $n;
}
if($this->parent_name) {
if (sizeof($p_name)>4)
foreach ($name as $n)
$pdf->Cell(40,5, $n,0,1,'L');
else
$pdf->Cell(40,5, html_entity_decode($this->parent_name),0,1,'L');
}
*/
$pdf->MultiCell(100,5, html_entity_decode($this->parent_name),0,1,'L');
//$pdf->SetFont('arialpl', '', 10);
if($this->parent_address_street) $pdf->Cell(20,5,html_entity_decode($this->parent_address_street),0,1,'L');
if (($this->parent_address_postalcode) || ($this->parent_address_city))
$pdf->Cell(20,5,html_entity_decode($this->parent_address_postalcode).' '.html_entity_decode($this->parent_address_city),0,1,'L');
if($this->to_vatid) $pdf->Cell(20,5,$mod_strings['LBL_PDF_VATID'].' '.html_entity_decode($this->to_vatid),0,1,'L');
$title='';
if($this->parent_contact_title) $title.=$this->parent_contact_title.' ';
if($this->parent_contact_name) {
$pdf->SetFont('arialpl', 'b', 10);
$pdf->Cell(20,5,$title.$this->parent_contact_name,0,1,'L');
$pdf->SetFont('arialpl', 'b', 10);
}
if ($this->parent_shipping_address_name || $this->parent_shipping_address_street) {
$x = $pdf->getX();
$y = $pdf->getY();
$pdf->setY($current);
$pdf->setX(100);
$pdf->Cell(100,5,$mod_strings['LBL_PDF_DELIVERY_TO'],0,1,'L');
$pdf->setX(100);
$pdf->MultiCell(100,5, html_entity_decode($this->parent_shipping_address_name),0,1,'L');
$pdf->setX(100);
if($this->parent_shipping_address_street) $pdf->Cell(100,5,html_entity_decode($this->parent_shipping_address_street),0,1,'L');
$pdf->setX(100);
if (($this->parent_shipping_address_postalcode) || ($this->parent_shipping_address_city))
$pdf->Cell(20,5,html_entity_decode($this->parent_address_postalcode).' '.html_entity_decode($this->parent_address_city),0,1,'L');
$pdf->setY($y);
$pdf->setX($x);
}
/*
if($this->name) {
$pdf->Cell(20,5,'',0,1,'L');
$pdf->SetFont('arialpl', 'b', 10);
$pdf->Cell(20,5,$mod_strings['LBL_PDF_NAME'],0,1,'L');
$pdf->SetFont('arialpl', '', 10);
$pdf->Cell(20,5,html_entity_decode($this->name),0,1,'L');
}
*/
$pdf->SetFont('arialpl', '', 10);
$pdf->Ln(2);
// $current = $pdf->GetY();
//$pdf->MultiCell(120,4,$address,0,'L');
//$pdf->SetFont('arialpl','B','10');
//$pdf->MultiCell(0,4,$address_cnt,0,'L');
if($this->parent_type="Contacts")$pdf->Ln(14);
$current2 = $pdf->GetY();
$pdf->SetFont('arialpl','','10');
$subFontSizeold = $pdf->FontSizePt;
$pdf->SetFontSize($subFontSize);
/*
// reposition y
$subOffset = ((($subFontSize - $subFontSizeold) / $pdf->k) * 0.3) + ($subOffset / $pdf->k);
$subX = $pdf->x;
$subY = $pdf->y;
$pdf->SetXY($subX, $subY - $subOffset);
//Output text
$pdf->Write(5, 'test','');
// restore y position
$subX = $pdf->x;
$subY = $pdf->y;
$pdf->SetXY($subX, $subY + $subOffset);
// restore font size
$pdf->SetFontSize($subFontSizeold);
*/
// $pdf->Ln(7);
$pdf->SetXY($pdf->fw-$pdf->rMargin-37,$current);
$table = array();
$table [0]['data'] = array('width' => 30, 'value' => $mod_strings['LBL_PDF_DATE_REGISTER'], 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-style' => 'b', 'font-size' => 9);
$table [1]['data'] = array('width' => 30, 'value' => date("d.m.Y"), 'border' => 0, 'overflow' => 1, 'align' => 'L');
$table [2]['data'] = array('width' => 30, 'value' => "", 'border' => 0, 'overflow' => 1, 'align' => 'L');
$r_created_by = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select first_name, last_name from users where id='".$this->modified_user_id."'"));
$table [4]['data'] = array('width' => 30, 'value' => $mod_strings['LBL_PDF_OWNER'], 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-style' => 'b', 'font-size' => 9); $table [4]['data'] = array('width' => 30, 'value' => $mod_strings['LBL_PDF_OWNER'], 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-style' => 'b', 'font-size' => 9);
$table [5]['data'] = array('width' => 30, 'value' => $r_created_by['first_name']." ".$r_created_by['last_name'] , 'border' => 0, 'overflow' => 1, 'align' => 'L');
$table [6]['data'] = array('width' => 30, 'value' => $mod_strings['LBL_PDF_ASSIGNED_TO'], 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-style' => 'b', 'font-size' => 9);
$table [7]['data'] = array('width' => 30, 'value' => $this->setUser()->full_name.'
tel.: '.$this->setUser()->phone_work.'
kom.: '.$this->setUser()->phone_mobile.'
e-mail: '.$this->setUser()->email1, 'border' => 0, 'overflow' => 1, 'align' => 'L');
$pdf->DrawTable($table, null, 0, 0, 3);
$pdf->SetY($current2-10);
$pdf->Ln(2);
$pdf->SetFont('arialpl','','14');
$pdf->MultiCell(0,0,$mod_strings['LBL_PDF_CONFIRM']." ".$this->document_no,0,'L');
$pdf->SetFont('arialpl','','9');
$pdf->Ln(5);
$table = array();
$table[0][0] = array('width' => 30, 'value' => $mod_strings['LBL_PDF_PARENT_DOCUMENT_NO'], 'background' => array(255,255,255), 'border' => 0, 'overflow' => '1', 'align' => 'L');
$table[0][1] = array('width' => 80, 'value' => $this->parent_document_no, 'background' => array(255,255,255), 'border' => 0, 'overflow' => '1', 'align' => 'L');
$pdf->DrawTable($table);
//$pdf->MultiCell(0,0,'Szablon dokumentu jest aktualnie przebudowywany.',0,'L');
$pdf->SetY($current2+5);
//$pdf->MultiCell(0,0,'Spróbuj za 30 min.',0,'L');
$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);
//header text
if($this->header_text){
$pdf->Ln(8);
$pdf->SetFont('arialpl','','10');
$pdf->MultiCell(0,4,$this->header_text,0,'J');
}
$pdf->Ln(8);
//**************************************************
global $mod_strings;
if(!isset($this->position_list) || !is_array($this->position_list))
$this->position_list = $this->getPositionList(true);
$calc = $this->calculate_currency($this->position_list,$this->currency_id, $this->currency_value);
$this->position_list = $this->formatPositions($this->position_list, $this->currency_id, $this->currency_value);
/*
$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;
*/
$name_w = 59;
$image_w = 10;
$recipient_code_w = 10;
if($this->show_images_on_offers){
$name_w -= $image_w;
}
if($this->show_recipient_code){
$name_w -= $recipient_code_w;
}
if($calc['draw_discount']){
$name_w -= 8;
}
if($calc['draw_vat']){
$name_w -= 8;
}
//jest rabat?
$rabat = false;
foreach($this->position_list as $p) {
if ($p['discount']!=0) $rabat=true;
}
if ($this->total_netto!='') $name_w+=35;
$table = array();
$table [0]['position'] = array('width' => 5, 'value' => $mod_strings['LBL_PDF_LIST_POSITION'], 'background' => array(233,233,233), 'border' => 0, 'overflow' => 1, 'align' => 'C');
$table [0]['description'] = array('width' => $name_w, 'value' => $mod_strings['LBL_PDF_LIST_DESCRIPTION'], 'background' => array(233,233,233), 'border' => 0, 'overflow' => 1, 'align' => 'C');
$table [0]['quantity'] = array('width' => 8, 'value' => $mod_strings['LBL_PDF_LIST_QUANTITY'],'background' => array(233,233,233), 'border' => 0, 'overflow' => 1, 'align' => 'C');
if ($this->total_netto=='') {
$table [0]['unit_price'] = array('width' => 14, 'value' => $mod_strings['LBL_PDF_LIST_PRICE'], 'background' => array(233,233,233), 'border' => 0, 'overflow' => 1, 'align' => 'C');
if ($rabat==true) {
$table [0]['discount'] = array('width' => 7, 'value' => $mod_strings['LBL_PDF_LIST_DISCOUNT'], 'background' => array(233,233,233), 'border' => 0, 'overflow' => 1, 'align' => 'C');
}
$table [0]['total'] = array('width' => 14, 'value' => $mod_strings['LBL_PDF_LIST_TOTAL'], 'background' => array(233,233,233), 'border' => 0, 'overflow' => 1, 'align' => 'R');
}
$i = 1;
$lv=return_app_list_strings_language($this->ecmlanguage);
if($this->position_list != '')
// $result = $db->query("SELECT total_netto from ecmquotes where id=$p['id']");
foreach($this->position_list as $p) {
$table [$i]['position'] = array('width' => 5, 'value' => $i, 'border' => 0, 'align' => 'C', );
$name = str_replace('','-',htmlspecialchars_decode($p['name']));
$table [$i]['description'] = array('width' => $name_w, 'value' => $name, 'border' => 0, 'align' => 'L', );
$table [$i]['quantity'] = array('width' => 8, 'value' => $p['quantity'], 'border' => 0, 'align' => 'C', );
if ($this->total_netto=='') {
$table [$i]['unit_price'] = array('width' => 14, 'value' => $p['price'], 'border' => 0, 'align' => 'C', );
if ($rabat==true) {
if ($p['discount']==0) $tmp='---'; else $tmp=$p['discount'];
$table [$i]['discount'] = array('width' => 7, 'value' => $tmp, 'border' => 0, 'align' => 'R', );
}
$table [$i]['total'] = array('width' => 14, 'value' => $p['total'], 'border' => 0, 'align' => 'R', );
}
$tmp_sep = ereg_replace('[^0-9.,]', '', $p['total']);
$len = strlen($tmp_sep);
$separator = substr($tmp_sep, $len-3, 1);
if ($separator == '.') $tmp = (float) ereg_replace('[^0-9.]', '', $p['total']);
if ($separator == ',') $tmp = (float) ereg_replace('[^0-9,]', '', $p['total']);
if ($p['currency_id'] == 'PLN') {
if (isset($total_price_pln)) $total_price_pln += $tmp;
else $total_price_pln = $tmp;
}
if ($p['currency_id'] == '6336d9a0-ee5f-52e3-7d0c-4e6f1472b2bf') {
if (isset($total_price_eur)) $total_price_eur+= $tmp;
else $total_price_eur= $tmp;
}
$i++;
}
$starttab=$pdf->GetY()+10;
$pdf->DrawTable($table,array(0));
$endtab=$pdf->GetY();
$pdf->SetY($endtab);
//mz
$table = array();
//EURO
if($calc['vats']) {
$table [] = array(
'subtotal1' => array('width' => 66, 'value' => $mod_strings['LBL_PDF_TOTAL'], 'background' => array(255,255,255), 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 9),
'subtotal2' => array('width' => 34, 'value' => $calc['subtotal'].' '.$calc['currency_symbol'], 'border' => 0, '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' => 66, 'value' => $mod_strings['LBL_PDF_VAT'].' ('.$vvn.')', 'background' => array(255,255,255), 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 9),
'vat2' => array('width' => 34, 'value' => $value.' '.$calc['currency_symbol'], 'border' => 0, 'overflow' => 1, 'align' => 'R', 'font-size' => 9), );
}
}
$table [] = array(
'total1' => array('width' => 66, 'value' => $mod_strings['LBL_PDF_END_TOTAL'], 'background' => array(233,233,233), 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 9, 'font-style' => 'b'),
'total2' => array('width' => 34, 'value' => $calc['total'].' '.$calc['currency_symbol'], 'border' => 0, 'background' => array(233,233,233), 'overflow' => 1, 'align' => 'R' , 'font-size' => 9, 'font-style' => 'b'), );
$pdf->DrawTable($table);
//PLN
/*
$starttab=$pdf->GetY()+1;
$pdf->SetY($starttab);
$table = array();
if($calc['vats_pln']) {
$table [] = array(
'subtotal1' => array('width' => 66, 'value' => $mod_strings['LBL_PDF_TOTAL'], 'background' => array(255,255,255), 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 9),
'subtotal2' => array('width' => 34, 'value' => $calc['subtotal_pln'].' PLN', 'border' => 0, 'overflow' => 1, 'align' => 'R', 'font-size' => 9), );
foreach($calc['vats_pln'] as $key => $value){
$r=mysql_fetch_array(mysql_query("select name from ecmvats where id='".$key."'"));
$vvn=$r['name'];
$table [] = array(
'vat1' => array('width' => 66, 'value' => $mod_strings['LBL_PDF_VAT'].' ('.$vvn.')', 'background' => array(255,255,255), 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 9),
'vat2' => array('width' => 34, 'value' => $value.' PLN', 'border' => 0, 'overflow' => 1, 'align' => 'R', 'font-size' => 9), );
}
}
$table [] = array(
'total1' => array('width' => 66, 'value' => $mod_strings['LBL_PDF_END_TOTAL'], 'background' => array(233,233,233), 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 9, 'font-style' => 'b'),
'total2' => array('width' => 34, 'value' => $calc['subtotal_pln'].' PLN', 'border' => 0, 'background' => array(233,233,233), 'overflow' => 1, 'align' => 'R' , 'font-size' => 9, 'font-style' => 'b'), );
$pdf->DrawTable($table);
*/
?>

View File

@@ -0,0 +1,95 @@
<?
error_reporting ( 0 );
$r = mysql_fetch_array ( mysql_query ( "select parent_id, document_no, ecmlanguage from " . strtolower ( $_REQUEST ['module'] ) . " where id='" . $_REQUEST ['record'] . "'" ) );
$b = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select document_bank_account as dba from accounts where id='".$r['parent_id']."'"));
$this->SetFont ( 'arialpl', '', 8 );
$this->SetY ( $this->fh - 15 );
$this->SetDrawColor ( 0, 0, 0 );
$this->SetFillColor ( 255, 255, 255 );
$this->Rect ( 0, $this->getBreakLine (), $this->fw, $this->bMargin + 1, "F" );
$this->SetDrawColor ( 0, 0, 0 );
$this->Cell ( 0, 10, $this->PageNo () . '/{nb}' );
$this->Ln ( 5 );
$this->AliasNbPages ();
$this->SetLineWidth ();
$this->SetDrawColor ( 0, 0, 0 );
$this->Line ( $this->lMargin, - 17 - 16 + 1, $this->fw - $this->rMargin, - 17 - 16 + 1 );
if ($this->edt->show_footer_on_all_pages == 0 && $this->page > 1) {
return;
}
$this->SetXY ( $this->lMargin, - 20 - 16 );
$this->Line(10,$this->fh-37,200,$this->fh-37);
$this->SetFont ( 'arialpl', '', '7' );
$this->Cell ( 110, 4, 'e5 Polska Sp. z o.o.' );
$this->SetFont ( 'arialpl', 'B', '7' );
$this->Cell ( 20, 4, 'Bank: ' );
$this->SetFont ( 'arialpl', '', '7' );
if ($b['dba']=='milenium')
$this->Cell ( 45, 4, 'BANK MILLENIUM', 0, 0, 'L' );
if ($b['dba']=='mbank')
$this->Cell ( 45, 4, 'MBANK', 0, 0, 'L' );
$this->Ln ();
$this->SetFont ( 'arialpl', '', '7' );
$this->Cell ( 110, 4, 'ul. Wąwozowa 11, 02-796 Warszawa, Poland' );
$this->SetFont ( 'arialpl', 'B', '7' );
$this->Cell ( 20, 4, 'Bank IBAN: ' );
$this->SetFont ( 'arialpl', '', '7' );
if ($b['dba']=='milenium')
$this->Cell ( 45, 4, 'PL36116022020000000064080587', 0, 0, 'L' );
if ($b['dba']=='mbank')
$this->Cell ( 45, 4, 'PL96114010100000548212001002', 0, 0, 'L' );
$this->Ln ();
$this->SetFont ( 'arialpl', '', '7' );
$this->Cell ( 110, 4, '22 228 20 90');
$this->SetFont ( 'arialpl', 'B', '7' );
$this->Cell ( 20, 4, 'Bank SWIFT: ' );
$this->SetFont ( 'arialpl', '', '7' );
if ($b['dba']=='milenium')
$this->Cell ( 45, 4, "BIGBPLPW", 0, 0, 'L' );
if ($b['dba']=='mbank')
$this->Cell ( 45, 4, "BREXPLPW", 0, 0, 'L' );
$this->Ln ();
$this->SetFont ( 'arialpl', '', '7' );
$this->Cell ( 110, 4, '+ 48 (56) 674 60 47' );
$this->SetFont ( 'arialpl', 'B', '7' );
$this->Cell ( 20, 4, 'KRS: ' );
$this->SetFont ( 'arialpl', '', '7' );
$this->Cell ( 45, 4, '28207', 0, 0, 'L' );
$this->Ln ();
$this->SetFont ( 'arialpl', '', '7' );
$this->Cell ( 110, 4, 'www.e5.pl' );
$this->SetFont ( 'arialpl', 'B', '7' );
$this->Cell ( 20, 4, 'NIP: ' );
$this->SetFont ( 'arialpl', '', '7' );
$this->Cell ( 45, 4, 'PL 525-21-73-990', 0, 0, 'L' );
$this->Ln ();
$this->SetFont ( 'arialpl', '', '7' );
$this->Cell ( 110, 4, '' );
$this->SetFont ( 'arialpl', 'B', '7' );
$this->Cell ( 20, 4, 'REGON: ' );
$this->SetFont ( 'arialpl', '', '7' );
$this->Cell ( 45, 4, '016280234', 0, 0, 'L' );
$this->Ln ();
$this->SetFont ( "arialpl", "B", 8 );
$this->SetXY ( 40, $this->GetY () + 1 );
$this->Cell ( 45, 4, $r ['document_no'], 0, 0, 'L' );
?>

View File

@@ -0,0 +1,93 @@
<?
error_reporting(0);
$r=mysql_fetch_array(mysql_query("select document_no, ecmlanguage from ".strtolower($_REQUEST['module'])." where id='".$_REQUEST['record']."'"));
$this->SetFont('arialpl', '', 8);
$this->SetY($this->fh-15);
$this->SetDrawColor(0,0,0);
$this->SetFillColor(255,255,255);
$this->Rect(0, $this->getBreakLine(), $this->fw, $this->bMargin+1, "F");
$this->SetDrawColor(0,0,0);
$this->Cell(0, 10, $this->PageNo().'/{nb}');
$this->Ln(5);
$this->AliasNbPages();
$this->SetLineWidth(0);
$this->SetDrawColor(0,0,0);
$this->Line($this->lMargin,-17-16+1,$this->fw-$this->rMargin,-17-16+1);
if($this->edt->show_footer_on_all_pages == 0 && $this->page > 1) {
return;
}
$this->SetXY($this->lMargin,-20-16);
$this->SetFont('arialpl','','7');
$this->Cell(110,4,$this->edt->footer_account);
$this->SetFont('arialpl','B','7');
$this->Cell(20,4,'Bank: ');
$this->SetFont('arialpl','','7');
$this->Cell(45,4,$this->edt->footer_bankname,0,0,'L');
$this->Ln();
$this->SetFont('arialpl','','7');
if ($r['ecmlanguage']=='pl_pl')
$this->Cell(110,4,$this->edt->footer_address);
else
$this->Cell(110,4,$this->edt->footer_address.', Poland');
$this->SetFont('arialpl','B','7');
if ($r['ecmlanguage']=='pl_pl')
$this->Cell(20,4,'Numer konta: ');
else
$this->Cell(20,4,'Bank IBAN: ');
$this->SetFont('arialpl','','7');
$this->Cell(45,4,$this->edt->account_number,0,0,'L');
$this->Ln();
$this->SetFont('arialpl','','7');
$this->Cell(110,4,$this->edt->footer_phone);
if ($r['ecmlanguage']=='pl_pl') {
$this->SetFont('arialpl','B','7');
$this->Cell(20,4,'Numer GIOS: ');
$this->SetFont('arialpl','','7');
$this->Cell(45,4,"E0006254W",0,0,'L');
} else {
$this->SetFont('arialpl','B','7');
$this->Cell(20,4,'Bank SWIFT: ');
$this->SetFont('arialpl','','7');
$this->Cell(45,4,"BIGBPLPW",0,0,'L');
}
$this->Ln();
$this->SetFont('arialpl','','7');
$this->Cell(110,4,$this->edt->footer_fax);
$this->SetFont('arialpl','B','7');
$this->Cell(20,4,'KRS: ');
$this->SetFont('arialpl','','7');
$this->Cell(45,4,$this->edt->footer_krs,0,0,'L');
$this->Ln();
$this->SetFont('arialpl','','7');
$this->Cell(110,4,'www.e5.pl');
$this->SetFont('arialpl','B','7');
$this->Cell(20,4,'NIP: ');
$this->SetFont('arialpl','','7');
$this->Cell(45,4,$this->edt->footer_nip,0,0,'L');
$this->Ln();
$this->SetFont('arialpl','','7');
$this->Cell(110,4,'');
$this->SetFont('arialpl','B','7');
$this->Cell(20,4,'REGON: ');
$this->SetFont('arialpl','','7');
$this->Cell(45,4,$this->edt->footer_regon,0,0,'L');
$this->Ln();
$this->SetFont("arialpl","B",8);
$this->SetXY(40,$this->GetY()+1);
$this->Cell(45,4,$r['document_no'],0,0,'L');
?>

View File

@@ -0,0 +1,91 @@
<?
error_reporting ( 0 );
$r = mysql_fetch_array ( mysql_query ( "select parent_id, document_no, ecmlanguage from " . strtolower ( $_REQUEST ['module'] ) . " where id='" . $_REQUEST ['record'] . "'" ) );
$b = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select document_bank_account as dba from accounts where id='".$r['parent_id']."'"));
$this->SetFont ( 'arialpl', '', 8 );
$this->SetY ( $this->fh - 15 );
$this->SetDrawColor ( 0, 0, 0 );
$this->SetFillColor ( 255, 255, 255 );
$this->Rect ( 0, $this->getBreakLine (), $this->fw, $this->bMargin + 1, "F" );
$this->SetDrawColor ( 0, 0, 0 );
$this->Cell ( 0, 10, $this->PageNo () . '/{nb}' );
$this->Ln ( 5 );
$this->AliasNbPages ();
$this->SetLineWidth ();
$this->SetDrawColor ( 0, 0, 0 );
$this->Line ( $this->lMargin, - 17 - 16 + 1, $this->fw - $this->rMargin, - 17 - 16 + 1 );
if ($this->edt->show_footer_on_all_pages == 0 && $this->page > 1) {
return;
}
$this->SetXY ( $this->lMargin, - 20 - 16 );
$this->Line(10,$this->fh-37,200,$this->fh-37);
$this->SetFont ( 'arialpl', '', '7' );
$this->Cell ( 110, 4, 'e5 Polska Sp. z o.o.' );
$this->SetFont ( 'arialpl', 'B', '7' );
$this->Cell ( 20, 4, 'Bank: ' );
$this->SetFont ( 'arialpl', '', '7' );
if ($b['dba']=='milenium')
$this->Cell ( 45, 4, 'BANK MILLENIUM', 0, 0, 'L' );
if ($b['dba']=='mbank')
$this->Cell ( 45, 4, 'MBANK', 0, 0, 'L' );
$this->Ln ();
$this->SetFont ( 'arialpl', '', '7' );
$this->Cell ( 110, 4, 'ul. Wąwozowa 11, 02-796 Warszawa' );
$this->SetFont ( 'arialpl', 'B', '7' );
$this->Cell ( 20, 4, 'Numer konta: ' );
$this->SetFont ( 'arialpl', '', '7' );
if ($b['dba']=='milenium')
$this->Cell ( 45, 4, '35 1160 2202 0000 0000 6408 0411', 0, 0, 'L' );
if ($b['dba']=='mbank')
$this->Cell ( 45, 4, '26 1140 1010 0000 5482 1200 1001', 0, 0, 'L' );
$this->Ln ();
$this->SetFont ( 'arialpl', '', '7' );
$this->Cell ( 110, 4, '22 228 20 90');
$this->SetFont ( 'arialpl', 'B', '7' );
$this->Cell ( 20, 4, 'Numer GIOŚ: ' );
$this->SetFont ( 'arialpl', '', '7' );
$this->Cell ( 45, 4, "E0006254W", 0, 0, 'L' );
$this->Ln ();
$this->SetFont ( 'arialpl', '', '7' );
$this->Cell ( 110, 4, '+ 48 (56) 674 60 47' );
$this->SetFont ( 'arialpl', 'B', '7' );
$this->Cell ( 20, 4, 'KRS: ' );
$this->SetFont ( 'arialpl', '', '7' );
$this->Cell ( 45, 4, '28207', 0, 0, 'L' );
$this->Ln ();
$this->SetFont ( 'arialpl', '', '7' );
$this->Cell ( 110, 4, 'www.e5.pl' );
$this->SetFont ( 'arialpl', 'B', '7' );
$this->Cell ( 20, 4, 'NIP: ' );
$this->SetFont ( 'arialpl', '', '7' );
$this->Cell ( 45, 4, 'PL 525-21-73-990', 0, 0, 'L' );
$this->Ln ();
$this->SetFont ( 'arialpl', '', '7' );
$this->Cell ( 110, 4, '' );
$this->SetFont ( 'arialpl', 'B', '7' );
$this->Cell ( 20, 4, 'REGON: ' );
$this->SetFont ( 'arialpl', '', '7' );
$this->Cell ( 45, 4, '016280234', 0, 0, 'L' );
$this->Ln ();
$this->SetFont ( "arialpl", "B", 8 );
$this->SetXY ( 40, $this->GetY () + 1 );
$this->Cell ( 45, 4, $r ['document_no'], 0, 0, 'L' );
?>

View File

@@ -0,0 +1,30 @@
<?
set_time_limit(99999);
error_reporting(0);
if(!$this->blnShowHeader) return;
if($this->edt->show_header_on_all_pages == 0 && $this->page > 1) return;
if(isset($this->edt->logo_path) && $this->edt->logo_path != '' && file_exists($this->edt->logo_path)){
$this->Image($this->edt->logo_path,$this->lMargin,$this->tMargin,0,15);
}
/*
$this->SetFont('arialpl', '', 8);
$this->SetXY($this->lMargin+135,$this->tMargin+2);
$this->SetFont ( 'arialpl', 'B', '7' );
$this->Cell ( 110, 4, 'e5 Polska Sp. z o.o.');
$this->Ln ();
$this->SetX($this->lMargin+135);
$this->Cell ( 110, 4, 'ul. Wąwozowa 11' );
$this->Ln ();
$this->SetX($this->lMargin+135);
$this->Cell ( 110, 4, '02-796 Warszawa' );
$this->Ln ();
$this->SetX($this->lMargin+135);
$this->Cell ( 20, 4, 'NIP: PL 525-21-73-990' );
$this->Ln ();
*/
$this->Line(10,30,200,30);
?>

View File

@@ -0,0 +1,375 @@
<?php
//echo __FILE__;
//exit;
//payment conditions
//
//if (!empty($this->ecmpaymentcondition_text)) {
// $pdf->Ln(4);
// $pdf->SetFont('arialpl', '', '8');
// $pdf->MultiCell(0, 4, $this->ecmpaymentcondition_text, 0, 'L');
// $pdf->Ln();
//}
//
//if ($this->type == "correct") {
// $pdf->SetFont('arialpl', 'b', '12');
// $pdf->Ln(3);
// $pdf->MultiCell(0, 4, $mod_strings['LBL_PDF_DOCUMENT_CORRECT_DIFFERENCE'] . " " . format_number(abs(unformat_number($this->total) + unformat_number($this->ecminvoiceout->total))) . ' ' . $this->currency_symbol);
// $pdf->Ln(3);
//}
if($this->ecmlanguage!='en_us'){
$pdf->writeHTML('</table>'); // fix background-color overflowing FROM table ... why ? //
if ($this->type == "correct") {
$brutto -= $this->paid_val;
if ($brutto > 0) {
$string = 'Do zapłaty:';
} else {
$string = 'Do zwrotu:';
}
$tmp = $brutto;
$brutto = format_number(abs($brutto));
$pdf->SetX(10);
$pdf->SetFont('arialpl', '', '8');
$pdf->Cell(50, 4, $string, 0, 0, 'L', 1);
$pdf->SetFont('arialpl', 'B', '8');
$pdf->Cell(30, 4, $brutto . ' ' . $this->currency_symbol, 0, 0, 'L', 1);
} else {
$total = 0;
$qw = "SELECT price, ecmvat_value, quantity, ecminvoiceoutitem_id FROM ecminvoiceoutitems WHERE ecminvoiceout_id = '" . $this->id . "'";
$w = $GLOBALS['db']->query($qw);
while ($r = $GLOBALS['db']->fetchByAssoc($w)) {
$total+=$r['price'] * $r['quantity'] + round($r['price'] * $r['quantity'] * $r['ecmvat_value'] / 100, 2);
}
$total-=floatval(str_replace(",", ".", str_replace(".", "", $this->discount)));
//$total -= $this->paid_val;
if ($total > 0) {
$string = $mod_strings['LBL_PDF_TO_PAID'];
} else {
$string = $mod_strings['LBL_PDF_TO_PAID_BACK'];
}
$total = format_number(abs($total));
$pdf->SetX(10);
$pdf->SetFont('arialpl', '', '8');
$pdf->Cell(50, 4, 'Razem do zapłaty:', 0, 0, 'L', 1);
$pdf->SetFont('arialpl', 'B', '8');
$pdf->Cell(30, 4, format_number($brutto) . ' ' . $this->currency_symbol, 0, 0, 'R', 1);
}
if (!isset($tmp) || $tmp > 0) {
$pdf->Ln(4);
$pdf->SetFont('arialpl', '', '8');
if ($this->prepaid) {
// $pdf->Cell(50, 4, $mod_strings['LBL_PDF_PREPAID_DOCUMENTS'] . ':', 0, 0, 'L', 1);
// $pdf->Cell(30, 4, implode(', ', $rr_prepayment), 0, 0, 'L', 1);
//
// $pdf->Ln(4);
$pdf->SetX(10);
$pdf->Cell(50, 4, $mod_strings['LBL_PDF_PREPAID'] . ':', 0, 0, 'L', 1);
$pdf->SetFont('arialpl', 'B', '8');
$pdf->Cell(30, 4, format_number($this->prepaid) . ' ' . $this->currency_symbol, 0, 0, 'R', 1);
$pdf->Ln(4);
}
//$pdf->Ln(4);
$pdf->SetX(10);
$pdf->SetFont('arialpl', '', '8');
$pdf->Cell(50, 4, $mod_strings['LBL_PDF_PAID'] . ':', 0, 0, 'L', 1);
$pdf->SetFont('arialpl', 'B', '8');
$pdf->Cell(30, 4, format_number($this->paid_val) . ' ' . $this->currency_symbol, 0, 0, 'R', 1);
if($this->paid_val > 0) {
//$pdf->SetX(100);
//$pdf->SetFont('arialpl', '', '8');
//$pdf->WriteHtml($app_list_strings['payment_method_dom'][$this->payment_method_paid]);
}
$pdf->Ln(4);
//if ($pdf->GetY() > 240) {
// $pdf->AddPage();
//}
$total -= ($this->paid_val);
//var_export($numberLength);
//var_export($fNumber);
//var_export(str_pad(format_number($this->paid_val), $numberLength, '_', STR_PAD_LEFT));
//var_export(implode(array_fill(0, 10 - 5, '&nbsp;')) . format_number($pleft));exit;
$pleft = $brutto - $this->prepaid - $this->paid_val;
$pdf->SetX(10);
$pdf->SetFont('arialpl', '', '8');
$pdf->Cell(50, 4, 'Pozostało do zapłaty:', 0, 0, 'L', 1);
$pdf->SetFont('arialpl', 'B', '8');
$pdf->Cell(30, 4, format_number(($pleft < 0) ? 0 : $pleft) . ' ' . $this->currency_symbol, 0, 0, 'R', 1);
$pdf->writeHTML('</b>');
}
//$pdf->Ln(4);
//$pdf->SetFont('arialpl', '', '8');
//
//if (false == is_null($pc)) {
// $pdf->Cell(50, 4, $mod_strings['LBL_PDF_PAYMENT_METHOD'] . ':', 0, 0, 'L', 1);
// $pdf->Cell(50, 4, $pc->name ? : '-', 0, 0, 'L', 1);
//
// $pdf->Ln(4);
//}
//
//$pdf->Cell(50, 4, $mod_strings['LBL_PDF_PAYMENT_TERMIN'] . ':', 0, 0, 'L', 1);
//$pdf->Cell(50, 4, $this->payment_date ? : '-', 0, 0, 'L', 1);
//
//$pdf->Ln(4);
//
//$pdf->SetFont('arialpl', '', '8');
//$pdf->Cell(30, 4, "Słownie:", 0, 0, 'L', 1);
//$pdf->SetFont('arialpl', 'B', '8');
//
//if ($this->type == "correct") {
// $tot = format_number(abs((float) $total - array_sum($inv_value)));
// $tot = str_replace(".", "", $tot);
// //$tot=str_replace(",",".",$tot);
// $sl = $this->slowniePL($tot);
//} else {
// $tot = str_replace(".", "", str_replace("PLN", "", $total - array_sum($inv_value)));
// $sl = $this->slowniePL($tot);
//}
//
//if ($this->document_no == "FV 1421/10") {
// $sl = "one thousand one hundred six EUR 41/100";
//}
//
//$pdf->Cell(150, 4, $sl, 0, 0, 'L', 1);
//echo '<pre>' . var_export(format_number('9.9999', 4, 4), true) . '</pre>'; exit;
//echo '<pre>' . var_export(gettype((double)$this->currency_value_nbp), true) . '</pre>'; exit;
if ($this->currency_value_nbp > 1 && $this->currency_symbol != 'EUR') {
$pdf->Ln(8);
$pdf->SetX(10);
$pdf->WriteHtml(sprintf('Ceny wyliczono wg kursu sprzedaży walut banku Citi Handlowego z dn. %s: 1 %s = %s %s', date('d.m.Y'), 'EUR', format_number($this->currency_value_nbp, 4, 4), $this->currency_symbol));
//$pdf->Cell(50, 4, 'Ceny wyliczono wg kursu sprzedaży walut banku Citi Handlowego z dn. wystawienia faktury: ' , 0, 0, 'L', 1); // $mod_strings['LBL_CURRENCY_VALUE'] . ':'
//$pdf->Cell(30, 4, '1 ' . $this->currency_symbol . ' = ' . format_number($this->currency_value_nbp, 4, 4) . ' zł', 0, 0, 'R', 1);
}
//echo '<pre>' . var_export($calc, true) . '</pre>'; exit;
//$cvatpln = '';
if($this->currency_value_nbp > 1 && $this->currency_symbol != 'PLN') {
$pdf->Ln(8);
$pdf->Cell(85, 1, "Kurs 1 EUR = " . format_number($this->currency_value_nbp, 4, 4) . ' PLN', 0, 0, 'L', 1);
$pdf->Ln(4);
$pdf->Cell(85, 1, "Wartość VAT = " . format_number($cVatPln) . ' PLN', 0, 0, 'L', 1);
// $pdf->Ln(8);
// $pdf->SetX(10);
// $pdf->WriteHtml(sprintf('Wartość VAT: %s PLN', format_number($cVatPln)));
}
$pdf->Ln(18);
$pdf->SetX(10);
$pdf->SetFont('arialpl', '', '7');
$pdf->Cell(95, 1, "...............................................................", 0, 0, 'L', 1);
$pdf->Cell(95, 1, "...............................................................", 0, 0, 'R', 1);
$pdf->Ln(4);
$pdf->SetX(10);
$pdf->Cell(43, 1, $mod_strings['LBL_PDF_OWNER_SIGNATURE'], 0, 0, 'C', 1);
$pdf->SetX(162);
$pdf->Cell(35, 1, $mod_strings['LBL_PDF_RECEIVER_SIGNATURE'], 0, 0, 'C', 1);
$pdf->Ln(4);
$pdf->SetX(10);
$pdf->Cell(43, 1, $this->setUser()->full_name, 0, 0, 'C', 1);
//footer text
$pdf->Ln(1);
//$pdf->SetFont('arialpl', '', '8');
//$pdf->MultiCell(0, 4, $this->footer_text, 0, 'J');
//header text
$pdf->Ln(5);
$pdf->SetFont('arialpl', 'B', '8');
$pdf->MultiCell(0, 4, $this->ads_text, 0, 'J');
/*
error_reporting(E_ALL);
ini_set('display_errors', 1);
$pdf->DeletePage(6);exit;
*/
} else {
//payment conditions
/*
if (!empty($this->ecmpaymentcondition_text)) {
$pdf->Ln(4);
$pdf->SetFont('arialpl', '', '8');
$pdf->MultiCell(0, 4, $this->ecmpaymentcondition_text, 0, 'L');
$pdf->Ln();
}
*/
/*
if ($this->type == "correct") {
$pdf->SetFont('arialpl', 'b', '12');
$pdf->Ln(3);
$pdf->MultiCell(0, 4, $mod_strings['LBL_PDF_DOCUMENT_CORRECT_DIFFERENCE'] . " " . format_number(abs(unformat_number($this->total) + unformat_number($this->ecminvoiceout->total))) . ' ' . $this->currency_symbol);
$pdf->Ln(3);
}
*/
$pdf->writeHTML('</table>'); // fix background-color overflowing from table ... why ? //
$pdf->Ln(2);
$pdf->SetFont('arialpl', '', '8');
$pdf->Cell(50, 4, 'Zapłacono/Paid:', 0, 0, 'L', 1);
$pdf->Cell(50, 4, format_number($this->paid_val) . ' ' . $this->currency_symbol, 0, 0, 'L', 1);
$pdf->Ln(4);
if ($pdf->GetY() > 250)
$pdf->AddPage();
if ($this->type == "correct") {
$pdf->SetFont('arialpl', '', '8');
$w = $GLOBALS['db']->query("select price,ecmvat_value,quantity,ecminvoiceoutitem_id from ecminvoiceoutitems where ecminvoiceout_id='" . $this->id . "'");
while ($r = $GLOBALS['db']->fetchByAssoc($w)) {
$total+=$r['price'] * $r['quantity'] + round($r['price'] * $r['quantity'] * $r['ecmvat_value'] / 100, 2);
$rr = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select price,quantity,ecmvat_value from ecminvoiceoutitems where id='" . $r['ecminvoiceoutitem_id'] . "'"));
$total-=$rr['price'] * $rr['quantity'] + round($rr['price'] * $rr['quantity'] * $rr['ecmvat_value'] / 100, 2);
}
//if($total>0)$string=$mod_strings['LBL_PDF_TO_PAID'];
//else $string=$mod_strings['LBL_PDF_TO_PAID_BACK'];
$string = "Pozostało do zapłaty/To pay:";
$pdf->Cell(50, 4, $string, 0, 0, 'L', 1);
$pdf->SetFont('arialpl', 'B', '8');
$pdf->Cell(50, 4, format_number(abs($total)) . ' ' . $this->currency_symbol, 0, 0, 'L', 1);
} else {
$total = 0;
$pdf->SetFont('arialpl', '', '8');
$w = $GLOBALS['db']->query("select price,ecmvat_value,quantity,ecminvoiceoutitem_id from ecminvoiceoutitems where ecminvoiceout_id='" . $this->id . "'");
while ($r = $GLOBALS['db']->fetchByAssoc($w)) {
$total+=$r['price'] * $r['quantity'] + round($r['price'] * $r['quantity'] * $r['ecmvat_value'] / 100, 2);
}
$total-=floatval(str_replace(",", ".", str_replace(".", "", $this->discount)));
$total = format_number($total);
$pdf->Cell(50, 4, "Pozostało do zapłaty/To pay: ", 0, 0, 'L', 1);
$pdf->SetFont('arialpl', 'B', '8');
$pdf->Cell(50, 4, format_number($sum_total-$this->paid_val) . ' ' . $this->currency_symbol, 0, 0, 'L', 1);
}
//$pdf->Ln(8);
$pdf->SetFont('arialpl', '', '8');
/*
$paymentCondition = new EcmPaymentCondition();
$paymentCondition->retrieve($this->ecmpaymentcondition_id);
$pdf->Cell(50, 4, 'Metoda płątności/Payment method:', 0, 0, 'L', 1);
$pdf->Cell(50, 4, $this->payment_method ? : '-', 0, 0, 'L', 1);
$pdf->Ln(4);
$pdf->Cell(50, 4, 'Termin płatności/Payment date:', 0, 0, 'L', 1);
$pdf->Cell(50, 4, $this->payment_date, 0, 0, 'L', 1);
/*
$pdf->Ln(4);
$pdf->SetFont('arialpl', '', '8');
$pdf->Cell(30, 4, "Słownie:", 0, 0, 'L', 1);
$pdf->SetFont('arialpl', 'B', '8');
if ($this->type == "correct") {
$tot = format_number(abs((float) $total));
$tot = str_replace(".", "", $tot);
//$tot=str_replace(",",".",$tot);
$sl = $this->slowniePL($tot);
} else {
$tot = str_replace(".", "", str_replace("PLN", "", $total));
$sl = $this->slowniePL($tot);
}
if ($this->document_no == "FV 1421/10")
$sl = "one thousand one hundred six EUR 41/100";
*/
$pdf->Cell(150, 4, $sl, 0, 0, 'L', 1);
$pdf->Ln(8);
//$pdf->Cell(50, 4, 'Kurs waluty/Rate of exchange', 0, 0, 'L', 1);
//$pdf->Cell(50, 4, '1 '.$this->currency_symbol.' = ' . format_number($this->currency_value_nbp ? : 1, 4, 4) . ' PLN', 0, 0, 'L', 1);
// $pdf->Cell(50, 4, format_number($this->currency_value_nbp ? : 1, 4, 4), 0, 0, 'L', 1);
$pdf->Ln(10);
$pdf->Ln(10);$pdf->Ln(10);
$pdf->SetFont('arialpl', '', '7');
$pdf->Cell(85, 1, "...............................................................", 0, 0, 'L', 1);
$pdf->Cell(85, 1, "...............................................................", 0, 0, 'R', 1);
$pdf->Ln(4);
$pdf->Cell(43, 1, "Seller signature", 0, 0, 'C', 1);
$pdf->SetX(155);
$pdf->Cell(35, 1, "Buyer signature", 0, 0, 'C', 1);
$pdf->Ln(4);
$pdf->Cell(43, 1, $this->setUser()->full_name, 0, 0, 'C', 1);
//footer text
//$pdf->Ln(18);
//$pdf->SetFont('arialpl', '', '8');
//$pdf->MultiCell(0, 4, $this->footer_text, 0, 'J');
//header text
//$pdf->Ln(6);
//$pdf->SetFont('arialpl', 'B', '8');
//$pdf->MultiCell(0, 4, $this->ads_text, 0, 'J');
}

View File

@@ -0,0 +1,913 @@
<?php
global $app_list_strings, $mod_strings, $db, $sugar_config;
$pdf->focus = $this;
//$mod_strings = return_module_language($sugar_config['default_language'], 'EcmInvoiceOuts', true);
$mod_strings = return_module_language($this->ecmlanguage, 'EcmInvoiceOuts', true);
//$mod_strings2 = return_module_language('en_us', 'EcmInvoiceOuts', true);
$mod_strings['LBL_PDF_FOOTER_DOCUMENT_NAME'] = 'Proforma';
$address = htmlspecialchars_decode($this->parent_name);//str_replace(array('&lt;', '&gt;'), array('<', '>'), $this->parent_name);
if ($this->parent_contact_name) {
$address .= PHP_EOL . $this->parent_contact_name;
if ($this->parent_contact_title) {
$address .= PHP_EOL . $this->parent_contact_title;
}
$personplus = 5;
} else {
$personplus = 0;
}
if ($this->parent_address_street) {
$address .= PHP_EOL . $this->parent_address_street;
}
if ($this->parent_address_postalcode) {
$address .= PHP_EOL . $this->parent_address_postalcode;
}
if ($this->parent_address_city) {
$address .= " " . $this->parent_address_city;
}
if ($this->to_vatid) {
$address .= PHP_EOL . $this->to_vatid;
}
$qr = 'SELECT iln, to_nip FROM accounts WHERE id = \'' . $this->parent_id . '\'';
$r = $db->fetchByAssoc($db->query($qr));
if ($r['iln']) {
$address .= "\nILN: " . $r['iln'];
}
//to address
$old_x = $pdf->GetX();
$old_y = $pdf->GetY();
$pdf->SetXY(10, 53);
$pdf->SetFont('arialpl', 'B', 8);
$pdf->Cell(35, 1, strtoupper($mod_strings['LBL_PDF_SELLER']), 0, 0, 'L', 1);
$pdf->Ln(3);
$pdf->SetX(10);
$pdf->SetFont('arialpl', '', 8);
$qr = 'SELECT nip FROM accounts WHERE id = \'' . $pdf->edt->account_id . '\'';
$r = $db->fetchByAssoc($db->query($qr));
$wys = $pdf->edt->name . PHP_EOL;
if ($pdf->edt->footer_address) {
$tmp = explode(",", $pdf->edt->footer_address);
$wys .= $tmp[0] . PHP_EOL . trim($tmp[1]).PHP_EOL;
}
$wys .= "NIP: PL 525-21-73-990";
$qr = 'SELECT index_dbf FROM accounts WHERE id = \'' . $this->parent_id . '\'';
$r = $db->fetchByAssoc($db->query($qr));
if ($r['index_dbf']) {
$address .= PHP_EOL . $mod_strings['LBL_PDF_INDEX_DBF'] . ": " . $r['index_dbf'];
}
$pdf->MultiCell(60, 4, $wys, 0, 'L');
$pdf->SetXY(76, 53);
$pdf->SetFont('arialpl', 'B', 8);
$pdf->Cell(35, 1, strtoupper($mod_strings['LBL_PDF_BUYER']), 0, 0, 'L', 1);
$pdf->Ln(3);
$pdf->SetX(76);
$pdf->SetFont('arialpl', '', 8);
$pdf->MultiCell(60, 4, $address, 0, 'L');
$qr = "SELECT * FROM ecmstockdocouts WHERE id='" . $wz_id . "'";
$r = $db->fetchByAssoc($db->query($qr));
if ($r['parent_id'] == $this->parent_id) {
$qr = "SELECT name as parent_name,shipping_address_street as parent_address_street,shipping_address_city as parent_address_city,shipping_address_postalcode as parent_address_postalcode,shipping_address_country as parent_address_country FROM accounts WHERE id='" . $this->parent_id . "'";
$r = $db->fetchByAssoc($db->query($qr));
}
$address = str_replace(array('&lt;', '&gt;'), array('<', '>'), $this->parent_shipping_address_name);
if ($this->parent_shipping_address_street) {
$address .= PHP_EOL . $this->parent_shipping_address_street;
}
if ($this->parent_shipping_address_postalcode) {
$address .= PHP_EOL . $this->parent_shipping_address_postalcode;
}
if ($this->parent_shipping_address_city) {
$address .= ' ' . $this->parent_shipping_address_city;
}
if ($address) {
$pdf->SetXY(143, 53);
$pdf->SetFont('arialpl', 'B', 8);
$pdf->Cell(35, 1, strtoupper($mod_strings['LBL_PDF_DELIVERY']), 0, 0, 'L', 1);
$pdf->Ln(3);
$pdf->SetX(143);
$pdf->SetFont('arialpl', '', 8);
$pdf->MultiCell(60, 4, $address, 0, 'L');
}
$ynew = 53 + 12;
$pc = null;
if ($this->ecmpaymentcondition_id) {
require_once("modules/EcmPaymentConditions/EcmPaymentCondition.php");
$pc = new EcmPaymentCondition();
$pc->retrieve($this->ecmpaymentcondition_id);
}
$pdf->SetXY(160, $old_y + 15 + $personplus);
$table = array();
$table[1]['date_reg'] = array(
'width' => 16,
'value' => $mod_strings['LBL_PDF_DATE_REGISTER'],
'border' => 0,
'overflow' => 1,
'align' => 'L',
'font-size' => 8,
);
$table[1]['date_reg_value'] = array(
'width' => 36 + 4,
'value' => date('d.m.Y'),//$this->register_date,
'border' => 0,
'overflow' => 1,
'align' => 'L',
'font-style' => 'b',
'font-size' => 8,
);
if(true) {
$table[4]['date_sell'] = array(
'width' => 16,
'value' => $mod_strings['LBL_ZAM_NUM'],
'border' => 0,
'overflow' => 1,
'align' => 'L',
'font-size' => 8,
);
$table[6]['parent_document_no'] = array(
'width' => 16,
'value' => $mod_strings['LBL_ZAM_KL'],
'border' => 0,
'overflow' => 1,
'align' => 'L',
'font-size' => 8,
);
$table[6]['parent_document_no_v'] = array(
'width' => 16,
'value' => $this->parent_document_no,
'border' => 0,
'overflow' => 1,
'align' => 'L',
'font-size' => 8,
'font-style' => 'b',
);
$table[4]['date_sell_value'] = array(
'width' => 36 + 4,
'value' => $this->document_no,
'border' => 0,
'overflow' => 1,
'align' => 'L',
'font-style' => 'b',
'font-size' => 8,
'valign' => 'C',
);
$table[5]['date_sell'] = array(
'width' => 16,
'value' => $mod_strings['LBL_ZAM_DAT'],
'border' => 0,
'overflow' => 1,
'align' => 'L',
'font-size' => 8,
);
$table[5]['date_sell_value'] = array(
'width' => 36 + 4,
'value' => date('d.m.Y', strtotime($this->date_entered)),
'border' => 0,
'overflow' => 1,
'align' => 'L',
'font-style' => 'b',
'font-size' => 8,
'valign' => 'C',
);
}
$r = $db->fetchByAssoc($db->query("SELECT so_id FROM ecminvoiceouts WHERE id='" . $this->id . "'"));
$this->so_id = $r['so_id'];
if (!$this->so_id) {
$this->so_id = $_SESSION['invoice_so_id'];
}
$qr = "SELECT wz_id FROM ecminvoiceouts WHERE id = '" . $this->id . "'";
$r = $db->fetchByAssoc($db->query($qr));
$qr = "SELECT so_id FROM ecmstockdocouts WHERE id = '" . $r['wz_id'] . "'";
$r = $db->fetchByAssoc($db->query($qr));
$qr = "SELECT order_no FROM ecmsales WHERE id = '" . $r['so_id'] . "'";
$r = $db->fetchByAssoc($db->query($qr));
if ($r['order_no'] && $this->type != "correct") {
$table[8]['order_no'] = array(
'width' => 20,
'value' => $mod_strings['LBL_PDF_ORDER_NO'],
'border' => 0,
'overflow' => 1,
'align' => 'L',
'font-size' => 8,
);
$table[8]['order_no_value'] = array(
'width' => 25,
'value' => $r['order_no'],
'border' => 0,
'overflow' => 1,
'align' => 'L',
'font-style' => 'b',
'font-size' => 8,
);
}
//if ($this->type != "normal") {
if (!$this->so_id) {
$this->so_id = $_SESSION['invoice_so_id'];
}
$qr_so = "SELECT * FROM ecmsales WHERE id='" . $this->so_id . "'";
$r_so = $db->fetchByAssoc($db->query($qr_so));
//}
$pdf->SetXY(143, $pdf->tMargin + 20);
$pdf->DrawTable($table, null, 0.5, 0.5, 3);
$pdf->Ln(9);
$pdf->SetFont('arialpl', '', '18');
$pdf->SetXY(60, $pdf->tMargin + 25);
//if ($this->type == "normal") {
$pieces = explode(" ", $this->document_no);
$pdf->MultiCell(80, 7, "Faktura Proforma " . $pieces[1], 0, 'C');
$pdf->SetFont('arialpl', 'B', 7);
$pdf->Ln(3);
$pdf->SetX(60);
//} else if ($this->type == "correct") {
// $pdf->MultiCell(80, 7, $mod_strings['LBL_PDF_DOCUMENT_NAME_CORRECT'] . " " . $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');
$currency = new Currency();
$currency->retrieve($this->currency_id);
$this->currency_symbol = $currency->iso4217;
$this->currency_value = $currency->conversion_rate;
// echo $this->currency_symbol ;
//if($this->currency_symbol == 'PLN') {
// $this->currency_symbol = 'zł';
//}
//echo '<pre>' . var_export($this->currency_value, true) . '</pre>'; exit;
//$this->currency_value = $currency->conversion_rate;
if (!isset($this->position_list) || !is_array($this->position_list)) {
$this->position_list = $this->getPositionList(true);
}
//blad $calc = $this->calculate_currency($this->position_list, $this->currency_id, $this->currency_value);
$calc = $this->calculate($this->position_list, false);
$this->position_list = $this->formatPositions($this->position_list, $this->currency_id, $this->currency_value);
//$this->position_list = $this->getPositionList(true);
//echo '<pre>'. var_export($calc, true); exit;
//echo '<pre>'. var_export($this->position_list, true);
//echo '<pre>'. var_export($this->currency_symbol, true);
//exit;
$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;
}
}
$summary_offset = 118;
//$calc['discount'] = 0;
$widths = array(
// List.
'position' => 4,
'description' => 40,
'recipient_code' => 10,
'quantity' => 8,// 7 + 5,
//'unit' => 5,
'draw_discount' => 11,
'unit_price' => 11,
'unit_price_total' => 11,
'vat_id' => 5,
'vat_value' => 11,
'total' => 11,
// Summary.
'fix' => 53,
'vat_rate' => 10,
'netto_total' => 11,
'vat_total' => 16,
'brutto_total' => 11,
);
$pdf->Ln(7);
//$calc['draw_discount'] = false;
if ($calc['draw_discount']) {
$widths['description'] -= $widths['draw_discount'] - 1;
$widths['quantity'] -= 1;
$widths['vat_rate'] -= 3;
$widths['netto_total'] += 3;
}
$list = array();
$list[0]['position'] = array(
'background' => array(233, 233, 233),
'width' => $widths['position'],
'value' => $mod_strings['LBL_PDF_LIST_POSITION'],
'border' => 1,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 8,
);
$list[0]['description'] = array(
'background' => array(233, 233, 233),
'width' => $widths['description'],
'value' => $mod_strings['LBL_PDF_LIST_DESCRIPTION'] . PHP_EOL . $mod_strings['LBL_PDF_LIST_INDEX'],
'border' => 1,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
);
if ($calc['draw_recipient_code']) {
$list[0]['recipient_code'] = array(
'background' => array(233, 233, 233),
'width' => $widths['recipient_code'],
'value' => $mod_strings['LBL_PDF_RECIPIENT_CODE'],
'border' => 1,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
);
}
//$list[0]['tax_code'] = array(
// 'background' => array(233, 233, 233),
// 'width' => $widths['tax_code'],
// 'value' => $mod_strings['LBL_PDF_LIST_TAX_CODE'],
// 'border' => 1,
// 'overflow' => 1,
// 'align' => 'C',
// 'font-style' => 'b',
// 'font-size' => 7,
//);
//
//$list[0]['recipient_code'] = array(
// 'background' => array(233, 233, 233),
// 'width' => $widths['recipient_code'],
// 'value' => $mod_strings['LBL_PDF_LIST_TAX_CODE'],
// 'border' => 1,
// 'overflow' => 1,
// 'align' => 'C',
// 'font-style' => 'b',
// 'font-size' => 7,
//);
$list[0]['quantity'] = array(
'background' => array(233, 233, 233),
'width' => $widths['quantity'],
'value' => $mod_strings['LBL_PDF_LIST_QUANTITY'] . PHP_EOL . $mod_strings['LBL_PDF_LIST_UNIT'],
'border' => 1,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
);
/*
$list[0]['unit'] = array(
'background' => array(233, 233, 233),
'width' => $widths['unit'],
'value' => $mod_strings['LBL_PDF_LIST_UNIT'],
'border' => 1,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 8,
);
*/
if ($calc['draw_discount']) {
$list[0]['draw_discount'] = array(
'background' => array(233, 233, 233),
'width' => $widths['draw_discount'],
'value' => 'Cena' . PHP_EOL . $mod_strings['LBL_PDF_LIST_DISCOUNT'],
'border' => 1,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
);
}
$list[0]['unit_price'] = array(
'background' => array(233, 233, 233),
'width' => $widths['unit_price'],
'value' => $mod_strings['LBL_PDF_LIST_UNIT_PRICE'],
'border' => 1,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
);
$list[0]['unit_price_total'] = array(
'background' => array(233, 233, 233),
'width' => $widths['unit_price_total'],
'value' => $mod_strings['LBL_PDF_LIST_UNIT_PRICE_TOTAL'],
'border' => 1,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
);
//if($calc['draw_vat']) {
//if ($this->currency_symbol != "USD") {
$list[0]['vat_id'] = array(
'background' => array(233, 233, 233),
'width' => $widths['vat_id'],
'value' => $mod_strings['LBL_PDF_LIST_VAT_ID'],
'border' => 1,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
);
$list[0]['vat_value'] = array(
'background' => array(233, 233, 233),
'width' => $widths['vat_value'],
'value' => $mod_strings['LBL_PDF_LIST_VAT_VALUE'],
'border' => 1,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
);
//}
//}
//
//if ($this->currency_symbol == "USD") {
// $list[0]['nw'] = array(
// 'background' => array(233, 233, 233),
// 'width' => 9,
// 'value' => "Netto weight",
// 'border' => 1,
// 'overflow' => 1,
// 'align' => 'C',
// 'font-style' => 'b',
// 'font-size' => 7,
// );
//
// $list[0]['bw'] = array(
// 'background' => array(233, 233, 233),
// 'width' => 9,
// 'value' => "Brutto weight",
// 'border' => 1,
// 'overflow' => 1,
// 'align' => 'C',
// 'font-style' => 'b',
// 'font-size' => 7,
// );
//}
$list[0]['total'] = array(
'background' => array(233, 233, 233),
'width' => $widths['total'],
'value' => $mod_strings['LBL_PDF_LIST_TOTAL'],
'border' => 1,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
);
if ($this->type != "normal") {
$pdf->SetY(76);
}
$lv = return_app_list_strings_language($this->ecmlanguage);
$i = 1;
$netto_weight = $brutto_weight = 0;
$this->position_list = $this->getPositionList(true);
//$p = array_pop($this->position_list);
//$this->position_list = array_fill(0, 100, $p);
//echo '<pre>' . var_export($this->position_list);exit;
foreach ($this->position_list as $key => $position) {
$list[$i]['position'] = array(
'width' => $widths['position'],
'value' => $i,
'border' => 1,
'align' => 'R',
'font-size' => 7,
);
$code = $position['code'];
// Hardcoded. Trust that temporary indexes are in "%s_%s" format.
$list[$i]['description'] = array(
'width' => $widths['description'],
'value' => htmlspecialchars_decode($position['name']) . PHP_EOL . $code, //$position['product_code'],
'border' => 1,
'align' => 'L',
'font-size' => 7,
);
$netto_weight += $position['netto_weight'];
//$brutto_weight += $position['brutto_weight'];
$brutto_weight += ($position['quantity'] * $position['netto_weight']);
$list[$i]['quantity'] = array(
'width' => $widths['quantity'],
'value' => format_number($position['quantity']) . PHP_EOL . $position['unit_name'],
'border' => 1,
'align' => 'R',
'font-size' => 7,
);
$price_total = 0.0;
if ($calc['draw_discount']) {
$tmp = ($position['price']) * (1 - $position['discount'] / 100);
$price_total = $tmp * $position['quantity'];
$list[$i]['draw_discount'] = array(
'width' => $widths['draw_discount'],
//'value' => format_number(unformat_number($position['price']) * (1 - $position['discount'] / 100)) . PHP_EOL . format_number($position['discount']),
'value' => format_number( ($position['price'])) . PHP_EOL . format_number($position['discount']),
'border' => 1,
'align' => 'R',
'font-size' => 7,
);
$list[$i]['unit_price'] = array(
'width' => $widths['unit_price'],
'value' => format_number($tmp) . PHP_EOL . $this->currency_symbol,
'border' => 1,
'align' => 'R',
'font-size' => 7,
);
} else {
$price_total = ($position['price']) * $position['quantity'];
$list[$i]['unit_price'] = array(
'width' => $widths['unit_price'],
'value' => format_number(($position['price'])) . PHP_EOL . $this->currency_symbol,
'border' => 1,
'align' => 'R',
'font-size' => 7,
);
}
$list[$i]['unit_price_total'] = array(
'width' => $widths['unit_price_total'],
'value' => format_number($price_total),
'border' => 1,
'align' => 'R',
'font-size' => 7,
);
$list[$i]['vat_id'] = array(
'width' => $widths['vat_id'],
'value' => format_number($position['vat_value']),
'border' => 1,
'align' => 'R',
'font-size' => 7,
);
$vat_value = round($price_total * ($position['vat_value'] / 100), 2);
// $vat_value = round($position['total'] - $position['subtotal'], 2);
$list[$i]['vat_value'] = array(
'width' => $widths['vat_value'],
'value' => format_number($vat_value),
'border' => 1,
'align' => 'R',
'font-size' => 7,
);
$list[$i]['total'] = array(
'width' => $widths['total'],
'value' => format_number($price_total + $vat_value),
'border' => 1,
'align' => 'R',
'font-size' => 7,
);
$totals[$position['vat_id']]['price'] += $price_total;// * (($this->currency_symbol != $position['currency_name']) ? $this->currency_value : 1);
$totals[$position['vat_id']]['total'] += ($price_total + $vat_value);// * (($this->currency_symbol != $position['currency_name']) ? $this->currency_value : 1);
$totals[$position['vat_id']]['vat'] += $vat_value;
$sum_total += ($price_total + $vat_value);// * (($this->currency_symbol != $position['currency_name']) ? $this->currency_value : 1);;
$sum_netto += $price_total ;//* (($this->currency_symbol != $position['currency_name']) ? $this->currency_value : 1);
$i++;
}
$pdf->Ln(8);
$pdf->setX(10);
$pdf->DrawTable($list, array(0));
$pdf->Ln(1);
$pdf->setX(10);
$pdf->Ln(4);
$pr = ($pdf->fw - $pdf->lMargin - $pdf->rMargin) / 100;
$summary = array();
$i = 0;
/*
if ($calc['vats']) {
$summary[$i]['fix'] = array(
'width' => $widths['fix'],
'value' => '',
'border' => 0,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
);
$summary[$i]['vat_rate'] = array(
'width' => $widths['vat_rate'],
'value' => $mod_strings['LBL_PDF_LIST_VAT_RATE'],
'border' => 1,
'background' => array(233, 233, 233),
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
);
$summary[$i]['netto_total'] = array(
'width' => $widths['netto_total'],
'value' => $mod_strings['LBL_PDF_LIST_NETTO_TOTAL'], //$mod_strings['LBL_PDF_LIST_TOTAL_PRICE'],
'background' => array(233, 233, 233),
'border' => 1,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
);
$summary[$i]['vat_total'] = array(
'width' => $widths['vat_total'],
'value' => $mod_strings['LBL_PDF_LIST_VAT_TOTAL'],
'background' => array(233, 233, 233),
'border' => 1,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
);
$summary[$i]['brutto_total'] = array(
'width' => $widths['brutto_total'],
'value' => $mod_strings['LBL_PDF_LIST_BRUTTO_TOTAL'],
'border' => 1,
'background' => array(233, 233, 233),
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
);
foreach ($calc['vats'] as $key => $value) {
$i++;
$qr = "SELECT id, name, value FROM ecmvats WHERE id = '" . $key . "'";
$r = $db->fetchByAssoc($db->query($qr));
$summary[$i]['fix'] = array(
'width' => $widths['fix'],
'value' => '',
'border' => 0,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
);
$summary[$i]['vat_rate'] = array(
'width' => $widths['vat_rate'],
'value' => format_number($r['value']),
'background' => array(255, 255, 255),
'border' => 1,
'overflow' => 1,
'align' => 'R',
'font-size' => 7,
);
$summary[$i]['netto_total'] = array(
'width' => $widths['netto_total'],
'value' => format_number($totals[$r['id']]['price']),
'background' => array(255, 255, 255),
'border' => 1,
'overflow' => 1,
'align' => 'R',
'font-size' => 7,
);
$cVatPlnTmp = $totals[$r['id']]['price'] * ($r['value']/100) ;
$cVatPln += $cVatPlnTmp * $this->currency_value_nbp;
// echo '<pre>' . $cVatPlnTmp . '</pre>';
$summary[$i]['vat_total'] = array(
'width' => $widths['vat_total'],
'value' => format_number($cVatPlnTmp),
'background' => array(255, 255, 255),
'border' => 1,
'overflow' => 1,
'align' => 'R',
'font-size' => 7,
);
$summary[$i]['brutto_total'] = array(
'width' => $widths['brutto_total'],
'value' => format_number($totals[$r['id']]['price']+$cVatPlnTmp),
'border' => 1,
'overflow' => 1,
'align' => 'R',
'font-size' => 7,
);
}
}
*/
if ($calc['discount']) {
$disc = floatval(str_replace(",", ".", str_replace(".", "", $this->discount)));
}
$brutto = $sum_total - $disc;
$netto = $sum_netto;
$vvat = $brutto - $netto;
$summary[$i]['fix'] = array(
'width' => $widths['fix'],
'value' => '',
'border' => 0,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
);
$i++;
$summary[$i]['fix'] = array(
'width' => $widths['fix'],
'value' => '',
'border' => 0,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
);
$summary[$i]['vat_rate'] = array(
'background' => array(233, 233, 233),
'width' => $widths['vat_rate'],
'value' => $mod_strings['LBL_PDF_LIST_SUMMARY_TOTAL'],
'border' => 1,
'overflow' => 1,
'align' => 'C',
'font-size' => 7,
'font-style' => 'b',
);
$summary[$i]['netto_total'] = array(
'background' => array(233, 233, 233),
'width' => $widths['netto_total'],
'value' => format_number($netto).' '.$this->currency_symbol,
'border' => 1,
'overflow' => 1,
'align' => 'R',
'font-size' => 7,
'font-style' => 'b',
);
$pdf->SetX(50);
//$pdf->DrawTable($table);
$pdf->DrawTable($summary);

View File

@@ -0,0 +1,316 @@
<?php
global $db;
$pdf->focus=$this;
$pdf->Ln(2);
$pdf->SetY($pdf->GetY()+2);
$current = $pdf->GetY();
$pdf->SetFont('arialpl', '', 9);
/*
$p_name = html_entity_decode($this->parent_name);
$p_name = explode(' ', $p_name);
$name = array();
if (sizeof($p_name)>4) {
for ($i=0; $i<sizeof($p_name); $i++) {
$n.=$p_name[$i].' ';
//$pdf->Cell(40,5, $n,0,1,'L');
if (($i%5==0) && ($i!=0)) {
$name[] = $n;
$n='';
}
}
$name[] = $n;
}
if($this->parent_name) {
if (sizeof($p_name)>4)
foreach ($name as $n)
$pdf->Cell(40,5, $n,0,1,'L');
else
$pdf->Cell(40,5, html_entity_decode($this->parent_name),0,1,'L');
}
*/
$pdf->MultiCell(100,5, html_entity_decode($this->parent_name),0,1,'L');
//$pdf->SetFont('arialpl', '', 10);
if($this->parent_address_street) $pdf->Cell(20,5,html_entity_decode($this->parent_address_street),0,1,'L');
if (($this->parent_address_postalcode) || ($this->parent_address_city))
$pdf->Cell(20,5,html_entity_decode($this->parent_address_postalcode).' '.html_entity_decode($this->parent_address_city),0,1,'L');
if($this->to_vatid) $pdf->Cell(20,5,$mod_strings['LBL_PDF_VATID'].' '.html_entity_decode($this->to_vatid),0,1,'L');
$title='';
if($this->parent_contact_title) $title.=$this->parent_contact_title.' ';
if($this->parent_contact_name) {
$pdf->SetFont('arialpl', 'b', 10);
$pdf->Cell(20,5,$title.$this->parent_contact_name,0,1,'L');
$pdf->SetFont('arialpl', 'b', 10);
}
/*
if($this->name) {
$pdf->Cell(20,5,'',0,1,'L');
$pdf->SetFont('arialpl', 'b', 10);
$pdf->Cell(20,5,$mod_strings['LBL_PDF_NAME'],0,1,'L');
$pdf->SetFont('arialpl', '', 10);
$pdf->Cell(20,5,html_entity_decode($this->name),0,1,'L');
}
*/
$pdf->SetFont('arialpl', '', 10);
$pdf->Ln(2);
// $current = $pdf->GetY();
//$pdf->MultiCell(120,4,$address,0,'L');
//$pdf->SetFont('arialpl','B','10');
//$pdf->MultiCell(0,4,$address_cnt,0,'L');
if($this->parent_type="Contacts")$pdf->Ln(14);
$current2 = $pdf->GetY();
$pdf->SetFont('arialpl','','10');
$subFontSizeold = $pdf->FontSizePt;
$pdf->SetFontSize($subFontSize);
/*
// reposition y
$subOffset = ((($subFontSize - $subFontSizeold) / $pdf->k) * 0.3) + ($subOffset / $pdf->k);
$subX = $pdf->x;
$subY = $pdf->y;
$pdf->SetXY($subX, $subY - $subOffset);
//Output text
$pdf->Write(5, 'test','');
// restore y position
$subX = $pdf->x;
$subY = $pdf->y;
$pdf->SetXY($subX, $subY + $subOffset);
// restore font size
$pdf->SetFontSize($subFontSizeold);
*/
// $pdf->Ln(7);
$pdf->SetXY($pdf->fw-$pdf->rMargin-37,$current);
$table = array();
$table [0]['data'] = array('width' => 30, 'value' => $mod_strings['LBL_PDF_DATE_REGISTER'], 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-style' => 'b', 'font-size' => 9);
$table [1]['data'] = array('width' => 30, 'value' => date("d.m.Y"), 'border' => 0, 'overflow' => 1, 'align' => 'L');
$table [2]['data'] = array('width' => 30, 'value' => "", 'border' => 0, 'overflow' => 1, 'align' => 'L');
$r_created_by = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select first_name, last_name from users where id='".$this->modified_user_id."'"));
$table [4]['data'] = array('width' => 30, 'value' => $mod_strings['LBL_PDF_OWNER'], 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-style' => 'b', 'font-size' => 9); $table [4]['data'] = array('width' => 30, 'value' => $mod_strings['LBL_PDF_OWNER'], 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-style' => 'b', 'font-size' => 9);
$table [5]['data'] = array('width' => 30, 'value' => $r_created_by['first_name']." ".$r_created_by['last_name'] , 'border' => 0, 'overflow' => 1, 'align' => 'L');
$table [6]['data'] = array('width' => 30, 'value' => $mod_strings['LBL_PDF_ASSIGNED_TO'], 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-style' => 'b', 'font-size' => 9);
$table [7]['data'] = array('width' => 30, 'value' => $this->setUser()->full_name.'
tel.: '.$this->setUser()->phone_work.'
kom.: '.$this->setUser()->phone_mobile.'
e-mail: '.$this->setUser()->email1, 'border' => 0, 'overflow' => 1, 'align' => 'L');
$pdf->DrawTable($table, null, 0, 0, 3);
$pdf->SetY($current2-10);
$pdf->Ln(2);
$pdf->SetFont('arialpl','','14');
$pdf->MultiCell(0,0,"Proforma nr ".$this->document_no,0,'L');
$pdf->SetFont('arialpl','','9');
$pdf->Ln(5);
//$table = array();
// $table[0][0] = array('width' => 30, 'value' => $mod_strings['LBL_PDF_PARENT_DOCUMENT_NO'], 'background' => array(255,255,255), 'border' => 0, 'overflow' => '1', 'align' => 'L');
//$table[0][1] = array('width' => 80, 'value' => $this->parent_document_no, 'background' => array(255,255,255), 'border' => 0, 'overflow' => '1', 'align' => 'L');
// $pdf->DrawTable($table);
//$pdf->MultiCell(0,0,'Szablon dokumentu jest aktualnie przebudowywany.',0,'L');
$pdf->SetY($current2+5);
//$pdf->MultiCell(0,0,'Spróbuj za 30 min.',0,'L');
$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);
//header text
if($this->header_text){
$pdf->Ln(8);
$pdf->SetFont('arialpl','','10');
$pdf->MultiCell(0,4,$this->header_text,0,'J');
}
$pdf->Ln(8);
//**************************************************
global $mod_strings;
if(!isset($this->position_list) || !is_array($this->position_list))
$this->position_list = $this->getPositionList(true);
$calc = $this->calculate_currency($this->position_list,$this->currency_id, $this->currency_value);
$this->position_list = $this->formatPositions($this->position_list, $this->currency_id, $this->currency_value);
/*
$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;
*/
$name_w = 59;
$image_w = 10;
$recipient_code_w = 10;
if($this->show_images_on_offers){
$name_w -= $image_w;
}
if($this->show_recipient_code){
$name_w -= $recipient_code_w;
}
if($calc['draw_discount']){
$name_w -= 8;
}
if($calc['draw_vat']){
$name_w -= 8;
}
//jest rabat?
$rabat = false;
foreach($this->position_list as $p) {
if ($p['discount']!=0) $rabat=true;
}
if ($this->total_netto!='') $name_w+=35;
$table = array();
$table [0]['position'] = array('width' => 5, 'value' => $mod_strings['LBL_PDF_LIST_POSITION'], 'background' => array(233,233,233), 'border' => 0, 'overflow' => 1, 'align' => 'C');
$table [0]['description'] = array('width' => $name_w, 'value' => $mod_strings['LBL_PDF_LIST_DESCRIPTION'], 'background' => array(233,233,233), 'border' => 0, 'overflow' => 1, 'align' => 'C');
$table [0]['quantity'] = array('width' => 8, 'value' => $mod_strings['LBL_PDF_LIST_QUANTITY'],'background' => array(233,233,233), 'border' => 0, 'overflow' => 1, 'align' => 'C');
if ($this->total_netto=='') {
$table [0]['unit_price'] = array('width' => 14, 'value' => $mod_strings['LBL_PDF_LIST_PRICE'], 'background' => array(233,233,233), 'border' => 0, 'overflow' => 1, 'align' => 'C');
if ($rabat==true) {
$table [0]['discount'] = array('width' => 7, 'value' => $mod_strings['LBL_PDF_LIST_DISCOUNT'], 'background' => array(233,233,233), 'border' => 0, 'overflow' => 1, 'align' => 'C');
}
$table [0]['total'] = array('width' => 14, 'value' => $mod_strings['LBL_PDF_LIST_TOTAL'], 'background' => array(233,233,233), 'border' => 0, 'overflow' => 1, 'align' => 'R');
}
$i = 1;
$lv=return_app_list_strings_language($this->ecmlanguage);
if($this->position_list != '')
// $result = $db->query("SELECT total_netto from ecmquotes where id=$p['id']");
foreach($this->position_list as $p) {
$table [$i]['position'] = array('width' => 5, 'value' => $i, 'border' => 0, 'align' => 'C', );
$name = str_replace('','-',htmlspecialchars_decode($p['name']));
$table [$i]['description'] = array('width' => $name_w, 'value' => $name, 'border' => 0, 'align' => 'L', );
$table [$i]['quantity'] = array('width' => 8, 'value' => $p['quantity'], 'border' => 0, 'align' => 'C', );
if ($this->total_netto=='') {
$table [$i]['unit_price'] = array('width' => 14, 'value' => $p['price'], 'border' => 0, 'align' => 'C', );
if ($rabat==true) {
if ($p['discount']==0) $tmp='---'; else $tmp=$p['discount'];
$table [$i]['discount'] = array('width' => 7, 'value' => $tmp, 'border' => 0, 'align' => 'R', );
}
$table [$i]['total'] = array('width' => 14, 'value' => $p['total'], 'border' => 0, 'align' => 'R', );
}
$tmp_sep = ereg_replace('[^0-9.,]', '', $p['total']);
$len = strlen($tmp_sep);
$separator = substr($tmp_sep, $len-3, 1);
if ($separator == '.') $tmp = (float) ereg_replace('[^0-9.]', '', $p['total']);
if ($separator == ',') $tmp = (float) ereg_replace('[^0-9,]', '', $p['total']);
if ($p['currency_id'] == 'PLN') {
if (isset($total_price_pln)) $total_price_pln += $tmp;
else $total_price_pln = $tmp;
}
if ($p['currency_id'] == '6336d9a0-ee5f-52e3-7d0c-4e6f1472b2bf') {
if (isset($total_price_eur)) $total_price_eur+= $tmp;
else $total_price_eur= $tmp;
}
$i++;
}
$starttab=$pdf->GetY()+10;
$pdf->DrawTable($table,array(0));
$endtab=$pdf->GetY();
$pdf->SetY($endtab);
//mz
$table = array();
//EURO
if($calc['vats']) {
$table [] = array(
'subtotal1' => array('width' => 66, 'value' => $mod_strings['LBL_PDF_TOTAL'], 'background' => array(255,255,255), 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 9),
'subtotal2' => array('width' => 34, 'value' => $calc['subtotal'].' '.$calc['currency_symbol'], 'border' => 0, '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' => 66, 'value' => $mod_strings['LBL_PDF_VAT'].' ('.$vvn.')', 'background' => array(255,255,255), 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 9),
'vat2' => array('width' => 34, 'value' => $value.' '.$calc['currency_symbol'], 'border' => 0, 'overflow' => 1, 'align' => 'R', 'font-size' => 9), );
}
}
$table [] = array(
'total1' => array('width' => 66, 'value' => $mod_strings['LBL_PDF_END_TOTAL'], 'background' => array(233,233,233), 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 9, 'font-style' => 'b'),
'total2' => array('width' => 34, 'value' => $calc['total'].' '.$calc['currency_symbol'], 'border' => 0, 'background' => array(233,233,233), 'overflow' => 1, 'align' => 'R' , 'font-size' => 9, 'font-style' => 'b'), );
$pdf->DrawTable($table);
//PLN
/*
$starttab=$pdf->GetY()+1;
$pdf->SetY($starttab);
$table = array();
if($calc['vats_pln']) {
$table [] = array(
'subtotal1' => array('width' => 66, 'value' => $mod_strings['LBL_PDF_TOTAL'], 'background' => array(255,255,255), 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 9),
'subtotal2' => array('width' => 34, 'value' => $calc['subtotal_pln'].' PLN', 'border' => 0, 'overflow' => 1, 'align' => 'R', 'font-size' => 9), );
foreach($calc['vats_pln'] as $key => $value){
$r=mysql_fetch_array(mysql_query("select name from ecmvats where id='".$key."'"));
$vvn=$r['name'];
$table [] = array(
'vat1' => array('width' => 66, 'value' => $mod_strings['LBL_PDF_VAT'].' ('.$vvn.')', 'background' => array(255,255,255), 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 9),
'vat2' => array('width' => 34, 'value' => $value.' PLN', 'border' => 0, 'overflow' => 1, 'align' => 'R', 'font-size' => 9), );
}
}
$table [] = array(
'total1' => array('width' => 66, 'value' => $mod_strings['LBL_PDF_END_TOTAL'], 'background' => array(233,233,233), 'border' => 0, 'overflow' => 1, 'align' => 'L', 'font-size' => 9, 'font-style' => 'b'),
'total2' => array('width' => 34, 'value' => $calc['subtotal_pln'].' PLN', 'border' => 0, 'background' => array(233,233,233), 'overflow' => 1, 'align' => 'R' , 'font-size' => 9, 'font-style' => 'b'), );
$pdf->DrawTable($table);
*/
?>

View File

@@ -0,0 +1,72 @@
<?php
$pdf->SetAutoPageBreak(true, 50);
//$pdf->AddFont('arialgr', '', 'arialgr.php');
//$pdf->SetFont('arialgr','','8');
//$pdf->MultiCell(0,4,"TEST",0,'J');
$lv = return_app_list_strings_language($this->ecmlanguage);
//check delivery address
$q = "
select
shipping_address_street,
shipping_address_city,
shipping_address_postalcode,
shipping_address_state,
shipping_address_country
from accounts where
(shipping_address_street!=billing_address_street OR
shipping_address_city!=billing_address_city OR
shipping_address_postalcode!=billing_address_postalcode OR
shipping_address_state!=billing_address_state OR
shipping_address_country!=billing_address_country) AND
id='" . $this->parent_id . "';
";
$res = $GLOBALS['db']->query($q);
if ($res->num_rows > 0) {
$r = $GLOBALS['db']->fetchByAssoc($res);
$table = array();
$table [0][] = array('width' => 30,
'value' => $mod_strings['LBL_PDF_SHIP_TO'],
'border' => 0,
'overflow' => 1,
'align' => 'L',
'font-style' => 'b',
'font-size' => 9,
);
$tmp= html_entity_decode($r['shipping_address_street']) . ', ' . html_entity_decode($r['shipping_address_postalcode']) . ' ' . html_entity_decode($r['shipping_address_city']);
$table [0][] = array(
'width' => 100,
'value' => $tmp,
'border' => 0,
'overflow' => 1,
'align' => 'L',
'font-style' => '',
'font-size' => 9,
);
$pdf->Ln(1);
$pdf->DrawTable($table, null, 0, 0, 3);
}
if ($this->footer_text != '') {
//footer text
$pdf->Ln(8);
$pdf->SetFont('arialpl', '', '8');
$pdf->MultiCell(0, 4, $this->footer_text, 0, 'J');
}
//payment conditions
$pdf->SetFont('arialpl', 'B', '8');
if ($this->ads_text != '') {
//ads text
$pdf->Ln(8);
$pdf->SetFont('arialpl', '', '8');
$pdf->MultiCell(0, 4, $this->ads_text, 0, 'J');
}

View File

@@ -0,0 +1,794 @@
<?php
global $db;
$mod_strings['LBL_PDF_FOOTER_DOCUMENT_NAME'] = 'Zamówienie';
$pdf->focus = $this;
$pdf->Ln(2);
$pdf->SetY($pdf->GetY() + 2);
$current = $pdf->GetY();
$pdf->SetFont('arialpl', '', 9);
$pdf->MultiCell(100, 5, html_entity_decode($this->parent_name), 0, 1, 'L');
//$pdf->SetFont('arialpl', '', 10);
if ($this->parent_address_street) {
$pdf->Cell(20, 5, html_entity_decode($this->parent_address_street), 0, 1, 'L');
}
if (($this->parent_address_postalcode) || ($this->parent_address_city)) {
$pdf->Cell(20, 5, html_entity_decode($this->parent_address_postalcode) . ' ' . html_entity_decode($this->parent_address_city), 0, 1, 'L');
}
if ($this->to_vatid) {
$pdf->Cell(20, 5, $mod_strings['LBL_PDF_VATID'] . ' ' . html_entity_decode($this->to_vatid), 0, 1, 'L');
}
$title = '';
if ($this->parent_contact_title) {
$title.=$this->parent_contact_title . ' ';
}
if ($this->parent_contact_name) {
$pdf->SetFont('arialpl', 'b', 10);
$pdf->Cell(20, 5, $title . $this->parent_contact_name, 0, 1, 'L');
$pdf->SetFont('arialpl', '', 10);
}
if ($this->parent_shipping_address_name || $this->parent_shipping_address_street) {
$x = $pdf->getX();
$y = $pdf->getY();
$pdf->setY($current+20);
$pdf->setX(25);
$pdf->SetFont('arialpl', 'b', 10);
$pdf->Cell(100, 5, $mod_strings['LBL_PDF_DELIVERY_TO'], 0, 1, 'L');
$pdf->SetFont('arialpl', '', 10);
$pdf->setX(25);
$pdf->MultiCell(100, 5, html_entity_decode($this->parent_shipping_address_name), 0, 1, 'L');
$pdf->setX(25);
if ($this->parent_shipping_address_street) {
$pdf->Cell(100, 5, html_entity_decode($this->parent_shipping_address_street), 0, 1, 'L');
}
$pdf->setX(25);
if (($this->parent_shipping_address_postalcode) || ($this->parent_shipping_address_city)) {
$pdf->Cell(20, 5, html_entity_decode($this->parent_shipping_address_postalcode) . ' ' . html_entity_decode($this->parent_shipping_address_city), 0, 1, 'L');
}
$pdf->setY($y);
$pdf->setX($x);
}
if ($this->name) {
$pdf->Cell(20, 5, '', 0, 1, 'L');
$pdf->SetFont('arialpl', 'b', 10);
$pdf->Cell(20, 5, $mod_strings['LBL_PDF_NAME'], 0, 1, 'L');
$pdf->SetFont('arialpl', '', 10);
$pdf->Cell(20, 5, html_entity_decode($this->name), 0, 1, 'L');
}
$pdf->SetFont('arialpl', '', 10);
$pdf->Ln(5);
if ($this->parent_type = "Contacts") {
$pdf->Ln(14);
}
$current2 = $pdf->GetY();
$pdf->SetFont('arialpl', '', '10');
$subFontSizeold = $pdf->FontSizePt;
$pdf->SetFontSize($subFontSize);
$pdf->SetXY($pdf->fw - $pdf->rMargin - 37, $current);
$table = array();
$table [0]['data'] = array(
'width' => 30,
'value' => $mod_strings['LBL_PDF_DATE_REGISTER'],
'border' => 0,
'overflow' => 1,
'align' => 'L',
'font-style' => 'b',
'font-size' => 9,
);
$table [1]['data'] = array(
'width' => 30,
'value' => $this->register_date,
'border' => 0,
'overflow' => 1,
'align' => 'L',
);
$table [2]['data'] = array(
'width' => 30,
'value' => $mod_strings['LBL_PDF_VALIDTILL_DATE'],
'border' => 0,
'overflow' => 1,
'align' => 'L',
'font-style' => 'b',
'font-size' => 9,
);
$table [3]['data'] = array(
'width' => 30,
'value' => $this->delivery_date,
'border' => 0,
'overflow' => 1,
'align' => 'L',
);
$table [4]['data'] = array(
'width' => 30,
'value' => $mod_strings['LBL_PDF_OWNER'],
'border' => 0,
'overflow' => 1,
'align' => 'L',
'font-style' => 'b',
'font-size' => 9,
);
$table [5]['data'] = array(
'width' => 30,
'value' => $this->setUser()->full_name,
'border' => 0,
'overflow' => 1,
'align' => 'L',
);
if ($this->parent_document_no && $this->parent_document_no!='') {
$table [6]['data'] = array(
'width' => 30,
'value' => $mod_strings['LBL_PDF_NUMBER'],
'border' => 0,
'overflow' => 1,
'align' => 'L',
'font-style' => 'b',
'font-size' => 9,
);
$table [7]['data'] = array(
'width' => 30,
'value' => $this->parent_document_no,
'border' => 0,
'overflow' => 1,
'align' => 'L',
);
}
$pdf->DrawTable($table, null, 0, 0, 3);
if ($this->parent_shipping_address_name || $this->parent_shipping_address_street)
$pdf->SetY($current+10);
$pdf->SetX(70);
//$pdf->Ln(8);
$pdf->SetFont('arialpl', '', '18');
$pdf->MultiCell(0, 0, $mod_strings['LBL_PDF_DOCUMENT_NAME'] . " " . $this->document_no, 0, 'L');
//$pdf->MultiCell(0,0,'Szablon dokumentu jest aktualnie przebudowywany.',0,'L');
$pdf->SetY($current2 + 15);
//$pdf->MultiCell(0,0,'Spróbuj za 30 min.',0,'L');
//$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);
/*
//header text
if ($this->header_text) {
$pdf->Ln(8);
$pdf->SetFont('arialpl', '', '10');
$pdf->MultiCell(0, 4, $this->header_text, 0, 'J');
}
*/
$pdf->Ln(8);
//**************************************************
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->formatPositions($this->position_list, $this->currency_id , $this->currency_value );
$this->position_list = $this->getPositionList(true);
}
//$calc = $this->calculate_currency($this->position_list, $this->currency_id , $this->currency_value );
//$this->position_list = $this->formatPositions($this->position_list, $this->currency_id , $this->currency_value );
$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;
}
}
*/
/*
echo '<pre>' . var_export($calc, true);
echo '<pre>' . var_export($this->position_list, true);
exit;
*/
$widths = array(
'position' => 5,
'description' => 60,
'quantity' => 8,
'unit_price' => 15,
'discount' => 8,
'total' => 15,
//
'fix' => 73 - 8,
'subtotal1' => 15 + 8, // 66
'subtotal2' => 15, // 34
);
$image_w = 10;
$recipient_code_w = 10;
if ($this->show_images_on_offers) {
$widths['description'] -= $image_w;
}
if ($this->show_recipient_code) {
$widths['description'] -= $recipient_code_w;
}
/*
if ($calc['draw_discount']) {
//$widths['description'] -= 8;
}
if ($calc['draw_vat']) {
$widths['description'] -= 8;
}
*/
//jest rabat?
$rabat = false;
foreach ($this->position_list as $p) {
if ($p['discount'] != 0)
$rabat = true;
}
if ($rabat) {
$widths['description'] -= $widths['discount'];
$widths['fix'] -= $widths['discount'];
$widths['subtotal2'] += $widths['discount'];
}
if ($this->total_netto != '') {
$widths['description']+=35;
}
$widths['description'] = $widths['description'] - 20;
$widths['code'] = 20;
$table = array();
$table [0]['position'] = array(
'width' => $widths['position'],
'value' => $mod_strings['LBL_PDF_LIST_POSITION'],
'background' => array(233, 233, 233),
'border' => 1,
'overflow' => 1,
'align' => 'C',
);
$table [0]['code'] = array(
'width' => $widths['code'],
'value' => $mod_strings['LBL_PDF_LIST_CODE'],
'background' => array(233, 233, 233),
'border' => 1,
'overflow' => 1,
'align' => 'C',
);
$table [0]['description'] = array(
'width' => $widths['description'],
'value' => $mod_strings['LBL_PDF_LIST_DESCRIPTION'],
'background' => array(233, 233, 233),
'border' => 1,
'overflow' => 1,
'align' => 'C',
);
$table [0]['quantity'] = array(
'width' => $widths['quantity'],
'value' => $mod_strings['LBL_PDF_LIST_QUANTITY'],
'background' => array(233, 233, 233),
'border' => 1,
'overflow' => 1,
'align' => 'C',
);
if ($this->total_netto == '') {
$table [0]['unit_price'] = array(
'width' => $widths['unit_price'],
'value' => $mod_strings['LBL_PDF_LIST_PRICE'],
'background' => array(233, 233, 233),
'border' => 1,
'overflow' => 1,
'align' => 'C',
);
if ($rabat == true) {
$table [0]['discount'] = array(
'width' => $widths['discount'],
'value' => $mod_strings['LBL_PDF_LIST_DISCOUNT'],
'background' => array(233, 233, 233),
'border' => 1,
'overflow' => 1,
'align' => 'C',
);
}
$table [0]['total'] = array(
'width' => $widths['total'],
'value' => $mod_strings['LBL_PDF_LIST_TOTAL'],
'background' => array(233, 233, 233),
'border' => 1,
'overflow' => 1,
'align' => 'R',
);
}
$i = 1;
$lv = return_app_list_strings_language($this->ecmlanguage);
if ($this->position_list != '') {
// $p = array_pop($this->position_list);
// $this->position_list = array_fill(0, 100, $p);
//
// $result = $db->query("SELECT total_netto from ecmquotes where id=$p['id']");
foreach ($this->position_list as $p) {
$table [$i]['position'] = array(
'width' => $widths['position'],
'value' => $i,
'border' => 1,
'align' => 'C',
);
$name = str_replace('', '-', htmlspecialchars_decode($p['name']));
$table [$i]['code'] = array(
'width' => $widths['code'],
'value' => $p['code'].PHP_EOL.$p['recipient_code'],
'border' => 1,
'align' => 'L',
);
$table [$i]['description'] = array(
'width' => $widths['description'],
'value' => $name,
'border' => 1,
'align' => 'L',
);
$table [$i]['quantity'] = array(
'width' => $widths['quantity'],
'value' =>format_number($p['quantity'],null,null,null,0),
'border' => 1,
'align' => 'C',
);
if ($this->total_netto == '') {
$table [$i]['unit_price'] = array(
'width' => $widths['unit_price'],
//'value' => format_number($p['price']) . ' ' . $this->currency_symbol,
'value' => format_number($p['price']),
'border' => 1,
'align' => 'R',
);
if ($rabat == true) {
if ($p['discount'] == 0) {
$tmp = '---';
} else {
$tmp = $p['discount'];
}
$table [$i]['discount'] = array(
'width' => $widths['discount'],
'value' => format_number($tmp) . '%',
'border' => 1,
'align' => 'R',
);
}
$table [$i]['total'] = array(
'width' => $widths['total'],
//'value' => format_number($p['total']) . ' ' . $this->currency_symbol,
'value' => format_number($p['total']),
'border' => 1,
'align' => 'R',
);
}
$tmp_sep = ereg_replace('[^0-9.,]', '', $p['total']);
$len = strlen($tmp_sep);
$separator = substr($tmp_sep, $len - 3, 1);
if ($separator == '.') {
$tmp = (float) ereg_replace('[^0-9.]', '', $p['total']);
}
if ($separator == ',') {
$tmp = (float) ereg_replace('[^0-9,]', '', $p['total']);
}
if ($p['currency_id'] == 'PLN') {
if (isset($total_price_pln)) {
$total_price_pln += $tmp;
} else {
$total_price_pln = $tmp;
}
}
if ($p['currency_id'] == '6336d9a0-ee5f-52e3-7d0c-4e6f1472b2bf') {
if (isset($total_price_eur)) {
$total_price_eur+= $tmp;
} else {
$total_price_eur = $tmp;
}
}
$i++;
}
}
$starttab = $pdf->GetY() + 10;
$pdf->DrawTable($table, array(0));
//EURO
/*
if ($calc['vats_eur']) {
$endtab = $pdf->GetY();
$pdf->SetY($endtab);
$table = array();
$table[] = array(
'fix' => array(
'width' => $widths['fix'],
'value' => '',
'border' => 0,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
),
'subtotal1' => array(
'width' => $widths['subtotal1'],
'value' => $mod_strings['LBL_PDF_TOTAL'],
'background' => array(255, 255, 255),
'border' => 1,
'overflow' => 1,
'align' => 'L',
'font-size' => 9,
),
'subtotal2' => array(
'width' => $widths['subtotal2'],
'value' => $calc['subtotal_eur'] . ' EUR',
'border' => 1,
'overflow' => 1,
'align' => 'R',
'font-size' => 9,
),
);
foreach ($calc['vats_eur'] as $key => $value) {
$r = mysql_fetch_array(mysql_query("select name from ecmvats where id='" . $key . "'"));
$vvn = $r['name'];
$table[] = array(
'fix' => array(
'width' => $widths['fix'],
'value' => '',
'border' => 0,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
),
'subtotal1' => array(
'width' => $widths['subtotal1'],
'value' => $mod_strings['LBL_PDF_VAT'] . ' (' . $vvn . ')',
'background' => array(255, 255, 255),
'border' => 1,
'overflow' => 1,
'align' => 'L',
'font-size' => 9,
),
'subtotal2' => array(
'width' => $widths['subtotal2'],
'value' => $value . ' EUR',
'border' => 1,
'overflow' => 1,
'align' => 'R',
'font-size' => 9,
),
);
}
$table[] = array(
'fix' => array(
'width' => $widths['fix'],
'value' => '',
'border' => 0,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
),
'subtotal1' => array(
'width' => $widths['subtotal1'],
'value' => $mod_strings['LBL_PDF_END_TOTAL'],
'background' => array(233, 233, 233),
'border' => 1,
'overflow' => 1,
'align' => 'L',
'font-size' => 9,
'font-style' => 'b',
),
'subtotal2' => array(
'width' => $widths['subtotal2'],
'value' => $calc['subtotal_eur'] . ' EUR',
'border' => 1,
'background' => array(233, 233, 233),
'overflow' => 1,
'align' => 'R',
'font-size' => 9,
'font-style' => 'b',
),
);
$pdf->Ln(4);
$pdf->DrawTable($table);
}
if ($calc['vats_pln']) {
//PLN
$starttab = $pdf->GetY() + 4;
$pdf->SetY($starttab);
$table = array();
$table[] = array(
'fix' => array(
'width' => $widths['fix'],
'value' => '',
'border' => 0,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
),
'subtotal1' => array(
'width' => $widths['subtotal1'],
'value' => $mod_strings['LBL_PDF_TOTAL'],
'background' => array(255, 255, 255),
'border' => 1,
'overflow' => 1,
'align' => 'L',
'font-size' => 9,
),
'subtotal2' => array(
'width' => $widths['subtotal2'],
'value' => $calc['subtotal_pln'] . ' PLN',
'border' => 1,
'overflow' => 1,
'align' => 'R',
'font-size' => 9,
),
);
foreach ($calc['vats_pln'] as $key => $value) {
$r = mysql_fetch_array(mysql_query("select name from ecmvats where id='" . $key . "'"));
$vvn = $r['name'];
$table[] = array(
'fix' => array(
'width' => $widths['fix'],
'value' => '',
'border' => 0,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
),
'subtotal1' => array(
'width' => $widths['subtotal1'],
'value' => $mod_strings['LBL_PDF_VAT'] . ' (' . $vvn . ')',
'background' => array(255, 255, 255),
'border' => 1,
'overflow' => 1,
'align' => 'L',
'font-size' => 9,
),
'subtotal2' => array(
'width' => $widths['subtotal2'],
'value' => $value . ' PLN',
'border' => 1,
'overflow' => 1,
'align' => 'R',
'font-size' => 9,
),
);
}
$table[] = array(
'fix' => array(
'width' => $widths['fix'],
'value' => '',
'border' => 0,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
),
'subtotal1' => array(
'width' => $widths['subtotal1'],
'value' => $mod_strings['LBL_PDF_END_TOTAL'],
'background' => array(233, 233, 233),
'border' => 1,
'overflow' => 1,
'align' => 'L',
'font-size' => 9,
'font-style' => 'b',
),
'subtotal2' => array(
'width' => $widths['subtotal2'],
'value' => $calc['subtotal_pln'] . ' PLN',
'border' => 1,
'background' => array(233, 233, 233),
'overflow' => 1,
'align' => 'R',
'font-size' => 9,
'font-style' => 'b',
),
);
$pdf->DrawTable($table);
}
*/
if ($calc['vats']) {
$starttab = $pdf->GetY() + 4;
$pdf->SetY($starttab);
$table = array();
$table[] = array(
'fix' => array(
'width' => $widths['fix'],
'value' => '',
'border' => 0,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
),
'subtotal1' => array(
'width' => $widths['subtotal1'],
'value' => $mod_strings['LBL_PDF_TOTAL'],
'background' => array(255, 255, 255),
'border' => 1,
'overflow' => 1,
'align' => 'L',
'font-size' => 9,
),
'subtotal2' => array(
'width' => $widths['subtotal2'],
'value' => $calc['subtotal'] . ' ' . $this->currency_symbol,
'border' => 1,
'overflow' => 1,
'align' => 'R',
'font-size' => 9,
),
);
if ($this->invoice_type!='U') {
foreach ($calc['vats'] as $key => $value) {
$r = mysql_fetch_array(mysql_query("select name from ecmvats where id='" . $key . "'"));
$vvn = $r['name'];
$table[] = array(
'fix' => array(
'width' => $widths['fix'],
'value' => '',
'border' => 0,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
),
'subtotal1' => array(
'width' => $widths['subtotal1'],
'value' => $mod_strings['LBL_PDF_VAT'] . ' (' . $vvn . ')',
'background' => array(255, 255, 255),
'border' => 1,
'overflow' => 1,
'align' => 'L',
'font-size' => 9,
),
'subtotal2' => array(
'width' => $widths['subtotal2'],
'value' => $value . ' ' . $this->currency_symbol,
'border' => 1,
'overflow' => 1,
'align' => 'R',
'font-size' => 9,
),
);
}
$table[] = array(
'fix' => array(
'width' => $widths['fix'],
'value' => '',
'border' => 0,
'overflow' => 1,
'align' => 'C',
'font-style' => 'b',
'font-size' => 7,
),
'subtotal1' => array(
'width' => $widths['subtotal1'],
'value' => $mod_strings['LBL_PDF_END_TOTAL'],
'background' => array(233, 233, 233),
'border' => 1,
'overflow' => 1,
'align' => 'L',
'font-size' => 9,
'font-style' => 'b',
),
'subtotal2' => array(
'width' => $widths['subtotal2'],
'value' => $calc['total'] . ' ' . $this->currency_symbol ,
'border' => 1,
'background' => array(233, 233, 233),
'overflow' => 1,
'align' => 'R',
'font-size' => 9,
'font-style' => 'b',
),
);
}
$pdf->DrawTable($table);
}