File: /var/www/html/pmw24/driver_settlement/old/applicationold/models/admin/Msetting.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Msetting extends CI_Model {
/*
author: soumya hazra
purpose: Get lifting
date: 9-9-2019
*/
public function get_lifting()
{
$result = array();
$this->db->select('*');
$this->db->from('master_lifting_fee');
$query = $this->db->get();
$result = $query->row_array();
return $result;
}
/*
author: soumya hazra
purpose: Get levy
date: 9-9-2019
*/
public function get_levy()
{
$result = array();
$this->db->select('*');
$this->db->from('master_levy');
$query = $this->db->get();
$result = $query->row_array();
return $result;
}
/*
author: soumya hazra
purpose: Get Commission
date: 9-9-2019
*/
public function get_comissions()
{
$result = array();
$this->db->select('*');
$this->db->from('master_commission');
$query = $this->db->get();
$result = $query->result_array();
return $result;
}
/*
author: soumya hazra
purpose: Get questions
date: 9-9-2019
*/
public function get_questions()
{
$result = array();
$this->db->select('*');
$this->db->from('master_question');
$this->db->where('is_active',1);
$this->db->order_by('question_id','DESC');
$query = $this->db->get();
$result = $query->result_array();
return $result;
}
/*
author: soumya hazra
purpose: Get questions inactive
date: 9-9-2019
*/
public function get_questions_inactive()
{
$result = array();
$this->db->select('*');
$this->db->from('master_question');
$this->db->where('is_active',0);
$this->db->order_by('question_id','DESC');
$query = $this->db->get();
$result = $query->result_array();
return $result;
}
/*
author: soumya hazra
purpose: Get Single Comission
date: 9-9-2019
*/
public function get_singl_comissions($cid)
{
$result = array();
$this->db->select('*');
$this->db->from('master_commission');
$this->db->where('commission_id',$cid);
$query = $this->db->get();
$result = $query->row_array();
return $result;
}
/*
author: soumya hazra
purpose: Get Single Ques
date: 9-9-2019
*/
public function get_singl_qus($qid)
{
$result = array();
$this->db->select('*');
$this->db->from('master_question');
$this->db->where('question_id',$qid);
$query = $this->db->get();
$result = $query->row_array();
return $result;
}
/*
author: soumya hazra
purpose: Add lifting
date: 9-9-2019
*/
public function addlifting($data)
{
$this->db->insert('master_lifting_fee', $data);
return true;
}
/*
author: soumya hazra
purpose: Add question
date: 9-9-2019
*/
public function submit_question($data)
{
$this->db->insert('master_question', $data);
return true;
}
/*
author: soumya hazra
purpose: Add lifting
date: 9-9-2019
*/
public function add_levy($data)
{
$this->db->insert('master_levy', $data);
return true;
}
/*
author: soumya hazra
purpose: Add comission
date: 9-9-2019
*/
public function add_comission($data)
{
$this->db->insert('master_commission', $data);
return true;
}
/*
author: soumya hazra
purpose: Update lifting
date: 9-9-2019
*/
public function updatelifting($data,$lifting_fee_id)
{
$this->db->where('lifting_fee_id', $lifting_fee_id);
$this->db->Update('master_lifting_fee',$data);
return true;
}
/*
author: soumya hazra
purpose: Update lifting
date: 9-9-2019
*/
public function update_question($data,$question_id)
{
$this->db->where('question_id', $question_id);
$this->db->Update('master_question',$data);
return true;
}
/*
author: soumya hazra
purpose: set Inactive
date: 9-9-2019
*/
public function set_inactive($qid)
{
$this->db->where('question_id', $qid);
$this->db->set('is_active',0);
$this->db->Update('master_question');
return true;
}
/*
author: soumya hazra
purpose: set Inactive
date: 9-9-2019
*/
public function set_active($qid)
{
$this->db->where('question_id', $qid);
$this->db->set('is_active',1);
$this->db->Update('master_question');
return true;
}
/*
author: soumya hazra
purpose: Update levy
date: 9-9-2019
*/
public function update_levy($data,$levy_id)
{
$this->db->where('levy_id', $levy_id);
$this->db->Update('master_levy',$data);
return true;
}
/*
author: soumya hazra
purpose: Update commission
date: 9-9-2019
*/
public function update_commission($data,$commission_id)
{
$this->db->where('commission_id', $commission_id);
$this->db->Update('master_commission',$data);
return true;
}
/*
author: soumya hazra
purpose: Get all car
date: 9-9-2019
*/
public function get_cars()
{
$result = array();
$this->db->select('*');
$this->db->from('master_car');
$this->db->where('status',1);
$query = $this->db->get();
$result = $query->result_array();
return $result;
}
/*
author: soumya hazra
purpose: Get all car
date: 9-9-2019
*/
public function get_drivers()
{
$result=array();
$query = "select mu.user_id,mu.dc_no,
CONCAT(up.first_name,' ',ifnull(up.middle_name,''),' ',up.last_name) as full_name
from master_user mu
inner join user_profile up on mu.user_id=up.user_id
where mu.role_id=2 AND mu.status = 1 AND mu.is_active = 1";
$query1 = $this->db->query($query);
$result=$query1->result_array();
//echo $this->db->last_query();die;
return $result;
}
/*
author: soumya hazra
purpose: Get all inspection
date: 9-9-2019
*/
public function get_inspection($car_id,$driver_id,$start_date,$end_date)
{
$result = array();
$qstart_date = $qend_date ='';
$qstart_date = date("Y-m-d", strtotime(str_replace('/', '-',$this->input->post( 'start_date' ))));
$qend_date = date("Y-m-d", strtotime(str_replace('/', '-',$this->input->post( 'end_date' ))));
$this->db->select('inspection.*,master_car.registration_no,CONCAT(user_profile.first_name," ",user_profile.middle_name," ",user_profile.last_name) as driver_name,master_user.dc_no');
$this->db->from('inspection');
$this->db->join('master_car','master_car.car_id = inspection.car_id');
$this->db->join('master_user','master_user.user_id = inspection.driver_id');
$this->db->join('user_profile','user_profile.user_id = inspection.driver_id');
if($driver_id)
{
$this->db->where('inspection.driver_id',$driver_id);
}
if($car_id)
{
$this->db->where('inspection.car_id',$car_id);
}
if($start_date)
{
$this->db->where('inspection.inspection_date >=', $qstart_date);
}
if($end_date)
{
$this->db->where('inspection.inspection_date <=', $qend_date);
}
$this->db->order_by('inspection.inspection_date','DESC');
$query = $this->db->get();
$result = $query->result_array();
return $result;
}
/*
author: soumya hazra
purpose: Get all accident data
date: 9-9-2019
*/
public function get_accidents()
{
$this->db->select('master_accident.*,master_user.dc_no,master_car.registration_no,CONCAT(user_profile.first_name," ",user_profile.middle_name," ",user_profile.last_name) as driver_name');
$this->db->from('master_accident');
$this->db->join('master_car','master_car.car_id = master_accident.car_id');
$this->db->join('user_profile','user_profile.user_id = master_accident.driver_id');
$this->db->join('master_user','master_user.user_id = master_accident.driver_id');
$this->db->order_by('master_accident.accident_id','desc');
$query = $this->db->get();
$result = $query->result_array();
// echo $this->db->last_query();die;
return $result;
}
/*
author: soumya hazra
purpose: Get single accident data
date: 9-9-2019
*/
public function fetch_accident_data($accident_id)
{
$this->db->select('master_accident.*,master_car.registration_no');
$this->db->from('master_accident');
$this->db->join('master_car','master_car.car_id = master_accident.car_id');
$this->db->where('master_accident.accident_id',$accident_id);
$query = $this->db->get();
$result = $query->row_array();
return $result;
}
/*
author: soumya hazra
purpose: get accident charges
date: 9-9-2019
*/
public function get_acc_charges($driver_id = null)
{
$this->db->select('accident_charge.*,master_accident.*,master_user.dc_no,master_car.registration_no,CONCAT(user_profile.first_name," ",user_profile.middle_name," ",user_profile.last_name) as driver_name');
$this->db->from('accident_charge');
$this->db->join('master_accident','accident_charge.accident_id = master_accident.accident_id');
$this->db->join('master_car','master_car.car_id = master_accident.car_id');
$this->db->join('user_profile','user_profile.user_id = master_accident.driver_id');
$this->db->join('master_user','master_user.user_id = master_accident.driver_id');
if($driver_id){
$this->db->where('master_accident.driver_id',$driver_id);
}
$query = $this->db->get();
$result = $query->result_array();
//echo $this->db->last_query();die;
return $result;
}
/*
author: soumya hazra
purpose: Get accident releted in shift Edit
date: 13-9-2019
*/
public function fetch_accident_data_edit($accident_id)
{
$this->db->select('accident_charge.*,master_accident.*,master_user.dc_no,master_car.registration_no,CONCAT(user_profile.first_name," ",user_profile.middle_name," ",user_profile.last_name) as driver_name');
$this->db->from('accident_charge');
$this->db->join('master_accident','accident_charge.accident_id = master_accident.accident_id');
$this->db->join('master_car','master_car.car_id = master_accident.car_id');
$this->db->join('user_profile','user_profile.user_id = master_accident.driver_id');
$this->db->join('master_user','master_user.user_id = master_accident.driver_id');
$this->db->where('master_accident.accident_id',$accident_id);
$query = $this->db->get();
$result = $query->row_array();
return $result;
}
/*
author: soumya hazra
purpose: Add accident charge
date: 13-9-2019
*/
public function add_acc_charge($data)
{
$this->db->insert('accident_charge', $data);
return true;
}
/*
author: soumya hazra
purpose: Update accident charge
date: 13-9-2019
*/
public function update_acc_charge($accident_id,$settlement_amount)
{
$this->db->set('settlement_amount', $settlement_amount);
$this->db->set('amt_due', 'amt_due -'.$settlement_amount,false);
$this->db->where('accident_id', $accident_id);
$this->db->update('accident_charge');
return true;
}
/*
author: soma
purpose: Get no of accident car
date: 24-9-2019
*/
public function no_of_car($accident_id)
{
//$this->db->select('master_accident.*,accident_witness.*,accident_involved_car.*,master_user.dc_no,master_car.registration_no,CONCAT(user_profile.first_name," ",user_profile.middle_name," ",user_profile.last_name) as drivername');
$this->db->select('master_accident.*,accident_witness.*,accident_involved_car.*,master_user.dc_no,master_car.registration_no');
$this->db->from('master_accident');
$this->db->join('master_car','master_car.car_id = master_accident.car_id');
$this->db->join('accident_witness','accident_witness.accident_id = master_accident.accident_id');
$this->db->join('accident_involved_car','accident_involved_car.accident_id = master_accident.accident_id');
//$this->db->join('user_profile','user_profile.user_id = master_accident.driver_id');
$this->db->join('master_user','master_user.user_id = master_accident.driver_id');
$this->db->where('master_accident.accident_id', $accident_id);
$query = $this->db->get();
// $result = $query->row_array();
$result = $query->num_rows();
//echo $this->db->last_query();die;
return $result;
}
/*
author: soma
purpose: Get a owner vehicle by id
date: 30-9-2019
*/
public function owner_vehicle($accident_id)
{
$this->db->select('master_accident.*,master_company.email as company_email,master_company.company_name,master_company.business_name,master_company.mobile as company_mobile,master_company.landline_no as company_landline,master_company.abn as company_abn,CONCAT(master_company.flat_no," ",master_company.street_no," ",master_company.street_name," ",master_company.suburb," ",master_company.state," ",master_company.pin) as companyaddress,master_user.dc_no,master_user.email as driveremail,user_profile.mobile as drivermobile,user_profile.landline_no as driverlandline,user_profile.dob as driverdob,user_profile.dr_licence_expiry as driver_dr_licence_expiry,master_car.registration_no as company_rego,master_car.make as company_make,CONCAT(user_profile.first_name," ",user_profile.middle_name," ",user_profile.last_name) as drivername,CONCAT(user_profile.flat_no," ",user_profile.street_no," ",user_profile.street_name) as driveraddress');
// $this->db->select('master_accident.*,accident_witness.*,accident_involved_car.*,master_user.dc_no,master_car.registration_no');
$this->db->from('master_accident');
$this->db->join('master_car','master_car.car_id = master_accident.car_id');
// $this->db->join('accident_witness','accident_witness.accident_id = master_accident.accident_id');
// $this->db->join('accident_involved_car','accident_involved_car.accident_id = master_accident.accident_id');
$this->db->join('user_profile','user_profile.user_id = master_accident.driver_id');
$this->db->join('master_user','master_user.user_id = master_accident.driver_id');
$this->db->join('master_company','master_company.company_id = master_car.company_id');
$this->db->where('master_accident.accident_id', $accident_id);
$query = $this->db->get();
$num = $query->num_rows();
//$result = $query->result_array();
$result = $query->row_array();
//echo $this->db->last_query();die;
return $result;
}
/*
author: soma
purpose: Get a single accident by id
date: 19-9-2019
*/
public function singl_accident($accident_id)
{
//$this->db->select('master_accident.*,accident_witness.*,accident_involved_car.*,master_user.dc_no,master_car.registration_no,CONCAT(user_profile.first_name," ",user_profile.middle_name," ",user_profile.last_name) as drivername');
// $this->db->select('master_accident.*,accident_witness.*,accident_involved_car.*,master_user.dc_no,master_car.registration_no');
$this->db->select('master_accident.*,accident_witness.*,accident_involved_car.*,master_user.dc_no,master_car.registration_no');
$this->db->from('master_accident');
$this->db->join('master_car','master_car.car_id = master_accident.car_id','left');
$this->db->join('accident_witness','accident_witness.accident_id = master_accident.accident_id','left');
$this->db->join('accident_involved_car','accident_involved_car.accident_id = master_accident.accident_id','left');
//$this->db->join('user_profile','user_profile.user_id = master_accident.driver_id');
$this->db->join('master_user','master_user.user_id = master_accident.driver_id','left');
$this->db->where('master_accident.accident_id', $accident_id);
$query = $this->db->get();
$num = $query->num_rows();
$result = $query->result_array();
//echo $this->db->last_query();die;
return $result;
}
/*
author: soma
purpose: Get a media accident by id
date: 19-9-2019
*/
public function accident_media($accident_id,$accident_media)
{
$this->db->select('accident_media.*,master_accident.*');
$this->db->from('accident_media');
$this->db->join('master_accident','master_accident.accident_id = accident_media.accident_id');
$this->db->where('accident_media.accident_id', $accident_id);
$this->db->where('accident_media.type', $accident_media);
$query = $this->db->get();
$result = $query->result_array();
// echo $this->db->last_query();die;
return $result;
}
/*
author: soma
purpose: Get a media accident by id
date: 19-9-2019
*/
public function accident_car_number_plate($accident_id,$car_number_plate)
{
$this->db->select('accident_media.*,master_accident.*');
// $this->db->select('*');
$this->db->from('accident_media');
$this->db->join('master_accident','master_accident.accident_id = accident_media.accident_id');
$this->db->where('accident_media.accident_id', $accident_id);
$this->db->where('accident_media.type', $car_number_plate);
$query = $this->db->get();
$result = $query->row_array();
// echo $this->db->last_query();die;
return $result;
}
/*
author: soma
purpose: Get a media accident by id
date: 19-9-2019
*/
public function accident_driving_licence_front($accident_id,$driving_licence_front)
{
$this->db->select('accident_media.*,master_accident.*');
$this->db->from('accident_media');
$this->db->join('master_accident','master_accident.accident_id = accident_media.accident_id');
$this->db->where('accident_media.accident_id', $accident_id);
$this->db->where('accident_media.type', $driving_licence_front);
$query = $this->db->get();
$result = $query->row_array();
// echo $this->db->last_query();die;
return $result;
}
/*
author: soma
purpose: Get a media accident by id
date: 19-9-2019
*/
public function accident_driving_licence_back($accident_id,$driving_licence_back)
{
$this->db->select('accident_media.*,master_accident.*');
$this->db->from('accident_media');
$this->db->join('master_accident','master_accident.accident_id = accident_media.accident_id');
$this->db->where('accident_media.accident_id', $accident_id);
$this->db->where('accident_media.type', $driving_licence_back);
$query = $this->db->get();
$result = $query->row_array();
// echo $this->db->last_query();die;
return $result;
}
/*
author: soma
purpose: Get a row by id
date: 19-9-2019
*/
public function get_details($accident_media_id){
$this->db->select('*');
$this->db->from('accident_media');
$this->db->where('accident_media_id',$accident_media_id);
$query=$this->db->get();
//echo $this->db->last_query();die;
return $query->row_array();
}
/*
author: soma
purpose: Get accident data by id to generate pdf
date: 23-9-2019
*/
public function get_accidents_byId($accident_id)
{
$this->db->select('master_accident.*,master_user.dc_no,master_car.registration_no,CONCAT(user_profile.first_name," ",user_profile.middle_name," ",user_profile.last_name) as driver_name');
$this->db->from('master_accident');
$this->db->join('master_car','master_car.car_id = master_accident.car_id');
$this->db->join('user_profile','user_profile.user_id = master_accident.driver_id');
$this->db->join('master_user','master_user.user_id = master_accident.driver_id');
$this->db->where('master_accident.accident_id',$accident_id);
$query = $this->db->get();
$result = $query->result_array();
// echo $this->db->last_query();die;
return $result;
}
/*
author: soma
purpose: Get is_insured
date: 01-10-2019
*/
public function getDetails($table,$condition,$select = null){
if(isset($select) && $select){
$this->db->select($select);
}
$this->db->where($condition);
$query=$this->db->get($table);
//echo $this->db->last_query();die;
return $query->result_array();
}
public function get_accident_list_against_driver($driver_id,$add_or_settle_flag){
$query="SELECT ma.* FROM master_accident ma WHERE ma.driver_id='".$driver_id."'";
if($add_or_settle_flag=='add'){
$query .=" AND NOT EXISTS(SELECT 1 FROM accident_charge ac WHERE ac.accident_id=ma.accident_id)";
}
if($add_or_settle_flag=='settle'){
$query .=" AND EXISTS(SELECT 1 FROM accident_charge ac WHERE ac.accident_id=ma.accident_id)";
}
$run_query=$this->db->query($query);
//echo $this->db->last_query();die;
return $run_query->result_array();
}
/*
author: Sreela
purpose: Get is_insured
date: 24-10-2019
*/
public function get_inspection_details($inspection_id)
{
$this->db->select('master_car.registration_no,master_question.question,inspection_answer.*,inspection_answer_image.image');
$this->db->from('inspection');
$this->db->join('master_car','master_car.car_id = inspection.car_id');
$this->db->join('inspection_answer','inspection.inspection_id = inspection_answer.inspection_id','inner');
$this->db->join('master_question','master_question.question_id = inspection_answer.question_id');
$this->db->join('inspection_answer_image','inspection_answer_image.inspection_answer_id = inspection_answer.inspection_answer_id','left');
$this->db->where('inspection.inspection_id',$inspection_id);
$query = $this->db->get();
//echo $this->db->last_query();exit;
$result = $query->result_array();
return $result;
}
}