public static function showGridColumns($_item) { $return = ''; $nonSequential = Mage::helper('payperrentals/config')->isNonSequentialSelect(Mage::app()->getStore()->getId()); if (ITwebexperts_Payperrentals_Helper_Data::isReservationType($_item->getProductId())) { if ($_item->getProductType() == ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE || $_item->getProductType() == ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE_CONFIGURABLE || $_item->getProductType() == ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE_BUNDLE) { $buyRequest = $_item->getBuyRequest(); $_showTime = (bool) Mage::getResourceModel('catalog/product')->getAttributeRawValue($_item->getProductId(), 'payperrentals_use_times', $_item->getStoreId()); if ($nonSequential) { $stDate = ITwebexperts_Payperrentals_Helper_Date::localiseNonsequentialBuyRequest($buyRequest->getStartDate(), $_showTime); } else { if ($buyRequest->getStartTime()) { $buyStartDate = str_replace('00:00:00', $buyRequest->getStartTime(), $buyRequest->getStartDate()); $buyEndDate = str_replace('23:59:59', $buyRequest->getEndTime(), $buyRequest->getEndDate()); } else { $buyStartDate = $buyRequest->getStartDate(); $buyEndDate = $buyRequest->getEndDate(); } $stDate = ITwebexperts_Payperrentals_Helper_Date::formatDbDate($buyStartDate, !$_showTime); $enDate = ITwebexperts_Payperrentals_Helper_Date::formatDbDate($buyEndDate, !$_showTime); } if ($nonSequential) { $return .= '<td class="">' . $stDate . '</td>'; } else { $return .= '<td class="">' . $stDate . '</td>'; $return .= '<td class="">' . $enDate . '</td>'; } $resultObject = new Varien_Object(); //$resultObject->setReturn($return); Mage::dispatchEvent('options_grid', array('item' => $_item, 'result' => $resultObject)); $return .= $resultObject->getReturn(); } } else { if ($nonSequential) { $return .= '<td class="">' . '' . '</td>'; } else { $return .= '<td class="">' . '' . '</td>'; $return .= '<td class="">' . '' . '</td>'; } } return $return; }
public static function getAdminDamageWaiverHtml($item, $productId) { $html = '<div>'; $startDate = Mage::getSingleton('core/session')->getData('startDateInitial'); $endDate = Mage::getSingleton('core/session')->getData('endDateInitial'); $damageWaiverSelected = false; if (isset($item) && $item != -1 && Mage::app()->getRequest()->getActionName() != 'configureProductToAdd') { $buyRequest = $item->getBuyRequest(); if ($buyRequest->getDamageWaiver() != '' && $buyRequest->getDamageWaiver() == '1') { $damageWaiverSelected = true; } $_showTime = (bool) Mage::getResourceModel('catalog/product')->getAttributeRawValue($item->getProductId(), 'payperrentals_use_times', $item->getStoreId()); if (!Mage::helper('payperrentals/config')->isNonSequentialSelect(Mage::app()->getStore()->getId())) { $startDate = $buyRequest->getStartDate() != '' ? $buyRequest->getStartDate() : ($startDate ? $startDate : false); $endDate = $buyRequest->getEndDate() != '' ? $buyRequest->getEndDate() : ($endDate ? $endDate : false); } else { $startDate = $buyRequest->getStartDate() != '' ? ITwebexperts_Payperrentals_Helper_Date::localiseNonsequentialBuyRequest($buyRequest->getStartDate(), $_showTime) : ($startDate ? $startDate : false); $endDate = $buyRequest->getStartDate() != '' ? ITwebexperts_Payperrentals_Helper_Date::localiseNonsequentialBuyRequest($buyRequest->getStartDate(), $_showTime) : ($startDate ? $startDate : false); } } if ($startDate) { list($startDate, $endDate) = ITwebexperts_Payperrentals_Helper_Date::convertDatepickerToDbFormat($startDate, $endDate); $rentalPrice = ITwebexperts_Payperrentals_Helper_Price::calculatePrice($productId, $startDate, $endDate, 1, ITwebexperts_Payperrentals_Helper_Data::getCustomerGroup()); $damageWaiverPrice = self::getDamageWaiver($productId, $rentalPrice); } else { $damageWaiverPrice = self::getDamageWaiver($productId, 0); } if ($damageWaiverPrice) { $html .= '<input type="radio" name="damage_waiver" class="damage-waiver-input" id="damageWaiverNo" value="0" '; if (!$damageWaiverSelected) { $html .= 'checked="checked"'; } $html .= '/>'; $html .= '<label for="damageWaiverNo">' . Mage::helper('payperrentals')->__(' No') . '</label>'; $html .= '</div>'; $html .= '<div>'; $html .= '<input type="radio" name="damage_waiver" class="damage-waiver-input" id="damageWaiverYes" value="1" '; if ($damageWaiverSelected) { $html .= 'checked="checked"'; } $html .= '/>'; $html .= '<label for="damageWaiverYes">' . Mage::helper('payperrentals')->__(' Yes +%s', Mage::helper('checkout')->formatPrice($damageWaiverPrice > -1 ? $damageWaiverPrice : $item->getData(ITwebexperts_Payperrentals_Helper_Price::DAMAGE_WAIVER_OPTION_PRICE), true, true)) . '</label>'; $html .= '</div>'; } return $html; }
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(); }