00001 <?php
00002
00006 class PdfBlock
00007 {
00012 protected $_aCache = array();
00013
00022 protected function _toCache( $sFunc, $aParams )
00023 {
00024 $oItem = new stdClass();
00025 $oItem->sFunc = $sFunc;
00026 $oItem->aParams = $aParams;
00027 $this->_aCache[] = $oItem;
00028 }
00029
00037 public function run( $oPdf )
00038 {
00039 foreach ( $this->_aCache as $oItem ) {
00040 $sFn = $oItem->sFunc;
00041 switch ( count( $oItem->aParams ) ) {
00042 case 0:
00043 $oPdf->$sFn();
00044 break;
00045 case 1:
00046 $oPdf->$sFn( $oItem->aParams[0]);
00047 break;
00048 case 2:
00049 $oPdf->$sFn( $oItem->aParams[0], $oItem->aParams[1] );
00050 break;
00051 case 3:
00052 $oPdf->$sFn( $oItem->aParams[0], $oItem->aParams[1], $oItem->aParams[2]);
00053 break;
00054 case 4:
00055 $oPdf->$sFn( $oItem->aParams[0], $oItem->aParams[1], $oItem->aParams[2], $oItem->aParams[3]);
00056 break;
00057 }
00058 }
00059 }
00060
00071 public function line( $iLPos, $iLHeight, $iRPos, $iRHeight )
00072 {
00073 $this->_toCache( 'Line', array( $iLPos, $iLHeight, $iRPos, $iRHeight ) );
00074 }
00075
00085 public function text( $iLPos, $iLHeight, $sString )
00086 {
00087 $this->_toCache( 'Text', array( $iLPos, $iLHeight, $sString ) );
00088 }
00089
00099 public function font( $sType, $sWeight, $sSize )
00100 {
00101 $this->_toCache( 'SetFont', array( $sType, $sWeight, $sSize ) );
00102 }
00103
00111 public function ajustHeight( $iDelta )
00112 {
00113 foreach ( $this->_aCache as $key => $oItem ) {
00114 switch ( $oItem->sFunc ) {
00115 case 'Line':
00116 $this->_aCache[$key]->aParams[3] += $iDelta;
00117 $this->_aCache[$key]->aParams[1] += $iDelta;
00118 break;
00119 case 'Text':
00120 $this->_aCache[$key]->aParams[1] += $iDelta;
00121 break;
00122 }
00123 }
00124 }
00125 }
00126
00130 class PdfArticleSummary extends PdfBlock
00131 {
00132
00137 protected $_oData = null;
00138
00143 protected $_oPdf = null;
00144
00153 public function __construct( $oData, $oPdf )
00154 {
00155 $this->_oData = $oData;
00156 $this->_oPdf = $oPdf;
00157 }
00158
00166 protected function _setTotalCostsWithoutDiscount( &$iStartPos )
00167 {
00168 $oLang = oxLang::getInstance();
00169
00170
00171 $this->line( 15, $iStartPos + 1, 195, $iStartPos + 1 );
00172 $sNetSum = $oLang->formatCurrency( $this->_oData->oxorder__oxtotalnetsum->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00173 $this->text( 45, $iStartPos + 4, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLPRICENETTO' ) );
00174 $this->text( 195 - $this->_oPdf->getStringWidth( $sNetSum ), $iStartPos + 4, $sNetSum );
00175
00176
00177 $iCtr = 0;
00178 foreach ( $this->_oData->getVats() as $iVat => $dVatPrice ) {
00179 $iStartPos += 4 * $iCtr;
00180 $sVATSum = $oLang->formatCurrency( $dVatPrice, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00181 $this->text( 45, $iStartPos + 8, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ).$iVat.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_PERCENTSUM' ) );
00182 $this->text( 195 - $this->_oPdf->getStringWidth( $sVATSum ), $iStartPos + 8, $sVATSum );
00183 $iCtr++;
00184 }
00185
00186
00187 $sBrutPrice = $oLang->formatCurrency( $this->_oData->oxorder__oxtotalbrutsum->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00188 $this->text( 45, $iStartPos + 12, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLPRICEBRUTTO' ) );
00189 $this->text( 195 - $this->_oPdf->getStringWidth( $sBrutPrice ), $iStartPos + 12, $sBrutPrice );
00190 $iStartPos++;
00191
00192
00193 $this->line( 45, $iStartPos + 13, 195, $iStartPos + 13 );
00194 $iStartPos += 5;
00195 }
00196
00204 protected function _setTotalCostsWithDiscount( &$iStartPos )
00205 {
00206 $oLang = oxLang::getInstance();
00207
00208
00209 $this->line( 15, $iStartPos + 1, 195, $iStartPos + 1 );
00210
00211
00212 $sBrutPrice = $oLang->formatCurrency( $this->_oData->oxorder__oxtotalbrutsum->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00213 $this->text( 45, $iStartPos + 4, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLPRICEBRUTTO' ) );
00214 $this->text( 195 - $this->_oPdf->getStringWidth( $sBrutPrice ), $iStartPos + 4, $sBrutPrice );
00215
00216
00217 $this->line( 45, $iStartPos + 5, 195, $iStartPos + 5 );
00218
00219
00220 $dDiscountVal = $this->_oData->oxorder__oxdiscount->value;
00221 if ( $dDiscountVal > 0 ) {
00222 $dDiscountVal *= -1;
00223 }
00224 $sDiscount = $oLang->formatCurrency( $dDiscountVal, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00225 $this->text( 45, $iStartPos + 8, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_DISCOUNT' ) );
00226 $this->text( 195 - $this->_oPdf->getStringWidth( $sDiscount ), $iStartPos + 8, $sDiscount );
00227 $iStartPos++;
00228
00229
00230 $this->line( 45, $iStartPos + 8, 195, $iStartPos + 8 );
00231 $iStartPos += 4;
00232
00233
00234 $sNetSum = $oLang->formatCurrency( $this->_oData->oxorder__oxtotalnetsum->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00235 $this->text( 45, $iStartPos + 8, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLPRICENETTO' ) );
00236 $this->text( 195 - $this->_oPdf->getStringWidth( $sNetSum ), $iStartPos + 8, $sNetSum );
00237
00238
00239 $iCtr = 0;
00240 foreach ( $this->_oData->getVats() as $iVat => $dVatPrice ) {
00241 $iStartPos += 4 * $iCtr;
00242 $sVATSum = $oLang->formatCurrency( $dVatPrice, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00243 $this->text( 45, $iStartPos + 12, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ).$iVat.$this->_oData->translate('ORDER_OVERVIEW_PDF_PERCENTSUM' ) );
00244 $this->text( 195 - $this->_oPdf->getStringWidth( $sVATSum ), $iStartPos + 12, $sVATSum );
00245 $iCtr++;
00246 }
00247 $iStartPos += 4;
00248 }
00249
00257 protected function _setVoucherInfo( &$iStartPos )
00258 {
00259 $dVoucher = 0;
00260 if ( $this->_oData->oxorder__oxvoucherdiscount->value ) {
00261 $dDiscountVal = $this->_oData->oxorder__oxvoucherdiscount->value;
00262 if ( $dDiscountVal > 0 ) {
00263 $dDiscountVal *= -1;
00264 }
00265 $sPayCost = oxLang::getInstance()->formatCurrency( $dDiscountVal, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00266 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_VOUCHER' ) );
00267 $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCost ), $iStartPos, $sPayCost );
00268 $iStartPos += 4;
00269 }
00270
00271 $iStartPos++;
00272 }
00273
00281 protected function _setDeliveryInfo( &$iStartPos )
00282 {
00283 $oLang = oxLang::getInstance();
00284 $sAddString = '';
00285 if ( $this->_oData->oxorder__oxdelvat->value ) {
00286
00287
00288 $sDelCostNetto = $oLang->formatCurrency( $this->_oData->getOrderDeliveryPrice()->getNettoPrice(), $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00289 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_SHIPCOST' ).' '.$this->_oData->translate('ORDER_OVERVIEW_PDF_NETTO' ) );
00290 $this->text( 195 - $this->_oPdf->getStringWidth( $sDelCostNetto ), $iStartPos, $sDelCostNetto );
00291 $iStartPos += 4;
00292
00293
00294 $sDelCostVAT = $oLang->formatCurrency( $this->_oData->getOrderDeliveryPrice()->getVATValue(), $this->_oData->getCurrency()).' '.$this->_oData->getCurrency()->name;
00295 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ).$this->_oData->oxorder__oxdelvat->value.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_PERCENTSUM' ) );
00296 $this->text( 195 - $this->_oPdf->getStringWidth( $sDelCostVAT ), $iStartPos, $sDelCostVAT );
00297 $iStartPos += 4;
00298
00299 $sAddString = ' '.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_BRUTTO' );
00300
00301
00302 $this->line( 45, $iStartPos - 3, 195, $iStartPos - 3 );
00303 $iStartPos++;
00304 }
00305
00306
00307
00308
00309 if ( $this->_oData->oxorder__oxstorno->value ) {
00310 $this->_oData->oxorder__oxdelcost->setValue(0);
00311 }
00312
00313 $sDelCost = $oLang->formatCurrency( $this->_oData->oxorder__oxdelcost->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00314 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_SHIPCOST' ).$sAddString );
00315 $this->text( 195 - $this->_oPdf->getStringWidth( $sDelCost ), $iStartPos, $sDelCost );
00316 }
00317
00325 protected function _setWrappingInfo( &$iStartPos )
00326 {
00327 if ( $this->_oData->oxorder__oxwrapcost->value ) {
00328 $sAddString = '';
00329 $oLang = oxLang::getInstance();
00330
00331
00332 if ( $this->_oData->oxorder__oxwrapvat->value ) {
00333
00334
00335 $iStartPos += 5;
00336 $sWrapCostNetto = $oLang->formatCurrency( $this->_oData->getOrderWrappingPrice()->getNettoPrice(), $this->_oData->getCurrency()).' '.$this->_oData->getCurrency()->name;
00337 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_WRAPPING' ).' '.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_NETTO' ) );
00338 $this->text( 195 - $this->_oPdf->getStringWidth( $sWrapCostNetto ), $iStartPos, $sWrapCostNetto );
00339
00340
00341 $iStartPos += 4;
00342 $sWrapCostVAT = $oLang->formatCurrency( $this->_oData->getOrderWrappingPrice()->getVATValue(), $this->_oData->getCurrency()).' '.$this->_oData->getCurrency()->name;
00343 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ).$this->_oData->oxorder__oxwrapvat->value.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_PERCENTSUM' ) );
00344 $this->text( 195 - $this->_oPdf->getStringWidth( $sWrapCostVAT ), $iStartPos, $sWrapCostVAT );
00345
00346 $sAddString = ' '.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_BRUTTO' );
00347
00348
00349 $iStartPos += 4;
00350 $this->line(45, $iStartPos - 3, 195, $iStartPos - 3);
00351 }
00352 $iStartPos += 4;
00353
00354
00355 $sWrapCost = $oLang->formatCurrency( $this->_oData->oxorder__oxwrapcost->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00356 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_WRAPPING' ).$sAddString );
00357 $this->text( 195 - $this->_oPdf->getStringWidth( $sWrapCost ), $iStartPos, $sWrapCost );
00358 $iStartPos++;
00359 }
00360 }
00361
00369 protected function _setPaymentInfo( &$iStartPos )
00370 {
00371 $oLang = oxLang::getInstance();
00372 if ( $this->_oData->oxorder__oxpayvat->value ) {
00373
00374
00375 $iStartPos += 4;
00376 $sPayCostNetto = $oLang->formatCurrency( $this->_oData->getOrderPaymentPrice()->getNettoPrice(), $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00377 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_PAYMENTIMPACT' ).' '.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_NETTO' ) );
00378 $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCostNetto ), $iStartPos, $sPayCostNetto );
00379
00380
00381 $iStartPos += 4;
00382 $sPayCostVAT = $oLang->formatCurrency( $this->_oData->getOrderPaymentPrice()->getVATValue(), $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00383 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ).$this->_oData->oxorder__oxpayvat->value.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_PERCENTSUM' ) );
00384 $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCostVAT ), $iStartPos, $sPayCostVAT );
00385
00386 }
00387
00388
00389 if ( $this->_oData->oxorder__oxstorno->value ) {
00390 $this->_oData->oxorder__oxpaycost->setValue(0);
00391 }
00392
00393
00394 if ( $this->_oData->oxorder__oxpaycost->value ) {
00395 $iStartPos += 4;
00396 $sPayCost = $oLang->formatCurrency( $this->_oData->oxorder__oxpaycost->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00397 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_PAYMENTIMPACT' ) );
00398 $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCost ), $iStartPos, $sPayCost );
00399 }
00400
00401 $iStartPos++;
00402 }
00403
00411 protected function _setTsProtection( &$iStartPos )
00412 {
00413 $oLang = oxLang::getInstance();
00414 $oConfig = oxConfig::getInstance();
00415 if ( $oConfig->getConfigParam( 'blCalcVATForPayCharge' ) ) {
00416
00417
00418 $iStartPos += 4;
00419 $sPayCostNetto = $oLang->formatCurrency( $this->_oData->getOrderTsProtectionPrice()->getNettoPrice(), $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00420 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_TSPROTECTION' ).' '.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_NETTO' ) );
00421 $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCostNetto ), $iStartPos, $sPayCostNetto );
00422
00423
00424 $iStartPos += 4;
00425 $sPayCostVAT = $oLang->formatCurrency( $this->_oData->getOrderTsProtectionPrice()->getVATValue(), $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00426 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ).$oConfig->getConfigParam( 'dDefaultVAT' ).$this->_oData->translate( 'ORDER_OVERVIEW_PDF_PERCENTSUM' ) );
00427 $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCostVAT ), $iStartPos, $sPayCostVAT );
00428
00429 }
00430
00431
00432 if ( $this->_oData->oxorder__oxtsprotectcosts->value ) {
00433 $iStartPos += 4;
00434 $sPayCost = $oLang->formatCurrency( $this->_oData->oxorder__oxtsprotectcosts->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00435 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_TSPROTECTION' ) );
00436 $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCost ), $iStartPos, $sPayCost );
00437 }
00438
00439 $iStartPos++;
00440 }
00441
00449 protected function _setGrandTotalPriceInfo( &$iStartPos )
00450 {
00451 $oLang = oxLang::getInstance();
00452
00453
00454 $this->font( 'Arial', 'B', 10 );
00455 if ( $this->_oData->oxorder__oxdelvat->value || $this->_oData->oxorder__oxwrapvat->value || $this->_oData->oxorder__oxpayvat->value ) {
00456
00457
00458 $sTotalNetSum = $oLang->formatCurrency( $this->_oData->getOrderNetSum(), $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00459 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLSUM_NET' ) );
00460 $this->text( 195 - $this->_oPdf->getStringWidth( $sTotalNetSum ), $iStartPos, $sTotalNetSum );
00461 $iStartPos += 4;
00462 }
00463
00464
00465 $sTotalOrderSum = $oLang->formatCurrency( $this->_oData->oxorder__oxtotalordersum->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00466 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLSUM' ) );
00467 $this->text( 195 - $this->_oPdf->getStringWidth( $sTotalOrderSum ), $iStartPos, $sTotalOrderSum );
00468 $iStartPos += 2;
00469 }
00470
00478 protected function _setPaymentMethodInfo( &$iStartPos )
00479 {
00480 $oPayment = oxNew( 'oxpayment' );
00481 $oPayment->loadInLang( $this->_oData->getSelectedLang(), $this->_oData->oxorder__oxpaymenttype->value );
00482
00483 $text = $this->_oData->translate( 'ORDER_OVERVIEW_PDF_SELPAYMENT' ).$oPayment->oxpayments__oxdesc->value;
00484 $this->font( 'Arial', '', 10 );
00485 $this->text( 15, $iStartPos + 4, $text );
00486 $iStartPos += 4;
00487 }
00488
00496 protected function _setPayUntilInfo( &$iStartPos )
00497 {
00498 $text = $this->_oData->translate( 'ORDER_OVERVIEW_PDF_PAYUPTO' ).date( 'd.m.Y', mktime( 0, 0, 0, date ( 'm' ), date ( 'd' ) + 7, date( 'Y' ) ) );
00499 $this->font( 'Arial', '', 10 );
00500 $this->text( 15, $iStartPos + 4, $text );
00501 $iStartPos += 4;
00502 }
00503
00511 public function generate( $iStartPos )
00512 {
00513
00514 $this->font( 'Arial', '', 10 );
00515 $siteH = $iStartPos;
00516
00517
00518 if ( !$this->_oData->oxorder__oxdiscount->value ) {
00519 $this->_setTotalCostsWithoutDiscount( $siteH );
00520 } else {
00521 $this->_setTotalCostsWithDiscount( $siteH );
00522 }
00523
00524 $siteH += 12;
00525
00526
00527 $this->_setVoucherInfo( $siteH );
00528
00529
00530 if ( $this->_oData->oxorder__oxdiscount->value || $this->_oData->oxorder__oxvoucherdiscount->value ) {
00531 $this->line( 45, $siteH - 3, 195, $siteH - 3 );
00532 }
00533
00534
00535 $this->_setDeliveryInfo( $siteH );
00536
00537
00538 $this->_setWrappingInfo( $siteH );
00539
00540
00541 $this->_setPaymentInfo( $siteH );
00542
00543
00544 $this->_setTsProtection( $siteH );
00545
00546
00547 $this->line( 15, $siteH, 195, $siteH );
00548 $siteH += 4;
00549
00550
00551 $this->_setGrandTotalPriceInfo( $siteH );
00552
00553
00554 $this->line( 15, $siteH, 195, $siteH );
00555 $siteH += 4;
00556
00557
00558 $this->_setPaymentMethodInfo( $siteH );
00559
00560
00561 $this->_setPayUntilInfo( $siteH );
00562
00563 return $siteH - $iStartPos;
00564 }
00565 }
00566
00570 class MyOrder extends MyOrder_parent
00571 {
00572
00577 protected $_iSelectedLang = 0;
00578
00583 protected $_oActShop = null;
00584
00589 protected $_aVATs = array();
00590
00595 protected $_oCur = null;
00596
00602 protected function _getActShop()
00603 {
00604
00605 if ( $this->_oActShop !== null )
00606 return $this->_oActShop;
00607
00608 $this->_oActShop = oxNew( 'oxshop' );
00609 $this->_oActShop->load( $this->getConfig()->getShopId() );
00610
00611 return $this->_oActShop;
00612 }
00613
00621 public function translate( $sString )
00622 {
00623 return oxLang::getInstance()->translateString( $sString, $this->_iSelectedLang );
00624 }
00625
00633 public function pdfFooter( $oPdf )
00634 {
00635
00636 $oShop = $this->_getActShop();
00637
00638 $oPdf->line( 15, 272, 195, 272 );
00639
00640
00641 $oPdf->setFont( 'Arial', '', 7 );
00642 $oPdf->text( 15, 275, strip_tags( $oShop->oxshops__oxcompany->getRawValue() ) );
00643 $oPdf->text( 15, 278, strip_tags( $oShop->oxshops__oxfname->getRawValue() ).' '. strip_tags( $oShop->oxshops__oxlname->getRawValue() ) );
00644 $oPdf->text( 15, 281, strip_tags( $oShop->oxshops__oxstreet->getRawValue() ) );
00645 $oPdf->text( 15, 284, strip_tags( $oShop->oxshops__oxzip->value ).' '. strip_tags( $oShop->oxshops__oxcity->getRawValue() ) );
00646 $oPdf->text( 15, 287, strip_tags( $oShop->oxshops__oxcountry->getRawValue() ) );
00647
00648
00649 $oPdf->text( 85, 275, $this->translate( 'ORDER_OVERVIEW_PDF_PHONE' ).strip_tags( $oShop->oxshops__oxtelefon->value ) );
00650 $oPdf->text( 85, 278, $this->translate( 'ORDER_OVERVIEW_PDF_FAX' ).strip_tags( $oShop->oxshops__oxtelefax->value ) );
00651 $oPdf->text( 85, 281, strip_tags( $oShop->oxshops__oxurl->value ) );
00652 $oPdf->text( 85, 284, strip_tags( $oShop->oxshops__oxorderemail->value ) );
00653
00654
00655 $oPdf->text( 150, 275, strip_tags( $oShop->oxshops__oxbankname->getRawValue() ) );
00656 $oPdf->text( 150, 278, $this->translate( 'ORDER_OVERVIEW_PDF_ACCOUNTNR' ).strip_tags( $oShop->oxshops__oxbanknumber->value ) );
00657 $oPdf->text( 150, 281, $this->translate( 'ORDER_OVERVIEW_PDF_BANKCODE' ).strip_tags( $oShop->oxshops__oxbankcode->value ) );
00658 $oPdf->text( 150, 284, strip_tags( $oShop->oxshops__oxvatnumber->value ) );
00659 $oPdf->text( 150, 287, '' );
00660 }
00661
00669 public function pdfHeaderPlus( $oPdf )
00670 {
00671
00672
00673 $this->pdfHeader( $oPdf );
00674
00675
00676 $oPdf->setFont( 'Arial', '', 8 );
00677 $oPdf->text( 15, 50, $this->translate( 'ORDER_OVERVIEW_PDF_AMOUNT' ) );
00678 $oPdf->text( 30, 50, $this->translate( 'ORDER_OVERVIEW_PDF_ARTID') );
00679 $oPdf->text( 45, 50, $this->translate( 'ORDER_OVERVIEW_PDF_DESC' ) );
00680 $oPdf->text( 160, 50, $this->translate( 'ORDER_OVERVIEW_PDF_UNITPRICE' ) );
00681 $sText = $this->translate( 'ORDER_OVERVIEW_PDF_ALLPRICE' );
00682 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), 50, $sText );
00683
00684
00685 $oPdf->line( 15, 52, 195, 52 );
00686
00687 return 56;
00688 }
00689
00697 public function pdfHeader( $oPdf )
00698 {
00699
00700 $oPdf->addPage();
00701
00702
00703 $oShop = $this->_getActShop();
00704
00705
00706 $myConfig = $this->getConfig();
00707 $aSize = getimagesize( $myConfig->getAbsImageDir().'/pdf_logo.jpg' );
00708 $iMargin = 195 - $aSize[0] * 0.2;
00709 $oPdf->setLink( $oShop->oxshops__oxurl->value );
00710 $oPdf->image( $myConfig->getAbsImageDir().'/pdf_logo.jpg', $iMargin, 10, $aSize[0] * 0.2, $aSize[1] * 0.2, '', $oShop->oxshops__oxurl->value );
00711 return 14 + $aSize[1] * 0.2;
00712 }
00713
00722 public function genPdf( $sFilename, $iSelLang = 0 )
00723 {
00724
00725 $this->_iSelectedLang = $iSelLang;
00726
00727
00728 if ( !$this->oxorder__oxbillnr->value ) {
00729 $this->oxorder__oxbillnr->setValue($this->getNextBillNum());
00730 $this->save();
00731 }
00732
00733
00734 $oPdf = oxNew( 'oxPDF' );
00735 $oPdf->setPrintHeader( false );
00736 $oPdf->open();
00737
00738
00739 $this->pdfHeader( $oPdf );
00740
00741
00742 switch ( oxConfig::getParameter( 'pdftype' ) ) {
00743 case 'dnote':
00744 $this->exportDeliveryNote( $oPdf );
00745 break;
00746 default:
00747 $this->exportStandart( $oPdf );
00748 }
00749
00750
00751 $this->pdfFooter( $oPdf );
00752
00753
00754 $oPdf->output( $sFilename, 'I' );
00755 }
00756
00757
00765 protected function _setBillingAddressToPdf( $oPdf )
00766 {
00767 $oLang = oxLang::getInstance();
00768 $sSal = $this->oxorder__oxbillsal->value;
00769 try {
00770 $sSal = $oLang->translateString($this->oxorder__oxbillsal->value, $this->_iSelectedLang);
00771 } catch (Exception $e) {
00772 }
00773 $oPdf->setFont( 'Arial', '', 10 );
00774 $oPdf->text( 15, 59, $sSal);
00775 $oPdf->text( 15, 63, $this->oxorder__oxbilllname->getRawValue().' '.$this->oxorder__oxbillfname->getRawValue() );
00776 $oPdf->text( 15, 67, $this->oxorder__oxbillcompany->getRawValue() );
00777 $oPdf->text( 15, 71, $this->oxorder__oxbillstreet->getRawValue().' '.$this->oxorder__oxbillstreetnr->value );
00778 $oPdf->setFont( 'Arial', 'B', 10 );
00779 $oPdf->text( 15, 75, $this->oxorder__oxbillzip->value.' '.$this->oxorder__oxbillcity->getRawValue() );
00780 $oPdf->setFont( 'Arial', '', 10 );
00781 $oPdf->text( 15, 79, $this->oxorder__oxbillcountry->getRawValue() );
00782 }
00783
00791 protected function _setDeliveryAddressToPdf( $oPdf )
00792 {
00793 $oLang = oxLang::getInstance();
00794 $sSal = $this->oxorder__oxdelsal->value;
00795 try {
00796 $sSal = $oLang->translateString($this->oxorder__oxdelsal->value, $this->_iSelectedLang);
00797 } catch (Exception $e) {
00798 }
00799 $oPdf->setFont( 'Arial', '', 6 );
00800 $oPdf->text( 15, 87, $this->translate( 'ORDER_OVERVIEW_PDF_DELIVERYADDRESS' ) );
00801 $oPdf->setFont( 'Arial', '', 10 );
00802 $oPdf->text( 15, 91, $sSal);
00803 $oPdf->text( 15, 95, $this->oxorder__oxdellname->getRawValue().' '.$this->oxorder__oxdelfname->getRawValue() );
00804 $oPdf->text( 15, 99, $this->oxorder__oxdelcompany->getRawValue() );
00805 $oPdf->text( 15, 103, $this->oxorder__oxdelstreet->getRawValue().' '.$this->oxorder__oxdelstreetnr->value );
00806 $oPdf->setFont( 'Arial', 'B', 10 );
00807 $oPdf->text( 15, 107, $this->oxorder__oxdelzip->value.' '.$this->oxorder__oxdelcity->getRawValue() );
00808 $oPdf->setFont( 'Arial', '', 10 );
00809 $oPdf->text( 15, 111, $this->oxorder__oxdelcountry->getRawValue() );
00810 }
00811
00821 protected function _setOrderArticlesToPdf( $oPdf, &$iStartPos, $blShowPrice = true )
00822 {
00823 if (!$this->_oArticles) {
00824 $this->_oArticles = $this->getOrderArticles(true);
00825 }
00826
00827 $oCurr = $this->getCurrency();
00828
00829
00830 foreach ( $this->_oArticles as $key => $oOrderArt ) {
00831
00832
00833 if ( $iStartPos > 243 ) {
00834 $this->pdffooter( $oPdf );
00835 $iStartPos = $this->pdfheaderplus( $oPdf );
00836 $oPdf->setFont( 'Arial', '', 10 );
00837 } else {
00838 $iStartPos = $iStartPos + 4;
00839 }
00840
00841
00842 $oPdf->text( 20 - $oPdf->getStringWidth( $oOrderArt->oxorderarticles__oxamount->value ), $iStartPos, $oOrderArt->oxorderarticles__oxamount->value );
00843
00844
00845 $oPdf->setFont( 'Arial', '', 8 );
00846 $oPdf->text( 28, $iStartPos, $oOrderArt->oxorderarticles__oxartnum->value );
00847
00848
00849 $oPdf->setFont( 'Arial', '', 10 );
00850 $oPdf->text( 45, $iStartPos, substr( strip_tags( $this->_replaceExtendedChars( $oOrderArt->oxorderarticles__oxtitle->getRawValue(), true ) ), 0, 58 ) );
00851
00852 if ( $blShowPrice ) {
00853 $oLang = oxLang::getInstance();
00854
00855
00856 if ( !isset( $this->_aVATs[$oOrderArt->oxorderarticles__oxvat->value] ) ) {
00857 $this->_aVATs[$oOrderArt->oxorderarticles__oxvat->value] = 0;
00858 }
00859
00860 if ( $oOrderArt->oxorderarticles__oxamount->value > 0 ) {
00861 $this->_aVATs[$oOrderArt->oxorderarticles__oxvat->value] += ( $oOrderArt->oxorderarticles__oxvatprice->value * $oCurr->rate );
00862 }
00863
00864
00865 $oPdf->text( 150 - $oPdf->getStringWidth( $oOrderArt->oxorderarticles__oxvat->value ), $iStartPos, $oOrderArt->oxorderarticles__oxvat->value );
00866
00867
00868 $sText = $oLang->formatCurrency( $oOrderArt->oxorderarticles__oxbprice->value, $this->_oCur ).' '.$this->_oCur->name;
00869 $oPdf->text( 173 - $oPdf->getStringWidth( $sText ), $iStartPos, $sText );
00870
00871
00872 $sText = $oLang->formatCurrency( $oOrderArt->oxorderarticles__oxbrutprice->value, $this->_oCur ).' '.$this->_oCur->name;
00873 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iStartPos, $sText );
00874
00875 }
00876
00877
00878 if ( $oOrderArt->oxorderarticles__oxselvariant->value ) {
00879 $iStartPos = $iStartPos + 4;
00880 $oPdf->text( 45, $iStartPos, substr( $oOrderArt->oxorderarticles__oxselvariant->value, 0, 58 ) );
00881 }
00882
00883 }
00884 }
00885
00893 public function exportStandart( $oPdf )
00894 {
00895
00896 $myConfig = $this->getConfig();
00897
00898 $this->_oCur = $myConfig->getCurrencyObject( $this->oxorder__oxcurrency->value );
00899 if ( !$this->_oCur ) {
00900 $this->_oCur = $myConfig->getActShopCurrencyObject();
00901 }
00902
00903
00904 $oShop = $this->_getActShop();
00905
00906
00907 $oPdf->setFont( 'Arial', '', 6 );
00908 $oPdf->text( 15, 55, $oShop->oxshops__oxname->getRawValue().' - '.$oShop->oxshops__oxstreet->getRawValue().' - '.$oShop->oxshops__oxzip->value.' - '.$oShop->oxshops__oxcity->getRawValue() );
00909
00910
00911 $this->_setBillingAddressToPdf( $oPdf );
00912
00913
00914 if ( $this->oxorder__oxdelsal->value ) {
00915 $this->_setDeliveryAddressToPdf( $oPdf );
00916 }
00917
00918
00919 $oUser = oxNew( 'oxuser' );
00920 $oUser->load( $this->oxorder__oxuserid->value );
00921
00922
00923 $sText = $this->translate( 'ORDER_OVERVIEW_PDF_FILLONPAYMENT' );
00924 $oPdf->setFont( 'Arial', '', 5 );
00925 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), 55, $sText );
00926
00927
00928 $sCustNr = $this->translate( 'ORDER_OVERVIEW_PDF_CUSTNR').' '.$oUser->oxuser__oxcustnr->value;
00929 $oPdf->setFont( 'Arial', '', 7 );
00930 $oPdf->text( 195 - $oPdf->getStringWidth( $sCustNr ), 59, $sCustNr );
00931
00932
00933 if ( $this->oxorder__oxdelsal->value ) {
00934 $iTop = 115;
00935 } else {
00936 $iTop = 91;
00937 }
00938
00939
00940 $sText = $oShop->oxshops__oxcity->getRawValue().', '.date( 'd.m.Y' );
00941 $oPdf->setFont( 'Arial', '', 10 );
00942 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop + 8, $sText );
00943
00944
00945 if ( $oShop->oxshops__oxvatnumber->value ) {
00946 $sText = $this->translate( 'ORDER_OVERVIEW_PDF_TAXIDNR' ).' '.$oShop->oxshops__oxvatnumber->value;
00947 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop + 12, $sText );
00948 $iTop += 8;
00949 } else {
00950 $iTop += 4;
00951 }
00952
00953
00954 $sText = $this->translate( 'ORDER_OVERVIEW_PDF_COUNTNR' ).' '.$this->oxorder__oxbillnr->value;
00955 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop + 8, $sText );
00956
00957
00958 if ( $this->oxorder__oxstorno->value == 1 ) {
00959 $this->oxorder__oxordernr->setValue( $this->oxorder__oxordernr->getRawValue() . ' '.$this->translate( 'ORDER_OVERVIEW_PDF_STORNO' ), oxField::T_RAW );
00960 }
00961
00962
00963 $oPdf->setFont( 'Arial', '', 12 );
00964 $oPdf->text( 15, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_PURCHASENR' ).' '.$this->oxorder__oxordernr->value );
00965
00966
00967 $oPdf->setFont( 'Arial', '', 10 );
00968 $aOrderDate = explode( ' ', $this->oxorder__oxorderdate->value );
00969 $sOrderDate = oxUtilsDate::getInstance()->formatDBDate( $aOrderDate[0]);
00970 $oPdf->text( 15, $iTop + 8, $this->translate( 'ORDER_OVERVIEW_PDF_ORDERSFROM' ).$sOrderDate.$this->translate( 'ORDER_OVERVIEW_PDF_ORDERSAT' ).$oShop->oxshops__oxurl->value );
00971 $iTop += 16;
00972
00973
00974 $oPdf->setFont( 'Arial', '', 8 );
00975 $oPdf->text( 15, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_AMOUNT' ) );
00976 $oPdf->text( 30, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_ARTID' ) );
00977 $oPdf->text( 45, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_DESC' ) );
00978 $oPdf->text( 145, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_VAT' ) );
00979 $oPdf->text( 158, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_UNITPRICE' ) );
00980 $sText = $this->translate( 'ORDER_OVERVIEW_PDF_ALLPRICE' );
00981 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop, $sText );
00982
00983
00984 $iTop += 2;
00985 $oPdf->line( 15, $iTop, 195, $iTop );
00986
00987
00988 $siteH = $iTop;
00989 $oPdf->setFont( 'Arial', '', 10 );
00990
00991
00992 $this->_setOrderArticlesToPdf( $oPdf, $siteH, true );
00993
00994
00995 $oArtSumm = new PdfArticleSummary( $this, $oPdf );
00996 $iHeight = $oArtSumm->generate( $siteH );
00997 if ( $siteH + $iHeight > 258 ) {
00998 $this->pdfFooter( $oPdf );
00999 $iTop = $this->pdfHeader( $oPdf );
01000 $oArtSumm->ajustHeight( $iTop - $siteH );
01001 $siteH = $iTop;
01002 }
01003
01004 $oArtSumm->run( $oPdf );
01005 $siteH += $iHeight + 8;
01006
01007 $oPdf->text( 15, $siteH, $this->translate( 'ORDER_OVERVIEW_PDF_GREETINGS' ) );
01008 }
01009
01017 public function exportDeliveryNote( $oPdf )
01018 {
01019 $myConfig = $this->getConfig();
01020 $oShop = $this->_getActShop();
01021
01022 $oLang = oxLang::getInstance();
01023 $sSal = $this->oxorder__oxdelsal->value;
01024 try {
01025 $sSal = $oLang->translateString($this->oxorder__oxdelsal->value, $this->_iSelectedLang);
01026 } catch (Exception $e) {
01027 }
01028
01029
01030 $this->_oCur = $myConfig->getCurrencyObject( $this->oxorder__oxcurrency->value );
01031 if ( !isset( $this->_oCur ) ) {
01032 $this->_oCur = $myConfig->getActShopCurrencyObject();
01033 }
01034
01035
01036 $oPdf->setFont( 'Arial', '', 6 );
01037 $oPdf->text( 15, 55, $oShop->oxshops__oxname->getRawValue().' - '.$oShop->oxshops__oxstreet->getRawValue().' - '.$oShop->oxshops__oxzip->value.' - '.$oShop->oxshops__oxcity->getRawValue() );
01038
01039
01040 $oPdf->setFont( 'Arial', '', 10 );
01041 if ( $this->oxorder__oxdelsal->value ) {
01042 $oPdf->text( 15, 59, $sSal );
01043 $oPdf->text( 15, 63, $this->oxorder__oxdellname->getRawValue().' '.$this->oxorder__oxdelfname->getRawValue() );
01044 $oPdf->text( 15, 67, $this->oxorder__oxdelcompany->getRawValue() );
01045 $oPdf->text( 15, 71, $this->oxorder__oxdelstreet->getRawValue().' '.$this->oxorder__oxdelstreetnr->value );
01046 $oPdf->setFont( 'Arial', 'B', 10 );
01047 $oPdf->text( 15, 75, $this->oxorder__oxdelzip->value.' '.$this->oxorder__oxdelcity->getRawValue() );
01048 $oPdf->setFont( 'Arial', '', 10 );
01049 $oPdf->text( 15, 79, $this->oxorder__oxdelcountry->getRawValue() );
01050 } else {
01051
01052 $this->_setBillingAddressToPdf( $oPdf );
01053 }
01054
01055
01056 $oUser = oxNew( 'oxuser' );
01057 $oUser->load( $this->oxorder__oxuserid->value );
01058
01059
01060 $sText = $this->translate( 'ORDER_OVERVIEW_PDF_FILLONPAYMENT' );
01061 $oPdf->setFont( 'Arial', '', 5 );
01062 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), 70, $sText );
01063
01064
01065 $sCustNr = $this->translate( 'ORDER_OVERVIEW_PDF_CUSTNR' ).' '.$oUser->oxuser__oxcustnr->value;
01066 $oPdf->setFont( 'Arial', '', 7 );
01067 $oPdf->text( 195 - $oPdf->getStringWidth( $sCustNr ), 73, $sCustNr );
01068
01069
01070 $sText = $oShop->oxshops__oxcity->getRawValue().', '.date( 'd.m.Y' );
01071 $oPdf->setFont( 'Arial', '', 10 );
01072 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), 95, $sText );
01073
01074 $iTop = 99;
01075
01076 if ( $oShop->oxshops__oxvatnumber->value ) {
01077 $sText = $this->translate( 'ORDER_OVERVIEW_PDF_TAXIDNR' ).' '.$oShop->oxshops__oxvatnumber->value;
01078 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop, $sText );
01079 $iTop += 4;
01080 }
01081
01082
01083 $sText = $this->translate( 'ORDER_OVERVIEW_PDF_COUNTNR' ).' '.$this->oxorder__oxbillnr->value;
01084 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop, $sText );
01085
01086
01087 if ( $this->oxorder__oxstorno->value == 1 ) {
01088 $this->oxorder__oxordernr->setValue( $this->oxorder__oxordernr->getRawValue() . ' '.$this->translate( 'ORDER_OVERVIEW_PDF_STORNO' ), oxField::T_RAW );
01089 }
01090
01091
01092 $oPdf->setFont( 'Arial', '', 12 );
01093 $oPdf->text( 15, 108, $this->translate( 'ORDER_OVERVIEW_PDF_DELIVNOTE' ).' '.$this->oxorder__oxordernr->value );
01094
01095
01096 $aOrderDate = explode( ' ', $this->oxorder__oxorderdate->value );
01097 $sOrderDate = oxUtilsDate::getInstance()->formatDBDate( $aOrderDate[0]);
01098 $oPdf->setFont( 'Arial', '', 10 );
01099 $oPdf->text(15, 119, $this->translate( 'ORDER_OVERVIEW_PDF_ORDERSFROM' ).$sOrderDate.$this->translate( 'ORDER_OVERVIEW_PDF_ORDERSAT' ).$oShop->oxshops__oxurl->value );
01100
01101
01102 $oPdf->setFont( 'Arial', '', 8 );
01103 $oPdf->text( 15, 128, $this->translate( 'ORDER_OVERVIEW_PDF_AMOUNT' ) );
01104 $oPdf->text( 30, 128, $this->translate( 'ORDER_OVERVIEW_PDF_ARTID' ) );
01105 $oPdf->text( 45, 128, $this->translate( 'ORDER_OVERVIEW_PDF_DESC' ) );
01106
01107
01108 $oPdf->line( 15, 130, 195, 130 );
01109
01110
01111 $oPdf->setFont( 'Arial', '', 10 );
01112 $siteH = 130;
01113
01114
01115 $this->_setOrderArticlesToPdf( $oPdf, $siteH, false );
01116
01117
01118 $oPdf->line( 15, $siteH + 2, 195, $siteH + 2 );
01119 $siteH += 4;
01120
01121
01122 $oPdf->setFont( 'Arial', '', 10 );
01123 $text = $this->translate( 'ORDER_OVERVIEW_PDF_PAYUPTO' ).date( 'd.m.Y', mktime( 0, 0, 0, date ( 'm' ), date ( 'd' ) + 7, date( 'Y' ) ) );
01124 $oPdf->text( 15, $siteH + 4, $text );
01125 }
01126
01136 protected function _replaceExtendedChars( $sValue, $blReverse = false )
01137 {
01138
01139
01140
01141
01142
01143
01144 $aReplace = array( chr(169) => "©", chr(128) => "€", "\"" => """, "'" => "'");
01145
01146
01147
01148 if ($blReverse) {
01149
01150 $aTransTbl = get_html_translation_table (HTML_ENTITIES);
01151 $aTransTbl = array_flip ($aTransTbl) + array_flip ($aReplace);
01152 $sValue = strtr($sValue, $aTransTbl);
01153 $sValue = getStr()->preg_replace('/\&\#([0-9]+)\;/me', "chr('\\1')", $sValue);
01154 }
01155
01156 return $sValue;
01157 }
01158
01164 public function getVats()
01165 {
01166
01167 $aVats = $this->getProductVats( false );
01168
01169
01170 return ( is_array( $aVats ) && count( $aVats ) ) ? $aVats : $this->_aVATs;
01171 }
01172
01178 public function getCurrency()
01179 {
01180 return $this->_oCur;
01181 }
01182
01188 public function getSelectedLang()
01189 {
01190 return $this->_iSelectedLang;
01191 }
01192
01200 public function getOrderArticles( $blStorno = false )
01201 {
01202 if ( $this->_oArticles == null ) {
01203
01204 $this->_oArticles = oxNew( 'oxlist' );
01205 $this->_oArticles->init( 'oxorderarticle' );
01206
01207 $sSelect = 'select oxorderarticles.* from oxorderarticles where oxorderarticles.oxorderid="'.$this->getId().'"';
01208 if ( $blStorno ) {
01209 $sSelect.= ' and oxstorno = 0';
01210 }
01211 $sSelect.= ' order by oxorderarticles.oxartid';
01212 $this->_oArticles->selectString( $sSelect );
01213 }
01214
01215 return $this->_oArticles;
01216 }
01217 }