예제 #1
0
파일: Row.php 프로젝트: laiello/resmania
 private function _getForm($unitTypeID = null)
 {
     if ($unitTypeID == null) {
         $unitTypeID = RM_UnitTypes::DEFAULT_TYPE;
     }
     $unitTypesModel = new RM_UnitTypes();
     $unitType = $unitTypesModel->find($unitTypeID)->current();
     $unitTypeFormsModel = new RM_UnitTypeForms();
     $unitTypeForm = $unitTypeFormsModel->fetchBy($this, $unitType);
     return $unitTypeForm;
 }
예제 #2
0
 public function getNode()
 {
     $std = new stdClass();
     $std->id = $this->name . '_controlpanelJson_EditJson';
     $std->text = $this->getName();
     $std->disabled = false;
     $std->iconCls = 'RM_modules_leaf_icon';
     $nodes = array();
     $formModel = new RM_Forms();
     $globalForms = $formModel->getAllGlobal();
     foreach ($globalForms as $form) {
         $nodeStd = new stdClass();
         $nodeStd->text = $form->name;
         $nodeStd->id = 'FormDesigner_EditJson_' . $form->id;
         $nodeStd->formID = $form->id;
         $nodeStd->unitTypeID = RM_UnitTypes::DEFAULT_TYPE;
         $nodeStd->leaf = true;
         $nodeStd->iconCls = "RM_module_formdesigner_leaf_icon";
         $nodes[] = $nodeStd;
     }
     $unitTypesModel = new RM_UnitTypes();
     $nonGlobalForms = $formModel->getAllNonGlobal();
     $types = $unitTypesModel->fetchAll();
     foreach ($types as $type) {
         $nodeUnit = new stdClass();
         $nodeUnit->text = $type->getName();
         $nodeUnit->leaf = false;
         $nodeUnit->expanded = false;
         $nodeUnit->disabled = true;
         $nodeUnit->children = array();
         foreach ($nonGlobalForms as $form) {
             $nodeStd = new stdClass();
             $nodeStd->text = $form->name;
             $nodeStd->id = 'FormDesigner_EditJson_' . $form->id . '_' . $type->id;
             $nodeStd->formID = $form->id;
             $nodeStd->unitTypeID = $type->id;
             $nodeStd->leaf = true;
             $nodeStd->iconCls = "RM_module_formdesigner_leaf_icon";
             $nodeUnit->children[] = $nodeStd;
         }
         $nodes[] = $nodeUnit;
     }
     if (count($nodes) == 0) {
         $std->leaf = 'true';
     } else {
         $std->expanded = 'true';
         $std->children = $nodes;
     }
     return $std;
 }
예제 #3
0
 public function getDefaultUnitType()
 {
     $model = new RM_UnitTypes();
     $row = $model->fetchRow($model->select()->where("`default`=1"));
     if ($row == null) {
         //We have a situation when no unit type is default.
         //We need to assign Default unit type to default.
         $row = $model->find($this->_defaultUnitType)->current();
         if ($row !== null) {
             $this->makeDefault($row);
         }
     }
     return $row;
 }
