OXID eShop CE  4.9.6
 All Classes Files Functions Variables Pages
invoicepdfoxorder.php
Go to the documentation of this file.
1 <?php
2 
7 {
8 
14  protected $_iSelectedLang = 0;
15 
21  protected $_oActShop = null;
22 
28  protected $_aVATs = array();
29 
35  protected $_oCur = null;
36 
37 
43  public function setSelectedLang($iLang)
44  {
45  $this->_iSelectedLang = $iLang;
46  }
47 
53  protected function _getActShop()
54  {
55  // shop is allready loaded
56  if ($this->_oActShop !== null) {
57  return $this->_oActShop;
58  }
59 
60  $this->_oActShop = oxNew('oxshop');
61  $this->_oActShop->load($this->getConfig()->getShopId());
62 
63  return $this->_oActShop;
64  }
65 
73  public function translate($sString)
74  {
75  return oxRegistry::getLang()->translateString($sString, $this->getSelectedLang());
76  }
77 
83  public function pdfFooter($oPdf)
84  {
85 
86  $oShop = $this->_getActShop();
87 
88  $oPdf->line(15, 272, 195, 272);
89 
90  $oPdfBlock = new InvoicepdfBlock();
91  /* column 1 - company name, shop owner info, shop address */
92  $oPdf->setFont($oPdfBlock->getFont(), '', 7);
93  $oPdf->text(15, 275, strip_tags($oShop->oxshops__oxcompany->getRawValue()));
94  $oPdf->text(15, 278, strip_tags($oShop->oxshops__oxfname->getRawValue()) . ' ' . strip_tags($oShop->oxshops__oxlname->getRawValue()));
95  $oPdf->text(15, 281, strip_tags($oShop->oxshops__oxstreet->getRawValue()));
96  $oPdf->text(15, 284, strip_tags($oShop->oxshops__oxzip->value) . ' ' . strip_tags($oShop->oxshops__oxcity->getRawValue()));
97  $oPdf->text(15, 287, strip_tags($oShop->oxshops__oxcountry->getRawValue()));
98 
99  /* column 2 - phone, fax, url, email address */
100  $oPdf->text(85, 275, $this->translate('ORDER_OVERVIEW_PDF_PHONE') . strip_tags($oShop->oxshops__oxtelefon->value));
101  $oPdf->text(85, 278, $this->translate('ORDER_OVERVIEW_PDF_FAX') . strip_tags($oShop->oxshops__oxtelefax->value));
102  $oPdf->text(85, 281, strip_tags($oShop->oxshops__oxurl->value));
103  $oPdf->text(85, 284, strip_tags($oShop->oxshops__oxorderemail->value));
104 
105  /* column 3 - bank information */
106  $oPdf->text(150, 275, strip_tags($oShop->oxshops__oxbankname->getRawValue()));
107  $oPdf->text(150, 278, $this->translate('ORDER_OVERVIEW_PDF_ACCOUNTNR') . strip_tags($oShop->oxshops__oxbanknumber->value));
108  $oPdf->text(150, 281, $this->translate('ORDER_OVERVIEW_PDF_BANKCODE') . strip_tags($oShop->oxshops__oxbankcode->value));
109  $oPdf->text(150, 284, $this->translate('ORDER_OVERVIEW_PDF_VATID') . strip_tags($oShop->oxshops__oxvatnumber->value));
110  $oPdf->text(150, 287, $this->translate('ORDER_OVERVIEW_PDF_TAXID') . strip_tags($oShop->oxshops__oxtaxnumber->value));
111  }
112 
120  public function pdfHeaderPlus($oPdf)
121  {
122 
123  // new page with shop logo
124  $this->pdfHeader($oPdf);
125 
126  $oPdfBlock = new InvoicepdfBlock();
127  // column names
128  $oPdf->setFont($oPdfBlock->getFont(), '', 8);
129  $oPdf->text(15, 50, $this->translate('ORDER_OVERVIEW_PDF_AMOUNT'));
130  $oPdf->text(30, 50, $this->translate('ORDER_OVERVIEW_PDF_ARTID'));
131  $oPdf->text(45, 50, $this->translate('ORDER_OVERVIEW_PDF_DESC'));
132  $oPdf->text(160, 50, $this->translate('ORDER_OVERVIEW_PDF_UNITPRICE'));
133  $sText = $this->translate('ORDER_OVERVIEW_PDF_ALLPRICE');
134  $oPdf->text(195 - $oPdf->getStringWidth($sText), 50, $sText);
135 
136  // line separator
137  $oPdf->line(15, 52, 195, 52);
138 
139  return 56;
140  }
141 
149  public function pdfHeader($oPdf)
150  {
151  // adding new page ...
152  $oPdf->addPage();
153 
154  // loading active shop
155  $oShop = $this->_getActShop();
156 
157  //logo
158  $myConfig = $this->getConfig();
159  $aSize = getimagesize($myConfig->getImageDir() . '/pdf_logo.jpg');
160  $iMargin = 195 - $aSize[0] * 0.2;
161  $oPdf->setLink($oShop->oxshops__oxurl->value);
162  $oPdf->image($myConfig->getImageDir() . '/pdf_logo.jpg', $iMargin, 10, $aSize[0] * 0.2, $aSize[1] * 0.2, '', $oShop->oxshops__oxurl->value);
163 
164  return 14 + $aSize[1] * 0.2;
165  }
166 
173  public function genPdf($sFilename, $iSelLang = 0)
174  {
175  // setting pdf language
176  $this->setSelectedLang($iSelLang);
177 
178  $blIsNewOrder = 0;
179  // setting invoice number
180  if (!$this->oxorder__oxbillnr->value) {
181  $this->oxorder__oxbillnr->setValue($this->getNextBillNum());
182  $blIsNewOrder = 1;
183  }
184  // setting invoice date
185  if ($this->oxorder__oxbilldate->value == '0000-00-00') {
186  $this->oxorder__oxbilldate->setValue(date('Y-m-d', mktime(0, 0, 0, date('m'), date('d'), date('Y'))));
187  $blIsNewOrder = 1;
188  }
189  // saving order if new number or date
190  if ($blIsNewOrder) {
191  $this->save();
192  }
193 
194  // initiating pdf engine
195  $oPdf = oxNew('oxPDF');
196  $oPdf->setPrintHeader(false);
197  $oPdf->open();
198 
199  // adding header
200  $this->pdfHeader($oPdf);
201 
202  // adding info data
203  switch (oxRegistry::getConfig()->getRequestParameter('pdftype')) {
204  case 'dnote':
205  $this->exportDeliveryNote($oPdf);
206  break;
207  default:
208  $this->exportStandart($oPdf);
209  }
210 
211  // adding footer
212  $this->pdfFooter($oPdf);
213 
214  // outputting file to browser
215  $oPdf->output($sFilename, 'I');
216  }
217 
218 
224  protected function _setBillingAddressToPdf($oPdf)
225  {
226  $oLang = oxRegistry::getLang();
227  $sSal = $this->oxorder__oxbillsal->value;
228  try {
229  $sSal = $oLang->translateString($this->oxorder__oxbillsal->value, $this->getSelectedLang());
230  } catch (Exception $e) {
231  }
232  $oPdfBlock = new InvoicepdfBlock();
233  $oPdf->setFont($oPdfBlock->getFont(), '', 10);
234  $oPdf->text(15, 59, $sSal);
235  $oPdf->text(15, 63, $this->oxorder__oxbillfname->getRawValue() . ' ' . $this->oxorder__oxbilllname->getRawValue());
236  $oPdf->text(15, 67, $this->oxorder__oxbillcompany->getRawValue());
237  $oPdf->text(15, 71, $this->oxorder__oxbillstreet->getRawValue() . ' ' . $this->oxorder__oxbillstreetnr->value);
238  $oPdf->setFont($oPdfBlock->getFont(), 'B', 10);
239  $oPdf->text(15, 75, $this->oxorder__oxbillzip->value . ' ' . $this->oxorder__oxbillcity->getRawValue());
240  $oPdf->setFont($oPdfBlock->getFont(), '', 10);
241  $oPdf->text(15, 79, $this->oxorder__oxbillcountry->getRawValue());
242  }
243 
249  protected function _setDeliveryAddressToPdf($oPdf)
250  {
251  $oLang = oxRegistry::getLang();
252  $sSal = $this->oxorder__oxdelsal->value;
253  try {
254  $sSal = $oLang->translateString($this->oxorder__oxdelsal->value, $this->getSelectedLang());
255  } catch (Exception $e) {
256  }
257  $oPdfBlock = new InvoicepdfBlock();
258  $oPdf->setFont($oPdfBlock->getFont(), '', 6);
259  $oPdf->text(15, 87, $this->translate('ORDER_OVERVIEW_PDF_DELIVERYADDRESS'));
260  $oPdf->setFont($oPdfBlock->getFont(), '', 10);
261  $oPdf->text(15, 91, $sSal);
262  $oPdf->text(15, 95, $this->oxorder__oxdellname->getRawValue() . ' ' . $this->oxorder__oxdelfname->getRawValue());
263  $oPdf->text(15, 99, $this->oxorder__oxdelcompany->getRawValue());
264  $oPdf->text(15, 103, $this->oxorder__oxdelstreet->getRawValue() . ' ' . $this->oxorder__oxdelstreetnr->value);
265  $oPdf->setFont($oPdfBlock->getFont(), 'B', 10);
266  $oPdf->text(15, 107, $this->oxorder__oxdelzip->value . ' ' . $this->oxorder__oxdelcity->getRawValue());
267  $oPdf->setFont($oPdfBlock->getFont(), '', 10);
268  $oPdf->text(15, 111, $this->oxorder__oxdelcountry->getRawValue());
269  }
270 
278  protected function _setOrderArticlesToPdf($oPdf, &$iStartPos, $blShowPrice = true)
279  {
280  if (!$this->_oArticles) {
281  $this->_oArticles = $this->getOrderArticles(true);
282  }
283 
284  $oCurr = $this->getCurrency();
285  $oPdfBlock = new InvoicepdfBlock();
286  // product list
287  foreach ($this->_oArticles as $key => $oOrderArt) {
288 
289  // starting a new page ...
290  if ($iStartPos > 243) {
291  $this->pdffooter($oPdf);
292  $iStartPos = $this->pdfheaderplus($oPdf);
293  $oPdf->setFont($oPdfBlock->getFont(), '', 10);
294  } else {
295  $iStartPos = $iStartPos + 4;
296  }
297 
298  // sold amount
299  $oPdf->text(20 - $oPdf->getStringWidth($oOrderArt->oxorderarticles__oxamount->value), $iStartPos, $oOrderArt->oxorderarticles__oxamount->value);
300 
301  // product number
302  $oPdf->setFont($oPdfBlock->getFont(), '', 8);
303  $oPdf->text(28, $iStartPos, $oOrderArt->oxorderarticles__oxartnum->value);
304 
305  // product title
306  $oPdf->setFont($oPdfBlock->getFont(), '', 10);
307  $oPdf->text(45, $iStartPos, substr(strip_tags($this->_replaceExtendedChars($oOrderArt->oxorderarticles__oxtitle->getRawValue(), true)), 0, 58));
308 
309  if ($blShowPrice) {
310  $oLang = oxRegistry::getLang();
311 
312  // product VAT percent
313  $oPdf->text(140 - $oPdf->getStringWidth($oOrderArt->oxorderarticles__oxvat->value), $iStartPos, $oOrderArt->oxorderarticles__oxvat->value);
314 
315  // product price
316 
317  $dUnitPrice = ($this->isNettoMode()) ? $oOrderArt->oxorderarticles__oxnprice->value : $oOrderArt->oxorderarticles__oxbprice->value;
318  $dTotalPrice = ($this->isNettoMode()) ? $oOrderArt->oxorderarticles__oxnetprice->value : $oOrderArt->oxorderarticles__oxbrutprice->value;
319 
320  $sText = $oLang->formatCurrency($dUnitPrice, $this->_oCur) . ' ' . $this->_oCur->name;
321  $oPdf->text(163 - $oPdf->getStringWidth($sText), $iStartPos, $sText);
322 
323  // total product price
324  $sText = $oLang->formatCurrency($dTotalPrice, $this->_oCur) . ' ' . $this->_oCur->name;
325  $oPdf->text(195 - $oPdf->getStringWidth($sText), $iStartPos, $sText);
326 
327  }
328 
329  // additional variant info
330  if ($oOrderArt->oxorderarticles__oxselvariant->value) {
331  $iStartPos = $iStartPos + 4;
332  $oPdf->text(45, $iStartPos, substr($oOrderArt->oxorderarticles__oxselvariant->value, 0, 58));
333  }
334 
335  }
336  }
337 
343  public function exportStandart($oPdf)
344  {
345  // preparing order curency info
346  $myConfig = $this->getConfig();
347  $oPdfBlock = new InvoicepdfBlock();
348 
349  $this->_oCur = $myConfig->getCurrencyObject($this->oxorder__oxcurrency->value);
350  if (!$this->_oCur) {
351  $this->_oCur = $myConfig->getActShopCurrencyObject();
352  }
353 
354  // loading active shop
355  $oShop = $this->_getActShop();
356 
357  // shop information
358  $oPdf->setFont($oPdfBlock->getFont(), '', 6);
359  $oPdf->text(15, 55, $oShop->oxshops__oxname->getRawValue() . ' - ' . $oShop->oxshops__oxstreet->getRawValue() . ' - ' . $oShop->oxshops__oxzip->value . ' - ' . $oShop->oxshops__oxcity->getRawValue());
360 
361  // billing address
362  $this->_setBillingAddressToPdf($oPdf);
363 
364  // delivery address
365  if ($this->oxorder__oxdelsal->value) {
366  $this->_setDeliveryAddressToPdf($oPdf);
367  }
368 
369  // loading user
370  $oUser = oxNew('oxuser');
371  $oUser->load($this->oxorder__oxuserid->value);
372 
373  // user info
374  $sText = $this->translate('ORDER_OVERVIEW_PDF_FILLONPAYMENT');
375  $oPdf->setFont($oPdfBlock->getFont(), '', 5);
376  $oPdf->text(195 - $oPdf->getStringWidth($sText), 55, $sText);
377 
378  // customer number
379  $sCustNr = $this->translate('ORDER_OVERVIEW_PDF_CUSTNR') . ' ' . $oUser->oxuser__oxcustnr->value;
380  $oPdf->setFont($oPdfBlock->getFont(), '', 7);
381  $oPdf->text(195 - $oPdf->getStringWidth($sCustNr), 59, $sCustNr);
382 
383  // setting position if delivery address is used
384  if ($this->oxorder__oxdelsal->value) {
385  $iTop = 115;
386  } else {
387  $iTop = 91;
388  }
389 
390  // shop city
391  $sText = $oShop->oxshops__oxcity->getRawValue() . ', ' . date('d.m.Y', strtotime($this->oxorder__oxbilldate->value));
392  $oPdf->setFont($oPdfBlock->getFont(), '', 10);
393  $oPdf->text(195 - $oPdf->getStringWidth($sText), $iTop + 8, $sText);
394 
395  // shop VAT number
396  if ($oShop->oxshops__oxvatnumber->value) {
397  $sText = $this->translate('ORDER_OVERVIEW_PDF_TAXIDNR') . ' ' . $oShop->oxshops__oxvatnumber->value;
398  $oPdf->text(195 - $oPdf->getStringWidth($sText), $iTop + 12, $sText);
399  $iTop += 8;
400  } else {
401  $iTop += 4;
402  }
403 
404  // invoice number
405  $sText = $this->translate('ORDER_OVERVIEW_PDF_COUNTNR') . ' ' . $this->oxorder__oxbillnr->value;
406  $oPdf->text(195 - $oPdf->getStringWidth($sText), $iTop + 8, $sText);
407 
408  // marking if order is canceled
409  if ($this->oxorder__oxstorno->value == 1) {
410  $this->oxorder__oxordernr->setValue($this->oxorder__oxordernr->getRawValue() . ' ' . $this->translate('ORDER_OVERVIEW_PDF_STORNO'), oxField::T_RAW);
411  }
412 
413  // order number
414  $oPdf->setFont($oPdfBlock->getFont(), '', 12);
415  $oPdf->text(15, $iTop, $this->translate('ORDER_OVERVIEW_PDF_PURCHASENR') . ' ' . $this->oxorder__oxordernr->value);
416 
417  // order date
418  $oPdf->setFont($oPdfBlock->getFont(), '', 10);
419  $aOrderDate = explode(' ', $this->oxorder__oxorderdate->value);
420  $sOrderDate = oxRegistry::get("oxUtilsDate")->formatDBDate($aOrderDate[0]);
421  $oPdf->text(15, $iTop + 8, $this->translate('ORDER_OVERVIEW_PDF_ORDERSFROM') . $sOrderDate . $this->translate('ORDER_OVERVIEW_PDF_ORDERSAT') . $oShop->oxshops__oxurl->value);
422  $iTop += 16;
423 
424  // product info header
425  $oPdf->setFont($oPdfBlock->getFont(), '', 8);
426  $oPdf->text(15, $iTop, $this->translate('ORDER_OVERVIEW_PDF_AMOUNT'));
427  $oPdf->text(30, $iTop, $this->translate('ORDER_OVERVIEW_PDF_ARTID'));
428  $oPdf->text(45, $iTop, $this->translate('ORDER_OVERVIEW_PDF_DESC'));
429  $oPdf->text(135, $iTop, $this->translate('ORDER_OVERVIEW_PDF_VAT'));
430  $oPdf->text(148, $iTop, $this->translate('ORDER_OVERVIEW_PDF_UNITPRICE'));
431  $sText = $this->translate('ORDER_OVERVIEW_PDF_ALLPRICE');
432  $oPdf->text(195 - $oPdf->getStringWidth($sText), $iTop, $sText);
433 
434  // separator line
435  $iTop += 2;
436  $oPdf->line(15, $iTop, 195, $iTop);
437 
438  // #345
439  $siteH = $iTop;
440  $oPdf->setFont($oPdfBlock->getFont(), '', 10);
441 
442  // order articles
443  $this->_setOrderArticlesToPdf($oPdf, $siteH, true);
444 
445  // generating pdf file
446  $oArtSumm = new InvoicepdfArticleSummary($this, $oPdf);
447  $iHeight = $oArtSumm->generate($siteH);
448  if ($siteH + $iHeight > 258) {
449  $this->pdfFooter($oPdf);
450  $iTop = $this->pdfHeader($oPdf);
451  $oArtSumm->ajustHeight($iTop - $siteH);
452  $siteH = $iTop;
453  }
454 
455  $oArtSumm->run($oPdf);
456  $siteH += $iHeight + 8;
457 
458  $oPdf->text(15, $siteH, $this->translate('ORDER_OVERVIEW_PDF_GREETINGS'));
459  }
460 
466  public function exportDeliveryNote($oPdf)
467  {
468  $myConfig = $this->getConfig();
469  $oShop = $this->_getActShop();
470  $oPdfBlock = new InvoicepdfBlock();
471 
472  $oLang = oxRegistry::getLang();
473  $sSal = $this->oxorder__oxdelsal->value;
474  try {
475  $sSal = $oLang->translateString($this->oxorder__oxdelsal->value, $this->getSelectedLang());
476  } catch (Exception $e) {
477  }
478 
479  // loading order currency info
480  $this->_oCur = $myConfig->getCurrencyObject($this->oxorder__oxcurrency->value);
481  if (!isset($this->_oCur)) {
482  $this->_oCur = $myConfig->getActShopCurrencyObject();
483  }
484 
485  // shop info
486  $oPdf->setFont($oPdfBlock->getFont(), '', 6);
487  $oPdf->text(15, 55, $oShop->oxshops__oxname->getRawValue() . ' - ' . $oShop->oxshops__oxstreet->getRawValue() . ' - ' . $oShop->oxshops__oxzip->value . ' - ' . $oShop->oxshops__oxcity->getRawValue());
488 
489  // delivery address
490  $oPdf->setFont($oPdfBlock->getFont(), '', 10);
491  if ($this->oxorder__oxdelsal->value) {
492  $oPdf->text(15, 59, $sSal);
493  $oPdf->text(15, 63, $this->oxorder__oxdellname->getRawValue() . ' ' . $this->oxorder__oxdelfname->getRawValue());
494  $oPdf->text(15, 67, $this->oxorder__oxdelcompany->getRawValue());
495  $oPdf->text(15, 71, $this->oxorder__oxdelstreet->getRawValue() . ' ' . $this->oxorder__oxdelstreetnr->value);
496  $oPdf->setFont($oPdfBlock->getFont(), 'B', 10);
497  $oPdf->text(15, 75, $this->oxorder__oxdelzip->value . ' ' . $this->oxorder__oxdelcity->getRawValue());
498  $oPdf->setFont($oPdfBlock->getFont(), '', 10);
499  $oPdf->text(15, 79, $this->oxorder__oxdelcountry->getRawValue());
500  } else {
501  // no delivery address - billing address is used for delivery
502  $this->_setBillingAddressToPdf($oPdf);
503  }
504 
505  // loading user info
506  $oUser = oxNew('oxuser');
507  $oUser->load($this->oxorder__oxuserid->value);
508 
509  // user info
510  $sText = $this->translate('ORDER_OVERVIEW_PDF_FILLONPAYMENT');
511  $oPdf->setFont($oPdfBlock->getFont(), '', 5);
512  $oPdf->text(195 - $oPdf->getStringWidth($sText), 70, $sText);
513 
514  // customer number
515  $sCustNr = $this->translate('ORDER_OVERVIEW_PDF_CUSTNR') . ' ' . $oUser->oxuser__oxcustnr->value;
516  $oPdf->setFont($oPdfBlock->getFont(), '', 7);
517  $oPdf->text(195 - $oPdf->getStringWidth($sCustNr), 73, $sCustNr);
518 
519  // shops city
520  $sText = $oShop->oxshops__oxcity->getRawValue() . ', ' . date('d.m.Y');
521  $oPdf->setFont($oPdfBlock->getFont(), '', 10);
522  $oPdf->text(195 - $oPdf->getStringWidth($sText), 95, $sText);
523 
524  $iTop = 99;
525  // shop VAT number
526  if ($oShop->oxshops__oxvatnumber->value) {
527  $sText = $this->translate('ORDER_OVERVIEW_PDF_TAXIDNR') . ' ' . $oShop->oxshops__oxvatnumber->value;
528  $oPdf->text(195 - $oPdf->getStringWidth($sText), $iTop, $sText);
529  $iTop += 4;
530  }
531 
532  // invoice number
533  $sText = $this->translate('ORDER_OVERVIEW_PDF_COUNTNR') . ' ' . $this->oxorder__oxbillnr->value;
534  $oPdf->text(195 - $oPdf->getStringWidth($sText), $iTop, $sText);
535 
536  // canceled order marker
537  if ($this->oxorder__oxstorno->value == 1) {
538  $this->oxorder__oxordernr->setValue($this->oxorder__oxordernr->getRawValue() . ' ' . $this->translate('ORDER_OVERVIEW_PDF_STORNO'), oxField::T_RAW);
539  }
540 
541  // order number
542  $oPdf->setFont($oPdfBlock->getFont(), '', 12);
543  $oPdf->text(15, 108, $this->translate('ORDER_OVERVIEW_PDF_DELIVNOTE') . ' ' . $this->oxorder__oxordernr->value);
544 
545  // order date
546  $aOrderDate = explode(' ', $this->oxorder__oxorderdate->value);
547  $sOrderDate = oxRegistry::get("oxUtilsDate")->formatDBDate($aOrderDate[0]);
548  $oPdf->setFont($oPdfBlock->getFont(), '', 10);
549  $oPdf->text(15, 119, $this->translate('ORDER_OVERVIEW_PDF_ORDERSFROM') . $sOrderDate . $this->translate('ORDER_OVERVIEW_PDF_ORDERSAT') . $oShop->oxshops__oxurl->value);
550 
551  // product info header
552  $oPdf->setFont($oPdfBlock->getFont(), '', 8);
553  $oPdf->text(15, 128, $this->translate('ORDER_OVERVIEW_PDF_AMOUNT'));
554  $oPdf->text(30, 128, $this->translate('ORDER_OVERVIEW_PDF_ARTID'));
555  $oPdf->text(45, 128, $this->translate('ORDER_OVERVIEW_PDF_DESC'));
556 
557  // line separator
558  $oPdf->line(15, 130, 195, 130);
559 
560  // product list
561  $oPdf->setFont($oPdfBlock->getFont(), '', 10);
562  $siteH = 130;
563 
564  // order articles
565  $this->_setOrderArticlesToPdf($oPdf, $siteH, false);
566 
567  // sine separator
568  $oPdf->line(15, $siteH + 2, 195, $siteH + 2);
569  $siteH += 4;
570 
571  // payment date
572  $oPdf->setFont($oPdfBlock->getFont(), '', 10);
573  $text = $this->translate('ORDER_OVERVIEW_PDF_PAYUPTO') . date('d.m.Y', strtotime('+' . $this->getPaymentTerm() . ' day', strtotime($this->oxorder__oxbilldate->value)));
574  $oPdf->text(15, $siteH + 4, $text);
575  }
576 
586  protected function _replaceExtendedChars($sValue, $blReverse = false)
587  {
588  // we need to replace this for compatibility with XHTML
589  // as this function causes a lot of trouble with editor
590  // we switch it off, even if this means that fields do not validate through xhtml
591  // return $sValue;
592 
593  // we need to replace this for compatibility with XHTML
594  $aReplace = array(chr(169) => "&copy;", chr(128) => "&euro;", "\"" => "&quot;", "'" => "&#039;");
595 
596  // #899C reverse html entities and references transformation is used in invoicepdf module
597  // so this part must be enabled. Now it works with html references like &#123;
598  if ($blReverse) {
599  // replace now
600  if (version_compare(PHP_VERSION, '5.3.4') >= 0) {
601  $aTransTbl = get_html_translation_table(HTML_ENTITIES, ENT_COMPAT, 'ISO-8859-1');
602  } else {
603  $aTransTbl = get_html_translation_table(HTML_ENTITIES, ENT_COMPAT);
604  }
605 
606  $aTransTbl = array_flip($aTransTbl) + array_flip($aReplace);
607  $sValue = strtr($sValue, $aTransTbl);
608  $sValue = getStr()->preg_replace_callback('/\&\#([0-9]+)\;/m', create_function('$matches', "return chr(\$matches[1]);") , $sValue);
609  }
610 
611  return $sValue;
612  }
613 
619  public function getVats()
620  {
621  // for older orders
622  return $this->getProductVats(false);
623  }
624 
630  public function getCurrency()
631  {
632  return $this->_oCur;
633  }
634 
640  public function getSelectedLang()
641  {
642  return $this->_iSelectedLang;
643  }
644 
650  public function getPaymentTerm()
651  {
652  if (null === $iPaymentTerm = $this->getConfig()->getConfigParam('iPaymentTerm')) {
653  $iPaymentTerm = 7;
654  }
655 
656  return $iPaymentTerm;
657  }
658 }