示例#1
0
 /**
  * Returns PHP dateformat to present reservation start and end date on the UI
  *
  * @param bool $php - internal PHP date format or UI date format, if true - internal PHP date format
  * @return string
  */
 public function getDateformat($php = false)
 {
     if ($php) {
         return RM_Config::MYSQL_DATEFORMAT_SHORT;
     }
     $config = new RM_Config();
     return $config->getJSDateformat();
 }
示例#2
0
 /**
  * @see system/libs/Zend/Controller/Zend_Controller_Action#preDispatch()
  */
 public function preDispatch()
 {
     $this->view->setTranslate(RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN));
     $this->_translate = RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN);
     $this->view->setRouter($this->getFrontController()->getRouter());
     $config = new RM_Config();
     $this->view->guiDateFormat = $config->getJSDateformat();
     $this->view->GUIMaximisedState = $config->getValue("rm_config_admin_gui_maximised");
     $this->view->mysqlDateFormat = RM_Config::MYSQL_DATEFORMAT;
     $this->view->phpDateFormat = RM_Config::PHP_DATEFORMAT;
     $this->view->calStartDay = $config->getValue("rm_config_calendar_startday");
     $this->view->CMSIntegration = $config->getValue("rm_config_enable_cms_integration");
     $this->view->enableUserGroups = $config->getValue("rm_config_enable_user_groups");
     $this->view->enableUnitsOnTreeMenu = $config->getValue("rm_config_enable_units_on_treemenu");
     $this->view->reservationsListBufferSize = $config->getValue("rm_config_reservations_list_buffersize");
     $this->view->editorType = $config->getValue("rm_config_editor");
 }
示例#3
0
 /**
  * ListAction is the main search routine used to list units. Params are sent from the
  * search forms and either submitted data is used or the saved criteria.
  *
  * @param array search  passed in post/get
  * @return  objects to view
  */
 function listAction()
 {
     // reset the returnAllUnits if it's set
     unset($_SESSION["returnAllUnits"]);
     // get the submitted search data
     $data = $this->_getParam('search', array());
     // get the category if set explicitly
     $category = $this->_getParam('category', "");
     // if category is not passed then set it to ""
     // if the category data sent in the request has data then add the category to the data array for use to create the criteria
     if ($category !== "true") {
         $data['categories'] = $category;
     }
     // if we are not re-ordering and have search data define a new search criteria
     if (!isset($data['reorder']) && !empty($data)) {
         // create a new criteria object
         $criteria = new RM_Unit_Search_Criteria($data);
         // reset the old criteria and save our new criteria
         RM_Reservation_Manager::getInstance()->resetCriteria()->setCriteria($criteria);
     } else {
         $criteria = RM_Reservation_Manager::getInstance()->getCriteria();
     }
     // perform a check to make sure our criteria object is the correct instance
     // if it's not it will cause errors, so we check it and if it isn't we create
     // it as the correct object
     if (!$criteria instanceof RM_Unit_Search_Criteria) {
         $criteria = new RM_Unit_Search_Criteria($data);
     }
     // if the category passed in the request is empty and the criteria has a category set then blank it.
     if ($category === "" && $criteria->categories) {
         $criteria->categories = null;
     }
     // only show published units
     $criteria->publishedOnly = true;
     $criteria->groupsOnly = false;
     // define the default page ordering if no page ordering is passed
     if (!$criteria->order) {
         $criteria->order = RM_User_UnitController::getDefaultOrder();
     }
     // if page re-ordering is called add this to the criteria and save it
     if (isset($data['reorder'])) {
         // if we are just re-odering the list get the saved criteria and use this.
         if (isset($data['order'])) {
             $criteria->order = $data['order'];
             // save the ordering to the criteria
             RM_Reservation_Manager::getInstance()->resetCriteria()->setCriteria($criteria);
         }
     }
     // get the default page lengths for the view
     $defaulCountPerPage = RM_Environment::getConnector()->getDefaultUnitListLength();
     $unitModel = new RM_Units();
     $units = $unitModel->getAll($criteria);
     if ($criteria->order == 'price') {
         $units = $this->_sortUnitsByPrice($criteria, $units);
     }
     $formModel = new RM_Forms();
     $form = $formModel->find('unitlist')->current();
     $this->view->form = $form;
     $this->view->criteria = $criteria;
     // get date formatting for the view
     $config = new RM_Config();
     $dateFormat = $config->getJSDateformat();
     if ($dateFormat == "d/m/Y") {
         $lng_dateFormat = "dd/mm/yyyy";
     } else {
         $lng_dateFormat = "mm/dd/yyyy";
     }
     $this->view->dateformat_short = $dateFormat;
     $this->view->dateformat_long = $lng_dateFormat;
     // criteria list header message
     $message = false;
     if ($criteria->start_datetime !== null && $criteria->end_datetime !== null && $criteria->start_datetime !== "" && $criteria->end_datetime !== "") {
         $message .= date($dateFormat, strtotime($criteria->start_datetime)) . " - " . date($dateFormat, strtotime($criteria->end_datetime)) . ", ";
     }
     if ((int) $criteria->image === 1) {
         $message .= $this->_translate->_('User.Unit.List', 'criteriaImage') . ", ";
     }
     if ((int) $criteria->flexible === 1) {
         $message .= $this->_translate->_('User.Unit.List', 'criteriaFlexible') . ", ";
     }
     if ((int) $criteria->map === 1) {
         $message .= $this->_translate->_('User.Unit.List', 'criteriaMap') . ", ";
     }
     if ((int) $criteria->prices_from !== 0) {
         $message .= $this->_translate->_('User.Unit.List', 'criteriaPricesFrom') . ": " . $criteria->prices_from . ", ";
     }
     if ($criteria->prices_to != "99999999" && $criteria->prices_to) {
         $message .= $this->_translate->_('User.Unit.List', 'criteriaPricesTo') . ": " . $criteria->prices_to . ", ";
     }
     if ((int) $criteria->adults > 1) {
         $message .= $this->_translate->_('User.Unit.List', 'criteriaAdults') . ": " . $criteria->adults . ", ";
     }
     if ((int) $criteria->children > 0) {
         $message .= $this->_translate->_('User.Unit.List', 'criteriaChildren') . ": " . $criteria->children . ", ";
     }
     if ((int) $criteria->infants > 0) {
         $message .= $this->_translate->_('User.Unit.List', 'criteriaInfants') . ": " . $criteria->infants . ", ";
     }
     $this->view->criteriaMessage = rtrim($message, ", ");
     $paginator = Zend_Paginator::factory($units);
     $paginator->setDefaultItemCountPerPage($defaulCountPerPage);
     $paginator->setCurrentPageNumber($this->_getParam('page', 1));
     $this->view->paginator = $paginator;
 }