<?php
// packing slip
include_once './core/order.class.php';
include_once './core/customergroups.class.php';

include_once './libs/tcpdf/tcpdf.php';
include_once './core/config.class.php';

class bopPDF extends TCPDF {

	private $order_id = NULL;
	public  $data = array();

	private $_image_path = NULL;

	private $_fill_r = 102;
	private $_fill_g = 102;
	private $_fill_b = 102;

	private $_border_r = 0;
	private $_border_g = 0;
	private $_border_b = 0;

	private $_stripe_r = 249;
	private $_stripe_g = 249;
	private $_stripe_b = 249;

	private $_text_r = 0;
	private $_text_g = 0;
	private $_text_b = 0;

	private $_light_text_r = 128;
	private $_light_text_g = 128;
	private $_light_text_b = 128;

	private $_line_width = 0.2;

	private $fontfamily = 'Arial';

	public function __construct($order_id) {
		$this->order_id=$order_id;
		$this->load();
		$this->writeBOPPDF();
	}

	private function load() {
		$db = Registry::get('base')->db;
		$order = new Order(Registry::get('base'));
		$order->set_id($this->order_id);

		$this->data['order'] = $order->get_data();
		if (sizeof($this->data['order']->items) > 0 ) {
			foreach ($this->data['order']->items As $index => $row) {
				if (sizeof($row->attribute_array) > 0) {
					foreach ($row->attribute_array AS $indece => $att) {

						if ($this->data['order']->items[$index]->variant1 && $att->value && $att->name && $this->data['order']->items[$index]->variant1 == $att->value) {
							$this->data['order']->items[$index]->vn1 = $att->name;
						}

						if ($this->data['order']->items[$index]->variant2 && $att->value && $att->name && $this->data['order']->items[$index]->variant2 == $att->value) {
							$this->data['order']->items[$index]->vn2 = $att->name;
						}
					}
				}
			}
		}

		$sql = "SELECT os.name AS status_bez, d.name AS deliverers, pm.name AS pm, ps.name AS ps, cb.name AS billing_country, cs.name AS shipping_country
				FROM order_status AS os  
				LEFT JOIN deliverers AS d ON(d.id = '".$this->data['order']->shipping_method."')
				LEFT JOIN payment_methods AS pm ON(pm.id = '".$this->data['order']->payment_method."')
				LEFT JOIN payment_status AS ps ON(ps.id = '".$this->data['order']->payment_status."')
				LEFT JOIN countries AS cb ON(cb.id = '".$this->data['order']->billing_country."')
				LEFT JOIN countries AS cs ON(cs.id = '".$this->data['order']->shipping_country."')
				WHERE os.id = '".$this->data['order']->order_status."'";

		$result = $db->query($sql);

		while ($row = $result->fetch_object()) {
			$this->data['order_data']['status_bez']=$row->status_bez;
			$this->data['order_data']['deliverers']=$row->deliverers;
			$this->data['order_data']['pm']=$row->pm;
			$this->data['order_data']['ps']=$row->ps;
			$this->data['order_data']['billing_country']=$row->billing_country;
			$this->data['order_data']['shipping_country']=$row->shipping_country;
		}
		$result->free();

		$this->customer_group_object = new CustomerGroups(Registry::get('base'));
		$this->data['customer_groups'] = $this->customer_group_object->get_by_user($this->data['order']->customer_id);
	}

	private function writeBOPPDF() {
		$this->pdfSettings();

		$this->writeOrderData();
		$this->writeCustomerData();
		$this->writePaymentsData();
		$this->writeBillingData();
		$this->writeBilingAddress();
		$this->writeShippingAddress();
		$this->writeItemData();
		$this->writebopUser();

		$this->getPdf();
	}

