activities_controller.php
1 month ago
auth_controller.php
3 months ago
booking_form_settings_controller.php
3 months ago
bookings_controller.php
12 hours ago
calendars_controller.php
3 months ago
carts_controller.php
12 hours ago
controller.php
3 months ago
customer_cabinet_controller.php
2 months ago
customers_controller.php
12 hours ago
dashboard_controller.php
2 months ago
default_agent_controller.php
3 months ago
events_controller.php
3 months ago
form_fields_controller.php
1 week ago
integrations_controller.php
3 months ago
invoices_controller.php
12 hours ago
manage_booking_by_key_controller.php
3 months ago
manage_order_by_key_controller.php
3 months ago
notifications_controller.php
3 months ago
orders_controller.php
12 hours ago
pro_controller.php
2 weeks ago
process_jobs_controller.php
3 months ago
processes_controller.php
1 month ago
razorpay_connect_controller.php
1 week ago
search_controller.php
3 months ago
services_controller.php
3 months ago
settings_controller.php
2 months ago
steps_controller.php
2 weeks ago
stripe_connect_controller.php
1 week ago
support_topics_controller.php
3 months ago
todos_controller.php
3 months ago
transactions_controller.php
12 hours ago
wizard_controller.php
1 week ago
search_controller.php
70 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 ) { |
| 22 | return; |
| 23 | } |
| 24 | $sql_query = '%' . $query . '%'; |
| 25 | |
| 26 | |
| 27 | $bookings = new OsBookingModel(); |
| 28 | $bookings = $bookings->filter_allowed_records()->where( [ 'booking_code' => strtoupper( $query ) ] )->get_results_as_models(); |
| 29 | $this->vars['bookings'] = $bookings; |
| 30 | |
| 31 | $customers = new OsCustomerModel(); |
| 32 | $customers->filter_allowed_records()->where( |
| 33 | array( |
| 34 | 'OR' => array( |
| 35 | 'CONCAT (first_name, " ", last_name) LIKE ' => $sql_query, |
| 36 | 'email LIKE' => $sql_query, |
| 37 | 'phone LIKE' => $sql_query, |
| 38 | ), |
| 39 | ) |
| 40 | )->set_limit( 6 ); |
| 41 | |
| 42 | $customers = $customers->get_results_as_models(); |
| 43 | $this->vars['customers'] = $customers; |
| 44 | $this->vars['query'] = $query; |
| 45 | |
| 46 | if ( OsRolesHelper::can_user( 'service__view' ) ) { |
| 47 | $services = new OsServiceModel(); |
| 48 | $services = $services->filter_allowed_records()->where( array( 'name LIKE ' => $sql_query ) )->set_limit( 6 )->get_results_as_models(); |
| 49 | $this->vars['services'] = $services; |
| 50 | } |
| 51 | if ( OsRolesHelper::can_user( 'agent__view' ) ) { |
| 52 | $agents = new OsAgentModel(); |
| 53 | $agents = $agents->filter_allowed_records()->where( |
| 54 | array( |
| 55 | 'OR' => array( |
| 56 | 'CONCAT (first_name, " ", last_name) LIKE ' => $sql_query, |
| 57 | 'email LIKE' => $sql_query, |
| 58 | 'phone LIKE' => $sql_query, |
| 59 | ), |
| 60 | ) |
| 61 | )->set_limit( 6 )->get_results_as_models(); |
| 62 | $this->vars['agents'] = $agents; |
| 63 | } |
| 64 | |
| 65 | |
| 66 | $this->format_render( __FUNCTION__ ); |
| 67 | } |
| 68 | } |
| 69 | endif; |
| 70 |