Esempio n. 1
0
 public function getItemOptions()
 {
     $result = parent::getItemOptions();
     $item = Mage::getModel('sales/order_item')->load($this->getItem()->getOrderItemId());
     if ($item->getProductType() != 'giftvoucher') {
         return $result;
     }
     if ($options = $item->getProductOptionByCode('info_buyRequest')) {
         foreach (Mage::helper('giftvoucher')->getGiftVoucherOptions() as $code => $label) {
             if ($options[$code]) {
                 $result[] = array('label' => $label, 'value' => $options[$code], 'print_value' => $options[$code]);
             }
         }
     }
     $giftVouchers = Mage::getModel('giftvoucher/giftvoucher')->getCollection()->addItemFilter($item->getId());
     if ($giftVouchers->getSize()) {
         $giftVouchersCode = array();
         foreach ($giftVouchers as $giftVoucher) {
             $currency = Mage::getModel('directory/currency')->load($giftVoucher->getCurrency());
             $balance = $giftVoucher->getBalance();
             if ($currency) {
                 $balance = $currency->format($balance, array(), false);
             }
             $giftVouchersCode[] = $giftVoucher->getGiftCode() . ' (' . $balance . ') ';
         }
         $codes = implode(' ', $giftVouchersCode);
         $result[] = array('label' => Mage::helper('giftvoucher')->__('Gift Voucher Code'), 'value' => $codes, 'print_value' => $codes);
     }
     return $result;
 }
 public function draw()
 {
     $order = $this->getOrder();
     if (!$order->getDcOrderId() || $order->getDeliveryDutyType() == Dutycalculator_Charge_Helper_Data::DC_DELIVERY_TYPE_DDU || $order->getFailedCalculation()) {
         parent::draw();
     } else {
         $item = $this->getItem();
         $pdf = $this->getPdf();
         $page = $this->getPage();
         $lines = array();
         $leftBound = 35;
         $rightBound = 565;
         $x = $leftBound;
         // draw Product name
         $lines[0] = array(array('text' => Mage::helper('core/string')->str_split($item->getName(), 60, true, true), 'feed' => $x));
         $x += 200;
         //220
         // draw SKU
         $lines[0][] = array('text' => Mage::helper('core/string')->str_split($this->getSku($item), 25), 'feed' => $x);
         $x += 80;
         //100
         // draw Total (ex)
         $lines[0][] = array('text' => $order->formatPriceTxt($item->getRowTotal()), 'feed' => $x, 'font' => 'bold', 'align' => 'right', 'width' => 50);
         $x += 50;
         // draw Discount
         $lines[0][] = array('text' => $order->formatPriceTxt(-$item->getDiscountAmount()), 'feed' => $x, 'font' => 'bold', 'align' => 'right', 'width' => 50);
         $x += 50;
         // draw QTY
         $lines[0][] = array('text' => $item->getQty() * 1, 'feed' => $x, 'font' => 'bold', 'align' => 'center', 'width' => 30);
         $x += 30;
         // draw Tax
         $lines[0][] = array('text' => $order->formatPriceTxt($item->getTaxAmount() + $item->getSalesTax()), 'feed' => $x, 'font' => 'bold', 'align' => 'right', 'width' => 35);
         $x += 40;
         //45
         // draw Tax
         $lines[0][] = array('text' => $order->formatPriceTxt($item->getImportDuty()), 'feed' => $x, 'font' => 'bold', 'align' => 'right', 'width' => 40);
         $x += 45;
         //45
         // draw Subtotal
         $lines[0][] = array('text' => $order->formatPriceTxt($item->getRowTotal() + $item->getTaxAmount() + $item->getImportDutyTax() - $item->getDiscountAmount()), 'feed' => $rightBound, 'font' => 'bold', 'align' => 'right');
         // draw options
         $options = $this->getItemOptions();
         if ($options) {
             foreach ($options as $option) {
                 // draw options label
                 $lines[][] = array('text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 70, true, true), 'font' => 'italic', 'feed' => $leftBound);
                 // draw options value
                 $_printValue = isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']);
                 $lines[][] = array('text' => Mage::helper('core/string')->str_split($_printValue, 50, true, true), 'feed' => $leftBound + 5);
             }
         }
         $lineBlock = array('lines' => $lines, 'height' => 10);
         $page = $pdf->drawLineBlocks($page, array($lineBlock), array('table_header' => true));
         $this->setPage($page);
     }
 }
 public function getItemOptions()
 {
     $opts = $this->getItem()->getOrderItem()->getProductOptions();
     $options = array();
     if (@$opts['info_buyRequest']) {
         if ($opts['info_buyRequest'] && ($periodTypeId = @$opts['info_buyRequest']['aw_sarp_subscription_type']) && ($periodStartDate = @$opts['info_buyRequest']['aw_sarp_subscription_start'])) {
             $startDateLabel = $this->getItem()->getOrderItem()->getIsVirtual() ? "Subscription start:" : "First delivery:";
             $options[] = array('label' => Mage::helper('sarp')->__('Subscription type:'), 'value' => Mage::getModel('sarp/period')->load($periodTypeId)->getName());
             $options[] = array('label' => Mage::helper('sarp')->__($startDateLabel), 'value' => $periodStartDate);
         }
     }
     $options = array_merge($options, parent::getItemOptions());
     return $options;
 }
Esempio n. 4
0
 public function getItemOptions()
 {
     $result = parent::getItemOptions();
     $result = Mage::helper('aitcg/options')->replaceAitTemplateWithText($result);
     return $result;
 }