예제 #1
0
 /**
  * Draw item line
  */
 public function draw()
 {
     $order = $this->getOrder();
     $item = $this->getItem();
     $pdf = $this->getPdf();
     $page = $this->getPage();
     $lines = array();
     // draw Product name
     $name = array();
     $name[] = $item->getName();
     //get order and check if it has items with different dates
     $isSingle = ITwebexperts_Payperrentals_Helper_Data::isSingleOrder($order);
     if ($options = $item->getOrderItem()->getProductOptions()) {
         //$startDateLabel = $this->getItem()->getIsVirtual() ? $this->__("Subscription start:") : $this->__("First delivery:");
         if (isset($options['info_buyRequest'])) {
             if (isset($options['info_buyRequest'][ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION])) {
                 $start_date = $options['info_buyRequest'][ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION];
                 $end_date = $options['info_buyRequest'][ITwebexperts_Payperrentals_Model_Product_Type_Reservation::END_DATE_OPTION];
             }
             if (!$isSingle['bool']) {
                 if (isset($start_date)) {
                     $name[] = 'Start date: ' . $start_date;
                 }
                 if (isset($end_date)) {
                     $name[] = 'End date: ' . $end_date;
                 }
             }
         }
     }
     foreach ($name as $j1 => $namen) {
         if ($order->getIsSingle() == 0 && $j1 > 0) {
             $lines[$j1] = array(array('text' => Mage::helper('core/string')->str_split($namen, 60, true, true), 'feed' => 100));
         } elseif ($j1 == 0) {
             $lines[$j1] = array(array('text' => Mage::helper('core/string')->str_split($namen . ($order->getIsSingle() == 1 ? '(reservation)' : ''), 60, true, true), 'feed' => 100));
         }
     }
     // draw QTY
     $lines[0][] = array('text' => $item->getQty() * 1, 'feed' => 35);
     // draw SKU
     $lines[0][] = array('text' => Mage::helper('core/string')->str_split($this->getSku($item), 25), 'feed' => 565, 'align' => 'right');
     // Custom 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' => 110);
             // draw options value
             if ($option['value']) {
                 $_printValue = isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']);
                 $values = explode(', ', $_printValue);
                 foreach ($values as $value) {
                     $lines[][] = array('text' => Mage::helper('core/string')->str_split($value, 50, true, true), 'feed' => 115);
                 }
             }
         }
     }
     $lineBlock = array('lines' => $lines, 'height' => 20);
     $page = $pdf->drawLineBlocks($page, array($lineBlock), array('table_header' => true));
     $this->setPage($page);
 }
예제 #2
0
 /**
  * Draw item line
  */
 public function draw()
 {
     $order = $this->getOrder();
     $item = $this->getItem();
     $pdf = $this->getPdf();
     $page = $this->getPage();
     $lines = array();
     // draw Product name
     $name = array();
     $name[] = $item->getName();
     //get order and check if it has items with different dates
     $isSingle = ITwebexperts_Payperrentals_Helper_Data::isSingleOrder($order);
     if ($options = $item->getOrderItem()->getProductOptions()) {
         //$startDateLabel = $this->getItem()->getIsVirtual() ? $this->__("Subscription start:") : $this->__("First delivery:");
         if (isset($options['info_buyRequest'])) {
             if (isset($options['info_buyRequest'][ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION])) {
                 $start_date = $options['info_buyRequest'][ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION];
                 $end_date = $options['info_buyRequest'][ITwebexperts_Payperrentals_Model_Product_Type_Reservation::END_DATE_OPTION];
             }
             if (!$isSingle['bool']) {
                 if (isset($start_date)) {
                     $name[] = 'Start date: ' . $start_date;
                 }
                 if (isset($end_date)) {
                     $name[] = 'End date: ' . $end_date;
                 }
             }
         }
     }
     foreach ($name as $j1 => $namen) {
         if ($order->getIsSingle() == 0 && $j1 > 0) {
             $lines[$j1] = array(array('text' => Mage::helper('core/string')->str_split($namen, 35, true, true), 'feed' => 35));
         } elseif ($j1 == 0) {
             $lines[$j1] = array(array('text' => Mage::helper('core/string')->str_split($namen . ($order->getIsSingle() == 1 ? '(reservation)' : ''), 35, true, true), 'feed' => 35));
         }
     }
     // draw SKU
     $lines[0][] = array('text' => Mage::helper('core/string')->str_split($this->getSku($item), 17), 'feed' => 290, 'align' => 'right');
     // draw QTY
     $lines[0][] = array('text' => $item->getQty() * 1, 'feed' => 435, 'align' => 'right');
     // draw item Prices
     $i = 0;
     $prices = $this->getItemPricesForDisplay();
     $feedPrice = 395;
     $feedSubtotal = $feedPrice + 170;
     foreach ($prices as $priceData) {
         if (isset($priceData['label'])) {
             // draw Price label
             $lines[$i][] = array('text' => $priceData['label'], 'feed' => $feedPrice, 'align' => 'right');
             // draw Subtotal label
             $lines[$i][] = array('text' => $priceData['label'], 'feed' => $feedSubtotal, 'align' => 'right');
             $i++;
         }
         // draw Price
         $lines[$i][] = array('text' => $priceData['price'], 'feed' => $feedPrice, 'font' => 'bold', 'align' => 'right');
         // draw Subtotal
         $lines[$i][] = array('text' => $priceData['subtotal'], 'feed' => $feedSubtotal, 'font' => 'bold', 'align' => 'right');
         $i++;
     }
     // draw Tax
     $lines[0][] = array('text' => $order->formatPriceTxt($item->getTaxAmount()), 'feed' => 495, 'font' => 'bold', 'align' => 'right');
     // custom 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']), 40, true, true), 'font' => 'italic', 'feed' => 35);
             if ($option['value']) {
                 if (isset($option['print_value'])) {
                     $_printValue = $option['print_value'];
                 } else {
                     $_printValue = strip_tags($option['value']);
                 }
                 $values = explode(', ', $_printValue);
                 foreach ($values as $value) {
                     $lines[][] = array('text' => Mage::helper('core/string')->str_split($value, 30, true, true), 'feed' => 40);
                 }
             }
         }
     }
     $lineBlock = array('lines' => $lines, 'height' => 20);
     $page = $pdf->drawLineBlocks($page, array($lineBlock), array('table_header' => true));
     $this->setPage($page);
 }
