コード例 #1
0
 function __construct()
 {
     $contact_type = CRM_Contact_BAO_ContactType::getSelectElements(false, true, '_');
     $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('display_name_a' => array('title' => ts('Contact A'), 'name' => 'display_name', 'required' => true), 'id' => array('no_display' => true, 'required' => true)), 'filters' => array('sort_name_a' => array('title' => ts('Contact A'), 'name' => 'sort_name', 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING)), 'grouping' => 'conact_a_fields'), 'civicrm_contact_b' => array('dao' => 'CRM_Contact_DAO_Contact', 'alias' => 'contact_b', 'fields' => array('display_name_b' => array('title' => ts('Contact B'), 'name' => 'display_name', 'required' => true), 'id' => array('no_display' => true, 'required' => true)), 'filters' => array('sort_name_b' => array('title' => ts('Contact B'), 'name' => 'sort_name', 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING)), 'grouping' => 'conact_b_fields'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email_a' => array('title' => ts('Email of Contact A'), 'name' => 'email')), 'grouping' => 'conact_a_fields'), 'civicrm_email_b' => array('dao' => 'CRM_Core_DAO_Email', 'alias' => 'email_b', 'fields' => array('email_b' => array('title' => ts('Email of Contact B'), 'name' => 'email')), 'grouping' => 'conact_b_fields'), 'civicrm_relationship_type' => array('dao' => 'CRM_Contact_DAO_RelationshipType', 'fields' => array('label_a_b' => array('title' => ts('Relationship A-B '), 'default' => true), 'label_b_a' => array('title' => ts('Relationship B-A '), 'default' => true)), 'filters' => array('contact_type_a' => array('title' => ts('Contact Type  A'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $contact_type, 'type' => CRM_Utils_Type::T_STRING), 'contact_type_b' => array('title' => ts('Contact Type  B'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $contact_type, 'type' => CRM_Utils_Type::T_STRING)), 'grouping' => 'relation-fields'), 'civicrm_relationship' => array('dao' => 'CRM_Contact_DAO_Relationship', 'fields' => array('start_date' => array('title' => ts('Relationship Start Date')), 'end_date' => array('title' => ts('Relationship End Date')), 'description' => array('title' => ts('Description'))), 'filters' => array('is_active' => array('title' => ts('Relationship Status'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array('' => '- Any -', 1 => 'Active', 0 => 'Inactive'), 'type' => CRM_Utils_Type::T_INT), 'relationship_type_id' => array('title' => ts('Relationship'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array('' => '- any relationship type -') + CRM_Contact_BAO_Relationship::getContactRelationshipType(null, 'null', null, null, true), 'type' => CRM_Utils_Type::T_INT)), 'grouping' => 'relation-fields'), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'filters' => array('country_id' => array('title' => ts('Country'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country()), 'state_province_id' => array('title' => ts('State/Province'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::stateProvince())), 'grouping' => 'contact-fields'), 'civicrm_group' => array('dao' => 'CRM_Contact_DAO_Group', 'alias' => 'cgroup', 'filters' => array('gid' => array('name' => 'group_id', 'title' => ts('Group'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'group' => true, 'options' => CRM_Core_PseudoConstant::group()))));
     $this->_tagFilter = true;
     parent::__construct();
 }
コード例 #2
0
ファイル: Basic.php プロジェクト: vincent1892/contact_report
 /**
  * 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();
 }
コード例 #3
0
 /**
  * Function to build the form
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     $this->setPageTitle(ts('Relationship Type'));
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     $this->applyFilter('__ALL__', 'trim');
     $this->add('text', 'label_a_b', ts('Relationship Label-A to B'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_RelationshipType', 'label_a_b'), TRUE);
     $this->addRule('label_a_b', ts('Label already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_RelationshipType', $this->_id, 'label_a_b'));
     $this->add('text', 'label_b_a', ts('Relationship Label-B to A'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_RelationshipType', 'label_b_a'));
     $this->addRule('label_b_a', ts('Label already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_RelationshipType', $this->_id, 'label_b_a'));
     $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_RelationshipType', 'description'));
     $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, '__');
     // add select for contact type
     $contactTypeA =& $this->add('select', 'contact_types_a', ts('Contact Type A') . ' ', array('' => ts('All Contacts')) + $contactTypes);
     $contactTypeB =& $this->add('select', 'contact_types_b', ts('Contact Type B') . ' ', array('' => ts('All Contacts')) + $contactTypes);
     $isActive =& $this->add('checkbox', 'is_active', ts('Enabled?'));
     //only selected field should be allow for edit, CRM-4888
     if ($this->_id && CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $this->_id, 'is_reserved')) {
         foreach (array('contactTypeA', 'contactTypeB', 'isActive') as $field) {
             ${$field}->freeze();
         }
     }
     if ($this->_action & CRM_Core_Action::VIEW) {
         $this->freeze();
     }
 }
コード例 #4
0
ファイル: Basic.php プロジェクト: prashantgajare/civicrm-core
 /**
  * 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();
 }
コード例 #5
0
 /**
  * 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();
 }
コード例 #6
0
ファイル: RelationshipType.php プロジェクト: bhirsch/voipdev
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     $this->applyFilter('__ALL__', 'trim');
     $this->add('text', 'label_a_b', ts('Relationship Label-A to B'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_RelationshipType', 'label_a_b'), true);
     $this->addRule('label_a_b', ts('Label already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_RelationshipType', $this->_id, 'label_a_b'));
     $this->add('text', 'label_b_a', ts('Relationship Label-B to A'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_RelationshipType', 'label_b_a'));
     $this->addRule('label_b_a', ts('Label already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_RelationshipType', $this->_id, 'label_b_a'));
     $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_RelationshipType', 'description'));
     require_once 'CRM/Contact/BAO/ContactType.php';
     $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements();
     // add select for contact type
     $contactTypeA =& $this->add('select', 'contact_types_a', ts('Contact Type A') . ' ', array('' => ts('- select -')) + $contactTypes);
     $contactTypeB =& $this->add('select', 'contact_types_b', ts('Contact Type B') . ' ', array('' => ts('- select -')) + $contactTypes);
     $isActive =& $this->add('checkbox', 'is_active', ts('Enabled?'));
     //only selected field should be allow for edit, CRM-4888
     if ($this->_id && CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $this->_id, 'is_reserved')) {
         foreach (array('contactTypeA', 'contactTypeB', 'isActive') as $field) {
             ${$field}->freeze();
         }
     }
     if ($this->_action & CRM_Core_Action::VIEW) {
         $this->freeze();
         $url = CRM_Utils_System::url('civicrm/admin/reltype&reset=1');
         $location = "window.location='{$url}'";
         $this->addElement('button', 'done', ts('Done'), array('onclick' => $location));
     }
 }
コード例 #7
0
ファイル: MultipleValues.php プロジェクト: hguru/224Civi
 function buildForm(&$form)
 {
     /**
      * You can define a custom title for the search form
      */
     $this->setTitle('Multiple Value Custom Group Search and Export');
     $form->add('text', 'sort_name', ts('Contact Name'), TRUE);
     // add select for contact type
     $contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements();
     $form->add('select', 'contact_type', ts('Find...'), $contactTypes);
     // add select for groups
     $group = array('' => ts('- any group -')) + CRM_Core_PseudoConstant::group();
     $form->addElement('select', 'group', ts('in'), $group);
     // add select for tags
     $tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
     $form->addElement('select', 'tag', ts('Tagged'), $tag);
     if (empty($this->_groupTree)) {
         CRM_Core_Error::statusBounce(ts("Atleast one Custom Group must be present, for Custom Group search."), CRM_Utils_System::url('civicrm/contact/search/custom/list', 'reset=1'));
     }
     // add the checkbox for custom_groups
     foreach ($this->_groupTree as $groupID => $group) {
         if ($groupID == 'info') {
             continue;
         }
         $form->addElement('checkbox', "custom_group[{$groupID}]", NULL, $group['title']);
     }
 }
コード例 #8
0
ファイル: Relationship.php プロジェクト: hyebahi/civicrm-core
 /**
  * Class constructor.
  */
 public function __construct()
 {
     $contact_type = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, '_');
     $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('sort_name_a' => array('title' => ts('Contact A'), 'name' => 'sort_name', 'required' => TRUE), 'id' => array('no_display' => TRUE, 'required' => TRUE), 'contact_type_a' => array('title' => ts('Contact Type (Contact A)'), 'name' => 'contact_type'), 'contact_sub_type_a' => array('title' => ts('Contact Subtype (Contact A)'), 'name' => 'contact_sub_type')), 'filters' => array('sort_name_a' => array('title' => ts('Contact A'), 'name' => 'sort_name', 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING), 'contact_type_a' => array('title' => ts('Contact Type A'), 'name' => 'contact_type', 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $contact_type, 'type' => CRM_Utils_Type::T_STRING)), 'grouping' => 'contact_a_fields'), 'civicrm_contact_b' => array('dao' => 'CRM_Contact_DAO_Contact', 'alias' => 'contact_b', 'fields' => array('sort_name_b' => array('title' => ts('Contact B'), 'name' => 'sort_name', 'required' => TRUE), 'id' => array('no_display' => TRUE, 'required' => TRUE), 'contact_type_b' => array('title' => ts('Contact Type (Contact B)'), 'name' => 'contact_type'), 'contact_sub_type_b' => array('title' => ts('Contact Subtype (Contact B)'), 'name' => 'contact_sub_type')), 'filters' => array('sort_name_b' => array('title' => ts('Contact B'), 'name' => 'sort_name', 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING), 'contact_type_b' => array('title' => ts('Contact Type B'), 'name' => 'contact_type', 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $contact_type, 'type' => CRM_Utils_Type::T_STRING)), 'grouping' => 'contact_b_fields'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email_a' => array('title' => ts('Email (Contact A)'), 'name' => 'email')), 'grouping' => 'contact_a_fields'), 'civicrm_email_b' => array('dao' => 'CRM_Core_DAO_Email', 'alias' => 'email_b', 'fields' => array('email_b' => array('title' => ts('Email (Contact B)'), 'name' => 'email')), 'grouping' => 'contact_b_fields'), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'alias' => 'phone_a', 'fields' => array('phone_a' => array('title' => ts('Phone (Contact A)'), 'name' => 'phone'), 'phone_ext_a' => array('title' => ts('Phone Ext (Contact A)'), 'name' => 'phone_ext')), 'grouping' => 'contact_a_fields'), 'civicrm_phone_b' => array('dao' => 'CRM_Core_DAO_Phone', 'alias' => 'phone_b', 'fields' => array('phone_b' => array('title' => ts('Phone (Contact B)'), 'name' => 'phone'), 'phone_ext_b' => array('title' => ts('Phone Ext (Contact B)'), 'name' => 'phone_ext')), 'grouping' => 'contact_b_fields'), 'civicrm_relationship_type' => array('dao' => 'CRM_Contact_DAO_RelationshipType', 'fields' => array('label_a_b' => array('title' => ts('Relationship A-B '), 'default' => TRUE), 'label_b_a' => array('title' => ts('Relationship B-A '), 'default' => TRUE)), 'grouping' => 'relation-fields'), 'civicrm_relationship' => array('dao' => 'CRM_Contact_DAO_Relationship', 'fields' => array('start_date' => array('title' => ts('Relationship Start Date')), 'end_date' => array('title' => ts('Relationship End Date')), 'description' => array('title' => ts('Description')), 'relationship_id' => array('title' => ts('Rel ID'), 'name' => 'id')), 'filters' => array('is_active' => array('title' => ts('Relationship Status'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array('' => '- Any -', 1 => 'Active', 0 => 'Inactive'), 'type' => CRM_Utils_Type::T_INT), 'is_valid' => array('title' => ts('Relationship Dates Validity'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array(NULL => ts('- Any -'), 1 => ts('Not expired'), 0 => ts('Expired')), 'type' => CRM_Utils_Type::T_INT), 'relationship_type_id' => array('title' => ts('Relationship'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, NULL, TRUE), 'type' => CRM_Utils_Type::T_INT), 'start_date' => array('title' => ts('Start Date'), 'type' => CRM_Utils_Type::T_DATE), 'end_date' => array('title' => ts('End Date'), 'type' => CRM_Utils_Type::T_DATE)), 'grouping' => 'relation-fields'), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'filters' => array('country_id' => array('title' => ts('Country'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country()), 'state_province_id' => array('title' => ts('State/Province'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::stateProvince())), 'grouping' => 'contact-fields'));
     $this->_groupFilter = TRUE;
     $this->_tagFilter = TRUE;
     parent::__construct();
 }
コード例 #9
0
ファイル: Basic.php プロジェクト: hguru/224Civi
 function buildForm(&$form)
 {
     $contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements();
     $form->add('select', 'contact_type', ts('Find...'), $contactTypes);
     // add select for groups
     $group = array('' => ts('- any group -')) + CRM_Core_PseudoConstant::group();
     $form->addElement('select', 'group', ts('in'), $group);
     // add select for categories
     $tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
     $form->addElement('select', 'tag', ts('Tagged'), $tag);
     // text for sort_name
     $form->add('text', 'sort_name', ts('Name'));
     $form->assign('elements', array('sort_name', 'contact_type', 'group', 'tag'));
 }
