45 $this->_iSelectedLang = $iLang;
56 if ($this->_oActShop !== null) {
60 $this->_oActShop =
oxNew(
'oxshop');
61 $this->_oActShop->load($this->getConfig()->getShopId());
88 $oPdf->line(15, 272, 195, 272);
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()));
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));
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));
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);
137 $oPdf->line(15, 52, 195, 52);
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);
164 return 14 + $aSize[1] * 0.2;
173 public function genPdf($sFilename, $iSelLang = 0)
180 if (!$this->oxorder__oxbillnr->value) {
181 $this->oxorder__oxbillnr->setValue($this->getNextBillNum());
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'))));
195 $oPdf =
oxNew(
'oxPDF');
196 $oPdf->setPrintHeader(
false);
215 $oPdf->output($sFilename,
'I');
227 $sSal = $this->oxorder__oxbillsal->value;
229 $sSal = $oLang->translateString($this->oxorder__oxbillsal->value, $this->getSelectedLang());
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());
252 $sSal = $this->oxorder__oxdelsal->value;
254 $sSal = $oLang->translateString($this->oxorder__oxdelsal->value, $this->getSelectedLang());
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());
280 if (!$this->_oArticles) {
281 $this->_oArticles = $this->getOrderArticles(
true);
287 foreach ($this->_oArticles as $key => $oOrderArt) {
290 if ($iStartPos > 243) {
291 $this->pdffooter($oPdf);
292 $iStartPos = $this->pdfheaderplus($oPdf);
293 $oPdf->setFont($oPdfBlock->getFont(),
'', 10);
295 $iStartPos = $iStartPos + 4;
299 $oPdf->text(20 - $oPdf->getStringWidth($oOrderArt->oxorderarticles__oxamount->value), $iStartPos, $oOrderArt->oxorderarticles__oxamount->value);
302 $oPdf->setFont($oPdfBlock->getFont(),
'', 8);
303 $oPdf->text(28, $iStartPos, $oOrderArt->oxorderarticles__oxartnum->value);
306 $oPdf->setFont($oPdfBlock->getFont(),
'', 10);
307 $oPdf->text(45, $iStartPos, substr(strip_tags($this->
_replaceExtendedChars($oOrderArt->oxorderarticles__oxtitle->getRawValue(),
true)), 0, 58));
313 $oPdf->text(140 - $oPdf->getStringWidth($oOrderArt->oxorderarticles__oxvat->value), $iStartPos, $oOrderArt->oxorderarticles__oxvat->value);
317 $dUnitPrice = ($this->isNettoMode()) ? $oOrderArt->oxorderarticles__oxnprice->value : $oOrderArt->oxorderarticles__oxbprice->value;
318 $dTotalPrice = ($this->isNettoMode()) ? $oOrderArt->oxorderarticles__oxnetprice->value : $oOrderArt->oxorderarticles__oxbrutprice->value;
320 $sText = $oLang->formatCurrency($dUnitPrice, $this->_oCur) .
' ' . $this->_oCur->name;
321 $oPdf->text(163 - $oPdf->getStringWidth($sText), $iStartPos, $sText);
324 $sText = $oLang->formatCurrency($dTotalPrice, $this->_oCur) .
' ' . $this->_oCur->name;
325 $oPdf->text(195 - $oPdf->getStringWidth($sText), $iStartPos, $sText);
330 if ($oOrderArt->oxorderarticles__oxselvariant->value) {
331 $iStartPos = $iStartPos + 4;
332 $oPdf->text(45, $iStartPos, substr($oOrderArt->oxorderarticles__oxselvariant->value, 0, 58));
349 $this->_oCur =
$myConfig->getCurrencyObject($this->oxorder__oxcurrency->value);
351 $this->_oCur =
$myConfig->getActShopCurrencyObject();
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());
365 if ($this->oxorder__oxdelsal->value) {
370 $oUser =
oxNew(
'oxuser');
371 $oUser->load($this->oxorder__oxuserid->value);
374 $sText = $this->
translate(
'ORDER_OVERVIEW_PDF_FILLONPAYMENT');
375 $oPdf->setFont($oPdfBlock->getFont(),
'', 5);
376 $oPdf->text(195 - $oPdf->getStringWidth($sText), 55, $sText);
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);
384 if ($this->oxorder__oxdelsal->value) {
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);
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);
405 $sText = $this->
translate(
'ORDER_OVERVIEW_PDF_COUNTNR') .
' ' . $this->oxorder__oxbillnr->value;
406 $oPdf->text(195 - $oPdf->getStringWidth($sText), $iTop + 8, $sText);
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);
414 $oPdf->setFont($oPdfBlock->getFont(),
'', 12);
415 $oPdf->text(15, $iTop, $this->
translate(
'ORDER_OVERVIEW_PDF_PURCHASENR') .
' ' . $this->oxorder__oxordernr->value);
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);
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);
436 $oPdf->line(15, $iTop, 195, $iTop);
440 $oPdf->setFont($oPdfBlock->getFont(),
'', 10);
447 $iHeight = $oArtSumm->generate($siteH);
448 if ($siteH + $iHeight > 258) {
451 $oArtSumm->ajustHeight($iTop - $siteH);
455 $oArtSumm->run($oPdf);
456 $siteH += $iHeight + 8;
458 $oPdf->text(15, $siteH, $this->
translate(
'ORDER_OVERVIEW_PDF_GREETINGS'));
473 $sSal = $this->oxorder__oxdelsal->value;
475 $sSal = $oLang->translateString($this->oxorder__oxdelsal->value, $this->getSelectedLang());
480 $this->_oCur =
$myConfig->getCurrencyObject($this->oxorder__oxcurrency->value);
481 if (!isset($this->_oCur)) {
482 $this->_oCur =
$myConfig->getActShopCurrencyObject();
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());
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());
506 $oUser =
oxNew(
'oxuser');
507 $oUser->load($this->oxorder__oxuserid->value);
510 $sText = $this->
translate(
'ORDER_OVERVIEW_PDF_FILLONPAYMENT');
511 $oPdf->setFont($oPdfBlock->getFont(),
'', 5);
512 $oPdf->text(195 - $oPdf->getStringWidth($sText), 70, $sText);
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);
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);
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);
533 $sText = $this->
translate(
'ORDER_OVERVIEW_PDF_COUNTNR') .
' ' . $this->oxorder__oxbillnr->value;
534 $oPdf->text(195 - $oPdf->getStringWidth($sText), $iTop, $sText);
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);
542 $oPdf->setFont($oPdfBlock->getFont(),
'', 12);
543 $oPdf->text(15, 108, $this->
translate(
'ORDER_OVERVIEW_PDF_DELIVNOTE') .
' ' . $this->oxorder__oxordernr->value);
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);
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'));
558 $oPdf->line(15, 130, 195, 130);
561 $oPdf->setFont($oPdfBlock->getFont(),
'', 10);
568 $oPdf->line(15, $siteH + 2, 195, $siteH + 2);
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);
594 $aReplace = array(chr(169) =>
"©", chr(128) =>
"€",
"\"" =>
""",
"'" =>
"'");
600 if (version_compare(PHP_VERSION,
'5.3.4') >= 0) {
601 $aTransTbl = get_html_translation_table(HTML_ENTITIES, ENT_COMPAT,
'ISO-8859-1');
603 $aTransTbl = get_html_translation_table(HTML_ENTITIES, ENT_COMPAT);
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);
622 return $this->getProductVats(
false);
652 if (null === $iPaymentTerm = $this->getConfig()->getConfigParam(
'iPaymentTerm')) {
656 return $iPaymentTerm;