3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 class CRM_Event_Form_SearchEvent
extends CRM_Core_Form
{
20 * Explicitly declare the entity api name.
22 public function getDefaultEntity() {
29 public function setDefaultValues() {
31 $defaults['eventsByDates'] = 0;
33 $this->_showHide
= new CRM_Core_ShowHideBlocks();
34 if (empty($defaults['eventsByDates'])) {
35 $this->_showHide
->addHide('id_fromToDates');
38 $this->_showHide
->addToTemplate();
43 * Build the form object.
45 * @throws \CRM_Core_Exception
47 public function buildQuickForm() {
48 $this->add('text', 'title', ts('Event Name'),
49 [CRM_Core_DAO
::getAttribute('CRM_Event_DAO_Event', 'title')]
52 $this->addSelect('event_type_id', ['multiple' => TRUE, 'context' => 'search']);
55 $searchOption = [ts('Show Current and Upcoming Events'), ts('Search All or by Date Range')];
56 $this->addRadio('eventsByDates', ts('Events by Dates'), $searchOption, ['onclick' => "return showHideByValue('eventsByDates','1','id_fromToDates','block','radio',true);"], ' ');
58 $this->add('datepicker', 'start_date', ts('From'), [], FALSE, ['time' => FALSE]);
59 $this->add('datepicker', 'end_date', ts('To'), [], FALSE, ['time' => FALSE]);
61 CRM_Campaign_BAO_Campaign
::addCampaignInComponentSearch($this);
66 'name' => ts('Search'),
72 public function postProcess() {
73 $params = $this->controller
->exportValues($this->_name
);
74 $parent = $this->controller
->getParent();
75 $parent->set('searchResult', 1);
76 if (!empty($params)) {
77 $fields = ['title', 'event_type_id', 'start_date', 'end_date', 'eventsByDates', 'campaign_id'];
78 foreach ($fields as $field) {
79 if (isset($params[$field]) &&
80 !CRM_Utils_System
::isNull($params[$field])
82 if ($field === 'end_date') {
83 $parent->set($field, $params[$field] . ' 23:59:59');
86 $parent->set($field, $params[$field]);
90 $parent->set($field, NULL);