[eluser]reghan[/eluser]
Code:
function add_sys(){
// set common properties
$data['title'] = 'Add New System';
// set common properties
$data['title'] = 'Add a new system';
$data['message'] = '';
$data['action'] = site_url('bia/addSystem');
$data['link_back'] = anchor('bia/systems/','Back to list of systems',array('class'=>'back'));
//load the add system view.
$this->load->view('systemEdit', $data);
}
function addSystem()
{
// set common properties
$data['title'] = 'Add new system';
$data['action'] = site_url('bia/addSystem');
$data['link_back'] = anchor('bia/systems/','Back to list of persons',array('class'=>'back'));
//set validation rules
$this->form_validation->set_rules('sysname', 'System Name', 'required');
$this->form_validation->set_rules('server','Server Name', 'required');
$this->form_validation->set_rules('ha', 'HA','required');
$this->form_validation->set_rules('dr', 'DR','required');
$this->form_validation->set_rules('descrip','Description', 'required');
$this->form_validation->set_rules('class','Class', 'required');
$this->form_validation->set_rules('lowRTO','Lowest RTO', 'required|numeric');
$this->form_validation->set_rules('lowProcess','Lowest RTO Process', 'required');
$this->form_validation->set_rules('lowDept','Lowest RTO Department', 'required');
//set rule messages
$this->form_validation->set_message('required', '* required');
$this->form_validation->set_message('numeric', '* Must be numeric');
if ($this->form_validation->run() == FALSE)
{
$data['message'] = validation_errors();
}
else
{
// save data
$system = array('SystemName' => $this->input->post('sysname'),
'Servers' => $this->input->post('server'),
'HA' => $this->input->post('ha'),
'DR' => $this->input->post('dr'),
'Desc' => $this->input->post('descrip'),
'Class' => $this->input->post('class'),
'LowestRTO' => $this->input->post('lowRTO'),
'LowestRTOProcess' => $this->input->post('lowProcess'),
'LowestRTODept' => $this->input->post('lowDept'));
$this->department_model->saveSystem($system);
// set user message
$data['message'] = '<div class="success">add new person success</div>';
}
// load view
$this->load->view('systemEdit', $data);
}