예제 #4
0
 public function allpanelsAction()
 {
     $unitModel = new RM_Units();
     $unitTypeID = $this->_getParam('unitTypeID');
     $unitTypeModel = new RM_UnitTypes();
     $unitType = $unitTypeModel->find($unitTypeID)->current();
     $unit = $unitModel->getAll(new RM_Unit_Search_Criteria(array('type' => $unitType, 'includeOptionUnits' => true, 'includeExcursionUnits' => true)))->current();
     if ($unitTypeID == RM_UnitTypes::DEFAULT_TYPE && $unit == null) {
         $unit = $unitModel->getAll(new RM_Unit_Search_Criteria())->current();
     }
     if ($unit == null) {
         $unit = $unitModel->createRow();
     }
     $this->view->unit = $unit;
     $this->view->admin = true;
     // this is required by captcha
     $panelModel = new RM_FormPanels();
     $panels = $panelModel->fetchAll();
     $this->view->panels = $panels;
 }
 public function configupdateJsonAction()
 {
     $unitTypesModel = new RM_UnitTypes();
     $prices = $this->_getParam("prices", array());
     foreach ($prices as $unitID => $priceModuleName) {
         $unitType = $unitTypesModel->find($unitID)->current();
         if ($unitType !== null) {
             $unitType->price = $priceModuleName;
             $unitType->save();
         }
     }
     $defaultTypeID = $this->_getParam('rm_default_system_unit_type');
     if ($defaultTypeID !== null) {
         $unitType = $unitTypesModel->find($defaultTypeID)->current();
         if ($unitType !== null) {
             $module = new RM_Module_UnitTypeManager();
             $module->makeDefault($unitType);
         }
     }
     return array('data' => array('success' => true));
 }
예제 #6
0
 /**
  * Saving form state into database
  *
  * @param formID
  * @param value
  * @return json information for the front-end
  */
 function savestateJsonAction()
 {
     $formID = $this->_getParam('formID');
     $state = $this->_getParam('state');
     $columns = $this->_getParam('columns');
     $column1width = $this->_getParam('column1width');
     $column2width = $this->_getParam('column2width');
     $column3width = $this->_getParam('column3width');
     $unitTypeID = $this->_getParam('unitTypeID', RM_UnitTypes::DEFAULT_TYPE);
     $model = new RM_Forms();
     $form = $model->find($formID)->current();
     $unitTypesModel = new RM_UnitTypes();
     $unitType = $unitTypesModel->find($unitTypeID)->current();
     if ($unitType == null) {
         $unitTypeID = RM_UnitTypes::DEFAULT_TYPE;
         $unitType = $unitTypesModel->find($unitTypeID)->current();
     }
     $unitTypeFormsModel = new RM_UnitTypeForms();
     if ($unitTypeFormsModel->check($form, $unitType)) {
         $unitTypeForm = $unitTypeFormsModel->fetchBy($form, $unitType);
     } else {
         //We need to create a new row for this unit type
         $unitTypeForm = $unitTypeFormsModel->createRow();
         $unitTypeForm->form_id = $form->id;
         $unitTypeForm->unit_type_id = $unitTypeID;
     }
     $unitTypeForm->columns = $columns;
     $unitTypeForm->column1width = $column1width;
     $unitTypeForm->column2width = $column2width;
     $unitTypeForm->column3width = $column3width;
     $unitTypeForm->state = $state;
     $result = $unitTypeForm->save();
     $resultJson = false;
     if ($result) {
         $resultJson = true;
     }
     return array('data' => array('success' => $resultJson));
 }
