Commit 8f02422d by Jansa Jose

chart

parent 0905fae6
...@@ -33,15 +33,19 @@ class Login_model extends CI_Model { ...@@ -33,15 +33,19 @@ class Login_model extends CI_Model {
$this->db->select('SUM(booking_approve.amount) as sum,ride.departure_date'); $this->db->select('SUM(booking_approve.amount) as sum,ride.departure_date');
$this->db->from('booking_approve'); $this->db->from('booking_approve');
$this->db->join('ride','ride.id = booking_approve.ride_id'); $this->db->join('ride','ride.id = booking_approve.ride_id');
$this->db->where('booking_approve.status','2');
$this->db->group_by('ride.departure_date'); $this->db->group_by('ride.departure_date');
$query = $this->db->get()->result(); $query = $this->db->get()->result();
//echo $this->db->last_query(); //echo $this->db->last_query();
$result = array(); $result = array();
foreach($query as $value){ foreach($query as $value){
$prev_date = date('Y-m-d', strtotime(date('Y-m-d') . ' -7 day'));
$value = (array)$value; $value = (array)$value;
if($value['departure_date'] >= $prev_date){
$sum = ($value['sum'] == null) ? '0' : $value['sum']; $sum = ($value['sum'] == null) ? '0' : $value['sum'];
$result[] = array($value['departure_date'],$sum); $result[] = array($value['departure_date'],$sum);
} }
}
return json_encode($result); return json_encode($result);
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment