/** * Function to build the form * * @return None * @access public */ public function buildQuickForm($check = FALSE) { parent::buildQuickForm(); $timeRange = CRM_Booking_Utils_DateTime::createTimeRange("00:00", "24:00"); $timeOptions = array(); foreach ($timeRange as $key => $time) { $option = date('G:i', $time); $timeOptions[$option] = $option; } $this->add('select', 'day_start_at', ts('Day starts at'), $timeOptions, FALSE, array()); $this->add('select', 'day_end_at', ts('Day ends at'), $timeOptions, FALSE, array()); /* $this->add('select', 'time_period', ts('Time period'), array(10 => '10', 15 => '15', 20 => '20', 30 => '30', 60 => '60'), FALSE, array() );*/ $this->add('text', 'cc_email_address', ts('CC'), array('size' => 50, 'maxlength' => 255), FALSE); $this->add('text', 'bcc_email_address', ts('BCC'), array('size' => 50, 'maxlength' => 255), FALSE); $this->add('checkbox', 'log_confirmation_email', ts('Log email?')); $this->add('checkbox', 'unlimited_resource_time_config', ts('')); $this->add('text', 'slot_new_colour', ts('New Slot Colour')); $this->add('text', 'slot_being_edited_colour', ts('Slot Editing Colour')); $this->add('text', 'slot_booked_colour', ts('Booked Slot Colour')); $this->add('text', 'slot_provisional_colour', ts('Provisional Slot Colour')); $this->addFormRule(array('CRM_Admin_Form_Preferences_Booking', 'formRule'), $this); $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE))); }
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 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(); }