示例#1
0
 public function render(Varien_Object $row)
 {
     $data = $row->getData($this->getColumn()->getIndex());
     if ($data != '') {
         $data = ITwebexperts_Payperrentals_Helper_Date::formatDbDate($data, false, false);
     } else {
         /** @var $sOrder Mage_Sales_Model_Order */
         $sOrder = Mage::getModel('sales/order')->load($row->getId());
         $items = $sOrder->getItemsCollection();
         /** @var $item Mage_Sales_Model_Order_Item */
         foreach ($items as $item) {
             /** @var $Product Mage_Catalog_model_Product */
             $Product = Mage::getModel('catalog/product')->load($item->getProductId());
             if ($Product->getTypeId() != ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE && $Product->getTypeId() != ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE_CONFIGURABLE) {
                 continue;
             }
             $data1 = $item->getProductOptionByCode('info_buyRequest');
             if ($this->getColumn()->getIndex() == 'start_date') {
                 $data = $data1[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION];
                 break;
             }
             if ($this->getColumn()->getIndex() == 'end_date') {
                 $data = $data1[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::END_DATE_OPTION];
                 break;
             }
         }
     }
     return $data;
 }
示例#2
0
 /**
  * @param Varien_Object $_row
  * @return string
  */
 public function render(Varien_Object $_row)
 {
     $this->setOrder($_row);
     $_shipmentCollectionAll = Mage::getResourceModel('sales/order_shipment_collection')->addFieldToFilter('order_id', array('eq' => $_row->getEntityId()));
     $_shipmentCollection = Mage::getResourceModel('payperrentals/sendreturn_collection')->addFieldToFilter('order_id', array('in' => array($_row->getEntityId(), $_row->getIncrementId())));
     $_totalQtyShipped = 0;
     $_shippedDate = '';
     $_shippedUnixtimeDate = 0;
     foreach ($_shipmentCollection as $_shipmentItem) {
         if ($_shipmentItem->getSendDate() != '0000-00-00 00:00:00' && $_shipmentItem->getSendDate() != '1970-01-01 00:00:00') {
             $_totalQtyShipped += $_shipmentItem->getQty();
         }
     }
     $_totalQtyShippedAll = 0;
     foreach ($_shipmentCollectionAll as $_shipmentItem) {
         $_totalQtyShippedAll += $_shipmentItem->getTotalQty();
         if ($_shippedUnixtimeDate < strtotime($_shipmentItem->getCreatedAt())) {
             $_shippedDate = $_shipmentItem->getCreatedAt();
             $_shippedUnixtimeDate = strtotime($_shipmentItem->getCreatedAt());
         }
     }
     Mage::unregister('total_qty_shipped');
     Mage::register('total_qty_shipped', $_totalQtyShipped);
     /*$_totalQtyShipped = $this->_getValue($_row);*/
     $_realOrder = Mage::getModel('sales/order')->load($_row->getId());
     $_totalQtyOrdered = (int) $_realOrder->getTotalQtyOrdered();
     $_shipButtonHtml = $this->_getShipButtonHtml();
     if (!$_totalQtyShippedAll) {
         return Mage::helper('payperrentals')->__('Not Shipped') . '<br/>' . $_shipButtonHtml;
     } elseif ($_totalQtyShippedAll < $_totalQtyOrdered) {
         return Mage::helper('payperrentals')->__('Partially Shipped') . '<br/>' . $_shipButtonHtml;
     } else {
         return ITwebexperts_Payperrentals_Helper_Date::formatDbDate($_shippedDate, true, true);
     }
 }
示例#3
0
 /**
  * Filters only start end date and save them into session if param is true and returns array with start date filtered
  * Function can take as @params any array but will automatically filter start and end dates and return only those
  * @param array $params
  * @param bool $canSave
  * return array
  */
 public static function saveDatesForGlobalUse($params, $canSave = true)
 {
     $newParams = array();
     if (isset($params['start_date'])) {
         if (!isset($params['start_time']) || $params['start_time'] == '00:00:00' || strpos($params['start_date'], ' ') !== false) {
             $newParams['start_date'] = $params['start_date'];
         } else {
             $newParams['start_date'] = $params['start_date'] . ' ' . $params['start_time'];
             //todo needs a check if the separator is always a space
         }
     }
     if (isset($params['end_date'])) {
         if (!isset($params['end_time']) || $params['end_time'] == '00:00:00' || strpos($params['end_date'], ' ') !== false) {
             $newParams['end_date'] = $params['end_date'];
         } else {
             $newParams['end_date'] = $params['end_date'] . ' ' . $params['end_time'];
             //todo needs a check if the separator is always a space
         }
     }
     list($startDate, $endDate) = ITwebexperts_Payperrentals_Helper_Date::convertDatepickerToDbFormat($newParams['start_date'], $newParams['end_date']);
     //if(!$isMultiple){
     //  self::_completeEndDate($params, $endDate);
     //}
     if ($canSave) {
         Mage::getSingleton('core/session')->setData('startDateInitial', $startDate);
         Mage::getSingleton('core/session')->setData('endDateInitial', $endDate);
     }
     return array($startDate, $endDate);
 }
