Problem:
I just want to update the bill by using unique id in my database but my problem is it showing the error as undefined index id..help me to resolve this error...
Controller Code:
public function Bill_Edit()
{
$session_data = $this->session->userdata('logged_in');
$data['username'] = $session_data['username'];
$query = $this->db->get('parmaster');
$data['PName']=$query->result_array();
$data['r'] = $this->User_model->Bill_Edit1();
$data['result'] =$this->User_model->Bill_Edit();
$this->load->view('Inventory/Bill_Edit',$data);
}
Model Code:
public function Bill_Edit()
{
$Search = $this->input->post('Search');
$this->db->where('billno', $Search);
$this->db->select('*');
$this->db->from('salesitem');
$this->db->join('salesbill', 'salesbill.no = salesitem.billno','left outer');
$query = $this->db->get()->result_array();
return $query;
}
public function Bill_Edit1()
{
$Search = $this->input->post('Search');
$this->db->where('billno', $Search);
$this->db->select('*');
$this->db->from('salesitem');
$this->db->join('salesbill', 'salesbill.no = salesitem.billno','left outer');
$query = $this->db->get()->row();
return $query;
}
Below i have attached the error of my screenshot..Help me to fix this error
Update batch code:
public function Bill_Update($data)
{
$LDate = $this->input->post('TDate');
$date = str_replace('/', '-', $LDate);
$newDate = date("Y-m-d", strtotime($date));
$id =$this->input->post('billid');
$billno = $this->input->post("billno");
$data = $this->input->post();
$count = count($data['Product_Code']);
for($i = 0; $i<$count; $i++){
$entries[] = array(
'Id' => $data['billId'][$i],
'Product_Code'=>$data['Product_Code'][$i],
'Prdtname'=>$data['Prdtname'][$i],
'Qty'=>$data['Qty'][$i],
'rate'=>$data['rate'][$i],
'billdate'=>$newDate,
'amount'=>$data['amount'][$i]
);
}
$this->db->where('Id',$id);
$this->db->update_batch('salesitem', $entries,'Id');
