HEX
Server: Apache/2.4.41 (Amazon) OpenSSL/1.0.2k-fips PHP/5.6.40
System: Linux ip-172-31-40-18 4.14.146-93.123.amzn1.x86_64 #1 SMP Tue Sep 24 00:45:23 UTC 2019 x86_64
User: apache (48)
PHP: 5.6.40
Disabled: NONE
Upload Files
File: //var/www/html/qcr24/app/application/models/admin/Mincome.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Mincome extends CI_Model {

    public function __construct() {
        parent::__construct();

    }

    public function getIncome($from_date='',$to_date='',$car_id=''){
        $this->db->select('riv.*,DATE_FORMAT(riv.created_ts,"%d/%m/%Y") AS created_date,mc.car_no,rov.weekly_rent');
        $this->db->from('rent_out_vehcile rov');
        $this->db->join('rent_in_vehcile riv','riv.rent_out_id=riv.rent_out_id','left');
        $this->db->join('master_car mc','mc.car_id=rov.car_id','inner');
        if(!empty($from_date) && !empty($to_date)){
            $this->db->where('riv.created_ts >= date("'.$from_date.'")');
            $this->db->where('riv.created_ts <= date("'.$to_date.'")');
        }
        if(!empty($car_id)){
            $this->db->where('rov.car_id',$car_id);
        }
        $query=$this->db->get();
        //echo $this->db->last_query();die;
        return $query->result_array();
    }

    public function get_car(){
        $this->db->select('*');
        $this->db->from('master_car');
        $this->db->where('status <>','2');
		/*$this->db->group_by('car_name');*/
        $query=$this->db->get();
        return $query->result_array();
    }

    

    public function edit_accident($accident_id){
        $this->db->select('*');
        $this->db->from('master_admin');
		$this->db->where('accident_id',$accident_id);
        $query=$this->db->get();
        return $query->row_array();
    }
	
    public function get_role(){
        $this->db->select('*');
        $this->db->from('master_role');
        $this->db->where('status','0');
        $this->db->where('role_id <>','2');
        $this->db->order_by('role_id','DESC');
        $query=$this->db->get();
        return $query->result_array();
		}

    public function get_state(){
        $this->db->select('*');
        $this->db->from('state');
        $this->db->order_by('state_id','ASC');
        $query=$this->db->get();
        return $query->result_array();
    }
    
    public function submit_accident($data){
        $this->db->insert('master_admin', $data);
        return $this->db->insert_id();
    }

    public function update_accident($condition,$data){
        $result=$this->db->update('master_admin', $data, $condition);
        return $result;
    }

    public function get_role_permission($role_id = '')
    {
        $role_permission = $this->db->where('role_id', $role_id)
                                    ->get('accident_permission')->result();
        return $role_permission;
    }

    public function add_edit_permission($data_array = array(), $insert_count_on)
    {
        $role_permission = '';
        if(!empty($data_array['role_id'])){
            $role_permission = $this->db->where('role_id', $data_array['role_id'])
                                        ->where('menu_id', $data_array['menu_id'])
                                        ->get('accident_permission')->row();
        }
        
        $data_array['created_by'] = $this->admin_session_data['accident_id'];
        $data_array['created_ts'] = date('Y-m-d h:i:s');

        if(!empty($role_permission)){
            $data_array['created_by'] = $role_permission->created_by;
            $data_array['created_ts'] = $role_permission->created_ts;
            $data_array['updated_by'] = $this->admin_session_data['accident_id'];
            $data_array['updated_ts'] = date('Y-m-d h:i:s');
            $this->db->where('permission_id', $role_permission->permission_id)->delete('accident_permission');
        }
        if($insert_count_on){
            $this->db->insert('accident_permission', $data_array);
            return $this->db->insert_id();
        }else{
            return true;
        }
    }

}