1$this->form_validation->set_rules('order_no', 'Order no', 'required|callback_check_order_no');
2
1function check_unique_order_no($id = '', $order_no) {
2 $this->db->where('order_no', $order_no);
3 $this->db->where('status', "A");
4
5 if($id) {
6 $this->db->where_not_in('id', $id);
7 }
8 return $this->db->get('delivery_order')->num_rows();
9 }
10
1function check_order_no($order_no) {
2 if($this->input->post('id'))
3 $id = $this->input->post('id');
4 else
5 $id = '';
6 $result = $this->Data_model->check_unique_order_no($id, $order_no);
7 if($result == 0)
8 $response = true;
9 else {
10 $this->form_validation->set_message('check_order_no', 'Order no already exist');
11 $response = false;
12 }
13 return $response;
14 }
15