Example #1
0
 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;
 }
Example #2
0
 public function testDraw()
 {
     $expectedPageSettings = array('table_header' => true);
     $expectedPdfPage = new Zend_Pdf_Page('a4');
     $expectedPdfData = array(array('lines' => array(array(array('text' => array('Downloadable Documentation'), 'feed' => 35), array('text' => array('downloadable-docu', 'mentation'), 'feed' => 255, 'align' => 'right'), array('text' => '$20.00', 'feed' => 330, 'font' => 'bold', 'align' => 'right'), array('text' => '$-5.00', 'feed' => 380, 'font' => 'bold', 'align' => 'right'), array('text' => '1', 'feed' => 445, 'font' => 'bold', 'align' => 'right'), array('text' => '$2.00', 'feed' => 495, 'font' => 'bold', 'align' => 'right'), array('text' => '$17.00', 'feed' => 565, 'font' => 'bold', 'align' => 'right')), array(array('text' => array('Test Custom Option'), 'font' => 'italic', 'feed' => 35)), array(array('text' => array('test value'), 'feed' => 40)), array(array('text' => array('Download Links'), 'font' => 'italic', 'feed' => 35)), array(array('text' => array('Magento User Guide'), 'feed' => 40))), 'height' => 20));
     $this->_model->setItem(new Varien_Object(array('name' => 'Downloadable Documentation', 'sku' => 'downloadable-documentation', 'row_total' => 20.0, 'discount_amount' => 5.0, 'qty' => 1, 'tax_amount' => 2.0, 'hidden_tax_amount' => 0.0, 'order_item' => new Varien_Object(array('product_options' => array('options' => array(array('label' => 'Test Custom Option', 'value' => 'test value'))))))));
     $this->_model->expects($this->any())->method('getLinksTitle')->will($this->returnValue('Download Links'));
     $this->_model->expects($this->any())->method('getLinks')->will($this->returnValue(new Varien_Object(array('purchased_items' => array(new Varien_Object(array('link_title' => 'Magento User Guide')))))));
     $this->_pdf->expects($this->once())->method('drawLineBlocks')->with($this->anything(), $expectedPdfData, $expectedPageSettings)->will($this->returnValue($expectedPdfPage));
     $this->assertNotSame($expectedPdfPage, $this->_model->getPage());
     $this->_model->draw();
     $this->assertSame($expectedPdfPage, $this->_model->getPage());
 }
 /**
  * Draw item line
  *
  */
 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;
         // 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);
         // 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);
             }
         }
         // downloadable Items
         $_purchasedItems = $this->getLinks()->getPurchasedItems();
         // draw Links title
         $lines[][] = array('text' => Mage::helper('core/string')->str_split($this->getLinksTitle(), 70, true, true), 'font' => 'italic', 'feed' => 35);
         // draw Links
         foreach ($_purchasedItems as $_link) {
             $lines[][] = array('text' => Mage::helper('core/string')->str_split($_link->getLinkTitle(), 50, true, true), 'feed' => 40);
         }
         $lineBlock = array('lines' => $lines, 'height' => 10);
         $page = $pdf->drawLineBlocks($page, array($lineBlock), array('table_header' => true));
         $this->setPage($page);
     }
 }