예제 #1
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0);
     $this->assign('bookingId', $this->_id);
     $config = CRM_Core_Config::singleton();
     /**
      * [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);
     $days = CRM_Booking_Utils_DateTime::getDays();
     $months = CRM_Utils_Date::getFullMonthNames();
     $years = CRM_Booking_Utils_DateTime::getYears();
     $this->assign('days', $days);
     $this->assign('months', $months);
     $this->assign('years', $years);
     $config = CRM_Core_Config::singleton();
     $currencySymbols = "";
     if (!empty($config->currencySymbols)) {
         $currencySymbols = $config->currencySymbols;
     } else {
         $currencySymbols = $config->defaultCurrencySymbol;
     }
     $resourceTypes = CRM_Booking_BAO_Resource::getResourceTypes();
     $resources = array();
     foreach ($resourceTypes as $key => $type) {
         $result = CRM_Booking_BAO_Resource::getResourcesByType($key);
         $rTypekey = trim(strtolower($key . '_' . $type['label']));
         $resources[$rTypekey]['label'] = $type['label'];
         $resources[$rTypekey]['child'] = $result;
     }
     $this->assign('resources', $resources);
     $this->assign('currencySymbols', $currencySymbols);
     $config = CRM_Booking_BAO_BookingConfig::getConfig();
     $this->assign('colour', CRM_Utils_Array::value('slot_new_colour', $config));
     list($xStart, $xSize, $xStep) = CRM_Booking_Utils_DateTime::getCalendarTime();
     $this->assign('xStart', $xStart);
     $this->assign('xSize', $xSize);
     $this->assign('xStep', $xStep);
     $this->assign('timeOptions', CRM_Booking_Utils_DateTime::getTimeRange());
     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'));
     }
     self::registerScripts();
 }
예제 #2
0
 /**
  * Browse all resources.
  *
  * @return void
  * @access public
  * @static
  */
 function browse($action = NULL)
 {
     $types = CRM_Booking_BAO_Resource::buildOptions('type_id', 'create');
     $locations = CRM_Booking_BAO_Resource::buildOptions('location_id', 'create');
     // get all custom groups sorted by weight
     $resources = array();
     $dao = new CRM_Booking_DAO_Resource();
     $dao->orderBy('weight');
     $dao->is_deleted = FALSE;
     $dao->find();
     while ($dao->fetch()) {
         $resources[$dao->id] = array();
         CRM_Core_DAO::storeValues($dao, $resources[$dao->id]);
         $resources[$dao->id]['type'] = CRM_Utils_Array::value(CRM_Utils_Array::value('type_id', $resources[$dao->id]), $types);
         $resources[$dao->id]['location'] = CRM_Utils_Array::value(CRM_Utils_Array::value('location_id', $resources[$dao->id]), $locations);
         // form all action links
         $action = array_sum(array_keys($this->links()));
         // update enable/disable links.
         if ($dao->is_active) {
             $action -= CRM_Core_Action::ENABLE;
         } else {
             $action -= CRM_Core_Action::DISABLE;
         }
         $resources[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id));
     }
     $this->assign('rows', $resources);
 }
예제 #3
0
 /**
  * Function to process the form
  *
  * @access public
  *
  * @return None
  */
 public function postProcess()
 {
     CRM_Utils_System::flushCache();
     $params = $this->exportValues();
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_Booking_BAO_Slot::delByResource($this->_id);
         CRM_Booking_BAO_Resource::del($this->_id);
         CRM_Core_Session::setStatus(ts('Selected resource has been deleted.'), ts('Record Deleted'), 'success');
     } else {
         $params = $this->exportValues();
         // If the is_active (enabled) checkbox is NOT set, it is NOT sent down in the form
         // The DAO definition for is_active has a default of '1'
         // So if not set it is by default ENABLED when in fact it should be DISABLED
         if (!isset($params['is_active'])) {
             $params['is_active'] = 0;
         }
         if ($this->_id) {
             $params['id'] = $this->_id;
         }
         $resource = CRM_Booking_BAO_Resource::create($params);
         CRM_Core_Session::setStatus(ts('The Record \'%1\' has been saved.', array(1 => $resource->label)), ts('Saved'), 'success');
     }
 }
예제 #4
0
 static function buildSearchForm(&$form)
 {
     $form->add('text', 'booking_po_no', ts('Purchase Order Number'));
     $resourceTypes = CRM_Booking_BAO_Resource::getResourceTypes();
     $resources = array();
     foreach ($resourceTypes as $value) {
         $resources[$value['id']] = $value['label'];
     }
     $form->add('select', 'booking_resource_id', ts('Resource Type'), array('' => ts('- select -')) + $resources, FALSE, array());
     $form->add('text', 'booking_id', ts('Booking ID'));
     $form->add('text', 'booking_title', ts('Booking Title'));
     CRM_Core_Form_Date::buildDateRange($form, 'booking_event_date', 1, '_low', '_high', ts('From'), FALSE);
     CRM_Core_Form_Date::buildDateRange($form, 'booking_start_date', 1, '_low', '_high', ts('From'), FALSE);
     CRM_Core_Form_Date::buildDateRange($form, 'booking_end_date', 1, '_low', '_high', ts('From'), FALSE);
     $bookingStatus = CRM_Booking_BAO_Booking::buildOptions('status_id', 'create');
     foreach ($bookingStatus as $id => $name) {
         $form->_bookingStatus =& $form->addElement('checkbox', "booking_status_id[{$id}]", NULL, $name);
     }
     $paymentStatus = CRM_Contribute_PseudoConstant::contributionStatus();
     foreach ($paymentStatus as $id => $name) {
         $form->_paymentStatus = $form->addElement('checkbox', "booking_payment_status_id[{$id}]", NULL, $name);
     }
 }