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
19 class CRM_Event_Form_SearchEvent
extends CRM_Core_Form
{
22 * Explicitly declare the entity api name.
24 public function getDefaultEntity() {
31 public function setDefaultValues() {
33 $defaults['eventsByDates'] = 0;
35 $this->_showHide
= new CRM_Core_ShowHideBlocks();
36 if (empty($defaults['eventsByDates'])) {
37 $this->_showHide
->addHide('id_fromToDates');
40 $this->_showHide
->addToTemplate();
45 * Build the form object.
47 * @throws \CRM_Core_Exception
49 public function buildQuickForm() {
50 $this->add('text', 'title', ts('Event Name'),
51 [CRM_Core_DAO
::getAttribute('CRM_Event_DAO_Event', 'title')]
54 $this->addSelect('event_type_id', ['multiple' => TRUE, 'context' => 'search']);
57 $searchOption = [ts('Show Current and Upcoming Events'), ts('Search All or by Date Range')];
58 $this->addRadio('eventsByDates', ts('Events by Dates'), $searchOption, ['onclick' => "return showHideByValue('eventsByDates','1','id_fromToDates','block','radio',true);"], ' ');
60 $this->add('datepicker', 'start_date', ts('From'), [], FALSE, ['time' => FALSE]);
61 $this->add('datepicker', 'end_date', ts('To'), [], FALSE, ['time' => FALSE]);
63 CRM_Campaign_BAO_Campaign
::addCampaignInComponentSearch($this);
68 'name' => ts('Search'),
74 public function postProcess() {
75 $params = $this->controller
->exportValues($this->_name
);
76 $parent = $this->controller
->getParent();
77 $parent->set('searchResult', 1);
78 if (!empty($params)) {
79 $fields = ['title', 'event_type_id', 'start_date', 'end_date', 'eventsByDates', 'campaign_id'];
80 foreach ($fields as $field) {
81 if (isset($params[$field]) &&
82 !CRM_Utils_System
::isNull($params[$field])
84 if ($field === 'end_date') {
85 $parent->set($field, $params[$field] . ' 23:59:59');
88 $parent->set($field, $params[$field]);
92 $parent->set($field, NULL);