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' ) . $this->_oData->oxorder__oxbilldate->value; //date( 'd.m.Y', mktime( 0, 0, 0, date ( 'm' ), date ( 'd' ) + 7, date( 'Y' ) ) );
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 
00697     protected function _getActShop()
00698     {
00699         // shop is allready loaded
00700         if ( $this->_oActShop !== null )
00701             return $this->_oActShop;
00702 
00703         $this->_oActShop = oxNew( 'oxshop' );
00704         $this->_oActShop->load( $this->getConfig()->getShopId() );
00705 
00706         return $this->_oActShop;
00707     }
00708 
00716     public function translate( $sString )
00717     {
00718         return oxRegistry::getLang()->translateString( $sString, $this->_iSelectedLang );
00719     }
00720 
00728     public function pdfFooter( $oPdf )
00729     {
00730 
00731         $oShop = $this->_getActShop();
00732 
00733         $oPdf->line( 15, 272, 195, 272 );
00734 
00735         $oPdfBlock = new PdfBlock();
00736         /* column 1 - company name, shop owner info, shop address */
00737         $oPdf->setFont( $oPdfBlock->getFont(), '', 7 );
00738         $oPdf->text( 15, 275, strip_tags( $oShop->oxshops__oxcompany->getRawValue() ) );
00739         $oPdf->text( 15, 278, strip_tags( $oShop->oxshops__oxfname->getRawValue() ).' '. strip_tags( $oShop->oxshops__oxlname->getRawValue() ) );
00740         $oPdf->text( 15, 281, strip_tags( $oShop->oxshops__oxstreet->getRawValue() ) );
00741         $oPdf->text( 15, 284, strip_tags( $oShop->oxshops__oxzip->value ).' '. strip_tags( $oShop->oxshops__oxcity->getRawValue() ) );
00742         $oPdf->text( 15, 287, strip_tags( $oShop->oxshops__oxcountry->getRawValue() ) );
00743 
00744         /* column 2 - phone, fax, url, email address */
00745         $oPdf->text( 85, 275, $this->translate( 'ORDER_OVERVIEW_PDF_PHONE' ).strip_tags( $oShop->oxshops__oxtelefon->value ) );
00746         $oPdf->text( 85, 278, $this->translate( 'ORDER_OVERVIEW_PDF_FAX' ).strip_tags( $oShop->oxshops__oxtelefax->value ) );
00747         $oPdf->text( 85, 281, strip_tags( $oShop->oxshops__oxurl->value ) );
00748         $oPdf->text( 85, 284, strip_tags( $oShop->oxshops__oxorderemail->value ) );
00749 
00750         /* column 3 - bank information */
00751         $oPdf->text( 150, 275, strip_tags( $oShop->oxshops__oxbankname->getRawValue() ) );
00752         $oPdf->text( 150, 278, $this->translate( 'ORDER_OVERVIEW_PDF_ACCOUNTNR' ).strip_tags( $oShop->oxshops__oxbanknumber->value ) );
00753         $oPdf->text( 150, 281, $this->translate( 'ORDER_OVERVIEW_PDF_BANKCODE' ).strip_tags( $oShop->oxshops__oxbankcode->value ) );
00754         $oPdf->text( 150, 284, strip_tags( $oShop->oxshops__oxvatnumber->value ) );
00755         $oPdf->text( 150, 287, '' );
00756     }
00757 
00765     public function pdfHeaderPlus( $oPdf )
00766     {
00767 
00768         // new page with shop logo
00769         $this->pdfHeader( $oPdf );
00770 
00771         $oPdfBlock = new PdfBlock();
00772         // column names
00773         $oPdf->setFont( $oPdfBlock->getFont(), '', 8 );
00774         $oPdf->text( 15, 50, $this->translate( 'ORDER_OVERVIEW_PDF_AMOUNT' ) );
00775         $oPdf->text( 30, 50, $this->translate( 'ORDER_OVERVIEW_PDF_ARTID') );
00776         $oPdf->text( 45, 50, $this->translate( 'ORDER_OVERVIEW_PDF_DESC' ) );
00777         $oPdf->text( 160, 50, $this->translate( 'ORDER_OVERVIEW_PDF_UNITPRICE' ) );
00778         $sText = $this->translate( 'ORDER_OVERVIEW_PDF_ALLPRICE' );
00779         $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), 50, $sText );
00780 
00781         // line separator
00782         $oPdf->line( 15, 52, 195, 52 );
00783 
00784         return 56;
00785     }
00786 
00794     public function pdfHeader( $oPdf )
00795     {
00796         // adding new page ...
00797         $oPdf->addPage();
00798 
00799         // loading active shop
00800         $oShop = $this->_getActShop();
00801 
00802         //logo
00803         $myConfig = $this->getConfig();
00804         $aSize    = getimagesize( $myConfig->getImageDir().'/pdf_logo.jpg' );
00805         $iMargin  = 195 - $aSize[0] * 0.2;
00806         $oPdf->setLink( $oShop->oxshops__oxurl->value );
00807         $oPdf->image( $myConfig->getImageDir().'/pdf_logo.jpg', $iMargin, 10, $aSize[0] * 0.2, $aSize[1] * 0.2, '', $oShop->oxshops__oxurl->value );
00808         return 14 + $aSize[1] * 0.2;
00809     }
00810 
00819     public function genPdf( $sFilename, $iSelLang = 0 )
00820     {
00821         // setting pdf language
00822         $this->_iSelectedLang = $iSelLang;
00823 
00824         // setting invoice number
00825         if ( !$this->oxorder__oxbillnr->value ) {
00826             $this->oxorder__oxbillnr->setValue($this->getNextBillNum());
00827             $this->oxorder__oxbilldate->setValue( date( 'd.m.Y', mktime( 0, 0, 0, date ( 'm' ), date ( 'd' ) + $this->getPaymentTerm(), date( 'Y' ) ) ) );
00828             $this->save();
00829         }
00830 
00831         // initiating pdf engine
00832         $oPdf = oxNew( 'oxPDF' );
00833         $oPdf->setPrintHeader( false );
00834         $oPdf->open();
00835 
00836         // adding header
00837         $this->pdfHeader( $oPdf );
00838 
00839         // adding info data
00840         switch ( oxConfig::getParameter( 'pdftype' ) ) {
00841             case 'dnote':
00842                 $this->exportDeliveryNote( $oPdf );
00843                 break;
00844             default:
00845                 $this->exportStandart( $oPdf );
00846         }
00847 
00848         // adding footer
00849         $this->pdfFooter( $oPdf );
00850 
00851         // outputting file to browser
00852         $oPdf->output( $sFilename, 'I' );
00853     }
00854 
00855 
00863     protected function _setBillingAddressToPdf( $oPdf )
00864     {
00865         $oLang = oxRegistry::getLang();
00866         $sSal = $this->oxorder__oxbillsal->value;
00867         try {
00868             $sSal = $oLang->translateString($this->oxorder__oxbillsal->value, $this->_iSelectedLang);
00869         } catch (Exception $e) {
00870         }
00871         $oPdfBlock = new PdfBlock();
00872         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
00873         $oPdf->text( 15, 59, $sSal);
00874         $oPdf->text( 15, 63, $this->oxorder__oxbillfname->getRawValue().' '.$this->oxorder__oxbilllname->getRawValue() );
00875         $oPdf->text( 15, 67, $this->oxorder__oxbillcompany->getRawValue() );
00876         $oPdf->text( 15, 71, $this->oxorder__oxbillstreet->getRawValue().' '.$this->oxorder__oxbillstreetnr->value );
00877         $oPdf->setFont( $oPdfBlock->getFont(), 'B', 10 );
00878         $oPdf->text( 15, 75, $this->oxorder__oxbillzip->value.' '.$this->oxorder__oxbillcity->getRawValue() );
00879         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
00880         $oPdf->text( 15, 79, $this->oxorder__oxbillcountry->getRawValue() );
00881     }
00882 
00890     protected function _setDeliveryAddressToPdf( $oPdf )
00891     {
00892         $oLang = oxRegistry::getLang();
00893         $sSal = $this->oxorder__oxdelsal->value;
00894         try {
00895             $sSal = $oLang->translateString($this->oxorder__oxdelsal->value, $this->_iSelectedLang);
00896         } catch (Exception $e) {
00897         }
00898         $oPdfBlock = new PdfBlock();
00899         $oPdf->setFont( $oPdfBlock->getFont(), '', 6 );
00900         $oPdf->text( 15, 87, $this->translate( 'ORDER_OVERVIEW_PDF_DELIVERYADDRESS' ) );
00901         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
00902         $oPdf->text( 15, 91, $sSal);
00903         $oPdf->text( 15, 95, $this->oxorder__oxdellname->getRawValue().' '.$this->oxorder__oxdelfname->getRawValue() );
00904         $oPdf->text( 15, 99, $this->oxorder__oxdelcompany->getRawValue() );
00905         $oPdf->text( 15, 103, $this->oxorder__oxdelstreet->getRawValue().' '.$this->oxorder__oxdelstreetnr->value );
00906         $oPdf->setFont( $oPdfBlock->getFont(), 'B', 10 );
00907         $oPdf->text( 15, 107, $this->oxorder__oxdelzip->value.' '.$this->oxorder__oxdelcity->getRawValue() );
00908         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
00909         $oPdf->text( 15, 111, $this->oxorder__oxdelcountry->getRawValue() );
00910     }
00911 
00921     protected function _setOrderArticlesToPdf( $oPdf, &$iStartPos, $blShowPrice = true )
00922     {
00923         if (!$this->_oArticles) {
00924             $this->_oArticles = $this->getOrderArticles(true);
00925         }
00926 
00927         $oCurr = $this->getCurrency();
00928         $oPdfBlock = new PdfBlock();
00929         // product list
00930         foreach ( $this->_oArticles as $key => $oOrderArt ) {
00931 
00932             // starting a new page ...
00933             if ( $iStartPos > 243 ) {
00934                 $this->pdffooter( $oPdf );
00935                 $iStartPos = $this->pdfheaderplus( $oPdf );
00936                 $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
00937             } else {
00938                 $iStartPos = $iStartPos + 4;
00939             }
00940 
00941             // sold amount
00942             $oPdf->text( 20 - $oPdf->getStringWidth( $oOrderArt->oxorderarticles__oxamount->value ), $iStartPos, $oOrderArt->oxorderarticles__oxamount->value );
00943 
00944             // product number
00945             $oPdf->setFont( $oPdfBlock->getFont(), '', 8 );
00946             $oPdf->text( 28, $iStartPos, $oOrderArt->oxorderarticles__oxartnum->value );
00947 
00948             // product title
00949             $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
00950             $oPdf->text( 45, $iStartPos, substr( strip_tags( $this->_replaceExtendedChars( $oOrderArt->oxorderarticles__oxtitle->getRawValue(), true ) ), 0, 58 ) );
00951 
00952             if ( $blShowPrice ) {
00953                 $oLang = oxRegistry::getLang();
00954 
00955                 // product VAT percent
00956                 $oPdf->text( 140 - $oPdf->getStringWidth( $oOrderArt->oxorderarticles__oxvat->value ), $iStartPos, $oOrderArt->oxorderarticles__oxvat->value );
00957 
00958                 // product price
00959 
00960                 $dUnitPrice = ($this->isNettoMode()) ? $oOrderArt->oxorderarticles__oxnprice->value : $oOrderArt->oxorderarticles__oxbprice->value;
00961                 $dTotalPrice = ($this->isNettoMode()) ? $oOrderArt->oxorderarticles__oxnetprice->value : $oOrderArt->oxorderarticles__oxbrutprice->value;
00962 
00963                 $sText = $oLang->formatCurrency( $dUnitPrice, $this->_oCur ).' '.$this->_oCur->name;
00964                 $oPdf->text( 163 - $oPdf->getStringWidth( $sText ), $iStartPos, $sText );
00965 
00966                 // total product price
00967                 $sText = $oLang->formatCurrency( $dTotalPrice, $this->_oCur ).' '.$this->_oCur->name;
00968                 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iStartPos, $sText );
00969 
00970             }
00971 
00972             // additional variant info
00973             if ( $oOrderArt->oxorderarticles__oxselvariant->value ) {
00974                 $iStartPos = $iStartPos + 4;
00975                 $oPdf->text( 45, $iStartPos, substr( $oOrderArt->oxorderarticles__oxselvariant->value, 0, 58 ) );
00976             }
00977 
00978         }
00979     }
00980 
00988     public function exportStandart( $oPdf )
00989     {
00990         // preparing order curency info
00991         $myConfig = $this->getConfig();
00992         $oPdfBlock = new PdfBlock();
00993 
00994         $this->_oCur = $myConfig->getCurrencyObject( $this->oxorder__oxcurrency->value );
00995         if ( !$this->_oCur ) {
00996             $this->_oCur = $myConfig->getActShopCurrencyObject();
00997         }
00998 
00999         // loading active shop
01000         $oShop = $this->_getActShop();
01001 
01002         // shop information
01003         $oPdf->setFont( $oPdfBlock->getFont(), '', 6 );
01004         $oPdf->text( 15, 55, $oShop->oxshops__oxname->getRawValue().' - '.$oShop->oxshops__oxstreet->getRawValue().' - '.$oShop->oxshops__oxzip->value.' - '.$oShop->oxshops__oxcity->getRawValue() );
01005 
01006         // billing address
01007         $this->_setBillingAddressToPdf( $oPdf );
01008 
01009         // delivery address
01010         if ( $this->oxorder__oxdelsal->value ) {
01011             $this->_setDeliveryAddressToPdf( $oPdf );
01012         }
01013 
01014         // loading user
01015         $oUser = oxNew( 'oxuser' );
01016         $oUser->load( $this->oxorder__oxuserid->value );
01017 
01018         // user info
01019         $sText = $this->translate( 'ORDER_OVERVIEW_PDF_FILLONPAYMENT' );
01020         $oPdf->setFont( $oPdfBlock->getFont(), '', 5 );
01021         $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), 55, $sText );
01022 
01023         // customer number
01024         $sCustNr = $this->translate( 'ORDER_OVERVIEW_PDF_CUSTNR').' '.$oUser->oxuser__oxcustnr->value;
01025         $oPdf->setFont( $oPdfBlock->getFont(), '', 7 );
01026         $oPdf->text( 195 - $oPdf->getStringWidth( $sCustNr ), 59, $sCustNr );
01027 
01028         // setting position if delivery address is used
01029         if ( $this->oxorder__oxdelsal->value ) {
01030             $iTop = 115;
01031         } else {
01032             $iTop = 91;
01033         }
01034 
01035         // shop city
01036         $sText = $oShop->oxshops__oxcity->getRawValue().', '.date( 'd.m.Y' );
01037         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
01038         $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop + 8, $sText );
01039 
01040         // shop VAT number
01041         if ( $oShop->oxshops__oxvatnumber->value ) {
01042             $sText = $this->translate( 'ORDER_OVERVIEW_PDF_TAXIDNR' ).' '.$oShop->oxshops__oxvatnumber->value;
01043             $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop + 12, $sText );
01044             $iTop += 8;
01045         } else {
01046             $iTop += 4;
01047         }
01048 
01049         // invoice number
01050         $sText = $this->translate( 'ORDER_OVERVIEW_PDF_COUNTNR' ).' '.$this->oxorder__oxbillnr->value;
01051         $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop + 8, $sText );
01052 
01053         // marking if order is canceled
01054         if ( $this->oxorder__oxstorno->value == 1 ) {
01055             $this->oxorder__oxordernr->setValue( $this->oxorder__oxordernr->getRawValue() . '   '.$this->translate( 'ORDER_OVERVIEW_PDF_STORNO' ), oxField::T_RAW );
01056         }
01057 
01058         // order number
01059         $oPdf->setFont( $oPdfBlock->getFont(), '', 12 );
01060         $oPdf->text( 15, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_PURCHASENR' ).' '.$this->oxorder__oxordernr->value );
01061 
01062         // order date
01063         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
01064         $aOrderDate = explode( ' ', $this->oxorder__oxorderdate->value );
01065         $sOrderDate = oxRegistry::get("oxUtilsDate")->formatDBDate( $aOrderDate[0]);
01066         $oPdf->text( 15, $iTop + 8, $this->translate( 'ORDER_OVERVIEW_PDF_ORDERSFROM' ).$sOrderDate.$this->translate( 'ORDER_OVERVIEW_PDF_ORDERSAT' ).$oShop->oxshops__oxurl->value );
01067         $iTop += 16;
01068 
01069         // product info header
01070         $oPdf->setFont( $oPdfBlock->getFont(), '', 8 );
01071         $oPdf->text( 15, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_AMOUNT' ) );
01072         $oPdf->text( 30, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_ARTID' ) );
01073         $oPdf->text( 45, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_DESC' ) );
01074         $oPdf->text( 135, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_VAT' ) );
01075         $oPdf->text( 148, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_UNITPRICE' ) );
01076         $sText = $this->translate( 'ORDER_OVERVIEW_PDF_ALLPRICE' );
01077         $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop, $sText );
01078 
01079         // separator line
01080         $iTop += 2;
01081         $oPdf->line( 15, $iTop, 195, $iTop );
01082 
01083         // #345
01084         $siteH = $iTop;
01085         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
01086 
01087         // order articles
01088         $this->_setOrderArticlesToPdf( $oPdf, $siteH, true );
01089 
01090         // generating pdf file
01091         $oArtSumm = new PdfArticleSummary( $this, $oPdf );
01092         $iHeight = $oArtSumm->generate( $siteH );
01093         if ( $siteH + $iHeight > 258 ) {
01094             $this->pdfFooter( $oPdf );
01095             $iTop = $this->pdfHeader( $oPdf );
01096             $oArtSumm->ajustHeight( $iTop - $siteH );
01097             $siteH = $iTop;
01098         }
01099 
01100         $oArtSumm->run( $oPdf );
01101         $siteH += $iHeight + 8;
01102 
01103         $oPdf->text( 15, $siteH, $this->translate( 'ORDER_OVERVIEW_PDF_GREETINGS' ) );
01104     }
01105 
01113     public function exportDeliveryNote( $oPdf )
01114     {
01115         $myConfig = $this->getConfig();
01116         $oShop    = $this->_getActShop();
01117         $oPdfBlock = new PdfBlock();
01118 
01119         $oLang = oxRegistry::getLang();
01120         $sSal = $this->oxorder__oxdelsal->value;
01121         try {
01122             $sSal = $oLang->translateString($this->oxorder__oxdelsal->value, $this->_iSelectedLang);
01123         } catch (Exception $e) {
01124         }
01125 
01126         // loading order currency info
01127         $this->_oCur = $myConfig->getCurrencyObject( $this->oxorder__oxcurrency->value );
01128         if ( !isset( $this->_oCur ) ) {
01129             $this->_oCur = $myConfig->getActShopCurrencyObject();
01130         }
01131 
01132         // shop info
01133         $oPdf->setFont( $oPdfBlock->getFont(), '', 6 );
01134         $oPdf->text( 15, 55, $oShop->oxshops__oxname->getRawValue().' - '.$oShop->oxshops__oxstreet->getRawValue().' - '.$oShop->oxshops__oxzip->value.' - '.$oShop->oxshops__oxcity->getRawValue() );
01135 
01136         // delivery address
01137         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
01138         if ( $this->oxorder__oxdelsal->value ) {
01139             $oPdf->text( 15, 59, $sSal );
01140             $oPdf->text( 15, 63, $this->oxorder__oxdellname->getRawValue().' '.$this->oxorder__oxdelfname->getRawValue() );
01141             $oPdf->text( 15, 67, $this->oxorder__oxdelcompany->getRawValue() );
01142             $oPdf->text( 15, 71, $this->oxorder__oxdelstreet->getRawValue().' '.$this->oxorder__oxdelstreetnr->value );
01143             $oPdf->setFont( $oPdfBlock->getFont(), 'B', 10 );
01144             $oPdf->text( 15, 75, $this->oxorder__oxdelzip->value.' '.$this->oxorder__oxdelcity->getRawValue() );
01145             $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
01146             $oPdf->text( 15, 79, $this->oxorder__oxdelcountry->getRawValue() );
01147         } else {
01148             // no delivery address - billing address is used for delivery
01149             $this->_setBillingAddressToPdf( $oPdf );
01150         }
01151 
01152         // loading user info
01153         $oUser = oxNew( 'oxuser' );
01154         $oUser->load( $this->oxorder__oxuserid->value );
01155 
01156         // user info
01157         $sText = $this->translate( 'ORDER_OVERVIEW_PDF_FILLONPAYMENT' );
01158         $oPdf->setFont( $oPdfBlock->getFont(), '', 5 );
01159         $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), 70, $sText );
01160 
01161         // customer number
01162         $sCustNr = $this->translate( 'ORDER_OVERVIEW_PDF_CUSTNR' ).' '.$oUser->oxuser__oxcustnr->value;
01163         $oPdf->setFont( $oPdfBlock->getFont(), '', 7 );
01164         $oPdf->text( 195 - $oPdf->getStringWidth( $sCustNr ), 73, $sCustNr );
01165 
01166         // shops city
01167         $sText = $oShop->oxshops__oxcity->getRawValue().', '.date( 'd.m.Y' );
01168         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
01169         $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), 95, $sText );
01170 
01171         $iTop = 99;
01172         // shop VAT number
01173         if ( $oShop->oxshops__oxvatnumber->value ) {
01174             $sText = $this->translate( 'ORDER_OVERVIEW_PDF_TAXIDNR' ).' '.$oShop->oxshops__oxvatnumber->value;
01175             $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop, $sText );
01176             $iTop += 4;
01177         }
01178 
01179         // invoice number
01180         $sText = $this->translate( 'ORDER_OVERVIEW_PDF_COUNTNR' ).' '.$this->oxorder__oxbillnr->value;
01181         $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop, $sText );
01182 
01183         // canceled order marker
01184         if ( $this->oxorder__oxstorno->value == 1 ) {
01185             $this->oxorder__oxordernr->setValue( $this->oxorder__oxordernr->getRawValue() . '   '.$this->translate( 'ORDER_OVERVIEW_PDF_STORNO' ), oxField::T_RAW );
01186         }
01187 
01188         // order number
01189         $oPdf->setFont( $oPdfBlock->getFont(), '', 12 );
01190         $oPdf->text( 15, 108, $this->translate( 'ORDER_OVERVIEW_PDF_DELIVNOTE' ).' '.$this->oxorder__oxordernr->value );
01191 
01192         // order date
01193         $aOrderDate = explode( ' ', $this->oxorder__oxorderdate->value );
01194         $sOrderDate = oxRegistry::get("oxUtilsDate")->formatDBDate( $aOrderDate[0]);
01195         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
01196         $oPdf->text(15, 119, $this->translate( 'ORDER_OVERVIEW_PDF_ORDERSFROM' ).$sOrderDate.$this->translate( 'ORDER_OVERVIEW_PDF_ORDERSAT' ).$oShop->oxshops__oxurl->value );
01197 
01198         // product info header
01199         $oPdf->setFont( $oPdfBlock->getFont(), '', 8 );
01200         $oPdf->text( 15, 128, $this->translate( 'ORDER_OVERVIEW_PDF_AMOUNT' ) );
01201         $oPdf->text( 30, 128, $this->translate( 'ORDER_OVERVIEW_PDF_ARTID' ) );
01202         $oPdf->text( 45, 128, $this->translate( 'ORDER_OVERVIEW_PDF_DESC' ) );
01203 
01204         // line separator
01205         $oPdf->line( 15, 130, 195, 130 );
01206 
01207         // product list
01208         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
01209         $siteH = 130;
01210 
01211         // order articles
01212         $this->_setOrderArticlesToPdf( $oPdf, $siteH, false );
01213 
01214         // sine separator
01215         $oPdf->line( 15, $siteH + 2, 195, $siteH + 2 );
01216         $siteH += 4;
01217 
01218         // payment date
01219         $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
01220         $text = $this->translate( 'ORDER_OVERVIEW_PDF_PAYUPTO' ).date( 'd.m.Y', mktime( 0, 0, 0, date ( 'm' ), date ( 'd' ) + 7, date( 'Y' ) ) );
01221         $oPdf->text( 15, $siteH + 4, $text );
01222     }
01223 
01233     protected function _replaceExtendedChars( $sValue, $blReverse = false )
01234     {
01235         // we need to replace this for compatibility with XHTML
01236         // as this function causes a lot of trouble with editor
01237         // we switch it off, even if this means that fields do not validate through xhtml
01238         // return $sValue;
01239 
01240         // we need to replace this for compatibility with XHTML
01241         $aReplace = array( chr(169) => "&copy;", chr(128) => "&euro;", "\"" => "&quot;", "'" => "&#039;");
01242 
01243         // #899C reverse html entities and references transformation is used in invoicepdf module
01244         // so this part must be enabled. Now it works with html references like &#123;
01245         if ($blReverse) {
01246             // replace now
01247             if (version_compare(PHP_VERSION, '5.3.4') >= 0) {
01248                 $aTransTbl = get_html_translation_table (HTML_ENTITIES, ENT_COMPAT, 'ISO-8859-1');
01249             } else {
01250                 $aTransTbl = get_html_translation_table (HTML_ENTITIES, ENT_COMPAT);
01251             }
01252 
01253             $aTransTbl = array_flip ($aTransTbl) + array_flip ($aReplace);
01254             $sValue = strtr($sValue, $aTransTbl);
01255             $sValue = getStr()->preg_replace('/\&\#([0-9]+)\;/me', "chr('\\1')", $sValue);
01256         }
01257 
01258         return $sValue;
01259     }
01260 
01266     public function getVats()
01267     {
01268         // for older orders
01269         return $this->getProductVats( false );
01270     }
01271 
01277     public function getCurrency()
01278     {
01279         return $this->_oCur;
01280     }
01281 
01287     public function getSelectedLang()
01288     {
01289         return $this->_iSelectedLang;
01290     }
01291 
01297     public function getPaymentTerm()
01298     {
01299         if ( null === $iPaymentTerm = $this->getConfig()->getConfigParam( 'iPaymentTerm' ) ) {
01300             $iPaymentTerm = 7;
01301         }
01302 
01303         return $iPaymentTerm;
01304     }
01305 }