示例#4
0
 public function afterSave($object)
 {
     if (is_object($this->_getProduct())) {
         $stockData = $this->_getProduct()->getStockData();
         $stockData['qty'] = $this->_getProduct()->getPayperrentalsQuantity();
         $stockData['is_in_stock'] = 1;
         $stockData['manage_stock'] = 0;
         $stockData['use_config_manage_stock'] = 0;
         $this->_getProduct()->setStockData($stockData);
         if (Mage::app()->getRequest()->getActionName() == 'duplicate') {
             $this->_getProduct()->setPayperrentalsUseSerials(ITwebexperts_Payperrentals_Model_Product_Useserials::STATUS_DISABLED);
         }
         if ($this->_getProduct()->getPayperrentalsUseSerials() == ITwebexperts_Payperrentals_Model_Product_Useserials::STATUS_ENABLED) {
             $sns = $object->getData($this->getAttribute()->getName());
             if (is_null($sns)) {
                 $sns = Mage::getModel('payperrentals/serialnumbers')->getCollection()->addEntityIdFilter($this->_getProduct()->getId())->getItems();
             }
             //                if ((!is_array($sns) || $this->_getProduct()->getPayperrentalsQuantity() != count($sns))) { //I need to check for broken status
             //                    Mage::getSingleton('adminhtml/session')->setData('ppr', Mage::app()->getRequest()->getParam('product'));
             //                    Mage::throwException('Number of items is different than number of serial numbers!');
             //                    return $this;
             //                }
             Mage::getResourceSingleton('payperrentals/serialnumbers')->deleteByEntityId($object->getId());
             foreach ($sns as $k => $sn) {
                 if (!is_numeric($k)) {
                     continue;
                 }
                 $ex = Mage::getModel('payperrentals/serialnumbers')->setEntityId($this->_getProduct()->getId())->setSn($sn['sn'])->setStatus($sn['status'])->setDateAcquired(ITwebexperts_Payperrentals_Helper_Date::toMysqlDate($sn['dateacquired']), true)->setWarehouseId($sn['warehouseid'])->save();
             }
         }
     }
     return $this;
 }
 public function updateAction()
 {
     $params = ITwebexperts_Payperrentals_Helper_Date::filterDates($this->getRequest()->getParams());
     $startDate = array_key_exists('start_date', $params) ? $params['start_date'] : null;
     $endDate = array_key_exists('end_date', $params) ? $params['end_date'] : null;
     if ($startDate && $endDate) {
         $checkoutSession = Mage::getSingleton('checkout/session');
         try {
             ITwebexperts_Payperrentals_Helper_Data::updateCurrentGlobalDates($startDate, $endDate);
             $checkoutSession->addSuccess($this->__('Global Date was updated'));
         } catch (Mage_Core_Exception $e) {
             if ($checkoutSession->getUseNotice(true)) {
                 $checkoutSession->addNotice(Mage::helper('core')->escapeHtml($e->getMessage()));
             } else {
                 $messages = array_unique(explode("\n", $e->getMessage()));
                 foreach ($messages as $message) {
                     $checkoutSession->addError(Mage::helper('core')->escapeHtml($message));
                 }
             }
         } catch (Exception $e) {
             $checkoutSession->addException($e, $this->__('Cannot add the item to shopping cart.'));
             Mage::logException($e);
         }
     }
     $this->_redirect('checkout/cart');
 }
示例#6
0
 /**
  * get collection of all rentals for start & end date
  *
  * @param $startDate
  * @param $endDate
  */
 public function getCollection($startDate, $endDate, $isByOrder = false)
 {
     $reserveOrderCollection = Mage::getModel('payperrentals/reservationorders')->getCollection();
     if (Mage::helper('itwebcommon')->isVendorAdmin()) {
         $reserveOrderCollection->addFieldToFilter('main_table.vendor_id', array('eq' => Mage::getSingleton('vendors/session')->getId()));
     }
     $reserveOrderCollection->addHavingFilter("main_table.start_turnover_before >= '" . ITwebexperts_Payperrentals_Helper_Date::toDbDate($startDate) . "' AND main_table.end_turnover_after <= '" . ITwebexperts_Payperrentals_Helper_Date::toDbDate($endDate) . "'");
     $reserveOrderCollection->getSelect()->joinLeft(array('soi' => Mage::getConfig()->getTablePrefix() . 'sales_flat_order_item'), 'soi.item_id=order_item_id', array('name'));
     $reserveOrderCollection->getSelect()->joinLeft(array('so' => Mage::getConfig()->getTablePrefix() . 'sales_flat_order'), 'so.entity_id=main_table.order_id', array('customer_firstname', 'customer_lastname', 'increment_id'));
     //        $reserveOrderCollection->getSelect()->join(array('product' => 'catalog_product_flat_1'),'product.entity_id=main_table.product_id','name');
     // $reserveOrderCollection->getSelect()->group('main_table.order_id');
     return $reserveOrderCollection;
 }
示例#7
0
 /**
  * @param Varien_Object $_row
  * @return string
  */
 public function render(Varien_Object $_row)
 {
     $this->setOrder($_row);
     $_returnCollection = Mage::getResourceModel('payperrentals/sendreturn_collection')->addFieldToFilter('order_id', array('in' => array($_row->getEntityId(), $_row->getIncrementId())));
     $_totalQtyReturned = 0;
     $_returnedDate = '';
     $_returnedUnixtimeDate = 0;
     $this->_hasShipmentInDb = false;
     if (count($_returnCollection)) {
         $this->_hasShipmentInDb = true;
     }
     foreach ($_returnCollection as $_returnItem) {
         if ($_returnItem->getReturnDate() != '0000-00-00 00:00:00' && $_returnItem->getReturnDate() != '1970-01-01 00:00:00') {
             $_totalQtyReturned += $_returnItem->getQty();
             if ($_returnedUnixtimeDate < strtotime($_returnItem->getReturnDate())) {
                 $_returnedDate = $_returnItem->getReturnDate();
                 $_returnedUnixtimeDate = strtotime($_returnItem->getReturnDate());
             }
         }
     }
     $callingBlock = $this->getColumn()->getGrid()->getId();
     if ($callingBlock == "sales_returnlate_grid") {
         /* START code below is for when return is used WITHOUT the ship render on late returns page */
         $_shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection')->addFieldToFilter('order_id', array('eq' => $_row->getEntityId()));
         $_totalQtyShipped = 0;
         $_shippedDate = '';
         $_shippedUnixtimeDate = 0;
         foreach ($_shipmentCollection as $_shipmentItem) {
             $_totalQtyShipped += $_shipmentItem->getTotalQty();
             if ($_shippedUnixtimeDate < strtotime($_shipmentItem->getCreatedAt())) {
                 $_shippedDate = $_shipmentItem->getCreatedAt();
                 $_shippedUnixtimeDate = strtotime($_shipmentItem->getCreatedAt());
             }
         }
         Mage::unregister('total_qty_shipped');
         Mage::register('total_qty_shipped', $_totalQtyShipped);
     }
     /* END code below is for when return is used WITHOUT the ship render on late returns page */
     $_totalQtyShipped = Mage::registry('total_qty_shipped') ? Mage::registry('total_qty_shipped') : 0;
     $this->_totalQtyShipped = $_totalQtyShipped;
     $this->_totalQtyReturned = $_totalQtyReturned;
     $_buttonHtml = $this->_getReturnButtonHtml();
     if (!$_totalQtyReturned) {
         return Mage::helper('payperrentals')->__('Not Returned') . '<br/>' . $_buttonHtml;
     } elseif ($_totalQtyReturned < $_totalQtyShipped) {
         return Mage::helper('payperrentals')->__('Partially Returned') . '<br/>' . $_buttonHtml;
     } else {
         return ITwebexperts_Payperrentals_Helper_Date::formatDbDate($_returnedDate, true, true);
     }
 }
 public function indexAction()
 {
     $orderId = $this->getRequest()->getParam('order_id');
     $newDate = ITwebexperts_Payperrentals_Helper_Date::toMysqlDate($this->getRequest()->getParam('new_date'), true);
     /** @var $sourceOrder Mage_Sales_Model_Order */
     $sourceOrder = Mage::getModel('sales/order')->load($orderId);
     $cart = Mage::getModel('checkout/cart');
     $cart->init();
     $cart->truncate();
     $orderItems = $sourceOrder->getAllItems();
     $configHelper = Mage::helper('payperrentals/config');
     foreach ($orderItems as $item) {
         $timeIncrement = $configHelper->getTimeIncrement() * 60;
         if ($item->getParentItem()) {
             continue;
         }
         $originalEndDate = $item->getBuyRequest()->getEndDate();
         //check timeIncrement and check if product has times enabled
         if (ITwebexperts_Payperrentals_Helper_Data::useTimes($item->getProduct()->getId()) == 0) {
             $timeIncrement = 24 * 60 * 60;
         }
         $originalEndDatePlusTimeIncrement = strtotime($originalEndDate) + $timeIncrement;
         $originalEndDatePlusTimeIncrement = date('Y-m-d H:i:s', $originalEndDatePlusTimeIncrement);
         $productOptions = $item->getProductOptions();
         $buyRequestArray = $productOptions['info_buyRequest'];
         $buyRequestArray['start_date'] = $originalEndDatePlusTimeIncrement;
         $buyRequestArray['end_date'] = $newDate;
         $buyRequestArray['is_extended'] = true;
         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' => $productOptions['info_buyRequest']['qty']);
             }
         } 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' => $productOptions['info_buyRequest']['qty']);
         }
         $buyRequest = new Varien_Object($buyRequestArray);
         $product = Mage::getModel('catalog/product')->load($item->getProductId());
         try {
             $cart->addProduct($product, $buyRequest);
         } catch (Exception $e) {
             Mage::getSingleton('core/session')->addError($e->getMessage());
         }
     }
     $cart->save();
     Mage::getSingleton('checkout/session')->setIsExtendedQuote(true);
     Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
     $this->_redirect('checkout/cart');
 }
