public function setInputData($data = null) { $shortage_ids = explode('_', $data['shortage_ids']); $shortage_ids = arr_val_del(0, $shortage_ids); $this->setShortageIds($shortage_ids); $this->setCommitDate($data['commit_date']); $this->setCreditAgentType($data['agent_type']); $this->setCreditAgent($data['agent_id']); }
public function _validate_shortage_ids_for_commiting($value) { $shortage_ids = explode('_', $value); $shortage_ids = arr_val_del(0, $shortage_ids); //checking if there is atleast one id selected if (sizeof($shortage_ids) == 0) { $this->form_validation->set_message('_validate_shortage_ids_for_commiting', 'Please select atleast one shortage.'); return false; } //checking if the ids are all integers. foreach ($shortage_ids as $id) { if (ctype_digit($id) == false) { $this->form_validation->set_message('_validate_shortage_ids_for_commiting', 'Invalid shortage ids.'); return false; } } //checking if there is already a voucher of given shortage ids $this->db->select('shortage_id'); $this->db->where_in('voucher_journal.shortage_id', $shortage_ids); $this->db->where('voucher_journal.active', 1); $result = $this->db->get('voucher_journal')->result(); if (sizeof($result) > 0) { $this->form_validation->set_message('_validate_shortage_ids_for_commiting', 'Some shortages (' . join(', ', property_to_array('shortage_id', $result)) . ') have already been commited. please try again.'); return false; } //checking if shortage ids are there in the shortage table.. $this->db->select('id'); $this->db->distinct(); $this->db->where_in('id', $shortage_ids); $result = $this->db->get('shortages')->result(); if (sizeof($result) != sizeof($shortage_ids)) { $this->form_validation->set_message('_validate_shortage_ids_for_commiting', 'Some shortages have been deleted from the system. please try again.'); return false; } return true; }