File: /home/cafsindia/allyindian_com/sbltt/application/models/Vehicleno_sales_model.php
<?php
class Vehicleno_sales_model extends CI_Model{
public function vehicle_sales($start_date,$end_date){
//echo "SELECT vehicle_no,booking_amount FROM sblt_operation_line inner join sblt_operation on sblt_operation.operation_id = sblt_operation_line.operation_id and sblt_operation_line.status = '1' inner join sblt_vehicle on sblt_vehicle.vehicle_id = sblt_operation_line.op_vehicle_id inner join sblt_veh_type on sblt_veh_type.veh_type_id = sblt_vehicle.vehicle_type where sblt_operation_line.status = '1' and DATE_FORMAT(sblt_operation.from_date, '%Y-%m-%d') BETWEEN '$start_date' and '$end_date' and sblt_operation.status='1' and sblt_operation.operation_sts='2' ORDER BY booking_amount DESC LIMIT 0,5";
$qry = $this->db->query("SELECT vehicle_no,IFNULL(sum(booking_amount),0) as book_amt FROM sblt_operation_line inner join sblt_operation on sblt_operation.operation_id = sblt_operation_line.operation_id and sblt_operation_line.status = '1' inner join sblt_vehicle on sblt_vehicle.vehicle_id = sblt_operation_line.op_vehicle_id inner join sblt_veh_type on sblt_veh_type.veh_type_id = sblt_vehicle.vehicle_type where sblt_operation_line.status = '1' and DATE_FORMAT(sblt_operation.from_date, '%Y-%m-%d') BETWEEN '$start_date' and '$end_date' and sblt_operation.status='1' and sblt_operation.operation_sts='2' group by sblt_operation_line.op_vehicle_id ORDER BY book_amt DESC LIMIT 0,5");
$row = $qry->result_array();
return $row;
}
public function bar_report($start_date,$end_date){
$qry = $this->db->query("SELECT vehicle_no,IFNULL(sum(booking_amount),0) as book_amt FROM sblt_operation_line inner join sblt_operation on sblt_operation.operation_id = sblt_operation_line.operation_id and sblt_operation_line.status = '1' inner join sblt_vehicle on sblt_vehicle.vehicle_id = sblt_operation_line.op_vehicle_id inner join sblt_veh_type on sblt_veh_type.veh_type_id = sblt_vehicle.vehicle_type where sblt_operation_line.status = '1' and DATE_FORMAT(sblt_operation.from_date, '%Y-%m-%d') BETWEEN '$start_date' and '$end_date' and sblt_operation.status='1' and sblt_operation.operation_sts='2' group by sblt_operation_line.op_vehicle_id ORDER BY book_amt DESC LIMIT 0,5");
$row = $qry->result_array();
foreach ($row as $key => $value) {
$vehicle_no = $value['vehicle_no'];
$book_amount = $value['book_amt'];
$category['name'] = 'Vehicle No';
$series1['name'] = 'Sales';
$category['data'][] = $vehicle_no;
$series1['data'][] = $book_amount;
}
$result = array();
array_push($result,$category);
array_push($result,$series1);
return $result;
}
}
?>