PluginProbe
Appointment Booking Plugin – LatePoint | Calendar & Scheduling for WordPress / 5.2.8
Appointment Booking Plugin – LatePoint | Calendar & Scheduling for WordPress v5.2.8
5.6.11 5.6.10 5.6.9 5.6.8 5.6.7 5.6.6 5.6.5 5.6.4 5.6.3 5.6.2 5.6.1 5.6.0 5.5.2 5.5.1 5.5.0 5.4.2 trunk 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 All 48 releases
latepoint / lib / controllers / search_controller.php
search_controller.php
52 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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;