示例#9
0
 public function render(Varien_Object $row)
 {
     $column = $this->getColumn()->getIndex();
     $data = $row->getData($column);
     if ($data == '0000-00-00 00:00:00' || $data == '1970-01-01 00:00:00' || $data == null) {
         if ($column == 'send_date') {
             $data = "Not Sent";
         } else {
             $data = "Not Returned";
         }
     } else {
         $data = ITwebexperts_Payperrentals_Helper_Date::formatDbDate($data, false, true);
     }
     return $data;
 }
示例#10
0
 public function render(Varien_Object $row)
 {
     $now = date("Y-m-d H:i:s");
     $data = $row->getData($this->getColumn()->getIndex());
     $htmlOut = '';
     $isDate = ITwebexperts_Payperrentals_Helper_Date::isFilteredDate($data);
     if (!$isDate || $isDate && strtotime($data) < strtotime($now)) {
         $button = "<button id=" . $row->getEntityId() . " onclick=\"showLateFeePopup('popup_form_policy',this.id)\")'>Charge Fee</button>";
         $lateFee = ITwebexperts_Payperrentals_Helper_LateFeesandReturns::calculateLateFeePriceForOrder($row->getOrderId(), null, null, $now);
         if ($lateFee > 0) {
             $lateFee = Mage::helper('core')->currency($lateFee);
             $htmlOut = $button . '<br />' . $lateFee;
         } else {
             $htmlOut = '';
         }
     }
     return $htmlOut;
 }
示例#11
0
 /**
  * @param Varien_Object $object
  * @return $this
  */
 public function afterSave($object)
 {
     $generalStoreId = $object->getStoreId();
     $periods = $object->getData($this->getAttribute()->getName());
     Mage::getResourceSingleton('payperrentals/excludeddates')->deleteByProductId($object->getId(), $generalStoreId);
     if (is_null($periods)) {
         return $this;
     }
     if (is_array($periods)) {
         foreach ($periods as $k => $period) {
             if (!is_numeric($k)) {
                 continue;
             }
             $storeId = @$period['use_default_value'] ? 0 : $object->getStoreId();
             $ex = Mage::getModel('payperrentals/excludeddates')->setProductId($object->getId())->setStoreId($storeId)->setDisabledFrom(ITwebexperts_Payperrentals_Helper_Date::toMysqlDate($period['excludefrom']))->setDisabledType($period['repeatperiod'])->setExcludeDatesFrom($period['excludedaysfrom'])->setDisabledTo(ITwebexperts_Payperrentals_Helper_Date::toMysqlDate($period['excludeto']))->save();
         }
     }
     return $this;
 }
示例#12
0
 public static function getExtensibleProductsFromOrder($orderId, $date = null)
 {
     $order = Mage::getModel('sales/order')->load($orderId);
     if (!is_null($date)) {
         $date = ITwebexperts_Payperrentals_Helper_Date::toMysqlDate($date, true);
     }
     $productsArr = array();
     foreach ($order->getAllItems() as $_item) {
         if (is_object($_item->getOrderItem())) {
             $item = $_item->getOrderItem();
         } else {
             $item = $_item;
         }
         if ($item->getParentItem()) {
             continue;
         }
         if (is_null($date)) {
             if (Mage::helper('payperrentals/config')->hasExtendEnabled($_item->getId(), $_item->getChildren())) {
                 $productsArr[] = array('name' => $_item->getProduct()->getName(), 'oId' => $_item->getId());
             }
         } else {
             if ($options = $item->getProductOptions()) {
                 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];
                         $diffSeconds = ITwebexperts_Payperrentals_Helper_Date::getDifferenceInSeconds($start_date, $date);
                         $maxLength = Mage::helper('payperrentals/config')->getMaximumExtensionLength();
                         $isExtendEnabled = Mage::helper('payperrentals/config')->hasExtendEnabled($_item->getProduct()->getId());
                         $isAvailable = ITwebexperts_Payperrentals_Helper_Inventory::getQuantityForAnyProductTypeFromOptions($_item->getProduct()->getId(), $end_date, $date, $options['info_buyRequest']) > 0;
                         if ($diffSeconds < $maxLength && strtotime($end_date) < strtotime($date) && $isExtendEnabled && $isAvailable) {
                             $productsArr[] = array('name' => $_item->getProduct()->getName(), 'oId' => $_item->getId());
                         }
                     }
                 }
             }
         }
     }
     return $productsArr;
 }
