diff --git a/src/application/controllers/backend_api.php b/src/application/controllers/backend_api.php index 26fbd398..30927414 100644 --- a/src/application/controllers/backend_api.php +++ b/src/application/controllers/backend_api.php @@ -402,15 +402,17 @@ class Backend_api extends CI_Controller { $this->load->model('customers_model'); $key = $this->db->escape_str($_POST['key']); + $key = strtoupper($key); $where_clause = - '(first_name LIKE "%' . $key . '%" OR ' . - 'last_name LIKE "%' . $key . '%" OR ' . - 'email LIKE "%' . $key . '%" OR ' . - 'phone_number LIKE "%' . $key . '%" OR ' . - 'address LIKE "%' . $key . '%" OR ' . - 'city LIKE "%' . $key . '%" OR ' . - 'zip_code LIKE "%' . $key . '%")'; + '(first_name LIKE upper("%' . $key . '%") OR ' . + 'last_name LIKE upper("%' . $key . '%") OR ' . + 'email LIKE upper("%' . $key . '%") OR ' . + 'phone_number LIKE upper("%' . $key . '%") OR ' . + 'address LIKE upper("%' . $key . '%") OR ' . + 'city LIKE upper("%' . $key . '%") OR ' . + 'zip_code LIKE upper("%' . $key . '%") OR ' . + 'notes LIKE upper("%' . $key . '%"))'; $customers = $this->customers_model->get_batch($where_clause); diff --git a/src/application/views/backend/calendar.php b/src/application/views/backend/calendar.php index 3c816b20..9cf6634e 100644 --- a/src/application/views/backend/calendar.php +++ b/src/application/views/backend/calendar.php @@ -294,15 +294,14 @@ - - - diff --git a/src/assets/css/backend.css b/src/assets/css/backend.css index 67cde975..3387f5e8 100644 --- a/src/assets/css/backend.css +++ b/src/assets/css/backend.css @@ -168,12 +168,12 @@ body .modal.full-screen .modal-content { body .modal.full-screen .wrapper { min-height: 100%; - margin-bottom: -67px; /* modal-footer height */ + /*margin-bottom: -67px;*/ /* modal-footer height */ } body .modal.full-screen .modal-footer { background-color: #f5f5f5; - position: absolute; + /*position: absolute;*/ bottom: 0; width: 100%; height: 67px; diff --git a/src/assets/js/backend_calendar.js b/src/assets/js/backend_calendar.js index a042c97d..b411898a 100644 --- a/src/assets/js/backend_calendar.js +++ b/src/assets/js/backend_calendar.js @@ -842,6 +842,8 @@ var BackendCalendar = { // Display modal form. $dialog.find('.modal-header h3').text(EALang['new_appointment_title']); $dialog.modal('show'); + + }); /** @@ -926,17 +928,63 @@ var BackendCalendar = { $('#filter-existing-customers').keyup(function() { var key = $(this).val().toLowerCase(); var $list = $('#existing-customers-list'); - $list.empty(); - $.each(GlobalVariables.customers, function(index, c) { - if (c.first_name.toLowerCase().indexOf(key) != -1 - || c.last_name.toLowerCase().indexOf(key) != -1 - || c.email.toLowerCase().indexOf(key) != -1 - || c.phone_number.toLowerCase().indexOf(key) != -1 - || c.address.toLowerCase().indexOf(key) != -1 - || c.city.toLowerCase().indexOf(key) != -1 - || c.zip_code.toLowerCase().indexOf(key) != -1) { - $list.append('
' - + c.first_name + ' ' + c.last_name + '
'); + + var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_customers'; + var postData = { + 'csrfToken': GlobalVariables.csrfToken, + 'key': key + }; + + // Try to get the updated customer list + $.ajax({ + 'type': 'POST', + 'url': postUrl, + 'data': postData, + 'dataType': 'json', + 'timeout': 1000, + 'global': false, + 'success': function(response) { + ///////////////////////////////////////////////////////////// + console.log('Filter Customers Appointment Response:', response); + ///////////////////////////////////////////////////////////// + + $list.empty(); + $.each(response, function(index, c) { + $list.append('
' + + c.first_name + ' ' + c.last_name + '
'); + + // Verify if this customer is on the old customer list + var result = $.grep(GlobalVariables.customers, + function(e){ return e.id == c.id; }); + + // Add it to the customer list + if(result.length == 0){ + GlobalVariables.customers.push(c); + } + }); + }, + 'error': function(jqXHR, textStatus, errorThrown) { + ////////////////////////////////////////////////////////////////// + console.log('Filter Customers Appointment Error:', jqXHR, textStatus, + errorThrown); + ////////////////////////////////////////////////////////////////// + + // If there is any error on the request, search by the local + // client database + $list.empty(); + $.each(GlobalVariables.customers, function(index, c) { + if (c.first_name.toLowerCase().indexOf(key) != -1 + || c.last_name.toLowerCase().indexOf(key) != -1 + || c.email.toLowerCase().indexOf(key) != -1 + || c.phone_number.toLowerCase().indexOf(key) != -1 + || c.address.toLowerCase().indexOf(key) != -1 + || c.city.toLowerCase().indexOf(key) != -1 + || c.zip_code.toLowerCase().indexOf(key) != -1 + || c.notes.toLowerCase().indexOf(key) != -1) { + $list.append('
' + + c.first_name + ' ' + c.last_name + '
'); + } + }); } }); });