00001 <?php
00002
00006 class InvoicepdfArticleSummary extends InvoicepdfBlock
00007 {
00008
00014 protected $_oData = null;
00015
00021 protected $_oPdf = null;
00022
00029 public function __construct($oData, $oPdf)
00030 {
00031 $this->_oData = $oData;
00032 $this->_oPdf = $oPdf;
00033 }
00034
00040 protected function _setTotalCostsWithoutDiscount(&$iStartPos)
00041 {
00042 $oLang = oxRegistry::getLang();
00043
00044
00045 $this->line(15, $iStartPos + 1, 195, $iStartPos + 1);
00046 $sNetSum = $oLang->formatCurrency($this->_oData->oxorder__oxtotalnetsum->value, $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00047 $this->text(45, $iStartPos + 4, $this->_oData->translate('ORDER_OVERVIEW_PDF_ALLPRICENETTO'));
00048 $this->text(195 - $this->_oPdf->getStringWidth($sNetSum), $iStartPos + 4, $sNetSum);
00049
00050
00051 $iCtr = 0;
00052 foreach ($this->_oData->getVats() as $iVat => $dVatPrice) {
00053 $iStartPos += 4 * $iCtr;
00054 $sVATSum = $oLang->formatCurrency($dVatPrice, $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00055 $this->text(45, $iStartPos + 8, $this->_oData->translate('ORDER_OVERVIEW_PDF_ZZGLVAT') . $iVat . $this->_oData->translate('ORDER_OVERVIEW_PDF_PERCENTSUM'));
00056 $this->text(195 - $this->_oPdf->getStringWidth($sVATSum), $iStartPos + 8, $sVATSum);
00057 $iCtr++;
00058 }
00059
00060
00061 $sBrutPrice = $oLang->formatCurrency($this->_oData->oxorder__oxtotalbrutsum->value, $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00062 $this->text(45, $iStartPos + 12, $this->_oData->translate('ORDER_OVERVIEW_PDF_ALLPRICEBRUTTO'));
00063 $this->text(195 - $this->_oPdf->getStringWidth($sBrutPrice), $iStartPos + 12, $sBrutPrice);
00064 $iStartPos++;
00065
00066
00067 $this->line(45, $iStartPos + 13, 195, $iStartPos + 13);
00068 $iStartPos += 5;
00069 }
00070
00076 protected function _setTotalCostsWithDiscount(&$iStartPos)
00077 {
00078 $oLang = oxRegistry::getLang();
00079
00080
00081 $this->line(15, $iStartPos + 1, 195, $iStartPos + 1);
00082
00083 if ($this->_oData->isNettoMode()) {
00084
00085
00086 $sNetSum = $oLang->formatCurrency($this->_oData->oxorder__oxtotalnetsum->value, $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00087 $this->text(45, $iStartPos + 4, $this->_oData->translate('ORDER_OVERVIEW_PDF_ALLPRICENETTO'));
00088 $this->text(195 - $this->_oPdf->getStringWidth($sNetSum), $iStartPos + 4, $sNetSum);
00089
00090
00091 $dDiscountVal = $this->_oData->oxorder__oxdiscount->value;
00092 if ($dDiscountVal > 0) {
00093 $dDiscountVal *= -1;
00094 }
00095 $sDiscount = $oLang->formatCurrency($dDiscountVal, $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00096 $this->text(45, $iStartPos + 8, $this->_oData->translate('ORDER_OVERVIEW_PDF_DISCOUNT'));
00097 $this->text(195 - $this->_oPdf->getStringWidth($sDiscount), $iStartPos + 8, $sDiscount);
00098 $iStartPos++;
00099
00100
00101 $this->line(45, $iStartPos + 8, 195, $iStartPos + 8);
00102
00103 $iCtr = 0;
00104 foreach ($this->_oData->getVats() as $iVat => $dVatPrice) {
00105 $iStartPos += 4 * $iCtr;
00106 $sVATSum = $oLang->formatCurrency($dVatPrice, $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00107 $this->text(45, $iStartPos + 12, $this->_oData->translate('ORDER_OVERVIEW_PDF_ZZGLVAT') . $iVat . $this->_oData->translate('ORDER_OVERVIEW_PDF_PERCENTSUM'));
00108 $this->text(195 - $this->_oPdf->getStringWidth($sVATSum), $iStartPos + 12, $sVATSum);
00109 $iCtr++;
00110 }
00111 $iStartPos += 4;
00112
00113
00114 $sBrutPrice = $oLang->formatCurrency($this->_oData->oxorder__oxtotalbrutsum->value, $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00115 $this->text(45, $iStartPos + 12, $this->_oData->translate('ORDER_OVERVIEW_PDF_ALLPRICEBRUTTO'));
00116 $this->text(195 - $this->_oPdf->getStringWidth($sBrutPrice), $iStartPos + 12, $sBrutPrice);
00117 $iStartPos += 4;
00118
00119 } else {
00120
00121 $sBrutPrice = $oLang->formatCurrency($this->_oData->oxorder__oxtotalbrutsum->value, $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00122 $this->text(45, $iStartPos + 4, $this->_oData->translate('ORDER_OVERVIEW_PDF_ALLPRICEBRUTTO'));
00123 $this->text(195 - $this->_oPdf->getStringWidth($sBrutPrice), $iStartPos + 4, $sBrutPrice);
00124
00125
00126 $this->line(45, $iStartPos + 5, 195, $iStartPos + 5);
00127
00128
00129 $dDiscountVal = $this->_oData->oxorder__oxdiscount->value;
00130 if ($dDiscountVal > 0) {
00131 $dDiscountVal *= -1;
00132 }
00133 $sDiscount = $oLang->formatCurrency($dDiscountVal, $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00134 $this->text(45, $iStartPos + 8, $this->_oData->translate('ORDER_OVERVIEW_PDF_DISCOUNT'));
00135 $this->text(195 - $this->_oPdf->getStringWidth($sDiscount), $iStartPos + 8, $sDiscount);
00136 $iStartPos++;
00137
00138
00139 $this->line(45, $iStartPos + 8, 195, $iStartPos + 8);
00140 $iStartPos += 4;
00141
00142
00143 $sNetSum = $oLang->formatCurrency($this->_oData->oxorder__oxtotalnetsum->value, $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00144 $this->text(45, $iStartPos + 8, $this->_oData->translate('ORDER_OVERVIEW_PDF_ALLPRICENETTO'));
00145 $this->text(195 - $this->_oPdf->getStringWidth($sNetSum), $iStartPos + 8, $sNetSum);
00146
00147
00148 $iCtr = 0;
00149 foreach ($this->_oData->getVats() as $iVat => $dVatPrice) {
00150 $iStartPos += 4 * $iCtr;
00151 $sVATSum = $oLang->formatCurrency($dVatPrice, $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00152 $this->text(45, $iStartPos + 12, $this->_oData->translate('ORDER_OVERVIEW_PDF_ZZGLVAT') . $iVat . $this->_oData->translate('ORDER_OVERVIEW_PDF_PERCENTSUM'));
00153 $this->text(195 - $this->_oPdf->getStringWidth($sVATSum), $iStartPos + 12, $sVATSum);
00154 $iCtr++;
00155 }
00156 $iStartPos += 4;
00157 }
00158 }
00159
00165 protected function _setVoucherInfo(&$iStartPos)
00166 {
00167 $dVoucher = 0;
00168 if ($this->_oData->oxorder__oxvoucherdiscount->value) {
00169 $dDiscountVal = $this->_oData->oxorder__oxvoucherdiscount->value;
00170 if ($dDiscountVal > 0) {
00171 $dDiscountVal *= -1;
00172 }
00173 $sPayCost = oxRegistry::getLang()->formatCurrency($dDiscountVal, $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00174 $this->text(45, $iStartPos, $this->_oData->translate('ORDER_OVERVIEW_PDF_VOUCHER'));
00175 $this->text(195 - $this->_oPdf->getStringWidth($sPayCost), $iStartPos, $sPayCost);
00176 $iStartPos += 4;
00177 }
00178
00179 $iStartPos++;
00180 }
00181
00187 protected function _setDeliveryInfo(&$iStartPos)
00188 {
00189 $sAddString = '';
00190 $oLang = oxRegistry::getLang();
00191 $oConfig = oxRegistry::getConfig();
00192
00193 if ($oConfig->getConfigParam('blShowVATForDelivery')) {
00194
00195 $sDelCostNetto = $oLang->formatCurrency($this->_oData->getOrderDeliveryPrice()->getNettoPrice(), $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00196 $this->text(45, $iStartPos, $this->_oData->translate('ORDER_OVERVIEW_PDF_SHIPCOST') . ' ' . $this->_oData->translate('ORDER_OVERVIEW_PDF_NETTO'));
00197 $this->text(195 - $this->_oPdf->getStringWidth($sDelCostNetto), $iStartPos, $sDelCostNetto);
00198 $iStartPos += 4;
00199
00200 if ($oConfig->getConfigParam('sAdditionalServVATCalcMethod') != 'proportional') {
00201 $sVatValueText = $this->_oData->translate('ORDER_OVERVIEW_PDF_ZZGLVAT') . $this->_oData->oxorder__oxdelvat->value . $this->_oData->translate('ORDER_OVERVIEW_PDF_PERCENTSUM');
00202 } else {
00203 $sVatValueText = $this->_oData->translate('TOTAL_PLUS_PROPORTIONAL_VAT');
00204 }
00205
00206
00207 $sDelCostVAT = $oLang->formatCurrency($this->_oData->getOrderDeliveryPrice()->getVATValue(), $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00208 $this->text(45, $iStartPos, $sVatValueText);
00209 $this->text(195 - $this->_oPdf->getStringWidth($sDelCostVAT), $iStartPos, $sDelCostVAT);
00210
00211
00212 $sAddString = ' ' . $this->_oData->translate('ORDER_OVERVIEW_PDF_BRUTTO');
00213 } else {
00214
00215 if ($this->_oData->oxorder__oxstorno->value) {
00216 $this->_oData->oxorder__oxdelcost->setValue(0);
00217 }
00218
00219 $sDelCost = $oLang->formatCurrency($this->_oData->oxorder__oxdelcost->value, $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00220 $this->text(45, $iStartPos, $this->_oData->translate('ORDER_OVERVIEW_PDF_SHIPCOST') . $sAddString);
00221 $this->text(195 - $this->_oPdf->getStringWidth($sDelCost), $iStartPos, $sDelCost);
00222 }
00223 }
00224
00230 protected function _setWrappingInfo(&$iStartPos)
00231 {
00232 if ($this->_oData->oxorder__oxwrapcost->value) {
00233 $sAddString = '';
00234 $oLang = oxRegistry::getLang();
00235 $oConfig = oxRegistry::getConfig();
00236
00237
00238 if ($oConfig->getConfigParam('blShowVATForWrapping')) {
00239
00240 if ($this->_oData->oxorder__oxwrapcost->value) {
00241
00242 $iStartPos += 4;
00243 $sWrapCostNetto = $oLang->formatCurrency($this->_oData->getOrderWrappingPrice()->getNettoPrice(), $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00244 $this->text(45, $iStartPos, $this->_oData->translate('WRAPPING_COSTS') . ' ' . $this->_oData->translate('ORDER_OVERVIEW_PDF_NETTO'));
00245 $this->text(195 - $this->_oPdf->getStringWidth($sWrapCostNetto), $iStartPos, $sWrapCostNetto);
00246
00247
00248
00249 $iStartPos += 4;
00250 $sWrapCostVAT = $oLang->formatCurrency($this->_oData->getOrderWrappingPrice()->getVATValue(), $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00251 $this->text(45, $iStartPos, $this->_oData->translate('ORDER_OVERVIEW_PDF_ZZGLVAT'));
00252 $this->text(195 - $this->_oPdf->getStringWidth($sWrapCostVAT), $iStartPos, $sWrapCostVAT);
00253
00254 }
00255
00256
00257 if ($this->_oData->oxorder__oxgiftcardcost->value) {
00258
00259 $iStartPos += 4;
00260 $sWrapCostNetto = $oLang->formatCurrency($this->_oData->getOrderGiftCardPrice()->getNettoPrice(), $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00261 $this->text(45, $iStartPos, $this->_oData->translate('GIFTCARD_COSTS') . ' ' . $this->_oData->translate('ORDER_OVERVIEW_PDF_NETTO'));
00262 $this->text(195 - $this->_oPdf->getStringWidth($sWrapCostNetto), $iStartPos, $sWrapCostNetto);
00263
00264
00265
00266 $iStartPos += 4;
00267 $sWrapCostVAT = $oLang->formatCurrency($this->_oData->getOrderGiftCardPrice()->getVATValue(), $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00268
00269 if ($oConfig->getConfigParam('sAdditionalServVATCalcMethod') != 'proportional') {
00270 $sVatValueText = $this->_oData->translate('ORDER_OVERVIEW_PDF_ZZGLVAT') . $this->_oData->oxorder__oxgiftcardvat->value . $this->_oData->translate('ORDER_OVERVIEW_PDF_PERCENTSUM');
00271 } else {
00272 $sVatValueText = $this->_oData->translate('TOTAL_PLUS_PROPORTIONAL_VAT');
00273 }
00274
00275 $this->text(45, $iStartPos, $sVatValueText);
00276 $this->text(195 - $this->_oPdf->getStringWidth($sWrapCostVAT), $iStartPos, $sWrapCostVAT);
00277 $iStartPos++;
00278 }
00279
00280 } else {
00281 $iStartPos += 4;
00282
00283 if ($this->_oData->oxorder__oxwrapcost->value) {
00284
00285 $sAddString = ' ' . $this->_oData->translate('ORDER_OVERVIEW_PDF_BRUTTO');
00286 $sWrapCost = $oLang->formatCurrency($this->_oData->oxorder__oxwrapcost->value, $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00287 $this->text(45, $iStartPos, $this->_oData->translate('WRAPPING_COSTS' ) . $sAddString);
00288 $this->text(195 - $this->_oPdf->getStringWidth($sWrapCost), $iStartPos, $sWrapCost);
00289 $iStartPos++;
00290 }
00291
00292 if ($this->_oData->oxorder__oxgiftcardcost->value) {
00293 $iStartPos += 4;
00294
00295 $sWrapCost = $oLang->formatCurrency($this->_oData->oxorder__oxgiftcardcost->value, $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00296 $this->text(45, $iStartPos, $this->_oData->translate('GIFTCARD_COSTS') . $sAddString);
00297 $this->text(195 - $this->_oPdf->getStringWidth($sWrapCost), $iStartPos, $sWrapCost);
00298 $iStartPos++;
00299 }
00300
00301 }
00302
00303 }
00304 }
00305
00311 protected function _setPaymentInfo(&$iStartPos)
00312 {
00313 $oLang = oxRegistry::getLang();
00314 $oConfig = oxRegistry::getConfig();
00315
00316 if ($this->_oData->oxorder__oxstorno->value) {
00317 $this->_oData->oxorder__oxpaycost->setValue(0);
00318 }
00319
00320 if ($oConfig->getConfigParam('blShowVATForDelivery')) {
00321 if ($this->_oData->oxorder__oxpayvat->value) {
00322
00323 $iStartPos += 4;
00324 $sPayCostNetto = $oLang->formatCurrency($this->_oData->getOrderPaymentPrice()->getNettoPrice(), $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00325 $this->text(45, $iStartPos, $this->_oData->translate('ORDER_OVERVIEW_PDF_PAYMENTIMPACT') . ' ' . $this->_oData->translate('ORDER_OVERVIEW_PDF_NETTO'));
00326 $this->text(195 - $this->_oPdf->getStringWidth($sPayCostNetto), $iStartPos, $sPayCostNetto);
00327
00328 if ($oConfig->getConfigParam('sAdditionalServVATCalcMethod') != 'proportional') {
00329 $sVatValueText = $this->_oData->translate('ORDER_OVERVIEW_PDF_ZZGLVAT') . $this->_oData->oxorder__oxpayvat->value . $this->_oData->translate('ORDER_OVERVIEW_PDF_PERCENTSUM');
00330 } else {
00331 $sVatValueText = $this->_oData->translate('TOTAL_PLUS_PROPORTIONAL_VAT');
00332 }
00333
00334
00335 $iStartPos += 4;
00336 $sPayCostVAT = $oLang->formatCurrency($this->_oData->getOrderPaymentPrice()->getVATValue(), $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00337 $this->text(45, $iStartPos, $sVatValueText);
00338 $this->text(195 - $this->_oPdf->getStringWidth($sPayCostVAT), $iStartPos, $sPayCostVAT);
00339
00340 }
00341
00342
00343
00344 } else {
00345
00346
00347 if ($this->_oData->oxorder__oxpaycost->value) {
00348 $iStartPos += 4;
00349 $sPayCost = $oLang->formatCurrency($this->_oData->oxorder__oxpaycost->value, $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00350 $this->text(45, $iStartPos, $this->_oData->translate('ORDER_OVERVIEW_PDF_PAYMENTIMPACT'));
00351 $this->text(195 - $this->_oPdf->getStringWidth($sPayCost), $iStartPos, $sPayCost);
00352 }
00353
00354 $iStartPos++;
00355 }
00356 }
00357
00363 protected function _setTsProtection(&$iStartPos)
00364 {
00365 $oLang = oxRegistry::getLang();
00366 $oConfig = oxRegistry::getConfig();
00367 if ($this->_oData->oxorder__oxtsprotectcosts->value && $oConfig->getConfigParam('blShowVATForPayCharge')) {
00368
00369
00370 $iStartPos += 4;
00371 $sPayCostNetto = $oLang->formatCurrency($this->_oData->getOrderTsProtectionPrice()->getNettoPrice(), $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00372 $this->text(45, $iStartPos, $this->_oData->translate('ORDER_OVERVIEW_PDF_TSPROTECTION') . ' ' . $this->_oData->translate('ORDER_OVERVIEW_PDF_NETTO'));
00373 $this->text(195 - $this->_oPdf->getStringWidth($sPayCostNetto), $iStartPos, $sPayCostNetto);
00374
00375
00376 $iStartPos += 4;
00377 $sPayCostVAT = $oLang->formatCurrency($this->_oData->getOrderTsProtectionPrice()->getVATValue(), $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00378 $this->text(45, $iStartPos, $this->_oData->translate('ORDER_OVERVIEW_PDF_ZZGLVAT') . $oConfig->getConfigParam('dDefaultVAT') . $this->_oData->translate('ORDER_OVERVIEW_PDF_PERCENTSUM'));
00379 $this->text(195 - $this->_oPdf->getStringWidth($sPayCostVAT), $iStartPos, $sPayCostVAT);
00380
00381 $iStartPos++;
00382
00383 } elseif ($this->_oData->oxorder__oxtsprotectcosts->value) {
00384
00385 $iStartPos += 4;
00386 $sPayCost = $oLang->formatCurrency($this->_oData->oxorder__oxtsprotectcosts->value, $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00387 $this->text(45, $iStartPos, $this->_oData->translate('ORDER_OVERVIEW_PDF_TSPROTECTION'));
00388 $this->text(195 - $this->_oPdf->getStringWidth($sPayCost), $iStartPos, $sPayCost);
00389
00390 $iStartPos++;
00391 }
00392 }
00393
00399 protected function _setGrandTotalPriceInfo(&$iStartPos)
00400 {
00401 $this->font($this->getFont(), 'B', 10);
00402
00403
00404 $sTotalOrderSum = $this->_oData->getFormattedTotalOrderSum() . ' ' . $this->_oData->getCurrency()->name;
00405 $this->text(45, $iStartPos, $this->_oData->translate('ORDER_OVERVIEW_PDF_ALLSUM'));
00406 $this->text(195 - $this->_oPdf->getStringWidth($sTotalOrderSum), $iStartPos, $sTotalOrderSum);
00407 $iStartPos += 2;
00408
00409 if ($this->_oData->oxorder__oxdelvat->value || $this->_oData->oxorder__oxwrapvat->value || $this->_oData->oxorder__oxpayvat->value) {
00410 $iStartPos += 2;
00411 }
00412 }
00413
00419 protected function _setPaymentMethodInfo(&$iStartPos)
00420 {
00421 $oPayment = oxNew('oxpayment');
00422 $oPayment->loadInLang($this->_oData->getSelectedLang(), $this->_oData->oxorder__oxpaymenttype->value);
00423
00424 $text = $this->_oData->translate('ORDER_OVERVIEW_PDF_SELPAYMENT') . $oPayment->oxpayments__oxdesc->value;
00425 $this->font($this->getFont(), '', 10);
00426 $this->text(15, $iStartPos + 4, $text);
00427 $iStartPos += 4;
00428 }
00429
00435 protected function _setPayUntilInfo(&$iStartPos)
00436 {
00437 $text = $this->_oData->translate('ORDER_OVERVIEW_PDF_PAYUPTO') . date('d.m.Y', strtotime('+' . $this->_oData->getPaymentTerm() . ' day', strtotime($this->_oData->oxorder__oxbilldate->value)));
00438 $this->font($this->getFont(), '', 10);
00439 $this->text(15, $iStartPos + 4, $text);
00440 $iStartPos += 4;
00441 }
00442
00450 public function generate($iStartPos)
00451 {
00452
00453 $this->font($this->getFont(), '', 10);
00454 $siteH = $iStartPos;
00455
00456
00457 if (!$this->_oData->oxorder__oxdiscount->value) {
00458 $this->_setTotalCostsWithoutDiscount($siteH);
00459 } else {
00460 $this->_setTotalCostsWithDiscount($siteH);
00461 }
00462
00463 $siteH += 12;
00464
00465
00466 $this->_setVoucherInfo($siteH);
00467
00468
00469 if ($this->_oData->oxorder__oxdiscount->value || $this->_oData->oxorder__oxvoucherdiscount->value) {
00470 $this->line(45, $siteH - 3, 195, $siteH - 3);
00471 }
00472
00473
00474 $this->_setDeliveryInfo($siteH);
00475
00476
00477 $this->_setPaymentInfo($siteH);
00478
00479
00480 $this->_setWrappingInfo($siteH);
00481
00482
00483 $this->_setTsProtection($siteH);
00484
00485
00486 $this->line(15, $siteH, 195, $siteH);
00487 $siteH += 4;
00488
00489
00490 $this->_setGrandTotalPriceInfo($siteH);
00491
00492
00493 $this->line(15, $siteH, 195, $siteH);
00494 $siteH += 4;
00495
00496
00497 $this->_setPaymentMethodInfo($siteH);
00498
00499
00500 $this->_setPayUntilInfo($siteH);
00501
00502 return $siteH - $iStartPos;
00503 }
00504 }