function preProcess()
 {
     $this->_id = $this->get('id');
     $config = CRM_Core_Config::singleton();
     $currencySymbols = "";
     if (!empty($config->currencySymbols)) {
         $currencySymbols = $config->currencySymbols;
     } else {
         $currencySymbols = $config->defaultCurrencySymbol;
     }
     $this->assign('currencySymbols', $currencySymbols);
     //Control the flexibility of time configuration for unlimited resource
     $bookingConfig = CRM_Booking_BAO_BookingConfig::getConfig();
     $this->assign('timeconfig', CRM_Utils_Array::value('unlimited_resource_time_config', $bookingConfig));
     $selectResourcePage = $this->controller->exportValues('SelectResource');
     $selectedResources = json_decode($selectResourcePage['resources'], true);
     $this->assign('resources', $selectedResources);
     foreach ($selectedResources as $key => $resource) {
         $this->_subTotal += $resource['price'];
         $this->_resourcesPrice[$key] = $resource['price'];
         $this->_discountAmount = 0;
     }
     $this->_total = $this->_subTotal;
     require_once 'CRM/Booking/Utils/DateTime.php';
     $this->assign('timeOptions', CRM_Booking_Utils_DateTime::getTimeRange());
     // get all custom groups sorted by weight
     $items = array();
     $bao = new CRM_Booking_BAO_AdhocChargesItem();
     $bao->orderBy('weight');
     $bao->is_active = 1;
     $bao->is_deleted = 0;
     $bao->find();
     while ($bao->fetch()) {
         $items[$bao->id] = array();
         CRM_Core_DAO::storeValues($bao, $items[$bao->id]);
         $items[$bao->id]['name'] = preg_replace('/[^\\p{L}\\p{N}\\s]/u', '_', $items[$bao->id]['name']);
     }
     //$days = CRM_Booking_Utils_DateTime::getDays();
     //$months = CRM_Utils_Date::getFullMonthNames();
     //$years = CRM_Booking_Utils_DateTime::getYears();
     $this->assign('items', $items);
     if ($this->_id && $this->_action == CRM_Core_Action::UPDATE) {
         $title = CRM_Core_DAO::getFieldValue('CRM_Booking_BAO_Booking', $this->_id, 'title', 'id');
         CRM_Utils_System::setTitle(ts('Edit Booking') . " - {$title}");
     } else {
         CRM_Utils_System::setTitle(ts('New Booking'));
     }
     /**
      * [dateformatDatetime] => %B %E%f, %Y %l:%M %P
      * [dateformatFull] => %B %E%f, %Y
      * [dateformatPartial] => %B %Y
      * [dateformatYear] => %Y
      * [dateformatTime] => %l:%M %P
      */
     $this->crmDateFormat = $config->dateformatDatetime;
     //retrieve crmDateFormat
     $this->assign('dateFormat', $this->crmDateFormat);
     self::registerScripts();
 }
 /**
  * Function to process the form
  *
  * @access public
  *
  * @return None
  */
 public function postProcess()
 {
     CRM_Utils_System::flushCache();
     $params = $this->exportValues();
     // delete action
     // TODO::Make sure we cannot delete if the entity is linked to bookings
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_Booking_BAO_AdhocChargesItem::del($this->_id);
         CRM_Core_Session::setStatus(ts('Selected additional charges item has been deleted.'), ts('Record Deleted'), 'success');
     } else {
         $params = $this->exportValues();
         if ($this->_id) {
             $params['id'] = $this->_id;
             if (!isset($params['is_active'])) {
                 $params['is_active'] = 0;
             }
         }
         $set = CRM_Booking_BAO_AdhocChargesItem::create($params);
         // udpate action
         if ($this->_action & CRM_Core_Action::UPDATE) {
             CRM_Core_Session::setStatus(ts('The Record \'%1\' has been saved.', array(1 => $set->label)), ts('Saved'), 'success');
         } else {
             $url = CRM_Utils_System::url('civicrm/admin/adhoc_charges_item', 'reset=1&action=browse&sid=' . $set->id);
             CRM_Core_Session::setStatus(ts("Your additional charges item '%1' has been added.", array(1 => $set->label)), ts('Saved'), 'success');
             $session = CRM_Core_Session::singleton();
             $session->replaceUserContext($url);
         }
     }
 }