コード例 #1
0
ファイル: UnitTypeConfig.php プロジェクト: laiello/resmania
 /**
  * Register new unit type for all DEFAULT unit config value except some providerd
  *
  * @param  $unitTypeID
  * @param array $except
  * @return void
  */
 function register($unitTypeID, $except = array())
 {
     $model = new RM_UnitConfig();
     $default = $model->getDefault();
     foreach ($default as $row) {
         if (in_array($row->id, $except)) {
             continue;
         }
         if ($this->exist($unitTypeID, $row->id) == false) {
             $this->insert(array('unit_type_id' => $unitTypeID, 'unit_config_id' => $row->id));
         }
     }
 }
コード例 #2
0
 /**
  * Edit JS - Used to load all configuration for Edit Reservation Form
  *
  * This method loads only configuration information required by the edit.js
  * reservation page.
  *
  * @return   js variable used directly by edit.js
  */
 public function edit_Js_Action()
 {
     $fieldsDAO = new RM_ReservationConfig();
     $configFields = $fieldsDAO->getAdminEdit()->toArray();
     foreach ($configFields as $key => $configField) {
         $metainfo[] = $configField['admin_edit_preferences'];
     }
     $fieldsDAO = new RM_UnitConfig();
     $configFields = $fieldsDAO->getAllReservationFields()->toArray();
     foreach ($configFields as $key => $configField) {
         $metainfo[] = $configField['admin_edit_reservation_preferences'];
     }
     return "RM.Common.Reservations_Edit_Setup([" . implode(',', $metainfo) . "]);";
 }
コード例 #3
0
ファイル: UnitsController.php プロジェクト: laiello/resmania
 public function editJsonAction()
 {
     $json = new stdClass();
     $id = $this->_getParam('id');
     $iso = $this->_getParam('iso', RM_Environment::getInstance()->getLocale());
     $unitModel = new RM_Units();
     $unit = $unitModel->get($id, $iso);
     $config = new RM_UnitConfig();
     $fields = $config->getEditFormByUnit($unit);
     $config = new RM_Config();
     // view_preferences_1 provides non html editors, just raw editors
     foreach ($fields as $field) {
         if ($config->getValue('rm_config_editor') == "text" && $field->view_preferences_1 !== "") {
             $jsonFields[] = $field->view_preferences_1;
         } else {
             $jsonFields[] = $field->view_preferences;
         }
     }
     $reservationModel = new RM_Reservations();
     $reservations = $reservationModel->fetchAllByUnit($unit);
     $jsonReservations = array();
     /*
      * the reservation information required to add events to the calendar must include
      * the start and end date but also the unit color.
      */
     foreach ($reservations as $reservation) {
         $jsonReservation = new stdClass();
         $jsonReservation->start_date = $config->convertDates($reservation->start_datetime, RM_Config::MYSQL_DATEFORMAT, RM_Config::MYSQL_DATEFORMAT_SHORT);
         $jsonReservation->end_date = $config->convertDates($reservation->end_datetime, RM_Config::MYSQL_DATEFORMAT, RM_Config::MYSQL_DATEFORMAT_SHORT);
         $jsonReservation->color = $unit->color;
         // unit color
         $jsonReservations[] = $jsonReservation;
     }
     $priceSystems = RM_Environment::getInstance()->getPriceSystem()->getAllPriceSystems();
     $jsonPriceSystems = array();
     foreach ($priceSystems as $system) {
         $jsonPriceSystems[] = $system->name;
     }
     $priceSystem = RM_Environment::getInstance()->getPriceSystem()->getRealPriceSystem($unit);
     // group handling (only used when the groups is enabled)
     $isGroupTemplate = 0;
     if ($unit->isTemplateUnit() === (int) $unit->id) {
         $isGroupTemplate = 1;
     } elseif ($unit->isTemplateUnit() === null || $unit->isTemplateUnit() === 0) {
         // if this unit is not in a group then we set the isGroupTemplate true
         // as this is really the same as a template for the GUI
         $isGroupTemplate = 1;
     }
     $json = "{ unit : " . Zend_Json::encode($unitModel->convertToGUI($unit->toArray())) . ", isgrouptemplate: '" . $isGroupTemplate . "', fields : [" . implode(',', $jsonFields) . "], periods: " . Zend_Json::encode($jsonReservations) . ", language: '" . $iso . "', price: '" . $priceSystem->name . "', prices: " . Zend_Json::encode($jsonPriceSystems) . "}";
     return array('data' => $json, 'encoded' => true);
 }
コード例 #4
0
 /**
  * @deprecated
  */
 public function fetchAllByReservation($reservation, $order = null, $count = null, $offset = null, $language = null)
 {
     if ($language == null) {
         $language = RM_Environment::getInstance()->getLocale();
     }
     if ($reservation == null) {
         return null;
     }
     //1. we need all fields from reservation_config that have admin_edit_preferences!=""
     $reservationConfigModel = new RM_ReservationConfig();
     $reservationDetailColumns = $reservationConfigModel->getAdminEdit();
     //2. we need all fields from unit config that have admin_reservation=1 and language = 0
     $unitConfigModel = new RM_UnitConfig();
     $unitColumns = $unitConfigModel->getReservationFields();
     //3. we need all fields from unit config that have admin_reservation=1 and language = 1
     $unitLanguageColumns = $unitConfigModel->getReservationLanguageFields();
     //4. create SQL
     $fieldsNames = array();
     foreach ($reservationDetailColumns as $field) {
         $fieldsNames[] = 'rd.' . $field->name . ' AS ' . $field->name;
     }
     foreach ($unitColumns as $field) {
         $fieldsNames[] = 'rm_units.' . $field->column_name . ' AS ' . $field->column_name;
     }
     foreach ($unitLanguageColumns as $field) {
         $fieldsNames[] = 'rm_unit_language_details.' . $field->column_name . ' AS ' . $field->column_name;
     }
     if ($offset === null) {
         $offset = 0;
     }
     $sql = "\r\n            SELECT\r\n                " . implode(',', $fieldsNames) . "\r\n            FROM\r\n                {$this->_name} rd\r\n            INNER JOIN\r\n                rm_units ON rm_units.id = rd.unit_id\r\n            LEFT OUTER JOIN\r\n                rm_unit_language_details ON rm_unit_language_details.unit_id=rm_units.id AND rm_unit_language_details.iso = '{$language}'\r\n            WHERE\r\n                rd.reservation_id = '{$reservation->id}' ";
     if ($order !== null) {
         $sql .= " ORDER BY {$order} ";
     }
     if ($count !== null) {
         $sql .= " LIMIT {$offset}, {$count} ";
     }
     return $this->_getBySQL($sql);
 }
コード例 #5
0
ファイル: Units.php プロジェクト: laiello/resmania
 /**
  * Returns all fields information belongs to a different type of a unit.
  *
  * @param Zend_Db_Table_Row $type 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 _getFieldsByType($type)
 {
     $configModel = new RM_UnitConfig();
     $fields = $configModel->getFields($type->id);
     $languageFields = $configModel->getLanguageFields($type->id);
     return array($fields, $languageFields);
 }