myorder.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class PdfBlock
00007 {
00012     protected $_aCache = array();
00013 
00018     protected $_sFont = 'Arial';
00019 
00028     protected function _toCache( $sFunc, $aParams )
00029     {
00030         $oItem = new stdClass();
00031         $oItem->sFunc   = $sFunc;
00032         $oItem->aParams = $aParams;
00033         $this->_aCache[]  = $oItem;
00034     }
00035 
00043     public function run( $oPdf )
00044     {
00045         foreach ( $this->_aCache as $oItem ) {
00046             $sFn = $oItem->sFunc;
00047             switch ( count( $oItem->aParams ) ) {
00048                 case 0:
00049                     $oPdf->$sFn();
00050                     break;
00051                 case 1:
00052                     $oPdf->$sFn( $oItem->aParams[0]);
00053                     break;
00054                 case 2:
00055                     $oPdf->$sFn( $oItem->aParams[0], $oItem->aParams[1] );
00056                     break;
00057                 case 3:
00058                     $oPdf->$sFn( $oItem->aParams[0], $oItem->aParams[1], $oItem->aParams[2]);
00059                     break;
00060                 case 4:
00061                     $oPdf->$sFn( $oItem->aParams[0], $oItem->aParams[1], $oItem->aParams[2], $oItem->aParams[3]);
00062                     break;
00063             }
00064         }
00065     }
00066 
00077     public function line( $iLPos, $iLHeight, $iRPos, $iRHeight )
00078     {
00079         $this->_toCache( 'Line', array( $iLPos, $iLHeight, $iRPos, $iRHeight ) );
00080     }
00081 
00091     public function text( $iLPos, $iLHeight, $sString )
00092     {
00093         $this->_toCache( 'Text', array( $iLPos, $iLHeight, $sString ) );
00094     }
00095 
00105     public function font( $sType, $sWeight, $sSize )
00106     {
00107         $this->_toCache( 'SetFont', array( $sType, $sWeight, $sSize ) );
00108     }
00109 
00117     public function ajustHeight( $iDelta )
00118     {
00119         foreach ( $this->_aCache as $key => $oItem ) {
00120             switch ( $oItem->sFunc ) {
00121                 case 'Line':
00122                     $this->_aCache[$key]->aParams[3] += $iDelta;
00123                     $this->_aCache[$key]->aParams[1] += $iDelta;
00124                     break;
00125                 case 'Text':
00126                     $this->_aCache[$key]->aParams[1] += $iDelta;
00127                     break;
00128             }
00129         }
00130     }
00131 
00137     public function getFont()
00138     {
00139         return $this->_sFont;
00140     }
00141 }
00142 
00146 class PdfArticleSummary extends PdfBlock
00147 {
00148 
00153     protected $_oData = null;
00154 
00159     protected $_oPdf = null;
00160 
00169     public function __construct( $oData, $oPdf )
00170     {
00171         $this->_oData = $oData;
00172         $this->_oPdf = $oPdf;
00173     }
00174 
00182     protected function _setTotalCostsWithoutDiscount( &$iStartPos )
00183     {
00184         $oLang = oxRegistry::getLang();
00185 
00186         // products netto price
00187         $this->line( 15, $iStartPos + 1, 195, $iStartPos + 1 );
00188         $sNetSum = $oLang->formatCurrency( $this->_oData->oxorder__oxtotalnetsum->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00189         $this->text( 45, $iStartPos + 4, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLPRICENETTO' ) );
00190         $this->text( 195 - $this->_oPdf->getStringWidth( $sNetSum ), $iStartPos + 4, $sNetSum );
00191 
00192         // #345 - product VAT info
00193         $iCtr = 0;
00194         foreach ( $this->_oData->getVats() as $iVat => $dVatPrice ) {
00195             $iStartPos += 4 * $iCtr;
00196             $sVATSum = $oLang->formatCurrency( $dVatPrice, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00197             $this->text( 45, $iStartPos + 8, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ).$iVat.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_PERCENTSUM' ) );
00198             $this->text( 195 - $this->_oPdf->getStringWidth( $sVATSum ), $iStartPos + 8, $sVATSum );
00199             $iCtr++;
00200         }
00201 
00202         // products brutto price
00203         $sBrutPrice = $oLang->formatCurrency( $this->_oData->oxorder__oxtotalbrutsum->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00204         $this->text( 45, $iStartPos + 12, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLPRICEBRUTTO' ) );
00205         $this->text( 195 - $this->_oPdf->getStringWidth( $sBrutPrice ), $iStartPos + 12, $sBrutPrice );
00206         $iStartPos++;
00207 
00208         // line separator
00209         $this->line( 45, $iStartPos + 13, 195, $iStartPos + 13 );
00210         $iStartPos += 5;
00211     }
00212 
00220     protected function _setTotalCostsWithDiscount( &$iStartPos )
00221     {
00222         $oLang = oxRegistry::getLang();
00223 
00224         // line separator
00225         $this->line( 15, $iStartPos + 1, 195, $iStartPos + 1 );
00226 
00227         if ( $this->_oData->isNettoMode() ) {
00228 
00229             // products netto price
00230             $sNetSum = $oLang->formatCurrency( $this->_oData->oxorder__oxtotalnetsum->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00231             $this->text( 45, $iStartPos + 4, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLPRICENETTO' ) );
00232             $this->text( 195 - $this->_oPdf->getStringWidth( $sNetSum ), $iStartPos + 4, $sNetSum );
00233 
00234             // discount
00235             $dDiscountVal = $this->_oData->oxorder__oxdiscount->value;
00236             if ( $dDiscountVal > 0 ) {
00237                 $dDiscountVal *= -1;
00238             }
00239             $sDiscount = $oLang->formatCurrency( $dDiscountVal, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00240             $this->text( 45, $iStartPos + 8, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_DISCOUNT' ) );
00241             $this->text( 195 - $this->_oPdf->getStringWidth( $sDiscount ), $iStartPos + 8, $sDiscount );
00242             $iStartPos++;
00243 
00244             // line separator
00245             $this->line( 45, $iStartPos + 8, 195, $iStartPos + 8 );
00246 
00247             $iCtr = 0;
00248             foreach ( $this->_oData->getVats() as $iVat => $dVatPrice ) {
00249                 $iStartPos += 4 * $iCtr;
00250                 $sVATSum = $oLang->formatCurrency( $dVatPrice, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00251                 $this->text( 45, $iStartPos + 12, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ).$iVat.$this->_oData->translate('ORDER_OVERVIEW_PDF_PERCENTSUM' ) );
00252                 $this->text( 195 - $this->_oPdf->getStringWidth( $sVATSum ), $iStartPos + 12, $sVATSum );
00253                 $iCtr++;
00254             }
00255             $iStartPos += 4;
00256 
00257             // products brutto price
00258             $sBrutPrice = $oLang->formatCurrency( $this->_oData->oxorder__oxtotalbrutsum->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00259             $this->text( 45, $iStartPos + 12, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLPRICEBRUTTO' ) );
00260             $this->text( 195 - $this->_oPdf->getStringWidth( $sBrutPrice ), $iStartPos + 12, $sBrutPrice );
00261             $iStartPos += 4;
00262 
00263         } else {
00264             // products brutto price
00265             $sBrutPrice = $oLang->formatCurrency( $this->_oData->oxorder__oxtotalbrutsum->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00266             $this->text( 45, $iStartPos + 4, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLPRICEBRUTTO' ) );
00267             $this->text( 195 - $this->_oPdf->getStringWidth( $sBrutPrice ), $iStartPos + 4, $sBrutPrice );
00268 
00269             // line separator
00270             $this->line( 45, $iStartPos + 5, 195, $iStartPos + 5 );
00271 
00272             // discount
00273             $dDiscountVal = $this->_oData->oxorder__oxdiscount->value;
00274             if ( $dDiscountVal > 0 ) {
00275                 $dDiscountVal *= -1;
00276             }
00277             $sDiscount = $oLang->formatCurrency( $dDiscountVal, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00278             $this->text( 45, $iStartPos + 8, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_DISCOUNT' ) );
00279             $this->text( 195 - $this->_oPdf->getStringWidth( $sDiscount ), $iStartPos + 8, $sDiscount );
00280             $iStartPos++;
00281 
00282             // line separator
00283             $this->line( 45, $iStartPos + 8, 195, $iStartPos + 8 );
00284             $iStartPos += 4;
00285 
00286             // products netto price
00287             $sNetSum = $oLang->formatCurrency( $this->_oData->oxorder__oxtotalnetsum->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00288             $this->text( 45, $iStartPos + 8, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLPRICENETTO' ) );
00289             $this->text( 195 - $this->_oPdf->getStringWidth( $sNetSum ), $iStartPos + 8, $sNetSum );
00290 
00291             // #345 - product VAT info
00292             $iCtr = 0;
00293             foreach ( $this->_oData->getVats() as $iVat => $dVatPrice ) {
00294                 $iStartPos += 4 * $iCtr;
00295                 $sVATSum = $oLang->formatCurrency( $dVatPrice, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00296                 $this->text( 45, $iStartPos + 12, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ).$iVat.$this->_oData->translate('ORDER_OVERVIEW_PDF_PERCENTSUM' ) );
00297                 $this->text( 195 - $this->_oPdf->getStringWidth( $sVATSum ), $iStartPos + 12, $sVATSum );
00298                 $iCtr++;
00299             }
00300             $iStartPos += 4;
00301         }
00302     }
00303 
00311     protected function _setVoucherInfo( &$iStartPos )
00312     {
00313         $dVoucher = 0;
00314         if ( $this->_oData->oxorder__oxvoucherdiscount->value ) {
00315             $dDiscountVal = $this->_oData->oxorder__oxvoucherdiscount->value;
00316             if ( $dDiscountVal > 0 ) {
00317                 $dDiscountVal *= -1;
00318             }
00319             $sPayCost = oxRegistry::getLang()->formatCurrency( $dDiscountVal, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00320             $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_VOUCHER' ) );
00321             $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCost ), $iStartPos, $sPayCost );
00322             $iStartPos += 4;
00323         }
00324 
00325         $iStartPos++;
00326     }
00327 
00335     protected function _setDeliveryInfo( &$iStartPos )
00336     {
00337         $sAddString = '';
00338         $oLang = oxRegistry::getLang();
00339         $oConfig = oxRegistry::getConfig();
00340 
00341         if ( $oConfig->getConfigParam( 'blShowVATForDelivery' ) ) {
00342             // delivery netto
00343             $sDelCostNetto = $oLang->formatCurrency( $this->_oData->getOrderDeliveryPrice()->getNettoPrice(), $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00344             $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_SHIPCOST' ).' '.$this->_oData->translate('ORDER_OVERVIEW_PDF_NETTO' ) );
00345             $this->text( 195 - $this->_oPdf->getStringWidth( $sDelCostNetto ), $iStartPos, $sDelCostNetto );
00346             $iStartPos += 4;
00347 
00348             if ( $oConfig->getConfigParam('sAdditionalServVATCalcMethod') != 'proportional' ) {
00349                 $sVatValueText = $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ).$this->_oData->oxorder__oxdelvat->value.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_PERCENTSUM' );
00350             } else {
00351                 $sVatValueText = $this->_oData->translate( 'TOTAL_PLUS_PROPORTIONAL_VAT' );
00352             }
00353 
00354             // delivery VAT
00355             $sDelCostVAT = $oLang->formatCurrency( $this->_oData->getOrderDeliveryPrice()->getVATValue(), $this->_oData->getCurrency()).' '.$this->_oData->getCurrency()->name;
00356             $this->text( 45, $iStartPos, $sVatValueText );
00357             $this->text( 195 - $this->_oPdf->getStringWidth( $sDelCostVAT ), $iStartPos, $sDelCostVAT );
00358             //$iStartPos += 4;
00359 
00360             $sAddString = ' '.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_BRUTTO' );
00361         } else {
00362             // if canceled order, reset value
00363             if ( $this->_oData->oxorder__oxstorno->value ) {
00364                 $this->_oData->oxorder__oxdelcost->setValue(0);
00365             }
00366 
00367             $sDelCost = $oLang->formatCurrency( $this->_oData->oxorder__oxdelcost->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00368             $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_SHIPCOST' ).$sAddString );
00369             $this->text( 195 - $this->_oPdf->getStringWidth( $sDelCost ), $iStartPos, $sDelCost );
00370         }
00371     }
00372 
00380     protected function _setWrappingInfo( &$iStartPos )
00381     {
00382         if ( $this->_oData->oxorder__oxwrapcost->value ) {
00383             $sAddString = '';
00384             $oLang = oxRegistry::getLang();
00385             $oConfig = oxRegistry::getConfig();
00386 
00387             //displaying wrapping VAT info
00388             if ( $oConfig->getConfigParam('blShowVATForWrapping') ) {
00389 
00390                 if ($this->_oData->oxorder__oxwrapcost->value) {
00391                     // wrapping netto
00392                     $iStartPos += 4;
00393                     $sWrapCostNetto = $oLang->formatCurrency( $this->_oData->getOrderWrappingPrice()->getNettoPrice(), $this->_oData->getCurrency()).' '.$this->_oData->getCurrency()->name;
00394                     $this->text( 45, $iStartPos, $this->_oData->translate( 'WRAPPING_COSTS' ).' '.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_NETTO' ) );
00395                     $this->text( 195 - $this->_oPdf->getStringWidth( $sWrapCostNetto ), $iStartPos, $sWrapCostNetto );
00396                     //$iStartPos++;
00397 
00398                     //wrapping VAT
00399                     $iStartPos += 4;
00400                     $sWrapCostVAT = $oLang->formatCurrency( $this->_oData->getOrderWrappingPrice()->getVATValue(), $this->_oData->getCurrency()).' '.$this->_oData->getCurrency()->name;
00401                     $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ) );
00402                     $this->text( 195 - $this->_oPdf->getStringWidth( $sWrapCostVAT ), $iStartPos, $sWrapCostVAT );
00403                    // $iStartPos++;
00404                 }
00405 
00406 
00407                 if ($this->_oData->oxorder__oxgiftcardcost->value) {
00408                     // wrapping netto
00409                     $iStartPos += 4;
00410                     $sWrapCostNetto = $oLang->formatCurrency( $this->_oData->getOrderGiftCardPrice()->getNettoPrice(), $this->_oData->getCurrency()).' '.$this->_oData->getCurrency()->name;
00411                     $this->text( 45, $iStartPos, $this->_oData->translate( 'GIFTCARD_COSTS' ).' '.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_NETTO' ) );
00412                     $this->text( 195 - $this->_oPdf->getStringWidth( $sWrapCostNetto ), $iStartPos, $sWrapCostNetto );
00413                     //$iStartPos++;
00414 
00415                     //wrapping VAT
00416                     $iStartPos += 4;
00417                     $sWrapCostVAT = $oLang->formatCurrency( $this->_oData->getOrderGiftCardPrice()->getVATValue(), $this->_oData->getCurrency()).' '.$this->_oData->getCurrency()->name;
00418 
00419                     if ( $oConfig->getConfigParam('sAdditionalServVATCalcMethod') != 'proportional' ) {
00420                         $sVatValueText = $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ) .$this->_oData->oxorder__oxgiftcardvat->value.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_PERCENTSUM' );
00421                     } else {
00422                         $sVatValueText = $this->_oData->translate( 'TOTAL_PLUS_PROPORTIONAL_VAT' );
00423                     }
00424 
00425                     $this->text( 45, $iStartPos, $sVatValueText );
00426                     $this->text( 195 - $this->_oPdf->getStringWidth( $sWrapCostVAT ), $iStartPos, $sWrapCostVAT );
00427                     $iStartPos++;
00428                 }
00429 
00430             } else {
00431                 $iStartPos += 4;
00432 
00433                 if ($this->_oData->oxorder__oxwrapcost->value) {
00434                     // wrapping cost
00435                     $sAddString = ' '.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_BRUTTO' );
00436                     $sWrapCost = $oLang->formatCurrency( $this->_oData->oxorder__oxwrapcost->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00437                     $this->text( 45, $iStartPos, $this->_oData->translate( 'WRAPPING_COSTS'/*'ORDER_OVERVIEW_PDF_WRAPPING'*/ ).$sAddString );
00438                     $this->text( 195 - $this->_oPdf->getStringWidth( $sWrapCost ), $iStartPos, $sWrapCost );
00439                     $iStartPos++;
00440                 }
00441 
00442                 if ($this->_oData->oxorder__oxgiftcardcost->value) {
00443                     $iStartPos += 4;
00444                 // gift card cost
00445                     $sWrapCost = $oLang->formatCurrency( $this->_oData->oxorder__oxgiftcardcost->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00446                     $this->text( 45, $iStartPos, $this->_oData->translate( 'GIFTCARD_COSTS' ).$sAddString );
00447                     $this->text( 195 - $this->_oPdf->getStringWidth( $sWrapCost ), $iStartPos, $sWrapCost );
00448                     $iStartPos++;
00449                 }
00450 
00451             }
00452 
00453         }
00454     }
00455 
00463     protected function _setPaymentInfo( &$iStartPos )
00464     {
00465         $oLang = oxRegistry::getLang();
00466         $oConfig = oxRegistry::getConfig();
00467 
00468         if ( $this->_oData->oxorder__oxstorno->value ) {
00469                 $this->_oData->oxorder__oxpaycost->setValue(0);
00470         }
00471 
00472         if ($oConfig->getConfigParam('blShowVATForDelivery')) {
00473             if ( $this->_oData->oxorder__oxpayvat->value ) {
00474                 // payment netto
00475                 $iStartPos += 4;
00476                 $sPayCostNetto = $oLang->formatCurrency( $this->_oData->getOrderPaymentPrice()->getNettoPrice(), $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00477                 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_PAYMENTIMPACT' ).' '.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_NETTO' ) );
00478                 $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCostNetto ), $iStartPos, $sPayCostNetto );
00479 
00480                 if ( $oConfig->getConfigParam('sAdditionalServVATCalcMethod') != 'proportional' ) {
00481                     $sVatValueText = $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ).$this->_oData->oxorder__oxpayvat->value.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_PERCENTSUM' );
00482                 } else {
00483                     $sVatValueText = $this->_oData->translate( 'TOTAL_PLUS_PROPORTIONAL_VAT' );
00484                 }
00485 
00486                 // payment VAT
00487                 $iStartPos += 4;
00488                 $sPayCostVAT = $oLang->formatCurrency( $this->_oData->getOrderPaymentPrice()->getVATValue(), $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00489                 $this->text( 45, $iStartPos, $sVatValueText );
00490                 $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCostVAT ), $iStartPos, $sPayCostVAT );
00491 
00492             }
00493 
00494             // if canceled order, reset value
00495 
00496         } else {
00497 
00498             // payment costs
00499             if ( $this->_oData->oxorder__oxpaycost->value ) {
00500                 $iStartPos += 4;
00501                 $sPayCost = $oLang->formatCurrency( $this->_oData->oxorder__oxpaycost->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00502                 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_PAYMENTIMPACT' ) );
00503                 $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCost ), $iStartPos, $sPayCost );
00504             }
00505 
00506             $iStartPos++;
00507         }
00508     }
00509 
00517     protected function _setTsProtection( &$iStartPos )
00518     {
00519         $oLang   = oxRegistry::getLang();
00520         $oConfig = oxRegistry::getConfig();
00521         if ( $this->_oData->oxorder__oxtsprotectcosts->value && $oConfig->getConfigParam( 'blShowVATForPayCharge' ) ) {
00522 
00523             // payment netto
00524             $iStartPos += 4;
00525             $sPayCostNetto = $oLang->formatCurrency( $this->_oData->getOrderTsProtectionPrice()->getNettoPrice(), $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00526             $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_TSPROTECTION' ).' '.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_NETTO' ) );
00527             $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCostNetto ), $iStartPos, $sPayCostNetto );
00528 
00529             // payment VAT
00530             $iStartPos += 4;
00531             $sPayCostVAT = $oLang->formatCurrency( $this->_oData->getOrderTsProtectionPrice()->getVATValue(), $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00532             $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ).$oConfig->getConfigParam( 'dDefaultVAT' ).$this->_oData->translate( 'ORDER_OVERVIEW_PDF_PERCENTSUM' ) );
00533             $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCostVAT ), $iStartPos, $sPayCostVAT );
00534 
00535             $iStartPos++;
00536 
00537         } elseif ( $this->_oData->oxorder__oxtsprotectcosts->value ) {
00538 
00539             $iStartPos += 4;
00540             $sPayCost = $oLang->formatCurrency( $this->_oData->oxorder__oxtsprotectcosts->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00541             $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_TSPROTECTION' ) );
00542             $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCost ), $iStartPos, $sPayCost );
00543 
00544             $iStartPos++;
00545         }
00546     }
00547 
00555     protected function _setGrandTotalPriceInfo( &$iStartPos )
00556     {
00557         $this->font( $this->getFont(), 'B', 10 );
00558 
00559         // total order sum
00560         $sTotalOrderSum = $this->_oData->getFormattedTotalOrderSum() . ' ' . $this->_oData->getCurrency()->name;
00561         $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLSUM' ) );
00562         $this->text( 195 - $this->_oPdf->getStringWidth( $sTotalOrderSum ), $iStartPos, $sTotalOrderSum );
00563         $iStartPos += 2;
00564 
00565         if ( $this->_oData->oxorder__oxdelvat->value || $this->_oData->oxorder__oxwrapvat->value || $this->_oData->oxorder__oxpayvat->value ) {
00566             $iStartPos += 2;
00567         }
00568     }
00569 
00577     protected function _setPaymentMethodInfo( &$iStartPos )
00578     {
00579         $oPayment = oxNew( 'oxpayment' );
00580         $oPayment->loadInLang( $this->_oData->getSelectedLang(), $this->_oData->oxorder__oxpaymenttype->value );
00581 
00582         $text = $this->_oData->translate( 'ORDER_OVERVIEW_PDF_SELPAYMENT' ).$oPayment->oxpayments__oxdesc->value;
00583         $this->font( $this->getFont(), '', 10 );
00584         $this->text( 15, $iStartPos + 4, $text );
00585         $iStartPos += 4;
00586     }
00587 
00595     protected function _setPayUntilInfo( &$iStartPos )
00596     {
00597         $text = $this->_oData->translate( 'ORDER_OVERVIEW_PDF_PAYUPTO' ) . date( 'd.m.Y', strtotime( '+' . $this->_oData->getPaymentTerm() . ' day', strtotime( $this->_oData->oxorder__oxbilldate->value ) ) );
00598         $this->font( $this->getFont(), '', 10 );
00599         $this->text( 15, $iStartPos + 4, $text );
00600         $iStartPos += 4;
00601     }
00602 
00610     public function generate( $iStartPos )
00611     {
00612 
00613         $this->font( $this->getFont(), '', 10 );
00614         $siteH = $iStartPos;
00615 
00616         // #1147 discount for vat must be displayed
00617         if ( !$this->_oData->oxorder__oxdiscount->value ) {
00618             $this->_setTotalCostsWithoutDiscount( $siteH );
00619         } else {
00620             $this->_setTotalCostsWithDiscount( $siteH );
00621         }
00622 
00623         $siteH += 12;
00624 
00625         // voucher info
00626         $this->_setVoucherInfo( $siteH );
00627 
00628         // additional line separator
00629         if ( $this->_oData->oxorder__oxdiscount->value || $this->_oData->oxorder__oxvoucherdiscount->value ) {
00630             $this->line( 45, $siteH - 3, 195, $siteH - 3 );
00631         }
00632 
00633         // delivery info
00634         $this->_setDeliveryInfo( $siteH );
00635 
00636         // payment info
00637         $this->_setPaymentInfo( $siteH );
00638 
00639         // wrapping info
00640         $this->_setWrappingInfo( $siteH );
00641 
00642         // TS protection info
00643         $this->_setTsProtection( $siteH );
00644 
00645         // separating line
00646         $this->line( 15, $siteH, 195, $siteH );
00647         $siteH += 4;
00648 
00649         // total order sum
00650         $this->_setGrandTotalPriceInfo( $siteH );
00651 
00652         // separating line
00653         $this->line( 15, $siteH, 195, $siteH );
00654         $siteH += 4;
00655 
00656         // payment method
00657         $this->_setPaymentMethodInfo( $siteH );
00658 
00659         // pay until ...
00660         $this->_setPayUntilInfo( $siteH );
00661 
00662         return $siteH - $iStartPos;
00663     }
00664 }
00665 
00669 class MyOrder extends MyOrder_parent
00670 {
00671 
00676     protected $_iSelectedLang = 0;
00677 
00682     protected $_oActShop = null;
00683 
00688     protected $_aVATs = array();
00689 
00694     protected $_oCur = null;
00695 
00696 
00702     public function setSelectedLang( $iLang )
00703     {
00704        $this->_iSelectedLang = $iLang;
00705     }
00706 
00712     protected function _getActShop()
00713     {
00714         // shop is allready loaded
00715         if ( $this->_oActShop !== null )
00716             return $this->_oActShop;
00717 
00718         $this->_oActShop = oxNew( 'oxshop' );
00719         $this->_oActShop->load( $this->getConfig()->getShopId() );
00720 
00721         return $this->_oActShop;
00722     }
00723 
00731     public function translate( $sString )
00732     {
00733         return oxRegistry::getLang()->translateString( $sString, $this->getSelectedLang() );
00734     }
00735 
00743     public function pdfFooter( $oPdf )
00744     {
00745 
00746         $oShop = $this->_getActShop();
00747 
00748         $oPdf->line( 15, 272, 195, 272 );
00749 
00750         $oPdfBlock = new PdfBlock();
00751         /* column 1 - company name, shop owner info, shop address */
00752         $oPdf->setFont( $oPdfBlock->getFont(), '', 7 );
00753         $oPdf->text( 15, 275, strip_tags( $oShop->oxshops__oxcompany->getRawValue() ) );
00754         $oPdf->text( 15, 278, strip_tags( $oShop->oxshops__oxfname->getRawValue() ).' '. strip_tags( $oShop->oxshops__oxlname->getRawValue() ) );
00755         $oPdf->text( 15, 281, strip_tags( $oShop->oxshops__oxstreet->getRawValue() ) );
00756         $oPdf->text( 15, 284, strip_tags( $oShop->oxshops__oxzip->value ).' '. strip_tags( $oShop->oxshops__oxcity->getRawValue() ) );
00757         $oPdf->text( 15, 287, strip_tags( $oShop->oxshops__oxcountry->getRawValue() ) );
00758 
00759         /* column 2 - phone, fax, url, email address */
00760         $oPdf->text( 85, 275, $this->translate( 'ORDER_OVERVIEW_PDF_PHONE' ).strip_tags( $oShop->oxshops__oxtelefon->value ) );
00761         $oPdf->text( 85, 278, $this->translate( 'ORDER_OVERVIEW_PDF_FAX' ).strip_tags( $oShop->oxshops__oxtelefax->value ) );
00762         $oPdf->text( 85, 281, strip_tags( $oShop->oxshops__oxurl->value ) );
00763         $oPdf->text( 85, 284, strip_tags( $oShop->oxshops__oxorderemail->value ) );
00764 
00765         /* column 3 - bank information */
00766         $oPdf->text( 150, 275, strip_tags( $oShop->oxshops__oxbankname->getRawValue() ) );
00767         $oPdf->text( 150, 278, $this->translate( 'ORDER_OVERVIEW_PDF_ACCOUNTNR' ).strip_tags( $oShop->oxshops__oxbanknumber->value ) );
00768         $oPdf->text( 150, 281, $this->translate( 'ORDER_OVERVIEW_PDF_BANKCODE' ).strip_tags( $oShop->oxshops__oxbankcode->value ) );
00769         $oPdf->text( 150, 284, strip_tags( $oShop->oxshops__oxvatnumber->value ) );
00770         $oPdf->text( 150, 287, '' );
00771     }
00772 
00780     public function pdfHeaderPlus( $oPdf )
00781     {
00782 
00783         // new page with shop logo
00784         $this->pdfHeader( $oPdf );
00785 
00786         $oPdfBlock = new PdfBlock();
00787         // column names
00788         $oPdf->setFont( $oPdfBlock->getFont(), '', 8 );
00789         $oPdf->text( 15, 50, $this->translate( 'ORDER_OVERVIEW_PDF_AMOUNT' ) );
00790         $oPdf->text( 30, 50, $this->translate( 'ORDER_OVERVIEW_PDF_ARTID') );
00791         $oPdf->text( 45, 50, $this->translate( 'ORDER_OVERVIEW_PDF_DESC' ) );
00792         $oPdf->text( 160, 50, $this->translate( 'ORDER_OVERVIEW_PDF_UNITPRICE' ) );
00793         $sText = $this->translate( 'ORDER_OVERVIEW_PDF_ALLPRICE' );
00794         $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), 50, $sText );
00795 
00796         // line separator
00797         $oPdf->line( 15, 52, 195, 52 );
00798 
00799         return 56;
00800     }
00801 
00809     public function pdfHeader( $oPdf )
00810     {
00811         // adding new page ...
00812         $oPdf->addPage();
00813 
00814         // loading active shop
00815         $oShop = $this->_getActShop();
00816 
00817         //logo
00818         $myConfig = $this->getConfig();
00819         $aSize    = getimagesize( $myConfig->getImageDir().'/pdf_logo.jpg' );
00820         $iMargin  = 195 - $aSize[0] * 0.2;
00821         $oPdf->setLink( $oShop->oxshops__oxurl->value );
00822         $oPdf->image( $myConfig->getImageDir().'/pdf_logo.jpg', $iMargin, 10, $aSize[0] * 0.2, $aSize[1] * 0.2, '', $oShop->oxshops__oxurl->value );
00823         return 14 + $aSize[1] * 0.2;
00824     }
00825 
00834     public function genPdf( $sFilename, $iSelLang = 0 )
00835     {
00836         // setting pdf language
00837         $this->setSelectedLang( $iSelLang );
00838 
00839         $blIsNewOrder = 0;
00840         // setting invoice number
00841         if ( !$this->oxorder__oxbillnr->value ) {
00842             $this->oxorder__oxbillnr->setValue( $this->getNextBillNum() );
00843             $blIsNewOrder = 1;
00844         }
00845         // setting invoice date
00846         if ( $this->oxorder__oxbilldate->value == '0000-00-00' ) {
00847             $this->oxorder__oxbilldate->setValue( date( 'd.m.Y', mktime( 0, 0, 0, date ( 'm' ), date ( 'd' ), date( 'Y' ) ) ) );
00848             $blIsNewOrder = 1;
00849         }
00850         // saving order if new number or date
00851         if ( $blIsNewOrder ){
00852             $this->save();
00853         }
00854 
00855         // initiating pdf engine
00856         $oPdf = oxNew( 'oxPDF' );
00857         $oPdf->setPrintHeader( false );
00858         $oPdf->open();
00859 
00860         // adding header
00861         $this->pdfHeader( $oPdf );
00862 
00863         // adding info data
00864         switch ( oxConfig::getParameter( 'pdftype' ) ) {
00865             case 'dnote':
00866                 $this->exportDeliveryNote( $oPdf );
00867                 break;
00868             default:
00869                 $this->exportStandart( $oPdf );
00870         }
00871 
00872         // adding footer
00873         $this->pdfFooter( $oPdf );
00874 
00875         // outputting file to browser
00876         $oPdf->output( $sFilename, 'I' );
00877     }
00878 
00879 
00887     protected function _setBillingAddressToPdf( $oPdf )
00888     {
00889         $oLang = oxRegistry::getLang();
00890         $sSal = $this->oxorder__oxbillsal->value;
00891         try {
00892             $sSal = $oLang->translateString($this->oxorder__oxbillsal->value, $this->getSelectedLang());
00893         } catch (Exception $e) {
00894         }
00895         $oPdfBlock = new PdfBlock();
00896         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
00897         $oPdf->text( 15, 59, $sSal);
00898         $oPdf->text( 15, 63, $this->oxorder__oxbillfname->getRawValue().' '.$this->oxorder__oxbilllname->getRawValue() );
00899         $oPdf->text( 15, 67, $this->oxorder__oxbillcompany->getRawValue() );
00900         $oPdf->text( 15, 71, $this->oxorder__oxbillstreet->getRawValue().' '.$this->oxorder__oxbillstreetnr->value );
00901         $oPdf->setFont( $oPdfBlock->getFont(), 'B', 10 );
00902         $oPdf->text( 15, 75, $this->oxorder__oxbillzip->value.' '.$this->oxorder__oxbillcity->getRawValue() );
00903         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
00904         $oPdf->text( 15, 79, $this->oxorder__oxbillcountry->getRawValue() );
00905     }
00906 
00914     protected function _setDeliveryAddressToPdf( $oPdf )
00915     {
00916         $oLang = oxRegistry::getLang();
00917         $sSal = $this->oxorder__oxdelsal->value;
00918         try {
00919             $sSal = $oLang->translateString($this->oxorder__oxdelsal->value, $this->getSelectedLang());
00920         } catch (Exception $e) {
00921         }
00922         $oPdfBlock = new PdfBlock();
00923         $oPdf->setFont( $oPdfBlock->getFont(), '', 6 );
00924         $oPdf->text( 15, 87, $this->translate( 'ORDER_OVERVIEW_PDF_DELIVERYADDRESS' ) );
00925         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
00926         $oPdf->text( 15, 91, $sSal);
00927         $oPdf->text( 15, 95, $this->oxorder__oxdellname->getRawValue().' '.$this->oxorder__oxdelfname->getRawValue() );
00928         $oPdf->text( 15, 99, $this->oxorder__oxdelcompany->getRawValue() );
00929         $oPdf->text( 15, 103, $this->oxorder__oxdelstreet->getRawValue().' '.$this->oxorder__oxdelstreetnr->value );
00930         $oPdf->setFont( $oPdfBlock->getFont(), 'B', 10 );
00931         $oPdf->text( 15, 107, $this->oxorder__oxdelzip->value.' '.$this->oxorder__oxdelcity->getRawValue() );
00932         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
00933         $oPdf->text( 15, 111, $this->oxorder__oxdelcountry->getRawValue() );
00934     }
00935 
00945     protected function _setOrderArticlesToPdf( $oPdf, &$iStartPos, $blShowPrice = true )
00946     {
00947         if (!$this->_oArticles) {
00948             $this->_oArticles = $this->getOrderArticles(true);
00949         }
00950 
00951         $oCurr = $this->getCurrency();
00952         $oPdfBlock = new PdfBlock();
00953         // product list
00954         foreach ( $this->_oArticles as $key => $oOrderArt ) {
00955 
00956             // starting a new page ...
00957             if ( $iStartPos > 243 ) {
00958                 $this->pdffooter( $oPdf );
00959                 $iStartPos = $this->pdfheaderplus( $oPdf );
00960                 $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
00961             } else {
00962                 $iStartPos = $iStartPos + 4;
00963             }
00964 
00965             // sold amount
00966             $oPdf->text( 20 - $oPdf->getStringWidth( $oOrderArt->oxorderarticles__oxamount->value ), $iStartPos, $oOrderArt->oxorderarticles__oxamount->value );
00967 
00968             // product number
00969             $oPdf->setFont( $oPdfBlock->getFont(), '', 8 );
00970             $oPdf->text( 28, $iStartPos, $oOrderArt->oxorderarticles__oxartnum->value );
00971 
00972             // product title
00973             $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
00974             $oPdf->text( 45, $iStartPos, substr( strip_tags( $this->_replaceExtendedChars( $oOrderArt->oxorderarticles__oxtitle->getRawValue(), true ) ), 0, 58 ) );
00975 
00976             if ( $blShowPrice ) {
00977                 $oLang = oxRegistry::getLang();
00978 
00979                 // product VAT percent
00980                 $oPdf->text( 140 - $oPdf->getStringWidth( $oOrderArt->oxorderarticles__oxvat->value ), $iStartPos, $oOrderArt->oxorderarticles__oxvat->value );
00981 
00982                 // product price
00983 
00984                 $dUnitPrice = ($this->isNettoMode()) ? $oOrderArt->oxorderarticles__oxnprice->value : $oOrderArt->oxorderarticles__oxbprice->value;
00985                 $dTotalPrice = ($this->isNettoMode()) ? $oOrderArt->oxorderarticles__oxnetprice->value : $oOrderArt->oxorderarticles__oxbrutprice->value;
00986 
00987                 $sText = $oLang->formatCurrency( $dUnitPrice, $this->_oCur ).' '.$this->_oCur->name;
00988                 $oPdf->text( 163 - $oPdf->getStringWidth( $sText ), $iStartPos, $sText );
00989 
00990                 // total product price
00991                 $sText = $oLang->formatCurrency( $dTotalPrice, $this->_oCur ).' '.$this->_oCur->name;
00992                 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iStartPos, $sText );
00993 
00994             }
00995 
00996             // additional variant info
00997             if ( $oOrderArt->oxorderarticles__oxselvariant->value ) {
00998                 $iStartPos = $iStartPos + 4;
00999                 $oPdf->text( 45, $iStartPos, substr( $oOrderArt->oxorderarticles__oxselvariant->value, 0, 58 ) );
01000             }
01001 
01002         }
01003     }
01004 
01012     public function exportStandart( $oPdf )
01013     {
01014         // preparing order curency info
01015         $myConfig = $this->getConfig();
01016         $oPdfBlock = new PdfBlock();
01017 
01018         $this->_oCur = $myConfig->getCurrencyObject( $this->oxorder__oxcurrency->value );
01019         if ( !$this->_oCur ) {
01020             $this->_oCur = $myConfig->getActShopCurrencyObject();
01021         }
01022 
01023         // loading active shop
01024         $oShop = $this->_getActShop();
01025 
01026         // shop information
01027         $oPdf->setFont( $oPdfBlock->getFont(), '', 6 );
01028         $oPdf->text( 15, 55, $oShop->oxshops__oxname->getRawValue().' - '.$oShop->oxshops__oxstreet->getRawValue().' - '.$oShop->oxshops__oxzip->value.' - '.$oShop->oxshops__oxcity->getRawValue() );
01029 
01030         // billing address
01031         $this->_setBillingAddressToPdf( $oPdf );
01032 
01033         // delivery address
01034         if ( $this->oxorder__oxdelsal->value ) {
01035             $this->_setDeliveryAddressToPdf( $oPdf );
01036         }
01037 
01038         // loading user
01039         $oUser = oxNew( 'oxuser' );
01040         $oUser->load( $this->oxorder__oxuserid->value );
01041 
01042         // user info
01043         $sText = $this->translate( 'ORDER_OVERVIEW_PDF_FILLONPAYMENT' );
01044         $oPdf->setFont( $oPdfBlock->getFont(), '', 5 );
01045         $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), 55, $sText );
01046 
01047         // customer number
01048         $sCustNr = $this->translate( 'ORDER_OVERVIEW_PDF_CUSTNR').' '.$oUser->oxuser__oxcustnr->value;
01049         $oPdf->setFont( $oPdfBlock->getFont(), '', 7 );
01050         $oPdf->text( 195 - $oPdf->getStringWidth( $sCustNr ), 59, $sCustNr );
01051 
01052         // setting position if delivery address is used
01053         if ( $this->oxorder__oxdelsal->value ) {
01054             $iTop = 115;
01055         } else {
01056             $iTop = 91;
01057         }
01058 
01059         // shop city
01060         $sText = $oShop->oxshops__oxcity->getRawValue().', '.date( 'd.m.Y', strtotime($this->oxorder__oxbilldate->value ) );
01061         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
01062         $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop + 8, $sText );
01063 
01064         // shop VAT number
01065         if ( $oShop->oxshops__oxvatnumber->value ) {
01066             $sText = $this->translate( 'ORDER_OVERVIEW_PDF_TAXIDNR' ).' '.$oShop->oxshops__oxvatnumber->value;
01067             $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop + 12, $sText );
01068             $iTop += 8;
01069         } else {
01070             $iTop += 4;
01071         }
01072 
01073         // invoice number
01074         $sText = $this->translate( 'ORDER_OVERVIEW_PDF_COUNTNR' ).' '.$this->oxorder__oxbillnr->value;
01075         $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop + 8, $sText );
01076 
01077         // marking if order is canceled
01078         if ( $this->oxorder__oxstorno->value == 1 ) {
01079             $this->oxorder__oxordernr->setValue( $this->oxorder__oxordernr->getRawValue() . '   '.$this->translate( 'ORDER_OVERVIEW_PDF_STORNO' ), oxField::T_RAW );
01080         }
01081 
01082         // order number
01083         $oPdf->setFont( $oPdfBlock->getFont(), '', 12 );
01084         $oPdf->text( 15, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_PURCHASENR' ).' '.$this->oxorder__oxordernr->value );
01085 
01086         // order date
01087         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
01088         $aOrderDate = explode( ' ', $this->oxorder__oxorderdate->value );
01089         $sOrderDate = oxRegistry::get("oxUtilsDate")->formatDBDate( $aOrderDate[0]);
01090         $oPdf->text( 15, $iTop + 8, $this->translate( 'ORDER_OVERVIEW_PDF_ORDERSFROM' ).$sOrderDate.$this->translate( 'ORDER_OVERVIEW_PDF_ORDERSAT' ).$oShop->oxshops__oxurl->value );
01091         $iTop += 16;
01092 
01093         // product info header
01094         $oPdf->setFont( $oPdfBlock->getFont(), '', 8 );
01095         $oPdf->text( 15, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_AMOUNT' ) );
01096         $oPdf->text( 30, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_ARTID' ) );
01097         $oPdf->text( 45, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_DESC' ) );
01098         $oPdf->text( 135, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_VAT' ) );
01099         $oPdf->text( 148, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_UNITPRICE' ) );
01100         $sText = $this->translate( 'ORDER_OVERVIEW_PDF_ALLPRICE' );
01101         $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop, $sText );
01102 
01103         // separator line
01104         $iTop += 2;
01105         $oPdf->line( 15, $iTop, 195, $iTop );
01106 
01107         // #345
01108         $siteH = $iTop;
01109         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
01110 
01111         // order articles
01112         $this->_setOrderArticlesToPdf( $oPdf, $siteH, true );
01113 
01114         // generating pdf file
01115         $oArtSumm = new PdfArticleSummary( $this, $oPdf );
01116         $iHeight = $oArtSumm->generate( $siteH );
01117         if ( $siteH + $iHeight > 258 ) {
01118             $this->pdfFooter( $oPdf );
01119             $iTop = $this->pdfHeader( $oPdf );
01120             $oArtSumm->ajustHeight( $iTop - $siteH );
01121             $siteH = $iTop;
01122         }
01123 
01124         $oArtSumm->run( $oPdf );
01125         $siteH += $iHeight + 8;
01126 
01127         $oPdf->text( 15, $siteH, $this->translate( 'ORDER_OVERVIEW_PDF_GREETINGS' ) );
01128     }
01129 
01137     public function exportDeliveryNote( $oPdf )
01138     {
01139         $myConfig = $this->getConfig();
01140         $oShop    = $this->_getActShop();
01141         $oPdfBlock = new PdfBlock();
01142 
01143         $oLang = oxRegistry::getLang();
01144         $sSal = $this->oxorder__oxdelsal->value;
01145         try {
01146             $sSal = $oLang->translateString($this->oxorder__oxdelsal->value, $this->getSelectedLang());
01147         } catch (Exception $e) {
01148         }
01149 
01150         // loading order currency info
01151         $this->_oCur = $myConfig->getCurrencyObject( $this->oxorder__oxcurrency->value );
01152         if ( !isset( $this->_oCur ) ) {
01153             $this->_oCur = $myConfig->getActShopCurrencyObject();
01154         }
01155 
01156         // shop info
01157         $oPdf->setFont( $oPdfBlock->getFont(), '', 6 );
01158         $oPdf->text( 15, 55, $oShop->oxshops__oxname->getRawValue().' - '.$oShop->oxshops__oxstreet->getRawValue().' - '.$oShop->oxshops__oxzip->value.' - '.$oShop->oxshops__oxcity->getRawValue() );
01159 
01160         // delivery address
01161         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
01162         if ( $this->oxorder__oxdelsal->value ) {
01163             $oPdf->text( 15, 59, $sSal );
01164             $oPdf->text( 15, 63, $this->oxorder__oxdellname->getRawValue().' '.$this->oxorder__oxdelfname->getRawValue() );
01165             $oPdf->text( 15, 67, $this->oxorder__oxdelcompany->getRawValue() );
01166             $oPdf->text( 15, 71, $this->oxorder__oxdelstreet->getRawValue().' '.$this->oxorder__oxdelstreetnr->value );
01167             $oPdf->setFont( $oPdfBlock->getFont(), 'B', 10 );
01168             $oPdf->text( 15, 75, $this->oxorder__oxdelzip->value.' '.$this->oxorder__oxdelcity->getRawValue() );
01169             $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
01170             $oPdf->text( 15, 79, $this->oxorder__oxdelcountry->getRawValue() );
01171         } else {
01172             // no delivery address - billing address is used for delivery
01173             $this->_setBillingAddressToPdf( $oPdf );
01174         }
01175 
01176         // loading user info
01177         $oUser = oxNew( 'oxuser' );
01178         $oUser->load( $this->oxorder__oxuserid->value );
01179 
01180         // user info
01181         $sText = $this->translate( 'ORDER_OVERVIEW_PDF_FILLONPAYMENT' );
01182         $oPdf->setFont( $oPdfBlock->getFont(), '', 5 );
01183         $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), 70, $sText );
01184 
01185         // customer number
01186         $sCustNr = $this->translate( 'ORDER_OVERVIEW_PDF_CUSTNR' ).' '.$oUser->oxuser__oxcustnr->value;
01187         $oPdf->setFont( $oPdfBlock->getFont(), '', 7 );
01188         $oPdf->text( 195 - $oPdf->getStringWidth( $sCustNr ), 73, $sCustNr );
01189 
01190         // shops city
01191         $sText = $oShop->oxshops__oxcity->getRawValue().', '.date( 'd.m.Y' );
01192         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
01193         $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), 95, $sText );
01194 
01195         $iTop = 99;
01196         // shop VAT number
01197         if ( $oShop->oxshops__oxvatnumber->value ) {
01198             $sText = $this->translate( 'ORDER_OVERVIEW_PDF_TAXIDNR' ).' '.$oShop->oxshops__oxvatnumber->value;
01199             $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop, $sText );
01200             $iTop += 4;
01201         }
01202 
01203         // invoice number
01204         $sText = $this->translate( 'ORDER_OVERVIEW_PDF_COUNTNR' ).' '.$this->oxorder__oxbillnr->value;
01205         $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop, $sText );
01206 
01207         // canceled order marker
01208         if ( $this->oxorder__oxstorno->value == 1 ) {
01209             $this->oxorder__oxordernr->setValue( $this->oxorder__oxordernr->getRawValue() . '   '.$this->translate( 'ORDER_OVERVIEW_PDF_STORNO' ), oxField::T_RAW );
01210         }
01211 
01212         // order number
01213         $oPdf->setFont( $oPdfBlock->getFont(), '', 12 );
01214         $oPdf->text( 15, 108, $this->translate( 'ORDER_OVERVIEW_PDF_DELIVNOTE' ).' '.$this->oxorder__oxordernr->value );
01215 
01216         // order date
01217         $aOrderDate = explode( ' ', $this->oxorder__oxorderdate->value );
01218         $sOrderDate = oxRegistry::get("oxUtilsDate")->formatDBDate( $aOrderDate[0]);
01219         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
01220         $oPdf->text(15, 119, $this->translate( 'ORDER_OVERVIEW_PDF_ORDERSFROM' ).$sOrderDate.$this->translate( 'ORDER_OVERVIEW_PDF_ORDERSAT' ).$oShop->oxshops__oxurl->value );
01221 
01222         // product info header
01223         $oPdf->setFont( $oPdfBlock->getFont(), '', 8 );
01224         $oPdf->text( 15, 128, $this->translate( 'ORDER_OVERVIEW_PDF_AMOUNT' ) );
01225         $oPdf->text( 30, 128, $this->translate( 'ORDER_OVERVIEW_PDF_ARTID' ) );
01226         $oPdf->text( 45, 128, $this->translate( 'ORDER_OVERVIEW_PDF_DESC' ) );
01227 
01228         // line separator
01229         $oPdf->line( 15, 130, 195, 130 );
01230 
01231         // product list
01232         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
01233         $siteH = 130;
01234 
01235         // order articles
01236         $this->_setOrderArticlesToPdf( $oPdf, $siteH, false );
01237 
01238         // sine separator
01239         $oPdf->line( 15, $siteH + 2, 195, $siteH + 2 );
01240         $siteH += 4;
01241 
01242         // payment date
01243         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
01244         $text = $this->translate( 'ORDER_OVERVIEW_PDF_PAYUPTO' ) . date( 'd.m.Y', strtotime( '+' . $this->getPaymentTerm() . ' day', strtotime( $this->oxorder__oxbilldate->value ) ) );
01245         $oPdf->text( 15, $siteH + 4, $text );
01246     }
01247 
01257     protected function _replaceExtendedChars( $sValue, $blReverse = false )
01258     {
01259         // we need to replace this for compatibility with XHTML
01260         // as this function causes a lot of trouble with editor
01261         // we switch it off, even if this means that fields do not validate through xhtml
01262         // return $sValue;
01263 
01264         // we need to replace this for compatibility with XHTML
01265         $aReplace = array( chr(169) => "&copy;", chr(128) => "&euro;", "\"" => "&quot;", "'" => "&#039;");
01266 
01267         // #899C reverse html entities and references transformation is used in invoicepdf module
01268         // so this part must be enabled. Now it works with html references like &#123;
01269         if ($blReverse) {
01270             // replace now
01271             if (version_compare(PHP_VERSION, '5.3.4') >= 0) {
01272                 $aTransTbl = get_html_translation_table (HTML_ENTITIES, ENT_COMPAT, 'ISO-8859-1');
01273             } else {
01274                 $aTransTbl = get_html_translation_table (HTML_ENTITIES, ENT_COMPAT);
01275             }
01276 
01277             $aTransTbl = array_flip ($aTransTbl) + array_flip ($aReplace);
01278             $sValue = strtr($sValue, $aTransTbl);
01279             $sValue = getStr()->preg_replace('/\&\#([0-9]+)\;/me', "chr('\\1')", $sValue);
01280         }
01281 
01282         return $sValue;
01283     }
01284 
01290     public function getVats()
01291     {
01292         // for older orders
01293         return $this->getProductVats( false );
01294     }
01295 
01301     public function getCurrency()
01302     {
01303         return $this->_oCur;
01304     }
01305 
01311     public function getSelectedLang()
01312     {
01313         return $this->_iSelectedLang;
01314     }
01315 
01321     public function getPaymentTerm()
01322     {
01323         if ( null === $iPaymentTerm = $this->getConfig()->getConfigParam( 'iPaymentTerm' ) ) {
01324             $iPaymentTerm = 7;
01325         }
01326 
01327         return $iPaymentTerm;
01328     }
01329 }