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->getProductVats(false) 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->getProductVats(false) 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 _setGrandTotalPriceInfo( &$iStartPos )
00412 {
00413 $oLang = oxLang::getInstance();
00414
00415
00416 $this->font( 'Arial', 'B', 10 );
00417 if ( $this->_oData->oxorder__oxdelvat->value || $this->_oData->oxorder__oxwrapvat->value || $this->_oData->oxorder__oxpayvat->value ) {
00418
00419
00420 $sTotalNetSum = $oLang->formatCurrency( $this->_oData->getOrderNetSum(), $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00421 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLSUM_NET' ) );
00422 $this->text( 195 - $this->_oPdf->getStringWidth( $sTotalNetSum ), $iStartPos, $sTotalNetSum );
00423 $iStartPos += 4;
00424 }
00425
00426
00427 $sTotalOrderSum = $oLang->formatCurrency( $this->_oData->oxorder__oxtotalordersum->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
00428 $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLSUM' ) );
00429 $this->text( 195 - $this->_oPdf->getStringWidth( $sTotalOrderSum ), $iStartPos, $sTotalOrderSum );
00430 $iStartPos += 2;
00431 }
00432
00440 protected function _setPaymentMethodInfo( &$iStartPos )
00441 {
00442 $oPayment = oxNew( 'oxpayment' );
00443 $oPayment->loadInLang( $this->_oData->getSelectedLang(), $this->_oData->oxorder__oxpaymenttype->value );
00444
00445 $text = $this->_oData->translate( 'ORDER_OVERVIEW_PDF_SELPAYMENT' ).$oPayment->oxpayments__oxdesc->value;
00446 $this->font( 'Arial', '', 10 );
00447 $this->text( 15, $iStartPos + 4, $text );
00448 $iStartPos += 4;
00449 }
00450
00458 protected function _setPayUntilInfo( &$iStartPos )
00459 {
00460 $text = $this->_oData->translate( 'ORDER_OVERVIEW_PDF_PAYUPTO' ).date( 'd.m.Y', mktime( 0, 0, 0, date ( 'm' ), date ( 'd' ) + 7, date( 'Y' ) ) );
00461 $this->font( 'Arial', '', 10 );
00462 $this->text( 15, $iStartPos + 4, $text );
00463 $iStartPos += 4;
00464 }
00465
00473 public function generate( $iStartPos )
00474 {
00475
00476 $this->font( 'Arial', '', 10 );
00477 $siteH = $iStartPos;
00478
00479
00480 if ( !$this->_oData->oxorder__oxdiscount->value ) {
00481 $this->_setTotalCostsWithoutDiscount( $siteH );
00482 } else {
00483 $this->_setTotalCostsWithDiscount( $siteH );
00484 }
00485
00486 $siteH += 12;
00487
00488
00489 $this->_setVoucherInfo( $siteH );
00490
00491
00492 if ( $this->_oData->oxorder__oxdiscount->value || $this->_oData->oxorder__oxvoucherdiscount->value ) {
00493 $this->line( 45, $siteH - 3, 195, $siteH - 3 );
00494 }
00495
00496
00497 $this->_setDeliveryInfo( $siteH );
00498
00499
00500 $this->_setWrappingInfo( $siteH );
00501
00502
00503 $this->_setPaymentInfo( $siteH );
00504
00505
00506 $this->line( 15, $siteH, 195, $siteH );
00507 $siteH += 4;
00508
00509
00510 $this->_setGrandTotalPriceInfo( $siteH );
00511
00512
00513 $this->line( 15, $siteH, 195, $siteH );
00514 $siteH += 4;
00515
00516
00517 $this->_setPaymentMethodInfo( $siteH );
00518
00519
00520 $this->_setPayUntilInfo( $siteH );
00521
00522 return $siteH - $iStartPos;
00523 }
00524 }
00525
00529 class MyOrder extends MyOrder_parent
00530 {
00531
00536 protected $_iSelectedLang = 0;
00537
00542 protected $_oActShop = null;
00543
00548 protected $_oCur = null;
00549
00555 protected function _getActShop()
00556 {
00557
00558 if ( $this->_oActShop !== null )
00559 return $this->_oActShop;
00560
00561 $this->_oActShop = oxNew( 'oxshop' );
00562 $this->_oActShop->load( $this->getConfig()->getShopId() );
00563
00564 return $this->_oActShop;
00565 }
00566
00574 public function translate( $sString )
00575 {
00576 return oxLang::getInstance()->translateString( $sString, $this->_iSelectedLang );
00577 }
00578
00586 public function pdfFooter( $oPdf )
00587 {
00588
00589 $oShop = $this->_getActShop();
00590
00591 $oPdf->line( 15, 272, 195, 272 );
00592
00593
00594 $oPdf->setFont( 'Arial', '', 7 );
00595 $oPdf->text( 15, 275, strip_tags( $oShop->oxshops__oxcompany->getRawValue() ) );
00596 $oPdf->text( 15, 278, strip_tags( $oShop->oxshops__oxfname->getRawValue() ).' '. strip_tags( $oShop->oxshops__oxlname->getRawValue() ) );
00597 $oPdf->text( 15, 281, strip_tags( $oShop->oxshops__oxstreet->getRawValue() ) );
00598 $oPdf->text( 15, 284, strip_tags( $oShop->oxshops__oxzip->value ).' '. strip_tags( $oShop->oxshops__oxcity->getRawValue() ) );
00599 $oPdf->text( 15, 287, strip_tags( $oShop->oxshops__oxcountry->getRawValue() ) );
00600
00601
00602 $oPdf->text( 85, 275, $this->translate( 'ORDER_OVERVIEW_PDF_PHONE' ).strip_tags( $oShop->oxshops__oxtelefon->value ) );
00603 $oPdf->text( 85, 278, $this->translate( 'ORDER_OVERVIEW_PDF_FAX' ).strip_tags( $oShop->oxshops__oxtelefax->value ) );
00604 $oPdf->text( 85, 281, strip_tags( $oShop->oxshops__oxurl->value ) );
00605 $oPdf->text( 85, 284, strip_tags( $oShop->oxshops__oxorderemail->value ) );
00606
00607
00608 $oPdf->text( 150, 275, strip_tags( $oShop->oxshops__oxbankname->getRawValue() ) );
00609 $oPdf->text( 150, 278, $this->translate( 'ORDER_OVERVIEW_PDF_ACCOUNTNR' ).strip_tags( $oShop->oxshops__oxbanknumber->value ) );
00610 $oPdf->text( 150, 281, $this->translate( 'ORDER_OVERVIEW_PDF_BANKCODE' ).strip_tags( $oShop->oxshops__oxbankcode->value ) );
00611 $oPdf->text( 150, 284, strip_tags( $oShop->oxshops__oxvatnumber->value ) );
00612 $oPdf->text( 150, 287, '' );
00613 }
00614
00622 public function pdfHeaderPlus( $oPdf )
00623 {
00624
00625
00626 $this->pdfHeader( $oPdf );
00627
00628
00629 $oPdf->setFont( 'Arial', '', 8 );
00630 $oPdf->text( 15, 50, $this->translate( 'ORDER_OVERVIEW_PDF_AMOUNT' ) );
00631 $oPdf->text( 30, 50, $this->translate( 'ORDER_OVERVIEW_PDF_ARTID') );
00632 $oPdf->text( 45, 50, $this->translate( 'ORDER_OVERVIEW_PDF_DESC' ) );
00633 $oPdf->text( 160, 50, $this->translate( 'ORDER_OVERVIEW_PDF_UNITPRICE' ) );
00634 $sText = $this->translate( 'ORDER_OVERVIEW_PDF_ALLPRICE' );
00635 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), 50, $sText );
00636
00637
00638 $oPdf->line( 15, 52, 195, 52 );
00639
00640 return 56;
00641 }
00642
00650 public function pdfHeader( $oPdf )
00651 {
00652
00653 $oPdf->addPage();
00654
00655
00656 $oShop = $this->_getActShop();
00657
00658
00659 $myConfig = $this->getConfig();
00660 $aSize = getimagesize( $myConfig->getAbsImageDir().'/pdf_logo.jpg' );
00661 $iMargin = 195 - $aSize[0] * 0.2;
00662 $oPdf->setLink( $oShop->oxshops__oxurl->value );
00663 $oPdf->image( $myConfig->getAbsImageDir().'/pdf_logo.jpg', $iMargin, 10, $aSize[0] * 0.2, $aSize[1] * 0.2, '', $oShop->oxshops__oxurl->value );
00664 return 14 + $aSize[1] * 0.2;
00665 }
00666
00675 public function genPdf( $sFilename, $iSelLang = 0 )
00676 {
00677
00678 $this->_iSelectedLang = $iSelLang;
00679
00680
00681 if ( !$this->oxorder__oxbillnr->value ) {
00682 $this->oxorder__oxbillnr->setValue($this->getNextBillNum());
00683 $this->save();
00684 }
00685
00686
00687 $oPdf = oxNew( 'oxPDF' );
00688 $oPdf->setPrintHeader( false );
00689 $oPdf->open();
00690
00691
00692 $this->pdfHeader( $oPdf );
00693
00694
00695 switch ( oxConfig::getParameter( 'pdftype' ) ) {
00696 case 'dnote':
00697 $this->exportDeliveryNote( $oPdf );
00698 break;
00699 default:
00700 $this->exportStandart( $oPdf );
00701 }
00702
00703
00704 $this->pdfFooter( $oPdf );
00705
00706
00707 $oPdf->output( $sFilename, 'I' );
00708 }
00709
00710
00718 protected function _setBillingAddressToPdf( $oPdf )
00719 {
00720 $oLang = oxLang::getInstance();
00721 $sSal = $this->oxorder__oxbillsal->value;
00722 try {
00723 $sSal = $oLang->translateString($this->oxorder__oxbillsal->value, $this->_iSelectedLang);
00724 } catch (Exception $e) {
00725 }
00726 $oPdf->setFont( 'Arial', '', 10 );
00727 $oPdf->text( 15, 59, $sSal);
00728 $oPdf->text( 15, 63, $this->oxorder__oxbilllname->getRawValue().' '.$this->oxorder__oxbillfname->getRawValue() );
00729 $oPdf->text( 15, 67, $this->oxorder__oxbillcompany->getRawValue() );
00730 $oPdf->text( 15, 71, $this->oxorder__oxbillstreet->getRawValue().' '.$this->oxorder__oxbillstreetnr->value );
00731 $oPdf->setFont( 'Arial', 'B', 10 );
00732 $oPdf->text( 15, 75, $this->oxorder__oxbillzip->value.' '.$this->oxorder__oxbillcity->getRawValue() );
00733 $oPdf->setFont( 'Arial', '', 10 );
00734 $oPdf->text( 15, 79, $this->oxorder__oxbillcountry->getRawValue() );
00735 }
00736
00744 protected function _setDeliveryAddressToPdf( $oPdf )
00745 {
00746 $oLang = oxLang::getInstance();
00747 $sSal = $this->oxorder__oxdelsal->value;
00748 try {
00749 $sSal = $oLang->translateString($this->oxorder__oxdelsal->value, $this->_iSelectedLang);
00750 } catch (Exception $e) {
00751 }
00752 $oPdf->setFont( 'Arial', '', 6 );
00753 $oPdf->text( 15, 87, $this->translate( 'ORDER_OVERVIEW_PDF_DELIVERYADDRESS' ) );
00754 $oPdf->setFont( 'Arial', '', 10 );
00755 $oPdf->text( 15, 91, $sSal);
00756 $oPdf->text( 15, 95, $this->oxorder__oxdellname->getRawValue().' '.$this->oxorder__oxdelfname->getRawValue() );
00757 $oPdf->text( 15, 99, $this->oxorder__oxdelcompany->getRawValue() );
00758 $oPdf->text( 15, 103, $this->oxorder__oxdelstreet->getRawValue().' '.$this->oxorder__oxdelstreetnr->value );
00759 $oPdf->setFont( 'Arial', 'B', 10 );
00760 $oPdf->text( 15, 107, $this->oxorder__oxdelzip->value.' '.$this->oxorder__oxdelcity->getRawValue() );
00761 $oPdf->setFont( 'Arial', '', 10 );
00762 $oPdf->text( 15, 111, $this->oxorder__oxdelcountry->getRawValue() );
00763 }
00764
00774 protected function _setOrderArticlesToPdf( $oPdf, &$iStartPos, $blShowPrice = true )
00775 {
00776 if (!$this->_oArticles) {
00777 $this->_oArticles = $this->getOrderArticles(true);
00778 }
00779
00780
00781 foreach ( $this->_oArticles as $key => $oOrderArt ) {
00782
00783
00784 if ( $iStartPos > 243 ) {
00785 $this->pdffooter( $oPdf );
00786 $iStartPos = $this->pdfheaderplus( $oPdf );
00787 $oPdf->setFont( 'Arial', '', 10 );
00788 } else {
00789 $iStartPos = $iStartPos + 4;
00790 }
00791
00792
00793 $oPdf->text( 20 - $oPdf->getStringWidth( $oOrderArt->oxorderarticles__oxamount->value ), $iStartPos, $oOrderArt->oxorderarticles__oxamount->value );
00794
00795
00796 $oPdf->setFont( 'Arial', '', 8 );
00797 $oPdf->text( 28, $iStartPos, $oOrderArt->oxorderarticles__oxartnum->value );
00798
00799
00800 $oPdf->setFont( 'Arial', '', 10 );
00801 $oPdf->text( 45, $iStartPos, substr( strip_tags( $this->_replaceExtendedChars( $oOrderArt->oxorderarticles__oxtitle->getRawValue(), true ) ), 0, 58 ) );
00802
00803 if ( $blShowPrice ) {
00804 $oLang = oxLang::getInstance();
00805
00806
00807 $oPdf->text( 150 - $oPdf->getStringWidth( $oOrderArt->oxorderarticles__oxvat->value ), $iStartPos, $oOrderArt->oxorderarticles__oxvat->value );
00808
00809
00810 $sText = $oLang->formatCurrency( $oOrderArt->oxorderarticles__oxbprice->value, $this->_oCur ).' '.$this->_oCur->name;
00811 $oPdf->text( 173 - $oPdf->getStringWidth( $sText ), $iStartPos, $sText );
00812
00813
00814 $sText = $oLang->formatCurrency( $oOrderArt->oxorderarticles__oxbrutprice->value, $this->_oCur ).' '.$this->_oCur->name;
00815 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iStartPos, $sText );
00816
00817 }
00818
00819
00820 if ( $oOrderArt->oxorderarticles__oxselvariant->value ) {
00821 $iStartPos = $iStartPos + 4;
00822 $oPdf->text( 45, $iStartPos, substr( $oOrderArt->oxorderarticles__oxselvariant->value, 0, 58 ) );
00823 }
00824
00825 }
00826 }
00827
00835 public function exportStandart( $oPdf )
00836 {
00837
00838 $myConfig = $this->getConfig();
00839
00840 $this->_oCur = $myConfig->getCurrencyObject( $this->oxorder__oxcurrency->value );
00841 if ( !$this->_oCur ) {
00842 $this->_oCur = $myConfig->getActShopCurrencyObject();
00843 }
00844
00845
00846 $oShop = $this->_getActShop();
00847
00848
00849 $oPdf->setFont( 'Arial', '', 6 );
00850 $oPdf->text( 15, 55, $oShop->oxshops__oxname->getRawValue().' - '.$oShop->oxshops__oxstreet->getRawValue().' - '.$oShop->oxshops__oxzip->value.' - '.$oShop->oxshops__oxcity->getRawValue() );
00851
00852
00853 $this->_setBillingAddressToPdf( $oPdf );
00854
00855
00856 if ( $this->oxorder__oxdelsal->value ) {
00857 $this->_setDeliveryAddressToPdf( $oPdf );
00858 }
00859
00860
00861 $oUser = oxNew( 'oxuser' );
00862 $oUser->load( $this->oxorder__oxuserid->value );
00863
00864
00865 $sText = $this->translate( 'ORDER_OVERVIEW_PDF_FILLONPAYMENT' );
00866 $oPdf->setFont( 'Arial', '', 5 );
00867 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), 55, $sText );
00868
00869
00870 $sCustNr = $this->translate( 'ORDER_OVERVIEW_PDF_CUSTNR').' '.$oUser->oxuser__oxcustnr->value;
00871 $oPdf->setFont( 'Arial', '', 7 );
00872 $oPdf->text( 195 - $oPdf->getStringWidth( $sCustNr ), 59, $sCustNr );
00873
00874
00875 if ( $this->oxorder__oxdelsal->value ) {
00876 $iTop = 115;
00877 } else {
00878 $iTop = 91;
00879 }
00880
00881
00882 $sText = $oShop->oxshops__oxcity->getRawValue().', '.date( 'd.m.Y' );
00883 $oPdf->setFont( 'Arial', '', 10 );
00884 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop + 8, $sText );
00885
00886
00887 if ( $oShop->oxshops__oxvatnumber->value ) {
00888 $sText = $this->translate( 'ORDER_OVERVIEW_PDF_TAXIDNR' ).' '.$oShop->oxshops__oxvatnumber->value;
00889 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop + 12, $sText );
00890 $iTop += 8;
00891 } else {
00892 $iTop += 4;
00893 }
00894
00895
00896 $sText = $this->translate( 'ORDER_OVERVIEW_PDF_COUNTNR' ).' '.$this->oxorder__oxbillnr->value;
00897 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop + 8, $sText );
00898
00899
00900 if ( $this->oxorder__oxstorno->value == 1 ) {
00901 $this->oxorder__oxordernr->setValue( $this->oxorder__oxordernr->getRawValue() . ' '.$this->translate( 'ORDER_OVERVIEW_PDF_STORNO' ), oxField::T_RAW );
00902 }
00903
00904
00905 $oPdf->setFont( 'Arial', '', 12 );
00906 $oPdf->text( 15, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_PURCHASENR' ).' '.$this->oxorder__oxordernr->value );
00907
00908
00909 $oPdf->setFont( 'Arial', '', 10 );
00910 $aOrderDate = explode( ' ', $this->oxorder__oxorderdate->value );
00911 $sOrderDate = oxUtilsDate::getInstance()->formatDBDate( $aOrderDate[0]);
00912 $oPdf->text( 15, $iTop + 8, $this->translate( 'ORDER_OVERVIEW_PDF_ORDERSFROM' ).$sOrderDate.$this->translate( 'ORDER_OVERVIEW_PDF_ORDERSAT' ).$oShop->oxshops__oxurl->value );
00913 $iTop += 16;
00914
00915
00916 $oPdf->setFont( 'Arial', '', 8 );
00917 $oPdf->text( 15, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_AMOUNT' ) );
00918 $oPdf->text( 30, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_ARTID' ) );
00919 $oPdf->text( 45, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_DESC' ) );
00920 $oPdf->text( 145, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_VAT' ) );
00921 $oPdf->text( 158, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_UNITPRICE' ) );
00922 $sText = $this->translate( 'ORDER_OVERVIEW_PDF_ALLPRICE' );
00923 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop, $sText );
00924
00925
00926 $iTop += 2;
00927 $oPdf->line( 15, $iTop, 195, $iTop );
00928
00929
00930 $siteH = $iTop;
00931 $oPdf->setFont( 'Arial', '', 10 );
00932
00933
00934 $this->_setOrderArticlesToPdf( $oPdf, $siteH, true );
00935
00936
00937 $oArtSumm = new PdfArticleSummary( $this, $oPdf );
00938 $iHeight = $oArtSumm->generate( $siteH );
00939 if ( $siteH + $iHeight > 258 ) {
00940 $this->pdfFooter( $oPdf );
00941 $iTop = $this->pdfHeader( $oPdf );
00942 $oArtSumm->ajustHeight( $iTop - $siteH );
00943 $siteH = $iTop;
00944 }
00945
00946 $oArtSumm->run( $oPdf );
00947 $siteH += $iHeight + 8;
00948
00949 $oPdf->text( 15, $siteH, $this->translate( 'ORDER_OVERVIEW_PDF_GREETINGS' ) );
00950 }
00951
00959 public function exportDeliveryNote( $oPdf )
00960 {
00961 $myConfig = $this->getConfig();
00962 $oShop = $this->_getActShop();
00963
00964 $oLang = oxLang::getInstance();
00965 $sSal = $this->oxorder__oxdelsal->value;
00966 try {
00967 $sSal = $oLang->translateString($this->oxorder__oxdelsal->value, $this->_iSelectedLang);
00968 } catch (Exception $e) {
00969 }
00970
00971
00972 $this->_oCur = $myConfig->getCurrencyObject( $this->oxorder__oxcurrency->value );
00973 if ( !isset( $this->_oCur ) ) {
00974 $this->_oCur = $myConfig->getActShopCurrencyObject();
00975 }
00976
00977
00978 $oPdf->setFont( 'Arial', '', 6 );
00979 $oPdf->text( 15, 55, $oShop->oxshops__oxname->getRawValue().' - '.$oShop->oxshops__oxstreet->getRawValue().' - '.$oShop->oxshops__oxzip->value.' - '.$oShop->oxshops__oxcity->getRawValue() );
00980
00981
00982 $oPdf->setFont( 'Arial', '', 10 );
00983 if ( $this->oxorder__oxdelsal->value ) {
00984 $oPdf->text( 15, 59, $sSal );
00985 $oPdf->text( 15, 63, $this->oxorder__oxdellname->getRawValue().' '.$this->oxorder__oxdelfname->getRawValue() );
00986 $oPdf->text( 15, 67, $this->oxorder__oxdelcompany->getRawValue() );
00987 $oPdf->text( 15, 71, $this->oxorder__oxdelstreet->getRawValue().' '.$this->oxorder__oxdelstreetnr->value );
00988 $oPdf->setFont( 'Arial', 'B', 10 );
00989 $oPdf->text( 15, 75, $this->oxorder__oxdelzip->value.' '.$this->oxorder__oxdelcity->getRawValue() );
00990 $oPdf->setFont( 'Arial', '', 10 );
00991 $oPdf->text( 15, 79, $this->oxorder__oxdelcountry->getRawValue() );
00992 } else {
00993
00994 $this->_setBillingAddressToPdf( $oPdf );
00995 }
00996
00997
00998 $oUser = oxNew( 'oxuser' );
00999 $oUser->load( $this->oxorder__oxuserid->value );
01000
01001
01002 $sText = $this->translate( 'ORDER_OVERVIEW_PDF_FILLONPAYMENT' );
01003 $oPdf->setFont( 'Arial', '', 5 );
01004 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), 70, $sText );
01005
01006
01007 $sCustNr = $this->translate( 'ORDER_OVERVIEW_PDF_CUSTNR' ).' '.$oUser->oxuser__oxcustnr->value;
01008 $oPdf->setFont( 'Arial', '', 7 );
01009 $oPdf->text( 195 - $oPdf->getStringWidth( $sCustNr ), 73, $sCustNr );
01010
01011
01012 $sText = $oShop->oxshops__oxcity->getRawValue().', '.date( 'd.m.Y' );
01013 $oPdf->setFont( 'Arial', '', 10 );
01014 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), 95, $sText );
01015
01016 $iTop = 99;
01017
01018 if ( $oShop->oxshops__oxvatnumber->value ) {
01019 $sText = $this->translate( 'ORDER_OVERVIEW_PDF_TAXIDNR' ).' '.$oShop->oxshops__oxvatnumber->value;
01020 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop, $sText );
01021 $iTop += 4;
01022 }
01023
01024
01025 $sText = $this->translate( 'ORDER_OVERVIEW_PDF_COUNTNR' ).' '.$this->oxorder__oxbillnr->value;
01026 $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop, $sText );
01027
01028
01029 if ( $this->oxorder__oxstorno->value == 1 ) {
01030 $this->oxorder__oxordernr->setValue( $this->oxorder__oxordernr->getRawValue() . ' '.$this->translate( 'ORDER_OVERVIEW_PDF_STORNO' ), oxField::T_RAW );
01031 }
01032
01033
01034 $oPdf->setFont( 'Arial', '', 12 );
01035 $oPdf->text( 15, 108, $this->translate( 'ORDER_OVERVIEW_PDF_DELIVNOTE' ).' '.$this->oxorder__oxordernr->value );
01036
01037
01038 $aOrderDate = explode( ' ', $this->oxorder__oxorderdate->value );
01039 $sOrderDate = oxUtilsDate::getInstance()->formatDBDate( $aOrderDate[0]);
01040 $oPdf->setFont( 'Arial', '', 10 );
01041 $oPdf->text(15, 119, $this->translate( 'ORDER_OVERVIEW_PDF_ORDERSFROM' ).$sOrderDate.$this->translate( 'ORDER_OVERVIEW_PDF_ORDERSAT' ).$oShop->oxshops__oxurl->value );
01042
01043
01044 $oPdf->setFont( 'Arial', '', 8 );
01045 $oPdf->text( 15, 128, $this->translate( 'ORDER_OVERVIEW_PDF_AMOUNT' ) );
01046 $oPdf->text( 30, 128, $this->translate( 'ORDER_OVERVIEW_PDF_ARTID' ) );
01047 $oPdf->text( 45, 128, $this->translate( 'ORDER_OVERVIEW_PDF_DESC' ) );
01048
01049
01050 $oPdf->line( 15, 130, 195, 130 );
01051
01052
01053 $oPdf->setFont( 'Arial', '', 10 );
01054 $siteH = 130;
01055
01056
01057 $this->_setOrderArticlesToPdf( $oPdf, $siteH, false );
01058
01059
01060 $oPdf->line( 15, $siteH + 2, 195, $siteH + 2 );
01061 $siteH += 4;
01062
01063
01064 $oPdf->setFont( 'Arial', '', 10 );
01065 $text = $this->translate( 'ORDER_OVERVIEW_PDF_PAYUPTO' ).date( 'd.m.Y', mktime( 0, 0, 0, date ( 'm' ), date ( 'd' ) + 7, date( 'Y' ) ) );
01066 $oPdf->text( 15, $siteH + 4, $text );
01067 }
01068
01078 protected function _replaceExtendedChars( $sValue, $blReverse = false )
01079 {
01080
01081
01082
01083
01084
01085
01086 $aReplace = array( chr(169) => "©", chr(128) => "€", "\"" => """, "'" => "'");
01087
01088
01089
01090 if ($blReverse) {
01091
01092 $aTransTbl = get_html_translation_table (HTML_ENTITIES);
01093 $aTransTbl = array_flip ($aTransTbl) + array_flip ($aReplace);
01094 $sValue = strtr($sValue, $aTransTbl);
01095 $sValue = preg_replace('/\&\#([0-9]+)\;/me', "chr('\\1')", $sValue);
01096 }
01097
01098 return $sValue;
01099 }
01100
01106 public function getCurrency()
01107 {
01108 return $this->_oCur;
01109 }
01110
01116 public function getSelectedLang()
01117 {
01118 return $this->_iSelectedLang;
01119 }
01120
01128 public function getOrderArticles( $blStorno = false )
01129 {
01130 if ( $this->_oArticles == null ) {
01131
01132 $this->_oArticles = oxNew( 'oxlist' );
01133 $this->_oArticles->init( 'oxorderarticle' );
01134
01135 $sSelect = 'select oxorderarticles.* from oxorderarticles where oxorderarticles.oxorderid="'.$this->getId().'"';
01136 if ( $blStorno ) {
01137 $sSelect.= ' and oxstorno = 0';
01138 }
01139 $sSelect.= ' order by oxorderarticles.oxartid';
01140 $this->_oArticles->selectString( $sSelect );
01141 }
01142
01143 return $this->_oArticles;
01144 }
01145 }