Merge pull request #7781 from rohankatkar/CRM-18010
[civicrm-core.git] / CRM / Event / BAO / Query.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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-2015
32 * $Id$
33 *
34 */
35 class CRM_Event_BAO_Query {
36
37 /**
38 * Function get the import/export fields for contribution.
39 *
40 * @param bool $checkPermission
41 *
42 * @return array
43 * Associative array of contribution fields
44 */
45 public static function &getFields($checkPermission = TRUE) {
46 $fields = array();
47 $fields = array_merge($fields, CRM_Event_DAO_Event::import());
48 $fields = array_merge($fields, self::getParticipantFields());
49 $fields = array_merge($fields, CRM_Core_DAO_Discount::export());
50
51 return $fields;
52 }
53
54 /**
55 * @return array
56 */
57 public static function &getParticipantFields() {
58 $fields = CRM_Event_BAO_Participant::importableFields('Individual', TRUE, TRUE);
59 return $fields;
60 }
61
62 /**
63 * Build select for CiviEvent.
64 *
65 * @param $query
66 */
67 public static function select(&$query) {
68 if (($query->_mode & CRM_Contact_BAO_Query::MODE_EVENT) ||
69 CRM_Contact_BAO_Query::componentPresent($query->_returnProperties, 'participant_')
70 ) {
71 $query->_select['participant_id'] = "civicrm_participant.id as participant_id";
72 $query->_element['participant_id'] = 1;
73 $query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
74
75 //add fee level
76 if (!empty($query->_returnProperties['participant_fee_level'])) {
77 $query->_select['participant_fee_level'] = "civicrm_participant.fee_level as participant_fee_level";
78 $query->_element['participant_fee_level'] = 1;
79 }
80
81 //add participant contact ID
82 if (!empty($query->_returnProperties['participant_contact_id'])) {
83 $query->_select['participant_contact_id'] = "civicrm_participant.contact_id as participant_contact_id";
84 $query->_element['participant_contact_id'] = 1;
85 }
86
87 //add fee amount
88 if (!empty($query->_returnProperties['participant_fee_amount'])) {
89 $query->_select['participant_fee_amount'] = "civicrm_participant.fee_amount as participant_fee_amount";
90 $query->_element['participant_fee_amount'] = 1;
91 }
92
93 //add fee currency
94 if (!empty($query->_returnProperties['participant_fee_currency'])) {
95 $query->_select['participant_fee_currency'] = "civicrm_participant.fee_currency as participant_fee_currency";
96 $query->_element['participant_fee_currency'] = 1;
97 }
98
99 //add event title also if event id is select
100 if (!empty($query->_returnProperties['event_id']) || !empty($query->_returnProperties['event_title'])) {
101 $query->_select['event_id'] = "civicrm_event.id as event_id";
102 $query->_select['event_title'] = "civicrm_event.title as event_title";
103 $query->_element['event_id'] = 1;
104 $query->_element['event_title'] = 1;
105 $query->_tables['civicrm_event'] = 1;
106 $query->_whereTables['civicrm_event'] = 1;
107 }
108
109 //add start date / end date
110 if (!empty($query->_returnProperties['event_start_date'])) {
111 $query->_select['event_start_date'] = "civicrm_event.start_date as event_start_date";
112 $query->_element['event_start_date'] = 1;
113 }
114
115 if (!empty($query->_returnProperties['event_end_date'])) {
116 $query->_select['event_end_date'] = "civicrm_event.end_date as event_end_date";
117 $query->_element['event_end_date'] = 1;
118 }
119
120 //event type
121 if (!empty($query->_returnProperties['event_type'])) {
122 $query->_select['event_type'] = "event_type.label as event_type";
123 $query->_element['event_type'] = 1;
124 $query->_tables['event_type'] = 1;
125 $query->_whereTables['event_type'] = 1;
126 }
127
128 if (!empty($query->_returnProperties['event_type_id'])) {
129 $query->_select['event_type_id'] = "event_type.id as event_type_id";
130 $query->_element['event_type_id'] = 1;
131 $query->_tables['event_type'] = 1;
132 $query->_whereTables['event_type'] = 1;
133 }
134
135 //add status_id
136 if (!empty($query->_returnProperties['participant_status_id'])) {
137 $query->_select['participant_status_id'] = "civicrm_participant.status_id as participant_status_id";
138 $query->_element['participant_status_id'] = 1;
139 $query->_tables['civicrm_participant'] = 1;
140 $query->_whereTables['civicrm_participant'] = 1;
141 }
142
143 // get particupant_status label
144 if (!empty($query->_returnProperties['participant_status'])) {
145 $query->_select['participant_status'] = "participant_status.label as participant_status";
146 $query->_element['participant_status'] = 1;
147 $query->_tables['participant_status'] = 1;
148 $query->_whereTables['civicrm_participant'] = 1;
149 }
150
151 //add participant_role_id
152 if (!empty($query->_returnProperties['participant_role_id'])) {
153 $query->_select['participant_role_id'] = "civicrm_participant.role_id as participant_role_id";
154 $query->_element['participant_role_id'] = 1;
155 $query->_tables['civicrm_participant'] = 1;
156 $query->_whereTables['civicrm_participant'] = 1;
157 $query->_pseudoConstantsSelect['participant_role_id'] = array(
158 'pseudoField' => 'participant_role_id',
159 'idCol' => 'participant_role_id',
160 );
161 }
162
163 //add participant_role
164 if (!empty($query->_returnProperties['participant_role'])) {
165 $query->_select['participant_role'] = "civicrm_participant.role_id as participant_role";
166 $query->_element['participant_role'] = 1;
167 $query->_tables['participant_role'] = 1;
168 $query->_whereTables['civicrm_participant'] = 1;
169 $query->_pseudoConstantsSelect['participant_role'] = array(
170 'pseudoField' => 'participant_role',
171 'idCol' => 'participant_role',
172 );
173 }
174
175 //add register date
176 if (!empty($query->_returnProperties['participant_register_date'])) {
177 $query->_select['participant_register_date'] = "civicrm_participant.register_date as participant_register_date";
178 $query->_element['participant_register_date'] = 1;
179 }
180
181 //add source
182 if (!empty($query->_returnProperties['participant_source'])) {
183 $query->_select['participant_source'] = "civicrm_participant.source as participant_source";
184 $query->_element['participant_source'] = 1;
185 $query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
186 }
187
188 //participant note
189 if (!empty($query->_returnProperties['participant_note'])) {
190 $query->_select['participant_note'] = "civicrm_note.note as participant_note";
191 $query->_element['participant_note'] = 1;
192 $query->_tables['participant_note'] = 1;
193 $query->_whereTables['civicrm_note'] = 1;
194 }
195
196 if (!empty($query->_returnProperties['participant_is_pay_later'])) {
197 $query->_select['participant_is_pay_later'] = "civicrm_participant.is_pay_later as participant_is_pay_later";
198 $query->_element['participant_is_pay_later'] = 1;
199 }
200
201 if (!empty($query->_returnProperties['participant_is_test'])) {
202 $query->_select['participant_is_test'] = "civicrm_participant.is_test as participant_is_test";
203 $query->_element['participant_is_test'] = 1;
204 }
205
206 if (!empty($query->_returnProperties['participant_registered_by_id'])) {
207 $query->_select['participant_registered_by_id'] = "civicrm_participant.registered_by_id as participant_registered_by_id";
208 $query->_element['participant_registered_by_id'] = 1;
209 }
210
211 // get discount name
212 if (!empty($query->_returnProperties['participant_discount_name'])) {
213 $query->_select['participant_discount_name'] = "discount_name.title as participant_discount_name";
214 $query->_element['participant_discount_name'] = 1;
215 $query->_tables['civicrm_discount'] = 1;
216 $query->_tables['participant_discount_name'] = 1;
217 $query->_whereTables['civicrm_discount'] = 1;
218 $query->_whereTables['participant_discount_name'] = 1;
219 }
220
221 //carry campaign id to selectors.
222 if (!empty($query->_returnProperties['participant_campaign_id'])) {
223 $query->_select['participant_campaign_id'] = 'civicrm_participant.campaign_id as participant_campaign_id';
224 $query->_element['participant_campaign_id'] = 1;
225 }
226 }
227 }
228
229
230 /**
231 * @param $query
232 */
233 public static function where(&$query) {
234 $grouping = NULL;
235 foreach (array_keys($query->_params) as $id) {
236 if (empty($query->_params[$id][0])) {
237 continue;
238 }
239 if (substr($query->_params[$id][0], 0, 6) == 'event_' ||
240 substr($query->_params[$id][0], 0, 12) == 'participant_'
241 ) {
242 if ($query->_mode == CRM_Contact_BAO_QUERY::MODE_CONTACTS) {
243 $query->_useDistinct = TRUE;
244 }
245 $grouping = $query->_params[$id][3];
246 self::whereClauseSingle($query->_params[$id], $query);
247 }
248 }
249 }
250
251 /**
252 * @param $values
253 * @param $query
254 */
255 public static function whereClauseSingle(&$values, &$query) {
256 list($name, $op, $value, $grouping, $wildcard) = $values;
257 $fields = array_merge(CRM_Event_BAO_Event::fields(), CRM_Event_BAO_Participant::exportableFields());
258
259 switch ($name) {
260 case 'event_start_date_low':
261 case 'event_start_date_high':
262 $query->dateQueryBuilder($values,
263 'civicrm_event', 'event_start_date', 'start_date', 'Start Date'
264 );
265 return;
266
267 case 'event_end_date_low':
268 case 'event_end_date_high':
269 $query->dateQueryBuilder($values,
270 'civicrm_event', 'event_end_date', 'end_date', 'End Date'
271 );
272 return;
273
274 case 'event_include_repeating_events':
275 /**
276 * Include Repeating Events
277 */
278 //Get parent of this event
279 $exEventId = '';
280 if ($query->_where[$grouping]) {
281 foreach ($query->_where[$grouping] as $key => $val) {
282 if (strstr($val, 'civicrm_event.id =')) {
283 $exEventId = $val;
284 $extractEventId = explode(" ", $val);
285 $value = $extractEventId[2];
286 unset($query->_where[$grouping][$key]);
287 }
288 }
289 $extractEventId = explode(" ", $exEventId);
290 $value = $extractEventId[2];
291 unset($query->_where[$grouping][$key]);
292 }
293 $thisEventHasParent = CRM_Core_BAO_RecurringEntity::getParentFor($value, 'civicrm_event');
294 if ($thisEventHasParent) {
295 $getAllConnections = CRM_Core_BAO_RecurringEntity::getEntitiesForParent($thisEventHasParent, 'civicrm_event');
296 $allEventIds = array();
297 foreach ($getAllConnections as $key => $val) {
298 $allEventIds[] = $val['id'];
299 }
300 if (!empty($allEventIds)) {
301 $op = "IN";
302 $value = "(" . implode(",", $allEventIds) . ")";
303 }
304 }
305 $query->_where[$grouping][] = "civicrm_event.id $op {$value}";
306 $query->_qill[$grouping][] = ts('Include Repeating Events');
307 $query->_tables['civicrm_event'] = $query->_whereTables['civicrm_event'] = 1;
308 return;
309
310 case 'participant_is_test':
311 $key = array_search('civicrm_participant.is_test = 0', $query->_where[$grouping]);
312 if (!empty($key)) {
313 unset($query->_where[$grouping][$key]);
314 }
315 case 'participant_test':
316 // We dont want to include all tests for sql OR CRM-7827
317 if (!$value || $query->getOperator() != 'OR') {
318 $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_participant.is_test",
319 $op,
320 $value,
321 "Boolean"
322 );
323
324 $isTest = $value ? 'a Test' : 'not a Test';
325 $query->_qill[$grouping][] = ts("Participant is %1", array(1 => $isTest));
326 $query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
327 }
328 return;
329
330 case 'participant_fee_id':
331 $feeLabel = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $value, 'label');
332 $feeLabel = CRM_Core_DAO::escapeString(trim($feeLabel));
333 if ($value) {
334 $query->_where[$grouping][] = "civicrm_participant.fee_level LIKE '%$feeLabel%'";
335 $query->_qill[$grouping][] = ts("Fee level") . " contains $feeLabel";
336 }
337 $query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
338 return;
339
340 case 'participant_fee_amount_high':
341 case 'participant_fee_amount_low':
342 $query->numberRangeBuilder($values,
343 'civicrm_participant', 'participant_fee_amount', 'fee_amount', 'Fee Amount'
344 );
345 return;
346
347 case 'participant_status_id':
348 if ($value && is_array($value) && strpos($op, 'IN') === FALSE) {
349 $op = 'IN';
350 }
351 case 'participant_status':
352 case 'participant_source':
353 case 'participant_id':
354 case 'participant_contact_id':
355 case 'participant_is_pay_later':
356 case 'participant_fee_amount':
357 case 'participant_fee_level':
358 case 'participant_campaign_id':
359
360 $qillName = $name;
361 if (in_array($name, array(
362 'participant_status_id',
363 'participant_source',
364 'participant_id',
365 'participant_contact_id',
366 'participant_fee_amount',
367 'participant_fee_level',
368 'participant_is_pay_later',
369 'participant_campaign_id',
370 ))
371 ) {
372 $name = str_replace('participant_', '', $name);
373 if ($name == 'is_pay_later') {
374 $qillName = $name;
375 }
376 }
377 elseif ($name == 'participant_status') {
378 $name = 'status_id';
379 }
380
381 $dataType = !empty($fields[$qillName]['type']) ? CRM_Utils_Type::typeToString($fields[$qillName]['type']) : 'String';
382 $tableName = empty($tableName) ? 'civicrm_participant' : $tableName;
383 if (is_array($value) && in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
384 $op = key($value);
385 $value = $value[$op];
386 }
387 $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("$tableName.$name", $op, $value, $dataType);
388
389 list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Event_DAO_Participant', $name, $value, $op);
390 $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$qillName]['title'], 2 => $op, 3 => $value));
391 $query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
392 return;
393
394 case 'participant_role':
395 case 'participant_role_id':
396 $qillName = $name;
397 $name = 'role_id';
398
399 if (is_array($value) && in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
400 $op = key($value);
401 $value = $value[$op];
402 }
403 if (!strstr($op, 'NULL') && !strstr($op, 'EMPTY') && !strstr($op, 'LIKE')) {
404 $regexOp = (strstr($op, '!') || strstr($op, 'NOT')) ? 'NOT REGEXP' : 'REGEXP';
405 $regexp = "[[:cntrl:]]*" . implode('[[:>:]]*|[[:<:]]*', (array) $value) . "[[:cntrl:]]*";
406 $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_participant.$name", $regexOp, $regexp, 'String');
407 }
408 else {
409 $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("$tableName.$name", $op, $value, $dataType);
410 }
411
412 list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Event_DAO_Participant', $name, $value, $op);
413 $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$qillName]['title'], 2 => $op, 3 => $value));
414 $query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
415 return;
416
417 case 'participant_register_date':
418 case 'participant_register_date_high':
419 case 'participant_register_date_low':
420 $query->dateQueryBuilder($values,
421 'civicrm_participant', 'participant_register_date', 'register_date', 'Register Date'
422 );
423 return;
424
425 case 'event_id':
426 case 'participant_event_id':
427 $name = str_replace('participant_', '', $name);
428 case 'event_is_public':
429 case 'event_type_id':
430 case 'event_title':
431 $qillName = $name;
432 if (in_array($name, array(
433 'event_id',
434 'event_title',
435 'event_is_public',
436 )
437 )
438 ) {
439 $name = str_replace('event_', '', $name);
440 }
441 $dataType = !empty($fields[$qillName]['type']) ? CRM_Utils_Type::typeToString($fields[$qillName]['type']) : 'String';
442
443 $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_event.$name", $op, $value, $dataType);
444 $query->_tables['civicrm_event'] = $query->_whereTables['civicrm_event'] = 1;
445 if (!array_key_exists($qillName, $fields)) {
446 break;
447 }
448 list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Event_DAO_Event', $name, $value, $op);
449 $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$qillName]['title'], 2 => $op, 3 => $value));
450 return;
451 }
452 }
453
454 /**
455 * @param string $name
456 * @param $mode
457 * @param $side
458 *
459 * @return null|string
460 */
461 public static function from($name, $mode, $side) {
462 $from = NULL;
463 switch ($name) {
464 case 'civicrm_participant':
465 $from = " LEFT JOIN civicrm_participant ON civicrm_participant.contact_id = contact_a.id ";
466 break;
467
468 case 'civicrm_event':
469 $from = " INNER JOIN civicrm_event ON civicrm_participant.event_id = civicrm_event.id ";
470 break;
471
472 case 'event_type':
473 $from = " $side JOIN civicrm_option_group option_group_event_type ON (option_group_event_type.name = 'event_type')";
474 $from .= " $side JOIN civicrm_option_value event_type ON (civicrm_event.event_type_id = event_type.value AND option_group_event_type.id = event_type.option_group_id ) ";
475 break;
476
477 case 'participant_note':
478 $from .= " $side JOIN civicrm_note ON ( civicrm_note.entity_table = 'civicrm_participant' AND
479 civicrm_participant.id = civicrm_note.entity_id )";
480 break;
481
482 case 'participant_status':
483 $from .= " $side JOIN civicrm_participant_status_type participant_status ON (civicrm_participant.status_id = participant_status.id) ";
484 break;
485
486 case 'participant_role':
487 $from = " $side JOIN civicrm_option_group option_group_participant_role ON (option_group_participant_role.name = 'participant_role')";
488 $from .= " $side JOIN civicrm_option_value participant_role ON ((civicrm_participant.role_id = participant_role.value OR SUBSTRING_INDEX(role_id,'\ 1', 1) = participant_role.value)
489 AND option_group_participant_role.id = participant_role.option_group_id ) ";
490 break;
491
492 case 'participant_discount_name':
493 $from = " $side JOIN civicrm_discount discount ON ( civicrm_participant.discount_id = discount.id )";
494 $from .= " $side JOIN civicrm_option_group discount_name ON ( discount_name.id = discount.price_set_id ) ";
495 break;
496 }
497 return $from;
498 }
499
500 /**
501 * Getter for the qill object.
502 *
503 * @return string
504 */
505 public function qill() {
506 return (isset($this->_qill)) ? $this->_qill : "";
507 }
508
509 /**
510 * @param $mode
511 * @param bool $includeCustomFields
512 *
513 * @return array|null
514 */
515 public static function defaultReturnProperties(
516 $mode,
517 $includeCustomFields = TRUE
518 ) {
519 $properties = NULL;
520 if ($mode & CRM_Contact_BAO_Query::MODE_EVENT) {
521 $properties = array(
522 'contact_type' => 1,
523 'contact_sub_type' => 1,
524 'sort_name' => 1,
525 'display_name' => 1,
526 'event_id' => 1,
527 'event_title' => 1,
528 'event_start_date' => 1,
529 'event_end_date' => 1,
530 'event_type' => 1,
531 'participant_id' => 1,
532 'participant_status' => 1,
533 'participant_status_id' => 1,
534 'participant_role' => 1,
535 'participant_role_id' => 1,
536 'participant_note' => 1,
537 'participant_register_date' => 1,
538 'participant_source' => 1,
539 'participant_fee_level' => 1,
540 'participant_is_test' => 1,
541 'participant_is_pay_later' => 1,
542 'participant_fee_amount' => 1,
543 'participant_discount_name' => 1,
544 'participant_fee_currency' => 1,
545 'participant_registered_by_id' => 1,
546 'participant_campaign_id' => 1,
547 );
548
549 if ($includeCustomFields) {
550 // also get all the custom participant properties
551 $fields = CRM_Core_BAO_CustomField::getFieldsForImport('Participant');
552 if (!empty($fields)) {
553 foreach ($fields as $name => $dontCare) {
554 $properties[$name] = 1;
555 }
556 }
557 }
558 }
559
560 return $properties;
561 }
562
563 /**
564 * @param CRM_Core_Form $form
565 */
566 public static function buildSearchForm(&$form) {
567 $dataURLEventFee = CRM_Utils_System::url('civicrm/ajax/eventFee',
568 "reset=1",
569 FALSE, NULL, FALSE
570 );
571
572 $form->assign('dataURLEventFee', $dataURLEventFee);
573
574 $form->addEntityRef('event_id', ts('Event Name'), array(
575 'entity' => 'event',
576 'placeholder' => ts('- any -'),
577 'select' => array('minimumInputLength' => 0),
578 )
579 );
580 $form->addEntityRef('event_type_id', ts('Event Type'), array(
581 'entity' => 'option_value',
582 'placeholder' => ts('- any -'),
583 'select' => array('minimumInputLength' => 0),
584 'api' => array(
585 'params' => array('option_group_id' => 'event_type'),
586 ),
587 )
588 );
589 $form->add('text', 'participant_fee_id', ts('Fee Level'), array('class' => 'big crm-ajax-select'));
590
591 CRM_Core_Form_Date::buildDateRange($form, 'event', 1, '_start_date_low', '_end_date_high', ts('From'), FALSE);
592
593 CRM_Core_Form_Date::buildDateRange($form, 'participant', 1, '_register_date_low', '_register_date_high', ts('From'), FALSE);
594
595 $form->addElement('checkbox', "event_include_repeating_events", NULL, ts('Include participants from all events in the %1 series', array(1 => '<em>%1</em>')));
596
597 $form->addSelect('participant_status_id',
598 array(
599 'entity' => 'participant',
600 'label' => ts('Participant Status'),
601 'multiple' => 'multiple',
602 'option_url' => NULL,
603 'placeholder' => ts('- any -'),
604 )
605 );
606
607 $form->addSelect('participant_role_id',
608 array(
609 'entity' => 'participant',
610 'label' => ts('Participant Role'),
611 'multiple' => 'multiple',
612 'option_url' => NULL,
613 'placeholder' => ts('- any -'),
614 )
615 );
616
617 $form->addYesNo('participant_test', ts('Participant is a Test?'), TRUE);
618 $form->addYesNo('participant_is_pay_later', ts('Participant is Pay Later?'), TRUE);
619 $form->addElement('text', 'participant_fee_amount_low', ts('From'), array('size' => 8, 'maxlength' => 8));
620 $form->addElement('text', 'participant_fee_amount_high', ts('To'), array('size' => 8, 'maxlength' => 8));
621
622 $form->addRule('participant_fee_amount_low', ts('Please enter a valid money value.'), 'money');
623 $form->addRule('participant_fee_amount_high', ts('Please enter a valid money value.'), 'money');
624 // add all the custom searchable fields
625 $extends = array('Participant', 'Event');
626 $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
627 if ($groupDetails) {
628 $form->assign('participantGroupTree', $groupDetails);
629 foreach ($groupDetails as $group) {
630 foreach ($group['fields'] as $field) {
631 $fieldId = $field['id'];
632 $elementName = 'custom_' . $fieldId;
633 CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, TRUE);
634 }
635 }
636 }
637
638 CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'participant_campaign_id');
639
640 $form->assign('validCiviEvent', TRUE);
641 $form->setDefaults(array('participant_test' => 0));
642 }
643
644 /**
645 * @param $row
646 * @param int $id
647 */
648 public static function searchAction(&$row, $id) {
649 }
650
651 /**
652 * @param $tables
653 */
654 public static function tableNames(&$tables) {
655 //add participant table
656 if (!empty($tables['civicrm_event'])) {
657 $tables = array_merge(array('civicrm_participant' => 1), $tables);
658 }
659 }
660
661 }