示例#13
0
 public function addBetweenDatesFilter($start_date)
 {
     $this->getSelect()->where('date(start_date) <= date("' . ITwebexperts_Payperrentals_Helper_Date::toDbDate($start_date) . '")')->where('date(end_date) >= date("' . ITwebexperts_Payperrentals_Helper_Date::toDbDate($start_date) . '")');
     return $this;
 }
示例#14
0
 public function getToSendCollection($startDatefrom, $startDateto, $endDatefrom, $endDateto, $forStore)
 {
     $this->addSelectFilter("start_date >= '" . ITwebexperts_Payperrentals_Helper_Date::toDbDate($startDatefrom) . "' AND start_date <= '" . ITwebexperts_Payperrentals_Helper_Date::toDbDate($startDateto) . "'")->addSelectFilter("end_date >= '" . ITwebexperts_Payperrentals_Helper_Date::toDbDate($endDatefrom) . "' AND end_date <= '" . ITwebexperts_Payperrentals_Helper_Date::toDbDate($endDateto) . "'")->addSelectFilter("main_table.qty >= main_table.qty_shipped")->addSelectFilter("product_type = '" . ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE . "'")->addFieldToFilter('main_table.order_id', array('neq' => 0))->groupByOrderId();
     if ($forStore) {
         $this->getSelect()->joinLeft(array('so' => Mage::getSingleton('core/resource')->getTableName('sales_flat_order')), 'main_table.order_id = ' . 'so.entity_id', array('so.store_id as store_id'));
         $this->getSelect()->where('so.store_id=?', $this->getRequest()->getParam('forStore'));
     }
     //echo $this->getSelect();
     return $this;
 }
示例#15
0
 /**
  * Adds rental start and end dates to custom options
  *
  * @param Varien_Object $buyRequest
  * @param null $product
  * @param null $processMode
  * @param string $productType
  * @return string
  * todo refactor /investigate more to additional_options(how the translations of options would work, might need a lot of effort)
  * this function should check if we are in global dates mode, should get the existing param etc, no need to modify query string on listing.
  * This will allow so adding a product from a different block from listing to work too
  */
 public function prepareForCartAdvanced(Varien_Object $buyRequest, $product = null, $processMode = null, $productType = 'simple')
 {
     if (ITwebexperts_Payperrentals_Helper_Data::isBuyout($buyRequest)) {
         $product->addCustomOption(ITwebexperts_Payperrentals_Model_Product_Type_Reservation::BUYOUT_PRICE_OPTION, true, $product);
         return 'call_parent';
     }
     if (!ITwebexperts_Payperrentals_Helper_Sso::isAllowedRenting()) {
         return Mage::helper('payperrentals')->__('You are not allowed renting. Please login on CNH');
     }
     if ($productType != 'simple' && !ITwebexperts_Payperrentals_Helper_Data::isReservationAndRental($product)) {
         return 'call_parent';
     }
     if ($buyRequest->getIsReservation() == ITwebexperts_Payperrentals_Model_Product_Isreservation::STATUS_RENTAL) {
         return Mage::helper('payperrentals/membership')->addProductToQueue($product, $buyRequest, $productType == 'grouped' ? true : false);
     }
     $msg = $this->_completeBuyRequestObject($buyRequest, $product, $productType);
     if ($msg) {
         return $msg;
     }
     $resultObject = new Varien_Object();
     Mage::dispatchEvent('prepare_advanced_before', array('buy_request' => $buyRequest, 'product_type' => $productType, 'product' => $product, 'result' => $resultObject));
     if ($resultObject->getResult() != '') {
         return $resultObject->getResult();
     }
     $this->_addCustomOptions($product, $buyRequest);
     ITwebexperts_Payperrentals_Helper_Date::saveDatesForGlobalUse((array) $buyRequest);
     return 'call_parent';
 }
示例#16
0
 /**
  * @param bool $isExtended
  */
 private static function getReservationItemsToBeReturnedForCustomerEmail($isExtended = false)
 {
     $reminderPerCustomer = array();
     $startDate = date('Y-m-d', strtotime('-3 day', strtotime(date('Y-m-d'))));
     //$startDate = date('Y-m-d');
     if (!$isExtended) {
         $endDate = date('Y-m-d', strtotime('+' . Mage::getStoreConfig(self::XML_PATH_REMINDER_DAYS) . ' day', strtotime(date('m/d/Y'))));
     } else {
         $endDate = date('Y-m-d', strtotime('+' . Mage::getStoreConfig(self::XML_PATH_EXTENDED_REMINDER_DAYS) . ' day', strtotime(date('m/d/Y'))));
     }
     $collReservationToBeReturned = Mage::getModel('payperrentals/sendreturn')->getCollection()->addSelectFilter("res_enddate >= '" . ITwebexperts_Payperrentals_Helper_Date::toDbDate($startDate) . "' AND res_enddate <= '" . ITwebexperts_Payperrentals_Helper_Date::toDbDate($endDate) . "' AND return_date='0000-00-00 00:00:00'")->groupByOrder();
     $clientListIncoming = '<ul>';
     $listIncoming = '';
     $nrIncoming = 0;
     $usedOrders = array();
     foreach ($collReservationToBeReturned as $item) {
         $order = Mage::getModel('sales/order')->load($item->getOrderId());
         $customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
         if (isset($usedOrders[$customer->getEmail()]) && in_array($item->getOrderId(), $usedOrders[$customer->getEmail()])) {
             continue;
         }
         $orderInfo = '<p>Order Id: ' . $order->getIncrementId() . '</p> <p> - Start Date: ' . $order->getStartDatetime() . '</p> <p> - Return Date: ' . $order->getEndDatetime() . '</p>';
         $clientListIncoming .= '<li>' . $orderInfo . '</li>';
         $nrIncoming++;
         if (!$isExtended) {
             $listIncoming .= '<p><a style="font-size:15px" href="' . Mage::getUrl('sales/order/view', array('order_id' => $order->getId())) . '">' . $orderInfo . '</a></p>';
         } else {
             $listIncoming .= '<p><a style="font-size:15px" href="' . Mage::getUrl('payperrentals_front/customer_extendorder', array('order_id' => $order->getId())) . '">' . $orderInfo . '</a></p>';
         }
         $usedOrders[$customer->getEmail()][] = $item->getOrderId();
     }
     foreach ($usedOrders as $email => $orderIds) {
         foreach ($orderIds as $orderId) {
             $order = Mage::getModel('sales/order')->load($orderId);
             $listIncoming .= '<br/><p style="font-style:italic;color:#cccccc;">' . Mage::helper('payperrentals')->__('Products from order:') . ' ' . $order->getIncrementId() . '</p>';
             foreach ($order->getAllItems() as $orderItem) {
                 if ($orderItem->getParentItem()) {
                     continue;
                 }
                 //$productQty = intval($orderItem->getQtyInvoiced());
                 $productName = $orderItem->getName();
                 $listIncoming .= '<p style="margin-left:20px">' . ' - ' . $productName . '</p>';
             }
         }
         $reminderPerCustomer[$email][] = $listIncoming;
     }
     $clientListIncoming .= '</ul>';
     $emailItems = array('nrIncoming' => $nrIncoming, 'clientListIncoming' => $clientListIncoming, 'listIncoming' => $listIncoming, 'reminderPerCustomer' => $reminderPerCustomer, 'customerName' => $customer->getFirstname() . ' ' . $customer->getLastname(), 'reminderdays' => !$isExtended ? Mage::getStoreConfig(self::XML_PATH_REMINDER_DAYS) : Mage::getStoreConfig(self::XML_PATH_EXTENDED_REMINDER_DAYS));
     if ($nrIncoming > 0) {
         if (!$isExtended) {
             ITwebexperts_Payperrentals_Helper_Emails::sendEmail('return_reminder', $emailItems);
         } else {
             ITwebexperts_Payperrentals_Helper_Emails::sendEmail('extend_reminder', $emailItems);
         }
     }
 }
