activities_controller.php
1 year ago
auth_controller.php
1 year ago
booking_form_settings_controller.php
1 year ago
bookings_controller.php
1 year ago
calendars_controller.php
1 year ago
carts_controller.php
1 year ago
controller.php
1 year ago
customer_cabinet_controller.php
1 year ago
customers_controller.php
1 year ago
dashboard_controller.php
1 year ago
default_agent_controller.php
1 year ago
events_controller.php
1 year ago
form_fields_controller.php
1 year ago
integrations_controller.php
1 year ago
invoices_controller.php
1 year ago
manage_booking_by_key_controller.php
1 year ago
manage_order_by_key_controller.php
1 year ago
notifications_controller.php
1 year ago
orders_controller.php
1 year ago
pro_controller.php
1 year ago
process_jobs_controller.php
1 year ago
processes_controller.php
1 year ago
search_controller.php
1 year ago
services_controller.php
1 year ago
settings_controller.php
1 year ago
steps_controller.php
1 year ago
stripe_connect_controller.php
1 year ago
support_topics_controller.php
1 year ago
todos_controller.php
1 year ago
transactions_controller.php
1 year ago
wizard_controller.php
1 year ago
search_controller.php
52 lines
| 1 | <?php |
| 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | exit; // Exit if accessed directly. |
| 4 | } |
| 5 | |
| 6 | |
| 7 | if ( ! class_exists( 'OsSearchController' ) ) : |
| 8 | |
| 9 | |
| 10 | class OsSearchController extends OsController { |
| 11 | |
| 12 | private $booking; |
| 13 | |
| 14 | function __construct(){ |
| 15 | parent::__construct(); |
| 16 | $this->views_folder = LATEPOINT_VIEWS_ABSPATH . 'search/'; |
| 17 | } |
| 18 | |
| 19 | function query_results(){ |
| 20 | $query = trim($this->params['query']); |
| 21 | if(!$query) return; |
| 22 | $sql_query = '%'.$query.'%'; |
| 23 | |
| 24 | |
| 25 | $bookings = new OsBookingModel(); |
| 26 | $bookings = $bookings->filter_allowed_records()->where(['booking_code' => strtoupper($query)])->get_results_as_models(); |
| 27 | $this->vars['bookings'] = $bookings; |
| 28 | |
| 29 | $customers = new OsCustomerModel(); |
| 30 | $customers->filter_allowed_records()->where(array('OR' => array('CONCAT (first_name, " ", last_name) LIKE ' => $sql_query, 'email LIKE' => $sql_query, 'phone LIKE' => $sql_query)))->set_limit(6); |
| 31 | |
| 32 | $customers = $customers->get_results_as_models(); |
| 33 | $this->vars['customers'] = $customers; |
| 34 | $this->vars['query'] = $query; |
| 35 | |
| 36 | if(OsRolesHelper::can_user('service__view')){ |
| 37 | $services = new OsServiceModel(); |
| 38 | $services = $services->filter_allowed_records()->where(array('name LIKE ' => $sql_query))->set_limit(6)->get_results_as_models(); |
| 39 | $this->vars['services'] = $services; |
| 40 | } |
| 41 | if(OsRolesHelper::can_user('agent__view')) { |
| 42 | $agents = new OsAgentModel(); |
| 43 | $agents = $agents->filter_allowed_records()->where(array('OR' => array('CONCAT (first_name, " ", last_name) LIKE ' => $sql_query, 'email LIKE' => $sql_query, 'phone LIKE' => $sql_query)))->set_limit(6)->get_results_as_models(); |
| 44 | $this->vars['agents'] = $agents; |
| 45 | } |
| 46 | |
| 47 | |
| 48 | $this->format_render(__FUNCTION__); |
| 49 | } |
| 50 | |
| 51 | } |
| 52 | endif; |