File: //home/cafsindia/allyindian_com/sbltt/application/models/Pkg_er_report_model.php
<?php
class Pkg_er_report_model extends CI_Model
{
public function search($search, $filters, $rows = 0, $limit_from = 0, $sort = '', $order = 'asc'){
$start_date = $filters['start_date'];
$end_date = $filters['end_date'];
// if(!$sort){
// $sort = "ncd";
// }
$this->db->select('customer_name,customers.phone_number,enquiry_date,ticket_count,pickup_point,discount,sourcing,enquiry_sts,package_name');
$this->db->from('temple_enquiry');
$this->db->join('customers', 'customers.cust_id = temple_enquiry.cust_id','left');
$this->db->join('package_management', 'package_management.package_id = temple_enquiry.package_id','left');
if($search){
$this->db->group_start();
$this->db->or_like('customer_name',$search);
$this->db->or_like('phone_number',$search);
$this->db->or_like('package_name',$search);
$this->db->or_like('enquiry_month',$search);
if(strpos($search, '-') !== false){
$this->db->or_like('enquiry_date', date('Y-m-d',strtotime($search)));
}
$this->db->group_end();
}
$this->db->group_start();
$this->db->where('DATE_FORMAT(from_date, "%Y-%m-%d") BETWEEN '. $this->db->escape($start_date).' AND '.$this->db->escape($end_date))->or_where('DATE_FORMAT(to_date, "%Y-%m-%d") BETWEEN '. $this->db->escape($start_date).' AND '.$this->db->escape($end_date));
$this->db->group_end();
$this->db->where('temple_enquiry.status',1);
$this->db->order_by($sort,$order);
if($rows>0){
$this->db->limit($rows, $limit_from);
}
return $this->db->get();
}
public function get_found_rows($search, $filters){
return $this->search($search, $filters)->num_rows();
}
public function vehicle_type_report_chart($start_date,$end_date){
$qry = $this->db->query("SELECT count(*) as tot,veh_type from sblt_booking inner join sblt_operation on sblt_operation.booking_id = sblt_booking.booking_id inner join sblt_veh_type on sblt_operation.vehicle_type = sblt_veh_type.veh_type_id where sblt_booking.status = '1' and sblt_booking.booking_sts = '2' and (DATE_FORMAT(sblt_operation.from_date, '%Y-%m-%d') BETWEEN '$start_date' and '$end_date' or DATE_FORMAT(sblt_operation.to_date, '%Y-%m-%d') BETWEEN '$start_date' and '$end_date') group by veh_type");
$result = $qry->result_array();
return $result;
}
public function vehicle_type_report($filters){
$start_date = $filters['start_date'];
$end_date = $filters['end_date'];
$start = date('d-M-Y',strtotime($start_date));
$end = date('d-M-Y',strtotime($end_date));
$book_qry = $this->db->query("SELECT count(*) as tot,veh_type from sblt_booking inner join sblt_operation on sblt_operation.booking_id = sblt_booking.booking_id inner join sblt_veh_type on sblt_operation.vehicle_type = sblt_veh_type.veh_type_id where sblt_booking.status = '1' and sblt_booking.booking_sts = '2' and (DATE_FORMAT(sblt_operation.from_date, '%Y-%m-%d') BETWEEN '$start_date' and '$end_date' or DATE_FORMAT(sblt_operation.to_date, '%Y-%m-%d') BETWEEN '$start_date' and '$end_date') group by veh_type ");
$book_row = $book_qry->result_array();
$tot = 0;
foreach ($book_row as $key => $value) {
$tot = $value['tot'];
$veh_type = $value['veh_type'];
$tr_line .="<tr>
<td style ='color:#00000 !important;text-align:center !important;'>$veh_type</td>
<td style ='color:#00000 !important;text-align:center !important;'>$tot</td></tr>";
}
echo "<table id='detail_list' class='table table-hover table-striped col-style'>
<thead>
<tr><h5 style='font-weight:bold;text-align:center !important;'>$start to $end</h5></tr>
<tr style='font-weight:bold;text-align:center !important;background:#3369E6;'>
<th style='text-align:center !important;padding:4px;'>Vehicle Type</th>
<th style='text-align:center !important;padding:4px;'>Count</th>
</tr>
</thead>
<tbody>$tr_line</tbody>
</table>";
}
public function get_value($ids,$cat){
$this->get_value($ids,$cat);
$ids = $row[0]['ids'];
$this->get_value($ids);
}
}
?>