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 || $this->_oData->oxorder__oxgiftcardcost->value ) {
00383             $oLang = oxRegistry::getLang();
00384             $oConfig = oxRegistry::getConfig();
00385 
00386             //displaying wrapping VAT info
00387             if ( $oConfig->getConfigParam('blShowVATForWrapping') ) {
00388 
00389                 if ($this->_oData->oxorder__oxwrapcost->value) {
00390                     // wrapping netto
00391                     $iStartPos += 4;
00392                     $sWrapCostNetto = $oLang->formatCurrency( $this->_oData->getOrderWrappingPrice()->getNettoPrice(), $this->_oData->getCurrency()).' '.$this->_oData->getCurrency()->name;
00393                     $this->text( 45, $iStartPos, $this->_oData->translate( 'WRAPPING_COSTS' ).' '.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_NETTO' ) );
00394                     $this->text( 195 - $this->_oPdf->getStringWidth( $sWrapCostNetto ), $iStartPos, $sWrapCostNetto );
00395                     //$iStartPos++;
00396 
00397                     //wrapping VAT
00398                     $iStartPos += 4;
00399                     $sWrapCostVAT = $oLang->formatCurrency( $this->_oData->getOrderWrappingPrice()->getVATValue(), $this->_oData->getCurrency()).' '.$this->_oData->getCurrency()->name;
00400                     $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ) );
00401                     $this->text( 195 - $this->_oPdf->getStringWidth( $sWrapCostVAT ), $iStartPos, $sWrapCostVAT );
00402                    // $iStartPos++;
00403                 }
00404 
00405                 if ($this->_oData->oxorder__oxgiftcardcost->value) {
00406                     // wrapping netto
00407                     $iStartPos += 4;
00408                     $sWrapCostNetto = $oLang->formatCurrency( $this->_oData->getOrderGiftCardPrice()->getNettoPrice(), $this->_oData->getCurrency()).' '.$this->_oData->getCurrency()->name;
00409                     $this->text( 45, $iStartPos, $this->_oData->translate( 'GIFTCARD_COSTS' ).' '.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_NETTO' ) );
00410                     $this->text( 195 - $this->_oPdf->getStringWidth( $sWrapCostNetto ), $iStartPos, $sWrapCostNetto );
00411                     //$iStartPos++;
00412 
00413                     //wrapping VAT
00414                     $iStartPos += 4;
00415                     $sWrapCostVAT = $oLang->formatCurrency( $this->_oData->getOrderGiftCardPrice()->getVATValue(), $this->_oData->getCurrency()).' '.$this->_oData->getCurrency()->name;
00416 
00417                     if ( $oConfig->getConfigParam('sAdditionalServVATCalcMethod') != 'proportional' ) {
00418                         $sVatValueText = $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ) .$this->_oData->oxorder__oxgiftcardvat->value.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_PERCENTSUM' );
00419                     } else {
00420                         $sVatValueText = $this->_oData->translate( 'TOTAL_PLUS_PROPORTIONAL_VAT' );
00421                     }
00422 
00423                     $this->text( 45, $iStartPos, $sVatValueText );
00424                     $this->text( 195 - $this->_oPdf->getStringWidth( $sWrapCostVAT ), $iStartPos, $sWrapCostVAT );
00425                     $iStartPos++;
00426                 }
00427 
00428             } else {
00429                 $sAddString = ' '.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_BRUTTO' );
00430 
00431                 if ($this->_oData->oxorder__oxwrapcost->value) {
00432                     $iStartPos += 4;
00433                     // wrapping cost
00434                     $sWrapCost = $oLang->formatCurrency( $this->_oData->oxorder__oxwrapcost->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00435                     $this->text( 45, $iStartPos, $this->_oData->translate( 'WRAPPING_COSTS'/*'ORDER_OVERVIEW_PDF_WRAPPING'*/ ).$sAddString );
00436                     $this->text( 195 - $this->_oPdf->getStringWidth( $sWrapCost ), $iStartPos, $sWrapCost );
00437                     $iStartPos++;
00438                 }
00439 
00440                 if ($this->_oData->oxorder__oxgiftcardcost->value) {
00441                     $iStartPos += 4;
00442                     // gift card cost
00443                     $sWrapCost = $oLang->formatCurrency( $this->_oData->oxorder__oxgiftcardcost->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00444                     $this->text( 45, $iStartPos, $this->_oData->translate( 'GIFTCARD_COSTS' ).$sAddString );
00445                     $this->text( 195 - $this->_oPdf->getStringWidth( $sWrapCost ), $iStartPos, $sWrapCost );
00446                     $iStartPos++;
00447                 }
00448             }
00449         }
00450     }
00451 
00459     protected function _setPaymentInfo( &$iStartPos )
00460     {
00461         $oLang = oxRegistry::getLang();
00462         $oConfig = oxRegistry::getConfig();
00463 
00464         if ( $this->_oData->oxorder__oxstorno->value ) {
00465                 $this->_oData->oxorder__oxpaycost->setValue(0);
00466         }
00467 
00468         if ($oConfig->getConfigParam('blShowVATForDelivery')) {
00469             if ( $this->_oData->oxorder__oxpayvat->value ) {
00470                 // payment netto
00471                 $iStartPos += 4;
00472                 $sPayCostNetto = $oLang->formatCurrency( $this->_oData->getOrderPaymentPrice()->getNettoPrice(), $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00473                 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_PAYMENTIMPACT' ).' '.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_NETTO' ) );
00474                 $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCostNetto ), $iStartPos, $sPayCostNetto );
00475 
00476                 if ( $oConfig->getConfigParam('sAdditionalServVATCalcMethod') != 'proportional' ) {
00477                     $sVatValueText = $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ).$this->_oData->oxorder__oxpayvat->value.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_PERCENTSUM' );
00478                 } else {
00479                     $sVatValueText = $this->_oData->translate( 'TOTAL_PLUS_PROPORTIONAL_VAT' );
00480                 }
00481 
00482                 // payment VAT
00483                 $iStartPos += 4;
00484                 $sPayCostVAT = $oLang->formatCurrency( $this->_oData->getOrderPaymentPrice()->getVATValue(), $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00485                 $this->text( 45, $iStartPos, $sVatValueText );
00486                 $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCostVAT ), $iStartPos, $sPayCostVAT );
00487 
00488             }
00489 
00490             // if canceled order, reset value
00491 
00492         } else {
00493 
00494             // payment costs
00495             if ( $this->_oData->oxorder__oxpaycost->value ) {
00496                 $iStartPos += 4;
00497                 $sPayCost = $oLang->formatCurrency( $this->_oData->oxorder__oxpaycost->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00498                 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_PAYMENTIMPACT' ) );
00499                 $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCost ), $iStartPos, $sPayCost );
00500             }
00501 
00502             $iStartPos++;
00503         }
00504     }
00505 
00513     protected function _setTsProtection( &$iStartPos )
00514     {
00515         $oLang   = oxRegistry::getLang();
00516         $oConfig = oxRegistry::getConfig();
00517         if ( $this->_oData->oxorder__oxtsprotectcosts->value && $oConfig->getConfigParam( 'blShowVATForPayCharge' ) ) {
00518 
00519             // payment netto
00520             $iStartPos += 4;
00521             $sPayCostNetto = $oLang->formatCurrency( $this->_oData->getOrderTsProtectionPrice()->getNettoPrice(), $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00522             $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_TSPROTECTION' ).' '.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_NETTO' ) );
00523             $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCostNetto ), $iStartPos, $sPayCostNetto );
00524 
00525             // payment VAT
00526             $iStartPos += 4;
00527             $sPayCostVAT = $oLang->formatCurrency( $this->_oData->getOrderTsProtectionPrice()->getVATValue(), $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00528             $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ).$oConfig->getConfigParam( 'dDefaultVAT' ).$this->_oData->translate( 'ORDER_OVERVIEW_PDF_PERCENTSUM' ) );
00529             $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCostVAT ), $iStartPos, $sPayCostVAT );
00530 
00531             $iStartPos++;
00532 
00533         } elseif ( $this->_oData->oxorder__oxtsprotectcosts->value ) {
00534 
00535             $iStartPos += 4;
00536             $sPayCost = $oLang->formatCurrency( $this->_oData->oxorder__oxtsprotectcosts->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00537             $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_TSPROTECTION' ) );
00538             $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCost ), $iStartPos, $sPayCost );
00539 
00540             $iStartPos++;
00541         }
00542     }
00543 
00551     protected function _setGrandTotalPriceInfo( &$iStartPos )
00552     {
00553         $this->font( $this->getFont(), 'B', 10 );
00554 
00555         // total order sum
00556         $sTotalOrderSum = $this->_oData->getFormattedTotalOrderSum() . ' ' . $this->_oData->getCurrency()->name;
00557         $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLSUM' ) );
00558         $this->text( 195 - $this->_oPdf->getStringWidth( $sTotalOrderSum ), $iStartPos, $sTotalOrderSum );
00559         $iStartPos += 2;
00560 
00561         if ( $this->_oData->oxorder__oxdelvat->value || $this->_oData->oxorder__oxwrapvat->value || $this->_oData->oxorder__oxpayvat->value ) {
00562             $iStartPos += 2;
00563         }
00564     }
00565 
00573     protected function _setPaymentMethodInfo( &$iStartPos )
00574     {
00575         $oPayment = oxNew( 'oxpayment' );
00576         $oPayment->loadInLang( $this->_oData->getSelectedLang(), $this->_oData->oxorder__oxpaymenttype->value );
00577 
00578         $text = $this->_oData->translate( 'ORDER_OVERVIEW_PDF_SELPAYMENT' ).$oPayment->oxpayments__oxdesc->value;
00579         $this->font( $this->getFont(), '', 10 );
00580         $this->text( 15, $iStartPos + 4, $text );
00581         $iStartPos += 4;
00582     }
00583 
00591     protected function _setPayUntilInfo( &$iStartPos )
00592     {
00593         $text = $this->_oData->translate( 'ORDER_OVERVIEW_PDF_PAYUPTO' ) . date( 'd.m.Y', strtotime( '+' . $this->_oData->getPaymentTerm() . ' day', strtotime( $this->_oData->oxorder__oxbilldate->value ) ) );
00594         $this->font( $this->getFont(), '', 10 );
00595         $this->text( 15, $iStartPos + 4, $text );
00596         $iStartPos += 4;
00597     }
00598 
00606     public function generate( $iStartPos )
00607     {
00608 
00609         $this->font( $this->getFont(), '', 10 );
00610         $siteH = $iStartPos;
00611 
00612         // #1147 discount for vat must be displayed
00613         if ( !$this->_oData->oxorder__oxdiscount->value ) {
00614             $this->_setTotalCostsWithoutDiscount( $siteH );
00615         } else {
00616             $this->_setTotalCostsWithDiscount( $siteH );
00617         }
00618 
00619         $siteH += 12;
00620 
00621         // voucher info
00622         $this->_setVoucherInfo( $siteH );
00623 
00624         // additional line separator
00625         if ( $this->_oData->oxorder__oxdiscount->value || $this->_oData->oxorder__oxvoucherdiscount->value ) {
00626             $this->line( 45, $siteH - 3, 195, $siteH - 3 );
00627         }
00628 
00629         // delivery info
00630         $this->_setDeliveryInfo( $siteH );
00631 
00632         // payment info
00633         $this->_setPaymentInfo( $siteH );
00634 
00635         // wrapping info
00636         $this->_setWrappingInfo( $siteH );
00637 
00638         // TS protection info
00639         $this->_setTsProtection( $siteH );
00640 
00641         // separating line
00642         $this->line( 15, $siteH, 195, $siteH );
00643         $siteH += 4;
00644 
00645         // total order sum
00646         $this->_setGrandTotalPriceInfo( $siteH );
00647 
00648         // separating line
00649         $this->line( 15, $siteH, 195, $siteH );
00650         $siteH += 4;
00651 
00652         // payment method
00653         $this->_setPaymentMethodInfo( $siteH );
00654 
00655         // pay until ...
00656         $this->_setPayUntilInfo( $siteH );
00657 
00658         return $siteH - $iStartPos;
00659     }
00660 }
00661 
00665 class MyOrder extends MyOrder_parent
00666 {
00667 
00672     protected $_iSelectedLang = 0;
00673 
00678     protected $_oActShop = null;
00679 
00684     protected $_aVATs = array();
00685 
00690     protected $_oCur = null;
00691 
00692 
00698     public function setSelectedLang( $iLang )
00699     {
00700        $this->_iSelectedLang = $iLang;
00701     }
00702 
00708     protected function _getActShop()
00709     {
00710         // shop is allready loaded
00711         if ( $this->_oActShop !== null )
00712             return $this->_oActShop;
00713 
00714         $this->_oActShop = oxNew( 'oxshop' );
00715         $this->_oActShop->load( $this->getConfig()->getShopId() );
00716 
00717         return $this->_oActShop;
00718     }
00719 
00727     public function translate( $sString )
00728     {
00729         return oxRegistry::getLang()->translateString( $sString, $this->getSelectedLang() );
00730     }
00731 
00739     public function pdfFooter( $oPdf )
00740     {
00741 
00742         $oShop = $this->_getActShop();
00743 
00744         $oPdf->line( 15, 272, 195, 272 );
00745 
00746         $oPdfBlock = new PdfBlock();
00747         /* column 1 - company name, shop owner info, shop address */
00748         $oPdf->setFont( $oPdfBlock->getFont(), '', 7 );
00749         $oPdf->text( 15, 275, strip_tags( $oShop->oxshops__oxcompany->getRawValue() ) );
00750         $oPdf->text( 15, 278, strip_tags( $oShop->oxshops__oxfname->getRawValue() ).' '. strip_tags( $oShop->oxshops__oxlname->getRawValue() ) );
00751         $oPdf->text( 15, 281, strip_tags( $oShop->oxshops__oxstreet->getRawValue() ) );
00752         $oPdf->text( 15, 284, strip_tags( $oShop->oxshops__oxzip->value ).' '. strip_tags( $oShop->oxshops__oxcity->getRawValue() ) );
00753         $oPdf->text( 15, 287, strip_tags( $oShop->oxshops__oxcountry->getRawValue() ) );
00754 
00755         /* column 2 - phone, fax, url, email address */
00756         $oPdf->text( 85, 275, $this->translate( 'ORDER_OVERVIEW_PDF_PHONE' ).strip_tags( $oShop->oxshops__oxtelefon->value ) );
00757         $oPdf->text( 85, 278, $this->translate( 'ORDER_OVERVIEW_PDF_FAX' ).strip_tags( $oShop->oxshops__oxtelefax->value ) );
00758         $oPdf->text( 85, 281, strip_tags( $oShop->oxshops__oxurl->value ) );
00759         $oPdf->text( 85, 284, strip_tags( $oShop->oxshops__oxorderemail->value ) );
00760 
00761         /* column 3 - bank information */
00762         $oPdf->text( 150, 275, strip_tags( $oShop->oxshops__oxbankname->getRawValue() ) );
00763         $oPdf->text( 150, 278, $this->translate( 'ORDER_OVERVIEW_PDF_ACCOUNTNR' ).strip_tags( $oShop->oxshops__oxbanknumber->value ) );
00764         $oPdf->text( 150, 281, $this->translate( 'ORDER_OVERVIEW_PDF_BANKCODE' ).strip_tags( $oShop->oxshops__oxbankcode->value ) );
00765         $oPdf->text( 150, 284, strip_tags( $oShop->oxshops__oxvatnumber->value ) );
00766         $oPdf->text( 150, 287, '' );
00767     }
00768 
00776     public function pdfHeaderPlus( $oPdf )
00777     {
00778 
00779         // new page with shop logo
00780         $this->pdfHeader( $oPdf );
00781 
00782         $oPdfBlock = new PdfBlock();
00783         // column names
00784         $oPdf->setFont( $oPdfBlock->getFont(), '', 8 );
00785         $oPdf->text( 15, 50, $this->translate( 'ORDER_OVERVIEW_PDF_AMOUNT' ) );
00786         $oPdf->text( 30, 50, $this->translate( 'ORDER_OVERVIEW_PDF_ARTID') );
00787         $oPdf->text( 45, 50, $this->translate( 'ORDER_OVERVIEW_PDF_DESC' ) );
00788         $oPdf->text( 160, 50, $this->translate( 'ORDER_OVERVIEW_PDF_UNITPRICE' ) );
00789         $sText = $this->translate( 'ORDER_OVERVIEW_PDF_ALLPRICE' );
00790         $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), 50, $sText );
00791 
00792         // line separator
00793         $oPdf->line( 15, 52, 195, 52 );
00794 
00795         return 56;
00796     }
00797 
00805     public function pdfHeader( $oPdf )
00806     {
00807         // adding new page ...
00808         $oPdf->addPage();
00809 
00810         // loading active shop
00811         $oShop = $this->_getActShop();
00812 
00813         //logo
00814         $myConfig = $this->getConfig();
00815         $aSize    = getimagesize( $myConfig->getImageDir().'/pdf_logo.jpg' );
00816         $iMargin  = 195 - $aSize[0] * 0.2;
00817         $oPdf->setLink( $oShop->oxshops__oxurl->value );
00818         $oPdf->image( $myConfig->getImageDir().'/pdf_logo.jpg', $iMargin, 10, $aSize[0] * 0.2, $aSize[1] * 0.2, '', $oShop->oxshops__oxurl->value );
00819         return 14 + $aSize[1] * 0.2;
00820     }
00821 
00830     public function genPdf( $sFilename, $iSelLang = 0 )
00831     {
00832         // setting pdf language
00833         $this->setSelectedLang( $iSelLang );
00834 
00835         $blIsNewOrder = 0;
00836         // setting invoice number
00837         if ( !$this->oxorder__oxbillnr->value ) {
00838             $this->oxorder__oxbillnr->setValue( $this->getNextBillNum() );
00839             $blIsNewOrder = 1;
00840         }
00841         // setting invoice date
00842         if ( $this->oxorder__oxbilldate->value == '0000-00-00' ) {
00843             $this->oxorder__oxbilldate->setValue( date( 'Y-m-d', mktime( 0, 0, 0, date ( 'm' ), date ( 'd' ), date( 'Y' ) ) ) );
00844             $blIsNewOrder = 1;
00845         }
00846         // saving order if new number or date
00847         if ( $blIsNewOrder ){
00848             $this->save();
00849         }
00850 
00851         // initiating pdf engine
00852         $oPdf = oxNew( 'oxPDF' );
00853         $oPdf->setPrintHeader( false );
00854         $oPdf->open();
00855 
00856         // adding header
00857         $this->pdfHeader( $oPdf );
00858 
00859         // adding info data
00860         switch ( oxConfig::getParameter( 'pdftype' ) ) {
00861             case 'dnote':
00862                 $this->exportDeliveryNote( $oPdf );
00863                 break;
00864             default:
00865                 $this->exportStandart( $oPdf );
00866         }
00867 
00868         // adding footer
00869         $this->pdfFooter( $oPdf );
00870 
00871         // outputting file to browser
00872         $oPdf->output( $sFilename, 'I' );
00873     }
00874 
00875 
00883     protected function _setBillingAddressToPdf( $oPdf )
00884     {
00885         $oLang = oxRegistry::getLang();
00886         $sSal = $this->oxorder__oxbillsal->value;
00887         try {
00888             $sSal = $oLang->translateString($this->oxorder__oxbillsal->value, $this->getSelectedLang());
00889         } catch (Exception $e) {
00890         }
00891         $oPdfBlock = new PdfBlock();
00892         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
00893         $oPdf->text( 15, 59, $sSal);
00894         $oPdf->text( 15, 63, $this->oxorder__oxbillfname->getRawValue().' '.$this->oxorder__oxbilllname->getRawValue() );
00895         $oPdf->text( 15, 67, $this->oxorder__oxbillcompany->getRawValue() );
00896         $oPdf->text( 15, 71, $this->oxorder__oxbillstreet->getRawValue().' '.$this->oxorder__oxbillstreetnr->value );
00897         $oPdf->setFont( $oPdfBlock->getFont(), 'B', 10 );
00898         $oPdf->text( 15, 75, $this->oxorder__oxbillzip->value.' '.$this->oxorder__oxbillcity->getRawValue() );
00899         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
00900         $oPdf->text( 15, 79, $this->oxorder__oxbillcountry->getRawValue() );
00901     }
00902 
00910     protected function _setDeliveryAddressToPdf( $oPdf )
00911     {
00912         $oLang = oxRegistry::getLang();
00913         $sSal = $this->oxorder__oxdelsal->value;
00914         try {
00915             $sSal = $oLang->translateString($this->oxorder__oxdelsal->value, $this->getSelectedLang());
00916         } catch (Exception $e) {
00917         }
00918         $oPdfBlock = new PdfBlock();
00919         $oPdf->setFont( $oPdfBlock->getFont(), '', 6 );
00920         $oPdf->text( 15, 87, $this->translate( 'ORDER_OVERVIEW_PDF_DELIVERYADDRESS' ) );
00921         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
00922         $oPdf->text( 15, 91, $sSal);
00923         $oPdf->text( 15, 95, $this->oxorder__oxdellname->getRawValue().' '.$this->oxorder__oxdelfname->getRawValue() );
00924         $oPdf->text( 15, 99, $this->oxorder__oxdelcompany->getRawValue() );
00925         $oPdf->text( 15, 103, $this->oxorder__oxdelstreet->getRawValue().' '.$this->oxorder__oxdelstreetnr->value );
00926         $oPdf->setFont( $oPdfBlock->getFont(), 'B', 10 );
00927         $oPdf->text( 15, 107, $this->oxorder__oxdelzip->value.' '.$this->oxorder__oxdelcity->getRawValue() );
00928         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
00929         $oPdf->text( 15, 111, $this->oxorder__oxdelcountry->getRawValue() );
00930     }
00931 
00941     protected function _setOrderArticlesToPdf( $oPdf, &$iStartPos, $blShowPrice = true )
00942     {
00943         if (!$this->_oArticles) {
00944             $this->_oArticles = $this->getOrderArticles(true);
00945         }
00946 
00947         $oCurr = $this->getCurrency();
00948         $oPdfBlock = new PdfBlock();
00949         // product list
00950         foreach ( $this->_oArticles as $key => $oOrderArt ) {
00951 
00952             // starting a new page ...
00953             if ( $iStartPos > 243 ) {
00954                 $this->pdffooter( $oPdf );
00955                 $iStartPos = $this->pdfheaderplus( $oPdf );
00956                 $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
00957             } else {
00958                 $iStartPos = $iStartPos + 4;
00959             }
00960 
00961             // sold amount
00962             $oPdf->text( 20 - $oPdf->getStringWidth( $oOrderArt->oxorderarticles__oxamount->value ), $iStartPos, $oOrderArt->oxorderarticles__oxamount->value );
00963 
00964             // product number
00965             $oPdf->setFont( $oPdfBlock->getFont(), '', 8 );
00966             $oPdf->text( 28, $iStartPos, $oOrderArt->oxorderarticles__oxartnum->value );
00967 
00968             // product title
00969             $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
00970             $oPdf->text( 45, $iStartPos, substr( strip_tags( $this->_replaceExtendedChars( $oOrderArt->oxorderarticles__oxtitle->getRawValue(), true ) ), 0, 58 ) );
00971 
00972             if ( $blShowPrice ) {
00973                 $oLang = oxRegistry::getLang();
00974 
00975                 // product VAT percent
00976                 $oPdf->text( 140 - $oPdf->getStringWidth( $oOrderArt->oxorderarticles__oxvat->value ), $iStartPos, $oOrderArt->oxorderarticles__oxvat->value );
00977 
00978                 // product price
00979 
00980                 $dUnitPrice = ($this->isNettoMode()) ? $oOrderArt->oxorderarticles__oxnprice->value : $oOrderArt->oxorderarticles__oxbprice->value;
00981                 $dTotalPrice = ($this->isNettoMode()) ? $oOrderArt->oxorderarticles__oxnetprice->value : $oOrderArt->oxorderarticles__oxbrutprice->value;
00982 
00983                 $sText = $oLang->formatCurrency( $dUnitPrice, $this->_oCur ).' '.$this->_oCur->name;
00984                 $oPdf->text( 163 - $oPdf->getStringWidth( $sText ), $iStartPos, $sText );
00985 
00986                 // total product price
00987                 $sText = $oLang->formatCurrency( $dTotalPrice, $this->_oCur ).' '.$this->_oCur->name;
00988                 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iStartPos, $sText );
00989 
00990             }
00991 
00992             // additional variant info
00993             if ( $oOrderArt->oxorderarticles__oxselvariant->value ) {
00994                 $iStartPos = $iStartPos + 4;
00995                 $oPdf->text( 45, $iStartPos, substr( $oOrderArt->oxorderarticles__oxselvariant->value, 0, 58 ) );
00996             }
00997 
00998         }
00999     }
01000 
01008     public function exportStandart( $oPdf )
01009     {
01010         // preparing order curency info
01011         $myConfig = $this->getConfig();
01012         $oPdfBlock = new PdfBlock();
01013 
01014         $this->_oCur = $myConfig->getCurrencyObject( $this->oxorder__oxcurrency->value );
01015         if ( !$this->_oCur ) {
01016             $this->_oCur = $myConfig->getActShopCurrencyObject();
01017         }
01018 
01019         // loading active shop
01020         $oShop = $this->_getActShop();
01021 
01022         // shop information
01023         $oPdf->setFont( $oPdfBlock->getFont(), '', 6 );
01024         $oPdf->text( 15, 55, $oShop->oxshops__oxname->getRawValue().' - '.$oShop->oxshops__oxstreet->getRawValue().' - '.$oShop->oxshops__oxzip->value.' - '.$oShop->oxshops__oxcity->getRawValue() );
01025 
01026         // billing address
01027         $this->_setBillingAddressToPdf( $oPdf );
01028 
01029         // delivery address
01030         if ( $this->oxorder__oxdelsal->value ) {
01031             $this->_setDeliveryAddressToPdf( $oPdf );
01032         }
01033 
01034         // loading user
01035         $oUser = oxNew( 'oxuser' );
01036         $oUser->load( $this->oxorder__oxuserid->value );
01037 
01038         // user info
01039         $sText = $this->translate( 'ORDER_OVERVIEW_PDF_FILLONPAYMENT' );
01040         $oPdf->setFont( $oPdfBlock->getFont(), '', 5 );
01041         $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), 55, $sText );
01042 
01043         // customer number
01044         $sCustNr = $this->translate( 'ORDER_OVERVIEW_PDF_CUSTNR').' '.$oUser->oxuser__oxcustnr->value;
01045         $oPdf->setFont( $oPdfBlock->getFont(), '', 7 );
01046         $oPdf->text( 195 - $oPdf->getStringWidth( $sCustNr ), 59, $sCustNr );
01047 
01048         // setting position if delivery address is used
01049         if ( $this->oxorder__oxdelsal->value ) {
01050             $iTop = 115;
01051         } else {
01052             $iTop = 91;
01053         }
01054 
01055         // shop city
01056         $sText = $oShop->oxshops__oxcity->getRawValue().', '.date( 'd.m.Y', strtotime($this->oxorder__oxbilldate->value ) );
01057         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
01058         $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop + 8, $sText );
01059 
01060         // shop VAT number
01061         if ( $oShop->oxshops__oxvatnumber->value ) {
01062             $sText = $this->translate( 'ORDER_OVERVIEW_PDF_TAXIDNR' ).' '.$oShop->oxshops__oxvatnumber->value;
01063             $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop + 12, $sText );
01064             $iTop += 8;
01065         } else {
01066             $iTop += 4;
01067         }
01068 
01069         // invoice number
01070         $sText = $this->translate( 'ORDER_OVERVIEW_PDF_COUNTNR' ).' '.$this->oxorder__oxbillnr->value;
01071         $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop + 8, $sText );
01072 
01073         // marking if order is canceled
01074         if ( $this->oxorder__oxstorno->value == 1 ) {
01075             $this->oxorder__oxordernr->setValue( $this->oxorder__oxordernr->getRawValue() . '   '.$this->translate( 'ORDER_OVERVIEW_PDF_STORNO' ), oxField::T_RAW );
01076         }
01077 
01078         // order number
01079         $oPdf->setFont( $oPdfBlock->getFont(), '', 12 );
01080         $oPdf->text( 15, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_PURCHASENR' ).' '.$this->oxorder__oxordernr->value );
01081 
01082         // order date
01083         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
01084         $aOrderDate = explode( ' ', $this->oxorder__oxorderdate->value );
01085         $sOrderDate = oxRegistry::get("oxUtilsDate")->formatDBDate( $aOrderDate[0]);
01086         $oPdf->text( 15, $iTop + 8, $this->translate( 'ORDER_OVERVIEW_PDF_ORDERSFROM' ).$sOrderDate.$this->translate( 'ORDER_OVERVIEW_PDF_ORDERSAT' ).$oShop->oxshops__oxurl->value );
01087         $iTop += 16;
01088 
01089         // product info header
01090         $oPdf->setFont( $oPdfBlock->getFont(), '', 8 );
01091         $oPdf->text( 15, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_AMOUNT' ) );
01092         $oPdf->text( 30, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_ARTID' ) );
01093         $oPdf->text( 45, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_DESC' ) );
01094         $oPdf->text( 135, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_VAT' ) );
01095         $oPdf->text( 148, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_UNITPRICE' ) );
01096         $sText = $this->translate( 'ORDER_OVERVIEW_PDF_ALLPRICE' );
01097         $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop, $sText );
01098 
01099         // separator line
01100         $iTop += 2;
01101         $oPdf->line( 15, $iTop, 195, $iTop );
01102 
01103         // #345
01104         $siteH = $iTop;
01105         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
01106 
01107         // order articles
01108         $this->_setOrderArticlesToPdf( $oPdf, $siteH, true );
01109 
01110         // generating pdf file
01111         $oArtSumm = new PdfArticleSummary( $this, $oPdf );
01112         $iHeight = $oArtSumm->generate( $siteH );
01113         if ( $siteH + $iHeight > 258 ) {
01114             $this->pdfFooter( $oPdf );
01115             $iTop = $this->pdfHeader( $oPdf );
01116             $oArtSumm->ajustHeight( $iTop - $siteH );
01117             $siteH = $iTop;
01118         }
01119 
01120         $oArtSumm->run( $oPdf );
01121         $siteH += $iHeight + 8;
01122 
01123         $oPdf->text( 15, $siteH, $this->translate( 'ORDER_OVERVIEW_PDF_GREETINGS' ) );
01124     }
01125 
01133     public function exportDeliveryNote( $oPdf )
01134     {
01135         $myConfig = $this->getConfig();
01136         $oShop    = $this->_getActShop();
01137         $oPdfBlock = new PdfBlock();
01138 
01139         $oLang = oxRegistry::getLang();
01140         $sSal = $this->oxorder__oxdelsal->value;
01141         try {
01142             $sSal = $oLang->translateString($this->oxorder__oxdelsal->value, $this->getSelectedLang());
01143         } catch (Exception $e) {
01144         }
01145 
01146         // loading order currency info
01147         $this->_oCur = $myConfig->getCurrencyObject( $this->oxorder__oxcurrency->value );
01148         if ( !isset( $this->_oCur ) ) {
01149             $this->_oCur = $myConfig->getActShopCurrencyObject();
01150         }
01151 
01152         // shop info
01153         $oPdf->setFont( $oPdfBlock->getFont(), '', 6 );
01154         $oPdf->text( 15, 55, $oShop->oxshops__oxname->getRawValue().' - '.$oShop->oxshops__oxstreet->getRawValue().' - '.$oShop->oxshops__oxzip->value.' - '.$oShop->oxshops__oxcity->getRawValue() );
01155 
01156         // delivery address
01157         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
01158         if ( $this->oxorder__oxdelsal->value ) {
01159             $oPdf->text( 15, 59, $sSal );
01160             $oPdf->text( 15, 63, $this->oxorder__oxdellname->getRawValue().' '.$this->oxorder__oxdelfname->getRawValue() );
01161             $oPdf->text( 15, 67, $this->oxorder__oxdelcompany->getRawValue() );
01162             $oPdf->text( 15, 71, $this->oxorder__oxdelstreet->getRawValue().' '.$this->oxorder__oxdelstreetnr->value );
01163             $oPdf->setFont( $oPdfBlock->getFont(), 'B', 10 );
01164             $oPdf->text( 15, 75, $this->oxorder__oxdelzip->value.' '.$this->oxorder__oxdelcity->getRawValue() );
01165             $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
01166             $oPdf->text( 15, 79, $this->oxorder__oxdelcountry->getRawValue() );
01167         } else {
01168             // no delivery address - billing address is used for delivery
01169             $this->_setBillingAddressToPdf( $oPdf );
01170         }
01171 
01172         // loading user info
01173         $oUser = oxNew( 'oxuser' );
01174         $oUser->load( $this->oxorder__oxuserid->value );
01175 
01176         // user info
01177         $sText = $this->translate( 'ORDER_OVERVIEW_PDF_FILLONPAYMENT' );
01178         $oPdf->setFont( $oPdfBlock->getFont(), '', 5 );
01179         $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), 70, $sText );
01180 
01181         // customer number
01182         $sCustNr = $this->translate( 'ORDER_OVERVIEW_PDF_CUSTNR' ).' '.$oUser->oxuser__oxcustnr->value;
01183         $oPdf->setFont( $oPdfBlock->getFont(), '', 7 );
01184         $oPdf->text( 195 - $oPdf->getStringWidth( $sCustNr ), 73, $sCustNr );
01185 
01186         // shops city
01187         $sText = $oShop->oxshops__oxcity->getRawValue().', '.date( 'd.m.Y' );
01188         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
01189         $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), 95, $sText );
01190 
01191         $iTop = 99;
01192         // shop VAT number
01193         if ( $oShop->oxshops__oxvatnumber->value ) {
01194             $sText = $this->translate( 'ORDER_OVERVIEW_PDF_TAXIDNR' ).' '.$oShop->oxshops__oxvatnumber->value;
01195             $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop, $sText );
01196             $iTop += 4;
01197         }
01198 
01199         // invoice number
01200         $sText = $this->translate( 'ORDER_OVERVIEW_PDF_COUNTNR' ).' '.$this->oxorder__oxbillnr->value;
01201         $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop, $sText );
01202 
01203         // canceled order marker
01204         if ( $this->oxorder__oxstorno->value == 1 ) {
01205             $this->oxorder__oxordernr->setValue( $this->oxorder__oxordernr->getRawValue() . '   '.$this->translate( 'ORDER_OVERVIEW_PDF_STORNO' ), oxField::T_RAW );
01206         }
01207 
01208         // order number
01209         $oPdf->setFont( $oPdfBlock->getFont(), '', 12 );
01210         $oPdf->text( 15, 108, $this->translate( 'ORDER_OVERVIEW_PDF_DELIVNOTE' ).' '.$this->oxorder__oxordernr->value );
01211 
01212         // order date
01213         $aOrderDate = explode( ' ', $this->oxorder__oxorderdate->value );
01214         $sOrderDate = oxRegistry::get("oxUtilsDate")->formatDBDate( $aOrderDate[0]);
01215         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
01216         $oPdf->text(15, 119, $this->translate( 'ORDER_OVERVIEW_PDF_ORDERSFROM' ).$sOrderDate.$this->translate( 'ORDER_OVERVIEW_PDF_ORDERSAT' ).$oShop->oxshops__oxurl->value );
01217 
01218         // product info header
01219         $oPdf->setFont( $oPdfBlock->getFont(), '', 8 );
01220         $oPdf->text( 15, 128, $this->translate( 'ORDER_OVERVIEW_PDF_AMOUNT' ) );
01221         $oPdf->text( 30, 128, $this->translate( 'ORDER_OVERVIEW_PDF_ARTID' ) );
01222         $oPdf->text( 45, 128, $this->translate( 'ORDER_OVERVIEW_PDF_DESC' ) );
01223 
01224         // line separator
01225         $oPdf->line( 15, 130, 195, 130 );
01226 
01227         // product list
01228         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
01229         $siteH = 130;
01230 
01231         // order articles
01232         $this->_setOrderArticlesToPdf( $oPdf, $siteH, false );
01233 
01234         // sine separator
01235         $oPdf->line( 15, $siteH + 2, 195, $siteH + 2 );
01236         $siteH += 4;
01237 
01238         // payment date
01239         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
01240         $text = $this->translate( 'ORDER_OVERVIEW_PDF_PAYUPTO' ) . date( 'd.m.Y', strtotime( '+' . $this->getPaymentTerm() . ' day', strtotime( $this->oxorder__oxbilldate->value ) ) );
01241         $oPdf->text( 15, $siteH + 4, $text );
01242     }
01243 
01253     protected function _replaceExtendedChars( $sValue, $blReverse = false )
01254     {
01255         // we need to replace this for compatibility with XHTML
01256         // as this function causes a lot of trouble with editor
01257         // we switch it off, even if this means that fields do not validate through xhtml
01258         // return $sValue;
01259 
01260         // we need to replace this for compatibility with XHTML
01261         $aReplace = array( chr(169) => "&copy;", chr(128) => "&euro;", "\"" => "&quot;", "'" => "&#039;");
01262 
01263         // #899C reverse html entities and references transformation is used in invoicepdf module
01264         // so this part must be enabled. Now it works with html references like &#123;
01265         if ($blReverse) {
01266             // replace now
01267             if (version_compare(PHP_VERSION, '5.3.4') >= 0) {
01268                 $aTransTbl = get_html_translation_table (HTML_ENTITIES, ENT_COMPAT, 'ISO-8859-1');
01269             } else {
01270                 $aTransTbl = get_html_translation_table (HTML_ENTITIES, ENT_COMPAT);
01271             }
01272 
01273             $aTransTbl = array_flip ($aTransTbl) + array_flip ($aReplace);
01274             $sValue = strtr($sValue, $aTransTbl);
01275             $sValue = getStr()->preg_replace('/\&\#([0-9]+)\;/me', "chr('\\1')", $sValue);
01276         }
01277 
01278         return $sValue;
01279     }
01280 
01286     public function getVats()
01287     {
01288         // for older orders
01289         return $this->getProductVats( false );
01290     }
01291 
01297     public function getCurrency()
01298     {
01299         return $this->_oCur;
01300     }
01301 
01307     public function getSelectedLang()
01308     {
01309         return $this->_iSelectedLang;
01310     }
01311 
01317     public function getPaymentTerm()
01318     {
01319         if ( null === $iPaymentTerm = $this->getConfig()->getConfigParam( 'iPaymentTerm' ) ) {
01320             $iPaymentTerm = 7;
01321         }
01322 
01323         return $iPaymentTerm;
01324     }
01325 }