<?php
class Member_card_report_model extends CI_Model {
    
    function __construct() {
        parent::__construct();
        $this->member_card = TBL_BILL_MEMBER_CARD;
        $this->card_topup = TBL_BILL_CARD_TOPUP;
        $this->star = TBL_STAR;
    }
    
    public function get_data($start_date='',$end_date='',$card_no=''){
        $this->db->select('mc.card_no, mc.name, mc.contact_no, mc.tamil_name, star.name as star, ct.*',FALSE);
        $this->db->join($this->member_card . ' as mc','mc.id = ct.mem_id');
        $this->db->join($this->star . ' as star','star.id = mc.star','left');
        if(!empty($start_date) && !empty($end_date)) {
            $this->db->where('ct.created_on >=',date('Y-m-d 00:00:00',strtotime($start_date)));
            $this->db->where('ct.created_on <=',date('Y-m-d 23:59:59',strtotime($end_date)));
        } else {
            $this->db->where('ct.created_on >=',date('Y-m-d 00:00:00'));
            $this->db->where('ct.created_on <=',date('Y-m-d 23:59:59'));
        } 
        if(!empty($card_no)) {
            $this->db->where('mc.card_no',$card_no);
        }
        #$this->db->where('ct.status',1);
        return $this->db->get($this->card_topup . ' as ct')->result();
    }
}
?>


