Here i want to get the sum of balance of selected customer_id.for example here the customer_id of 19 is having an sum of 120 but the result is not fetching. here is my controler
public function make_payment()
{
$data['active_mn']='';
$data['active_mn']='';
$data['result']=$this->Account_model->view_order_id($code);
$customer_id=$this->input->post('customer_id');
$data['details'] = $this->Account_model->order_details($customer_id)->row();
$this->load->view('make_payment',$data);
}
This is my model
public function order_details($customer_id)
{
$this->db->join('payment','payment.order_id=services.id');
$this->db->select('services.*,payment.balance,payment.actual_amount,payment.customer_id');
//$this->db->select_sum('payment.balance');
$this->db->order_by('payment.id','desc');
$query = $this->db->get_where('services',array('customer_id' => $customer_id));
retu $query;
}
this is my payment table..
id order_id customer_id actual_amount paid_amount balance type
5 9 19 650.00 600.00 50.00 Cash
6 8 35 600.00 500.00 0.00 Cash
7 7 15 750.00 750.00 0.00 Cash
8 5 16 800.00 400.00 400.00 Cash
9 4 35 400.00 300.00 100.00 Cash
10 3 19 500.00 450.00 50.00 Cash
11 2 15 100.00 100.00 0.00 Cash
12 1 16 1200.00 1000.00 200.00 Cash
18 10 19 100.00 80.00 20.00 Cash
this is my services table
id code customer_id estimated_amount
1 ORD00001 16 100
2 ORD00002 15 324
3 ORD00003 19 11
4 ORD00004 35 54
5 ORD00005 16 400
7 ORD00007 15 555
8 ORD00008 35 12
