File: //var/www/html/qcr24/app/application/models/admin/Mbooking.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Mbooking extends CI_Model {
public function __construct() {
parent::__construct();
}
public function search_room($request_data){
$sql = "CALL get_property_available_accomm_disc (".$request_data['property_id'].",'".$request_data['check_in_date']."','".$request_data['check_out_date']."',0,0,1,".$request_data['discount_perc'].");";
//echo $sql;die;
// SELECT bd.booking_id,count(bd.booking_detail_id),a.*
// FROM accommodation a
// INNER JOIN booking_detail bd ON bd.accommodation_id = a.accommodation_id AND bd.in_date
// WHERE a.property_id = 1 AND (bd.in_date NOT BETWEEN '2022-09-10' AND '2022-09-11') AND () AND is_active = 1 GROUP BY a.accommodation_id ORDER BY bd.booking_id DESC;
$query=$this->db->query($sql);
$search_room_results = $query->result_array();
return $search_room_results;
}
public function get_properties(){
$sql = "SELECT *
FROM property_master
WHERE is_active = 1";
$query = $this->db->query($sql);
return $query->result_array();
}
public function get_customer_list(){
$sql = "SELECT *
FROM customer_master
WHERE is_active = 1";
$query = $this->db->query($sql);
return $query->result_array();
}
public function get_booking_details($booking_id){
$sql = "SELECT *
FROM booking_listing_view
WHERE booking_id = ".$booking_id."";
$query = $this->db->query($sql);
return $query->result_array();
}
public function get_booking_payment_details($booking_id){
$sql = "SELECT *
FROM booking_payment_listing_view
WHERE booking_id = ".$booking_id."";
$query = $this->db->query($sql);
return $query->result_array();
}
public function get_property_country($condn = null){
$this->db->select('country_master.*');
$this->db->from('country_master');
$this->db->where($condn);
$this->db->order_by('country_name', 'ASC');
$query = $this->db->get();
return $query->result_array();
}
public function get_property_state($condn = null){
$this->db->select('state_master.*');
$this->db->from('state_master');
$this->db->where($condn);
$this->db->order_by('state_name', 'ASC');
$query = $this->db->get();
return $query->result_array();
}
public function submit_gymnasiumrate($data){
$this->db->insert('gymnasium_rates', $data);
return $this->db->insert_id();
}
public function edit_rate($rate_id){
$this->db->select('gr.*,mey.effective_year');
$this->db->from('gymnasium_rates gr');
$this->db->join('master_effective_year mey', 'mey.effective_year_id = gr.effective_year_id', 'inner');
$this->db->where('gr.status','0');
$this->db->where('gr.gymnasium_rate_id',$rate_id);
$query=$this->db->get();
return $query->row_array();
}
public function update_rate($condition,$data){
$result=$this->db->update('gymnasium_rates', $data, $condition);
return $result;
}
public function get_getaccommodation($property_id){
$this->db->select('*');
$this->db->from('accommodation');
$this->db->where('is_active','1');
$this->db->where('property_id',$property_id);
$query=$this->db->get();
return $query->result_array();
}
public function get_fieldunit(){
$this->db->select('*');
$this->db->from('master_fieldunit');
$this->db->where('status','0');
$this->db->order_by('fieldunit_name','ASC');
$query=$this->db->get();
return $query->result_array();
}
public function get_gymnasiums($location_id,$slug){
$this->db->select('*');
$this->db->from('sports_facilities');
$this->db->where('status','0');
$this->db->where('location_id',$location_id);
$this->db->where('slug',$slug);
$this->db->order_by('sports_facilities_name','ASC');
$query=$this->db->get();
return $query->result_array();
}
public function get_effective_years(){
$this->db->select('*');
$this->db->from('master_effective_year');
$this->db->where('status','0');
$this->db->order_by('effective_year','ASC');
$query=$this->db->get();
return $query->result_array();
}
public function gymnasium_rate_count($sports_facilities_id,$effective_year_id,$user_type){
$this->db->select('gymnasium_rate_id');
$this->db->from('gymnasium_rates');
$this->db->where('user_type',$user_type);
$this->db->where('sports_facilities_id',$sports_facilities_id);
$this->db->where('effective_year_id',$effective_year_id);
$query=$this->db->get();
$ret = $query->num_rows();
return $ret;
}
public function gymnasium_schedule_count($rate_id){
$this->db->select('gymnasium_schedule_id');
$this->db->from('gymnasium_schedule');
$this->db->where('gymnasium_rate_id',$rate_id);
$query=$this->db->get();
$ret = $query->num_rows();
return $ret;
}
public function update_booking_details($booking_id ='', $data = array()){
try{
$this->db->where('booking_id', $booking_id)->update('booking_header', $data);
return true;
}catch(Exception $ex){
return false;
}
}
}