예제 #7
0
 function detailsAction()
 {
     // reset the returnAllUnits if it's set
     unset($_SESSION["returnAllUnits"]);
     $unitID = $this->_getParam('unit_id', null);
     $isGroup = $this->_getParam('isGroup', 0);
     if ($unitID == null) {
         $this->_redirect('Unit', 'list');
         return;
     }
     $unitModel = new RM_Units();
     $language = RM_Environment::getInstance()->getLocale();
     $availableSubUnits = array();
     $mainFound = false;
     // if this is a group we need to get an available unit from the 'pool'
     if ($isGroup) {
         $masterUnit = $unitModel->get($unitID, $language);
         $qty = $this->_getParam('qty', 1);
         // define how many subunits to pick
         if (!isset($qty) || $qty == 0) {
             $qty = 1;
         }
         $criteria = RM_Reservation_Manager::getInstance()->getCriteria();
         if (!$criteria) {
             $criteria = new RM_Unit_Search_Criteria();
         }
         if ($criteria->showOptionUnits === "1" || $criteria->showExcursionUnits === "1") {
             $criteria = new RM_Unit_Search_Criteria();
         }
         $groupsModel = new RM_Groups();
         // get available sub units
         $AllavailableSubUnits = $masterUnit->getAllSubUnits($criteria, $masterUnit);
         // the groups module will return a free unit using the method above
         // this means if there are no subunits it will return the available
         // main unit. This causes us a problem as if the unit returned is not
         // the main unit then we need to + one to the available units as the
         // main unit is also available for reservation.
         foreach ($AllavailableSubUnits as $subunit) {
             if ($subunit->getGroupId() === $masterUnit->getGroupId()) {
                 if ($groupsModel->isMain($subunit)) {
                     // if it's the main unit set a flag
                     $mainFound = true;
                 }
                 $availableSubUnits[] = $subunit;
             }
         }
         $unit = $masterUnit;
         if (count($availableSubUnits) < $qty) {
             $availableSubUnits[] = $masterUnit;
         }
     } else {
         $unit = $unitModel->get($unitID, $language);
     }
     if ($unit == null) {
         $this->_redirect('Unit', 'list');
         return;
     }
     $qtyAvailable = count($availableSubUnits);
     // if the main unit was not found add one to the quantity
     // total as the main unit + the sub unit is available.
     if (!$mainFound) {
         $qtyAvailable += 1;
     }
     $this->view->unit = $unit;
     $this->view->subunits = $availableSubUnits;
     $this->view->quantity = $qtyAvailable;
     // set the page title
     RM_Environment::getConnector()->setPageTitle($unit->name);
     $formModel = new RM_Forms();
     $form = $formModel->find('unitdetails')->current();
     $this->view->form = $form;
     $this->view->state = $form->getState($unit->type_id);
     $unitTypeModel = new RM_UnitTypes();
     $unitType = $unitTypeModel->find($unit->type_id)->current();
     $unitTypeFormsModel = new RM_UnitTypeForms();
     $this->view->unitTypeForm = $unitTypeFormsModel->fetchBy($form, $unitType);
 }
예제 #8
0
 /**
  * Get current price system for unit
  *
  * @param RM_Unit_Row $unit
  * @return RM_Prices_Interface
  */
 private function _getPriceSystem(RM_Unit_Row $unit)
 {
     //TODO: maybe we need to change this later
     if (class_exists('RM_Module_UnitTypeManager') == false) {
         return $this->_getDefaultPriceSystem();
     }
     $unitTypeModel = new RM_UnitTypes();
     $unitType = $unitTypeModel->find($unit->type_id)->current();
     if ($unitType == null) {
         return $this->_getDefaultPriceSystem();
     }
     $priceModuleName = $unitType->price;
     if ($priceModuleName == "") {
         return $this->_getDefaultPriceSystem();
     }
     $priceSystems = $this->_getAllPriceSystems();
     foreach ($priceSystems as $priceSystem) {
         if ($priceSystem->name == $priceModuleName) {
             return $priceSystem;
         }
     }
     return $this->_getDefaultPriceSystem();
 }
