CRM-13929 - Parameterize radio clear widget
[civicrm-core.git] / CRM / Contact / Form / Search / Criteria.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
232624b1 4 | CiviCRM version 4.4 |
6a488035
TO
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26*/
27
28/**
29 *
30 * @package CRM
31 * @copyright CiviCRM LLC (c) 2004-2013
32 * $Id$
33 *
34 */
35class CRM_Contact_Form_Search_Criteria {
8a4f27dc
CW
36 /**
37 * @param $form CRM_Core_Form
38 */
6a488035
TO
39 static function basic(&$form) {
40 $form->addElement('hidden', 'hidden_basic', 1);
41
42 if ($form->_searchOptions['contactType']) {
43 // add checkboxes for contact type
6a488035
TO
44 $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements();
45
46 if ($contactTypes) {
47 $form->add('select', 'contact_type', ts('Contact Type(s)'), $contactTypes, FALSE,
02ddf039 48 array('id' => 'contact_type', 'multiple' => 'multiple', 'class' => 'crm-select2', 'style' => 'width: 100%;')
6a488035
TO
49 );
50 }
51 }
52
53 if ($form->_searchOptions['groups']) {
54 // multiselect for groups
55 if ($form->_group) {
56 // Arrange groups into hierarchical listing (child groups follow their parents and have indentation spacing in title)
f828fa2c 57 $groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($form->_group, NULL, '&nbsp;&nbsp;', TRUE);
6a488035
TO
58
59 $form->add('select', 'group', ts('Groups'), $groupHierarchy, FALSE,
02ddf039 60 array('id' => 'group', 'multiple' => 'multiple', 'class' => 'crm-select2')
6a488035
TO
61 );
62 $groupOptions = CRM_Core_BAO_OptionValue::getOptionValuesAssocArrayFromName('group_type');
63 $form->add('select', 'group_type', ts('Group Types'), $groupOptions, FALSE,
02ddf039 64 array('id' => 'group_type', 'multiple' => 'multiple', 'class' => 'crm-select2')
6a488035
TO
65 );
66 $form->add('hidden','group_search_selected','group');
67 }
68 }
69
70 if ($form->_searchOptions['tags']) {
71 // multiselect for categories
72 $contactTags = CRM_Core_BAO_Tag::getTags();
73
74 if ($contactTags) {
75 $form->add('select', 'contact_tags', ts('Tags'), $contactTags, FALSE,
02ddf039 76 array('id' => 'contact_tags', 'multiple' => 'multiple', 'class' => 'crm-select2', 'style' => 'width: 100%;')
6a488035
TO
77 );
78 }
79
80 $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
81 CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', NULL, TRUE, FALSE, TRUE);
f828fa2c 82
6a488035
TO
83 $used_for = CRM_Core_OptionGroup::values('tag_used_for');
84 $tagsTypes = array();
85 $showAllTagTypes = false;
86 foreach ($used_for as $key => $value) {
87 //check tags for every type and find if there are any defined
88 $tags = CRM_Core_BAO_Tag::getTagsUsedFor($key, FALSE, TRUE, NULL);
89 // check if there are tags other than contact type, if no - keep checkbox hidden on adv search
90 // we will hide searching contact by attachments tags until it will be implemented in core
91 if (count($tags) && $key != 'civicrm_file' && $key != 'civicrm_contact') {
92 //if tags exists then add type to display in adv search form help text
f828fa2c 93 $tagsTypes[] = ts($value);
6a488035
TO
94 $showAllTagTypes = true;
95 }
96 }
97 $tagTypesText = implode(" or ", $tagsTypes);
98 if ($showAllTagTypes) {
99 $form->add('checkbox', 'all_tag_types', ts('Include tags used for %1', array(1 => $tagTypesText)));
100 $form->add('hidden','tag_types_text', $tagTypesText);
101 }
102 }
103
104 // add text box for last name, first name, street name, city
105 $form->addElement('text', 'sort_name', ts('Find...'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
106
107 // add text box for last name, first name, street name, city
108 $form->add('text', 'email', ts('Contact Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
109
110 //added contact source
111 $form->add('text', 'contact_source', ts('Contact Source'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'contact_source'));
112
113 //added job title
114 $form->addElement('text', 'job_title', ts('Job Title'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'job_title'));
115
116
117 //added internal ID
c8ef633b 118 $form->addElement('text', 'contact_id', ts('Contact ID'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'id'));
5a0739f2 119 $form->addRule('contact_id', ts('Please enter valid Contact ID'), 'positiveInteger');
6a488035
TO
120
121 //added external ID
122 $form->addElement('text', 'external_identifier', ts('External ID'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'external_identifier'));
123
124 if (CRM_Core_Permission::check('access deleted contacts') and CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_undelete', NULL)) {
125 $form->add('checkbox', 'deleted_contacts', ts('Search in Trash') . '<br />' . ts('(deleted contacts)'));
126 }
127
128 // add checkbox for cms users only
8a4f27dc 129 $form->addYesNo('uf_user', ts('CMS User?'), TRUE);
6a488035
TO
130
131 // tag all search
132 $form->add('text', 'tag_search', ts('All Tags'));
133
134 // add search profiles
135
136 // FIXME: This is probably a part of profiles - need to be
137 // FIXME: eradicated from here when profiles are reworked.
138 $types = array('Participant', 'Contribution', 'Membership');
139
140 // get component profiles
141 $componentProfiles = array();
142 $componentProfiles = CRM_Core_BAO_UFGroup::getProfiles($types);
143
144 $ufGroups = CRM_Core_BAO_UFGroup::getModuleUFGroup('Search Profile', 1);
145 $accessibleUfGroups = CRM_Core_Permission::ufGroup(CRM_Core_Permission::VIEW);
146
147 $searchProfiles = array();
148 foreach ($ufGroups as $key => $var) {
149 if (!array_key_exists($key, $componentProfiles) && in_array($key, $accessibleUfGroups)) {
150 $searchProfiles[$key] = $var['title'];
151 }
152 }
153
154 $form->addElement('select',
155 'uf_group_id',
156 ts('Search Views'),
157 array(
158 '0' => ts('- default view -')) + $searchProfiles
159 );
160
161 $componentModes = CRM_Contact_Form_Search::getModeSelect();
162
163 // unset contributions or participants if user does not have
164 // permission on them
165 if (!CRM_Core_Permission::access('CiviContribute')) {
166 unset($componentModes['2']);
167 }
168
169 if (!CRM_Core_Permission::access('CiviEvent')) {
170 unset($componentModes['3']);
171 }
172
173 if (!CRM_Core_Permission::access('CiviMember')) {
174 unset($componentModes['5']);
175 }
176
177 if (!CRM_Core_Permission::check('view all activities')) {
178 unset($componentModes['4']);
179 }
180
181 if (count($componentModes) > 1) {
182 $form->addElement('select',
183 'component_mode',
184 ts('Display Results As'),
185 $componentModes
186 );
187 }
188
189 $form->addElement('select',
190 'operator',
191 ts('Search Operator'),
192 array('AND' => ts('AND'),
193 'OR' => ts('OR'),
194 )
195 );
196
197 // add the option to display relationships
198 $rTypes = CRM_Core_PseudoConstant::relationshipType();
199 $rSelect = array('' => ts('- Select Relationship Type-'));
200 foreach ($rTypes as $rid => $rValue) {
201 if ($rValue['label_a_b'] == $rValue['label_b_a']) {
202 $rSelect[$rid] = $rValue['label_a_b'];
203 }
204 else {
205 $rSelect["{$rid}_a_b"] = $rValue['label_a_b'];
206 $rSelect["{$rid}_b_a"] = $rValue['label_b_a'];
207 }
208 }
209
210 $form->addElement('select',
211 'display_relationship_type',
212 ts('Display Results as Relationship'),
213 $rSelect
214 );
215
216 // checkboxes for DO NOT phone, email, mail
217 // we take labels from SelectValues
218 $t = CRM_Core_SelectValues::privacy();
219 $form->add('select',
220 'privacy_options',
221 ts('Privacy'),
222 $t,
223 FALSE,
224 array(
225 'id' => 'privacy_options',
226 'multiple' => 'multiple',
02ddf039 227 'class' => 'crm-select2',
6a488035
TO
228 )
229 );
230
231 $form->addElement('select',
232 'privacy_operator',
233 ts('Operator'),
234 array('OR' => ts('OR'),
235 'AND' => ts('AND'),
236 )
237 );
238
239 $options = array(
240 1 => ts('Exclude'),
241 2 => ts('Include by Privacy Option(s)'),
242 );
8a4f27dc 243 $form->addRadio('privacy_toggle', ts('Privacy Options'), $options, NULL, NULL, TRUE);
6a488035
TO
244
245 // preferred communication method
e7e657f0 246 $comm = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method');
6a488035
TO
247
248 $commPreff = array();
249 foreach ($comm as $k => $v) {
250 $commPreff[] = $form->createElement('advcheckbox', $k, NULL, $v);
251 }
252
253 $onHold[] = $form->createElement('advcheckbox', 'on_hold', NULL, ts(''));
254 $form->addGroup($onHold, 'email_on_hold', ts('Email On Hold'));
255
256 $form->addGroup($commPreff, 'preferred_communication_method', ts('Preferred Communication Method'));
257
258 //CRM-6138 Preferred Language
02ddf039 259 $form->add('select', 'preferred_language', ts('Preferred Language'), array('' => ts('- any -')) + CRM_Contact_BAO_Contact::buildOptions('preferred_language'), FALSE, array('class' => 'crm-select2'));
6a488035
TO
260
261 // Phone search
262 $form->addElement('text', 'phone_numeric', ts('Phone Number'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone'));
b2b0530a 263 $locationType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
b4f964d9 264 $phoneType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
6a488035
TO
265 $form->add('select', 'phone_location_type_id', ts('Phone Location'), array('' => ts('- any -')) + $locationType);
266 $form->add('select', 'phone_phone_type_id', ts('Phone Type'), array('' => ts('- any -')) + $phoneType);
267 }
268
269
270 static function location(&$form) {
271 // Build location criteria based on _submitValues if
272 // available; otherwise, use $form->_formValues.
273 $formValues = $form->_submitValues;
274
275 if (empty($formValues) && !empty($form->_formValues)) {
276 $formValues = $form->_formValues;
277 }
278
279 $form->addElement('hidden', 'hidden_location', 1);
280
281 $addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
282 'address_options', TRUE, NULL, TRUE
283 );
284
285 $attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Address');
286
287 $elements = array(
288 'street_address' => array(ts('Street Address'), $attributes['street_address'], NULL, NULL),
289 'city' => array(ts('City'), $attributes['city'], NULL, NULL),
290 'postal_code' => array(ts('Zip / Postal Code'), $attributes['postal_code'], NULL, NULL),
291 'county' => array(ts('County'), $attributes['county_id'], 'county', TRUE),
292 'state_province' => array(ts('State / Province'), $attributes['state_province_id'], 'stateProvince', TRUE),
293 'country' => array(ts('Country'), $attributes['country_id'], 'country', FALSE),
294 'address_name' => array(ts('Address Name'), $attributes['address_name'], NULL, NULL),
295 'street_number' => array(ts('Street Number'), $attributes['street_number'], NULL, NULL),
296 'street_name' => array(ts('Street Name'), $attributes['street_name'], NULL, NULL),
297 'street_unit' => array(ts('Apt/Unit/Suite'), $attributes['street_unit'], NULL, NULL),
298 );
299
300 $parseStreetAddress = CRM_Utils_Array::value('street_address_parsing', $addressOptions, 0);
301 $form->assign('parseStreetAddress', $parseStreetAddress);
302 foreach ($elements as $name => $v) {
303 list($title, $attributes, $select, $multiSelect) = $v;
304
305 if (in_array($name,
306 array('street_number', 'street_name', 'street_unit')
307 )) {
308 if (!$parseStreetAddress) {
309 continue;
310 }
311 }
312 elseif (!$addressOptions[$name]) {
313 continue;
314 }
315
316 if (!$attributes) {
317 $attributes = $attributes[$name];
318 }
319
320 if ($select) {
6a488035
TO
321 $stateCountryMap[] = array(
322 'state_province' => 'state_province',
323 'country' => 'country',
324 'county' => 'county',
325 );
326 if ($select == 'stateProvince') {
a7488080 327 if (!empty($formValues['country'])) {
6a488035
TO
328 $selectElements = array('' => ts('- select -')) + CRM_Core_PseudoConstant::stateProvinceForCountry($formValues['country']);
329 }
330 else {
331 //if not setdefault any country
02ddf039 332 $selectElements = CRM_Core_PseudoConstant::$select();
6a488035 333 }
02ddf039 334 $element = $form->add('select', $name, $title, $selectElements, FALSE, array('class' => 'crm-select2'));
6a488035
TO
335 }
336 elseif ($select == 'country') {
6a488035 337 $selectElements = array('' => ts('- any -')) + CRM_Core_PseudoConstant::$select();
02ddf039 338 $element = $form->add('select', $name, $title, $selectElements, FALSE, array('class' => 'crm-select2'));
6a488035
TO
339 }
340 elseif ($select == 'county') {
341 if ( array_key_exists('state_province', $formValues) && !CRM_Utils_System::isNull($formValues['state_province'])) {
342 $selectElements = array('' => ts('- select -')) + CRM_Core_PseudoConstant::countyForState($formValues['state_province']);
343 }
344 else {
345 $selectElements = array('' => ts('- any -'));
346 }
02ddf039 347 $element = $form->add('select', $name, $title, $selectElements, FALSE, array('class' => 'crm-select2'));
6a488035
TO
348 }
349 else {
350 $selectElements = array('' => ts('- any -')) + CRM_Core_PseudoConstant::$select();
02ddf039 351 $element = $form->add('select', $name, $title, $selectElements, FALSE, array('class' => 'crm-select2'));
6a488035
TO
352 }
353 if ($multiSelect) {
354 $element->setMultiple(TRUE);
355 }
356 }
357 else {
358 $form->addElement('text', $name, $title, $attributes);
359 }
360
361 if ($addressOptions['postal_code']) {
362 $form->addElement('text', 'postal_code_low', ts('Range-From'),
363 CRM_Utils_Array::value('postal_code', $attributes)
364 );
365 $form->addElement('text', 'postal_code_high', ts('To'),
366 CRM_Utils_Array::value('postal_code', $attributes)
367 );
368 }
369 }
370
2f1714c3 371 CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap);
c8ef633b 372
6a488035
TO
373 // extend addresses with proximity search
374 $form->addElement('text', 'prox_distance', ts('Find contacts within'));
375 $form->addElement('select', 'prox_distance_unit', NULL, array('miles' => ts('Miles'), 'kilos' => ts('Kilometers')));
376
377 // is there another form rule that does decimals besides money ? ...
378 $form->addRule('prox_distance', ts('Please enter positive number as a distance'), 'numeric');
379
6a488035 380 $worldRegions = array('' => ts('- any region -')) + CRM_Core_PseudoConstant::worldRegion();
02ddf039 381 $form->add('select', 'world_region', ts('World Region'), $worldRegions, FALSE, array('class' => 'crm-select2'));
6a488035
TO
382
383 // checkboxes for location type
384 $location_type = array();
b2b0530a 385 $locationType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
6a488035
TO
386 foreach ($locationType as $locationTypeID => $locationTypeName) {
387 $location_type[] = $form->createElement('checkbox', $locationTypeID, NULL, $locationTypeName);
388 }
389 $form->addGroup($location_type, 'location_type', ts('Location Types'), '&nbsp;');
390
391 // custom data extending addresses -
392 $extends = array('Address');
393 $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
394 if ($groupDetails) {
395 $form->assign('addressGroupTree', $groupDetails);
396 foreach ($groupDetails as $group) {
397 foreach ($group['fields'] as $field) {
398 $elementName = 'custom_' . $field['id'];
399 CRM_Core_BAO_CustomField::addQuickFormElement($form,
400 $elementName,
401 $field['id'],
402 FALSE, FALSE, TRUE
403 );
404 }
405 }
406 }
407 }
408
409 static function activity(&$form) {
410 $form->add('hidden', 'hidden_activity', 1);
411 CRM_Activity_BAO_Query::buildSearchForm($form);
412 }
413
414 static function changeLog(&$form) {
415 $form->add('hidden', 'hidden_changeLog', 1);
416
417 // block for change log
418 $form->addElement('text', 'changed_by', ts('Modified By'), NULL);
419
420 $dates = array(1 => ts('Added'), 2 => ts('Modified'));
8a4f27dc 421 $form->addRadio('log_date', NULL, $dates, array('unselectable' => TRUE), '<br />');
6a488035
TO
422
423 CRM_Core_Form_Date::buildDateRange($form, 'log_date', 1, '_low', '_high', ts('From'), FALSE, FALSE);
424 }
425
426 static function task(&$form) {
427 $form->add('hidden', 'hidden_task', 1);
428 }
429
430 static function relationship(&$form) {
431 $form->add('hidden', 'hidden_relationship', 1);
432
433 $allRelationshipType = array();
434 $allRelationshipType = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, NULL, TRUE);
02ddf039 435 $form->add('select', 'relation_type_id', ts('Relationship Type'), array('' => ts('- select -')) + $allRelationshipType, FALSE, array('class' => 'crm-select2'));
6a488035 436 $form->addElement('text', 'relation_target_name', ts('Target Contact'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
5ea73a9f 437 // relation status
6a488035
TO
438 $relStatusOption = array(ts('Active '), ts('Inactive '), ts('All'));
439 $form->addRadio('relation_status', ts('Relationship Status'), $relStatusOption);
440 $form->setDefaults(array('relation_status' => 0));
5ea73a9f
DG
441 // relation permission
442 $relPermissionOption = array(ts('Any'), ts('Yes '), ts('No ') );
443 $form->addRadio('relation_permission', ts('Permissioned Relationship?'), $relPermissionOption);
444 $form->setDefaults(array('relation_permission' => 0));
6a488035
TO
445
446 //add the target group
447 if ($form->_group) {
448 $form->add('select', 'relation_target_group', ts('Target Contact(s) in Group'), $form->_group, FALSE,
02ddf039 449 array('id' => 'relation_target_group', 'multiple' => 'multiple', 'class' => 'crm-select2')
6a488035
TO
450 );
451 }
ad682134 452 CRM_Core_Form_Date::buildDateRange($form, 'relation_start_date', 1, '_low', '_high', ts('From:'), FALSE, FALSE);
453 CRM_Core_Form_Date::buildDateRange($form, 'relation_end_date', 1, '_low', '_high', ts('From:'), FALSE, FALSE);
6a488035
TO
454
455 // Add reltionship dates
456 CRM_Core_Form_Date::buildDateRange($form, 'relation_date', 1, '_low', '_high', ts('From:'), FALSE, FALSE);
457
458 // add all the custom searchable fields
459 $relationship = array('Relationship');
460 $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $relationship);
461 if ($groupDetails) {
462 $form->assign('relationshipGroupTree', $groupDetails);
463 foreach ($groupDetails as $group) {
464 foreach ($group['fields'] as $field) {
465 $fieldId = $field['id'];
466 $elementName = 'custom_' . $fieldId;
467 CRM_Core_BAO_CustomField::addQuickFormElement($form,
468 $elementName,
469 $fieldId,
470 FALSE, FALSE, TRUE
471 );
472 }
473 }
474 }
475 }
476
477 static function demographics(&$form) {
478 $form->add('hidden', 'hidden_demographics', 1);
479 // radio button for gender
480 $genderOptions = array();
26cf88b5 481 $gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id');
6a488035
TO
482 foreach ($gender as $key => $var) {
483 $genderOptions[$key] = $form->createElement('radio', NULL,
484 ts('Gender'), $var, $key,
485 array('id' => "civicrm_gender_{$var}_{$key}")
486 );
487 }
8a4f27dc 488 $form->addGroup($genderOptions, 'gender_id', ts('Gender'))->setAttribute('unselectable', TRUE);
6a488035
TO
489
490 CRM_Core_Form_Date::buildDateRange($form, 'birth_date', 1, '_low', '_high', ts('From'), FALSE, FALSE, 'birth');
491
492 CRM_Core_Form_Date::buildDateRange($form, 'deceased_date', 1, '_low', '_high', ts('From'), FALSE, FALSE, 'birth');
493
494
495 // radio button for is_deceased
8a4f27dc 496 $form->addYesNo( 'is_deceased', ts('Deceased'), TRUE);
6a488035
TO
497 }
498
499 static function notes(&$form) {
500 $form->add('hidden', 'hidden_notes', 1);
501
502 $options = array(
503 2 => ts('Body Only'),
504 3 => ts('Subject Only'),
505 6 => ts('Both'),
506 );
507 $form->addRadio('note_option', '', $options);
508
509 $form->addElement('text', 'note', ts('Note Text'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
510
511 $form->setDefaults(array('note_option' => 6));
512 }
513
514 /**
515 * Generate the custom Data Fields based
516 * on the is_searchable
517 *
518 * @access private
519 *
520 * @return void
521 */
522 static function custom(&$form) {
523 $form->add('hidden', 'hidden_custom', 1);
524 $extends = array_merge(array('Contact', 'Individual', 'Household', 'Organization'),
525 CRM_Contact_BAO_ContactType::subTypes()
526 );
527 $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE,
528 $extends
529 );
530
531 $form->assign('groupTree', $groupDetails);
532
533 foreach ($groupDetails as $key => $group) {
534 $_groupTitle[$key] = $group['name'];
535 CRM_Core_ShowHideBlocks::links($form, $group['name'], '', '');
536
537 $groupId = $group['id'];
538 foreach ($group['fields'] as $field) {
539 $fieldId = $field['id'];
540 $elementName = 'custom_' . $fieldId;
541
542 CRM_Core_BAO_CustomField::addQuickFormElement($form,
543 $elementName,
544 $fieldId,
545 FALSE, FALSE, TRUE
546 );
547 }
548 }
549
550 //TODO: validate for only one state if prox_distance isset
551 }
552
553 static function CiviCase(&$form) {
554 //Looks like obsolete code, since CiviCase is a component, but might be used by HRD
555 $form->add('hidden', 'hidden_CiviCase', 1);
556 CRM_Case_BAO_Query::buildSearchForm($form);
557 }
558}
559