예제 #3
0
 public function getExtendPopupAction()
 {
     if (!$this->getRequest()->getParam('order_id')) {
         return;
     }
     $order = Mage::getModel('sales/order')->load($this->getRequest()->getParam('order_id'));
     $orderDatesArr = ITwebexperts_Payperrentals_Helper_Data::isSingleOrder($order);
     $html = ITwebexperts_Payperrentals_Helper_Extend::getExtendHtml($this->getRequest()->getParam('order_id'));
     $jsonReturn = array('content' => $html, 'minDate' => date('r', strtotime('+1 day', strtotime($orderDatesArr['end_date']))));
     $this->getResponse()->setBody(Zend_Json::encode($jsonReturn));
 }
예제 #4
0
 public static function showSingleDates($order, $_isSingleLine = true)
 {
     $isSingle = ITwebexperts_Payperrentals_Helper_Data::isSingleOrder($order);
     if ($isSingle['bool']) {
         if (!Mage::helper('payperrentals/config')->isNonSequentialSelect(Mage::app()->getStore()->getId())) {
             if ($isSingle['start_date'] != $isSingle['end_date'] && $isSingle['start_date'] != '') {
                 $_space = !$_isSingleLine ? '<br/>' : ' ';
                 return '<span style="font-weight:bold;font-size:12px">' . Mage::helper('payperrentals')->__('Start Date: ') . '</span><span style="font-weight:normal;font-size:12px;">' . ITwebexperts_Payperrentals_Helper_Date::formatDbDate($isSingle['start_date'], false) . '</span>' . $_space . $_space . '<span style="font-weight:bold;font-size:12px">' . Mage::helper('payperrentals')->__('End Date: ') . '</span><span style="font-weight:normal;font-size:12px;">' . ITwebexperts_Payperrentals_Helper_Date::formatDbDate($isSingle['end_date'], false) . '</span><br /><br />';
             } else {
                 if ($isSingle['start_date'] != '') {
                     return '<span style="font-weight:bold;font-size:12px;">' . Mage::helper('payperrentals')->__('Start Date:') . '</span><span style="font-weight:normal;font-size:12px;">' . ITwebexperts_Payperrentals_Helper_Date::formatDbDate($isSingle['start_date'], false) . '</span>';
                 }
             }
         } else {
             if ($isSingle['start_date'] != '') {
                 return '<strong>' . Mage::helper('payperrentals')->__('Dates:') . '</strong><span>' . ITwebexperts_Payperrentals_Helper_Date::localiseNonsequentialBuyRequest($isSingle['start_date'], true) . '</span>';
             }
         }
     }
     return '';
 }
