Change autocomplete to lookup surname or firstname

This commit is contained in:
2016-01-30 13:40:17 +11:00
parent 2d80df15b2
commit ba0ee914f9

View File

@@ -11,7 +11,8 @@ function _booking_rooms_name_autocomplete($string) {
$query = db_select('booking_person', 'p')
->fields('p', array('nid', 'booking_firstname', 'booking_lastname'));
$db_and = db_and()->condition('p.booking_lastname', '%' . db_like($string) . '%', 'LIKE')->condition('p.booking_event_id', $event->eid, '=');
$db_or = db_or()->condition('p.booking_lastname', '%' . db_like($string) . '%', 'LIKE')->condition('p.booking_firstname', '%' . db_like($string) . '%', 'LIKE');
$db_and = db_and()->condition($db_or)->condition('p.booking_event_id', $event->eid, '=');
$result = $query->condition($db_and)
->execute();
@@ -36,7 +37,7 @@ function booking_rooms_allocate_test_form($node, &$form_state, $location_id) {
$options = array();
$counter = 0;
$prefix = "<p>Enter a person's surname in the text field to autocomplete with the person's details. Make sure you click on the person from the dropdown list that appears.</p>";
$prefix = "<p>Enter part of a person's name in the text field and wait for the blue spinning circle to autocomplete with the person's details. Make sure you click on the person from the dropdown list that appears.</p>";
$form['first_para'] = array (
'#type' => 'markup',
'#markup' => $prefix,