/** * Renders grid column * * @param Varien_Object $row * @return string */ public function render(Varien_Object $_row) { if (ITwebexperts_Payperrentals_Helper_Data::isReservationType($_row->getId())) { $dates = Mage::helper('payperrentals/timebox')->getProductGridDates(); $data = intval(ITwebexperts_Payperrentals_Helper_Inventory::getQuantity($_row->getId(), $dates['start_date'], $dates['end_date'])); } else { $data = 0; } return $data; }
public function getProductPrices($sourceOrder) { $output = array(); $resOrders = Mage::getModel('payperrentals/reservationorders')->getCollection()->addOrderIdFilter($sourceOrder->getId()); $hasReservations = $resOrders->getSize() > 0 ? true : false; $orderItems = $sourceOrder->getAllItems(); foreach ($orderItems as $item) { $originalStartDate = $item->getBuyRequest()->getStartDate(); $originalEndDate = $item->getBuyRequest()->getEndDate(); $stockAvail = ITwebexperts_Payperrentals_Helper_Inventory::getQuantity($item->getProduct()->getId(), $originalStartDate, $originalEndDate, ITwebexperts_Payperrentals_Helper_Data::objectToArray($item->getBuyRequest())); if ($stockAvail == '10000000') { $output[$item->getId()] = array('avail' => '', 'remaining' => ''); } else { $output[$item->getId()] = array('avail' => $stockAvail + ($hasReservations ? $item->getBuyRequest()->getQty() : 0), 'remaining' => $stockAvail); } } return $output; }
protected function _prepareForm() { $data = null; $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))), 'method' => 'post', 'enctype' => 'multipart/form-data')); $form->setUseContainer(true); $this->setForm($form); if (Mage::getSingleton('adminhtml/session')->getFormData()) { $data = Mage::getSingleton('adminhtml/session')->getFormData(); Mage::getSingleton('adminhtml/session')->setFormData(null); } elseif (Mage::registry('registry_data')) { $data = Mage::registry('registry_data')->getData(); } $fieldset = $form->addFieldset('registry_form', array('legend' => Mage::helper('payperrentals')->__('Reservation Information'))); $productsInOrder = null !== Mage::registry('productsInOrder') ? Mage::registry('productsInOrder') : 1; $dateFormatIso = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT); $prodCollection = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('name')->addAttributeToFilter('type_id', array('eq' => 'reservation')); if (Mage::helper('itwebcommon')->isVendorAdmin()) { $prodCollection->addAttributeToFilter('vendor_id', array('eq' => Mage::getSingleton('vendors/session')->getId())); } /** * Setup product names array */ $prodArray = array('-1' => 'Please Select'); foreach ($prodCollection as $productItem) { $prodArray[$productItem->getId()] = $productItem->getName() . ' - ' . $productItem->getSku(); } asort($prodArray); $valueData = array(); $fieldset->addField('pricenote', 'note', array('text' => Mage::helper('payperrentals')->__('** Note: Editing rental dates here will not change the order price. '), 'class' => 'notedates')); if ($productsInOrder > 1) { $fieldset->addField('note2', 'note', array('text' => Mage::helper('payperrentals')->__('To globally update rental dates, use the global start and end date and click Update All Dates'))); $fieldset->addField('global_start_date', 'text', array('label' => Mage::helper('payperrentals')->__('Global Start Date'), 'name' => 'global_start_date')); $fieldset->addField('global_end_date', 'text', array('label' => Mage::helper('payperrentals')->__('Global End Date'), 'name' => 'global_end_date')); } for ($i = 0; $i < $productsInOrder; $i++) { /** * Custom code to be used for $form->setValues as an array from $data * $valueData['data_key' . $index] = value */ if (isset($data[$i]) && is_array($data[$i])) { $valArr = $data[$i]; } else { $valArr = $data; } foreach ($valArr as $datakey => $dataitem) { $valueData[$datakey . $i] = $dataitem; } // for showing heading above each product if (isset($data[$i]['product_id'])) { $productid = $data[$i]['product_id']; $productName = Mage::getModel('catalog/product')->load($data[$i]['product_id'])->getName(); } else { $productName = "New Reservation"; } if (isset($data['product_id'])) { $productid = $data['product_id']; $productName = Mage::getModel('catalog/product')->load($data['product_id'])->getName(); } $fieldset->addField('noteproduct' . $i, 'note', array('text' => "<b>" . Mage::helper('payperrentals')->__('Product: ') . $productName . "</b>")); $fieldset->addField('id' . $i, 'hidden', array('readonly' => true, 'name' => 'entity_id' . $i)); /** used for inventory calculation to know if we should add original reserved quantiy * to returned quantity in ajax controller getquantity */ $valueData['originalprodid' . $i] = $productid; $valueData['originalstart_date' . $i] = $valueData['start_date' . $i]; $valueData['originalend_date' . $i] = $valueData['end_date' . $i]; $fieldset->addField('originalprodid' . $i, 'hidden', array('readonly' => true, 'name' => 'originalprodid' . $i)); $fieldset->addField('originalstart_date' . $i, 'hidden', array('name' => 'originalstart_date' . $i)); $fieldset->addField('originalend_date' . $i, 'hidden', array('name' => 'originalend_date' . $i)); $fieldset->addField('start_date' . $i, 'text', array('label' => Mage::helper('payperrentals')->__('Start Date'), 'class' => 'required-entry startdate', 'name' => 'start_date' . $i, 'title' => $i)); $fieldset->addField('end_date' . $i, 'text', array('label' => Mage::helper('payperrentals')->__('End Date'), 'class' => 'required-entry enddate', 'required' => 'true', 'name' => 'end_date' . $i, 'title' => $i)); $fieldset->addField('qty' . $i, 'text', array('label' => Mage::helper('payperrentals')->__('Qty'), 'class' => 'required-entry qty', 'required' => 'true', 'style' => 'width:40px', 'name' => 'qty' . $i, 'title' => $i)); /** * Used to hold returned available quantity for start/end dates * manually set value since it is not in $data. Add to the available quantity * the already reserved quantity for this record. */ if (isset($data[$i]['product_id'])) { $valueData['available_qty' . $i] = ITwebexperts_Payperrentals_Helper_Inventory::getQuantity($data[$i]['product_id'], $data[$i]['start_date'], $data[$i]['end_date']) + $data[$i]['qty']; } if (isset($data['product_id'])) { $valueData['available_qty' . $i] = ITwebexperts_Payperrentals_Helper_Inventory::getQuantity($data['product_id'], $data['start_date'], $data['end_date']) + $data['qty']; } if (isset($data[$i]['product_id']) || isset($data['product_id'])) { $fieldset->addField('available_qty' . $i, 'hidden', array('name' => 'available_qty' . $i)); if (isset($data[$i]['product_id'])) { $valueData['original_qty' . $i] = $data[$i]['qty']; } if (isset($data['product_id'])) { $valueData['original_qty' . $i] = $data['qty']; } $fieldset->addField('original_qty' . $i, 'hidden', array('name' => 'original_qty' . $i)); } $fieldset->addField('product_id' . $i, 'select', array('label' => Mage::helper('payperrentals')->__('Product - Sku'), 'class' => 'required-entry productdrop', 'required' => 'true', 'name' => 'product_id' . $i, 'values' => $prodArray, 'value' => 'product_id', 'title' => $i)); $fieldset->addField('comments' . $i, 'text', array('label' => Mage::helper('payperrentals')->__('Comments'), 'required' => false, 'name' => 'comments' . $i)); $fieldset->addField('order_id' . $i, 'text', array('label' => Mage::helper('payperrentals')->__('Order Id'), 'required' => false, 'readonly' => true, 'style' => 'width:40px', 'name' => 'order_id' . $i)); $fieldset->addField('order_item_id' . $i, 'hidden', array('readonly' => true, 'name' => 'order_item_id' . $i)); } $fieldset->addField('number_of_products', 'hidden', array('readonly' => true, 'name' => 'number_of_products')); $valueData['number_of_products'] = $productsInOrder; $form->setValues($valueData); return parent::_prepareForm(); }
/** * override for changing the current stock qty based on the quote_item * (this is a bad design from Magento, checkQuoteItemQty should receive the quoteItem in the original code too) * * @param mixed $qty * @param mixed $summaryQty * @param int $origQty * @param Mage_Sales_Model_Quote_Item $quoteItem * * @return Varien_Object */ public function checkQuoteItemQty($qty, $summaryQty, $origQty = 0, $quoteItem = null, $product = null) { if ($quoteItem && ITwebexperts_Payperrentals_Helper_Data::isReservationOnly($product) && (!$quoteItem->getChildren() || Mage::app()->getStore()->isAdmin())) { $qtyOption = 1; if ($quoteItem->getParentProductQty()) { $qty = $quoteItem->getParentProductQty(); $qtyOption = $quoteItem->getParentProductQtyOption(); } $quoteItemId = $quoteItem->getId(); if ($quoteItem->getParentItem() && $quoteItem->getParentItem()->getProduct()) { if ($quoteItem->getParentItem()->getProduct()->getTypeId() == ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE_BUNDLE) { $quoteItemId = $quoteItem->getParentItem()->getItemId(); } } $turnoverArr = ITwebexperts_Payperrentals_Helper_Data::getTurnoverFromQuoteItemOrBuyRequest($product, $quoteItem); list($startDate, $endDate) = array($turnoverArr['before'], $turnoverArr['after']); $result = new Varien_Object(); $result->setHasError(false); if (!is_numeric($qty)) { $qty = Mage::app()->getLocale()->getNumber($qty); } /** * Check quantity type */ $result->setItemIsQtyDecimal($this->getIsQtyDecimal()); if (!$this->getIsQtyDecimal()) { $result->setHasQtyOptionUpdate(true); $qty = intval($qty); /** * Adding stock data to quote item */ $result->setItemQty($qty); if (!is_numeric($qty)) { $qty = Mage::app()->getLocale()->getNumber($qty); } $origQty = intval($origQty); $result->setOrigQty($origQty); } if ($qty < ITwebexperts_Payperrentals_Helper_Inventory::getMinSaleQuantity($product)) { $result->setHasError(true)->setMessage(Mage::helper('cataloginventory')->__('The minimum quantity allowed for purchase is %s.', ITwebexperts_Payperrentals_Helper_Inventory::getMinSaleQuantity($product)))->setErrorCode('qty_min')->setQuoteMessage(Mage::helper('cataloginventory')->__('Some of the products cannot be ordered in requested quantity.'))->setQuoteMessageIndex('qty'); return $result; } if ($qty > ITwebexperts_Payperrentals_Helper_Inventory::getMaxSaleQuantity($product)) { $result->setHasError(true)->setMessage(Mage::helper('cataloginventory')->__('The maximum quantity allowed for purchase is %s.', ITwebexperts_Payperrentals_Helper_Inventory::getMaxSaleQuantity($product)))->setErrorCode('qty_max')->setQuoteMessage(Mage::helper('cataloginventory')->__('Some of the products cannot be ordered in requested quantity.'))->setQuoteMessageIndex('qty'); return $result; } $result->addData($this->checkQtyIncrements($qty)->getData()); if ($result->getHasError()) { return $result; } $option = $quoteItem->getOptionByCode('info_buyRequest'); $buyRequest = $option ? unserialize($option->getValue()) : null; if (Mage::app()->getStore()->isAdmin() && Mage::getSingleton('adminhtml/session_quote')->getOrderId()) { $editedOrderId = Mage::getSingleton('adminhtml/session_quote')->getOrderId(); $order = Mage::getModel('sales/order')->load($editedOrderId); $buyRequestArray = (array) $buyRequest; foreach ($order->getAllItems() as $oItem) { if ($oItem->getProduct()->getId() != $product->getId()) { continue; } if (is_object($oItem->getOrderItem())) { $item = $oItem->getOrderItem(); } else { $item = $oItem; } if ($item->getParentItem()) { continue; } //check for bundles if (count($item->getChildrenItems()) > 0) { foreach ($item->getChildrenItems() as $child) { $turnoverArr = ITwebexperts_Payperrentals_Helper_Data::getTurnoverFromQuoteItemOrBuyRequest($child->getProductId(), $child); $buyRequestArray['excluded_qty'][] = array('product_id' => $child->getProductId(), 'start_date' => $turnoverArr['before'], 'end_date' => $turnoverArr['after'], 'qty' => $item->getQtyOrdered()); } } else { $turnoverArr = ITwebexperts_Payperrentals_Helper_Data::getTurnoverFromQuoteItemOrBuyRequest($item->getProductId(), $item); $buyRequestArray['excluded_qty'][] = array('product_id' => $item->getProductId(), 'start_date' => $turnoverArr['before'], 'end_date' => $turnoverArr['after'], 'qty' => $item->getQtyOrdered()); } } $buyRequest = new Varien_Object($buyRequestArray); } if (isset($buyRequest['start_date']) && isset($buyRequest['end_date'])) { if (strtotime($buyRequest['start_date']) > strtotime($buyRequest['end_date'])) { $message = Mage::helper('payperrentals')->__('Start Date is bigger then End Date. Please change!'); $result->setHasError(true)->setMessage($message)->setQuoteMessage($message); return $result; } } $isAvailable = false; if (ITwebexperts_Payperrentals_Helper_Inventory::isAllowedOverbook($product->getId())) { $isAvailable = true; } if (ITwebexperts_Payperrentals_Helper_Data::isBuyout($buyRequest)) { if (!$isAvailable) { Mage::register('quote_item_id', $quoteItemId); $maxQty = ITwebexperts_Payperrentals_Helper_Inventory::getQuantity($product, null, null, $buyRequest); Mage::unregister('quote_item_id'); if ($maxQty >= $qty) { $isAvailable = true; } } if ($isAvailable) { return $result; } else { $message = Mage::helper('payperrentals')->__('There is not enough quantity for buy this product'); $result->setHasError(true)->setMessage($message)->setQuoteMessage($message); return $result; } } if (!Mage::app()->getStore()->isAdmin() && !Mage::getSingleton('checkout/session')->getIsExtendedQuote() && isset($buyRequest['start_date']) && isset($buyRequest['end_date']) && ITwebexperts_Payperrentals_Helper_Inventory::isExcludedDay($product->getId(), $buyRequest['start_date'], $buyRequest['end_date'])) { $message = Mage::helper('payperrentals')->__('There are blocked dates or excluded days on your selected dates!'); $result->setHasError(true)->setMessage($message)->setQuoteMessage($message); return $result; } else { if (!$isAvailable && isset($buyRequest['start_date']) && isset($buyRequest['end_date'])) { Mage::register('quote_item_id', $quoteItemId); $maxQty = ITwebexperts_Payperrentals_Helper_Inventory::getQuantity($product, $startDate, $endDate, $buyRequest); Mage::unregister('quote_item_id'); if ($maxQty >= $qty) { $isAvailable = true; } } } if (ITwebexperts_Payperrentals_Helper_Data::isUsingGlobalDatesShoppingCart($product) && !$buyRequest['start_date']) { $message = Mage::helper('payperrentals')->__('Please select Global Dates!'); $result->setHasError(true)->setMessage($message)->setQuoteMessage($message); return $result; } if (!Mage::app()->getStore()->isAdmin() && !ITwebexperts_Payperrentals_Helper_Data::isBuyout($buyRequest) && (isset($buyRequest['start_date']) && strtotime($buyRequest['start_date']) < strtotime(date('Y-m-d')) || isset($buyRequest['end_date']) && strtotime($buyRequest['end_date']) < strtotime(date('Y-m-d')))) { $message = Mage::helper('payperrentals')->__('The selected Dates are in the past. Please select new dates!'); $result->setHasError(true)->setMessage($message)->setQuoteMessage($message); return $result; } if (Mage::app()->getStore()->isAdmin() && ITwebexperts_Payperrentals_Helper_Inventory::isAllowedOverbook($product->getId()) && ITwebexperts_Payperrentals_Helper_Inventory::showAdminOverbookWarning()) { Mage::register('quote_item_id', $quoteItemId); $maxQty = ITwebexperts_Payperrentals_Helper_Inventory::getQuantity($product, $startDate, $endDate, $buyRequest, true); Mage::unregister('quote_item_id'); if ($maxQty < $qty) { $message = Mage::helper('cataloginventory')->__('Product is not available for the selected dates'); $result->setHasError(false)->setMessage($message)->setQuoteMessage($message)->setQuoteMessageIndex('qtyppr'); return $result; } } Mage::dispatchEvent('before_stock_check', array('buyrequest' => $buyRequest, 'isavailable' => &$isAvailable)); if (!$isAvailable) { if (isset($buyRequest['start_date']) && isset($buyRequest['end_date'])) { //Mage::register('no_quote', 1); Mage::register('quote_item_id', $quoteItemId); $maxQty = ITwebexperts_Payperrentals_Helper_Inventory::getQuantity($product, $startDate, $endDate, $buyRequest); Mage::unregister('quote_item_id'); $maxQty = intval($maxQty / $qtyOption); //Mage::unregister('no_quote', 1); if ($maxQty > 0) { $message = Mage::helper('payperrentals')->__('Max quantity available for these dates is: ' . $maxQty . ', your quantity has been adjusted.'); // Mage::getSingleton('checkout/session')->addError($message); $result->setHasQtyOptionUpdate(true); //$result->setOrigQty($maxQty); $result->setQty($maxQty); $result->setItemQty($maxQty); $result->setMessage($message)->setQuoteMessage($message); return $result; } $message = Mage::helper('cataloginventory')->__('The requested quantity for "%s" is not available.', $this->getProductName()); } else { $message = Mage::helper('cataloginventory')->__('Please select Start and End Dates'); } $result->setHasError(true)->setMessage($message)->setQuoteMessage($message)->setQuoteMessageIndex('qtyppr'); return $result; } return $result; } $return = parent::checkQuoteItemQty($qty, $summaryQty, $origQty); return $return; }
/** * Returns the array of booked days, for the quantity and selected dates * * @return array */ public function updateBookedForProductAction() { if (!$this->getRequest()->getParam('product_id')) { $bookedHtml = array('bookedDates' => '', 'fixedRentalDates' => '', 'isDisabled' => true, 'isShoppingCartDates' => ITwebexperts_Payperrentals_Helper_Data::isUsingGlobalDatesShoppingCart() ? true : false, 'partiallyBooked' => ''); $this->getResponse()->setBody(Zend_Json::encode($bookedHtml)); return; } $product = ITwebexperts_Payperrentals_Helper_Data::initProduct($this->getRequest()->getParam('product_id')); //todo might not be necessary $qty = $this->getRequest()->getParam('qty') ? $this->getRequest()->getParam('qty') : 1; $normalPrice = ''; $needsConfigure = false; $isConfigurable = false; $isDisabled = false; $attributes = $this->getRequest()->getParam('super_attribute') ? $this->getRequest()->getParam('super_attribute') : null; $bundleOptions = $this->getRequest()->getParam('bundle_option') ? $this->getRequest()->getParam('bundle_option') : null; $bundleOptionsQty1 = $this->getRequest()->getParam('bundle_option_qty1') ? $this->getRequest()->getParam('bundle_option_qty1') : null; $bundleOptionsQty = $this->getRequest()->getParam('bundle_option_qty') ? $this->getRequest()->getParam('bundle_option_qty') : null; $qtyArr = ITwebexperts_Payperrentals_Helper_Inventory::getQuantityArrayForProduct($product, 1, $attributes, $bundleOptions, $bundleOptionsQty1, $bundleOptionsQty, true); $maxQtyArr = array(); $bookedDates = array(); $partiallyBookedDates = array(); $turnoverTimeBefore = 0; $turnoverTimeAfter = 0; $maxQtyForParentProduct = 10000; /** * We get the maximum qty available at this moment for every associated product */ foreach ($qtyArr as $iProduct => $iQty) { if (ITwebexperts_Payperrentals_Helper_Inventory::isAllowedOverbook($iProduct)) { $maxQtyForChildProduct = 100000; } else { $maxQtyForChildProduct = ITwebexperts_Payperrentals_Helper_Inventory::getQuantity($iProduct); } $qtyForParentProduct = intval($maxQtyForChildProduct / $iQty); $maxQtyArr[$iProduct] = $maxQtyForChildProduct; if ($maxQtyForParentProduct > $qtyForParentProduct) { $maxQtyForParentProduct = $qtyForParentProduct; } if ($maxQtyForChildProduct < $iQty * $qty) { $isDisabled = true; break; } } if (!$isDisabled) { $resProductArrIds = ITwebexperts_Payperrentals_Helper_Inventory::getReservationProductsArrayIds($product->getId(), $attributes, $bundleOptions); $turnoverArr = ITwebexperts_Payperrentals_Helper_Data::getTurnoverFromQuoteItemOrBuyRequest($product->getId(), null, null, null, 'days'); $turnoverTimeBefore = $turnoverArr['before']; $turnoverTimeAfter = $turnoverArr['after']; foreach ($resProductArrIds as $resProductId) { $booked = ITwebexperts_Payperrentals_Helper_Inventory::getBookedQtyForProducts($resProductId); //Normally if shipping method with turnovers is used global turnovers should be null if ($turnoverTimeAfter == 0 && $turnoverTimeBefore == 0) { $turnoverArr = ITwebexperts_Payperrentals_Helper_Data::getTurnoverFromQuoteItemOrBuyRequest($resProductId, null, null, null, 'days'); $turnoverTimeBefore = $turnoverArr['before']; $turnoverTimeAfter = $turnoverArr['after']; } /** * We go product by product(in the associated products) and date by date and subtract from * this moment qty the booked qty for that date This is how calendar is created. */ if (isset($booked[$resProductId])) { foreach ($booked[$resProductId] as $dateFormatted => $vObject) { $qtyAvailForProduct = intval(($maxQtyArr[$resProductId] - $vObject->getQty()) / $qtyArr[$resProductId]); $isPartial = false; if (date('H:i', strtotime($dateFormatted)) != '00:00') { if (!isset($partiallyBookedDates[$dateFormatted . ':00'])) { $partiallyBookedDates[$dateFormatted . ':00'] = $qtyAvailForProduct; } else { $partiallyBookedDates[$dateFormatted . ':00'] = min($qtyAvailForProduct, $partiallyBookedDates[$dateFormatted . ':00']); } $isPartial = true; } if (!$isPartial) { if (!isset($bookedDates[$dateFormatted])) { $bookedDates[$dateFormatted] = $qtyAvailForProduct; } else { $bookedDates[$dateFormatted] = min($bookedDates[$dateFormatted], $qtyAvailForProduct); } } } } } $bookedDates = ITwebexperts_Payperrentals_Helper_Data::toFormattedBookedArray($bookedDates, false); } $typeId = ITwebexperts_Payperrentals_Helper_Data::getAttributeCodeForId($product->getId(), 'type_id'); if ($typeId == ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE_CONFIGURABLE) { reset($qtyArr); $normalPrice = ITwebexperts_Payperrentals_Helper_Price::getPriceListHtml(key($qtyArr)); $isConfigurable = true; $blockedDates = ITwebexperts_Payperrentals_Helper_Data::getDisabledDates(key($qtyArr)); $fixedRentalDates = ITwebexperts_Payperrentals_Helper_Data::getFixedRentalDates(key($qtyArr)); } else { $blockedDates = ITwebexperts_Payperrentals_Helper_Data::getDisabledDates($product->getId()); $fixedRentalDates = ITwebexperts_Payperrentals_Helper_Data::getFixedRentalDates($product->getId()); } $blockedDates = ITwebexperts_Payperrentals_Helper_Data::toFormattedDateArray($blockedDates, false); $fixedRentalDates = ITwebexperts_Payperrentals_Helper_Data::toFormattedArraysOfDatesArray($fixedRentalDates, false); $bookedHtml = array('bookedDates' => $bookedDates, 'fixedRentalDates' => $fixedRentalDates, 'isDisabled' => $isDisabled, 'blockedDates' => implode(',', $blockedDates), 'isShoppingCartDates' => ITwebexperts_Payperrentals_Helper_Data::isUsingGlobalDatesShoppingCart() ? true : false, 'isConfigurable' => $isConfigurable, 'needsConfigure' => $needsConfigure, 'normalPrice' => $normalPrice, 'partiallyBooked' => $partiallyBookedDates); $bookedHtml['turnoverTimeBefore'] = $turnoverTimeBefore; $bookedHtml['turnoverTimeAfter'] = $turnoverTimeAfter; $bookedHtml['maxQty'] = $maxQtyForParentProduct; $disabledDaysStart = ITwebexperts_Payperrentals_Helper_Data::getDisabledDaysStart(); $disabledDaysEnd = ITwebexperts_Payperrentals_Helper_Data::getDisabledDaysEnd(); if (count($disabledDaysStart) > 0) { $bookedHtml['disabledForStartRange'] = $disabledDaysStart; } if (count($disabledDaysEnd) > 0) { $bookedHtml['disabledForEndRange'] = $disabledDaysEnd; } if (Mage::helper('payperrentals/config')->getFutureReservationLimit($product) > 0) { $bookedHtml['futureDate'] = date('Y-m-d', time() + Mage::helper('payperrentals/config')->getFutureReservationLimit($product) * 3600 * 24); } Mage::dispatchEvent('ppr_get_booked_html_for_products', array('request_params' => $this->getRequest()->getParams(), 'booked_html' => &$bookedHtml, 'product' => $product)); $this->getResponse()->setBody(Zend_Json::encode($bookedHtml)); }
/** * Check reserve inventory for send/return date * * @param string $_testId * @param int $product_id * @param int $reserve4send_return * @param datetime $start_date * @param datetime $end_date * @test * @loadFixture * @loadExpectation * @dataProvider dataProvider */ public function reserveSendReturn($_testId, $product_id, $reserve4send_return, $start_date, $end_date) { Mage::getConfig()->saveConfig(ITwebexperts_Payperrentals_Helper_Config::XML_PATH_USE_RESERVE_INVENTORY_SEND_RETURN, $reserve4send_return); Mage::getConfig()->reinit(); Mage::app()->reinitStores(); $availableQty = ITwebexperts_Payperrentals_Helper_Inventory::getQuantity($product_id, $start_date, $end_date); $_expected = $this->expected('testId' . $_testId); $this->assertEquals($_expected->getQty(), $availableQty); }