/** * 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(); }
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); } }