示例#17
0
 public function indexAction()
 {
     $orderId = $this->getRequest()->getParam('order_id');
     $newDate = ITwebexperts_Payperrentals_Helper_Date::toMysqlDate($this->getRequest()->getParam('new_date'), true);
     /** @var $sourceOrder Mage_Sales_Model_Order */
     $sourceOrder = Mage::getModel('sales/order')->load($orderId);
     /** @var Mage_Adminhtml_Model_Session_Quote $orderSession */
     $orderSession = Mage::getSingleton('adminhtml/session_quote');
     $orderSession->clear();
     $customer = Mage::getModel('customer/customer')->load($sourceOrder->getCustomerId());
     $orderSession->setCustomer($customer);
     $orderSession->setCustomerId($sourceOrder->getCustomerId());
     $orderSession->setStoreId($sourceOrder->getStoreId());
     //$orderSession->setQuoteId($quote->getId());
     /** @var $quote Mage_Sales_Model_Quote */
     $quote = $orderSession->getQuote();
     /** @var $converterOrder Mage_Sales_Model_Convert_Order */
     $converterOrder = Mage::getModel('sales/convert_order');
     $orderShippingAddress = $converterOrder->addressToQuoteAddress($sourceOrder->getShippingAddress());
     $orderBillingAddress = $converterOrder->addressToQuoteAddress($sourceOrder->getBillingAddress());
     // $orderPayment = $converterOrder->paymentToQuotePayment($sourceOrder->getPayment());
     $quote->setShippingAddress($orderShippingAddress);
     $quote->setBillingAddress($orderBillingAddress);
     //$quote->setPayment($orderPayment);
     $orderItems = $sourceOrder->getAllItems();
     $configHelper = Mage::helper('payperrentals/config');
     foreach ($orderItems as $item) {
         $timeIncrement = $configHelper->getTimeIncrement() * 60;
         if ($item->getParentItem()) {
             continue;
         }
         $originalEndDate = $item->getBuyRequest()->getEndDate();
         //check timeIncrement and check if product has times enabled
         if (ITwebexperts_Payperrentals_Helper_Data::useTimes($item->getProduct()->getId()) == 0) {
             $timeIncrement = 24 * 60 * 60;
         }
         $originalEndDatePlusTimeIncrement = strtotime($originalEndDate) + $timeIncrement;
         $originalEndDatePlusTimeIncrement = date('Y-m-d H:i:s', $originalEndDatePlusTimeIncrement);
         $productOptions = $item->getProductOptions();
         $buyRequestArray = $productOptions['info_buyRequest'];
         $buyRequestArray['start_date'] = $originalEndDatePlusTimeIncrement;
         $buyRequestArray['end_date'] = $newDate;
         $buyRequestArray['is_extended'] = true;
         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' => $productOptions['info_buyRequest']['qty']);
             }
         } 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' => $productOptions['info_buyRequest']['qty']);
         }
         $buyRequest = new Varien_Object($buyRequestArray);
         $product = Mage::getModel('catalog/product')->load($item->getProductId());
         $itemNew = $quote->addProduct($product, $buyRequest);
         $itemNew->calcRowTotal();
         $quote->collectTotals();
     }
     $quote->save();
     $orderSession->setIsExtendedQuote(true);
     $this->_redirect('adminhtml/sales_order_create/index');
 }
示例#18
0
 public function getProductGridDates()
 {
     $dates = array();
     $request = base64_decode(Mage::app()->getRequest()->getParam('product_filter'));
     parse_str($request, $request_values);
     if (empty($request_values)) {
         $dates['start_date'] = date('Y-m-d');
     } elseif (!empty($request_values['payperrental_custgrid_startdate'])) {
         $dates['start_date'] = ITwebexperts_Payperrentals_Helper_Date::toMysqlDate($request_values['payperrental_custgrid_startdate'], true);
     } elseif (Mage::getSingleton('core/session')->getProductGridStart()) {
         $dates['start_date'] = Mage::getSingleton('core/session')->getProductGridStart();
     } else {
         $dates['start_date'] = date('Y-m-d');
     }
     Mage::getSingleton('core/session')->setProductGridStart($dates['start_date']);
     if (empty($request_values)) {
         $dates['end_date'] = date('Y-m-d');
     } elseif (!empty($request_values['payperrental_custgrid_enddate'])) {
         $dates['end_date'] = ITwebexperts_Payperrentals_Helper_Date::toMysqlDate($request_values['payperrental_custgrid_enddate'], true);
     } elseif (Mage::getSingleton('core/session')->getProductGridEnd()) {
         $dates['end_date'] = Mage::getSingleton('core/session')->getProductGridEnd();
     } else {
         $dates['end_date'] = date('Y-m-d');
     }
     Mage::getSingleton('core/session')->setProductGridEnd($dates['end_date']);
     return $dates;
 }
