/** * Build the form * * @access public * * @return void */ function buildQuickForm() { // text for sort_name or email criteria $config = CRM_Core_Config::singleton(); $label = empty($config->includeEmailInName) ? ts('Name') : ts('Name or Email'); $this->add('text', 'sort_name', $label); $searchOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'advanced_search_options'); if (!empty($searchOptions['contactType'])) { $contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements(); $this->add('select', 'contact_type', ts('is...'), $contactTypes); } if (!empty($searchOptions['groups'])) { // Arrange groups into hierarchical listing (child groups follow their parents and have indentation spacing in title) $groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($this->_group, NULL, ' ', TRUE); // add select for groups $group = array('' => ts('- any group -')) + $groupHierarchy; $this->_groupElement =& $this->addElement('select', 'group', ts('in'), $group); } if (!empty($searchOptions['tags'])) { // tag criteria if (!empty($this->_tag)) { $tag = array('' => ts('- any tag -')) + $this->_tag; $this->_tagElement =& $this->addElement('select', 'tag', ts('with'), $tag); } } parent::buildQuickForm(); }
/** * Build the form object. * * * @return void */ public function buildQuickForm() { // text for sort_name or email criteria $config = CRM_Core_Config::singleton(); $label = empty($config->includeEmailInName) ? ts('Name') : ts('Name or Email'); $this->add('text', 'sort_name', $label); $searchOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'advanced_search_options'); $shortCuts = array(); //@todo FIXME - using the CRM_Core_DAO::VALUE_SEPARATOR creates invalid html - if you can find the form // this is loaded onto then replace with something like '__' & test $separator = CRM_Core_DAO::VALUE_SEPARATOR; if (!empty($searchOptions['contactType'])) { $contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator); $this->add('select', 'contact_type', ts('is...'), $contactTypes, FALSE, array('class' => 'crm-select2')); } // add select for groups if (!empty($searchOptions['groups'])) { $this->addSelect('group', array('entity' => 'group_contact', 'label' => ts('in'), 'context' => 'search', 'placeholder' => ts('- any group -'))); } if (!empty($searchOptions['tags'])) { // tag criteria if (!empty($this->_tag)) { $this->addSelect('tag', array('entity' => 'entity_tag', 'label' => ts('with'), 'context' => 'search', 'placeholder' => ts('- any tag -'))); } } parent::buildQuickForm(); }
/** * Build the form object. */ public function buildQuickForm() { $this->addSortNameField(); $searchOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'advanced_search_options'); if (!empty($searchOptions['contactType'])) { $contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements(); $this->add('select', 'contact_type', ts('is...'), $contactTypes, FALSE, array('class' => 'crm-select2')); } // add select for groups if (!empty($searchOptions['groups'])) { $this->addField('group', array('entity' => 'group_contact', 'label' => ts('in'), 'placeholder' => ts('- any group -'))); } if (!empty($searchOptions['tags'])) { // tag criteria if (!empty($this->_tag)) { $this->addField('tag', array('entity' => 'entity_tag', 'label' => ts('with'), 'placeholder' => ts('- any tag -'))); } } parent::buildQuickForm(); }
/** * Build the form object. */ public function buildQuickForm() { // text for sort_name or email criteria $config = CRM_Core_Config::singleton(); $label = empty($config->includeEmailInName) ? ts('Name') : ts('Name or Email'); $this->add('text', 'sort_name', $label); $searchOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'advanced_search_options'); if (!empty($searchOptions['contactType'])) { $contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements(); $this->add('select', 'contact_type', ts('is...'), $contactTypes, FALSE, array('class' => 'crm-select2')); } // add select for groups if (!empty($searchOptions['groups'])) { $this->addSelect('group', array('entity' => 'group_contact', 'label' => ts('in'), 'context' => 'search', 'placeholder' => ts('- any group -'))); } if (!empty($searchOptions['tags'])) { // tag criteria if (!empty($this->_tag)) { $this->addSelect('tag', array('entity' => 'entity_tag', 'label' => ts('with'), 'context' => 'search', 'placeholder' => ts('- any tag -'))); } } parent::buildQuickForm(); }
/** * Build the form * * @access public * * @return void */ function buildQuickForm() { $this->set('context', 'advanced'); $this->_searchPane = CRM_Utils_Array::value('searchPane', $_GET); $this->_searchOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'advanced_search_options'); if (!$this->_searchPane || $this->_searchPane == 'basic') { CRM_Contact_Form_Search_Criteria::basic($this); } $allPanes = array(); $paneNames = array(ts('Address Fields') => 'location', ts('Custom Fields') => 'custom', ts('Activities') => 'activity', ts('Relationships') => 'relationship', ts('Demographics') => 'demographics', ts('Notes') => 'notes', ts('Change Log') => 'changeLog'); //check if there are any custom data searchable fields $groupDetails = array(); $extends = array_merge(array('Contact', 'Individual', 'Household', 'Organization'), CRM_Contact_BAO_ContactType::subTypes()); $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends); // if no searchable fields unset panel if (empty($groupDetails)) { unset($paneNames[ts('Custom Fields')]); } foreach ($paneNames as $name => $type) { if (!$this->_searchOptions[$type]) { unset($paneNames[$name]); } } $components = CRM_Core_Component::getEnabledComponents(); $componentPanes = array(); foreach ($components as $name => $component) { if (in_array($name, array_keys($this->_searchOptions)) && $this->_searchOptions[$name] && CRM_Core_Permission::access($component->name)) { $componentPanes[$name] = $component->registerAdvancedSearchPane(); $componentPanes[$name]['name'] = $name; } } usort($componentPanes, array('CRM_Utils_Sort', 'cmpFunc')); foreach ($componentPanes as $name => $pane) { // FIXME: we should change the use of $name here to keyword $paneNames[$pane['title']] = $pane['name']; } $hookPanes = array(); CRM_Contact_BAO_Query_Hook::singleton()->registerAdvancedSearchPane($hookPanes); $paneNames = array_merge($paneNames, $hookPanes); $this->_paneTemplatePath = array(); foreach ($paneNames as $name => $type) { if (!array_key_exists($type, $this->_searchOptions) && !in_array($type, $hookPanes)) { continue; } $allPanes[$name] = array('url' => CRM_Utils_System::url('civicrm/contact/search/advanced', "snippet=1&searchPane={$type}&qfKey={$this->controller->_key}"), 'open' => 'false', 'id' => $type); // see if we need to include this paneName in the current form if ($this->_searchPane == $type || CRM_Utils_Array::value("hidden_{$type}", $_POST) || CRM_Utils_Array::value("hidden_{$type}", $this->_formValues)) { $allPanes[$name]['open'] = 'true'; if (CRM_Utils_Array::value($type, $components)) { $c = $components[$type]; $this->add('hidden', "hidden_{$type}", 1); $c->buildAdvancedSearchPaneForm($this); $this->_paneTemplatePath[$type] = $c->getAdvancedSearchPaneTemplatePath(); } else { if (in_array($type, $hookPanes)) { CRM_Contact_BAO_Query_Hook::singleton()->buildAdvancedSearchPaneForm($this, $type); CRM_Contact_BAO_Query_Hook::singleton()->setAdvancedSearchPaneTemplatePath($this->_paneTemplatePath, $type); } else { CRM_Contact_Form_Search_Criteria::$type($this); $template = ucfirst($type); $this->_paneTemplatePath[$type] = "CRM/Contact/Form/Search/Criteria/{$template}.tpl"; } } } } $this->assign('allPanes', $allPanes); if (!$this->_searchPane) { parent::buildQuickForm(); } else { $this->assign('suppressForm', TRUE); } }
public function buildQuickForm() { $fields = self::fields(); // Get fields of type date // FIXME: This is a hack until our fields contain this meta-data $dateFields = array(); foreach ($fields as $name => $field) { if (strpos($name, '_date') || CRM_Utils_Array::value('data_type', $field) == 'Date') { $dateFields[] = $name; } } // Add javascript CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Contact/Form/Search/Builder.js')->addSetting(array('searchBuilder' => array('newBlock' => $this->get('newBlock'), 'dateFields' => $dateFields, 'fieldOptions' => self::fieldOptions()))); //get the saved search mapping id $mappingId = NULL; if ($this->_ssID) { $mappingId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID, 'mapping_id'); } CRM_Core_BAO_Mapping::buildMappingForm($this, 'Search Builder', $mappingId, $this->_columnCount, $this->_blockCount); parent::buildQuickForm(); }
function buildQuickForm() { $this->_customClass->buildForm($this); parent::buildQuickForm(); }
/** * Build the form * * @access public * @return void */ function buildQuickForm() { // text for sort_name or email criteria $this->add('text', 'sort_name', ts('Name or Email')); require_once 'CRM/Core/BAO/Preferences.php'; $searchOptions = CRM_Core_BAO_Preferences::valueOptions('advanced_search_options'); if (CRM_Utils_Array::value('contactType', $searchOptions)) { require_once 'CRM/Contact/BAO/ContactType.php'; $contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements(); $this->add('select', 'contact_type', ts('is...'), $contactTypes); } if (CRM_Utils_Array::value('groups', $searchOptions)) { $config =& CRM_Core_Config::singleton(); if ($config->groupTree) { $this->add('hidden', 'group', null, array('id' => 'group')); $group = CRM_Utils_Array::value('group', $this->_formValues); $selectedGroups = explode(',', $group); if (is_array($selectedGroups)) { $groupNames = null; $groupIds = array(); foreach ($selectedGroups as $groupId) { if ($groupNames) { $groupNames .= '<br/>'; } $groupNames .= $this->_group[$groupId]; } $groupIds[] = $groupId; } $this->assign('groupIds', implode(',', $groupIds)); $this->assign('groupNames', $groupNames); } else { // add select for groups $group = array('' => ts('- any group -')) + $this->_group; $this->_groupElement =& $this->addElement('select', 'group', ts('in'), $group); } } if (CRM_Utils_Array::value('tags', $searchOptions)) { // tag criteria $tag = array('' => ts('- any tag -')) + $this->_tag; $this->_tagElement =& $this->addElement('select', 'tag', ts('with'), $tag); } parent::buildQuickForm(); }
public function buildQuickForm() { //get the saved search mapping id $mappingId = null; if ($this->_ssID) { $mappingId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID, 'mapping_id'); } CRM_Core_BAO_Mapping::buildMappingForm($this, 'Search Builder', $mappingId, $this->_columnCount, $this->_blockCount); parent::buildQuickForm(); }
/** * Build the form * * @access public * * @return void */ function buildQuickForm() { // text for sort_name or email criteria $config = CRM_Core_Config::singleton(); $label = empty($config->includeEmailInName) ? ts('Name') : ts('Name or Email'); $this->add('text', 'sort_name', $label); $searchOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'advanced_search_options'); if (CRM_Utils_Array::value('contactType', $searchOptions)) { $contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements(); $this->add('select', 'contact_type', ts('is...'), $contactTypes); } if (CRM_Utils_Array::value('groups', $searchOptions)) { if ($config->groupTree) { $this->add('hidden', 'group', NULL, array('id' => 'group')); $group = CRM_Utils_Array::value('group', $this->_formValues); $selectedGroups = explode(',', $group); if (is_array($selectedGroups)) { $groupNames = NULL; $groupIds = array(); foreach ($selectedGroups as $groupId) { if ($groupNames) { $groupNames .= '<br/>'; } $groupNames .= $this->_group[$groupId]; } $groupIds[] = $groupId; } $this->assign('groupIds', implode(',', $groupIds)); $this->assign('groupNames', $groupNames); } else { // add select for groups $group = array('' => ts('- any group -')) + $this->_group; $this->_groupElement =& $this->addElement('select', 'group', ts('in'), $group); } } if (CRM_Utils_Array::value('tags', $searchOptions)) { // tag criteria if (!empty($this->_tag)) { $tag = array('' => ts('- any tag -')) + $this->_tag; $this->_tagElement =& $this->addElement('select', 'tag', ts('with'), $tag); } } parent::buildQuickForm(); }
/** * Build the form * * @access public * * @return void */ function buildQuickForm() { // text for sort_name or email criteria $config = CRM_Core_Config::singleton(); $label = empty($config->includeEmailInName) ? ts('Name') : ts('Name or Email'); $this->add('text', 'sort_name', $label); $searchOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'advanced_search_options'); $shortCuts = array(); //@todo FIXME - using the CRM_Core_DAO::VALUE_SEPARATOR creates invalid html - if you can find the form // this is loaded onto then replace with something like '__' & test $separator = CRM_Core_DAO::VALUE_SEPARATOR; if (!empty($searchOptions['contactType'])) { $contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator); $this->add('select', 'contact_type', ts('is...'), $contactTypes, FALSE, array('class' => 'crm-select2')); } if (!empty($searchOptions['groups'])) { // Arrange groups into hierarchical listing (child groups follow their parents and have indentation spacing in title) $groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($this->_group, NULL, ' ', TRUE); // add select for groups $group = array('' => ts('- any group -')) + $groupHierarchy; $this->add('select', 'group', ts('in'), $group, FALSE, array('class' => 'crm-select2')); } if (!empty($searchOptions['tags'])) { // tag criteria if (!empty($this->_tag)) { $tag = array('' => ts('- any tag -')) + $this->_tag; $this->add('select', 'tag', ts('with'), $tag, FALSE, array('class' => 'crm-select2')); } } parent::buildQuickForm(); }
/** * Build quick form. */ public function buildQuickForm() { $fields = self::fields(); // Get fields of type date // FIXME: This is a hack until our fields contain this meta-data $dateFields = array(); $stringFields = array(); $searchByLabelFields = array(); foreach ($fields as $name => $field) { if (strpos($name, '_date') || CRM_Utils_Array::value('data_type', $field) == 'Date') { $dateFields[] = $name; } // it's necessary to know which of the fields are from string data type if (isset($field['type']) && $field['type'] === CRM_Utils_Type::T_STRING) { $stringFields[] = $name; } // it's necessary to know which of the fields are searchable by label if (isset($field['searchByLabel']) && $field['searchByLabel']) { $searchByLabelFields[] = $name; } } // Add javascript CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Contact/Form/Search/Builder.js', 1, 'html-header')->addSetting(array('searchBuilder' => array('newBlock' => $this->get('newBlock'), 'dateFields' => $dateFields, 'fieldOptions' => self::fieldOptions(), 'stringFields' => $stringFields, 'searchByLabelFields' => $searchByLabelFields, 'generalOperators' => array('' => ts('-operator-')) + CRM_Core_SelectValues::getSearchBuilderOperators(), 'stringOperators' => array('' => ts('-operator-')) + CRM_Core_SelectValues::getSearchBuilderOperators(CRM_Utils_Type::T_STRING)))); //get the saved search mapping id $mappingId = NULL; if ($this->_ssID) { $mappingId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID, 'mapping_id'); } CRM_Core_BAO_Mapping::buildMappingForm($this, 'Search Builder', $mappingId, $this->_columnCount, $this->_blockCount); parent::buildQuickForm(); }