Esempio n. 1
0
 /**
  * Renders grid column
  *
  * @param   Varien_Object $row
  * @return  string
  */
 public function render(Varien_Object $_row)
 {
     if (ITwebexperts_Payperrentals_Helper_Data::isReservationType($_row->getId())) {
         $data = intval(ITwebexperts_Payperrentals_Helper_Data::getAttributeCodeForId($_row->getId(), 'payperrentals_quantity'));
     } else {
         $data = intval($_row->getQty());
     }
     return $data;
 }
Esempio n. 2
0
 /**
  * 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;
 }
Esempio n. 3
0
 /**
  * Render minimal price for downloadable products
  *
  * @param   Varien_Object $row
  * @return  string
  */
 public function render(Varien_Object $row)
 {
     $_product = Mage::getModel('catalog/product')->load($row->getData($this->getColumn()->getIndex()));
     $qtyStock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty();
     if (ITwebexperts_Payperrentals_Helper_Data::isReservationType($_product)) {
         $html = '<span class="currentstock">' . Mage::helper('payperrentals')->__('') . '</span>';
     } else {
         $html = '<span class="currentstock">' . intval($qtyStock) . '</span>';
     }
     $html .= '<script type="text/javascript">if (typeof(onLoadActions) == "function") onLoadActions();</script>';
     return $html;
 }
Esempio n. 4
0
 public function getPriceBundle()
 {
     $product = $this->getProduct();
     $htmlOutput = '';
     if (ITwebexperts_Payperrentals_Helper_Data::isReservationType($product)) {
         $bundlePriceType = ITwebexperts_Payperrentals_Helper_Data::getAttributeCodeForId($product->getId(), 'bundle_pricingtype');
         if ($bundlePriceType == ITwebexperts_Payperrentals_Model_Product_Bundlepricingtype::PRICING_BUNDLE_FORALL) {
             $htmlOutput = ITwebexperts_Payperrentals_Helper_Price::getPriceListHtml($product, Mage::getStoreConfig(ITwebexperts_Payperrentals_Helper_Config::XML_PATH_PRICING_ON_LISTING));
         } else {
             $htmlOutput = '';
         }
         $htmlOutput .= '<input type="hidden" class="ppr_attr_butname" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . Mage::helper('payperrentals')->__('Rent') . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" />';
     }
     return $htmlOutput;
 }
Esempio n. 5
0
 /**
  * Function to get maximum quantity available for specific start and end dates.
  * This function first gets max available inventory for a product, then reduces it
  * via the number reserved in the inventory_serialized EAV field for that time period.
  * It then returns the inventory for when the least amount of inventory is available.
  *
  * @param Mage_Catalog_Product|int $product
  * @param                          $startDate
  * @param                          $endDate
  *
  * @return int
  */
 public static function getQuantity($product, $startDate = null, $endDate = null, $options = null, $forceReal = false)
 {
     $productId = $product;
     if (is_object($product)) {
         $productId = $product->getId();
     }
     if (!is_object($product)) {
         $product = ITwebexperts_Payperrentals_Helper_Data::initProduct($product);
     }
     $isReservation = ITwebexperts_Payperrentals_Helper_Data::isReservationType($productId);
     $maxQty = 0;
     if (!$isReservation) {
         if (!is_object($product)) {
             $product = ITwebexperts_Payperrentals_Helper_Data::initProduct($product);
         }
         $maxQty = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty();
     }
     if ($isReservation && ITwebexperts_Payperrentals_Helper_Data::isReservationOnly($productId)) {
         $payperrentalsUseSerials = ITwebexperts_Payperrentals_Helper_Data::getAttributeCodeForId($productId, 'payperrentals_use_serials');
         $payperrentalsQuantity = ITwebexperts_Payperrentals_Helper_Data::getAttributeCodeForId($productId, 'payperrentals_quantity');
         if (!$payperrentalsQuantity) {
             $payperrentalsQuantity = 0;
         }
         if ($payperrentalsUseSerials == ITwebexperts_Payperrentals_Model_Product_Useserials::STATUS_ENABLED) {
             $serialCollection = Mage::getModel('payperrentals/serialnumbers')->getCollection()->addEntityIdFilter($productId)->addSelectFilter("status <> 'B' AND status <> 'M'");
             $maxQty = $serialCollection->getSize();
         } else {
             $maxQty = $payperrentalsQuantity;
         }
         if (!is_null($startDate) && !is_null($endDate)) {
             //should add turnover times to start end date
             $bookedArray = self::getBookedQtyForProducts($productId, $startDate, $endDate, false, isset($options['excluded_qty']) ? $options['excluded_qty'] : null);
             $maxQtyReserved = 1000000;
             if (isset($bookedArray[$productId])) {
                 foreach ($bookedArray[$productId] as $dateFormatted => $vObject) {
                     if (date('H:i', strtotime($dateFormatted)) == '00:00') {
                         $timeStart = strtotime($dateFormatted);
                         $timeEnd = strtotime($dateFormatted) + 86340;
                     } else {
                         $timeStart = strtotime($dateFormatted);
                         $timeEnd = strtotime($dateFormatted) + 3600;
                     }
                     if ($timeStart <= strtotime($endDate) && $timeEnd >= strtotime($startDate)) {
                         if ($maxQtyReserved > $maxQty - $vObject->getQty()) {
                             $maxQtyReserved = $maxQty - $vObject->getQty();
                         }
                     }
                 }
                 if ($maxQtyReserved == 1000000) {
                     $maxQtyReserved = $maxQty;
                 }
                 $maxQty = $maxQtyReserved;
             }
         }
     } elseif (!is_null($options)) {
         $maxQty = self::getQuantityForAnyProductTypeFromOptions($productId, $startDate, $endDate, $options, $forceReal);
     }
     $resultObject = new Varien_Object();
     $resultObject->setRetQty($maxQty);
     Mage::dispatchEvent('after_getquantity', array('product' => $productId, 'result' => $resultObject, 'start_date' => $startDate, 'end_date' => $endDate));
     return intval($resultObject->getRetQty());
 }
Esempio n. 6
0
 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;
 }