示例#19
0
 /**
  * Returns an array of excluded dates (holidays) for a product
  * from either the global or by product setting
  *
  * @param $product
  * @return array
  */
 public static function getDisabledDates($product = null, $isPrice = false)
 {
     if (Mage::app()->getStore()->isAdmin()) {
         return array();
     }
     $collectionExcluded = self::getCollectionExcludedDates($product);
     $blockedDates = array();
     foreach ($collectionExcluded as $item) {
         if ($item->getDisabledFrom() != '' && $item->getDisabledTo() != '') {
             $startDate = ITwebexperts_Payperrentals_Helper_Date::toMysqlDate($item->getDisabledFrom(), true);
             $endDate = ITwebexperts_Payperrentals_Helper_Date::toMysqlDate($item->getDisabledTo(), true);
             $excludeFrom = $item->getExcludeDatesFrom();
             if ($isPrice && $excludeFrom == ITwebexperts_Payperrentals_Model_Source_Excludedaysfrom::CALENDAR) {
                 continue;
             }
             if ($excludeFrom == ITwebexperts_Payperrentals_Model_Source_Excludedaysfrom::CALENDAR || $excludeFrom == ITwebexperts_Payperrentals_Model_Source_Excludedaysfrom::BOTH || $isPrice) {
                 //list($startDate, $endDate) = ITwebexperts_Payperrentals_Helper_Date::convertDatepickerToDbFormat($startDate, $endDate);
                 $startTimePadding = strtotime(date('Y-m-d', strtotime($startDate)));
                 $endTimePadding = strtotime(date('Y-m-d', strtotime($endDate)));
                 while ($startTimePadding <= $endTimePadding) {
                     $dateFormatted = date('Y-m-d', $startTimePadding);
                     $blockedDates[] = $dateFormatted;
                     switch ($item->getDisabledType()) {
                         case 'dayweek':
                             //for this case end_date should be =start_date
                             $currentDayOfWeek = date('l', $startTimePadding);
                             $nrWeeks = ITwebexperts_Payperrentals_Helper_Data::CALCULATE_DAYS_AFTER / 7;
                             $recurringStartDate = $startTimePadding;
                             for ($i = 0; $i < $nrWeeks; $i++) {
                                 $recurringStartDate = strtotime('next ' . $currentDayOfWeek, $recurringStartDate);
                                 $dateFormatted = date('Y-m-d', $recurringStartDate);
                                 $blockedDates[] = $dateFormatted;
                             }
                             break;
                         case 'monthly':
                             $nrMonths = ITwebexperts_Payperrentals_Helper_Data::CALCULATE_DAYS_AFTER / 30;
                             $recurringStartDate = $startTimePadding;
                             for ($i = 0; $i < $nrMonths; $i++) {
                                 $recurringStartDate = strtotime('+1 month', $recurringStartDate);
                                 $dateFormatted = date('Y-m-d', $recurringStartDate);
                                 $blockedDates[] = $dateFormatted;
                             }
                             break;
                         case 'yearly':
                             $nrYears = ITwebexperts_Payperrentals_Helper_Data::CALCULATE_DAYS_AFTER / 360;
                             $recurringStartDate = $startTimePadding;
                             for ($i = 0; $i < $nrYears; $i++) {
                                 $recurringStartDate = strtotime('+1 year', $recurringStartDate);
                                 $dateFormatted = date('Y-m-d', $recurringStartDate);
                                 $blockedDates[] = $dateFormatted;
                             }
                             break;
                     }
                     $startTimePadding += 60 * 60 * 24;
                 }
             }
         }
     }
     return $blockedDates;
 }
示例#20
0
 public function indexAction()
 {
     $orderid = $this->getRequest()->getParam('orderid');
     if ($this->getRequest()->getParam('late_date')) {
         $lateReturnDate = ITwebexperts_Payperrentals_Helper_Date::toMysqlDate($this->getRequest()->getParam('late_date'), true);
     } else {
         $lateReturnDate = date('Y-m-d H:i:s');
     }
     //if($this->getRequest()->getParam('custom_price') && $this->getRequest()->getParam('custom_price') != '') {
     //  $customPrice = $this->getRequest()->getParam('custom_price');
     //}
     /** @var $sourceOrder Mage_Sales_Model_Order */
     $sourceOrder = Mage::getModel('sales/order')->load($orderid);
     /** @var Mage_Adminhtml_Model_Session_Quote $orderSession */
     $orderSession = Mage::getSingleton('adminhtml/session_quote');
     $orderSession->clear();
     $customer = Mage::getModel('customer/customer')->load($sourceOrder->getCustomerId());
     $orderSession->setCustomer($customer);
     $orderSession->setCustomerId($sourceOrder->getCustomerId());
     $orderSession->setStoreId($sourceOrder->getStoreId());
     //$orderSession->setQuoteId($quote->getId());
     /** @var $quote Mage_Sales_Model_Quote */
     $quote = $orderSession->getQuote();
     /** @var $converterOrder Mage_Sales_Model_Convert_Order */
     $converterOrder = Mage::getModel('sales/convert_order');
     /** @var $quote Mage_Sales_Model_Quote */
     //$quoteNew = $converterOrder->toQuote($sourceOrder);
     $orderShippingAddress = $converterOrder->addressToQuoteAddress($sourceOrder->getShippingAddress());
     $orderBillingAddress = $converterOrder->addressToQuoteAddress($sourceOrder->getBillingAddress());
     //$orderPayment = $converterOrder->paymentToQuotePayment($sourceOrder->getPayment());
     $quote->setShippingAddress($orderShippingAddress);
     $quote->setBillingAddress($orderBillingAddress);
     //$quote->setPayment($orderPayment);
     $orderItems = $sourceOrder->getAllItems();
     $configHelper = Mage::helper('payperrentals/config');
     foreach ($orderItems as $item) {
         $timeIncrement = $configHelper->getTimeIncrement() * 60;
         if ($item->getParentItem()) {
             continue;
         }
         $originalEndDate = $item->getBuyRequest()->getEndDate();
         if (strtotime($originalEndDate) > strtotime($lateReturnDate)) {
             continue;
         }
         //check timeIncrement and check if product has times enabled
         $useTimes = ITwebexperts_Payperrentals_Helper_Data::useTimes($item->getProduct()->getId());
         if ($useTimes == 0) {
             $timeIncrement = 24 * 60 * 60;
         }
         $originalEndDatePlusTimeIncrement = strtotime($originalEndDate) + $timeIncrement;
         $originalEndDatePlusTimeIncrement = date('Y-m-d H:i:s', $originalEndDatePlusTimeIncrement);
         $productOptions = $item->getProductOptions();
         $buyRequestArray = $productOptions['info_buyRequest'];
         $buyRequestArray['start_date'] = $originalEndDatePlusTimeIncrement;
         $buyRequestArray['end_date'] = $useTimes == 0 ? date('Y-m-d', strtotime($lateReturnDate)) . ' 00:00:00' : $lateReturnDate;
         $buyRequestArray['is_extended'] = true;
         if (!isset($customPrice)) {
             $lateFee = ITwebexperts_Payperrentals_Helper_LateFeesandReturns::calculateLateFee($item->getProduct(), $item->getQtyOrdered(), $item->getBuyRequest()->getStartDate(), $originalEndDate, $lateReturnDate, $buyRequestArray);
         } else {
             $lateFee = $customPrice;
         }
         $buyRequest = new Varien_Object();
         $buyRequest->setData($buyRequestArray);
         $product = Mage::getModel('catalog/product')->load($item->getProductId());
         $additionalOptions[] = array('label' => 'Type', 'value' => 'Late Fee');
         $product->addCustomOption('additional_options', serialize($additionalOptions));
         $itemNew = $quote->addProduct($product, $buyRequest);
         //$itemNew = $quote->getItembyProduct($product);
         $itemNew->setCustomPrice($lateFee);
         $itemNew->calcRowTotal();
         $quote->collectTotals();
     }
     $quote->save();
     $orderSession->setIsExtendedQuote(true);
     $this->_redirect('adminhtml/sales_order_create/index');
 }
