OXID eShop CE  4.8.11
 All Classes Files Functions Variables Pages
myorder.php
Go to the documentation of this file.
1 <?php
2 
6 class PdfBlock
7 {
12  protected $_aCache = array();
13 
18  protected $_sFont = 'Arial';
19 
28  protected function _toCache( $sFunc, $aParams )
29  {
30  $oItem = new stdClass();
31  $oItem->sFunc = $sFunc;
32  $oItem->aParams = $aParams;
33  $this->_aCache[] = $oItem;
34  }
35 
43  public function run( $oPdf )
44  {
45  foreach ( $this->_aCache as $oItem ) {
46  $sFn = $oItem->sFunc;
47  switch ( count( $oItem->aParams ) ) {
48  case 0:
49  $oPdf->$sFn();
50  break;
51  case 1:
52  $oPdf->$sFn( $oItem->aParams[0]);
53  break;
54  case 2:
55  $oPdf->$sFn( $oItem->aParams[0], $oItem->aParams[1] );
56  break;
57  case 3:
58  $oPdf->$sFn( $oItem->aParams[0], $oItem->aParams[1], $oItem->aParams[2]);
59  break;
60  case 4:
61  $oPdf->$sFn( $oItem->aParams[0], $oItem->aParams[1], $oItem->aParams[2], $oItem->aParams[3]);
62  break;
63  }
64  }
65  }
66 
77  public function line( $iLPos, $iLHeight, $iRPos, $iRHeight )
78  {
79  $this->_toCache( 'Line', array( $iLPos, $iLHeight, $iRPos, $iRHeight ) );
80  }
81 
91  public function text( $iLPos, $iLHeight, $sString )
92  {
93  $this->_toCache( 'Text', array( $iLPos, $iLHeight, $sString ) );
94  }
95 
105  public function font( $sType, $sWeight, $sSize )
106  {
107  $this->_toCache( 'SetFont', array( $sType, $sWeight, $sSize ) );
108  }
109 
117  public function ajustHeight( $iDelta )
118  {
119  foreach ( $this->_aCache as $key => $oItem ) {
120  switch ( $oItem->sFunc ) {
121  case 'Line':
122  $this->_aCache[$key]->aParams[3] += $iDelta;
123  $this->_aCache[$key]->aParams[1] += $iDelta;
124  break;
125  case 'Text':
126  $this->_aCache[$key]->aParams[1] += $iDelta;
127  break;
128  }
129  }
130  }
131 
137  public function getFont()
138  {
139  return $this->_sFont;
140  }
141 }
142 
147 {
148 
153  protected $_oData = null;
154 
159  protected $_oPdf = null;
160 
169  public function __construct( $oData, $oPdf )
170  {
171  $this->_oData = $oData;
172  $this->_oPdf = $oPdf;
173  }
174 
182  protected function _setTotalCostsWithoutDiscount( &$iStartPos )
183  {
184  $oLang = oxRegistry::getLang();
185 
186  // products netto price
187  $this->line( 15, $iStartPos + 1, 195, $iStartPos + 1 );
188  $sNetSum = $oLang->formatCurrency( $this->_oData->oxorder__oxtotalnetsum->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
189  $this->text( 45, $iStartPos + 4, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLPRICENETTO' ) );
190  $this->text( 195 - $this->_oPdf->getStringWidth( $sNetSum ), $iStartPos + 4, $sNetSum );
191 
192  // #345 - product VAT info
193  $iCtr = 0;
194  foreach ( $this->_oData->getVats() as $iVat => $dVatPrice ) {
195  $iStartPos += 4 * $iCtr;
196  $sVATSum = $oLang->formatCurrency( $dVatPrice, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
197  $this->text( 45, $iStartPos + 8, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ).$iVat.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_PERCENTSUM' ) );
198  $this->text( 195 - $this->_oPdf->getStringWidth( $sVATSum ), $iStartPos + 8, $sVATSum );
199  $iCtr++;
200  }
201 
202  // products brutto price
203  $sBrutPrice = $oLang->formatCurrency( $this->_oData->oxorder__oxtotalbrutsum->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
204  $this->text( 45, $iStartPos + 12, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLPRICEBRUTTO' ) );
205  $this->text( 195 - $this->_oPdf->getStringWidth( $sBrutPrice ), $iStartPos + 12, $sBrutPrice );
206  $iStartPos++;
207 
208  // line separator
209  $this->line( 45, $iStartPos + 13, 195, $iStartPos + 13 );
210  $iStartPos += 5;
211  }
212 
220  protected function _setTotalCostsWithDiscount( &$iStartPos )
221  {
222  $oLang = oxRegistry::getLang();
223 
224  // line separator
225  $this->line( 15, $iStartPos + 1, 195, $iStartPos + 1 );
226 
227  if ( $this->_oData->isNettoMode() ) {
228 
229  // products netto price
230  $sNetSum = $oLang->formatCurrency( $this->_oData->oxorder__oxtotalnetsum->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
231  $this->text( 45, $iStartPos + 4, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLPRICENETTO' ) );
232  $this->text( 195 - $this->_oPdf->getStringWidth( $sNetSum ), $iStartPos + 4, $sNetSum );
233 
234  // discount
235  $dDiscountVal = $this->_oData->oxorder__oxdiscount->value;
236  if ( $dDiscountVal > 0 ) {
237  $dDiscountVal *= -1;
238  }
239  $sDiscount = $oLang->formatCurrency( $dDiscountVal, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
240  $this->text( 45, $iStartPos + 8, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_DISCOUNT' ) );
241  $this->text( 195 - $this->_oPdf->getStringWidth( $sDiscount ), $iStartPos + 8, $sDiscount );
242  $iStartPos++;
243 
244  // line separator
245  $this->line( 45, $iStartPos + 8, 195, $iStartPos + 8 );
246 
247  $iCtr = 0;
248  foreach ( $this->_oData->getVats() as $iVat => $dVatPrice ) {
249  $iStartPos += 4 * $iCtr;
250  $sVATSum = $oLang->formatCurrency( $dVatPrice, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
251  $this->text( 45, $iStartPos + 12, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ).$iVat.$this->_oData->translate('ORDER_OVERVIEW_PDF_PERCENTSUM' ) );
252  $this->text( 195 - $this->_oPdf->getStringWidth( $sVATSum ), $iStartPos + 12, $sVATSum );
253  $iCtr++;
254  }
255  $iStartPos += 4;
256 
257  // products brutto price
258  $sBrutPrice = $oLang->formatCurrency( $this->_oData->oxorder__oxtotalbrutsum->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
259  $this->text( 45, $iStartPos + 12, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLPRICEBRUTTO' ) );
260  $this->text( 195 - $this->_oPdf->getStringWidth( $sBrutPrice ), $iStartPos + 12, $sBrutPrice );
261  $iStartPos += 4;
262 
263  } else {
264  // products brutto price
265  $sBrutPrice = $oLang->formatCurrency( $this->_oData->oxorder__oxtotalbrutsum->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
266  $this->text( 45, $iStartPos + 4, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLPRICEBRUTTO' ) );
267  $this->text( 195 - $this->_oPdf->getStringWidth( $sBrutPrice ), $iStartPos + 4, $sBrutPrice );
268 
269  // line separator
270  $this->line( 45, $iStartPos + 5, 195, $iStartPos + 5 );
271 
272  // discount
273  $dDiscountVal = $this->_oData->oxorder__oxdiscount->value;
274  if ( $dDiscountVal > 0 ) {
275  $dDiscountVal *= -1;
276  }
277  $sDiscount = $oLang->formatCurrency( $dDiscountVal, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
278  $this->text( 45, $iStartPos + 8, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_DISCOUNT' ) );
279  $this->text( 195 - $this->_oPdf->getStringWidth( $sDiscount ), $iStartPos + 8, $sDiscount );
280  $iStartPos++;
281 
282  // line separator
283  $this->line( 45, $iStartPos + 8, 195, $iStartPos + 8 );
284  $iStartPos += 4;
285 
286  // products netto price
287  $sNetSum = $oLang->formatCurrency( $this->_oData->oxorder__oxtotalnetsum->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
288  $this->text( 45, $iStartPos + 8, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLPRICENETTO' ) );
289  $this->text( 195 - $this->_oPdf->getStringWidth( $sNetSum ), $iStartPos + 8, $sNetSum );
290 
291  // #345 - product VAT info
292  $iCtr = 0;
293  foreach ( $this->_oData->getVats() as $iVat => $dVatPrice ) {
294  $iStartPos += 4 * $iCtr;
295  $sVATSum = $oLang->formatCurrency( $dVatPrice, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
296  $this->text( 45, $iStartPos + 12, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ).$iVat.$this->_oData->translate('ORDER_OVERVIEW_PDF_PERCENTSUM' ) );
297  $this->text( 195 - $this->_oPdf->getStringWidth( $sVATSum ), $iStartPos + 12, $sVATSum );
298  $iCtr++;
299  }
300  $iStartPos += 4;
301  }
302  }
303 
311  protected function _setVoucherInfo( &$iStartPos )
312  {
313  $dVoucher = 0;
314  if ( $this->_oData->oxorder__oxvoucherdiscount->value ) {
315  $dDiscountVal = $this->_oData->oxorder__oxvoucherdiscount->value;
316  if ( $dDiscountVal > 0 ) {
317  $dDiscountVal *= -1;
318  }
319  $sPayCost = oxRegistry::getLang()->formatCurrency( $dDiscountVal, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
320  $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_VOUCHER' ) );
321  $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCost ), $iStartPos, $sPayCost );
322  $iStartPos += 4;
323  }
324 
325  $iStartPos++;
326  }
327 
335  protected function _setDeliveryInfo( &$iStartPos )
336  {
337  $sAddString = '';
338  $oLang = oxRegistry::getLang();
339  $oConfig = oxRegistry::getConfig();
340 
341  if ( $oConfig->getConfigParam( 'blShowVATForDelivery' ) ) {
342  // delivery netto
343  $sDelCostNetto = $oLang->formatCurrency( $this->_oData->getOrderDeliveryPrice()->getNettoPrice(), $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
344  $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_SHIPCOST' ).' '.$this->_oData->translate('ORDER_OVERVIEW_PDF_NETTO' ) );
345  $this->text( 195 - $this->_oPdf->getStringWidth( $sDelCostNetto ), $iStartPos, $sDelCostNetto );
346  $iStartPos += 4;
347 
348  if ( $oConfig->getConfigParam('sAdditionalServVATCalcMethod') != 'proportional' ) {
349  $sVatValueText = $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ).$this->_oData->oxorder__oxdelvat->value.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_PERCENTSUM' );
350  } else {
351  $sVatValueText = $this->_oData->translate( 'TOTAL_PLUS_PROPORTIONAL_VAT' );
352  }
353 
354  // delivery VAT
355  $sDelCostVAT = $oLang->formatCurrency( $this->_oData->getOrderDeliveryPrice()->getVATValue(), $this->_oData->getCurrency()).' '.$this->_oData->getCurrency()->name;
356  $this->text( 45, $iStartPos, $sVatValueText );
357  $this->text( 195 - $this->_oPdf->getStringWidth( $sDelCostVAT ), $iStartPos, $sDelCostVAT );
358  //$iStartPos += 4;
359 
360  $sAddString = ' '.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_BRUTTO' );
361  } else {
362  // if canceled order, reset value
363  if ( $this->_oData->oxorder__oxstorno->value ) {
364  $this->_oData->oxorder__oxdelcost->setValue(0);
365  }
366 
367  $sDelCost = $oLang->formatCurrency( $this->_oData->oxorder__oxdelcost->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
368  $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_SHIPCOST' ).$sAddString );
369  $this->text( 195 - $this->_oPdf->getStringWidth( $sDelCost ), $iStartPos, $sDelCost );
370  }
371  }
372 
380  protected function _setWrappingInfo( &$iStartPos )
381  {
382  if ( $this->_oData->oxorder__oxwrapcost->value || $this->_oData->oxorder__oxgiftcardcost->value ) {
383  $oLang = oxRegistry::getLang();
384  $oConfig = oxRegistry::getConfig();
385 
386  //displaying wrapping VAT info
387  if ( $oConfig->getConfigParam('blShowVATForWrapping') ) {
388 
389  if ($this->_oData->oxorder__oxwrapcost->value) {
390  // wrapping netto
391  $iStartPos += 4;
392  $sWrapCostNetto = $oLang->formatCurrency( $this->_oData->getOrderWrappingPrice()->getNettoPrice(), $this->_oData->getCurrency()).' '.$this->_oData->getCurrency()->name;
393  $this->text( 45, $iStartPos, $this->_oData->translate( 'WRAPPING_COSTS' ).' '.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_NETTO' ) );
394  $this->text( 195 - $this->_oPdf->getStringWidth( $sWrapCostNetto ), $iStartPos, $sWrapCostNetto );
395  //$iStartPos++;
396 
397  //wrapping VAT
398  $iStartPos += 4;
399  $sWrapCostVAT = $oLang->formatCurrency( $this->_oData->getOrderWrappingPrice()->getVATValue(), $this->_oData->getCurrency()).' '.$this->_oData->getCurrency()->name;
400  $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ) );
401  $this->text( 195 - $this->_oPdf->getStringWidth( $sWrapCostVAT ), $iStartPos, $sWrapCostVAT );
402  // $iStartPos++;
403  }
404 
405  if ($this->_oData->oxorder__oxgiftcardcost->value) {
406  // wrapping netto
407  $iStartPos += 4;
408  $sWrapCostNetto = $oLang->formatCurrency( $this->_oData->getOrderGiftCardPrice()->getNettoPrice(), $this->_oData->getCurrency()).' '.$this->_oData->getCurrency()->name;
409  $this->text( 45, $iStartPos, $this->_oData->translate( 'GIFTCARD_COSTS' ).' '.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_NETTO' ) );
410  $this->text( 195 - $this->_oPdf->getStringWidth( $sWrapCostNetto ), $iStartPos, $sWrapCostNetto );
411  //$iStartPos++;
412 
413  //wrapping VAT
414  $iStartPos += 4;
415  $sWrapCostVAT = $oLang->formatCurrency( $this->_oData->getOrderGiftCardPrice()->getVATValue(), $this->_oData->getCurrency()).' '.$this->_oData->getCurrency()->name;
416 
417  if ( $oConfig->getConfigParam('sAdditionalServVATCalcMethod') != 'proportional' ) {
418  $sVatValueText = $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ) .$this->_oData->oxorder__oxgiftcardvat->value.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_PERCENTSUM' );
419  } else {
420  $sVatValueText = $this->_oData->translate( 'TOTAL_PLUS_PROPORTIONAL_VAT' );
421  }
422 
423  $this->text( 45, $iStartPos, $sVatValueText );
424  $this->text( 195 - $this->_oPdf->getStringWidth( $sWrapCostVAT ), $iStartPos, $sWrapCostVAT );
425  $iStartPos++;
426  }
427 
428  } else {
429  $sAddString = ' '.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_BRUTTO' );
430 
431  if ($this->_oData->oxorder__oxwrapcost->value) {
432  $iStartPos += 4;
433  // wrapping cost
434  $sWrapCost = $oLang->formatCurrency( $this->_oData->oxorder__oxwrapcost->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
435  $this->text( 45, $iStartPos, $this->_oData->translate( 'WRAPPING_COSTS'/*'ORDER_OVERVIEW_PDF_WRAPPING'*/ ).$sAddString );
436  $this->text( 195 - $this->_oPdf->getStringWidth( $sWrapCost ), $iStartPos, $sWrapCost );
437  $iStartPos++;
438  }
439 
440  if ($this->_oData->oxorder__oxgiftcardcost->value) {
441  $iStartPos += 4;
442  // gift card cost
443  $sWrapCost = $oLang->formatCurrency( $this->_oData->oxorder__oxgiftcardcost->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
444  $this->text( 45, $iStartPos, $this->_oData->translate( 'GIFTCARD_COSTS' ).$sAddString );
445  $this->text( 195 - $this->_oPdf->getStringWidth( $sWrapCost ), $iStartPos, $sWrapCost );
446  $iStartPos++;
447  }
448  }
449  }
450  }
451 
459  protected function _setPaymentInfo( &$iStartPos )
460  {
461  $oLang = oxRegistry::getLang();
462  $oConfig = oxRegistry::getConfig();
463 
464  if ( $this->_oData->oxorder__oxstorno->value ) {
465  $this->_oData->oxorder__oxpaycost->setValue(0);
466  }
467 
468  if ($oConfig->getConfigParam('blShowVATForDelivery')) {
469  if ( $this->_oData->oxorder__oxpayvat->value ) {
470  // payment netto
471  $iStartPos += 4;
472  $sPayCostNetto = $oLang->formatCurrency( $this->_oData->getOrderPaymentPrice()->getNettoPrice(), $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
473  $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_PAYMENTIMPACT' ).' '.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_NETTO' ) );
474  $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCostNetto ), $iStartPos, $sPayCostNetto );
475 
476  if ( $oConfig->getConfigParam('sAdditionalServVATCalcMethod') != 'proportional' ) {
477  $sVatValueText = $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ).$this->_oData->oxorder__oxpayvat->value.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_PERCENTSUM' );
478  } else {
479  $sVatValueText = $this->_oData->translate( 'TOTAL_PLUS_PROPORTIONAL_VAT' );
480  }
481 
482  // payment VAT
483  $iStartPos += 4;
484  $sPayCostVAT = $oLang->formatCurrency( $this->_oData->getOrderPaymentPrice()->getVATValue(), $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
485  $this->text( 45, $iStartPos, $sVatValueText );
486  $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCostVAT ), $iStartPos, $sPayCostVAT );
487 
488  }
489 
490  // if canceled order, reset value
491 
492  } else {
493 
494  // payment costs
495  if ( $this->_oData->oxorder__oxpaycost->value ) {
496  $iStartPos += 4;
497  $sPayCost = $oLang->formatCurrency( $this->_oData->oxorder__oxpaycost->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
498  $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_PAYMENTIMPACT' ) );
499  $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCost ), $iStartPos, $sPayCost );
500  }
501 
502  $iStartPos++;
503  }
504  }
505 
513  protected function _setTsProtection( &$iStartPos )
514  {
515  $oLang = oxRegistry::getLang();
516  $oConfig = oxRegistry::getConfig();
517  if ( $this->_oData->oxorder__oxtsprotectcosts->value && $oConfig->getConfigParam( 'blShowVATForPayCharge' ) ) {
518 
519  // payment netto
520  $iStartPos += 4;
521  $sPayCostNetto = $oLang->formatCurrency( $this->_oData->getOrderTsProtectionPrice()->getNettoPrice(), $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
522  $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_TSPROTECTION' ).' '.$this->_oData->translate( 'ORDER_OVERVIEW_PDF_NETTO' ) );
523  $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCostNetto ), $iStartPos, $sPayCostNetto );
524 
525  // payment VAT
526  $iStartPos += 4;
527  $sPayCostVAT = $oLang->formatCurrency( $this->_oData->getOrderTsProtectionPrice()->getVATValue(), $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
528  $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ZZGLVAT' ).$oConfig->getConfigParam( 'dDefaultVAT' ).$this->_oData->translate( 'ORDER_OVERVIEW_PDF_PERCENTSUM' ) );
529  $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCostVAT ), $iStartPos, $sPayCostVAT );
530 
531  $iStartPos++;
532 
533  } elseif ( $this->_oData->oxorder__oxtsprotectcosts->value ) {
534 
535  $iStartPos += 4;
536  $sPayCost = $oLang->formatCurrency( $this->_oData->oxorder__oxtsprotectcosts->value, $this->_oData->getCurrency() ).' '.$this->_oData->getCurrency()->name;
537  $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_TSPROTECTION' ) );
538  $this->text( 195 - $this->_oPdf->getStringWidth( $sPayCost ), $iStartPos, $sPayCost );
539 
540  $iStartPos++;
541  }
542  }
543 
551  protected function _setGrandTotalPriceInfo( &$iStartPos )
552  {
553  $this->font( $this->getFont(), 'B', 10 );
554 
555  // total order sum
556  $sTotalOrderSum = $this->_oData->getFormattedTotalOrderSum() . ' ' . $this->_oData->getCurrency()->name;
557  $this->text( 45, $iStartPos, $this->_oData->translate( 'ORDER_OVERVIEW_PDF_ALLSUM' ) );
558  $this->text( 195 - $this->_oPdf->getStringWidth( $sTotalOrderSum ), $iStartPos, $sTotalOrderSum );
559  $iStartPos += 2;
560 
561  if ( $this->_oData->oxorder__oxdelvat->value || $this->_oData->oxorder__oxwrapvat->value || $this->_oData->oxorder__oxpayvat->value ) {
562  $iStartPos += 2;
563  }
564  }
565 
573  protected function _setPaymentMethodInfo( &$iStartPos )
574  {
575  $oPayment = oxNew( 'oxpayment' );
576  $oPayment->loadInLang( $this->_oData->getSelectedLang(), $this->_oData->oxorder__oxpaymenttype->value );
577 
578  $text = $this->_oData->translate( 'ORDER_OVERVIEW_PDF_SELPAYMENT' ).$oPayment->oxpayments__oxdesc->value;
579  $this->font( $this->getFont(), '', 10 );
580  $this->text( 15, $iStartPos + 4, $text );
581  $iStartPos += 4;
582  }
583 
591  protected function _setPayUntilInfo( &$iStartPos )
592  {
593  $text = $this->_oData->translate( 'ORDER_OVERVIEW_PDF_PAYUPTO' ) . date( 'd.m.Y', strtotime( '+' . $this->_oData->getPaymentTerm() . ' day', strtotime( $this->_oData->oxorder__oxbilldate->value ) ) );
594  $this->font( $this->getFont(), '', 10 );
595  $this->text( 15, $iStartPos + 4, $text );
596  $iStartPos += 4;
597  }
598 
606  public function generate( $iStartPos )
607  {
608 
609  $this->font( $this->getFont(), '', 10 );
610  $siteH = $iStartPos;
611 
612  // #1147 discount for vat must be displayed
613  if ( !$this->_oData->oxorder__oxdiscount->value ) {
614  $this->_setTotalCostsWithoutDiscount( $siteH );
615  } else {
616  $this->_setTotalCostsWithDiscount( $siteH );
617  }
618 
619  $siteH += 12;
620 
621  // voucher info
622  $this->_setVoucherInfo( $siteH );
623 
624  // additional line separator
625  if ( $this->_oData->oxorder__oxdiscount->value || $this->_oData->oxorder__oxvoucherdiscount->value ) {
626  $this->line( 45, $siteH - 3, 195, $siteH - 3 );
627  }
628 
629  // delivery info
630  $this->_setDeliveryInfo( $siteH );
631 
632  // payment info
633  $this->_setPaymentInfo( $siteH );
634 
635  // wrapping info
636  $this->_setWrappingInfo( $siteH );
637 
638  // TS protection info
639  $this->_setTsProtection( $siteH );
640 
641  // separating line
642  $this->line( 15, $siteH, 195, $siteH );
643  $siteH += 4;
644 
645  // total order sum
646  $this->_setGrandTotalPriceInfo( $siteH );
647 
648  // separating line
649  $this->line( 15, $siteH, 195, $siteH );
650  $siteH += 4;
651 
652  // payment method
653  $this->_setPaymentMethodInfo( $siteH );
654 
655  // pay until ...
656  $this->_setPayUntilInfo( $siteH );
657 
658  return $siteH - $iStartPos;
659  }
660 }
661 
665 class MyOrder extends MyOrder_parent
666 {
667 
672  protected $_iSelectedLang = 0;
673 
678  protected $_oActShop = null;
679 
684  protected $_aVATs = array();
685 
690  protected $_oCur = null;
691 
692 
698  public function setSelectedLang( $iLang )
699  {
700  $this->_iSelectedLang = $iLang;
701  }
702 
708  protected function _getActShop()
709  {
710  // shop is allready loaded
711  if ( $this->_oActShop !== null )
712  return $this->_oActShop;
713 
714  $this->_oActShop = oxNew( 'oxshop' );
715  $this->_oActShop->load( $this->getConfig()->getShopId() );
716 
717  return $this->_oActShop;
718  }
719 
727  public function translate( $sString )
728  {
729  return oxRegistry::getLang()->translateString( $sString, $this->getSelectedLang() );
730  }
731 
739  public function pdfFooter( $oPdf )
740  {
741 
742  $oShop = $this->_getActShop();
743 
744  $oPdf->line( 15, 272, 195, 272 );
745 
746  $oPdfBlock = new PdfBlock();
747  /* column 1 - company name, shop owner info, shop address */
748  $oPdf->setFont( $oPdfBlock->getFont(), '', 7 );
749  $oPdf->text( 15, 275, strip_tags( $oShop->oxshops__oxcompany->getRawValue() ) );
750  $oPdf->text( 15, 278, strip_tags( $oShop->oxshops__oxfname->getRawValue() ).' '. strip_tags( $oShop->oxshops__oxlname->getRawValue() ) );
751  $oPdf->text( 15, 281, strip_tags( $oShop->oxshops__oxstreet->getRawValue() ) );
752  $oPdf->text( 15, 284, strip_tags( $oShop->oxshops__oxzip->value ).' '. strip_tags( $oShop->oxshops__oxcity->getRawValue() ) );
753  $oPdf->text( 15, 287, strip_tags( $oShop->oxshops__oxcountry->getRawValue() ) );
754 
755  /* column 2 - phone, fax, url, email address */
756  $oPdf->text( 85, 275, $this->translate( 'ORDER_OVERVIEW_PDF_PHONE' ).strip_tags( $oShop->oxshops__oxtelefon->value ) );
757  $oPdf->text( 85, 278, $this->translate( 'ORDER_OVERVIEW_PDF_FAX' ).strip_tags( $oShop->oxshops__oxtelefax->value ) );
758  $oPdf->text( 85, 281, strip_tags( $oShop->oxshops__oxurl->value ) );
759  $oPdf->text( 85, 284, strip_tags( $oShop->oxshops__oxorderemail->value ) );
760 
761  /* column 3 - bank information */
762  $oPdf->text( 150, 275, strip_tags( $oShop->oxshops__oxbankname->getRawValue() ) );
763  $oPdf->text( 150, 278, $this->translate( 'ORDER_OVERVIEW_PDF_ACCOUNTNR' ).strip_tags( $oShop->oxshops__oxbanknumber->value ) );
764  $oPdf->text( 150, 281, $this->translate( 'ORDER_OVERVIEW_PDF_BANKCODE' ).strip_tags( $oShop->oxshops__oxbankcode->value ) );
765  $oPdf->text( 150, 284, strip_tags( $oShop->oxshops__oxvatnumber->value ) );
766  $oPdf->text( 150, 287, '' );
767  }
768 
776  public function pdfHeaderPlus( $oPdf )
777  {
778 
779  // new page with shop logo
780  $this->pdfHeader( $oPdf );
781 
782  $oPdfBlock = new PdfBlock();
783  // column names
784  $oPdf->setFont( $oPdfBlock->getFont(), '', 8 );
785  $oPdf->text( 15, 50, $this->translate( 'ORDER_OVERVIEW_PDF_AMOUNT' ) );
786  $oPdf->text( 30, 50, $this->translate( 'ORDER_OVERVIEW_PDF_ARTID') );
787  $oPdf->text( 45, 50, $this->translate( 'ORDER_OVERVIEW_PDF_DESC' ) );
788  $oPdf->text( 160, 50, $this->translate( 'ORDER_OVERVIEW_PDF_UNITPRICE' ) );
789  $sText = $this->translate( 'ORDER_OVERVIEW_PDF_ALLPRICE' );
790  $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), 50, $sText );
791 
792  // line separator
793  $oPdf->line( 15, 52, 195, 52 );
794 
795  return 56;
796  }
797 
805  public function pdfHeader( $oPdf )
806  {
807  // adding new page ...
808  $oPdf->addPage();
809 
810  // loading active shop
811  $oShop = $this->_getActShop();
812 
813  //logo
814  $myConfig = $this->getConfig();
815  $aSize = getimagesize( $myConfig->getImageDir().'/pdf_logo.jpg' );
816  $iMargin = 195 - $aSize[0] * 0.2;
817  $oPdf->setLink( $oShop->oxshops__oxurl->value );
818  $oPdf->image( $myConfig->getImageDir().'/pdf_logo.jpg', $iMargin, 10, $aSize[0] * 0.2, $aSize[1] * 0.2, '', $oShop->oxshops__oxurl->value );
819  return 14 + $aSize[1] * 0.2;
820  }
821 
830  public function genPdf( $sFilename, $iSelLang = 0 )
831  {
832  // setting pdf language
833  $this->setSelectedLang( $iSelLang );
834 
835  $blIsNewOrder = 0;
836  // setting invoice number
837  if ( !$this->oxorder__oxbillnr->value ) {
838  $this->oxorder__oxbillnr->setValue( $this->getNextBillNum() );
839  $blIsNewOrder = 1;
840  }
841  // setting invoice date
842  if ( $this->oxorder__oxbilldate->value == '0000-00-00' ) {
843  $this->oxorder__oxbilldate->setValue( date( 'Y-m-d', mktime( 0, 0, 0, date ( 'm' ), date ( 'd' ), date( 'Y' ) ) ) );
844  $blIsNewOrder = 1;
845  }
846  // saving order if new number or date
847  if ( $blIsNewOrder ){
848  $this->save();
849  }
850 
851  // initiating pdf engine
852  $oPdf = oxNew( 'oxPDF' );
853  $oPdf->setPrintHeader( false );
854  $oPdf->open();
855 
856  // adding header
857  $this->pdfHeader( $oPdf );
858 
859  // adding info data
860  switch ( oxConfig::getParameter( 'pdftype' ) ) {
861  case 'dnote':
862  $this->exportDeliveryNote( $oPdf );
863  break;
864  default:
865  $this->exportStandart( $oPdf );
866  }
867 
868  // adding footer
869  $this->pdfFooter( $oPdf );
870 
871  // outputting file to browser
872  $oPdf->output( $sFilename, 'I' );
873  }
874 
875 
883  protected function _setBillingAddressToPdf( $oPdf )
884  {
885  $oLang = oxRegistry::getLang();
886  $sSal = $this->oxorder__oxbillsal->value;
887  try {
888  $sSal = $oLang->translateString($this->oxorder__oxbillsal->value, $this->getSelectedLang());
889  } catch (Exception $e) {
890  }
891  $oPdfBlock = new PdfBlock();
892  $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
893  $oPdf->text( 15, 59, $sSal);
894  $oPdf->text( 15, 63, $this->oxorder__oxbillfname->getRawValue().' '.$this->oxorder__oxbilllname->getRawValue() );
895  $oPdf->text( 15, 67, $this->oxorder__oxbillcompany->getRawValue() );
896  $oPdf->text( 15, 71, $this->oxorder__oxbillstreet->getRawValue().' '.$this->oxorder__oxbillstreetnr->value );
897  $oPdf->setFont( $oPdfBlock->getFont(), 'B', 10 );
898  $oPdf->text( 15, 75, $this->oxorder__oxbillzip->value.' '.$this->oxorder__oxbillcity->getRawValue() );
899  $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
900  $oPdf->text( 15, 79, $this->oxorder__oxbillcountry->getRawValue() );
901  }
902 
910  protected function _setDeliveryAddressToPdf( $oPdf )
911  {
912  $oLang = oxRegistry::getLang();
913  $sSal = $this->oxorder__oxdelsal->value;
914  try {
915  $sSal = $oLang->translateString($this->oxorder__oxdelsal->value, $this->getSelectedLang());
916  } catch (Exception $e) {
917  }
918  $oPdfBlock = new PdfBlock();
919  $oPdf->setFont( $oPdfBlock->getFont(), '', 6 );
920  $oPdf->text( 15, 87, $this->translate( 'ORDER_OVERVIEW_PDF_DELIVERYADDRESS' ) );
921  $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
922  $oPdf->text( 15, 91, $sSal);
923  $oPdf->text( 15, 95, $this->oxorder__oxdellname->getRawValue().' '.$this->oxorder__oxdelfname->getRawValue() );
924  $oPdf->text( 15, 99, $this->oxorder__oxdelcompany->getRawValue() );
925  $oPdf->text( 15, 103, $this->oxorder__oxdelstreet->getRawValue().' '.$this->oxorder__oxdelstreetnr->value );
926  $oPdf->setFont( $oPdfBlock->getFont(), 'B', 10 );
927  $oPdf->text( 15, 107, $this->oxorder__oxdelzip->value.' '.$this->oxorder__oxdelcity->getRawValue() );
928  $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
929  $oPdf->text( 15, 111, $this->oxorder__oxdelcountry->getRawValue() );
930  }
931 
941  protected function _setOrderArticlesToPdf( $oPdf, &$iStartPos, $blShowPrice = true )
942  {
943  if (!$this->_oArticles) {
944  $this->_oArticles = $this->getOrderArticles(true);
945  }
946 
947  $oCurr = $this->getCurrency();
948  $oPdfBlock = new PdfBlock();
949  // product list
950  foreach ( $this->_oArticles as $key => $oOrderArt ) {
951 
952  // starting a new page ...
953  if ( $iStartPos > 243 ) {
954  $this->pdffooter( $oPdf );
955  $iStartPos = $this->pdfheaderplus( $oPdf );
956  $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
957  } else {
958  $iStartPos = $iStartPos + 4;
959  }
960 
961  // sold amount
962  $oPdf->text( 20 - $oPdf->getStringWidth( $oOrderArt->oxorderarticles__oxamount->value ), $iStartPos, $oOrderArt->oxorderarticles__oxamount->value );
963 
964  // product number
965  $oPdf->setFont( $oPdfBlock->getFont(), '', 8 );
966  $oPdf->text( 28, $iStartPos, $oOrderArt->oxorderarticles__oxartnum->value );
967 
968  // product title
969  $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
970  $oPdf->text( 45, $iStartPos, substr( strip_tags( $this->_replaceExtendedChars( $oOrderArt->oxorderarticles__oxtitle->getRawValue(), true ) ), 0, 58 ) );
971 
972  if ( $blShowPrice ) {
973  $oLang = oxRegistry::getLang();
974 
975  // product VAT percent
976  $oPdf->text( 140 - $oPdf->getStringWidth( $oOrderArt->oxorderarticles__oxvat->value ), $iStartPos, $oOrderArt->oxorderarticles__oxvat->value );
977 
978  // product price
979 
980  $dUnitPrice = ($this->isNettoMode()) ? $oOrderArt->oxorderarticles__oxnprice->value : $oOrderArt->oxorderarticles__oxbprice->value;
981  $dTotalPrice = ($this->isNettoMode()) ? $oOrderArt->oxorderarticles__oxnetprice->value : $oOrderArt->oxorderarticles__oxbrutprice->value;
982 
983  $sText = $oLang->formatCurrency( $dUnitPrice, $this->_oCur ).' '.$this->_oCur->name;
984  $oPdf->text( 163 - $oPdf->getStringWidth( $sText ), $iStartPos, $sText );
985 
986  // total product price
987  $sText = $oLang->formatCurrency( $dTotalPrice, $this->_oCur ).' '.$this->_oCur->name;
988  $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iStartPos, $sText );
989 
990  }
991 
992  // additional variant info
993  if ( $oOrderArt->oxorderarticles__oxselvariant->value ) {
994  $iStartPos = $iStartPos + 4;
995  $oPdf->text( 45, $iStartPos, substr( $oOrderArt->oxorderarticles__oxselvariant->value, 0, 58 ) );
996  }
997 
998  }
999  }
1000 
1008  public function exportStandart( $oPdf )
1009  {
1010  // preparing order curency info
1011  $myConfig = $this->getConfig();
1012  $oPdfBlock = new PdfBlock();
1013 
1014  $this->_oCur = $myConfig->getCurrencyObject( $this->oxorder__oxcurrency->value );
1015  if ( !$this->_oCur ) {
1016  $this->_oCur = $myConfig->getActShopCurrencyObject();
1017  }
1018 
1019  // loading active shop
1020  $oShop = $this->_getActShop();
1021 
1022  // shop information
1023  $oPdf->setFont( $oPdfBlock->getFont(), '', 6 );
1024  $oPdf->text( 15, 55, $oShop->oxshops__oxname->getRawValue().' - '.$oShop->oxshops__oxstreet->getRawValue().' - '.$oShop->oxshops__oxzip->value.' - '.$oShop->oxshops__oxcity->getRawValue() );
1025 
1026  // billing address
1027  $this->_setBillingAddressToPdf( $oPdf );
1028 
1029  // delivery address
1030  if ( $this->oxorder__oxdelsal->value ) {
1031  $this->_setDeliveryAddressToPdf( $oPdf );
1032  }
1033 
1034  // loading user
1035  $oUser = oxNew( 'oxuser' );
1036  $oUser->load( $this->oxorder__oxuserid->value );
1037 
1038  // user info
1039  $sText = $this->translate( 'ORDER_OVERVIEW_PDF_FILLONPAYMENT' );
1040  $oPdf->setFont( $oPdfBlock->getFont(), '', 5 );
1041  $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), 55, $sText );
1042 
1043  // customer number
1044  $sCustNr = $this->translate( 'ORDER_OVERVIEW_PDF_CUSTNR').' '.$oUser->oxuser__oxcustnr->value;
1045  $oPdf->setFont( $oPdfBlock->getFont(), '', 7 );
1046  $oPdf->text( 195 - $oPdf->getStringWidth( $sCustNr ), 59, $sCustNr );
1047 
1048  // setting position if delivery address is used
1049  if ( $this->oxorder__oxdelsal->value ) {
1050  $iTop = 115;
1051  } else {
1052  $iTop = 91;
1053  }
1054 
1055  // shop city
1056  $sText = $oShop->oxshops__oxcity->getRawValue().', '.date( 'd.m.Y', strtotime($this->oxorder__oxbilldate->value ) );
1057  $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
1058  $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop + 8, $sText );
1059 
1060  // shop VAT number
1061  if ( $oShop->oxshops__oxvatnumber->value ) {
1062  $sText = $this->translate( 'ORDER_OVERVIEW_PDF_TAXIDNR' ).' '.$oShop->oxshops__oxvatnumber->value;
1063  $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop + 12, $sText );
1064  $iTop += 8;
1065  } else {
1066  $iTop += 4;
1067  }
1068 
1069  // invoice number
1070  $sText = $this->translate( 'ORDER_OVERVIEW_PDF_COUNTNR' ).' '.$this->oxorder__oxbillnr->value;
1071  $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop + 8, $sText );
1072 
1073  // marking if order is canceled
1074  if ( $this->oxorder__oxstorno->value == 1 ) {
1075  $this->oxorder__oxordernr->setValue( $this->oxorder__oxordernr->getRawValue() . ' '.$this->translate( 'ORDER_OVERVIEW_PDF_STORNO' ), oxField::T_RAW );
1076  }
1077 
1078  // order number
1079  $oPdf->setFont( $oPdfBlock->getFont(), '', 12 );
1080  $oPdf->text( 15, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_PURCHASENR' ).' '.$this->oxorder__oxordernr->value );
1081 
1082  // order date
1083  $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
1084  $aOrderDate = explode( ' ', $this->oxorder__oxorderdate->value );
1085  $sOrderDate = oxRegistry::get("oxUtilsDate")->formatDBDate( $aOrderDate[0]);
1086  $oPdf->text( 15, $iTop + 8, $this->translate( 'ORDER_OVERVIEW_PDF_ORDERSFROM' ).$sOrderDate.$this->translate( 'ORDER_OVERVIEW_PDF_ORDERSAT' ).$oShop->oxshops__oxurl->value );
1087  $iTop += 16;
1088 
1089  // product info header
1090  $oPdf->setFont( $oPdfBlock->getFont(), '', 8 );
1091  $oPdf->text( 15, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_AMOUNT' ) );
1092  $oPdf->text( 30, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_ARTID' ) );
1093  $oPdf->text( 45, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_DESC' ) );
1094  $oPdf->text( 135, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_VAT' ) );
1095  $oPdf->text( 148, $iTop, $this->translate( 'ORDER_OVERVIEW_PDF_UNITPRICE' ) );
1096  $sText = $this->translate( 'ORDER_OVERVIEW_PDF_ALLPRICE' );
1097  $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop, $sText );
1098 
1099  // separator line
1100  $iTop += 2;
1101  $oPdf->line( 15, $iTop, 195, $iTop );
1102 
1103  // #345
1104  $siteH = $iTop;
1105  $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
1106 
1107  // order articles
1108  $this->_setOrderArticlesToPdf( $oPdf, $siteH, true );
1109 
1110  // generating pdf file
1111  $oArtSumm = new PdfArticleSummary( $this, $oPdf );
1112  $iHeight = $oArtSumm->generate( $siteH );
1113  if ( $siteH + $iHeight > 258 ) {
1114  $this->pdfFooter( $oPdf );
1115  $iTop = $this->pdfHeader( $oPdf );
1116  $oArtSumm->ajustHeight( $iTop - $siteH );
1117  $siteH = $iTop;
1118  }
1119 
1120  $oArtSumm->run( $oPdf );
1121  $siteH += $iHeight + 8;
1122 
1123  $oPdf->text( 15, $siteH, $this->translate( 'ORDER_OVERVIEW_PDF_GREETINGS' ) );
1124  }
1125 
1133  public function exportDeliveryNote( $oPdf )
1134  {
1135  $myConfig = $this->getConfig();
1136  $oShop = $this->_getActShop();
1137  $oPdfBlock = new PdfBlock();
1138 
1139  $oLang = oxRegistry::getLang();
1140  $sSal = $this->oxorder__oxdelsal->value;
1141  try {
1142  $sSal = $oLang->translateString($this->oxorder__oxdelsal->value, $this->getSelectedLang());
1143  } catch (Exception $e) {
1144  }
1145 
1146  // loading order currency info
1147  $this->_oCur = $myConfig->getCurrencyObject( $this->oxorder__oxcurrency->value );
1148  if ( !isset( $this->_oCur ) ) {
1149  $this->_oCur = $myConfig->getActShopCurrencyObject();
1150  }
1151 
1152  // shop info
1153  $oPdf->setFont( $oPdfBlock->getFont(), '', 6 );
1154  $oPdf->text( 15, 55, $oShop->oxshops__oxname->getRawValue().' - '.$oShop->oxshops__oxstreet->getRawValue().' - '.$oShop->oxshops__oxzip->value.' - '.$oShop->oxshops__oxcity->getRawValue() );
1155 
1156  // delivery address
1157  $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
1158  if ( $this->oxorder__oxdelsal->value ) {
1159  $oPdf->text( 15, 59, $sSal );
1160  $oPdf->text( 15, 63, $this->oxorder__oxdellname->getRawValue().' '.$this->oxorder__oxdelfname->getRawValue() );
1161  $oPdf->text( 15, 67, $this->oxorder__oxdelcompany->getRawValue() );
1162  $oPdf->text( 15, 71, $this->oxorder__oxdelstreet->getRawValue().' '.$this->oxorder__oxdelstreetnr->value );
1163  $oPdf->setFont( $oPdfBlock->getFont(), 'B', 10 );
1164  $oPdf->text( 15, 75, $this->oxorder__oxdelzip->value.' '.$this->oxorder__oxdelcity->getRawValue() );
1165  $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
1166  $oPdf->text( 15, 79, $this->oxorder__oxdelcountry->getRawValue() );
1167  } else {
1168  // no delivery address - billing address is used for delivery
1169  $this->_setBillingAddressToPdf( $oPdf );
1170  }
1171 
1172  // loading user info
1173  $oUser = oxNew( 'oxuser' );
1174  $oUser->load( $this->oxorder__oxuserid->value );
1175 
1176  // user info
1177  $sText = $this->translate( 'ORDER_OVERVIEW_PDF_FILLONPAYMENT' );
1178  $oPdf->setFont( $oPdfBlock->getFont(), '', 5 );
1179  $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), 70, $sText );
1180 
1181  // customer number
1182  $sCustNr = $this->translate( 'ORDER_OVERVIEW_PDF_CUSTNR' ).' '.$oUser->oxuser__oxcustnr->value;
1183  $oPdf->setFont( $oPdfBlock->getFont(), '', 7 );
1184  $oPdf->text( 195 - $oPdf->getStringWidth( $sCustNr ), 73, $sCustNr );
1185 
1186  // shops city
1187  $sText = $oShop->oxshops__oxcity->getRawValue().', '.date( 'd.m.Y' );
1188  $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
1189  $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), 95, $sText );
1190 
1191  $iTop = 99;
1192  // shop VAT number
1193  if ( $oShop->oxshops__oxvatnumber->value ) {
1194  $sText = $this->translate( 'ORDER_OVERVIEW_PDF_TAXIDNR' ).' '.$oShop->oxshops__oxvatnumber->value;
1195  $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop, $sText );
1196  $iTop += 4;
1197  }
1198 
1199  // invoice number
1200  $sText = $this->translate( 'ORDER_OVERVIEW_PDF_COUNTNR' ).' '.$this->oxorder__oxbillnr->value;
1201  $oPdf->text( 195 - $oPdf->getStringWidth( $sText ), $iTop, $sText );
1202 
1203  // canceled order marker
1204  if ( $this->oxorder__oxstorno->value == 1 ) {
1205  $this->oxorder__oxordernr->setValue( $this->oxorder__oxordernr->getRawValue() . ' '.$this->translate( 'ORDER_OVERVIEW_PDF_STORNO' ), oxField::T_RAW );
1206  }
1207 
1208  // order number
1209  $oPdf->setFont( $oPdfBlock->getFont(), '', 12 );
1210  $oPdf->text( 15, 108, $this->translate( 'ORDER_OVERVIEW_PDF_DELIVNOTE' ).' '.$this->oxorder__oxordernr->value );
1211 
1212  // order date
1213  $aOrderDate = explode( ' ', $this->oxorder__oxorderdate->value );
1214  $sOrderDate = oxRegistry::get("oxUtilsDate")->formatDBDate( $aOrderDate[0]);
1215  $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
1216  $oPdf->text(15, 119, $this->translate( 'ORDER_OVERVIEW_PDF_ORDERSFROM' ).$sOrderDate.$this->translate( 'ORDER_OVERVIEW_PDF_ORDERSAT' ).$oShop->oxshops__oxurl->value );
1217 
1218  // product info header
1219  $oPdf->setFont( $oPdfBlock->getFont(), '', 8 );
1220  $oPdf->text( 15, 128, $this->translate( 'ORDER_OVERVIEW_PDF_AMOUNT' ) );
1221  $oPdf->text( 30, 128, $this->translate( 'ORDER_OVERVIEW_PDF_ARTID' ) );
1222  $oPdf->text( 45, 128, $this->translate( 'ORDER_OVERVIEW_PDF_DESC' ) );
1223 
1224  // line separator
1225  $oPdf->line( 15, 130, 195, 130 );
1226 
1227  // product list
1228  $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
1229  $siteH = 130;
1230 
1231  // order articles
1232  $this->_setOrderArticlesToPdf( $oPdf, $siteH, false );
1233 
1234  // sine separator
1235  $oPdf->line( 15, $siteH + 2, 195, $siteH + 2 );
1236  $siteH += 4;
1237 
1238  // payment date
1239  $oPdf->setFont( $oPdfBlock->getFont(), '', 10 );
1240  $text = $this->translate( 'ORDER_OVERVIEW_PDF_PAYUPTO' ) . date( 'd.m.Y', strtotime( '+' . $this->getPaymentTerm() . ' day', strtotime( $this->oxorder__oxbilldate->value ) ) );
1241  $oPdf->text( 15, $siteH + 4, $text );
1242  }
1243 
1253  protected function _replaceExtendedChars( $sValue, $blReverse = false )
1254  {
1255  // we need to replace this for compatibility with XHTML
1256  // as this function causes a lot of trouble with editor
1257  // we switch it off, even if this means that fields do not validate through xhtml
1258  // return $sValue;
1259 
1260  // we need to replace this for compatibility with XHTML
1261  $aReplace = array( chr(169) => "&copy;", chr(128) => "&euro;", "\"" => "&quot;", "'" => "&#039;");
1262 
1263  // #899C reverse html entities and references transformation is used in invoicepdf module
1264  // so this part must be enabled. Now it works with html references like &#123;
1265  if ($blReverse) {
1266  // replace now
1267  if (version_compare(PHP_VERSION, '5.3.4') >= 0) {
1268  $aTransTbl = get_html_translation_table (HTML_ENTITIES, ENT_COMPAT, 'ISO-8859-1');
1269  } else {
1270  $aTransTbl = get_html_translation_table (HTML_ENTITIES, ENT_COMPAT);
1271  }
1272 
1273  $aTransTbl = array_flip ($aTransTbl) + array_flip ($aReplace);
1274  $sValue = strtr($sValue, $aTransTbl);
1275  $sValue = getStr()->preg_replace('/\&\#([0-9]+)\;/me', "chr('\\1')", $sValue);
1276  }
1277 
1278  return $sValue;
1279  }
1280 
1286  public function getVats()
1287  {
1288  // for older orders
1289  return $this->getProductVats( false );
1290  }
1291 
1297  public function getCurrency()
1298  {
1299  return $this->_oCur;
1300  }
1301 
1307  public function getSelectedLang()
1308  {
1309  return $this->_iSelectedLang;
1310  }
1311 
1317  public function getPaymentTerm()
1318  {
1319  if ( null === $iPaymentTerm = $this->getConfig()->getConfigParam( 'iPaymentTerm' ) ) {
1320  $iPaymentTerm = 7;
1321  }
1322 
1323  return $iPaymentTerm;
1324  }
1325 }