public function designation_form($id = '')
{
$data['title'] = display('add_designation');
#-------------------------------#
$this->form_validation->set_rules('designation',display('designation'),'required|max_length[200]');
$this->form_validation->set_rules('details', display('details') ,'max_length[250]');
#-------------------------------#
$data['designation'] = (object)$postData = [
'id' => $id,
'designation' => $this->input->post('designation',true),
'details' => $this->input->post('details',true),
];
#-------------------------------#
if ($this->form_validation->run()) {
#if empty $id then insert data
if (empty($id)) {
if ($this->hrm_model->create_designation($postData)) {
#set success message
$this->session->set_flashdata('message', display('save_successfully'));
} else {
$this->session->set_flashdata('exception', display('please_try_again'));
}
redirect("designation_list");
} else {
if ($this->hrm_model->update_designation($postData)) {
$this->session->set_flashdata('message', display('update_successfully'));
} else {
$this->session->set_flashdata('exception', display('please_try_again'));
}
redirect("designation_list");
}
} else {
if(!empty($id)){
$data['title'] = display('designation_update_form');
$data['designation'] = $this->hrm_model->single_designation_data($id);
}
$data['module'] = "hrm";
$data['page'] = "hrm/designation_form";
echo Modules::run('template/layout', $data);
}
}