示例#21
0
 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;
 }
示例#22
0
 public function deleteByQuoteItemAndDates(Mage_Sales_Model_Quote_Item $QuoteItem, $start_date, $end_date)
 {
     $condition = "quote_item_id=" . intval($QuoteItem->getId()) . ' AND start_date="' . ITwebexperts_Payperrentals_Helper_Date::toDbDate($start_date) . '" AND end_date="' . ITwebexperts_Payperrentals_Helper_Date::toDbDate($end_date) . '"';
     $this->_getWriteAdapter()->delete($this->getMainTable(), $condition);
     return $this;
 }
示例#23
0
 /**
  * Get price for the selected quantity and dates
  */
 public function getPriceAction()
 {
     if (!$this->getRequest()->getParam('product_id') || !$this->getRequest()->getParam('start_date')) {
         $jsonReturn = array('amount' => -1, 'onclick' => '', 'needsConfigure' => true, 'formatAmount' => -1);
         $this->getResponse()->setBody(Zend_Json::encode($jsonReturn));
         return;
     }
     $productId = $this->getRequest()->getParam('product_id');
     $product = Mage::getModel('catalog/product')->load($productId);
     $qty = urldecode($this->getRequest()->getParam('qty'));
     list($startDate, $endDate) = ITwebexperts_Payperrentals_Helper_Date::saveDatesForGlobalUse($this->getRequest()->getPost());
     if ($this->getRequest()->getParam('is_fixed_date')) {
         //get all fixed dates id with names and hours in a html with rectangle classes.. and disable rent button... have price as an attribute
         //add onclick event and a hidden field which updates...also enable button and start end date to get the real price
         $startDate = date('Y-m-d', strtotime($startDate));
         $endDate = date('Y-m-d', strtotime($endDate));
         $fixedDatesArray = ITwebexperts_Payperrentals_Helper_Data::getFixedRentalDates($product);
         $fixedDatesDropdown = '';
         if (count($fixedDatesArray)) {
             $fixedDatesDropdown .= '<ul class="fixed_array">';
         }
         $hasAvailability = false;
         foreach ($fixedDatesArray as $fixedDate) {
             if (date('Y-m-d', strtotime($fixedDate['start_date'])) == date('Y-m-d', strtotime($startDate))) {
                 if (Mage::helper('payperrentals/inventory')->isAvailable($productId, $fixedDate['start_date'], $fixedDate['end_date'], $qty)) {
                     //if (date('Y-m-d', strtotime($fixedDate['start_date'])) == date('Y-m-d', strtotime($fixedDate['end_date']))) {
                     //   $fixedDatesDropdown .= '<li idname="' . $fixedDate['id'] . '">' . date('H:i', strtotime($fixedDate['start_date'])) /*. '   ' . $fixedDate['name']*/ . '</li>';
                     //} else {
                     $fixedDatesDropdown .= '<li idname="' . $fixedDate['id'] . '">' . Mage::helper('payperrentals')->__('Start: ') . ITwebexperts_Payperrentals_Helper_Date::formatDbDate($fixedDate['start_date'], false, false) . ' &nbsp;&nbsp;&nbsp;  ' . Mage::helper('payperrentals')->__('End: ') . ITwebexperts_Payperrentals_Helper_Date::formatDbDate($fixedDate['end_date'], false, false) . '</li>';
                     //}
                     $hasAvailability = true;
                 }
             }
         }
         if (count($fixedDatesArray)) {
             $fixedDatesDropdown .= '</ul>';
         }
         if (!$hasAvailability) {
             $fixedDatesDropdown = Mage::helper('payperrentals')->__('Sorry, there is no availability left for this option');
         }
         $jsonReturn = array('amount' => 0, 'onclick' => '', 'fixedDates' => $fixedDatesDropdown, 'needsConfigure' => false, 'formatAmount' => -1);
         $this->getResponse()->setBody(Zend_Json::encode($jsonReturn));
         return;
     }
     $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;
     $onClick = '';
     $priceAmount = ITwebexperts_Payperrentals_Helper_Price::getPriceForAnyProductType($product, $attributes, $bundleOptions, $bundleOptionsQty1, $bundleOptionsQty, $startDate, $endDate, $qty, $onClick);
     if (Mage::helper('payperrentals/config')->useListButtons() || ITwebexperts_Payperrentals_Helper_Data::isUsingGlobalDates($product)) {
         ITwebexperts_Payperrentals_Helper_Date::saveDatesForGlobalUse($this->getRequest()->getPost());
     }
     $jsonReturn = array('amount' => $priceAmount, 'onclick' => $onClick, 'needsConfigure' => false, 'formatAmount' => $priceAmount != -1 ? Mage::helper('core')->currency($priceAmount) : -1);
     $this->getResponse()->setBody(Zend_Json::encode($jsonReturn));
 }
