Exemplo n.º 1
0
 protected function _getDamageWaiverHtml($damageWaiver)
 {
     return ITwebexperts_Payperrentals_Helper_Price::getDamageWaiverHtml($this->getItem(), (bool) $this->getItem()->getBuyRequest()->getDamageWaiver(), false);
 }
Exemplo n.º 2
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();
 }