00001 <?php
00002
00006 class PdfBlock
00007 {
00008
00013 protected $_aCache = array();
00014
00023 protected function _toCache( $sFunc, $aParams )
00024 {
00025 $oItem = new stdClass();
00026 $oItem->sFunc = $sFunc;
00027 $oItem->aParams = $aParams;
00028 $this->_aCache[] = $oItem;
00029 }
00030
00038 public function run( $oPdf )
00039 {
00040 foreach ( $this->_aCache as $oItem ) {
00041 $sFn = $oItem->sFunc;
00042 switch ( count( $oItem->aParams ) ) {
00043 case 0:
00044 $oPdf->$sFn();
00045 break;
00046 case 1:
00047 $oPdf->$sFn( $oItem->aParams[0]);
00048 break;
00049 case 2:
00050 $oPdf->$sFn( $oItem->aParams[0], $oItem->aParams[1] );
00051 break;
00052 case 3:
00053 $oPdf->$sFn( $oItem->aParams[0], $oItem->aParams[1], $oItem->aParams[2]);
00054 break;
00055 case 4:
00056 $oPdf->$sFn( $oItem->aParams[0], $oItem->aParams[1], $oItem->aParams[2], $oItem->aParams[3]);
00057 break;
00058 }
00059 }
00060 }
00061
00072 public function line( $iLPos, $iLHeight, $iRPos, $iRHeight )
00073 {
00074 $this->_toCache( 'Line', array( $iLPos, $iLHeight, $iRPos, $iRHeight ) );
00075 }
00076
00086 public function text( $iLPos, $iLHeight, $sString )
00087 {
00088 $this->_toCache( 'Text', array( $iLPos, $iLHeight, $sString ) );
00089 }
00090
00100 public function font( $sType, $sWeight, $sSize )
00101 {
00102 $this->_toCache( 'SetFont', array( $sType, $sWeight, $sSize ) );
00103 }
00104
00112 public function ajustHeight( $iDelta )
00113 {
00114 foreach ( $this->_aCache as $key => $oItem ) {
00115 switch ( $oItem->sFunc ) {
00116 case 'Line':
00117 $this->_aCache[$key]->aParams[3] += $iDelta;
00118 $this->_aCache[$key]->aParams[1] += $iDelta;
00119 break;
00120 case 'Text':
00121 $this->_aCache[$key]->aParams[1] += $iDelta;
00122 break;
00123 default:;
00124 }
00125 }
00126 }
00127 }
00128
00132 class PdfArticleSummary extends PdfBlock
00133 {
00134
00139 protected $_oData = null;
00140
00145 protected $_oPdf = null;
00146
00155 public function __construct( $oData, $oPdf )
00156 {
00157 $this->_oData = $oData;
00158 $this->_oPdf = $oPdf;
00159 }
00160
00168 protected function _setTotalCostsWithoutDiscount( &$iStartPos )
00169 {
00170
00171 $this->line( 15, $iStartPos + 1, 195, $iStartPos + 1 );
00172 $sNetSum = oxLang::getInstance()->formatCurrency( $this->_oData->oxorder__oxtotalnetsum->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00173 $this->text( 45, $iStartPos + 4, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLPRICENETTO' ) );
00174 $this->text( 195 - $this->_oPdf->getStringWidth( $sNetSum ), $iStartPos + 4, $sNetSum );
00175
00176
00177 $iCtr = 0;
00178 foreach ( $this->_oData->getVats() as $iVATPercent => $dVATValue ) {
00179 $iStartPos += 4 * $iCtr;
00180 $sVATSum = oxLang::getInstance()->formatCurrency( $dVATValue * $this->_oData->getCurrency()->rate, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00181 $this->text( 45, $iStartPos + 8, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ).$iVATPercent.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_PERCENTSUM' ) );
00182 $this->text( 195 - $this->_oPdf->getStringWidth( $sVATSum ), $iStartPos + 8, $sVATSum );
00183 $iCtr++;
00184 }
00185
00186
00187 $sBrutPrice = oxLang::getInstance()->formatCurrency( $this->_oData->oxorder__oxtotalbrutsum->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00188 $this->text( 45, $iStartPos + 12, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLPRICEBRUTTO' ) );
00189 $this->text( 195 - $this->_oPdf->getStringWidth( $sBrutPrice ), $iStartPos + 12, $sBrutPrice );
00190 $iStartPos++;
00191
00192
00193 $this->line( 45, $iStartPos + 13, 195, $iStartPos + 13 );
00194 $iStartPos += 5;
00195 }
00196
00204 protected function _setTotalCostsWithDiscount( &$iStartPos )
00205 {
00206
00207 $this->line( 15, $iStartPos + 1, 195, $iStartPos + 1 );
00208
00209
00210 $sBrutPrice = oxLang::getInstance()->formatCurrency( $this->_oData->oxorder__oxtotalbrutsum->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00211 $this->text( 45, $iStartPos + 4, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLPRICEBRUTTO' ) );
00212 $this->text( 195 - $this->_oPdf->getStringWidth( $sBrutPrice ), $iStartPos + 4, $sBrutPrice );
00213
00214
00215 $this->line( 45, $iStartPos + 5, 195, $iStartPos + 5 );
00216
00217
00218 $dDiscountVal = $this->_oData->oxorder__oxdiscount->value;
00219 if ( $dDiscountVal > 0 ) {
00220 $dDiscountVal *= -1;
00221 }
00222 $sDiscount = oxLang::getInstance()->formatCurrency( $dDiscountVal, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00223 $this->text( 45, $iStartPos + 8, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_DISCOUNT' ) );
00224 $this->text( 195 - $this->_oPdf->getStringWidth( $sDiscount ), $iStartPos + 8, $sDiscount );
00225 $iStartPos++;
00226
00227
00228 $this->line( 45, $iStartPos + 8, 195, $iStartPos + 8 );
00229 $iStartPos += 4;
00230
00231
00232 $sNetSum = oxLang::getInstance()->formatCurrency( $this->_oData->oxorder__oxtotalnetsum->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00233 $this->text( 45, $iStartPos + 8, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLPRICENETTO' ) );
00234 $this->text( 195 - $this->_oPdf->getStringWidth( $sNetSum ), $iStartPos + 8, $sNetSum );
00235
00236
00237 $iCtr = 0;
00238 foreach ( $this->_oData->getVats() as $iVATPercent => $dVATValue ) {
00239 $iStartPos += 4 * $iCtr;
00240 $sVATSum = oxLang::getInstance()->formatCurrency( $dVATValue * $this->_oData->getCurrency()->rate, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00241 $this->text( 45, $iStartPos + 12, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ).$iVATPercent.$this->_oData->translate('ORDER_OVERVIEW_PDF_PERCENTSUM' ) );
00242 $this->text( 195 - $this->_oPdf->getStringWidth( $sVATSum ), $iStartPos + 12, $sVATSum );
00243 $iCtr++;
00244 }
00245 $iStartPos += 4;
00246 }
00247
00255 protected function _setVoucherInfo( &$iStartPos )
00256 {
00257 $dVoucher = 0;
00258 if ( $this->_oData->oxorder__oxvoucherdiscount->value ) {
00259 $dDiscountVal = $this->_oData->oxorder__oxvoucherdiscount->value;
00260 if ( $dDiscountVal > 0 ) {
00261 $dDiscountVal *= -1;
00262 }
00263 $sPayCost = oxLang::getInstance()->formatCurrency( $dDiscountVal, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00264 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_VOUCHER' ) );
00265 $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCost ), $iStartPos, $sPayCost );
00266 $iStartPos += 4;
00267 }
00268
00269 $iStartPos++;
00270 }
00271
00279 protected function _setDeliveryInfo( &$iStartPos )
00280 {
00281 $sAddString = '';
00282 if ( $this->_oData->oxorder__oxdelvat->value ) {
00283
00284
00285 $sDelCostNetto = oxLang::getInstance()->formatCurrency( $this->_oData->getOrderDeliveryPrice()->getNettoPrice(), $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00286 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_SHIPCOST' ).' '.$this->_oData->translate('ORDER_OVERVIEW_PDF_NETTO' ) );
00287 $this->text( 195 - $this->_oPdf->getStringWidth( $sDelCostNetto ), $iStartPos, $sDelCostNetto );
00288 $iStartPos += 4;
00289
00290
00291 $sDelCostVAT = oxLang::getInstance()->formatCurrency( $this->_oData->getOrderDeliveryPrice()->getVATValue(), $this->_oData->getCurrency()).' '.$this->_oData->getCurrency()->name;
00292 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ).$this->_oData->oxorder__oxdelvat->value.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_PERCENTSUM' ) );
00293 $this->text( 195 - $this->_oPdf->getStringWidth( $sDelCostVAT ), $iStartPos, $sDelCostVAT );
00294 $iStartPos += 4;
00295
00296 $sAddString = ' '.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_BRUTTO' );
00297
00298
00299 $this->line( 45, $iStartPos - 3, 195, $iStartPos - 3 );
00300 $iStartPos++;
00301 }
00302
00303
00304
00305
00306 if ( $this->_oData->oxorder__oxstorno->value ) {
00307 $this->_oData->oxorder__oxdelcost->setValue(0);
00308 }
00309
00310 $sDelCost = oxLang::getInstance()->formatCurrency( $this->_oData->oxorder__oxdelcost->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00311 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_SHIPCOST' ).$sAddString );
00312 $this->text( 195 - $this->_oPdf->getStringWidth( $sDelCost ), $iStartPos, $sDelCost );
00313 }
00314
00322 protected function _setWrappingInfo( &$iStartPos )
00323 {
00324 if ( $this->_oData->oxorder__oxwrapcost->value ) {
00325 $sAddString = '';
00326
00327
00328 if ( $this->_oData->oxorder__oxwrapvat->value ) {
00329
00330
00331 $iStartPos += 5;
00332 $sWrapCostNetto = oxLang::getInstance()->formatCurrency( $this->_oData->getOrderWrappingPrice()->getNettoPrice(), $this->_oData->getCurrency()).' '.$this->_oData->getCurrency()->name;
00333 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_WRAPPING' ).' '.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_NETTO' ) );
00334 $this->text( 195 - $this->_oPdf->getStringWidth( $sWrapCostNetto ), $iStartPos, $sWrapCostNetto );
00335
00336
00337 $iStartPos += 4;
00338 $sWrapCostVAT = oxLang::getInstance()->formatCurrency( $this->_oData->getOrderWrappingPrice()->getVATValue(), $this->_oData->getCurrency()).' '.$this->_oData->getCurrency()->name;
00339 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ).$this->_oData->oxorder__oxwrapvat->value.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_PERCENTSUM' ) );
00340 $this->text( 195 - $this->_oPdf->getStringWidth( $sWrapCostVAT ), $iStartPos, $sWrapCostVAT );
00341
00342 $sAddString = ' '.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_BRUTTO' );
00343
00344
00345 $iStartPos += 4;
00346 $this->line(45, $iStartPos - 3, 195, $iStartPos - 3);
00347 }
00348 $iStartPos += 4;
00349
00350
00351 $sWrapCost = oxLang::getInstance()->formatCurrency( $this->_oData->oxorder__oxwrapcost->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00352 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_WRAPPING' ).$sAddString );
00353 $this->text( 195 - $this->_oPdf->getStringWidth( $sWrapCost ), $iStartPos, $sWrapCost );
00354 $iStartPos++;
00355 }
00356 }
00357
00365 protected function _setPaymentInfo( &$iStartPos )
00366 {
00367 if ( $this->_oData->oxorder__oxpayvat->value ) {
00368
00369
00370 $iStartPos += 4;
00371 $sPayCostNetto = oxLang::getInstance()->formatCurrency( $this->_oData->getOrderPaymentPrice()->getNettoPrice(), $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00372 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_PAYMENTIMPACT' ).' '.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_NETTO' ) );
00373 $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCostNetto ), $iStartPos, $sPayCostNetto );
00374
00375
00376 $iStartPos += 4;
00377 $sPayCostVAT = oxLang::getInstance()->formatCurrency( $this->_oData->getOrderPaymentPrice()->getVATValue(), $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00378 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ).$this->_oData->oxorder__oxpayvat->value.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_PERCENTSUM' ) );
00379 $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCostVAT ), $iStartPos, $sPayCostVAT );
00380
00381 }
00382
00383
00384 if ( $this->_oData->oxorder__oxstorno->value ) {
00385 $this->_oData->oxorder__oxpaycost->setValue(0);
00386 }
00387
00388
00389 $iStartPos += 4;
00390 $sPayCost = oxLang::getInstance()->formatCurrency( $this->_oData->oxorder__oxpaycost->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00391 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_PAYMENTIMPACT' ) );
00392 $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCost ), $iStartPos, $sPayCost );
00393
00394 $iStartPos++;
00395 }
00396
00404 protected function _setGrandTotalPriceInfo( &$iStartPos )
00405 {
00406
00407 $this->font( 'Arial', 'B', 10 );
00408 if ( $this->_oData->oxorder__oxdelvat->value || $this->_oData->oxorder__oxwrapvat->value || $this->_oData->oxorder__oxpayvat->value ) {
00409
00410
00411 $sTotalNetSum = oxLang::getInstance()->formatCurrency( $this->_oData->getOrderNetSum(), $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00412 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLSUM_NET' ) );
00413 $this->text( 195 - $this->_oPdf->getStringWidth( $sTotalNetSum ), $iStartPos, $sTotalNetSum );
00414 $iStartPos += 4;
00415 }
00416
00417
00418 $sTotalOrderSum = oxLang::getInstance()->formatCurrency( $this->_oData->oxorder__oxtotalordersum->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00419 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLSUM' ) );
00420 $this->text( 195 - $this->_oPdf->getStringWidth( $sTotalOrderSum ), $iStartPos, $sTotalOrderSum );
00421 $iStartPos += 2;
00422 }
00423
00431 protected function _setPaymentMethodInfo( &$iStartPos )
00432 {
00433 $oPayment = oxNew( 'oxpayment' );
00434 $oPayment->loadInLang( $this->_oData->getSelectedLang(), $this->_oData->oxorder__oxpaymenttype->value );
00435
00436 $text = $this->_oData->translate( 'ORDER_OVERVIEW_PDF_SELPAYMENT' ).$oPayment->oxpayments__oxdesc->value;
00437 $this->font( 'Arial', '', 10 );
00438 $this->text( 15, $iStartPos + 4, $text );
00439 $iStartPos += 4;
00440 }
00441
00449 protected function _setPayUntilInfo( &$iStartPos )
00450 {
00451 $text = $this->_oData->translate( 'ORDER_OVERVIEW_PDF_PAYUPTO' ).date( 'd.m.Y', mktime( 0, 0, 0, date ( 'm' ), date ( 'd' ) + 7, date( 'Y' ) ) );
00452 $this->font( 'Arial', '', 10 );
00453 $this->text( 15, $iStartPos + 4, $text );
00454 $iStartPos += 4;
00455 }
00456
00464 public function generate( $iStartPos )
00465 {
00466
00467 $this->font( 'Arial', '', 10 );
00468 $siteH = $iStartPos;
00469
00470
00471 if ( !$this->_oData->oxorder__oxdiscount->value ) {
00472 $this->_setTotalCostsWithoutDiscount( $siteH );
00473 } else {
00474 $this->_setTotalCostsWithDiscount( $siteH );
00475 }
00476
00477 $siteH += 12;
00478
00479
00480 $this->_setVoucherInfo( $siteH );
00481
00482
00483 if ( $this->_oData->oxorder__oxdiscount->value || $this->_oData->oxorder__oxvoucherdiscount->value ) {
00484 $this->line( 45, $siteH - 3, 195, $siteH - 3 );
00485 }
00486
00487
00488 $this->_setDeliveryInfo( $siteH );
00489
00490
00491 $this->_setWrappingInfo( $siteH );
00492
00493
00494 $this->_setPaymentInfo( $siteH );
00495
00496
00497 $this->line( 15, $siteH, 195, $siteH );
00498 $siteH += 4;
00499
00500
00501 $this->_setGrandTotalPriceInfo( $siteH );
00502
00503
00504 $this->line( 15, $siteH, 195, $siteH );
00505 $siteH += 4;
00506
00507
00508 $this->_setPaymentMethodInfo( $siteH );
00509
00510
00511 $this->_setPayUntilInfo( $siteH );
00512
00513 return $siteH - $iStartPos;
00514 }
00515 }
00516
00520 class MyOrder extends MyOrder_parent
00521 {
00522
00527 protected $_iSelectedLang = 0;
00528
00533 protected $_oActShop = null;
00534
00539 protected $_aVATs = array();
00540
00545 protected $_oCur = null;
00546
00552 protected function _getActShop()
00553 {
00554
00555 if ( $this->_oActShop !== null )
00556 return $this->_oActShop;
00557
00558 $this->_oActShop = oxNew( 'oxshop' );
00559 $this->_oActShop->load( $this->getConfig()->getShopId() );
00560
00561 return $this->_oActShop;
00562 }
00563
00571 public function translate( $sString )
00572 {
00573 return oxLang::getInstance()->translateString( $sString, $this->_iSelectedLang );
00574 }
00575
00583 public function pdfFooter( $oPdf )
00584 {
00585
00586 $oShop = $this->_getActShop();
00587
00588 $oPdf->line( 15, 272, 195, 272 );
00589
00590
00591 $oPdf->setFont( 'Arial', '', 7 );
00592 $oPdf->text( 15, 275, strip_tags( $oShop->oxshops__oxcompany->value ) );
00593 $oPdf->text( 15, 278, strip_tags( $oShop->oxshops__oxfname->value ).' '. strip_tags( $oShop->oxshops__oxlname->value ) );
00594 $oPdf->text( 15, 281, strip_tags( $oShop->oxshops__oxstreet->value ) );
00595 $oPdf->text( 15, 284, strip_tags( $oShop->oxshops__oxzip->value ).' '. strip_tags( $oShop->oxshops__oxcity->value ) );
00596 $oPdf->text( 15, 287, strip_tags( $oShop->oxshops__oxcountry->value ) );
00597
00598
00599 $oPdf->text( 85, 275, $this->translate( 'ORDER_OVERVIEW_PDF_PHONE' ).strip_tags( $oShop->oxshops__oxtelefon->value ) );
00600 $oPdf->text( 85, 278, $this->translate( 'ORDER_OVERVIEW_PDF_FAX' ).strip_tags( $oShop->oxshops__oxtelefax->value ) );
00601 $oPdf->text( 85, 281, strip_tags( $oShop->oxshops__oxurl->value ) );
00602 $oPdf->text( 85, 284, strip_tags( $oShop->oxshops__oxorderemail->value ) );
00603
00604
00605 $oPdf->text( 150, 275, strip_tags( $oShop->oxshops__oxbankname->value ) );
00606 $oPdf->text( 150, 278, $this->translate( 'ORDER_OVERVIEW_PDF_ACCOUNTNR' ).strip_tags( $oShop->oxshops__oxbanknumber->value ) );
00607 $oPdf->text( 150, 281, $this->translate( 'ORDER_OVERVIEW_PDF_BANKCODE' ).strip_tags( $oShop->oxshops__oxbankcode->value ) );
00608 $oPdf->text( 150, 284, strip_tags( $oShop->oxshops__oxvatnumber->value ) );
00609 $oPdf->text( 150, 287, '' );
00610 }
00611
00619 public function pdfHeaderPlus( $oPdf )
00620 {
00621
00622
00623 $this->pdfHeader( $oPdf );
00624
00625
00626 $oPdf->setFont( 'Arial', '', 8 );
00627 $oPdf->text( 15, 50, $this->translate( 'ORDER_OVERVIEW_PDF_AMOUNT' ) );
00628 $oPdf->text( 30, 50, $this->translate( 'ORDER_OVERVIEW_PDF_ARTID') );
00629 $oPdf->text( 45, 50, $this->translate( 'ORDER_OVERVIEW_PDF_DESC' ) );
00630 $oPdf->text( 160, 50, $this->translate( 'ORDER_OVERVIEW_PDF_UNITPRICE' ) );
00631 $sText = $this->translate( 'ORDER_OVERVIEW_PDF_ALLPRICE' );
00632 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), 50, $sText );
00633
00634
00635 $oPdf->line( 15, 52, 195, 52 );
00636
00637 return 56;
00638 }
00639
00647 public function pdfHeader( $oPdf )
00648 {
00649
00650 $oPdf->addPage();
00651
00652
00653 $oShop = $this->_getActShop();
00654
00655
00656 $myConfig = $this->getConfig();
00657 $aSize = getimagesize( $myConfig->getAbsImageDir().'/pdf_logo.jpg' );
00658 $iMargin = 195 - $aSize[0] * 0.2;
00659 $oPdf->setLink( $oShop->oxshops__oxurl->value );
00660 $oPdf->image( $myConfig->getAbsImageDir().'/pdf_logo.jpg', $iMargin, 10, $aSize[0] * 0.2, $aSize[1] * 0.2, '', $oShop->oxshops__oxurl->value );
00661 return 14 + $aSize[1] * 0.2;
00662 }
00663
00672 public function genPdf( $sFilename, $iSelLang = 0 )
00673 {
00674
00675 $this->_iSelectedLang = $iSelLang;
00676
00677
00678 if ( !$this->oxorder__oxinvoicenr->value ) {
00679 $this->oxorder__oxinvoicenr->setValue($this->getInvoiceNum());
00680 $this->save();
00681 }
00682
00683
00684 $oPdf = oxNew( 'oxPDF' );
00685 $oPdf->open();
00686
00687
00688 $this->pdfHeader( $oPdf );
00689
00690
00691 switch ( oxConfig::getParameter( 'pdftype' ) ) {
00692 case 'dnote':
00693 $this->exportDeliveryNote( $oPdf );
00694 break;
00695 default:
00696 $this->exportStandart( $oPdf );
00697 }
00698
00699
00700 $this->pdfFooter( $oPdf );
00701
00702
00703 $oPdf->output( $sFilename, true );
00704 }
00705
00706
00714 protected function _setBillingAddressToPdf( $oPdf )
00715 {
00716 $oPdf->setFont( 'Arial', '', 10 );
00717 $oPdf->text( 15, 59, $this->oxorder__oxbillsal->value );
00718 $oPdf->text( 15, 63, $this->oxorder__oxbilllname->value.' '.$this->oxorder__oxbillfname->value );
00719 $oPdf->text( 15, 67, $this->oxorder__oxbillcompany->value );
00720 $oPdf->text( 15, 71, $this->oxorder__oxbillstreet->value.' '.$this->oxorder__oxbillstreetnr->value );
00721 $oPdf->setFont( 'Arial', 'B', 10 );
00722 $oPdf->text( 15, 75, $this->oxorder__oxbillzip->value.' '.$this->oxorder__oxbillcity->value );
00723 $oPdf->setFont( 'Arial', '', 10 );
00724 $oPdf->text( 15, 79, $this->oxorder__oxbillcountry->value );
00725 }
00726
00734 protected function _setDeliveryAddressToPdf( $oPdf )
00735 {
00736 $oPdf->setFont( 'Arial', '', 6 );
00737 $oPdf->text( 15, 87, $this->translate( 'ORDER_OVERVIEW_PDF_DELIVERYADDRESS' ) );
00738 $oPdf->setFont( 'Arial', '', 10 );
00739 $oPdf->text( 15, 91, $this->oxorder__oxdelsal->value );
00740 $oPdf->text( 15, 95, $this->oxorder__oxdellname->value.' '.$this->oxorder__oxdelfname->value );
00741 $oPdf->text( 15, 99, $this->oxorder__oxdelcompany->value );
00742 $oPdf->text( 15, 103, $this->oxorder__oxdelstreet->value.' '.$this->oxorder__oxdelstreetnr->value );
00743 $oPdf->setFont( 'Arial', 'B', 10 );
00744 $oPdf->text( 15, 107, $this->oxorder__oxdelzip->value.' '.$this->oxorder__oxdelcity->value );
00745 $oPdf->setFont( 'Arial', '', 10 );
00746 $oPdf->text( 15, 111, $this->oxorder__oxdelcountry->value );
00747 }
00748
00758 protected function _setOrderArticlesToPdf( $oPdf, &$iStartPos, $blShowPrice = true )
00759 {
00760 if (!$this->_oArticles) {
00761 $this->_oArticles = $this->getOrderArticles();
00762 }
00763
00764
00765 foreach ( $this->_oArticles as $key => $oOrderArt ) {
00766
00767
00768 if ( $iStartPos > 243 ) {
00769 $this->pdffooter( $oPdf );
00770 $iStartPos = $this->pdfheaderplus( $oPdf );
00771 $oPdf->setFont( 'Arial', '', 10 );
00772 } else {
00773 $iStartPos = $iStartPos + 4;
00774 }
00775
00776
00777 if ( $oOrderArt->oxorderarticles__oxstorno->value == 1 ) {
00778 $oOrderArt->oxorderarticles__oxbrutprice->setValue(0);
00779 $oOrderArt->oxorderarticles__oxnetprice->setValue(0);
00780 $oOrderArt->oxorderarticles__oxtitle->value .= ' '.$this->translate( 'ORDER_OVERVIEW_PDF_STORNO' );
00781 }
00782
00783
00784 $oPdf->text( 20 - $oPdf->getStringWidth( $oOrderArt->oxorderarticles__oxamount->value ), $iStartPos, $oOrderArt->oxorderarticles__oxamount->value );
00785
00786
00787 $oPdf->setFont( 'Arial', '', 8 );
00788 $oPdf->text( 28, $iStartPos, $oOrderArt->oxorderarticles__oxartnum->value );
00789
00790
00791 $oPdf->setFont( 'Arial', '', 10 );
00792 $oPdf->text( 45, $iStartPos, substr( strip_tags( $this->_replaceExtendedChars( $oOrderArt->oxorderarticles__oxtitle->value, true ) ), 0, 58 ) );
00793
00794 if ( $blShowPrice ) {
00795
00796
00797 $sText = oxLang::getInstance()->formatCurrency( $oOrderArt->oxorderarticles__oxbprice->value, $this->_oCur ).' '.$this->_oCur->name;
00798 $oPdf->text( 163 - $oPdf->getStringWidth( $sText ), $iStartPos, $sText );
00799
00800
00801 $sText = oxLang::getInstance()->formatCurrency( $oOrderArt->oxorderarticles__oxbrutprice->value, $this->_oCur ).' '.$this->_oCur->name;
00802 $oPdf->text( 184 - $oPdf->getStringWidth( $sText ), $iStartPos, $sText );
00803
00804
00805 $oPdf->text( 195 - $oPdf->getStringWidth( $oOrderArt->oxorderarticles__oxvat->value ), $iStartPos, $oOrderArt->oxorderarticles__oxvat->value );
00806
00807
00808 if ( !isset( $this->_aVATs[$oOrderArt->oxorderarticles__oxvat->value] ) ) {
00809 $this->_aVATs[$oOrderArt->oxorderarticles__oxvat->value] = 0;
00810 }
00811 $this->_aVATs[$oOrderArt->oxorderarticles__oxvat->value] += $oOrderArt->oxorderarticles__oxvatprice->value;
00812 }
00813
00814
00815 if ( $oOrderArt->oxorderarticles__oxselvariant->value ) {
00816 $iStartPos = $iStartPos + 4;
00817 $oPdf->text( 45, $iStartPos, substr( $oOrderArt->oxorderarticles__oxselvariant->value, 0, 58 ) );
00818 }
00819
00820 }
00821 }
00822
00830 public function exportStandart( $oPdf )
00831 {
00832
00833 $myConfig = $this->getConfig();
00834
00835 $this->_oCur = $myConfig->getCurrencyObject( $this->oxorder__oxcurrency->value );
00836 if ( !$this->_oCur ) {
00837 $this->_oCur = $myConfig->getActShopCurrencyObject();
00838 }
00839
00840
00841 $oShop = $this->_getActShop();
00842
00843
00844 $oPdf->setFont( 'Arial', '', 6 );
00845 $oPdf->text( 15, 55, $oShop->oxshops__oxname->value.' - '.$oShop->oxshops__oxstreet->value.' - '.$oShop->oxshops__oxzip->value.' - '.$oShop->oxshops__oxcity->value );
00846
00847
00848 $this->_setBillingAddressToPdf( $oPdf );
00849
00850
00851 if ( $this->oxorder__oxdelsal->value ) {
00852 $this->_setDeliveryAddressToPdf( $oPdf );
00853 }
00854
00855
00856 $oUser = oxNew( 'oxuser' );
00857 $oUser->load( $this->oxorder__oxuserid->value );
00858
00859
00860 $sText = $this->translate( 'ORDER_OVERVIEW_PDF_FILLONPAYMENT' );
00861 $oPdf->setFont( 'Arial', '', 5 );
00862 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), 55, $sText );
00863
00864
00865 $sCustNr = $this->translate( 'ORDER_OVERVIEW_PDF_CUSTNR').' '.$oUser->oxuser__oxcustnr->value;
00866 $oPdf->setFont( 'Arial', '', 7 );
00867 $oPdf->text( 195 - $oPdf->getStringWidth( $sCustNr ), 59, $sCustNr );
00868
00869
00870 if ( $this->oxorder__oxdelsal->value ) {
00871 $iTop = 115;
00872 } else {
00873 $iTop = 91;
00874 }
00875
00876
00877 $sText = $oShop->oxshops__oxcity->value.', '.date( 'd.m.Y' );
00878 $oPdf->setFont( 'Arial', '', 10 );
00879 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop + 8, $sText );
00880
00881
00882 if ( $oShop->oxshops__oxvatnumber->value ) {
00883 $sText = $this->translate( 'ORDER_OVERVIEW_PDF_TAXIDNR' ).' '.$oShop->oxshops__oxvatnumber->value;
00884 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop + 12, $sText );
00885 $iTop += 8;
00886 }
00887
00888
00889 $sText = $this->translate( 'ORDER_OVERVIEW_PDF_COUNTNR' ).' '.$this->oxorder__oxinvoicenr->value;
00890 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop + 8, $sText );
00891
00892
00893 if ( $this->oxorder__oxstorno->value == 1 ) {
00894 $this->oxorder__oxordernr->value .= ' '.$this->translate( 'ORDER_OVERVIEW_PDF_STORNO' );
00895 }
00896
00897
00898 $oPdf->setFont( 'Arial', '', 12 );
00899 $oPdf->text( 15, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_PURCHASENR' ).' '.$this->oxorder__oxordernr->value );
00900
00901
00902 $oPdf->setFont( 'Arial', '', 10 );
00903 $aOrderDate = explode( ' ', $this->oxorder__oxorderdate->value );
00904 $sOrderDate = $aOrderDate[0];
00905 $oPdf->text( 15, $iTop + 8, $this->translate( 'ORDER_OVERVIEW_PDF_ORDERSFROM' ).$sOrderDate.$this->translate( 'ORDER_OVERVIEW_PDF_ORDERSAT' ).$oShop->oxshops__oxurl->value );
00906 $iTop += 16;
00907
00908
00909 $oPdf->setFont( 'Arial', '', 8 );
00910 $oPdf->text( 15, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_AMOUNT' ) );
00911 $oPdf->text( 30, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_ARTID' ) );
00912 $oPdf->text( 45, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_DESC' ) );
00913 $oPdf->text( 148, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_UNITPRICE' ) );
00914 $oPdf->text( 168, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_ALLPRICE' ) );
00915 $sText = $this->translate( 'ORDER_OVERVIEW_PDF_VAT' );
00916 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop, $sText );
00917
00918
00919 $iTop += 2;
00920 $oPdf->line( 15, $iTop, 195, $iTop );
00921
00922
00923 $siteH = $iTop;
00924 $oPdf->setFont( 'Arial', '', 10 );
00925
00926
00927 $this->_setOrderArticlesToPdf( $oPdf, $siteH, true );
00928
00929
00930 $oArtSumm = new PdfArticleSummary( $this, $oPdf );
00931 $iHeight = $oArtSumm->generate( $siteH );
00932 if ( $siteH + $iHeight > 258 ) {
00933 $this->pdfFooter( $oPdf );
00934 $iTop = $this->pdfHeader( $oPdf );
00935 $oArtSumm->ajustHeight( $iTop - $siteH );
00936 $siteH = $iTop;
00937 }
00938
00939 $oArtSumm->run( $oPdf );
00940 $siteH += $iHeight + 8;
00941
00942 $oPdf->text( 15, $siteH, $this->translate( 'ORDER_OVERVIEW_PDF_GREETINGS' ) );
00943 }
00944
00952 public function exportDeliveryNote( $oPdf )
00953 {
00954 $myConfig = $this->getConfig();
00955 $oShop = $this->_getActShop();
00956
00957
00958 $this->_oCur = $myConfig->getCurrencyObject( $this->oxorder__oxcurrency->value );
00959 if ( !isset( $this->_oCur ) ) {
00960 $this->_oCur = $myConfig->getActShopCurrencyObject();
00961 }
00962
00963
00964 $oPdf->setFont( 'Arial', '', 6 );
00965 $oPdf->text( 15, 55, $oShop->oxshops__oxname->value.' - '.$oShop->oxshops__oxstreet->value.' - '.$oShop->oxshops__oxzip->value.' - '.$oShop->oxshops__oxcity->value );
00966
00967
00968 $oPdf->setFont( 'Arial', '', 10 );
00969 if ( $this->oxorder__oxdelsal->value ) {
00970 $oPdf->text( 15, 59, $this->oxorder__oxdelsal->value );
00971 $oPdf->text( 15, 63, $this->oxorder__oxdellname->value.' '.$this->oxorder__oxdelfname->value );
00972 $oPdf->text( 15, 67, $this->oxorder__oxdelcompany->value );
00973 $oPdf->text( 15, 71, $this->oxorder__oxdelstreet->value.' '.$this->oxorder__oxdelstreetnr->value );
00974 $oPdf->setFont( 'Arial', 'B', 10 );
00975 $oPdf->text( 15, 75, $this->oxorder__oxdelzip->value.' '.$this->oxorder__oxdelcity->value );
00976 $oPdf->setFont( 'Arial', '', 10 );
00977 $oPdf->text( 15, 79, $this->oxorder__oxdelcountry->value );
00978 } else {
00979 $this->_setBillingAddressToPdf( $oPdf );
00980 }
00981
00982
00983 $oUser = oxNew( 'oxuser' );
00984 $oUser->load( $this->oxorder__oxuserid->value );
00985
00986
00987 $sText = $this->translate( 'ORDER_OVERVIEW_PDF_FILLONPAYMENT' );
00988 $oPdf->setFont( 'Arial', '', 5 );
00989 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), 70, $sText );
00990
00991
00992 $sCustNr = $this->translate( 'ORDER_OVERVIEW_PDF_CUSTNR' ).' '.$oUser->oxuser__oxcustnr->value;
00993 $oPdf->setFont( 'Arial', '', 7 );
00994 $oPdf->text( 195 - $oPdf->getStringWidth( $sCustNr ), 73, $sCustNr );
00995
00996
00997 $sText = $oShop->oxshops__oxcity->value.', '.date( 'd.m.Y' );
00998 $oPdf->setFont( 'Arial', '', 10 );
00999 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), 95, $sText );
01000
01001 $iTop = 99;
01002
01003 if ( $oShop->oxshops__oxvatnumber->value ) {
01004 $sText = $this->translate( 'ORDER_OVERVIEW_PDF_TAXIDNR' ).' '.$oShop->oxshops__oxvatnumber->value;
01005 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop, $sText );
01006 $iTop += 4;
01007 }
01008
01009
01010 $sText = $this->translate( 'ORDER_OVERVIEW_PDF_COUNTNR' ).' '.$this->oxorder__oxinvoicenr->value;
01011 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop, $sText );
01012
01013
01014 if ( $this->oxorder__oxstorno->value == 1 ) {
01015 $this->oxorder__oxordernr->value .= ' '.$this->translate( 'ORDER_OVERVIEW_PDF_STORNO' );
01016 }
01017
01018
01019 $oPdf->setFont( 'Arial', '', 12 );
01020 $oPdf->text( 15, 108, $this->translate( 'ORDER_OVERVIEW_PDF_DELIVNOTE' ).' '.$this->oxorder__oxordernr->value );
01021
01022
01023 $aOrderDate = explode( ' ', $this->oxorder__oxorderdate->value );
01024 $sOrderDate = $aOrderDate[0];
01025 $oPdf->setFont( 'Arial', '', 10 );
01026 $oPdf->text(15, 119, $this->translate( 'ORDER_OVERVIEW_PDF_ORDERSFROM' ).$sOrderDate.$this->translate( 'ORDER_OVERVIEW_PDF_ORDERSAT' ).$oShop->oxshops__oxurl->value );
01027
01028
01029 $oPdf->setFont( 'Arial', '', 8 );
01030 $oPdf->text( 15, 128, $this->translate( 'ORDER_OVERVIEW_PDF_AMOUNT' ) );
01031 $oPdf->text( 30, 128, $this->translate( 'ORDER_OVERVIEW_PDF_ARTID' ) );
01032 $oPdf->text( 45, 128, $this->translate( 'ORDER_OVERVIEW_PDF_DESC' ) );
01033
01034
01035 $oPdf->line( 15, 130, 195, 130 );
01036
01037
01038 $oPdf->setFont( 'Arial', '', 10 );
01039 $siteH = 130;
01040
01041
01042 $this->_setOrderArticlesToPdf( $oPdf, $siteH, false );
01043
01044
01045 $oPdf->line( 15, $siteH + 2, 195, $siteH + 2 );
01046 $siteH += 4;
01047
01048
01049 $oPdf->setFont( 'Arial', '', 10 );
01050 $text = $this->translate( 'ORDER_OVERVIEW_PDF_PAYUPTO' ).date( 'd.m.Y', mktime( 0, 0, 0, date ( 'm' ), date ( 'd' ) + 7, date( 'Y' ) ) );
01051 $oPdf->text( 15, $siteH + 4, $text );
01052 }
01053
01063 protected function _replaceExtendedChars( $sValue, $blReverse = false )
01064 {
01065
01066
01067
01068
01069
01070
01071 $aReplace = array( chr(169) => "©", chr(128) => "€", "\"" => """, "'" => "'");
01072
01073
01074
01075 if ($blReverse) {
01076 $aTransTbl = get_html_translation_table (HTML_ENTITIES);
01077 $aTransTbl = array_flip ($aTransTbl) + array_flip ($aReplace);
01078 $sValue = strtr($sValue, $aTransTbl);
01079 $sValue = preg_replace('/\&\#([0-9]+)\;/me', "chr('\\1')", $sValue);
01080 }
01081
01082 return $sValue;
01083 }
01084
01090 public function getVats()
01091 {
01092 return $this->_aVATs;
01093 }
01094
01100 public function getCurrency()
01101 {
01102 return $this->_oCur;
01103 }
01104
01110 public function getSelectedLang()
01111 {
01112 return $this->_iSelectedLang;
01113 }
01114 }