function _bat_event_potential_references in Booking and Availability Management Tools for Drupal 7
Parameters
$field:
$options:
Return value
array
1 call to _bat_event_potential_references()
- bat_event_potential_references in modules/
bat_event/ bat_event.module
File
- modules/
bat_event/ bat_event.module, line 1821 - Manage Events - Events store the EventValue of a Unit over a period of time.
Code
function _bat_event_potential_references($field, $options) {
$query = db_select('bat_event_state', 'u');
$event_id_alias = $query
->addField('u', 'id');
$event_label_alias = $query
->addField('u', 'label');
$query
->condition('event_type', $options['event_type']);
if ($options['string'] !== '') {
switch ($options['match']) {
case 'contains':
$query
->condition('u.label', '%' . $options['string'] . '%', 'LIKE');
break;
case 'starts_with':
$query
->condition('u.label', $options['string'] . '%', 'LIKE');
break;
case 'equals':
default:
// No match type or incorrect match type: use "=".
$query
->condition('u.label', $options['string']);
break;
}
}
$result = $query
->execute()
->fetchAll();
$references = array();
foreach ($result as $event) {
$references[$event->id] = array(
'title' => $event->label,
'rendered' => check_plain($event->label),
);
}
return $references;
}