예제 #5
0
 public function renderDates($options, $item = null, $product = null, $isCart = false)
 {
     $isSingle = true;
     $nonSequential = 0;
     if ($item && $item->getOrder() && !$isCart) {
         $isSingleBool = ITwebexperts_Payperrentals_Helper_Data::isSingleOrder($item->getOrder());
         $isSingle = $isSingleBool['bool'];
     } else {
         if ($item && $item->getQuote() && !$isCart) {
             $isSingle = false;
         }
     }
     $productId = -1;
     $storeId = 1;
     $qty = 0;
     if (!is_null($item) && !is_null($item->getProductId())) {
         $productId = $item->getProductId();
         $storeId = $item->getStoreId();
         $qty = $item->getQty();
         $product = $item->getProduct();
     } else {
         if (!is_null($product) && is_object($product)) {
             $productId = $product->getId();
         } elseif (isset($options['info_buyRequest']['product'])) {
             $productId = $options['info_buyRequest']['product'];
         }
     }
     $showTime = (bool) Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, 'payperrentals_use_times', $storeId);
     $customerGroup = ITwebexperts_Payperrentals_Helper_Data::getCustomerGroup();
     $source = $this->_getOptionsArray($product, $options);
     $options = array();
     $isBuyout = isset($source['buyout']) ? $source['buyout'] : 'false';
     if ($isBuyout != "false") {
         $options[] = array('label' => $this->__('Product Type'), 'value' => 'Rental Buyout', 'type' => 'reservation');
     } else {
         if (isset($source[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION]) && $source[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION] != '') {
             $startDate = ITwebexperts_Payperrentals_Helper_Date::formatDbDate($source[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION], !$showTime, false);
             $endDate = ITwebexperts_Payperrentals_Helper_Date::formatDbDate($source[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION], !$showTime, false);
             if (!isset($nonSequential) || $nonSequential == 0) {
                 $endDate = ITwebexperts_Payperrentals_Helper_Date::formatDbDate($source[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::END_DATE_OPTION], !$showTime, false);
                 if (isset($source[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::FIXED_DATE_ID])) {
                     $fixedRentalDatesCollection = Mage::getModel('payperrentals/fixedrentaldates')->getCollection()->addFieldToFilter('id', $source[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::FIXED_DATE_ID])->getFirstItem();
                     $fixedNameId = $fixedRentalDatesCollection->getNameid();
                     $fixedStartDate = $fixedRentalDatesCollection->getStartDate();
                     $fixedEndDate = $fixedRentalDatesCollection->getEndDate();
                     $difference = strtotime($fixedEndDate) - strtotime($fixedStartDate);
                     $startDate = date('Y-m-d', strtotime($startDate)) . ' ' . date('H:i:s', strtotime($fixedStartDate));
                     $endDate = date('Y-m-d H:i:s', strtotime($startDate) + $difference);
                     $fixedRentalNamesCollection = Mage::getModel('payperrentals/fixedrentalnames')->getCollection()->addFieldToFilter('id', $fixedNameId)->getFirstItem();
                     $fixedName = $fixedRentalNamesCollection->getName();
                     $options[] = array('label' => $this->__('Start Date'), 'value' => ITwebexperts_Payperrentals_Helper_Date::formatDbDate($startDate, !$showTime, false), 'type' => 'reservation');
                     $options[] = array('label' => $this->__('End Date'), 'value' => ITwebexperts_Payperrentals_Helper_Date::formatDbDate($endDate, !$showTime, false), 'type' => 'reservation');
                     //$options[] = array('label' => $this->__('Fixed Date'), 'value' => $fixedName, 'type' => 'reservation');
                 } else {
                     $options[] = array('label' => $this->__('Start Date'), 'value' => $startDate, 'type' => 'reservation');
                     $options[] = array('label' => $this->__('End Date'), 'value' => $endDate, 'type' => 'reservation');
                 }
             } else {
                 $options[] = array('label' => $this->__('Dates:'), 'value' => ITwebexperts_Payperrentals_Helper_Date::localiseNonsequentialBuyRequest($startDate, $showTime), 'type' => 'reservation');
             }
             if (!$isCart && $isSingle) {
                 $options = array();
             }
             $damageWaiver = ITwebexperts_Payperrentals_Helper_Price::getDamageWaiver($productId, 1);
             if ($damageWaiver) {
                 $options[] = array('label' => $this->__('Damage Waiver'), 'value' => ITwebexperts_Payperrentals_Helper_Price::getDamageWaiverHtml($item, (bool) $item->getBuyRequest()->getDamageWaiver(), $qty), 'type' => 'reservation');
             }
         } else {
             return array();
         }
     }
     $resultObject = new Varien_Object();
     $resultObject->setResult($options);
     Mage::dispatchEvent('render_cart', array('options' => $source, 'result' => $resultObject, 'product' => $product, 'item' => $item, 'is_cart' => $isCart));
     return $resultObject->getResult();
 }