	private function pdfSettings() {
		parent::__construct(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
		$this->_image_path = ROOT_DIR.'web/'.SHOP_SYSTEM.'/documents/';
		$this->SetMargins(6, 5, 5);
		$this->startPage();
	}

	public function Header() {}

	public function Footer() {}

	private function writeOrderData() {
		$order_dt = list($y,$m,$d)=explode('-',$this->data['order']->order_date);

		$orderdata = 'Bst. Nr.: '.$this->data['order']->order_number.PHP_EOL;

		if ($this->data['order_data']['status_bez']) {
			$orderdata.= 'Bst. Status: '.$this->data['order_data']['status_bez'].PHP_EOL;
		}

		$orderdata.= 'Bst. Datum: '.$d.'.'.$m.'.'.$y.PHP_EOL;

		$this->SetFont('', '',10);
		$this->MultiCell(40,15, $orderdata, 0, 'L',0,1,5,10);
	}

	private function writeCustomerData() {
		$customerdata = 'Kde. Nr.: '.$this->data['order']->customer_number.PHP_EOL;
		$customerdata.= 'Kde. Name: '.$this->data['order']->customer_name.PHP_EOL;
		if ($this->data['customer_groups']->name) {
			$customerdata.= 'Kde. Gruppe: '.$this->data['customer_groups']->name.PHP_EOL;
		}

		$this->SetFont('', '',10);
		$this->MultiCell(50,20, $customerdata, 0, 'L',0,1,50,10);
	}

	private function writePaymentsData() {
		$paymentdata='';

		if ($this->data['order_data']['pm']) {
			$paymentdata.= 'Zahlungsart: '.$this->data['order_data']['pm'].PHP_EOL;
		}

		if ($this->data['order_data']['ps']) {
			$paymentdata.= 'Zahlungsstatus: '.$this->data['order_data']['ps'].PHP_EOL;
		}

		if ($this->data['order']->payment_date) {
			$pay_dt = list($y,$m,$d)=explode('-',$this->data['order']->payment_date);
			$paymentdata.= 'Zahlungs Datum: '.$d.'.'.$m.'.'.$y.PHP_EOL;
		}
		$this->SetFont('', '',10);
		$this->MultiCell(50,35, $paymentdata, 0, 'L',0,1,105,10);
	}

	private function writeBillingData() {
		$billing_dt = list($y,$m,$d)=explode('-',$this->data['order']->billing_date);

		$billingdata.= 'Rechnungs Datum: '.$d.'.'.$m.'.'.$y.PHP_EOL;
		if ($this->data['order']->invoice_number) {
			$billingdata.= 'Rechnungs Nr.: '.$this->data['order']->invoice_number.PHP_EOL;
		}

		if ($this->data['order_data']['deliverers']) {
			$billingdata.= 'Lieferant.: '.$this->data['order_data']['deliverers'].PHP_EOL;
		}
		if ($this->data['order']->trackingcode) {
			$billingdata.= 'Tracking-Code: '.$this->data['order']->trackingcode.PHP_EOL;
		}

		$this->SetFont('', '',10);
		$this->MultiCell(50,35, $billingdata, 0, 'L',0,1,155,10);
	}

	private function writeBilingAddress() {
		$bill_address='Rechnungsadresse:'.PHP_EOL;

		switch($this->data['order']->billing_honorific) {
			case '0':   $bill_address.="Herr".PHP_EOL; break;
			case '1':   $bill_address.="Frau".PHP_EOL; break;
			case '2':   $bill_address.="Firma".PHP_EOL; break;
		}

		if ($this->data['order']->billing_company) {
			$bill_address.=$this->data['order']->billing_company.PHP_EOL;
		}

		if ($this->data['order']->billing_firstname || $this->data['order']->billing_surname) {
			if ($this->data['order']->billing_firstname) {
				$bill_address.=$this->data['order']->billing_firstname." ";
			}
			if ($this->data['order']->billing_surname) {
				$bill_address.=$this->data['order']->billing_surname;
			}
			$bill_address.=PHP_EOL;
		}

		$bill_address.=$this->data['order']->billing_street.' '.$this->data['order']->billing_house_number.PHP_EOL;
		$bill_address.=$this->data['order']->billing_zip_code.' '.$this->data['order']->billing_city.PHP_EOL;
		$bill_address.=$this->data['order_data']['billing_country'].PHP_EOL;

		$this->SetFont('', '',10);
		$this->MultiCell(80,20, $bill_address, 0, 'L',0,1,5,32);
	}

	private function writeShippingAddress() {
		$ship_address='Lieferadresse:'.PHP_EOL;

		switch($this->data['order']->shipping_honorific) {
			case '0':   $ship_address.="Herr".PHP_EOL; break;
			case '1':   $ship_address.="Frau".PHP_EOL; break;
			case '2':   $ship_address.="Firma".PHP_EOL; break;
		}

		if ($this->data['order']->shipping_company) {
			$ship_address.=$this->data['order']->shipping_company.PHP_EOL;
		}

		if ($this->data['order']->shipping_firstname || $this->data['order']->shipping_surname) {
			if ($this->data['order']->shipping_firstname) {
				$ship_address.=$this->data['order']->shipping_firstname." ";
			}
			if ($this->data['order']->shipping_surname) {
				$ship_address.=$this->data['order']->shipping_surname;
			}
			$ship_address.=PHP_EOL;
		}

		$ship_address.=$this->data['order']->shipping_street.' '.$this->data['order']->shipping_house_number.PHP_EOL;
		$ship_address.=$this->data['order']->shipping_zip_code.' '.$this->data['order']->shipping_city.PHP_EOL;
		$ship_address.=$this->data['order_data']['shipping_country'].PHP_EOL;


		$this->SetFont('', '',10);
		$this->MultiCell(80,20, $ship_address, 0, 'L',0,1,105,32);
	}

	private function writeItemData() {
		if (sizeof($this->data['order']->items) > 0) {

			$this->header_width = array(5, 5, 75, 10, 30, 25, 10, 40);
			$this->writeItemHeader();

			$i = 1;
			$fill = 0;
			foreach ($this->data['order']->items as $row) {
				$this->SetFont('', '', 8);
				$this->SetTextColor($this->_text_r, $this->_text_g, $this->_text_b);
				$this->Cell($this->header_width[0], 0, $i, 'L', 0, 'C', $fill); // Pos.
				$this->Cell($this->header_width[1], 0, $row->amount, 0, 0, 'C', $fill); // St.
				if (strlen($row->item_name) < 50) {
					$this->Cell($this->header_width[2], 0, $this->_stringCleaner($row->item_name), 0, 0, 'L', $fill); // Beschreibung
				} else {
					$this->Cell($this->header_width[2], 0, $this->_stringCleaner(substr($row->item_name,0,50)), 0, 0, 'L', $fill); // Beschreibung
				}

				$this->Cell($this->header_width[3], 0, $this->_stringCleaner(number_format($row->tax_rate, 2, ',', ' ').' %'), 0, 0, 'L', $fill); // mwst

				if ($this->data['customer_groups']->show_tax) {
					$gross_price = $row->price + $row->taxes;
					$gross_total = $row->amount * $gross_price;
					$this->sum += $gross_total;
					$this->taxes[$row->tax_rate] = $this->taxes[$row->tax_rate]+($row->taxes * $row->amount);
					$this->taxsum += $row->taxes * $row->amount;
					$this->Cell($this->header_width[4], 0, $this->_stringCleaner(number_format($gross_price, 2, ',', ' ').' €'), 0, 0, 'R', $fill); // Stückpreis
					$this->Cell($this->header_width[5], 0, $this->_stringCleaner(number_format($gross_total, 2, ',', ' ').' €'), 0, 0, 'R', $fill); // Gesamtpreis
				} else {
					$net_price = $row->price;
					$net_total = $row->amount * $net_price;
					$this->sum += $net_total;
					$this->taxes[$row->tax_rate] = $this->taxes[$row->tax_rate] + ($row->taxes * $row->amount);
					$this->taxsum += $row->taxes * $row->amount;
					$this->Cell($this->header_width[4], 0, $this->_stringCleaner(number_format($net_price, 2, ',', ' ').' €'), 0, 0, 'R', $fill); // Stückpreis
					$this->Cell($this->header_width[5], 0, $this->_stringCleaner(number_format($net_total, 2, ',', ' ').' €'), 0, 0, 'R', $fill); // Gesamtpreis
				}

				$this->Cell($this->header_width[6], 0, '', 'L', 0, 'R', $fill); // Lagerist Anzahl
				$this->Cell($this->header_width[7], 0, '', 'LR', 0, 'R', $fill); // Lagerist Comment
				$this->Ln();

				foreach (array(50, 100, 150, 200) as $i) {
					if (strlen($row->item_name) > $i) {
						$c = $i - 1;
						$this->Cell($this->header_width[0], 0, '', 'L', 0, 'C', $fill);
						$this->Cell($this->header_width[1], 0, '', '', 0, 'R', $fill);
						$this->Cell($this->header_width[2], 0, $this->_stringCleaner(substr($row->item_name,$c, 50)), '', 0, 'L', $fill); // Beschreibung
						$this->Cell($this->header_width[3], 0, '', '', 0, 'R', $fill);
						$this->Cell($this->header_width[4], 0, '', '', 0, 'R', $fill);
						$this->Cell($this->header_width[5], 0, '', '', 0, 'R', $fill);
						$this->Cell($this->header_width[6], 0, '', 'L', 0, 'R', $fill); // Lagerist Anzahl
						$this->Cell($this->header_width[7], 0, '', 'LR', 0, 'R', $fill); // Lagerist Comment
						$this->Ln();
					}
				}
				$this->SetFont('', '', 2);
				$this->Cell($this->header_width[0]+$this->header_width[1]+$this->header_width[2]+$this->header_width[3]+$this->header_width[4]+$this->header_width[5], 0, '', 'LR', 0, 'C', $fill);
				$this->Cell($this->header_width[6], 0, '', 'LR', 0, 'C', $fill);
				$this->Cell($this->header_width[7], 0, '', 'R', 0, 'C', $fill);
				$this->Ln();
				$this->SetFont('', '', 8);

				$artikelnr ="Art-Nr.: ".$row->item_number;
				if ($row->variant1) {
					$artikelnr.=" / ";
					if ($row->vn1) {
						$artikelnr.=$row->vn1.': ';
					} else {
						$artikelnr.='Attr: ';
					}
					$artikelnr.=$row->variant1;
				}
				if ($row->variant2) {
					$artikelnr.=" / ";
					if ($row->vn2) {
						$artikelnr.=$row->vn2.': ';
					} else {
						$artikelnr.='Attr: ';
					}
					$artikelnr.=$row->variant2;
				}



				if ($row->item_status == 2) {
					$this->Cell($this->header_width[0], 0, '', 'L', 0, 'C', $fill);
					$this->Cell($this->header_width[1], 0, '', '', 0, 'R', $fill);
					$this->Cell($this->header_width[2], 0, $artikelnr, '', 0, 'L', $fill); // Art-Nr.
					$this->Cell($this->header_width[3], 0, '', '', 0, 'R', $fill);
					$this->Cell($this->header_width[4], 0, '', '', 0, 'R', $fill);
					$this->Cell($this->header_width[5], 0, '', '', 0, 'R', $fill);
					$this->Cell($this->header_width[6], 0, '', 'L', 0, 'R', $fill); // Lagerist Anzahl
					$this->Cell($this->header_width[7], 0, '', 'LR', 0, 'R', $fill); // Lagerist Comment
					$this->Ln();

					// nachliefern
					$text = $row->amount.' bestellt '.$row->backorder_quantity.' auf nachlieferung';
					$width = 0;
					foreach ($this->header_width as $header_width) {
						$width += $header_width;
					}

					$width  -= ($this->header_width[0] + $this->header_width[1] + $this->header_width[6] + $this->header_width[7]);

					$this->Cell($this->header_width[0], 0, '', 'LB', 0, 'C', $fill);
					$this->Cell($this->header_width[1], 0, '', 'B', 0, 'R', $fill);
					$this->Cell($width, 0, $text, 'BR', 0, 'L', $fill);
					$this->Cell($this->header_width[6], 0, '', 'LB', 0, 'R', $fill); // Lagerist Anzahl
					$this->Cell($this->header_width[7], 0, '', 'LBR', 0, 'R', $fill); // Lagerist Comment
					$this->Ln();
				} else if ($row->item_status == 3) {
					$this->Cell($this->header_width[0], 0, '', 'L', 0, 'C', $fill);
					$this->Cell($this->header_width[1], 0, '', '', 0, 'R', $fill);
					$this->Cell($this->header_width[2], 0, $artikelnr, '', 0, 'L', $fill); // Art-Nr.
					$this->Cell($this->header_width[3], 0, '', '', 0, 'R', $fill);
					$this->Cell($this->header_width[4], 0, '', '', 0, 'R', $fill);
					$this->Cell($this->header_width[5], 0, '', '', 0, 'R', $fill);
					$this->Cell($this->header_width[6], 0, '', 'L', 0, 'R', $fill); // Lagerist Anzahl
					$this->Cell($this->header_width[7], 0, '', 'LR', 0, 'R', $fill); // Lagerist Comment
					$this->Ln();

					// infotext
					$text = $row->amount.' bestellt '.$row->backorder_quantity.' auf nachlieferung';
					$width = 0;
					foreach ($this->header_width as $header_width) {
						$width += $header_width;
					}

					$width  -= ($this->header_width[0] + $this->header_width[1] + $this->header_width[6] + $this->header_width[7]);

					$this->Cell($this->header_width[0], 0, '', 'LB', 0, 'C', $fill);
					$this->Cell($this->header_width[1], 0, '', 'B', 0, 'R', $fill);
					$this->Cell($width, 0, $row->item_status_text, 'BR', 0, 'L', $fill);
					$this->Cell($this->header_width[6], 0, '', 'LB', 0, 'R', $fill); // Lagerist Anzahl
					$this->Cell($this->header_width[7], 0, '', 'LBR', 0, 'R', $fill); // Lagerist Comment
					$this->Ln();




				} else {
					$this->Cell($this->header_width[0], 0, '', 'LB', 0, 'C', $fill);
					$this->Cell($this->header_width[1], 0, '', 'B', 0, 'R', $fill);
					$this->Cell($this->header_width[2], 0, $artikelnr, 'B', 0, 'L', $fill); // Art-Nr.
					$this->Cell($this->header_width[3], 0, '', 'B', 0, 'R', $fill);
					$this->Cell($this->header_width[4], 0, '', 'B', 0, 'R', $fill);
					$this->Cell($this->header_width[5], 0, '', 'B', 0, 'R', $fill);
					$this->Cell($this->header_width[6], 0, '', 'LB', 0, 'R', $fill); // Lagerist Anzahl
					$this->Cell($this->header_width[7], 0, '', 'LBR', 0, 'R', $fill); // Lagerist Comment
					$this->Ln();
				}

				$i++;
			}

			$this->writeItemFooter();
		}
	}

	private function writeItemHeader($header_width = 0) {
		$this->SetY($this->gety()+5);
		$this->SetFont('', 'B', 18);
		$this->Cell(120, 0, "Packschein", '', 0, 'L');
		$this->Ln();

		$this->SetFont('', '', 8);
		$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');

		// draw header
		$this->Cell($this->header_width[0], 0, 'P', 'LTB', 0, 'C', 1); // Pos.
		$this->Cell($this->header_width[1], 0, 'St.', 'TB', 0, 'C', 1); // St.
		$this->Cell($this->header_width[2], 0, 'Beschreibung/Art-Nr.', 'TB', 0, 'L', 1); // Art-Nr./Beschreibung
		$this->Cell($this->header_width[3], 0, 'MwSt.', 'TB', 0, 'L', 1); // 
		$this->Cell($this->header_width[4], 0, 'Stückpreis', 'TB', 0, 'R', 1); // 
		$this->Cell($this->header_width[5], 0, 'Gesamtpreis', 'RTB', 0, 'R', 1); //
		$this->Cell($this->header_width[6], 0, 'St.', 'LTB', 0, 'R', 1); // stückzahl lager
		$this->Cell($this->header_width[7], 0, 'Kommentar', 'LRTB', 0, 'R', 1); // comment
		$this->Ln();
	}

	private function writeItemFooter() {
		$fill = 0;
		$this->SetFont('', '', 8);

		$this->Cell($this->header_width[0]+$this->header_width[1]+$this->header_width[2], 0, '', 'L', 0, 'C', $fill);
		$this->Cell($this->header_width[3]+$this->header_width[4], 0, 'Summe aller Artikel:', 0, 0, 'L', $fill);
		$this->Cell($this->header_width[5], 0, $this->_stringCleaner(number_format($this->sum, 2, ',', ' ').' €'), 'R', 0, 'R', $fill);
		$this->Cell($this->header_width[6]+$this->header_width[7], 0, '', 'R', 0, 'R', $fill); // Lagerist Comment
		$this->Ln();

		$this->Cell($this->header_width[0]+$this->header_width[1]+$this->header_width[2], 0, '', 'L', 0, 'C', $fill);
		$this->Cell($this->header_width[3]+$this->header_width[4], 0, $this->_stringCleaner('Zahlungsgebühren:'), 0, 0, 'L', $fill);
		$this->Cell($this->header_width[5], 0, $this->_stringCleaner(number_format($this->data['order']->payment_method_charges, 2, ',', ' ').' €'), 'R', 0, 'R', $fill);
		$this->Cell($this->header_width[6]+$this->header_width[7], 0, '', 'R', 0, 'R', $fill); // Lagerist Comment
		$this->Ln();

		$this->Cell($this->header_width[0]+$this->header_width[1]+$this->header_width[2], 0, '', 'L', 0, 'C', $fill);
		$this->Cell($this->header_width[3]+$this->header_width[4], 0, 'Versandkosten:', 0, 0, 'L', $fill);
		$this->Cell($this->header_width[5], 0, $this->_stringCleaner(number_format($this->data['order']->shipping_charges, 2, ',', ' ').' €'), 'R', 0, 'R', $fill);
		$this->Cell($this->header_width[6]+$this->header_width[7], 0, '', 'R', 0, 'R', $fill); // Lagerist Comment
		$this->Ln();

		foreach ($this->taxes as $key => $value) {
			$this->Cell($this->header_width[0]+$this->header_width[1]+$this->header_width[2], 0, '', 'L', 0, 'C', $fill);
			if ($this->data['customer_groups']->show_tax) {
				$this->Cell($this->header_width[3]+$this->header_width[4], 0, $this->_stringCleaner('darin enthaltene Mwst.: '.number_format($key, 2, ',', ' ').' %'), 0, 0, 'L', $fill);
			} else {
				$this->Cell($this->header_width[3]+$this->header_width[4], 0, $this->_stringCleaner('zzgl.: '.number_format($key, 2, ',', ' ').' % Mwst.'), 0, 0, 'L', $fill);
			}
			$this->Cell($this->header_width[5], 0, $this->_stringCleaner(number_format($value, 2, ',', ' ').' €'), 'R', 0, 'R', $fill);
			$this->Cell($this->header_width[6]+$this->header_width[7], 0, '', 'R', 0, 'R', $fill); // Lagerist Comment
			$this->Ln();
		}

		// invoice total fat
		if ($this->data['customer_groups']->show_tax) {
			$total = $this->sum + $this->data['order']->shipping_charges + $this->data['order']->payment_method_charges;
		} else {
			$total = $this->sum + $this->data['order']->shipping_charges + $this->data['order']->payment_method_charges + $this->taxsum;
		}

		$this->SetFont('', 'B', 8);
		$this->Cell($this->header_width[0]+$this->header_width[1]+$this->header_width[2], 0, '', 'L', 0, 'C', $fill);
		$this->Cell($this->header_width[3]+$this->header_width[4],0,$this->_stringCleaner('zu zahlender Betrag:'), 0, 0, 'L', $fill);
		$this->Cell($this->header_width[5], 0, $this->_stringCleaner(number_format($total, 2, ',', ' ').' €'), 'R', 0, 'R', $fill);
		$this->Cell($this->header_width[6]+$this->header_width[7], 0, '', 'R', 0, 'R', $fill); // Lagerist Comment
		$this->Ln();

		$this->Cell(array_sum($this->header_width), 0, '', 'T');
		$this->Ln();
	}

	private function writebopUser() {
		$this->SetFont('', '', 10);
		$this->SetY($this->gety()+10);
		$this->Cell(10, 0, '', 0, 0, 'C');
		$this->Cell(80, 0, 'Datum / gepackt von', 'T', 0, 'C');
		$this->Cell(15, 0, '', 0, 0, 'C');
		$this->Cell(80, 0, 'Datum / geprüft von', 'T', 0, 'C');
	}

	protected function _stringCleaner($string) {
		$search = array('€', 'ß', 'ä', 'ö', 'ü', 'Ä', 'Ö', 'Ü');
		$replace = array(TCPDF_FONTS::unichr(8364), TCPDF_FONTS::unichr(223), TCPDF_FONTS::unichr(228), TCPDF_FONTS::unichr(246), TCPDF_FONTS::unichr(252), TCPDF_FONTS::unichr(196), TCPDF_FONTS::unichr(214), TCPDF_FONTS::unichr(220));
		return str_replace($search, $replace, $string);
	}

	private function getPdf() {
		$this->Output('Packschein-'.$this->data['order']->invoice_number.'.pdf', 'D');
	}

}
