/** * Build the form object. */ public function buildQuickForm() { //need to assign custom data type and subtype to the template $this->assign('customDataType', 'Event'); if ($this->_eventType) { $this->assign('customDataSubType', $this->_eventType); } $this->assign('entityId', $this->_id); $this->_first = TRUE; $this->applyFilter('__ALL__', 'trim'); $attributes = CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event'); if ($this->_isTemplate) { $this->add('text', 'template_title', ts('Template Title'), $attributes['template_title'], TRUE); } if ($this->_action & CRM_Core_Action::ADD) { $eventTemplates = CRM_Event_PseudoConstant::eventTemplates(); if (CRM_Utils_System::isNull($eventTemplates) && !$this->_isTemplate) { $url = CRM_Utils_System::url('civicrm/admin/eventTemplate', array('reset' => 1)); CRM_Core_Session::setStatus(ts('If you find that you are creating multiple events with similar settings, you may want to use the <a href="%1">Event Templates</a> feature to streamline your workflow.', array(1 => $url)), ts('Tip'), 'info'); } if (!CRM_Utils_System::isNull($eventTemplates)) { $this->add('select', 'template_id', ts('From Template'), array('' => ts('- select -')) + $eventTemplates, FALSE, array('class' => 'crm-select2 huge')); } // Make sure this form redirects properly $this->preventAjaxSubmit(); } // add event title, make required if this is not a template $this->add('text', 'title', ts('Event Title'), $attributes['event_title'], !$this->_isTemplate); $this->addSelect('event_type_id', array('onChange' => "CRM.buildCustomData( 'Event', this.value );"), TRUE); //CRM-7362 --add campaigns. $campaignId = NULL; if ($this->_id) { $campaignId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'campaign_id'); } CRM_Campaign_BAO_Campaign::addCampaign($this, $campaignId); $this->addSelect('default_role_id', array(), TRUE); $this->addSelect('participant_listing_id', array('placeholder' => ts('Disabled'), 'option_url' => NULL)); $this->add('textarea', 'summary', ts('Event Summary'), $attributes['summary']); $this->add('wysiwyg', 'description', ts('Complete Description'), $attributes['event_description']); $this->addElement('checkbox', 'is_public', ts('Public Event')); $this->addElement('checkbox', 'is_share', ts('Allow sharing through social media?')); $this->addElement('checkbox', 'is_map', ts('Include Map to Event Location')); $this->addDateTime('start_date', ts('Start Date'), FALSE, array('formatType' => 'activityDateTime')); $this->addDateTime('end_date', ts('End Date / Time'), FALSE, array('formatType' => 'activityDateTime')); $this->add('text', 'max_participants', ts('Max Number of Participants'), array('onchange' => "if (this.value != '') {cj('#id-waitlist').show(); showHideByValue('has_waitlist','0','id-waitlist-text','table-row','radio',false); showHideByValue('has_waitlist','0','id-event_full','table-row','radio',true); return;} else {cj('#id-event_full, #id-waitlist, #id-waitlist-text').hide(); return;}")); $this->addRule('max_participants', ts('Max participants should be a positive number'), 'positiveInteger'); $participantStatuses = CRM_Event_PseudoConstant::participantStatus(); $waitlist = 0; if (in_array('On waitlist', $participantStatuses) and in_array('Pending from waitlist', $participantStatuses)) { $this->addElement('checkbox', 'has_waitlist', ts('Offer a Waitlist?'), NULL, array('onclick' => "showHideByValue('has_waitlist','0','id-event_full','table-row','radio',true); showHideByValue('has_waitlist','0','id-waitlist-text','table-row','radio',false);")); $this->add('textarea', 'waitlist_text', ts('Waitlist Message'), $attributes['waitlist_text']); $waitlist = 1; } $this->assign('waitlist', $waitlist); $this->add('textarea', 'event_full_text', ts('Message if Event Is Full'), $attributes['event_full_text']); $this->addElement('checkbox', 'is_active', ts('Is this Event Active?')); $this->addFormRule(array('CRM_Event_Form_ManageEvent_EventInfo', 'formRule')); parent::buildQuickForm(); }
/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { if ($this->_cdType) { return CRM_Custom_Form_CustomData::buildQuickForm($this); } //need to assign custom data type and subtype to the template $this->assign('customDataType', 'Event'); if ($this->_eventType) { $this->assign('customDataSubType', $this->_eventType); } $this->assign('entityId', $this->_id); $this->_first = true; $this->applyFilter('__ALL__', 'trim'); $attributes = CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event'); if ($this->_isTemplate) { $this->add('text', 'template_title', ts('Template Title'), $attributes['template_title'], true); } if ($this->_action & CRM_Core_Action::ADD) { require_once 'CRM/Event/PseudoConstant.php'; $eventTemplates =& CRM_Event_PseudoConstant::eventTemplates(); if (CRM_Utils_System::isNull($eventTemplates)) { $this->assign('noEventTemplates', true); } else { $this->add('select', 'template_id', ts('From Template'), array('' => ts('- select -')) + $eventTemplates, false, array('onchange' => "reloadWindow( this.value );")); } } // add event title, make required if this is not a template $this->add('text', 'title', ts('Event Title'), $attributes['event_title'], !$this->_isTemplate); require_once 'CRM/Core/OptionGroup.php'; $event = CRM_Core_OptionGroup::values('event_type'); $this->add('select', 'event_type_id', ts('Event Type'), array('' => ts('- select -')) + $event, true, array('onChange' => "buildCustomData( 'Event', this.value );")); $participantRole = CRM_Core_OptionGroup::values('participant_role'); $this->add('select', 'default_role_id', ts('Participant Role'), $participantRole, true); $participantListing = CRM_Core_OptionGroup::values('participant_listing'); $this->add('select', 'participant_listing_id', ts('Participant Listing'), array('' => ts('Disabled')) + $participantListing, false); $this->add('textarea', 'summary', ts('Event Summary'), $attributes['summary']); $this->addWysiwyg('description', ts('Complete Description'), $attributes['event_description']); $this->addElement('checkbox', 'is_public', ts('Public Event?')); $this->addElement('checkbox', 'is_map', ts('Include Map to Event Location?')); $this->addDateTime('start_date', ts('Start Date'), false, array('formatType' => 'activityDateTime')); $this->addDateTime('end_date', ts('End Date / Time'), false, array('formatType' => 'activityDateTime')); $this->add('text', 'max_participants', ts('Max Number of Participants'), array('onchange' => "if (this.value != '') {show('id-waitlist','table-row'); showHideByValue('has_waitlist','0','id-waitlist-text','table-row','radio',false); showHideByValue('has_waitlist','0','id-event_full','table-row','radio',true); return;} else {hide('id-event_full','table-row'); hide('id-waitlist','table-row'); hide('id-waitlist-text','table-row'); return;}")); $this->addRule('max_participants', ts('Max participants should be a positive number'), 'positiveInteger'); require_once 'CRM/Event/PseudoConstant.php'; $participantStatuses =& CRM_Event_PseudoConstant::participantStatus(); if (in_array('On waitlist', $participantStatuses) and in_array('Pending from waitlist', $participantStatuses)) { $this->addElement('checkbox', 'has_waitlist', ts('Offer a Waitlist?'), null, array('onclick' => "showHideByValue('has_waitlist','0','id-event_full','table-row','radio',true); showHideByValue('has_waitlist','0','id-waitlist-text','table-row','radio',false);")); $this->add('textarea', 'waitlist_text', ts('Waitlist Message'), $attributes['waitlist_text']); } $this->add('textarea', 'event_full_text', ts('Message if Event Is Full'), $attributes['event_full_text']); $this->addElement('checkbox', 'is_active', ts('Is this Event Active?')); $this->addFormRule(array('CRM_Event_Form_ManageEvent_EventInfo', 'formRule')); parent::buildQuickForm(); }
/** * Retrieve list of Scheduled Reminders * * @param bool $namesOnly return simple list of names * * @param null $entityValue * @param null $id * * @return array (reference) reminder list * @static * @access public */ static function &getList($namesOnly = FALSE, $entityValue = NULL, $id = NULL) { $activity_type = CRM_Core_PseudoConstant::activityType(TRUE, TRUE); $activity_status = CRM_Core_PseudoConstant::activityStatus(); $event_type = CRM_Event_PseudoConstant::eventType(); $civicrm_event = CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )"); $civicrm_participant_status_type = CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label'); $event_template = CRM_Event_PseudoConstant::eventTemplates(); $civicrm_contact = self::getDateFields(); $auto_renew_options = CRM_Core_OptionGroup::values('auto_renew_options'); $contact_date_reminder_options = CRM_Core_OptionGroup::values('contact_date_reminder_options'); $civicrm_membership_type = CRM_Member_PseudoConstant::membershipType(); $entity = array('civicrm_activity' => 'Activity', 'civicrm_participant' => 'Event', 'civicrm_membership' => 'Member', 'civicrm_contact' => 'Contact'); $query = "\nSELECT\n title,\n cam.entity,\n cas.id as id,\n cam.entity_value as entityValue,\n cas.entity_value as entityValueIds,\n cam.entity_status as entityStatus,\n cas.entity_status as entityStatusIds,\n cas.start_action_date as entityDate,\n cas.start_action_offset,\n cas.start_action_unit,\n cas.start_action_condition,\n cas.absolute_date,\n is_repeat,\n is_active\n\nFROM civicrm_action_schedule cas\nLEFT JOIN civicrm_action_mapping cam ON (cam.id = cas.mapping_id)\n"; $params = CRM_Core_DAO::$_nullArray; if ($entityValue and $id) { $where = "\nWHERE cas.entity_value = {$id} AND\n cam.entity_value = '{$entityValue}'"; $query .= $where; $params = array(1 => array($id, 'Integer'), 2 => array($entityValue, 'String')); } $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { $list[$dao->id]['id'] = $dao->id; $list[$dao->id]['title'] = $dao->title; $list[$dao->id]['start_action_offset'] = $dao->start_action_offset; $list[$dao->id]['start_action_unit'] = $dao->start_action_unit; $list[$dao->id]['start_action_condition'] = $dao->start_action_condition; $list[$dao->id]['entityDate'] = ucwords(str_replace('_', ' ', $dao->entityDate)); $list[$dao->id]['absolute_date'] = $dao->absolute_date; $status = $dao->entityStatus; $statusArray = explode(CRM_Core_DAO::VALUE_SEPARATOR, $dao->entityStatusIds); foreach ($statusArray as &$s) { $s = CRM_Utils_Array::value($s, ${$status}); } $statusIds = implode(', ', $statusArray); $value = $dao->entityValue; $valueArray = explode(CRM_Core_DAO::VALUE_SEPARATOR, $dao->entityValueIds); foreach ($valueArray as &$v) { $v = CRM_Utils_Array::value($v, ${$value}); } $valueIds = implode(', ', $valueArray); $list[$dao->id]['entity'] = $entity[$dao->entity]; $list[$dao->id]['value'] = $valueIds; $list[$dao->id]['status'] = $statusIds; $list[$dao->id]['is_repeat'] = $dao->is_repeat; $list[$dao->id]['is_active'] = $dao->is_active; } return $list; }
protected static function getValueLabelMap($name) { static $valueLabelMap = NULL; if ($valueLabelMap === NULL) { $valueLabelMap['activity_type'] = \CRM_Core_PseudoConstant::activityType(TRUE, TRUE); asort($valueLabelMap['activity_type']); $valueLabelMap['activity_status'] = \CRM_Core_PseudoConstant::activityStatus(); $valueLabelMap['event_type'] = \CRM_Event_PseudoConstant::eventType(); $valueLabelMap['civicrm_event'] = \CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )"); $valueLabelMap['civicrm_participant_status_type'] = \CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label'); $valueLabelMap['event_template'] = \CRM_Event_PseudoConstant::eventTemplates(); $valueLabelMap['auto_renew_options'] = \CRM_Core_OptionGroup::values('auto_renew_options'); $valueLabelMap['contact_date_reminder_options'] = \CRM_Core_OptionGroup::values('contact_date_reminder_options'); $valueLabelMap['civicrm_membership_type'] = \CRM_Member_PseudoConstant::membershipType(); $allCustomFields = \CRM_Core_BAO_CustomField::getFields(''); $dateFields = array('birth_date' => ts('Birth Date'), 'created_date' => ts('Created Date'), 'modified_date' => ts('Modified Date')); foreach ($allCustomFields as $fieldID => $field) { if ($field['data_type'] == 'Date') { $dateFields["custom_{$fieldID}"] = $field['label']; } } $valueLabelMap['civicrm_contact'] = $dateFields; } return $valueLabelMap[$name]; }