예제 #9
0
 /**
  * Returns the list data for the Unit Assignment Grid.
  *
  * This creates a JS variable containing the list configuration/setup for
  * the reservation list. This is implicated in list.js
  *
  * @deprecated
  * @param  	request id  the reservation id.
  * @param  	request type    if this is a new or existing reservation.
  * @param    request start   list start used for pagenation
  * @param    request limit   list limit used for pagenation
  * @param    request sort    list sort parameter
  * @param    request dir list direction Asc/desc
  * @param    request filter  an array of any filters applied
  * @return   json    information required to configure unit selection grid.
  */
 public function listunitsJsonAction()
 {
     $id = $this->_getParam('id');
     $type = $this->_getParam('type');
     $offset = $this->_getParam('start');
     $count = $this->_getParam('limit');
     $sort = $this->_getParam('sort', 'id');
     $direction = $this->_getParam('dir', 'DESC');
     $language = $this->_translate->getAdapter()->getLocale();
     $order = $sort . ' ' . $direction;
     $dao = new RM_ReservationDetails();
     if ($type == "new") {
         $unitTypeDAO = new RM_UnitTypes();
         $unitType = $unitTypeDAO->find('1')->current();
         $details = $dao->getAll($unitType, $order, $count, $offset, $language, $filters)->toArray();
         $total = $dao->getAll($unitType, $order, null, null, $language, $filters)->count();
     } else {
         $reservationDAO = new RM_Reservations();
         $reservation = $reservationDAO->find($id)->current();
         $total = $dao->fetchAllByReservation($reservation, $order, null, null, $language)->count();
         $details = $dao->fetchAllByReservation($reservation, $order, $count, $offset, $language)->toArray();
     }
     $json = new stdClass();
     $json->total = $total;
     $json->data = $details;
     return array('data' => $json);
 }
예제 #10
0
 public function updateJsonAction()
 {
     $unit = $this->_getParam('edit_unit');
     $unit['color'] = ltrim($this->_getParam('color'), "#");
     $dao = new RM_Units();
     // update the unit record
     $dao->updateUnit($unit);
     if (isset($unit['group_id'])) {
         // make sure that sub units are converted to the same unit type
         if (class_exists(RM_Groups)) {
             $groups = new RM_Groups();
             // get the unit object
             $unitObject = $dao->get($unit['id'], null, array('description', 'summary'));
             if (!$groups->isMain($unitObject)) {
                 // if it's not a main unit, then update the unit to the same unit type as the main unit
                 $allGroupedUnits = $groups->getGroupUnitsByMain($unitObject);
                 // find the main unit id...
                 foreach ($allGroupedUnits as $groupUnit) {
                     if ($groups->isMain($groupUnit)) {
                         $mainUnitID = $groupUnit->id;
                     }
                 }
                 // get the main unit object
                 $mainUnitObject = $dao->get($mainUnitID, null, array('description', 'summary'));
                 // get the type for the main unit
                 $rmUnitTypes = new RM_UnitTypes();
                 $typeInfo = $rmUnitTypes->getByUnit($mainUnitObject)->toArray();
                 // update the subunit to the same type
                 $unit['type_id'] = (int) $typeInfo['id'];
                 $dao->updateUnit($unit);
             }
         }
     }
     return array('data' => array('success' => true, 'msg' => ''));
 }
예제 #11
0
파일: Units.php 프로젝트: laiello/resmania
 /**
  * Returns all fields belongs to a unit by it primary key value.
  *
  * @param int $unitID Unit type
  * @return array Array with keys:
  * 0 => Zend_Db_Table_Rowset with language undependent fields
  * 1 => Zend_Db_Table_Rowset with language dependent fields
  */
 protected function _getFields($unitID)
 {
     $unit = $this->find($unitID)->current();
     $unitTypeDAO = new RM_UnitTypes();
     $type = $unitTypeDAO->getByUnit($unit);
     return $this->_getFieldsByType($type);
 }
예제 #12
0
 /**
  * Add language to the system, laguage files need to be in there places on language folder
  *
  * @param string $iso
  */
 public function installLanguage($iso, $name)
 {
     $model = new RM_Languages();
     $language = array('iso' => $iso, 'name' => $name, 'icon' => $this->getIconPath($iso));
     $model->insert($language);
     //Here is a list of multilingual code models
     $model = new RM_UnitTypes();
     $model->addLanguage($iso);
     $unitModel = new RM_UnitLanguageDetails();
     $unitModel->addLanguage($iso);
     $templatesModel = new RM_Templates();
     $templatesModel->addLanguage($iso);
     $manager = new RM_Module_Manager();
     $manager->addLanguage($iso);
     $pluginManager = new RM_Plugin_Manager();
     $pluginManager->addLanguage($iso);
 }