示例#24
0
 public function getDateDetails($orderArr)
 {
     $orderIdsAr = explode(';', $orderArr[1]);
     $orderCollections = Mage::getModel('payperrentals/reservationorders')->getCollection()->addProductIdFilter($orderArr[2]);
     Mage::dispatchEvent('ppr_before_filter_order', array('collection' => $orderCollections));
     $orderCollections->addOrderIdsFilter($orderIdsAr);
     //$orderCollections->groupByOrder();
     $hasDropoff = false;
     $hasTurnover = false;
     $orderList = '';
     foreach ($orderCollections as $orderItem) {
         $order = Mage::getModel('sales/order')->load($orderItem->getOrderId());
         if ($order->getSendDatetime()) {
             $hasDropoff = true;
         }
         if ($order->getReturnDatetime()) {
             $hasDropoff = true;
         }
         if ($orderItem->getStartTurnoverBefore()) {
             $hasTurnover = true;
         }
         if ($orderItem->getEndTurnoverAfter()) {
             $hasTurnover = true;
         }
     }
     foreach ($orderCollections as $orderItem) {
         $orderList .= '<tr>';
         $order = Mage::getModel('sales/order')->load($orderItem->getOrderId());
         $shippingId = $order->getShippingAddressId();
         if (empty($shippingId)) {
             $shippingId = $order->getBillingAddressId();
         }
         $address = Mage::getModel('sales/order_address')->load($shippingId);
         $customerName = $address->getFirstname() . ' ' . $address->getLastname();
         $isManualReservation = false;
         if ($orderItem->getOrderId() == 0) {
             $isManualReservation = true;
         }
         /* if is manual reservation, show order comments instead of first/last name since there is none */
         if ($isManualReservation == true) {
             $orderList .= '<td>';
             $orderList .= $this->__('None');
             $orderList .= '</td>';
             $orderList .= '<td>';
             $orderList .= $orderItem->getComments();
             $orderList .= '</td>';
         } else {
             $orderList .= '<td>';
             $orderList .= $order->getIncrementId();
             $orderList .= '</td>';
             $orderList .= '<td>';
             $orderList .= $customerName;
             $orderList .= '</td>';
         }
         $orderList .= '<td>';
         $orderList .= ITwebexperts_Payperrentals_Helper_Date::formatDbDate($orderItem->getStartDate());
         $orderList .= '</td>';
         $orderList .= '<td>';
         $orderList .= ITwebexperts_Payperrentals_Helper_Date::formatDbDate($orderItem->getEndDate());
         $orderList .= '</td>';
         if ($hasDropoff) {
             $orderList .= '<td>';
             if ($orderItem->getDropoff()) {
                 $orderList .= ITwebexperts_Payperrentals_Helper_Date::formatDbDate($orderItem->getDropoff());
             } else {
                 $orderList .= '&nbsp;';
             }
             $orderList .= '</td>';
         }
         if ($hasDropoff) {
             $orderList .= '<td>';
             if ($orderItem->getPickup()) {
                 $orderList .= ITwebexperts_Payperrentals_Helper_Date::formatDbDate($orderItem->getPickup());
             } else {
                 $orderList .= '&nbsp;';
             }
             $orderList .= '</td>';
         }
         if ($hasTurnover) {
             $orderList .= '<td>';
             if ($orderItem->getStartTurnoverBefore()) {
                 $orderList .= ITwebexperts_Payperrentals_Helper_Date::formatDbDate($orderItem->getStartTurnoverBefore());
             } else {
                 $orderList .= '&nbsp;';
             }
             $orderList .= '</td>';
         }
         if ($hasTurnover) {
             $orderList .= '<td>';
             if ($orderItem->getEndTurnoverAfter()) {
                 $orderList .= ITwebexperts_Payperrentals_Helper_Date::formatDbDate($orderItem->getEndTurnoverAfter());
             } else {
                 $orderList .= '&nbsp;';
             }
             $orderList .= '</td>';
         }
         $orderList .= '<td>';
         $orderList .= $orderItem->getQty();
         $orderList .= '</td>';
         if ($isManualReservation == true) {
             $orderList .= '<td>';
             $orderList .= $this->__('None');
             $orderList .= '</td>';
         } else {
             $orderList .= '<td>';
             if (Mage::helper('itwebcommon')->isVendorAdmin()) {
                 $orderList .= '<a href="' . Mage::getUrl('vendors/sales_order/view', array('order_id' => $order->getEntityId())) . '">' . Mage::helper('payperrentals')->__('View') . '</a>';
             } else {
                 $orderList .= '<a href="' . Mage::getUrl('adminhtml/sales_order/view', array('order_id' => $order->getEntityId())) . '">' . Mage::helper('payperrentals')->__('View') . '</a>';
             }
             $orderList .= '</td>';
         }
         $orderList .= '</tr>';
     }
     $orderList = '<table cellpadding="10" cellspacing="10" border="0" style="min-width:400px;">
                     <tr>
                         <td style="font-weight: bold">' . $this->__('Order') . '</td>
                         <td style="font-weight: bold">' . $this->__('Customer Name') . '</td>
                         <td style="font-weight: bold">' . $this->__('Start') . '</td>
                         <td style="font-weight: bold">' . $this->__('End') . '</td>' . ($hasDropoff ? '<td style="font-weight: bold">' . $this->__('Dropoff') . '</td>
                                         <td style="font-weight: bold">' . $this->__('Pickup') . '</td>' : '') . ($hasTurnover ? '<td style="font-weight: bold">' . $this->__('Start W/Turnover') . '</td>
                                          <td style="font-weight: bold">' . $this->__('End W/Turnover') . '</td>' : '') . '<td style="font-weight: bold">' . $this->__('Qty') . '</td>
                         <td style="font-weight: bold">' . $this->__('View Order') . '</td>
                    </tr>' . $orderList;
     $orderList .= '</table>';
     $details['html'] = $orderList;
     $details['date'] = ITwebexperts_Payperrentals_Helper_Date::formatDbDate($orderArr[0]);
     return $details;
 }
示例#25
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;
 }