public function action_delete($id = null) { if ($staff_department = Model_Staff_Department::find($id)) { $staff_department->delete(); Session::set_flash('success', 'Deleted staff_department #' . $id); } else { Session::set_flash('error', 'Could not delete staff_department #' . $id); } Response::redirect('staff/department'); }
public function action_edit($id = null) { is_null($id) and Response::redirect('Staff'); $staff = Model_Staff::find($id); $val = Model_Staff::validate('edit'); if ($val->run()) { $staff->first_name = Input::post('first_name'); $staff->last_name = Input::post('last_name'); $staff->intranet_id = Input::post('intranet_id'); $staff->dialler_id = Input::post('dialler_id'); $staff->debtsolv_id = Input::post('debtsolv_id'); $staff->network_id = Input::post('network_id'); $staff->center_id = Input::post('center_id'); $staff->department_id = Input::post('department_id'); $staff->active = Input::post('active'); if ($staff->save()) { Session::set_flash('success', 'Updated staff #' . $id); Response::redirect('staff'); } else { Session::set_flash('error', 'Could not update staff #' . $id); } } else { if (Input::method() == 'POST') { $staff->first_name = $val->validated('first_name'); $staff->last_name = $val->validated('last_name'); $staff->intranet_id = $val->validated('intranet_id'); $staff->dialler_id = $val->validated('dialler_id'); $staff->debtsolv_id = $val->validated('debtsolv_id'); $staff->network_id = $val->validated('network_id'); $staff->center_id = $val->validated('center_id'); $staff->department_id = $val->validated('department_id'); $staff->active = $val->validated('active'); Session::set_flash('error', $val->error()); } $this->template->set_global('staff', $staff, false); } $departments = Model_Staff_Department::find('all'); $centers = Model_Call_Center::find('all'); $this->template->set_global('departments', $departments, false); $this->template->set_global('centers', $centers, false); $this->template->title = "Staffs"; $this->template->content = View::forge('staff/edit'); }