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'); }
/** * Return start end dates as filtered dates in format Y-m-d H:i:s * @param $startDate * @param $endDate * * @return array */ public static function convertDatepickerToDbFormat($startDate, $endDate = null) { if (is_null($endDate)) { $endDate = $startDate; } $allDates = explode(',', $startDate); $nrVal = count($allDates) - 1; if ($nrVal > 1) { $startingDate = ''; foreach ($allDates as $key => $iDate) { $paramsArr = array('idate' => $iDate); $paramsArr = ITwebexperts_Payperrentals_Helper_Date::filterDates($paramsArr, true); if ($key != $nrVal) { $startingDate .= $paramsArr['idate'] . ','; } else { $startingDate .= $paramsArr['idate']; } } $params = array('start_date' => $startingDate, 'end_date' => $startingDate); } else { $params = array('start_date' => $startDate, 'end_date' => $endDate); $params = ITwebexperts_Payperrentals_Helper_Date::filterDates($params, true); } return array($params['start_date'], $params['end_date']); }