miniCal
  • Quick Start
    • Introduction
  • miniCal Configuration
    • miniCal Hosted Service
    • Configure Feature Settings
    • Install Extensions
    • Create Multiple Properties
  • Local Installation
    • Local Installation
    • ENV Set-Up
    • Configuration Settings
    • Common Installations Errors
  • Contribution
    • Contribute to miniCal Core
  • Build an Extension
    • Build Your First Extension
      • Controllers
      • Assets
      • Config
      • language
      • Models
      • View
      • Helper
      • Library
      • Hooks
    • Open-source Extensions
    • Config Folder Files
      • Autoload File
      • Config File
      • Route File
    • miniCal Filters
    • miniCal Actions
    • Create Custom Hooks
    • Store Custom Data
      • POSTS
      • POSTMETA
      • OPTIONS
    • Composer Dependencies
  • Marketplace
    • miniCal Marketplace
  • Other resources
    • Overbooking for OTAs
    • miniCal Cron Setup
    • Automated Night Audit
    • Nginx Configuration
    • Docker Installation
    • Custom Domain Setup
  • Minical API Docs
    • API Documentation
  • Coming soon!
    • Access minical Data Using Helpers
      • Company Helper Functions
      • Customer Helper Functions
      • Booking Helper Functions
      • Rates Helper Functions
      • Rate Plan Helper Functions
      • Availability Helper Functions
      • Statement Helper Functions
      • Tax Helper Functions
      • Room Helper Functions
      • Charge Helper Functions
      • Payment Helper Functions
    • Access data in Extension
Powered by GitBook
On this page
  1. Build an Extension
  2. Build Your First Extension

Models

This folder contains model files, all the database-related queries will go on these files.

bookings_model.php
<?php
class Bookings_model extends CI_Model {

    function __construct()
    {
        parent::__construct();
    }
    
    /**
    * This function will return the result-set array of bookings.
    * @return Array $result array of bookings.
    */  
    function get_bookings()
    {
        $company_id = $this->session->userdata('current_company_id');
        
         $sql_query ="SELECT b.rate,b.booking_id,bb.room_id,bb.check_in_date, bb.check_out_date, r.room_name, c.customer_name, c.email
                from booking b, booking_block bb, room r, customer c
                where b.booking_id=bb.booking_id 
                and bb.room_id=r.room_id
                and b.booking_customer_id=c.customer_id
                and b.company_id=$company_id order by b.booking_id DESC LIMIT 20" ;
        
        $booking_data = $this->db->query($sql_query);    
            if ($this->db->_error_message()) 
            {
                show_error($this->db->_error_message());
            }
         $result = $booking_data->result_array();       
        
        return $result;
    }
   
      /**
    * This function will return the result-set array of customers.
    * @return Array $result array of customers.
    */  
    function get_customer_list()
    {
        $company_id = $this->session->userdata('current_company_id');
        $query = "SELECT customer_name, email, address,phone FROM customer where company_id = $company_id order by customer_id DESC LIMIT 20";
        $customer = $this->db->query($query);    
        if ($this->db->_error_message()) 
        {
            show_error($this->db->_error_message());
        }
        
        $result = $customer->result_array();       
        return $result;
    }  
}
PreviouslanguageNextView

Last updated 3 years ago