コード例 #10
0
ファイル: Basic.php プロジェクト: hampelm/Ginsberg-CiviDemo
 /**
  * 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
         if (!empty($this->_tag)) {
             $tag = array('' => ts('- any tag -')) + $this->_tag;
             $this->_tagElement =& $this->addElement('select', 'tag', ts('with'), $tag);
         }
     }
     parent::buildQuickForm();
 }
コード例 #11
0
 /**
  * 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();
 }
コード例 #12
0
ファイル: Basic.php プロジェクト: nielosz/civicrm-core
 /**
  * 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();
 }
コード例 #13
0
ファイル: Basic.php プロジェクト: nyimbi/civicrm-core
 /**
  * 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();
 }
コード例 #14
0
ファイル: Criteria.php プロジェクト: kidaa30/yes
 /**
  * @param CRM_Core_Form $form
  */
 public static function basic(&$form)
 {
     $form->addElement('hidden', 'hidden_basic', 1);
     if ($form->_searchOptions['contactType']) {
         // add checkboxes for contact type
         //@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;
         $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator);
         if ($contactTypes) {
             $form->add('select', 'contact_type', ts('Contact Type(s)'), $contactTypes, FALSE, array('id' => 'contact_type', 'multiple' => 'multiple', 'class' => 'crm-select2', 'style' => 'width: 100%;'));
         }
     }
     if ($form->_searchOptions['groups']) {
         // multiselect for groups
         if ($form->_group) {
             // Arrange groups into hierarchical listing (child groups follow their parents and have indentation spacing in title)
             $groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($form->_group, NULL, '&nbsp;&nbsp;', TRUE);
             $form->add('select', 'group', ts('Groups'), $groupHierarchy, FALSE, array('id' => 'group', 'multiple' => 'multiple', 'class' => 'crm-select2'));
             $groupOptions = CRM_Core_BAO_OptionValue::getOptionValuesAssocArrayFromName('group_type');
             $form->add('select', 'group_type', ts('Group Types'), $groupOptions, FALSE, array('id' => 'group_type', 'multiple' => 'multiple', 'class' => 'crm-select2'));
             $form->add('hidden', 'group_search_selected', 'group');
         }
     }
     if ($form->_searchOptions['tags']) {
         // multiselect for categories
         $contactTags = CRM_Core_BAO_Tag::getTags();
         if ($contactTags) {
             $form->add('select', 'contact_tags', ts('Tags'), $contactTags, FALSE, array('id' => 'contact_tags', 'multiple' => 'multiple', 'class' => 'crm-select2', 'style' => 'width: 100%;'));
         }
         $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
         CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', NULL, TRUE, FALSE);
         $used_for = CRM_Core_OptionGroup::values('tag_used_for');
         $tagsTypes = array();
         $showAllTagTypes = FALSE;
         foreach ($used_for as $key => $value) {
             //check tags for every type and find if there are any defined
             $tags = CRM_Core_BAO_Tag::getTagsUsedFor($key, FALSE, TRUE, NULL);
             // check if there are tags other than contact type, if no - keep checkbox hidden on adv search
             // we will hide searching contact by attachments tags until it will be implemented in core
             if (count($tags) && $key != 'civicrm_file' && $key != 'civicrm_contact') {
                 //if tags exists then add type to display in adv search form help text
                 $tagsTypes[] = ts($value);
                 $showAllTagTypes = TRUE;
             }
         }
         $tagTypesText = implode(" or ", $tagsTypes);
         if ($showAllTagTypes) {
             $form->add('checkbox', 'all_tag_types', ts('Include tags used for %1', array(1 => $tagTypesText)));
             $form->add('hidden', 'tag_types_text', $tagTypesText);
         }
     }
     // add text box for last name, first name, street name, city
     $form->addElement('text', 'sort_name', ts('Find...'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     // add text box for last name, first name, street name, city
     $form->add('text', 'email', ts('Contact Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     //added contact source
     $form->add('text', 'contact_source', ts('Contact Source'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'contact_source'));
     //added job title
     $form->addElement('text', 'job_title', ts('Job Title'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'job_title'));
     //added internal ID
     $form->addElement('text', 'contact_id', ts('Contact ID'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'id'));
     $form->addRule('contact_id', ts('Please enter valid Contact ID'), 'positiveInteger');
     //added external ID
     $form->addElement('text', 'external_identifier', ts('External ID'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'external_identifier'));
     if (CRM_Core_Permission::check('access deleted contacts') and CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_undelete', NULL)) {
         $form->add('checkbox', 'deleted_contacts', ts('Search in Trash') . '<br />' . ts('(deleted contacts)'));
     }
     // add checkbox for cms users only
     $form->addYesNo('uf_user', ts('CMS User?'), TRUE);
     // tag all search
     $form->add('text', 'tag_search', ts('All Tags'));
     // add search profiles
     // FIXME: This is probably a part of profiles - need to be
     // FIXME: eradicated from here when profiles are reworked.
     $types = array('Participant', 'Contribution', 'Membership');
     // get component profiles
     $componentProfiles = array();
     $componentProfiles = CRM_Core_BAO_UFGroup::getProfiles($types);
     $ufGroups = CRM_Core_BAO_UFGroup::getModuleUFGroup('Search Profile', 1);
     $accessibleUfGroups = CRM_Core_Permission::ufGroup(CRM_Core_Permission::VIEW);
     $searchProfiles = array();
     foreach ($ufGroups as $key => $var) {
         if (!array_key_exists($key, $componentProfiles) && in_array($key, $accessibleUfGroups)) {
             $searchProfiles[$key] = $var['title'];
         }
     }
     $form->add('select', 'uf_group_id', ts('Search Views'), array('0' => ts('- default view -')) + $searchProfiles, FALSE, array('class' => 'crm-select2'));
     $componentModes = CRM_Contact_Form_Search::getModeSelect();
     // unset contributions or participants if user does not have
     // permission on them
     if (!CRM_Core_Permission::access('CiviContribute')) {
         unset($componentModes['2']);
     }
     if (!CRM_Core_Permission::access('CiviEvent')) {
         unset($componentModes['3']);
     }
     if (!CRM_Core_Permission::access('CiviMember')) {
         unset($componentModes['5']);
     }
     if (!CRM_Core_Permission::check('view all activities')) {
         unset($componentModes['4']);
     }
     if (count($componentModes) > 1) {
         $form->add('select', 'component_mode', ts('Display Results As'), $componentModes, FALSE, array('class' => 'crm-select2'));
     }
     $form->addRadio('operator', ts('Search Operator'), array('AND' => ts('AND'), 'OR' => ts('OR')), array('allowClear' => FALSE));
     // add the option to display relationships
     $rTypes = CRM_Core_PseudoConstant::relationshipType();
     $rSelect = array('' => ts('- Select Relationship Type-'));
     foreach ($rTypes as $rid => $rValue) {
         if ($rValue['label_a_b'] == $rValue['label_b_a']) {
             $rSelect[$rid] = $rValue['label_a_b'];
         } else {
             $rSelect["{$rid}_a_b"] = $rValue['label_a_b'];
             $rSelect["{$rid}_b_a"] = $rValue['label_b_a'];
         }
     }
     $form->addElement('select', 'display_relationship_type', ts('Display Results as Relationship'), $rSelect, array('class' => 'crm-select2'));
     // checkboxes for DO NOT phone, email, mail
     // we take labels from SelectValues
     $t = CRM_Core_SelectValues::privacy();
     $form->add('select', 'privacy_options', ts('Privacy'), $t, FALSE, array('id' => 'privacy_options', 'multiple' => 'multiple', 'class' => 'crm-select2'));
     $form->addElement('select', 'privacy_operator', ts('Operator'), array('OR' => ts('OR'), 'AND' => ts('AND')));
     $options = array(1 => ts('Exclude'), 2 => ts('Include by Privacy Option(s)'));
     $form->addRadio('privacy_toggle', ts('Privacy Options'), $options, array('allowClear' => FALSE));
     // preferred communication method
     $comm = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method');
     $commPreff = array();
     foreach ($comm as $k => $v) {
         $commPreff[] = $form->createElement('advcheckbox', $k, NULL, $v);
     }
     $onHold[] = $form->createElement('advcheckbox', 'on_hold', NULL, '');
     $form->addGroup($onHold, 'email_on_hold', ts('Email On Hold'));
     $form->addGroup($commPreff, 'preferred_communication_method', ts('Preferred Communication Method'));
     //CRM-6138 Preferred Language
     $form->addSelect('preferred_language', array('class' => 'twenty', 'context' => 'search'));
     // Phone search
     $form->addElement('text', 'phone_numeric', ts('Phone Number'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone'));
     $locationType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
     $phoneType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
     $form->add('select', 'phone_location_type_id', ts('Phone Location'), array('' => ts('- any -')) + $locationType, FALSE, array('class' => 'crm-select2'));
     $form->add('select', 'phone_phone_type_id', ts('Phone Type'), array('' => ts('- any -')) + $phoneType, FALSE, array('class' => 'crm-select2'));
 }
コード例 #15
0
 /**
  * @param CRM_Core_Form $form
  */
 public static function contact_b(&$form)
 {
     $form->addElement('hidden', 'hidden_contact_b', 1);
     // add checkboxes for contact type
     //@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;
     $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator);
     if ($contactTypes) {
         $form->add('select', 'contact_b_contact_type', ts('Contact Type(s)'), $contactTypes, FALSE, array('id' => 'contact_b_contact_type', 'multiple' => 'multiple', 'class' => 'crm-select2', 'style' => 'width: 100%;'));
     }
     // add text box for last name, first name, street name, city
     $form->addElement('text', 'contact_b_display_name', ts('Find...'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     // add text box for last name, first name, street name, city
     $form->add('text', 'contact_b_email', ts('Contact Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     //added job title
     $form->addElement('text', 'contact_b_job_title', ts('Job Title'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'job_title'));
     //added internal ID
     $form->addElement('text', 'contact_b_contact_id', ts('Contact ID'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'id'));
     $form->addRule('contact_b_contact_id', ts('Please enter valid Contact ID'), 'positiveInteger');
     //added external ID
     $form->addElement('text', 'contact_b_external_identifier', ts('External ID'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'external_identifier'));
     // Phone search
     $form->addElement('text', 'contact_b_phone_numeric', ts('Phone Number'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone'));
     $locationType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
     $phoneType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
     $form->add('select', 'contact_b_phone_location_type_id', ts('Phone Location'), array('' => ts('- any -')) + $locationType, FALSE, array('class' => 'crm-select2'));
     $form->add('select', 'contact_b_phone_phone_type_id', ts('Phone Type'), array('' => ts('- any -')) + $phoneType, FALSE, array('class' => 'crm-select2'));
     // add all the custom  searchable fields
     $contact = array('Individual', 'Household', 'Organization');
     $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $contact);
     if ($groupDetails) {
         $form->assign('contactGroupTree', $groupDetails);
         foreach ($groupDetails as $group) {
             foreach ($group['fields'] as $field) {
                 $fieldId = $field['id'];
                 $elementName = 'custom_' . $fieldId;
                 CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, FALSE, TRUE);
             }
         }
     }
     // Add address fields
     $attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Address');
     $form->addElement('text', 'contact_b_street_address', ts('Street Address'), $attributes['street_address']);
     $form->addElement('text', 'contact_b_city', ts('City'), $attributes['city']);
     $form->addElement('text', 'contact_b_postal_code', ts('Zip / Postal Code'), $attributes['postal_code']);
     $form->addElement('text', 'contact_b_postal_code_low', NULL, $attributes['postal_code'] + array('placeholder' => ts('From')));
     $form->addElement('text', 'contact_b_postal_code_high', NULL, $attributes['postal_code'] + array('placeholder' => ts('To')));
     // select for location type
     $locationType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
     $form->add('select', 'contact_b_location_type', ts('Address Location'), $locationType, FALSE, array('multiple' => TRUE, 'class' => 'crm-select2', 'placeholder' => ts('Primary')));
     // Add demographics
     // radio button for gender
     $genderOptions = array();
     $gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id');
     foreach ($gender as $key => $var) {
         $genderOptions[$key] = $form->createElement('radio', NULL, ts('Gender'), $var, $key, array('id' => "civicrm_gender_{$var}_{$key}"));
     }
     $form->addGroup($genderOptions, 'contact_b_gender_id', ts('Gender'))->setAttribute('allowClear', TRUE);
     CRM_Core_Form_Date::buildDateRange($form, 'contact_b_birth_date', 1, '_low', '_high', ts('From'), FALSE, FALSE, 'birth');
     CRM_Core_Form_Date::buildDateRange($form, 'contact_b_deceased_date', 1, '_low', '_high', ts('From'), FALSE, FALSE, 'birth');
     // radio button for is_deceased
     $form->addYesNo('contact_b_is_deceased', ts('Deceased'), TRUE);
 }
コード例 #16
0
ファイル: Basic.php プロジェクト: prashantgajare/civicrm-core
 /**
  * browse all entities.
  *
  * @internal param int $action
  *
  * @return void
  * @access public
  */
 function browse()
 {
     $n = func_num_args();
     $action = $n > 0 ? func_get_arg(0) : NULL;
     $sort = $n > 0 ? func_get_arg(1) : NULL;
     $links =& $this->links();
     if ($action == NULL) {
         if (!empty($links)) {
             $action = array_sum(array_keys($links));
         }
     }
     if ($action & CRM_Core_Action::DISABLE) {
         $action -= CRM_Core_Action::DISABLE;
     }
     if ($action & CRM_Core_Action::ENABLE) {
         $action -= CRM_Core_Action::ENABLE;
     }
     $baoString = $this->getBAOName();
     $object = new $baoString();
     $values = array();
     /*
      * lets make sure we get the stuff sorted by name if it exists
      */
     $fields =& $object->fields();
     $key = '';
     if (!empty($fields['title'])) {
         $key = 'title';
     } elseif (!empty($fields['label'])) {
         $key = 'label';
     } elseif (!empty($fields['name'])) {
         $key = 'name';
     }
     if (trim($sort)) {
         $object->orderBy($sort);
     } elseif ($key) {
         $object->orderBy($key . ' asc');
     }
     //@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;
     $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator);
     // find all objects
     $object->find();
     while ($object->fetch()) {
         if (!isset($object->mapping_type_id) || $object->mapping_type_id != 1) {
             $permission = CRM_Core_Permission::EDIT;
             if ($key) {
                 $permission = $this->checkPermission($object->id, $object->{$key});
             }
             if ($permission) {
                 $values[$object->id] = array();
                 CRM_Core_DAO::storeValues($object, $values[$object->id]);
                 if (is_a($object, 'CRM_Contact_DAO_RelationshipType')) {
                     $values[$object->id]['contact_type_a_display'] = $contactTypes[$values[$object->id]['contact_type_a']];
                     $values[$object->id]['contact_type_b_display'] = $contactTypes[$values[$object->id]['contact_type_b']];
                 }
                 // populate action links
                 $this->action($object, $action, $values[$object->id], $links, $permission);
                 if (isset($object->mapping_type_id)) {
                     $mappintTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Mapping', 'mapping_type_id');
                     $values[$object->id]['mapping_type'] = $mappintTypes[$object->mapping_type_id];
                 }
             }
         }
     }
     $this->assign('rows', $values);
 }
コード例 #17
0
 /**
  * Get options for a given contact field.
  *
  * @see CRM_Core_DAO::buildOptions
  *
  * TODO: Should we always assume chainselect? What fn should be responsible for controlling that flow?
  * TODO: In context of chainselect, what to return if e.g. a country has no states?
  *
  * @param string $fieldName
  * @param string $context
  * @see CRM_Core_DAO::buildOptionsContext
  * @param array $props
  *   whatever is known about this dao object.
  *
  * @return array|bool
  */
 public static function buildOptions($fieldName, $context = NULL, $props = array())
 {
     $params = array();
     // Special logic for fields whose options depend on context or properties
     switch ($fieldName) {
         case 'contact_sub_type':
             if (!empty($props['contact_type'])) {
                 $params['condition'] = "parent_id = (SELECT id FROM civicrm_contact_type WHERE name='{$props['contact_type']}')";
             }
             break;
         case 'contact_type':
             if ($context == 'search') {
                 // CRM-15495 - EntityRef filters and basic search forms expect this format
                 // FIXME: Search builder does not
                 return CRM_Contact_BAO_ContactType::getSelectElements();
             }
             break;
             // The contact api supports some related entities so we'll honor that by fetching their options
         // The contact api supports some related entities so we'll honor that by fetching their options
         case 'group_id':
         case 'group':
             return CRM_Contact_BAO_GroupContact::buildOptions('group_id', $context, $props);
         case 'tag_id':
         case 'tag':
             $props['entity_table'] = 'civicrm_contact';
             return CRM_Core_BAO_EntityTag::buildOptions('tag_id', $context, $props);
     }
     return CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context);
 }
コード例 #18
0
    /**
     * add all the elements shared between,
     * normal voter search and voter listing (GOTV form)
     *
     * @access public
     *
     * @return void
     * @static
     */
    static function buildSearchForm(&$form)
    {
        $attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Address');
        $className = CRM_Utils_System::getClassName($form);
        $form->add('text', 'sort_name', ts('Contact Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
        $form->add('text', 'street_name', ts('Street Name'), $attributes['street_name']);
        $form->add('text', 'street_number', ts('Street Number'), $attributes['street_number']);
        $form->add('text', 'street_unit', ts('Street Unit'), $attributes['street_unit']);
        $form->add('text', 'street_address', ts('Street Address'), $attributes['street_address']);
        $form->add('text', 'city', ts('City'), $attributes['city']);
        $form->add('text', 'postal_code', ts('Zip / Postal Code'), $attributes['postal_code']);
        $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements();
        $form->add('select', 'contact_type', ts('Contact Type(s)'), $contactTypes, FALSE, array('id' => 'contact_type', 'multiple' => 'multiple', 'class' => 'crm-select2'));
        $groups = CRM_Core_PseudoConstant::group();
        $form->add('select', 'group', ts('Groups'), $groups, FALSE, array('id' => 'group', 'multiple' => 'multiple', 'class' => 'crm-select2'));
        $showInterviewer = FALSE;
        if (CRM_Core_Permission::check('administer CiviCampaign')) {
            $showInterviewer = TRUE;
        }
        $form->assign('showInterviewer', $showInterviewer);
        if ($showInterviewer || $className == 'CRM_Campaign_Form_Gotv') {
            //autocomplete url
            $dataUrl = CRM_Utils_System::url('civicrm/ajax/rest', 'className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&reset=1', FALSE, NULL, FALSE);
            $form->assign('dataUrl', $dataUrl);
            $form->add('text', 'survey_interviewer_name', ts('Interviewer'));
            $form->add('hidden', 'survey_interviewer_id', '', array('id' => 'survey_interviewer_id'));
            $userId = NULL;
            if (isset($form->_interviewerId) && $form->_interviewerId) {
                $userId = $form->_interviewerId;
            }
            if (!$userId) {
                $session = CRM_Core_Session::singleton();
                $userId = $session->get('userID');
            }
            if ($userId) {
                $defaults = array();
                $defaults['survey_interviewer_id'] = $userId;
                $defaults['survey_interviewer_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $userId, 'sort_name', 'id');
                $form->setDefaults($defaults);
            }
        }
        //build ward and precinct custom fields.
        $query = '
    SELECT  fld.id, fld.label
      FROM  civicrm_custom_field fld
INNER JOIN  civicrm_custom_group grp on fld.custom_group_id = grp.id
     WHERE  grp.name = %1';
        $dao = CRM_Core_DAO::executeQuery($query, array(1 => array('Voter_Info', 'String')));
        $customSearchFields = array();
        while ($dao->fetch()) {
            foreach (array('ward', 'precinct') as $name) {
                if (stripos($name, $dao->label) !== FALSE) {
                    $fieldId = $dao->id;
                    $fieldName = 'custom_' . $dao->id;
                    $customSearchFields[$name] = $fieldName;
                    CRM_Core_BAO_CustomField::addQuickFormElement($form, $fieldName, $fieldId, FALSE, FALSE);
                    break;
                }
            }
        }
        $form->assign('customSearchFields', $customSearchFields);
        $surveys = CRM_Campaign_BAO_Survey::getSurveys();
        if (empty($surveys) && $className == 'CRM_Campaign_Form_Search') {
            CRM_Core_Error::statusBounce(ts('Could not find survey for %1 respondents.', array(1 => $form->get('op'))), CRM_Utils_System::url('civicrm/survey/add', 'reset=1&action=add'));
        }
        //CRM-7406 --
        //If survey had associated campaign and
        //campaign has some contact groups, don't
        //allow to search the contacts those are not
        //in given campaign groups ( ie not in constituents )
        $groupJs = NULL;
        if ($form->get('searchVoterFor') == 'reserve') {
            $groupJs = array('onChange' => "buildCampaignGroups( );return false;");
        }
        $form->add('select', 'campaign_survey_id', ts('Survey'), $surveys, TRUE, $groupJs);
    }
コード例 #19
0
 static function basic(&$form)
 {
     $form->addElement('hidden', 'hidden_basic', 1);
     if ($form->_searchOptions['contactType']) {
         // add checkboxes for contact type
         $contact_type = array();
         $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements();
         if ($contactTypes) {
             $form->add('select', 'contact_type', ts('Contact Type(s)'), $contactTypes, FALSE, array('id' => 'contact_type', 'multiple' => 'multiple', 'title' => ts('- select -')));
         }
     }
     if ($form->_searchOptions['groups']) {
         // multiselect for groups
         if ($form->_group) {
             $form->add('select', 'group', ts('Groups'), $form->_group, FALSE, array('id' => 'group', 'multiple' => 'multiple', 'title' => ts('- select -')));
         }
     }
     if ($form->_searchOptions['tags']) {
         // multiselect for categories
         $contactTags = CRM_Core_BAO_Tag::getTags();
         if ($contactTags) {
             $form->add('select', 'contact_tags', ts('Tags'), $contactTags, FALSE, array('id' => 'contact_tags', 'multiple' => 'multiple', 'title' => ts('- select -')));
         }
         $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
         CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', NULL, TRUE, FALSE, TRUE);
     }
     // add text box for last name, first name, street name, city
     $form->addElement('text', 'sort_name', ts('Find...'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     // add text box for last name, first name, street name, city
     $form->add('text', 'email', ts('Contact Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     //added contact source
     $form->add('text', 'contact_source', ts('Contact Source'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'source'));
     //added job title
     $attributes['job_title']['size'] = 30;
     $form->addElement('text', 'job_title', ts('Job Title'), $attributes['job_title'], 'size="30"');
     //added internal ID
     $attributes['id']['size'] = 30;
     $form->addElement('text', 'id', ts('Contact ID'), $attributes['id'], 'size="30"');
     //added external ID
     $attributes['external_identifier']['size'] = 30;
     $form->addElement('text', 'external_identifier', ts('External ID'), $attributes['external_identifier'], 'size="30"');
     $config = CRM_Core_Config::singleton();
     if (CRM_Core_Permission::check('access deleted contacts') and $config->contactUndelete) {
         $form->add('checkbox', 'deleted_contacts', ts('Search in Trash') . '<br />' . ts('(deleted contacts)'));
     }
     // add checkbox for cms users only
     $form->addYesNo('uf_user', ts('CMS User?'));
     // tag all search
     $form->add('text', 'tag_search', ts('All Tags'));
     // add search profiles
     // FIXME: This is probably a part of profiles - need to be
     // FIXME: eradicated from here when profiles are reworked.
     $types = array('Participant', 'Contribution', 'Membership');
     // get component profiles
     $componentProfiles = array();
     $componentProfiles = CRM_Core_BAO_UFGroup::getProfiles($types);
     $ufGroups = CRM_Core_BAO_UFGroup::getModuleUFGroup('Search Profile', 1);
     $accessibleUfGroups = CRM_Core_Permission::ufGroup(CRM_Core_Permission::VIEW);
     $searchProfiles = array();
     foreach ($ufGroups as $key => $var) {
         if (!array_key_exists($key, $componentProfiles) && in_array($key, $accessibleUfGroups)) {
             $searchProfiles[$key] = $var['title'];
         }
     }
     $form->addElement('select', 'uf_group_id', ts('Search Views'), array('0' => ts('- default view -')) + $searchProfiles);
     $componentModes = CRM_Contact_Form_Search::getModeSelect();
     // unset contributions or participants if user does not have
     // permission on them
     if (!CRM_Core_Permission::access('CiviContribute')) {
         unset($componentModes['2']);
     }
     if (!CRM_Core_Permission::access('CiviEvent')) {
         unset($componentModes['3']);
     }
     if (!CRM_Core_Permission::access('CiviMember')) {
         unset($componentModes['5']);
     }
     if (!CRM_Core_Permission::check('view all activities')) {
         unset($componentModes['4']);
     }
     if (count($componentModes) > 1) {
         $form->addElement('select', 'component_mode', ts('Display Results As'), $componentModes);
     }
     $form->addElement('select', 'operator', ts('Search Operator'), array('AND' => ts('AND'), 'OR' => ts('OR')));
     // add the option to display relationships
     $rTypes = CRM_Core_PseudoConstant::relationshipType();
     $rSelect = array('' => ts('- Select Relationship Type-'));
     foreach ($rTypes as $rid => $rValue) {
         if ($rValue['label_a_b'] == $rValue['label_b_a']) {
             $rSelect[$rid] = $rValue['label_a_b'];
         } else {
             $rSelect["{$rid}_a_b"] = $rValue['label_a_b'];
             $rSelect["{$rid}_b_a"] = $rValue['label_b_a'];
         }
     }
     $form->addElement('select', 'display_relationship_type', ts('Display Results as Relationship'), $rSelect);
     // checkboxes for DO NOT phone, email, mail
     // we take labels from SelectValues
     $t = CRM_Core_SelectValues::privacy();
     $form->add('select', 'privacy_options', ts('Privacy'), $t, FALSE, array('id' => 'privacy_options', 'multiple' => 'multiple', 'title' => ts('- select -')));
     $form->addElement('select', 'privacy_operator', ts('Operator'), array('OR' => ts('OR'), 'AND' => ts('AND')));
     $toggleChoice = array();
     $toggleChoice[] = $form->createElement('radio', NULL, '', ' ' . ts('Exclude'), '1');
     $toggleChoice[] = $form->createElement('radio', NULL, '', ' ' . ts('Include by Privacy Option(s)'), '2');
     $form->addGroup($toggleChoice, 'privacy_toggle', 'Privacy Options');
     // preferred communication method
     $comm = CRM_Core_PseudoConstant::pcm();
     $commPreff = array();
     foreach ($comm as $k => $v) {
         $commPreff[] = $form->createElement('advcheckbox', $k, NULL, $v);
     }
     $onHold[] = $form->createElement('advcheckbox', 'on_hold', NULL, ts(''));
     $form->addGroup($onHold, 'email_on_hold', ts('Email On Hold'));
     $form->addGroup($commPreff, 'preferred_communication_method', ts('Preferred Communication Method'));
     //CRM-6138 Preferred Language
     $langPreff = CRM_Core_PseudoConstant::languages();
     $form->add('select', 'preferred_language', ts('Preferred Language'), array('' => ts('- select language -')) + $langPreff);
 }
コード例 #20
0
ファイル: Field.php プロジェクト: bhirsch/civicrm
 /**
  * Function to actually build the form
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete Profile Field'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
         return;
     }
     if (isset($this->_id)) {
         $params = array('id' => $this->_id);
         CRM_Core_BAO_UFField::retrieve($params, $defaults);
         // set it to null if so (avoids crappy E_NOTICE errors below
         $defaults['location_type_id'] = CRM_Utils_Array::value('location_type_id', $defaults);
         $specialFields = array('street_address', 'supplemental_address_1', 'supplemental_address_2', 'city', 'postal_code', 'postal_code_suffix', 'geo_code_1', 'geo_code_2', 'state_province', 'country', 'county', 'phone', 'email', 'im', 'address_name');
         if (!$defaults['location_type_id'] && in_array($defaults['field_name'], $specialFields)) {
             $defaults['location_type_id'] = 0;
         }
         $defaults['field_name'] = array($defaults['field_type'], $defaults['field_name'], $defaults['location_type_id'], CRM_Utils_Array::value('phone_type_id', $defaults));
         $this->_gid = $defaults['uf_group_id'];
     } else {
         $defaults['is_active'] = 1;
     }
     if ($this->_action & CRM_Core_Action::ADD) {
         $fieldValues = array('uf_group_id' => $this->_gid);
         $defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_UFField', $fieldValues);
     }
     // lets trim all the whitespace
     $this->applyFilter('__ALL__', 'trim');
     //hidden field to catch the group id in profile
     $this->add('hidden', 'group_id', $this->_gid);
     //hidden field to catch the field id in profile
     $this->add('hidden', 'field_id', $this->_id);
     $fields = array();
     $fields['Individual'] =& CRM_Contact_BAO_Contact::importableFields('Individual', false, false, true);
     $fields['Household'] =& CRM_Contact_BAO_Contact::importableFields('Household', false, false, true);
     $fields['Organization'] =& CRM_Contact_BAO_Contact::importableFields('Organization', false, false, true);
     // add current employer for individuals
     $fields['Individual']['current_employer'] = array('name' => 'organization_name', 'title' => ts('Current Employer'));
     // unset unwanted fields
     $unsetFieldArray = array('note', 'email_greeting_custom', 'postal_greeting_custom', 'addressee_custom', 'id');
     foreach ($unsetFieldArray as $value) {
         unset($fields['Individual'][$value]);
         unset($fields['Household'][$value]);
         unset($fields['Organization'][$value]);
     }
     require_once 'CRM/Core/BAO/Preferences.php';
     $addressOptions = CRM_Core_BAO_Preferences::valueOptions('address_options', true, null, true);
     if (!$addressOptions['county']) {
         unset($fields['Individual']['county']);
         unset($fields['Household']['county']);
         unset($fields['Organization']['county']);
     }
     //build the common contact fields array CRM-3037.
     foreach ($fields['Individual'] as $key => $value) {
         if (CRM_Utils_Array::value($key, $fields['Household']) && CRM_Utils_Array::value($key, $fields['Organization'])) {
             $fields['Contact'][$key] = $value;
             //as we move common fields to contacts. There fore these fields
             //are unset from resoective array's.
             unset($fields['Individual'][$key]);
             unset($fields['Household'][$key]);
             unset($fields['Organization'][$key]);
         }
     }
     // add current employer for individuals
     $fields['Contact']['id'] = array('name' => 'id', 'title' => ts('Internal Contact ID'));
     unset($fields['Contact']['contact_type']);
     // since we need a hierarchical list to display contact types & subtypes,
     // this is what we going to display in first selector
     $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(false, false);
     unset($contactTypes['']);
     // include Subtypes For Profile
     $subTypes = CRM_Contact_BAO_ContactType::subTypeInfo();
     foreach ($subTypes as $name => $val) {
         //custom fields for sub type
         $subTypeFields = CRM_Core_BAO_CustomField::getFieldsForImport($name);
         if (array_key_exists($val['parent'], $fields)) {
             $fields[$name] = $fields[$val['parent']] + $subTypeFields;
         } else {
             $fields[$name] = $subTypeFields;
         }
     }
     unset($subTypes);
     if (CRM_Core_Permission::access('Quest')) {
         require_once 'CRM/Quest/BAO/Student.php';
         $fields['Student'] =& CRM_Quest_BAO_Student::exportableFields();
     }
     if (CRM_Core_Permission::access('CiviContribute')) {
         $contribFields =& CRM_Contribute_BAO_Contribution::getContributionFields();
         if (!empty($contribFields)) {
             unset($contribFields['is_test']);
             unset($contribFields['is_pay_later']);
             unset($contribFields['contribution_id']);
             $fields['Contribution'] =& $contribFields;
         }
     }
     if (CRM_Core_Permission::access('CiviEvent')) {
         require_once 'CRM/Event/BAO/Query.php';
         $participantFields =& CRM_Event_BAO_Query::getParticipantFields(true);
         if (!empty($participantFields)) {
             unset($participantFields['external_identifier']);
             unset($participantFields['event_id']);
             unset($participantFields['participant_contact_id']);
             unset($participantFields['participant_is_test']);
             unset($participantFields['participant_fee_level']);
             unset($participantFields['participant_id']);
             unset($participantFields['participant_is_pay_later']);
             $fields['Participant'] =& $participantFields;
         }
     }
     if (CRM_Core_Permission::access('CiviMember')) {
         require_once 'CRM/Member/BAO/Membership.php';
         $membershipFields =& CRM_Member_BAO_Membership::getMembershipFields();
         unset($membershipFields['membership_id']);
         unset($membershipFields['join_date']);
         unset($membershipFields['membership_start_date']);
         unset($membershipFields['membership_type_id']);
         unset($membershipFields['membership_end_date']);
         unset($membershipFields['member_is_test']);
         unset($membershipFields['is_override']);
         unset($membershipFields['status_id']);
         unset($membershipFields['member_is_pay_later']);
         $fields['Membership'] =& $membershipFields;
     }
     $noSearchable = array();
     foreach ($fields as $key => $value) {
         foreach ($value as $key1 => $value1) {
             //CRM-2676, replacing the conflict for same custom field name from different custom group.
             require_once 'CRM/Core/BAO/CustomField.php';
             if ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($key1)) {
                 $customGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $customFieldId, 'custom_group_id');
                 $customGroupName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $customGroupId, 'title');
                 $this->_mapperFields[$key][$key1] = $value1['title'] . ' :: ' . $customGroupName;
             } else {
                 $this->_mapperFields[$key][$key1] = $value1['title'];
             }
             $hasLocationTypes[$key][$key1] = CRM_Utils_Array::value('hasLocationType', $value1);
             // hide the 'is searchable' field for 'File' custom data
             if (isset($value1['data_type']) && isset($value1['html_type']) && ($value1['data_type'] == 'File' && $value1['html_type'] == 'File' || $value1['data_type'] == 'Link' && $value1['html_type'] == 'Link')) {
                 if (!in_array($value1['title'], $noSearchable)) {
                     $noSearchable[] = $value1['title'];
                 }
             }
         }
     }
     $this->assign('noSearchable', $noSearchable);
     require_once 'CRM/Core/BAO/LocationType.php';
     $this->_location_types =& CRM_Core_PseudoConstant::locationType();
     $defaultLocationType =& CRM_Core_BAO_LocationType::getDefault();
     /* FIXME: dirty hack to make the default option show up first.  This
      * avoids a mozilla browser bug with defaults on dynamically constructed
      * selector widgets. */
     if ($defaultLocationType) {
         $defaultLocation = $this->_location_types[$defaultLocationType->id];
         unset($this->_location_types[$defaultLocationType->id]);
         $this->_location_types = array($defaultLocationType->id => $defaultLocation) + $this->_location_types;
     }
     $this->_location_types = array('Primary') + $this->_location_types;
     $contactTypes = !empty($contactTypes) ? array('Contact' => 'Contacts') + $contactTypes : array();
     $sel1 = array('' => '- select -') + $contactTypes;
     if (CRM_Core_Permission::access('Quest')) {
         $sel1['Student'] = 'Students';
     }
     if (CRM_Core_Permission::access('CiviEvent')) {
         $sel1['Participant'] = 'Participants';
     }
     if (!empty($contribFields)) {
         $sel1['Contribution'] = 'Contributions';
     }
     if (!empty($membershipFields)) {
         $sel1['Membership'] = 'Membership';
     }
     foreach ($sel1 as $key => $sel) {
         if ($key) {
             $sel2[$key] = $this->_mapperFields[$key];
         }
     }
     $sel3[''] = null;
     $phoneTypes = CRM_Core_PseudoConstant::phoneType();
     ksort($phoneTypes);
     foreach ($sel1 as $k => $sel) {
         if ($k) {
             foreach ($this->_location_types as $key => $value) {
                 $sel4[$k]['phone'][$key] =& $phoneTypes;
             }
         }
     }
     foreach ($sel1 as $k => $sel) {
         if ($k) {
             if (is_array($this->_mapperFields[$k])) {
                 foreach ($this->_mapperFields[$k] as $key => $value) {
                     if ($hasLocationTypes[$k][$key]) {
                         $sel3[$k][$key] = $this->_location_types;
                     } else {
                         $sel3[$key] = null;
                     }
                 }
             }
         }
     }
     $this->_defaults = array();
     $js = "<script type='text/javascript'>\n";
     $formName = "document.{$this->_name}";
     $alreadyMixProfile = false;
     if (CRM_Core_BAO_UFField::checkProfileType($this->_gid)) {
         $alreadyMixProfile = true;
     }
     $this->assign('alreadyMixProfile', $alreadyMixProfile);
     $attributes = array('onclick' => "showLabel();mixProfile();", 'onblur' => 'showLabel();mixProfile();');
     $sel =& $this->addElement('hierselect', "field_name", ts('Field Name'), $attributes);
     $formValues = array();
     $formValues = $this->exportValues();
     if (empty($formValues)) {
         for ($k = 1; $k < 4; $k++) {
             if (!$defaults['field_name'][$k]) {
                 $js .= "{$formName}['field_name[{$k}]'].style.display = 'none';\n";
             }
         }
     } else {
         if (!empty($formValues['field_name'])) {
             foreach ($formValues['field_name'] as $value) {
                 for ($k = 1; $k < 4; $k++) {
                     if (!isset($formValues['field_name'][$k]) || !$formValues['field_name'][$k]) {
                         $js .= "{$formName}['field_name[{$k}]'].style.display = 'none';\n";
                     } else {
                         $js .= "{$formName}['field_name[{$k}]'].style.display = '';\n";
                     }
                 }
             }
         } else {
             for ($k = 1; $k < 4; $k++) {
                 if (!isset($defaults['field_name'][$k])) {
                     $js .= "{$formName}['field_name[{$k}]'].style.display = 'none';\n";
                 }
             }
         }
     }
     foreach ($sel2 as $k => $v) {
         if (is_array($sel2[$k])) {
             asort($sel2[$k]);
         }
     }
     $sel->setOptions(array($sel1, $sel2, $sel3, $sel4));
     $js .= "</script>\n";
     $this->assign('initHideBoxes', $js);
     $this->add('select', 'visibility', ts('Visibility'), CRM_Core_SelectValues::ufVisibility(), true, array("onChange" => "showHideSeletorSearch(this.value);"));
     //CRM-4363
     $js = array('onclick' => "mixProfile();");
     // should the field appear in selectors (as a column)?
     $this->add('checkbox', 'in_selector', ts('Results Column?'), null, null, $js);
     $this->add('checkbox', 'is_searchable', ts('Searchable?'), null, null, $js);
     // weight
     $this->add('text', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFField', 'weight'), true);
     $this->addRule('weight', ts('is a numeric field'), 'numeric');
     $this->add('textarea', 'help_post', ts('Field Help'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFField', 'help_post'));
     // listings title
     $this->add('text', 'listings_title', ts('Listings Title'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFField', 'listings_title'));
     $this->addRule('listings_title', ts('Please enter a valid title for this field when displayed in user listings.'), 'title');
     $this->add('checkbox', 'is_required', ts('Required?'));
     $this->add('checkbox', 'is_active', ts('Active?'));
     $this->add('checkbox', 'is_view', ts('View Only?'));
     // $this->add( 'checkbox', 'is_registration', ts( 'Display in Registration Form?' ) );
     //$this->add( 'checkbox', 'is_match'       , ts( 'Key to Match Contacts?'        ) );
     $this->add('text', 'label', ts('Field Label'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFField', 'label'));
     $js = null;
     if ($this->_hasSearchableORInSelector) {
         $js = array('onclick' => "return verify( );");
     }
     // add buttons
     $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => true, 'js' => $js), array('type' => 'next', 'name' => ts('Save and New'), 'subName' => 'new', 'js' => $js), array('type' => 'cancel', 'name' => ts('Cancel'))));
     $this->addFormRule(array('CRM_UF_Form_Field', 'formRule'), $this);
     // if view mode pls freeze it with the done button.
     if ($this->_action & CRM_Core_Action::VIEW) {
         $this->freeze();
         $this->addElement('button', 'done', ts('Done'), array('onclick' => "location.href='civicrm/admin/uf/group/field?reset=1&action=browse&gid=" . $this->_gid . "'"));
     }
     $this->setDefaults($defaults);
 }
コード例 #21
0
ファイル: Basic.php プロジェクト: kidaa30/yes
 /**
  * @param CRM_Core_Form $form
  */
 public function buildForm(&$form)
 {
     //@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;
     $contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator);
     $form->add('select', 'contact_type', ts('Find...'), $contactTypes, FALSE, array('class' => 'crm-select2 huge'));
     // add select for groups
     $group = array('' => ts('- any group -')) + CRM_Core_PseudoConstant::nestedGroup();
     $form->addElement('select', 'group', ts('in'), $group, array('class' => 'crm-select2 huge'));
     // add select for categories
     $tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
     $form->addElement('select', 'tag', ts('Tagged'), $tag, array('class' => 'crm-select2 huge'));
     // text for sort_name
     $form->add('text', 'sort_name', ts('Name'));
     $form->assign('elements', array('sort_name', 'contact_type', 'group', 'tag'));
 }
コード例 #22
0
ファイル: Query.php プロジェクト: konadave/civicrm-core
    /**
     * Add all the elements shared between,
     * normal voter search and voter listing (GOTV form)
     *
     * @param CRM_Core_Form $form
     */
    public static function buildSearchForm(&$form)
    {
        $attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Address');
        $className = CRM_Utils_System::getClassName($form);
        $form->add('text', 'sort_name', ts('Contact Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
        $form->add('text', 'street_name', ts('Street Name'), $attributes['street_name']);
        $form->add('text', 'street_number', ts('Street Number'), $attributes['street_number']);
        $form->add('text', 'street_unit', ts('Street Unit'), $attributes['street_unit']);
        $form->add('text', 'street_address', ts('Street Address'), $attributes['street_address']);
        $form->add('text', 'city', ts('City'), $attributes['city']);
        $form->add('text', 'postal_code', ts('Postal Code'), $attributes['postal_code']);
        //@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;
        $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator);
        $form->add('select', 'contact_type', ts('Contact Type(s)'), $contactTypes, FALSE, array('id' => 'contact_type', 'multiple' => 'multiple', 'class' => 'crm-select2'));
        $groups = CRM_Core_PseudoConstant::nestedGroup();
        $form->add('select', 'group', ts('Groups'), $groups, FALSE, array('multiple' => 'multiple', 'class' => 'crm-select2'));
        $showInterviewer = FALSE;
        if (CRM_Core_Permission::check('administer CiviCampaign')) {
            $showInterviewer = TRUE;
        }
        $form->assign('showInterviewer', $showInterviewer);
        if ($showInterviewer || $className == 'CRM_Campaign_Form_Gotv') {
            $form->addEntityRef('survey_interviewer_id', ts('Interviewer'), array('class' => 'big'));
            $userId = NULL;
            if (isset($form->_interviewerId) && $form->_interviewerId) {
                $userId = $form->_interviewerId;
            }
            if (!$userId) {
                $session = CRM_Core_Session::singleton();
                $userId = $session->get('userID');
            }
            if ($userId) {
                $defaults = array();
                $defaults['survey_interviewer_id'] = $userId;
                $form->setDefaults($defaults);
            }
        }
        //build ward and precinct custom fields.
        $query = '
    SELECT  fld.id, fld.label
      FROM  civicrm_custom_field fld
INNER JOIN  civicrm_custom_group grp on fld.custom_group_id = grp.id
     WHERE  grp.name = %1';
        $dao = CRM_Core_DAO::executeQuery($query, array(1 => array('Voter_Info', 'String')));
        $customSearchFields = array();
        while ($dao->fetch()) {
            foreach (array('ward', 'precinct') as $name) {
                if (stripos($name, $dao->label) !== FALSE) {
                    $fieldId = $dao->id;
                    $fieldName = 'custom_' . $dao->id;
                    $customSearchFields[$name] = $fieldName;
                    CRM_Core_BAO_CustomField::addQuickFormElement($form, $fieldName, $fieldId, FALSE);
                    break;
                }
            }
        }
        $form->assign('customSearchFields', $customSearchFields);
        $surveys = CRM_Campaign_BAO_Survey::getSurveys();
        if (empty($surveys) && $className == 'CRM_Campaign_Form_Search') {
            CRM_Core_Error::statusBounce(ts('Could not find survey for %1 respondents.', array(1 => $form->get('op'))), CRM_Utils_System::url('civicrm/survey/add', 'reset=1&action=add'));
        }
        //CRM-7406 --
        //If survey had associated campaign and
        //campaign has some contact groups, don't
        //allow to search the contacts those are not
        //in given campaign groups ( ie not in constituents )
        $props = array('class' => 'crm-select2');
        if ($form->get('searchVoterFor') == 'reserve') {
            $props['onChange'] = "buildCampaignGroups( );return false;";
        }
        $form->add('select', 'campaign_survey_id', ts('Survey'), $surveys, TRUE, $props);
    }
コード例 #23
0
ファイル: Mapping.php プロジェクト: riyadennis/my_civicrm
 /**
  * Build the mapping form.
  *
  * @param CRM_Core_Form $form
  * @param string $mappingType
  *   (Export/Import/Search Builder).
  * @param int $mappingId
  * @param int $columnNo
  * @param int $blockCount
  *   (no of blocks shown).
  * @param NULL $exportMode
  *
  * @return void
  */
 public static function buildMappingForm(&$form, $mappingType = 'Export', $mappingId = NULL, $columnNo, $blockCount = 3, $exportMode = NULL)
 {
     if ($mappingType == 'Export') {
         $name = "Map";
         $columnCount = array('1' => $columnNo);
     } elseif ($mappingType == 'Search Builder') {
         $name = "Builder";
         $columnCount = $columnNo;
     }
     //get the saved mapping details
     if ($mappingType == 'Export') {
         $form->applyFilter('saveMappingName', 'trim');
         //to save the current mappings
         if (!isset($mappingId)) {
             $saveDetailsName = ts('Save this field mapping');
             $form->add('text', 'saveMappingName', ts('Name'));
             $form->add('text', 'saveMappingDesc', ts('Description'));
         } else {
             $form->assign('loadedMapping', $mappingId);
             $params = array('id' => $mappingId);
             $temp = array();
             $mappingDetails = CRM_Core_BAO_Mapping::retrieve($params, $temp);
             $form->assign('savedName', $mappingDetails->name);
             $form->add('hidden', 'mappingId', $mappingId);
             $form->addElement('checkbox', 'updateMapping', ts('Update this field mapping'), NULL);
             $saveDetailsName = ts('Save as a new field mapping');
             $form->add('text', 'saveMappingName', ts('Name'));
             $form->add('text', 'saveMappingDesc', ts('Description'));
         }
         $form->addElement('checkbox', 'saveMapping', $saveDetailsName, NULL, array('onclick' => "showSaveDetails(this)"));
         $form->addFormRule(array('CRM_Export_Form_Map', 'formRule'), $form->get('mappingTypeId'));
     } elseif ($mappingType == 'Search Builder') {
         $form->addElement('submit', 'addBlock', ts('Also include contacts where'), array('class' => 'submit-link'));
     }
     $defaults = array();
     $hasLocationTypes = array();
     $hasRelationTypes = array();
     $fields = array();
     if ($mappingType == 'Export') {
         $required = TRUE;
     } elseif ($mappingType == 'Search Builder') {
         $required = FALSE;
     }
     $contactType = array('Individual', 'Household', 'Organization');
     foreach ($contactType as $value) {
         $contactFields = CRM_Contact_BAO_Contact::exportableFields($value, FALSE, $required);
         $contactFields = array_merge($contactFields, CRM_Contact_BAO_Query_Hook::singleton()->getFields());
         // exclude the address options disabled in the Address Settings
         $fields[$value] = CRM_Core_BAO_Address::validateAddressOptions($contactFields);
         ksort($fields[$value]);
         if ($mappingType == 'Export') {
             $relationships = array();
             $relationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, $value);
             asort($relationshipTypes);
             foreach ($relationshipTypes as $key => $var) {
                 list($type) = explode('_', $key);
                 $relationships[$key]['title'] = $var;
                 $relationships[$key]['headerPattern'] = '/' . preg_quote($var, '/') . '/';
                 $relationships[$key]['export'] = TRUE;
                 $relationships[$key]['relationship_type_id'] = $type;
                 $relationships[$key]['related'] = TRUE;
                 $relationships[$key]['hasRelationType'] = 1;
             }
             if (!empty($relationships)) {
                 $fields[$value] = array_merge($fields[$value], array('related' => array('title' => ts('- related contact info -'))), $relationships);
             }
         }
     }
     //get the current employer for mapping.
     if ($required) {
         $fields['Individual']['current_employer']['title'] = ts('Current Employer');
     }
     // add component fields
     $compArray = array();
     //we need to unset groups, tags, notes for component export
     if ($exportMode != CRM_Export_Form_Select::CONTACT_EXPORT) {
         foreach (array('groups', 'tags', 'notes') as $value) {
             unset($fields['Individual'][$value]);
             unset($fields['Household'][$value]);
             unset($fields['Organization'][$value]);
         }
     }
     if ($mappingType == 'Search Builder') {
         //build the common contact fields array.
         $fields['Contact'] = array();
         foreach ($fields['Individual'] as $key => $value) {
             if (!empty($fields['Household'][$key]) && !empty($fields['Organization'][$key])) {
                 $fields['Contact'][$key] = $value;
                 unset($fields['Organization'][$key], $fields['Household'][$key], $fields['Individual'][$key]);
             }
         }
         if (array_key_exists('note', $fields['Contact'])) {
             $noteTitle = $fields['Contact']['note']['title'];
             $fields['Contact']['note']['title'] = $noteTitle . ': ' . ts('Body and Subject');
             $fields['Contact']['note_body'] = array('title' => $noteTitle . ': ' . ts('Body Only'), 'name' => 'note_body');
             $fields['Contact']['note_subject'] = array('title' => $noteTitle . ': ' . ts('Subject Only'), 'name' => 'note_subject');
         }
     }
     if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::CONTRIBUTE_EXPORT) {
         if (CRM_Core_Permission::access('CiviContribute')) {
             $fields['Contribution'] = CRM_Contribute_BAO_Contribution::exportableFields();
             foreach (array('contribution_contact_id', 'contribution_soft_credit_name', 'contribution_soft_credit_amount', 'contribution_soft_credit_type', 'contribution_soft_credit_contribution_id') as $element) {
                 unset($fields['Contribution'][$element]);
             }
             $compArray['Contribution'] = ts('Contribution');
         }
     }
     if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::EVENT_EXPORT) {
         if (CRM_Core_Permission::access('CiviEvent')) {
             $fields['Participant'] = CRM_Event_BAO_Participant::exportableFields();
             //get the component payment fields
             if ($exportMode == CRM_Export_Form_Select::EVENT_EXPORT) {
                 $componentPaymentFields = array();
                 foreach (CRM_Export_BAO_Export::componentPaymentFields() as $payField => $payTitle) {
                     $componentPaymentFields[$payField] = array('title' => $payTitle);
                 }
                 $fields['Participant'] = array_merge($fields['Participant'], $componentPaymentFields);
             }
             $compArray['Participant'] = ts('Participant');
         }
     }
     if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::MEMBER_EXPORT) {
         if (CRM_Core_Permission::access('CiviMember')) {
             $fields['Membership'] = CRM_Member_BAO_Membership::getMembershipFields($exportMode);
             unset($fields['Membership']['membership_contact_id']);
             $compArray['Membership'] = ts('Membership');
         }
     }
     if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::PLEDGE_EXPORT) {
         if (CRM_Core_Permission::access('CiviPledge')) {
             $fields['Pledge'] = CRM_Pledge_BAO_Pledge::exportableFields();
             unset($fields['Pledge']['pledge_contact_id']);
             $compArray['Pledge'] = ts('Pledge');
         }
     }
     if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::CASE_EXPORT) {
         if (CRM_Core_Permission::access('CiviCase')) {
             $fields['Case'] = CRM_Case_BAO_Case::exportableFields();
             $compArray['Case'] = ts('Case');
             $fields['Activity'] = CRM_Activity_BAO_Activity::exportableFields('Case');
             $compArray['Activity'] = ts('Case Activity');
             unset($fields['Case']['case_contact_id']);
         }
     }
     if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::GRANT_EXPORT) {
         if (CRM_Core_Permission::access('CiviGrant')) {
             $fields['Grant'] = CRM_Grant_BAO_Grant::exportableFields();
             unset($fields['Grant']['grant_contact_id']);
             if ($mappingType == 'Search Builder') {
                 unset($fields['Grant']['grant_type_id']);
             }
             $compArray['Grant'] = ts('Grant');
         }
     }
     if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::ACTIVITY_EXPORT) {
         $fields['Activity'] = CRM_Activity_BAO_Activity::exportableFields('Activity');
         $compArray['Activity'] = ts('Activity');
     }
     //Contact Sub Type For export
     $contactSubTypes = array();
     $subTypes = CRM_Contact_BAO_ContactType::subTypeInfo();
     foreach ($subTypes as $subType => $val) {
         //adding subtype specific relationships CRM-5256
         $csRelationships = array();
         if ($mappingType == 'Export') {
             $subTypeRelationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, $val['parent'], FALSE, 'label', TRUE, $subType);
             foreach ($subTypeRelationshipTypes as $key => $var) {
                 if (!array_key_exists($key, $fields[$val['parent']])) {
                     list($type) = explode('_', $key);
                     $csRelationships[$key]['title'] = $var;
                     $csRelationships[$key]['headerPattern'] = '/' . preg_quote($var, '/') . '/';
                     $csRelationships[$key]['export'] = TRUE;
                     $csRelationships[$key]['relationship_type_id'] = $type;
                     $csRelationships[$key]['related'] = TRUE;
                     $csRelationships[$key]['hasRelationType'] = 1;
                 }
             }
         }
         $fields[$subType] = $fields[$val['parent']] + $csRelationships;
         //custom fields for sub type
         $subTypeFields = CRM_Core_BAO_CustomField::getFieldsForImport($subType);
         $fields[$subType] += $subTypeFields;
         if (!empty($subTypeFields) || !empty($csRelationships)) {
             $contactSubTypes[$subType] = $val['label'];
         }
     }
     unset($subTypes);
     foreach ($fields as $key => $value) {
         foreach ($value as $key1 => $value1) {
             //CRM-2676, replacing the conflict for same custom field name from different custom group.
             $customGroupName = self::getCustomGroupName($key1);
             if ($customGroupName) {
                 $relatedMapperFields[$key][$key1] = $mapperFields[$key][$key1] = $customGroupName . ': ' . $value1['title'];
             } else {
                 $relatedMapperFields[$key][$key1] = $mapperFields[$key][$key1] = $value1['title'];
             }
             if (isset($value1['hasLocationType'])) {
                 $hasLocationTypes[$key][$key1] = $value1['hasLocationType'];
             }
             if (isset($value1['hasRelationType'])) {
                 $hasRelationTypes[$key][$key1] = $value1['hasRelationType'];
                 unset($relatedMapperFields[$key][$key1]);
             }
         }
         if (array_key_exists('related', $relatedMapperFields[$key])) {
             unset($relatedMapperFields[$key]['related']);
         }
     }
     $mapperKeys = array_keys($mapperFields);
     $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
     $defaultLocationType = CRM_Core_BAO_LocationType::getDefault();
     // FIXME: dirty hack to make the default option show up first.  This
     // avoids a mozilla browser bug with defaults on dynamically constructed
     // selector widgets.
     if ($defaultLocationType) {
         $defaultLocation = $locationTypes[$defaultLocationType->id];
         unset($locationTypes[$defaultLocationType->id]);
         $locationTypes = array($defaultLocationType->id => $defaultLocation) + $locationTypes;
     }
     $locationTypes = array(' ' => ts('Primary')) + $locationTypes;
     // since we need a hierarchical list to display contact types & subtypes,
     // this is what we going to display in first selector
     $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, FALSE);
     if ($mappingType == 'Search Builder') {
         $contactTypes = array('Contact' => ts('Contacts')) + $contactTypes;
     }
     $sel1 = array('' => ts('- select record type -')) + $contactTypes + $compArray;
     foreach ($sel1 as $key => $sel) {
         if ($key) {
             // sort everything BUT the contactType which is sorted seperately by
             // an initial commit of CRM-13278 (check ksort above)
             if (!in_array($key, $contactType)) {
                 asort($mapperFields[$key]);
             }
             $sel2[$key] = array('' => ts('- select field -')) + $mapperFields[$key];
         }
     }
     $sel3[''] = NULL;
     $sel5[''] = NULL;
     $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
     $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
     asort($phoneTypes);
     foreach ($sel1 as $k => $sel) {
         if ($k) {
             foreach ($locationTypes as $key => $value) {
                 if (trim($key) != '') {
                     $sel4[$k]['phone'][$key] =& $phoneTypes;
                     $sel4[$k]['im'][$key] =& $imProviders;
                 }
             }
         }
     }
     foreach ($sel1 as $k => $sel) {
         if ($k) {
             foreach ($mapperFields[$k] as $key => $value) {
                 if (isset($hasLocationTypes[$k][$key])) {
                     $sel3[$k][$key] = $locationTypes;
                 } else {
                     $sel3[$key] = NULL;
                 }
             }
         }
     }
     // Array for core fields and relationship custom data
     $relationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, NULL, TRUE);
     if ($mappingType == 'Export') {
         foreach ($sel1 as $k => $sel) {
             if ($k) {
                 foreach ($mapperFields[$k] as $field => $dontCare) {
                     if (isset($hasRelationTypes[$k][$field])) {
                         list($id, $first, $second) = explode('_', $field);
                         // FIX ME: For now let's not expose custom data related to relationship
                         $relationshipCustomFields = array();
                         //$relationshipCustomFields    = self::getRelationTypeCustomGroupData( $id );
                         //asort($relationshipCustomFields);
                         $relationshipType = new CRM_Contact_BAO_RelationshipType();
                         $relationshipType->id = $id;
                         if ($relationshipType->find(TRUE)) {
                             $direction = "contact_sub_type_{$second}";
                             if (isset($relationshipType->{$direction})) {
                                 $relatedFields = array_merge((array) $relatedMapperFields[$relationshipType->{$direction}], (array) $relationshipCustomFields);
                             } else {
                                 $target_type = 'contact_type_' . $second;
                                 $relatedFields = array_merge((array) $relatedMapperFields[$relationshipType->{$target_type}], (array) $relationshipCustomFields);
                             }
                         }
                         $relationshipType->free();
                         asort($relatedFields);
                         $sel5[$k][$field] = $relatedFields;
                     }
                 }
             }
         }
         //Location Type for relationship fields
         foreach ($sel5 as $k => $v) {
             if ($v) {
                 foreach ($v as $rel => $fields) {
                     foreach ($fields as $field => $fieldLabel) {
                         if (isset($hasLocationTypes[$k][$field])) {
                             $sel6[$k][$rel][$field] = $locationTypes;
                         }
                     }
                 }
             }
         }
         //PhoneTypes for  relationship fields
         $sel7[''] = NULL;
         foreach ($sel6 as $k => $rel) {
             if ($k) {
                 foreach ($rel as $phonekey => $phonevalue) {
                     foreach ($locationTypes as $locType => $loc) {
                         if (trim($locType) != '') {
                             $sel7[$k][$phonekey]['phone'][$locType] =& $phoneTypes;
                             $sel7[$k][$phonekey]['im'][$locType] =& $imProviders;
                         }
                     }
                 }
             }
         }
     }
     //special fields that have location, hack for primary location
     $specialFields = array('street_address', 'supplemental_address_1', 'supplemental_address_2', 'city', 'postal_code', 'postal_code_suffix', 'geo_code_1', 'geo_code_2', 'state_province', 'country', 'phone', 'email', 'im');
     if (isset($mappingId)) {
         $colCnt = 0;
         list($mappingName, $mappingContactType, $mappingLocation, $mappingPhoneType, $mappingImProvider, $mappingRelation, $mappingOperator, $mappingValue) = CRM_Core_BAO_Mapping::getMappingFields($mappingId);
         $blkCnt = count($mappingName);
         if ($blkCnt >= $blockCount) {
             $blockCount = $blkCnt + 1;
         }
         for ($x = 1; $x < $blockCount; $x++) {
             if (isset($mappingName[$x])) {
                 $colCnt = count($mappingName[$x]);
                 if ($colCnt >= $columnCount[$x]) {
                     $columnCount[$x] = $colCnt;
                 }
             }
         }
     }
     $form->_blockCount = $blockCount;
     $form->_columnCount = $columnCount;
     $form->set('blockCount', $form->_blockCount);
     $form->set('columnCount', $form->_columnCount);
     $defaults = $noneArray = $nullArray = array();
     //used to warn for mismatch column count or mismatch mapping
     $warning = 0;
     for ($x = 1; $x < $blockCount; $x++) {
         for ($i = 0; $i < $columnCount[$x]; $i++) {
             $sel =& $form->addElement('hierselect', "mapper[{$x}][{$i}]", ts('Mapper for Field %1', array(1 => $i)), NULL);
             $jsSet = FALSE;
             if (isset($mappingId)) {
                 $locationId = isset($mappingLocation[$x][$i]) ? $mappingLocation[$x][$i] : 0;
                 if (isset($mappingName[$x][$i])) {
                     if (is_array($mapperFields[$mappingContactType[$x][$i]])) {
                         if (isset($mappingRelation[$x][$i])) {
                             $contactDetails = strtolower(str_replace(" ", "_", $mappingName[$x][$i]));
                             $relLocationId = isset($mappingLocation[$x][$i]) ? $mappingLocation[$x][$i] : 0;
                             if (!$relLocationId && in_array($mappingName[$x][$i], $specialFields)) {
                                 $relLocationId = " ";
                             }
                             $relPhoneType = isset($mappingPhoneType[$x][$i]) ? $mappingPhoneType[$x][$i] : NULL;
                             $defaults["mapper[{$x}][{$i}]"] = array($mappingContactType[$x][$i], $mappingRelation[$x][$i], $locationId, $phoneType, $mappingName[$x][$i], $relLocationId, $relPhoneType);
                             if (!$locationId) {
                                 $noneArray[] = array($x, $i, 2);
                             }
                             if (!$phoneType && !$imProvider) {
                                 $noneArray[] = array($x, $i, 3);
                             }
                             if (!$mappingName[$x][$i]) {
                                 $noneArray[] = array($x, $i, 4);
                             }
                             if (!$relLocationId) {
                                 $noneArray[] = array($x, $i, 5);
                             }
                             if (!$relPhoneType) {
                                 $noneArray[] = array($x, $i, 6);
                             }
                             $noneArray[] = array($x, $i, 2);
                         } else {
                             $phoneType = isset($mappingPhoneType[$x][$i]) ? $mappingPhoneType[$x][$i] : NULL;
                             $imProvider = isset($mappingImProvider[$x][$i]) ? $mappingImProvider[$x][$i] : NULL;
                             if (!$locationId && in_array($mappingName[$x][$i], $specialFields)) {
                                 $locationId = " ";
                             }
                             $defaults["mapper[{$x}][{$i}]"] = array($mappingContactType[$x][$i], $mappingName[$x][$i], $locationId, $phoneType);
                             if (!$mappingName[$x][$i]) {
                                 $noneArray[] = array($x, $i, 1);
                             }
                             if (!$locationId) {
                                 $noneArray[] = array($x, $i, 2);
                             }
                             if (!$phoneType && !$imProvider) {
                                 $noneArray[] = array($x, $i, 3);
                             }
                             $noneArray[] = array($x, $i, 4);
                             $noneArray[] = array($x, $i, 5);
                             $noneArray[] = array($x, $i, 6);
                         }
                         $jsSet = TRUE;
                         if (CRM_Utils_Array::value($i, CRM_Utils_Array::value($x, $mappingOperator))) {
                             $defaults["operator[{$x}][{$i}]"] = CRM_Utils_Array::value($i, $mappingOperator[$x]);
                         }
                         if (CRM_Utils_Array::value($i, CRM_Utils_Array::value($x, $mappingValue))) {
                             $defaults["value[{$x}][{$i}]"] = CRM_Utils_Array::value($i, $mappingValue[$x]);
                         }
                     }
                 }
             }
             //Fix for Search Builder
             if ($mappingType == 'Export') {
                 $j = 7;
             } else {
                 $j = 4;
             }
             $formValues = $form->exportValues();
             if (!$jsSet) {
                 if (empty($formValues)) {
                     // Incremented length for third select box(relationship type)
                     for ($k = 1; $k < $j; $k++) {
                         $noneArray[] = array($x, $i, $k);
                     }
                 } else {
                     if (!empty($formValues['mapper'][$x])) {
                         foreach ($formValues['mapper'][$x] as $value) {
                             for ($k = 1; $k < $j; $k++) {
                                 if (!isset($formValues['mapper'][$x][$i][$k]) || !$formValues['mapper'][$x][$i][$k]) {
                                     $noneArray[] = array($x, $i, $k);
                                 } else {
                                     $nullArray[] = array($x, $i, $k);
                                 }
                             }
                         }
                     } else {
                         for ($k = 1; $k < $j; $k++) {
                             $noneArray[] = array($x, $i, $k);
                         }
                     }
                 }
             }
             //Fix for Search Builder
             if ($mappingType == 'Export') {
                 if (!isset($mappingId) || $i >= count(reset($mappingName))) {
                     if (isset($formValues['mapper']) && isset($formValues['mapper'][$x][$i][1]) && array_key_exists($formValues['mapper'][$x][$i][1], $relationshipTypes)) {
                         $sel->setOptions(array($sel1, $sel2, $sel5, $sel6, $sel7, $sel3, $sel4));
                     } else {
                         $sel->setOptions(array($sel1, $sel2, $sel3, $sel4, $sel5, $sel6, $sel7));
                     }
                 } else {
                     $sel->setOptions(array($sel1, $sel2, $sel3, $sel4, $sel5, $sel6, $sel7));
                 }
             } else {
                 $sel->setOptions(array($sel1, $sel2, $sel3, $sel4));
             }
             if ($mappingType == 'Search Builder') {
                 //CRM -2292, restricted array set
                 $operatorArray = array('' => ts('-operator-')) + CRM_Core_SelectValues::getSearchBuilderOperators();
                 $form->add('select', "operator[{$x}][{$i}]", '', $operatorArray);
                 $form->add('text', "value[{$x}][{$i}]", '');
             }
         }
         //end of columnCnt for
         if ($mappingType == 'Search Builder') {
             $title = ts('Another search field');
         } else {
             $title = ts('Select more fields');
         }
         $form->addElement('submit', "addMore[{$x}]", $title, array('class' => 'submit-link'));
     }
     //end of block for
     $js = "<script type='text/javascript'>\n";
     $formName = "document.{$name}";
     if (!empty($nullArray)) {
         $js .= "var nullArray = [";
         $elements = array();
         $seen = array();
         foreach ($nullArray as $element) {
             $key = "{$element[0]}, {$element[1]}, {$element[2]}";
             if (!isset($seen[$key])) {
                 $elements[] = "[{$key}]";
                 $seen[$key] = 1;
             }
         }
         $js .= implode(', ', $elements);
         $js .= "]";
         $js .= "\n                for (var i=0;i<nullArray.length;i++) {\n                    if ( {$formName}['mapper['+nullArray[i][0]+']['+nullArray[i][1]+']['+nullArray[i][2]+']'] ) {\n                        {$formName}['mapper['+nullArray[i][0]+']['+nullArray[i][1]+']['+nullArray[i][2]+']'].style.display = '';\n                    }\n                }\n";
     }
     if (!empty($noneArray)) {
         $js .= "var noneArray = [";
         $elements = array();
         $seen = array();
         foreach ($noneArray as $element) {
             $key = "{$element[0]}, {$element[1]}, {$element[2]}";
             if (!isset($seen[$key])) {
                 $elements[] = "[{$key}]";
                 $seen[$key] = 1;
             }
         }
         $js .= implode(', ', $elements);
         $js .= "]";
         $js .= "\n                for (var i=0;i<noneArray.length;i++) {\n                    if ( {$formName}['mapper['+noneArray[i][0]+']['+noneArray[i][1]+']['+noneArray[i][2]+']'] ) {\n  {$formName}['mapper['+noneArray[i][0]+']['+noneArray[i][1]+']['+noneArray[i][2]+']'].style.display = 'none';\n                    }\n                }\n";
     }
     $js .= "</script>\n";
     $form->assign('initHideBoxes', $js);
     $form->assign('columnCount', $columnCount);
     $form->assign('blockCount', $blockCount);
     $form->setDefaults($defaults);
     $form->setDefaultAction('refresh');
 }
コード例 #24
0
ファイル: Field.php プロジェクト: kidaa30/yes
 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete Profile Field'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
         return;
     }
     if (isset($this->_id)) {
         $params = array('id' => $this->_id);
         CRM_Core_BAO_UFField::retrieve($params, $defaults);
         // set it to null if so (avoids crappy E_NOTICE errors below
         $defaults['location_type_id'] = CRM_Utils_Array::value('location_type_id', $defaults);
         $specialFields = CRM_Core_BAO_UFGroup::getLocationFields();
         if (!$defaults['location_type_id'] && $defaults["field_type"] != "Formatting" && in_array($defaults['field_name'], $specialFields)) {
             $defaults['location_type_id'] = 0;
         }
         $defaults['field_name'] = array($defaults['field_type'], $defaults['field_type'] == "Formatting" ? "" : $defaults['field_name'], $defaults['field_name'] == "url" ? $defaults['website_type_id'] : $defaults['location_type_id'], CRM_Utils_Array::value('phone_type_id', $defaults));
         $this->_gid = $defaults['uf_group_id'];
     } else {
         $defaults['is_active'] = 1;
     }
     $otherModules = array_values(CRM_Core_BAO_UFGroup::getUFJoinRecord($this->_gid));
     $this->assign('otherModules', $otherModules);
     if ($this->_action & CRM_Core_Action::ADD) {
         $fieldValues = array('uf_group_id' => $this->_gid);
         $defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_UFField', $fieldValues);
     }
     // lets trim all the whitespace
     $this->applyFilter('__ALL__', 'trim');
     //hidden field to catch the group id in profile
     $this->add('hidden', 'group_id', $this->_gid);
     //hidden field to catch the field id in profile
     $this->add('hidden', 'field_id', $this->_id);
     $fields = CRM_Core_BAO_UFField::getAvailableFields($this->_gid, $defaults);
     $noSearchable = $hasWebsiteTypes = array();
     $addressCustomFields = array_keys(CRM_Core_BAO_CustomField::getFieldsForImport('Address'));
     foreach ($fields as $key => $value) {
         foreach ($value as $key1 => $value1) {
             //CRM-2676, replacing the conflict for same custom field name from different custom group.
             if ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($key1)) {
                 $customGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $customFieldId, 'custom_group_id');
                 $customGroupName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $customGroupId, 'title');
                 $this->_mapperFields[$key][$key1] = $value1['title'] . ' :: ' . $customGroupName;
                 if (in_array($key1, $addressCustomFields)) {
                     $noSearchable[] = $value1['title'] . ' :: ' . $customGroupName;
                 }
             } else {
                 $this->_mapperFields[$key][$key1] = $value1['title'];
             }
             $hasLocationTypes[$key][$key1] = CRM_Utils_Array::value('hasLocationType', $value1);
             $hasWebsiteTypes[$key][$key1] = CRM_Utils_Array::value('hasWebsiteType', $value1);
             // hide the 'is searchable' field for 'File' custom data
             if (isset($value1['data_type']) && isset($value1['html_type']) && ($value1['data_type'] == 'File' && $value1['html_type'] == 'File' || $value1['data_type'] == 'Link' && $value1['html_type'] == 'Link')) {
                 if (!in_array($value1['title'], $noSearchable)) {
                     $noSearchable[] = $value1['title'];
                 }
             }
         }
     }
     $this->assign('noSearchable', $noSearchable);
     $this->_location_types = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
     $defaultLocationType = CRM_Core_BAO_LocationType::getDefault();
     $this->_website_types = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id');
     /**
      * FIXME: dirty hack to make the default option show up first.  This
      * avoids a mozilla browser bug with defaults on dynamically constructed
      * selector widgets.
      */
     if ($defaultLocationType) {
         $defaultLocation = $this->_location_types[$defaultLocationType->id];
         unset($this->_location_types[$defaultLocationType->id]);
         $this->_location_types = array($defaultLocationType->id => $defaultLocation) + $this->_location_types;
     }
     $this->_location_types = array('Primary') + $this->_location_types;
     // since we need a hierarchical list to display contact types & subtypes,
     // this is what we going to display in first selector
     $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, FALSE);
     unset($contactTypes['']);
     $contactTypes = !empty($contactTypes) ? array('Contact' => 'Contacts') + $contactTypes : array();
     $sel1 = array('' => '- select -') + $contactTypes;
     if (!empty($fields['Activity'])) {
         $sel1['Activity'] = 'Activity';
     }
     if (CRM_Core_Permission::access('CiviEvent')) {
         $sel1['Participant'] = 'Participants';
     }
     if (!empty($fields['Contribution'])) {
         $sel1['Contribution'] = 'Contributions';
     }
     if (!empty($fields['Membership'])) {
         $sel1['Membership'] = 'Membership';
     }
     if (!empty($fields['Case'])) {
         $sel1['Case'] = 'Case';
     }
     if (!empty($fields['Formatting'])) {
         $sel1['Formatting'] = 'Formatting';
     }
     foreach ($sel1 as $key => $sel) {
         if ($key) {
             $sel2[$key] = $this->_mapperFields[$key];
         }
     }
     $sel3[''] = NULL;
     $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
     ksort($phoneTypes);
     foreach ($sel1 as $k => $sel) {
         if ($k) {
             foreach ($this->_location_types as $key => $value) {
                 $sel4[$k]['phone'][$key] =& $phoneTypes;
                 $sel4[$k]['phone_and_ext'][$key] =& $phoneTypes;
             }
         }
     }
     foreach ($sel1 as $k => $sel) {
         if ($k) {
             if (is_array($this->_mapperFields[$k])) {
                 foreach ($this->_mapperFields[$k] as $key => $value) {
                     if ($hasLocationTypes[$k][$key]) {
                         $sel3[$k][$key] = $this->_location_types;
                     } elseif ($hasWebsiteTypes[$k][$key]) {
                         $sel3[$k][$key] = $this->_website_types;
                     } else {
                         $sel3[$key] = NULL;
                     }
                 }
             }
         }
     }
     $this->_defaults = array();
     $js = "<script type='text/javascript'>\n";
     $formName = "document.{$this->_name}";
     $alreadyMixProfile = FALSE;
     if (CRM_Core_BAO_UFField::checkProfileType($this->_gid)) {
         $alreadyMixProfile = TRUE;
     }
     $this->assign('alreadyMixProfile', $alreadyMixProfile);
     $sel =& $this->addElement('hierselect', 'field_name', ts('Field Name'));
     $formValues = $this->exportValues();
     if (empty($formValues)) {
         for ($k = 1; $k < 4; $k++) {
             if (!isset($defaults['field_name'][$k])) {
                 $js .= "{$formName}['field_name[{$k}]'].style.display = 'none';\n";
             }
         }
     } else {
         if (!empty($formValues['field_name'])) {
             for ($key = 1; $key < 4; $key++) {
                 if (!isset($formValues['field_name'][$key])) {
                     $js .= "{$formName}['field_name[{$key}]'].style.display = 'none';\n";
                 } else {
                     $js .= "{$formName}['field_name[{$key}]'].style.display = '';\n";
                 }
             }
         } else {
             for ($k = 1; $k < 4; $k++) {
                 if (!isset($defaults['field_name'][$k])) {
                     $js .= "{$formName}['field_name[{$k}]'].style.display = 'none';\n";
                 }
             }
         }
     }
     foreach ($sel2 as $k => $v) {
         if (is_array($sel2[$k])) {
             asort($sel2[$k]);
         }
     }
     $sel->setOptions(array($sel1, $sel2, $sel3, $sel4));
     // proper interpretation of spec in CRM-8732
     if (!isset($this->_id) && in_array('Search Profile', $otherModules)) {
         $defaults['visibility'] = 'Public Pages and Listings';
     }
     $js .= "</script>\n";
     $this->assign('initHideBoxes', $js);
     $this->add('select', 'visibility', ts('Visibility'), CRM_Core_SelectValues::ufVisibility(), TRUE, array('onChange' => "showHideSeletorSearch(this.value);"));
     //CRM-4363
     $js = array('onChange' => "mixProfile();");
     // should the field appear in selectors (as a column)?
     $this->add('checkbox', 'in_selector', ts('Results Column?'), NULL, NULL, $js);
     $this->add('checkbox', 'is_searchable', ts('Searchable?'), NULL, NULL, $js);
     $attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFField');
     // weight
     $this->add('text', 'weight', ts('Order'), $attributes['weight'], TRUE);
     $this->addRule('weight', ts('is a numeric field'), 'numeric');
     $this->add('textarea', 'help_pre', ts('Field Pre Help'), $attributes['help_pre']);
     $this->add('textarea', 'help_post', ts('Field Post Help'), $attributes['help_post']);
     $this->add('checkbox', 'is_required', ts('Required?'));
     $this->add('checkbox', 'is_multi_summary', ts('Include in multi-record listing?'));
     $this->add('checkbox', 'is_active', ts('Active?'));
     $this->add('checkbox', 'is_view', ts('View Only?'));
     // $this->add( 'checkbox', 'is_registration', ts( 'Display in Registration Form?' ) );
     //$this->add( 'checkbox', 'is_match'       , ts( 'Key to Match Contacts?'        ) );
     $this->add('text', 'label', ts('Field Label'), $attributes['label']);
     $js = NULL;
     if ($this->_hasSearchableORInSelector) {
         $js = array('onclick' => "return verify( );");
     }
     // add buttons
     $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE, 'js' => $js), array('type' => 'next', 'name' => ts('Save and New'), 'subName' => 'new', 'js' => $js), array('type' => 'cancel', 'name' => ts('Cancel'))));
     $this->addFormRule(array('CRM_UF_Form_Field', 'formRule'), $this);
     // if view mode pls freeze it with the done button.
     if ($this->_action & CRM_Core_Action::VIEW) {
         $this->freeze();
         $this->addElement('button', 'done', ts('Done'), array('onclick' => "location.href='civicrm/admin/uf/group/field?reset=1&action=browse&gid=" . $this->_gid . "'"));
     }
     $this->setDefaults($defaults);
 }
