Я пытаюсь вставить пользовательские данные пользователя в основную таблицу, а также необходимо сгенерировать счет-фактуру с использованием таблицы счетов-фактур путем изменения статуса в качестве кнопки платного / неоплаченного. но в моем коде возникает проблема, которую я не могу понять. Использовал Mobile_no как внешний ключ и Invoice_no как автоинкремент. Таблица 1 работает нормально, но после вызова таблицы-2 ошибка ocrd.
Модель
// Get user detial by ID
public function get_user_by_id($id){
$query = $this->db->get_where('ci_users', array('id' => $id));
return $result = $query->row_array();
}
//---------------------------------------------------
// Edit user Record
public function edit_user($data, $id){
$this->db->where('id', $id);
$this->db->update('ci_users', $data);
return true;
}
//---------------------------------------------------
// Get User Role/Group
public function get_user_groups(){
$query = $this->db->get('ci_user_groups');
return $result = $query->result_array();
}
// Get voucher detial by Mobiele No
public function get_voucher_by_mobile_no($mobile_no){
$query = $this->db->get_where('voucher', array('mobile_no' => $mobile_no));
return $result = $query->row_array();
}
// Edit voucher Record
public function edit_user_voucher($data, $mobile_no){
$this->db->where('mobile_no', $mobile_no);
$this->db->update('voucher', $data);
return true;
}
Контроллер
public function edit($id = 0){
if($this->input->post('submit')){
$this->form_validation->set_rules('username', 'Username', 'trim|required');
$this->form_validation->set_rules('firstname', 'Firstname', 'trim|required');
$this->form_validation->set_rules('lastname', 'Lastname', 'trim|required');
$this->form_validation->set_rules('email', 'Email', 'trim|valid_email|required');
$this->form_validation->set_rules('mobile_no', 'Number', 'trim|required');
$this->form_validation->set_rules('status', 'Status', 'trim|required');
$this->form_validation->set_rules('address', 'Address', 'trim');
$this->form_validation->set_rules('group', 'Group', 'trim|required');
if ($this->form_validation->run() == FALSE) {
$data['user'] = $this->user_working->get_user_by_id($id);
$data['user_groups'] = $this->user_working->get_user_groups();
$data['view'] = 'user/users/user_edit';
$this->load->view('layout', $data);
}
else{
$data = array(
'referred_by_id' => $this->session->userdata('referred_by_id'),
'name' => $this->session->userdata('sponcer_name'),
'username' => $this->input->post('username'),
'firstname' => $this->input->post('firstname'),
'lastname' => $this->input->post('lastname'),
'email' => $this->input->post('email'),
'mobile_no' => $this->input->post('mobile_no'),
'password' => password_hash($this->input->post('password'), PASSWORD_BCRYPT),
'role' => $this->input->post('group'),
'address' => $this->input->post('address'),
'is_active' => $this->input->post('status'),
'updated_at' => date('Y-m-d : h:m:s'),
);
$data = $this->security->xss_clean($data);
$result = $this->user_working->edit_user($data, $id);
if($result){
$this->session->set_flashdata('msg', 'User has been updated successfully!');
redirect(base_url('user/users'));
}
}
}
else{
$data['user'] = $this->user_working->get_user_by_id($id);
$data['user_groups'] = $this->user_working->get_user_groups();
$data['view'] = 'user/users/user_edit';
$this->load->view('layout', $data);
}
}
//-----------------------------------------------------------------------
public function del($id = 0){
$this->db->delete('ci_users', array('id' => $id));
$this->session->set_flashdata('msg', 'Use has been deleted successfully!');
redirect(base_url('user/users'));
}