_image_path = ROOT_DIR.'web/'.SHOP_SYSTEM.'/documents/'; $this->SetMargins(15, 5, 5); $this->total = false; if (Config::has_key('bill_new_page_lines')) { $this->new_page_lines = Config::get_value('bill_new_page_lines'); } if (Config::has_key('bill_invoice_data_y')) { $this->invoice_data_y = Config::get_value('bill_invoice_data_y'); } if (Config::has_key('bill_header_image_x')) { $this->header_image_x = Config::get_value('bill_header_image_x'); } if (Config::has_key('bill_header_image_y')) { $this->header_image_y = Config::get_value('bill_header_image_y'); } if (Config::has_key('bill_footer_image_x')) { $this->footer_image_x = Config::get_value('bill_footer_image_x'); } if (Config::has_key('bill_footer_image_y')) { $this->footer_image_y = Config::get_value('bill_footer_image_y'); } } public function Header() { if (Config::has_key('bill_header_image')) { $header_image = (string)Config::get_value('bill_header_image'); if ($header_image != '') { $this->Image($this->_image_path.$header_image, $this->header_image_x, $this->header_image_y, 200, 0); } } if (Config::has_key('bill_header_text_window')) { $this->SetXY(16, 50); $this->SetFont('', '', 6); $this->Cell(50, 0, Config::get_value('bill_header_text_window'), 0, 0, 'L', 0); } if (Config::has_key('bill_header_text_address')) { $address = Config::get_value('bill_header_text_address'); if (Config::has_key('bill_header_alignment_address')) { $alignment = $this->_getAlignment(Config::get_value('bill_header_alignment_address')); } else { $alignment = 'L'; } $this->SetXY(125, 50); $this->SetFont('', '', 7); $this->MultiCell(70, 20, $address, 0, $alignment); } $this->setTopMargin(60 + 5); } public function Footer() { $this->SetFont('', '', 8); if (Config::has_key('bill_footer_image')) { $footer_image = (string)Config::get_value('bill_footer_image'); if ($footer_image != '') { $this->Image($this->_image_path.$footer_image, $this->footer_image_x, $this->footer_image_y, 200, 0); } } $footer_position_y = -25; if (Config::has_key('bill_footer_text_margin_bottom')) { $footer_position_y = (int)Config::get_value('bill_footer_text_margin_bottom'); } // left if (Config::has_key('bill_footer_text_left')) { $footer_left_text = (string)Config::get_value('bill_footer_text_left'); if ($footer_left_text != '') { if (Config::has_key('bill_footer_alignment_left')) { $alignment = $this->_getAlignment(Config::get_value('bill_footer_alignment_left')); } else { $alignment = 'L'; } $this->SetXY(15, $footer_position_y); $this->MultiCell(67, 20, $footer_left_text, 0, $alignment); } } // center if (Config::has_key('bill_footer_text_center')) { $footer_center_text = (string)Config::get_value('bill_footer_text_center'); if ($footer_center_text != '') { if (Config::has_key('bill_footer_alignment_center')) { $alignment = $this->_getAlignment(Config::get_value('bill_footer_alignment_center')); } else { $alignment = 'L'; } $this->SetXY(70, $footer_position_y); $this->MultiCell(66, 20, $footer_center_text, 0, $alignment); } } // right if (Config::has_key('bill_footer_text_right')) { $footer_right_text = (string)Config::get_value('bill_footer_text_right'); if ($footer_right_text != '') { if (Config::has_key('bill_footer_alignment_right')) { $alignment = $this->_getAlignment(Config::get_value('bill_footer_alignment_right')); } else { $alignment = 'R'; } $this->SetXY(140, $footer_position_y); $this->MultiCell(67, 20, $footer_right_text, 0, $alignment); } } } public function PrintCustomerAddress($data) { $this->SetX(5); $this->SetY(53); $this->SetFont('', '', 10); $this->MultiCell(80,35, $data, 0, 'L'); } public function PrintInvoiceData($data) { $this->SetFont('', '', 10); $key_string = ''; $value_string = ''; foreach ($data as $key => $value) { if ($key_string == '') { $key_string = $key; $value_string = $value; } else { $key_string .= "\n".$key; $value_string .= "\n".$value; } } $this->SetXY(125, $this->invoice_data_y); $this->MultiCell(40, 35, $key_string, 0, 'L'); $this->SetXY(165, $this->invoice_data_y); $this->MultiCell(40, 35, $value_string, 0, 'R'); } private function checkForNewPage($lines = false) { if ($lines && ($this->GetY() + $lines * 3.52778) > $this->new_page_lines) { $this->addPage('', '', true, true); } else if ($this->GetY() > $this->new_page_lines) { $this->addPage('', '', true, true); } } public function PrintInvoiceOrder($data) { $this->SetFont('', 'B', 18); $this->Cell(120, 0, "Rechnung", '', 0, 'L'); $this->Ln(); $this->SetX(5); $this->SetY($this->tMargin + 40); $this->SetFont('', '', 8); // conf header $this->SetFillColor($this->_fill_r, $this->_fill_g, $this->_fill_b); $this->SetTextColor(255); $this->SetDrawColor($this->_border_r, $this->_border_g, $this->_border_b); $this->SetLineWidth($this->_line_width); $this->SetFont('', 'B'); $header_width = array(15, 10, 90, 20, 30, 25); $length = count($header_width); // draw header $this->Cell($header_width[0], 0, 'Pos.', 'LTB', 0, 'C', 1); // Pos. $this->Cell($header_width[1], 0, 'St.', 'TB', 0, 'C', 1); // St. $this->Cell($header_width[2], 0, 'Beschreibung/Art-Nr.', 'TB', 0, 'L', 1); // Art-Nr./Beschreibung if ($data['header']->is_eu_order == 1) { $this->Cell($header_width[3], 0, '', 'TB', 0, 'R', 1); // no mwst .. eu bill } else { $this->Cell($header_width[3], 0, 'MwSt.', 'TB', 0, 'R', 1); // mwst } $this->Cell($header_width[4], 0, $this->_stringCleaner('Stückpreis'), 'TB', 0, 'R', 1); // Stueckpreis $this->Cell($header_width[5], 0, 'Gesamtpreis', 'RTB', 0, 'R', 1); // Gesamtpreis $this->Ln(); // conf data $this->SetFillColor($this->_stripe_r, $this->_stripe_g, $this->_stripe_b); $this->SetTextColor(0); $this->SetFont(''); $fill = 0; // draw data $i = 1; $sum = 0.0; $taxsum = 0.0; foreach ($data['items'] as $row) { $this->checkForNewPage(); // first row $this->SetFont('', '', 8); $this->SetTextColor($this->_text_r, $this->_text_g, $this->_text_b); $this->Cell($header_width[0], 0, $i, 'L', 0, 'C', $fill); // Pos. $this->Cell($header_width[1], 0, $row->amount, 0, 0, 'C', $fill); // St. if (strlen($row->item_name) > 70) { $this->Cell($header_width[2], 0, $this->_stringCleaner(substr($row->item_name,0,71)), 0, 0, 'L', $fill); // Beschreibung $this->Ln(); $this->Cell($header_width[0], 0, '', 'L', 0, 'C', $fill); // Pos. $this->Cell($header_width[1], 0, '', 0, 0, 'C', $fill); // St. $this->Cell($header_width[2], 0, $this->_stringCleaner(substr($row->item_name,70)), 0, 0, 'L', $fill); // Beschreibung } else { $this->Cell($header_width[2], 0, $this->_stringCleaner($row->item_name), 0, 0, 'L', $fill); // Beschreibung } if ($data['header']->is_eu_order == 1) { $this->Cell($header_width[3], 0, '', 0, 0, 'R', $fill); // no mwst .. eu bill } else { $this->Cell($header_width[3], 0, $this->_stringCleaner(number_format($row->tax_rate, 2, ',', ' ').' %'), 0, 0, 'R', $fill); // mwst } $sum += $row->shown_total; $item_taxes = $row->taxes * $row->amount; $taxes[$row->tax_rate] += $item_taxes; $taxsum += $item_taxes; $this->Cell($header_width[4], 0, $this->_stringCleaner(number_format($row->shown_amount, 2, ',', ' ').' €'), 0, 0, 'R', $fill); // Stückpreis $this->Cell($header_width[5], 0, $this->_stringCleaner(number_format($row->shown_total, 2, ',', ' ').' €'), 'R', 0, 'R', $fill); // Gesamtpreis $this->Ln(); // middle row $this->Cell($header_width[0], 0, '', 'L', 0, 'C', $fill); $this->Cell($header_width[1], 0, '', 0, 0, 'R', $fill); $this->Cell($header_width[2], 0, 'Art-Nr.: '.$row->item_number, 0, 0, 'L', $fill); // Art-Nr. $this->Cell($header_width[3], 0, '', 0, 0, 'R', $fill); $this->Cell($header_width[4], 0, '', 0, 0, 'R', $fill); $this->Cell($header_width[5], 0, '', 'R', 0, 'R', $fill); $this->Ln(); // last row if ($row->item_status) { $this->Cell($header_width[0] + $header_width[1], 0, '', 'L', 0, 'C', $fill); $text = ''; if ($row->item_status == 1) { // nicht lieferbar if ($row->item_status_text) { $text = $row->item_status_text; } else { $text = 'nicht lieferbar'; } } else if ($row->item_status == 2) { // nachliefern if ($row->backorder_quantity) { $text .= $row->backorder_quantity; } if ($text == '' && $row->item_status_text) { $text .= $row->item_status_text; } else if ($row->item_status_text) { $text .= ' '.$row->item_status_text; } else { $text .= ' nachliefern'; } if ($row->delivery_date) { if ($text != '') { $date = explode(' ', $row->delivery_date); $text .= ' - '.$date[2].'.'.$date[1].'.'.$date[0]; } } } else if ($row->item_status == 3) { // nachliefern if ($row->backorder_quantity) { $text .= $row->backorder_quantity; } if ($text == '' && $row->item_status_text) { $text .= $row->item_status_text; } else if ($row->item_status_text) { $text .= ' '.$row->item_status_text; } else { $text .= ' info'; } if ($row->delivery_date) { if ($text != '') { $date = explode(' ', $row->delivery_date); $text .= ' - '.$date[2].'.'.$date[1].'.'.$date[0]; } } } $this->Cell($header_width[2] + $header_width[3] + $header_width[4], 0, $this->_stringCleaner($text), 0, 0, 'L', $fill); $this->Cell($header_width[5], 0, '', 'R', 0, 'L', $fill); $this->Ln(); } $fill = !$fill; $i++; } // conf footer $this->SetTextColor(0); $this->SetFont(''); // draw footer // total sum $this->checkForNewPage(); $this->SetFont('', '', 8); $this->SetTextColor($this->_text_r, $this->_text_g, $this->_text_b); $this->Cell(90, 0, '', 'L', 0, 'C', $fill); $this->Cell(40, 0, 'Summe aller Artikel', 0, 0, 'L', $fill); $this->Cell(60, 0, $this->_stringCleaner(number_format($sum, 2, ',', ' ').' €'), 'R', 0, 'R', $fill); $this->Ln(); // payment method cost $this->checkForNewPage(); $fill = !$fill; $this->Cell(90, 0, '', 'L', 0, 'C', $fill); $this->Cell(40, 0, $this->_stringCleaner('Zahlungsgebühren'), 0, 0, 'L', $fill); $method_charges_gross = $data['header']->payment_method_charges; $method_charges_net = $data['header']->payment_method_charges / 119.0 * 100.0; $method_charges_vat = $data['header']->payment_method_charges / 119.0 * 19.0; if ($data['header']->cg_show_taxes) { $this->Cell(60, 0, $this->_stringCleaner(number_format($method_charges_gross, 2, ',', ' ').' €'), 'R', 0, 'R', $fill); } else { $this->Cell(60, 0, $this->_stringCleaner(number_format($method_charges_net, 2, ',', ' ').' €'), 'R', 0, 'R', $fill); } $this->Ln(); // delivery cost $this->checkForNewPage(); $fill = !$fill; $this->SetFont('', '', 8); $this->SetTextColor($this->_text_r, $this->_text_g, $this->_text_b); $this->Cell(90, 0, '', 'L', 0, 'C', $fill); $this->Cell(40, 0, 'Versandkosten', 0, 0, 'L', $fill); $shipping_charges_gross = $data['header']->shipping_charges; $shipping_charges_net = $data['header']->shipping_charges / 119.0 * 100.0; $shipping_charges_vat = $data['header']->shipping_charges / 119.0 * 19.0; if ($data['header']->cg_show_taxes) { $this->Cell(60, 0, $this->_stringCleaner(number_format($shipping_charges_gross, 2, ',', ' ').' €'), 'R', 0, 'R', $fill); } else { $this->Cell(60, 0, $this->_stringCleaner(number_format($shipping_charges_net, 2, ',', ' ').' €'), 'R', 0, 'R', $fill); } $this->Ln(); if ($data['header']->is_eu_order && !$data['header']->cg_show_taxes) { $this->checkForNewPage(); //$subtotal = $sum + $net_shipping_charges + $net_method_charges; $subtotal = $sum + $shipping_charges_net + $method_charges_net; if (isset($data['footer']->gift_certificate_id)) { $subtotal -= $data['footer']->gift_certificate_total; } // TODO: HACK HACK HACK $this->total = $subtotal; $fill = !$fill; $this->SetFont('', '', 8); $this->SetTextColor($this->_text_r, $this->_text_g, $this->_text_b); $this->Cell(90, 0, '', 'L', 0, 'C', $fill); $this->Cell(40, 0, $this->_stringCleaner('Bruttosumme'), 0, 0, 'L', $fill); $this->Cell(60, 0, $this->_stringCleaner(number_format($subtotal, 2, ',', ' ').' €'), 'R', 0, 'R', $fill); $this->Ln(); $this->checkForNewPage(); $fill = !$fill; $this->SetFont('', 'B', 8); $this->Cell(90, 0, '', 'L', 0, 'C', $fill); $this->Cell(40, 0, $this->_stringCleaner('zu zahlender Betrag'), 0, 0, 'L', $fill); $this->Cell(60, 0, $this->_stringCleaner(number_format($subtotal, 2, ',', ' ').' €'), 'R', 0, 'R', $fill); $this->Ln(); // line $this->Cell(array_sum($header_width), 0, '', 'T'); $this->Ln(); } else { if (!$data['footer']->taxes['19.00'] && ($method_charges_vat || $shipping_charges_vat)) { $data['footer']->taxes['19.00'] = 0; } foreach ($data['footer']->taxes as $key => $value) { if ($key == '19.00') { $value += ($method_charges_vat + $shipping_charges_vat); } $this->checkForNewPage(); $fill = !$fill; $this->SetFont('', '', 8); $this->SetTextColor($this->_text_r, $this->_text_g, $this->_text_b); $this->Cell(90, 0, '', 'L', 0, 'C', $fill); if ($data['header']->cg_show_taxes) { $this->Cell(40, 0, $this->_stringCleaner('darin enthaltene Mwst. '.number_format($key, 2, ',', ' ').' %'), 0, 0, 'L', $fill); } else { // richard hack!!! muss geprüft werden! $taxsum .= $value; /*echo "taxsum: $taxsum
value: $value
sum: $sum
"; echo "shipping: ".$data['header']->shipping_charges; echo "
payment: ".$data['header']->payment_method_charges; exit();*/ $this->Cell(40, 0, $this->_stringCleaner('zzgl. '.number_format($key, 2, ',', ' ').' % Mwst.'), 0, 0, 'L', $fill); } $this->Cell(60, 0, $this->_stringCleaner(number_format($value, 2, ',', ' ').' €'), 'R', 0, 'R', $fill); $this->Ln(); } // invoice total fat if ($data['header']->cg_show_taxes) { $total = $sum + $data['header']->shipping_charges + $data['header']->payment_method_charges; } else { // rk update hack!!! //$total = $sum + $shipping_charges_net + $method_charges_net + $taxsum; //$total = $sum + $data['header']->shipping_charges + $data['header']->payment_method_charges + $taxsum; $total = $data['footer']->order_total_with_tax; } // gift certificate if (isset($data['footer']->gift_certificate_id)) { $this->checkForNewPage(); $fill = !$fill; $this->SetFont('', 'B', 8); $this->Cell(90, 0, '', 'L', 0, 'C', $fill); $this->Cell(40, 0, $this->_stringCleaner('Zwischen Betrag'), 0, 0, 'L', $fill); $this->Cell(60, 0, $this->_stringCleaner(number_format($total, 2, ',', ' ').' €'), 'R', 0, 'R', $fill); $this->Ln(); $this->checkForNewPage(); $gift_certificate_text = 'abzgl. Gutschein '.$data['footer']->gift_certificate_code; $fill = !$fill; $this->SetFont('', '', 8); $this->SetTextColor($this->_text_r, $this->_text_g, $this->_text_b); $this->Cell(90, 0, '', 'L', 0, 'C', $fill); $this->Cell(40, 0, $this->_stringCleaner($gift_certificate_text), 0, 0, 'L', $fill); $this->Cell(60, 0, $this->_stringCleaner(number_format(-$data['footer']->gift_certificate_total, 2, ',', ' ').' €'), 'R', 0, 'R', $fill); $this->Ln(); $this->checkForNewPage(); $fill = !$fill; $this->SetFont('', 'B', 8); $this->Cell(90, 0, '', 'L', 0, 'C', $fill); $this->Cell(40, 0, $this->_stringCleaner('zu zahlender Betrag'), 0, 0, 'L', $fill); $this->Cell(60, 0, $this->_stringCleaner(number_format(($total - $data['footer']->gift_certificate_total), 2, ',', ' ').' €'), 'R', 0, 'R', $fill); $this->Ln(); // line $this->Cell(array_sum($header_width), 0, '', 'T'); $this->Ln(); $this->total = $total - $data['footer']->gift_certificate_total; } else { $this->checkForNewPage(); $fill = !$fill; $this->SetFont('', 'B', 8); $this->Cell(90, 0, '', 'L', 0, 'C', $fill); $this->Cell(40, 0, $this->_stringCleaner('zu zahlender Betrag'), 0, 0, 'L', $fill); $this->Cell(60, 0, $this->_stringCleaner(number_format($total, 2, ',', ' ').' €'), 'R', 0, 'R', $fill); $this->Ln(); // line $this->Cell(array_sum($header_width), 0, '', 'T'); $this->Ln(); $this->total = $total; } } } public function PrintEarlyPaymentRebate($rebate) { $earlyPayersRebate = $this->total * $rebate; $text = 'Bei Bezahlung innerhalb von 14 Tagen gewähren wir '. (int)($rebate * 100).' % Skonto ('.number_format(($this->total - $earlyPayersRebate), 2, ',', '.'). ' anstelle von '.number_format(($this->total), 2, ',', '.'). ', eine Ersparnis von '.number_format(($earlyPayersRebate), 2, ',', '.').' €)'; $this->PrintNotice('Zahlungshinweis', $text); } // end PrintEarlyPaymentRebate public function PrintNotice($title, $notice) { $this->checkForNewPage(substr_count($notice, "\n") + 1); $this->SetFillColor($this->_fill_r, $this->_fill_g, $this->_fill_b); $this->SetTextColor(255); $this->SetDrawColor($this->_border_r, $this->_border_g, $this->_border_b); $this->SetLineWidth($this->_line_width); $this->SetFont('', 'B'); $this->Cell(190, 1, $title, 1, 0, 'L', 1); $this->Ln(); $this->SetTextColor(0); $this->SetFont(''); $this->MultiCell(190, 1, $notice, 'LRB', 'L', 0); $this->Ln(4); } protected function _getAlignment($num) { if ($num == 0) { return 'L'; } else if ($num == 1) { return 'C'; } else if ($num == 2) { return 'R'; } return 'C'; } protected function _stringCleaner($sting) { $search = array('€', 'ß', 'ä', 'ö', 'ü', 'Ä', 'Ö', 'Ü'); $replace = array($this->unichr(8364), $this->unichr(223), $this->unichr(228), $this->unichr(246), $this->unichr(252), $this->unichr(196), $this->unichr(214), $this->unichr(220)); return str_replace($search, $replace, $sting); } }