コード例 #25
0
ファイル: Basic.php プロジェクト: nielosz/civicrm-core
 /**
  * Browse all entities.
  */
 public function browse()
 {
     $n = func_num_args();
     $action = $n > 0 ? func_get_arg(0) : NULL;
     $sort = $n > 0 ? func_get_arg(1) : NULL;
     $links =& $this->links();
     if ($action == NULL) {
         if (!empty($links)) {
             $action = array_sum(array_keys($links));
         }
     }
     if ($action & CRM_Core_Action::DISABLE) {
         $action -= CRM_Core_Action::DISABLE;
     }
     if ($action & CRM_Core_Action::ENABLE) {
         $action -= CRM_Core_Action::ENABLE;
     }
     $baoString = $this->getBAOName();
     $object = new $baoString();
     $values = array();
     // lets make sure we get the stuff sorted by name if it exists
     $fields =& $object->fields();
     $key = '';
     if (!empty($fields['title'])) {
         $key = 'title';
     } elseif (!empty($fields['label'])) {
         $key = 'label';
     } elseif (!empty($fields['name'])) {
         $key = 'name';
     }
     if (trim($sort)) {
         $object->orderBy($sort);
     } elseif ($key) {
         $object->orderBy($key . ' asc');
     }
     $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, FALSE);
     // find all objects
     $object->find();
     while ($object->fetch()) {
         if (!isset($object->mapping_type_id) || $object->mapping_type_id != 1) {
             $permission = CRM_Core_Permission::EDIT;
             if ($key) {
                 $permission = $this->checkPermission($object->id, $object->{$key});
             }
             if ($permission) {
                 $values[$object->id] = array();
                 CRM_Core_DAO::storeValues($object, $values[$object->id]);
                 if (is_a($object, 'CRM_Contact_DAO_RelationshipType')) {
                     if (isset($values[$object->id]['contact_type_a'])) {
                         $values[$object->id]['contact_type_a_display'] = $contactTypes[$values[$object->id]['contact_type_a']];
                     }
                     if (isset($values[$object->id]['contact_type_b'])) {
                         $values[$object->id]['contact_type_b_display'] = $contactTypes[$values[$object->id]['contact_type_b']];
                     }
                 }
                 // populate action links
                 $this->action($object, $action, $values[$object->id], $links, $permission);
                 if (isset($object->mapping_type_id)) {
                     $mappintTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Mapping', 'mapping_type_id');
                     $values[$object->id]['mapping_type'] = $mappintTypes[$object->mapping_type_id];
                 }
             }
         }
     }
     $this->assign('rows', $values);
 }
