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 || $this->_oData->oxorder__oxgiftcardcost->value) {
00233 $oLang = oxRegistry::getLang();
00234 $oConfig = oxRegistry::getConfig();
00235
00236
00237 if ($oConfig->getConfigParam('blShowVATForWrapping')) {
00238
00239 if ($this->_oData->oxorder__oxwrapcost->value) {
00240
00241 $iStartPos += 4;
00242 $sWrapCostNetto = $oLang->formatCurrency($this->_oData->getOrderWrappingPrice()->getNettoPrice(), $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00243 $this->text(45, $iStartPos, $this->_oData->translate('WRAPPING_COSTS') . ' ' . $this->_oData->translate('ORDER_OVERVIEW_PDF_NETTO'));
00244 $this->text(195 - $this->_oPdf->getStringWidth($sWrapCostNetto), $iStartPos, $sWrapCostNetto);
00245
00246
00247
00248 $iStartPos += 4;
00249 $sWrapCostVAT = $oLang->formatCurrency($this->_oData->getOrderWrappingPrice()->getVATValue(), $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00250 $this->text(45, $iStartPos, $this->_oData->translate('ORDER_OVERVIEW_PDF_ZZGLVAT'));
00251 $this->text(195 - $this->_oPdf->getStringWidth($sWrapCostVAT), $iStartPos, $sWrapCostVAT);
00252
00253 }
00254
00255 if ($this->_oData->oxorder__oxgiftcardcost->value) {
00256
00257 $iStartPos += 4;
00258 $sWrapCostNetto = $oLang->formatCurrency($this->_oData->getOrderGiftCardPrice()->getNettoPrice(), $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00259 $this->text(45, $iStartPos, $this->_oData->translate('GIFTCARD_COSTS') . ' ' . $this->_oData->translate('ORDER_OVERVIEW_PDF_NETTO'));
00260 $this->text(195 - $this->_oPdf->getStringWidth($sWrapCostNetto), $iStartPos, $sWrapCostNetto);
00261
00262
00263
00264 $iStartPos += 4;
00265 $sWrapCostVAT = $oLang->formatCurrency($this->_oData->getOrderGiftCardPrice()->getVATValue(), $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00266
00267 if ($oConfig->getConfigParam('sAdditionalServVATCalcMethod') != 'proportional') {
00268 $sVatValueText = $this->_oData->translate('ORDER_OVERVIEW_PDF_ZZGLVAT') . $this->_oData->oxorder__oxgiftcardvat->value . $this->_oData->translate('ORDER_OVERVIEW_PDF_PERCENTSUM');
00269 } else {
00270 $sVatValueText = $this->_oData->translate('TOTAL_PLUS_PROPORTIONAL_VAT');
00271 }
00272
00273 $this->text(45, $iStartPos, $sVatValueText);
00274 $this->text(195 - $this->_oPdf->getStringWidth($sWrapCostVAT), $iStartPos, $sWrapCostVAT);
00275 $iStartPos++;
00276 }
00277
00278 } else {
00279 $sAddString = ' ' . $this->_oData->translate('ORDER_OVERVIEW_PDF_BRUTTO');
00280
00281 if ($this->_oData->oxorder__oxwrapcost->value) {
00282 $iStartPos += 4;
00283
00284 $sWrapCost = $oLang->formatCurrency($this->_oData->oxorder__oxwrapcost->value, $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00285 $this->text(45, $iStartPos, $this->_oData->translate('WRAPPING_COSTS' ) . $sAddString);
00286 $this->text(195 - $this->_oPdf->getStringWidth($sWrapCost), $iStartPos, $sWrapCost);
00287 $iStartPos++;
00288 }
00289
00290 if ($this->_oData->oxorder__oxgiftcardcost->value) {
00291 $iStartPos += 4;
00292
00293 $sWrapCost = $oLang->formatCurrency($this->_oData->oxorder__oxgiftcardcost->value, $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00294 $this->text(45, $iStartPos, $this->_oData->translate('GIFTCARD_COSTS') . $sAddString);
00295 $this->text(195 - $this->_oPdf->getStringWidth($sWrapCost), $iStartPos, $sWrapCost);
00296 $iStartPos++;
00297 }
00298 }
00299 }
00300 }
00301
00307 protected function _setPaymentInfo(&$iStartPos)
00308 {
00309 $oLang = oxRegistry::getLang();
00310 $oConfig = oxRegistry::getConfig();
00311
00312 if ($this->_oData->oxorder__oxstorno->value) {
00313 $this->_oData->oxorder__oxpaycost->setValue(0);
00314 }
00315
00316 if ($oConfig->getConfigParam('blShowVATForDelivery')) {
00317 if ($this->_oData->oxorder__oxpayvat->value) {
00318
00319 $iStartPos += 4;
00320 $sPayCostNetto = $oLang->formatCurrency($this->_oData->getOrderPaymentPrice()->getNettoPrice(), $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00321 $this->text(45, $iStartPos, $this->_oData->translate('ORDER_OVERVIEW_PDF_PAYMENTIMPACT') . ' ' . $this->_oData->translate('ORDER_OVERVIEW_PDF_NETTO'));
00322 $this->text(195 - $this->_oPdf->getStringWidth($sPayCostNetto), $iStartPos, $sPayCostNetto);
00323
00324 if ($oConfig->getConfigParam('sAdditionalServVATCalcMethod') != 'proportional') {
00325 $sVatValueText = $this->_oData->translate('ORDER_OVERVIEW_PDF_ZZGLVAT') . $this->_oData->oxorder__oxpayvat->value . $this->_oData->translate('ORDER_OVERVIEW_PDF_PERCENTSUM');
00326 } else {
00327 $sVatValueText = $this->_oData->translate('TOTAL_PLUS_PROPORTIONAL_VAT');
00328 }
00329
00330
00331 $iStartPos += 4;
00332 $sPayCostVAT = $oLang->formatCurrency($this->_oData->getOrderPaymentPrice()->getVATValue(), $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00333 $this->text(45, $iStartPos, $sVatValueText);
00334 $this->text(195 - $this->_oPdf->getStringWidth($sPayCostVAT), $iStartPos, $sPayCostVAT);
00335
00336 }
00337
00338
00339
00340 } else {
00341
00342
00343 if ($this->_oData->oxorder__oxpaycost->value) {
00344 $iStartPos += 4;
00345 $sPayCost = $oLang->formatCurrency($this->_oData->oxorder__oxpaycost->value, $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00346 $this->text(45, $iStartPos, $this->_oData->translate('ORDER_OVERVIEW_PDF_PAYMENTIMPACT'));
00347 $this->text(195 - $this->_oPdf->getStringWidth($sPayCost), $iStartPos, $sPayCost);
00348 }
00349
00350 $iStartPos++;
00351 }
00352 }
00353
00359 protected function _setTsProtection(&$iStartPos)
00360 {
00361 $oLang = oxRegistry::getLang();
00362 $oConfig = oxRegistry::getConfig();
00363 if ($this->_oData->oxorder__oxtsprotectcosts->value && $oConfig->getConfigParam('blShowVATForPayCharge')) {
00364
00365
00366 $iStartPos += 4;
00367 $sPayCostNetto = $oLang->formatCurrency($this->_oData->getOrderTsProtectionPrice()->getNettoPrice(), $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00368 $this->text(45, $iStartPos, $this->_oData->translate('ORDER_OVERVIEW_PDF_TSPROTECTION') . ' ' . $this->_oData->translate('ORDER_OVERVIEW_PDF_NETTO'));
00369 $this->text(195 - $this->_oPdf->getStringWidth($sPayCostNetto), $iStartPos, $sPayCostNetto);
00370
00371
00372 $iStartPos += 4;
00373 $sPayCostVAT = $oLang->formatCurrency($this->_oData->getOrderTsProtectionPrice()->getVATValue(), $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00374 $this->text(45, $iStartPos, $this->_oData->translate('ORDER_OVERVIEW_PDF_ZZGLVAT') . $oConfig->getConfigParam('dDefaultVAT') . $this->_oData->translate('ORDER_OVERVIEW_PDF_PERCENTSUM'));
00375 $this->text(195 - $this->_oPdf->getStringWidth($sPayCostVAT), $iStartPos, $sPayCostVAT);
00376
00377 $iStartPos++;
00378
00379 } elseif ($this->_oData->oxorder__oxtsprotectcosts->value) {
00380
00381 $iStartPos += 4;
00382 $sPayCost = $oLang->formatCurrency($this->_oData->oxorder__oxtsprotectcosts->value, $this->_oData->getCurrency()) . ' ' . $this->_oData->getCurrency()->name;
00383 $this->text(45, $iStartPos, $this->_oData->translate('ORDER_OVERVIEW_PDF_TSPROTECTION'));
00384 $this->text(195 - $this->_oPdf->getStringWidth($sPayCost), $iStartPos, $sPayCost);
00385
00386 $iStartPos++;
00387 }
00388 }
00389
00395 protected function _setGrandTotalPriceInfo(&$iStartPos)
00396 {
00397 $this->font($this->getFont(), 'B', 10);
00398
00399
00400 $sTotalOrderSum = $this->_oData->getFormattedTotalOrderSum() . ' ' . $this->_oData->getCurrency()->name;
00401 $this->text(45, $iStartPos, $this->_oData->translate('ORDER_OVERVIEW_PDF_ALLSUM'));
00402 $this->text(195 - $this->_oPdf->getStringWidth($sTotalOrderSum), $iStartPos, $sTotalOrderSum);
00403 $iStartPos += 2;
00404
00405 if ($this->_oData->oxorder__oxdelvat->value || $this->_oData->oxorder__oxwrapvat->value || $this->_oData->oxorder__oxpayvat->value) {
00406 $iStartPos += 2;
00407 }
00408 }
00409
00415 protected function _setPaymentMethodInfo(&$iStartPos)
00416 {
00417 $oPayment = oxNew('oxpayment');
00418 $oPayment->loadInLang($this->_oData->getSelectedLang(), $this->_oData->oxorder__oxpaymenttype->value);
00419
00420 $text = $this->_oData->translate('ORDER_OVERVIEW_PDF_SELPAYMENT') . $oPayment->oxpayments__oxdesc->value;
00421 $this->font($this->getFont(), '', 10);
00422 $this->text(15, $iStartPos + 4, $text);
00423 $iStartPos += 4;
00424 }
00425
00431 protected function _setPayUntilInfo(&$iStartPos)
00432 {
00433 $text = $this->_oData->translate('ORDER_OVERVIEW_PDF_PAYUPTO') . date('d.m.Y', strtotime('+' . $this->_oData->getPaymentTerm() . ' day', strtotime($this->_oData->oxorder__oxbilldate->value)));
00434 $this->font($this->getFont(), '', 10);
00435 $this->text(15, $iStartPos + 4, $text);
00436 $iStartPos += 4;
00437 }
00438
00446 public function generate($iStartPos)
00447 {
00448
00449 $this->font($this->getFont(), '', 10);
00450 $siteH = $iStartPos;
00451
00452
00453 if (!$this->_oData->oxorder__oxdiscount->value) {
00454 $this->_setTotalCostsWithoutDiscount($siteH);
00455 } else {
00456 $this->_setTotalCostsWithDiscount($siteH);
00457 }
00458
00459 $siteH += 12;
00460
00461
00462 $this->_setVoucherInfo($siteH);
00463
00464
00465 if ($this->_oData->oxorder__oxdiscount->value || $this->_oData->oxorder__oxvoucherdiscount->value) {
00466 $this->line(45, $siteH - 3, 195, $siteH - 3);
00467 }
00468
00469
00470 $this->_setDeliveryInfo($siteH);
00471
00472
00473 $this->_setPaymentInfo($siteH);
00474
00475
00476 $this->_setWrappingInfo($siteH);
00477
00478
00479 $this->_setTsProtection($siteH);
00480
00481
00482 $this->line(15, $siteH, 195, $siteH);
00483 $siteH += 4;
00484
00485
00486 $this->_setGrandTotalPriceInfo($siteH);
00487
00488
00489 $this->line(15, $siteH, 195, $siteH);
00490 $siteH += 4;
00491
00492
00493 $this->_setPaymentMethodInfo($siteH);
00494
00495
00496 $this->_setPayUntilInfo($siteH);
00497
00498 return $siteH - $iStartPos;
00499 }
00500 }