<?php
class Temp_shop_sale_report_model extends CI_Model {
    
    function __construct() {
        parent::__construct();
        $this->services = TBL_SERVICE;
        $this->temp_shop_sale = TBL_BILL_TEMPLESHOP_SALES;
    }
    
    public function list_service_type(){
        $this->db->select('id,name as service_name');
        $this->db->where('menu_name',19);
        $this->db->where('status',1);
        return $this->db->get($this->services)->result();
    }
    
    public function get_data($start_date='',$end_date='',$type=''){
        $this->db->select('s.name as service_name, s.prefix, tss.*',FALSE);
        $this->db->join($this->services . ' as s','s.id = tss.service_id');
        if(!empty($start_date) && !empty($end_date)) {
            $this->db->where('tss.created_on >=',date('Y-m-d 00:00:00',strtotime($start_date)));
            $this->db->where('tss.created_on <=',date('Y-m-d 23:59:59',strtotime($end_date)));
        } else {
            $this->db->where('tss.created_on >=',date('Y-m-d 00:00:00'));
            $this->db->where('tss.created_on <=',date('Y-m-d 23:59:59'));
        } 
        if(!empty($type)) {
            $this->db->where('tss.service_id',$type);
        }
        #$this->db->where('gs.status',1);
        return $this->db->get($this->temp_shop_sale . ' as tss')->result();
    }
}
?>