コード例 #26
0
ファイル: Criteria.php プロジェクト: bhirsch/civicrm
 static function basic(&$form)
 {
     $form->addElement('hidden', 'hidden_basic', 1);
     if ($form->_searchOptions['contactType']) {
         // add checkboxes for contact type
         $contact_type = array();
         require_once 'CRM/Contact/BAO/ContactType.php';
         $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements();
         foreach ($contactTypes as $k => $v) {
             if (!empty($k)) {
                 $contact_type[] = HTML_QuickForm::createElement('checkbox', $k, null, $v);
             }
         }
         $form->addGroup($contact_type, 'contact_type', ts('Contact Type(s)'), '<br />');
     }
     if ($form->_searchOptions['groups']) {
         // checkboxes for groups
         foreach ($form->_group as $groupID => $group) {
             $form->_groupElement =& $form->addElement('checkbox', "group[{$groupID}]", null, $group);
         }
     }
     if ($form->_searchOptions['tags']) {
         // checkboxes for categories
         require_once 'CRM/Core/BAO/Tag.php';
         $tags = new CRM_Core_BAO_Tag();
         $tree = $tags->getTree();
         $form->assign('tree', $tags->getTree());
         foreach ($form->_tag as $tagID => $tagName) {
             $form->_tagElement =& $form->addElement('checkbox', "tag[{$tagID}]", null, $tagName);
         }
     }
     // add text box for last name, first name, street name, city
     $form->addElement('text', 'sort_name', ts('Find...'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     // add text box for last name, first name, street name, city
     $form->add('text', 'email', ts('Contact Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     //added contact source
     $form->add('text', 'contact_source', ts('Contact Source'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'source'));
     // add checkbox for cms users only
     if (CIVICRM_UF != 'Standalone') {
         $form->addYesNo('uf_user', ts('CMS User?'));
     }
     // add search profiles
     require_once 'CRM/Core/BAO/UFGroup.php';
     // FIXME: This is probably a part of profiles - need to be
     // FIXME: eradicated from here when profiles are reworked.
     $types = array('Participant', 'Contribution', 'Membership');
     // get component profiles
     $componentProfiles = array();
     $componentProfiles = CRM_Core_BAO_UFGroup::getProfiles($types);
     $ufGroups =& CRM_Core_BAO_UFGroup::getModuleUFGroup('Search Profile', 1);
     $accessibleUfGroups = CRM_Core_Permission::ufGroup(CRM_Core_Permission::VIEW);
     $searchProfiles = array();
     foreach ($ufGroups as $key => $var) {
         if (!array_key_exists($key, $componentProfiles) && in_array($key, $accessibleUfGroups)) {
             $searchProfiles[$key] = $var['title'];
         }
     }
     $form->addElement('select', 'uf_group_id', ts('Search Views'), array('0' => ts('- default view -')) + $searchProfiles);
     // checkboxes for DO NOT phone, email, mail
     // we take labels from SelectValues
     $t = CRM_Core_SelectValues::privacy();
     $t['do_not_toggle'] = ts('Include contacts who have these privacy option(s).');
     $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_phone', null, $t['do_not_phone']);
     $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_email', null, $t['do_not_email']);
     $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_mail', null, $t['do_not_mail']);
     $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_sms', null, $t['do_not_sms']);
     $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_trade', null, $t['do_not_trade']);
     $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_toggle', null, $t['do_not_toggle']);
     $form->addGroup($privacy, 'privacy', ts('Privacy'), array('&nbsp;', '&nbsp;', '&nbsp;', '<br/>'));
     // preferred communication method
     require_once 'CRM/Core/PseudoConstant.php';
     $comm = CRM_Core_PseudoConstant::pcm();
     $commPreff = array();
     foreach ($comm as $k => $v) {
         $commPreff[] = HTML_QuickForm::createElement('advcheckbox', $k, null, $v);
     }
     $form->addGroup($commPreff, 'preferred_communication_method', ts('Preferred Communication Method'));
 }
コード例 #27
0
ファイル: MultipleValues.php プロジェクト: kidaa30/yes
 /**
  * @param CRM_Core_Form $form
  */
 public function buildForm(&$form)
 {
     /**
      * You can define a custom title for the search form
      */
     $this->setTitle('Multiple Value Custom Group Search and Export');
     $form->add('text', 'sort_name', ts('Contact Name'), TRUE);
     // add select for contact type
     //@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;
     $contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator);
     $form->add('select', 'contact_type', ts('Find...'), $contactTypes, array('class' => 'crm-select2 huge'));
     // add select for groups
     $group = array('' => ts('- any group -')) + CRM_Core_PseudoConstant::group();
     $form->addElement('select', 'group', ts('in'), $group, array('class' => 'crm-select2 huge'));
     // add select for tags
     $tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
     $form->addElement('select', 'tag', ts('Tagged'), $tag, array('class' => 'crm-select2 huge'));
     if (empty($this->_groupTree)) {
         CRM_Core_Error::statusBounce(ts("Atleast one Custom Group must be present, for Custom Group search."), CRM_Utils_System::url('civicrm/contact/search/custom/list', 'reset=1'));
     }
     // add the checkbox for custom_groups
     foreach ($this->_groupTree as $groupID => $group) {
         if ($groupID == 'info') {
             continue;
         }
         $form->addElement('checkbox', "custom_group[{$groupID}]", NULL, $group['title']);
     }
 }
コード例 #28
0
 static function basic(&$form)
 {
     $form->addElement('hidden', 'hidden_basic', 1);
     if ($form->_searchOptions['contactType']) {
         // add checkboxes for contact type
         $contact_type = array();
         require_once 'CRM/Contact/BAO/ContactType.php';
         $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements();
         if ($contactTypes) {
             $form->add('select', 'contact_type', ts('Contact Type(s)'), $contactTypes, false, array('id' => 'contact_type', 'multiple' => 'multiple', 'title' => ts('- select -')));
         }
     }
     if ($form->_searchOptions['groups']) {
         // multiselect for groups
         if ($form->_group) {
             $form->add('select', 'group', ts('Groups'), $form->_group, false, array('id' => 'group', 'multiple' => 'multiple', 'title' => ts('- select -')));
         }
     }
     if ($form->_searchOptions['tags']) {
         // multiselect for categories
         require_once 'CRM/Core/BAO/Tag.php';
         $contactTags = CRM_Core_BAO_Tag::getTags();
         if ($contactTags) {
             $form->add('select', 'contact_tags', ts('Tags'), $contactTags, false, array('id' => 'contact_tags', 'multiple' => 'multiple', 'title' => ts('- select -')));
         }
         require_once 'CRM/Core/Form/Tag.php';
         require_once 'CRM/Core/BAO/Tag.php';
         $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
         CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', null, true);
     }
     // add text box for last name, first name, street name, city
     $form->addElement('text', 'sort_name', ts('Find...'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     // add text box for last name, first name, street name, city
     $form->add('text', 'email', ts('Contact Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     //added contact source
     $form->add('text', 'contact_source', ts('Contact Source'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'source'));
     //added job title
     $attributes['job_title']['size'] = 30;
     $form->addElement('text', 'job_title', ts('Job Title'), $attributes['job_title'], 'size="30"');
     $config =& CRM_Core_Config::singleton();
     if (CRM_Core_Permission::check('access deleted contacts') and $config->contactUndelete) {
         $form->add('checkbox', 'deleted_contacts', ts('Search in Trash (deleted contacts)'));
     }
     // add checkbox for cms users only
     $form->addYesNo('uf_user', ts('CMS User?'));
     // add search profiles
     require_once 'CRM/Core/BAO/UFGroup.php';
     // FIXME: This is probably a part of profiles - need to be
     // FIXME: eradicated from here when profiles are reworked.
     $types = array('Participant', 'Contribution', 'Membership');
     // get component profiles
     $componentProfiles = array();
     $componentProfiles = CRM_Core_BAO_UFGroup::getProfiles($types);
     $ufGroups =& CRM_Core_BAO_UFGroup::getModuleUFGroup('Search Profile', 1);
     $accessibleUfGroups = CRM_Core_Permission::ufGroup(CRM_Core_Permission::VIEW);
     $searchProfiles = array();
     foreach ($ufGroups as $key => $var) {
         if (!array_key_exists($key, $componentProfiles) && in_array($key, $accessibleUfGroups)) {
             $searchProfiles[$key] = $var['title'];
         }
     }
     $form->addElement('select', 'uf_group_id', ts('Search Views'), array('0' => ts('- default view -')) + $searchProfiles);
     require_once 'CRM/Contact/Form/Search.php';
     $componentModes =& CRM_Contact_Form_Search::getModeSelect();
     // unset contributions or participants if user does not have
     // permission on them
     if (!CRM_Core_Permission::access('CiviContribute')) {
         unset($componentModes['2']);
     }
     if (!CRM_Core_Permission::access('CiviEvent')) {
         unset($componentModes['3']);
     }
     if (!CRM_Core_Permission::check('view all activities')) {
         unset($componentModes['4']);
     }
     if (count($componentModes) > 1) {
         $form->addElement('select', 'component_mode', ts('Display Results As'), $componentModes);
     }
     // checkboxes for DO NOT phone, email, mail
     // we take labels from SelectValues
     $t = CRM_Core_SelectValues::privacy();
     $t['do_not_toggle'] = ts('Include contacts who have these privacy option(s).');
     $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_phone', null, $t['do_not_phone']);
     $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_email', null, $t['do_not_email']);
     $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_mail', null, $t['do_not_mail']);
     $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_sms', null, $t['do_not_sms']);
     $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_trade', null, $t['do_not_trade']);
     $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_toggle', null, $t['do_not_toggle']);
     $form->addGroup($privacy, 'privacy', ts('Privacy'), array('&nbsp;', '&nbsp;', '&nbsp;', '<br/>'));
     // preferred communication method
     require_once 'CRM/Core/PseudoConstant.php';
     $comm = CRM_Core_PseudoConstant::pcm();
     $commPreff = array();
     foreach ($comm as $k => $v) {
         $commPreff[] = HTML_QuickForm::createElement('advcheckbox', $k, null, $v);
     }
     $onHold[] = HTML_QuickForm::createElement('advcheckbox', 'on_hold', null, ts(''));
     $form->addGroup($onHold, 'email_on_hold', ts('Email On Hold'));
     $form->addGroup($commPreff, 'preferred_communication_method', ts('Preferred Communication Method'));
     //CRM-6138 Preferred Language
     $langPreff = CRM_Core_PseudoConstant::languages();
     $form->add('select', 'preferred_language', ts('Preferred Language'), array('' => ts('- select language -')) + $langPreff);
 }