public function suaAction() { $form = new Admin_Form_HocVi(); $form->removeElement('submitCon'); $form->submitExit->setLabel('Lưu'); $form->cancel->setLabel('Không lưu'); $this->view->form = $form; if ($this->getRequest()->isPost()) { $formData = $this->getRequest()->getPost(); if ($form->isValid($formData)) { if ($this->hoc_vi->kiem_tra_id_ma($form->getValue('id'), $form->getValue('ma'))) { $_SESSION['msg'] = 'Lỗi !. Mã học vị đã tồn tại, vui lòng kiểm tra lại .'; $_SESSION['type_msg'] = 'error'; $this->_redirect('/admin/hoc-vi/index'); } $hoc_vi = new Default_Model_HocVi(); $hoc_vi->setId($form->getValue('id')); $hoc_vi->setMa($form->getValue('ma')); $hoc_vi->setTen($form->getValue('ten')); $hoc_vi->setGhiChu($form->getValue('ghi_chu')); $kq = $hoc_vi->sua(); if (!kq) { $_SESSION['msg'] = 'Lỗi !. Đã có lỗi trong quá trình xử lý, vui lòng thử lại .'; $_SESSION['type_msg'] = 'error'; $this->_redirect('/admin/hoc-vi/index'); } $_SESSION['msg'] = 'Thành công !. Dữ liệu đã được cập nhật .'; $_SESSION['type_msg'] = 'success'; $this->_redirect('/admin/hoc-vi/index'); } else { $form->populate($formData); } } else { $id = $this->_getParam('id'); if (!empty($id)) { $data = $this->hoc_vi->getHocVi($id); if ($data != null) { $data = $this->hoc_vi->HocViToArray($data); $form->populate($data); } else { $_SESSION['msg'] = 'Lỗi !. Mã học vị không tồn tại .'; $_SESSION['type_msg'] = 'error'; $this->_redirect('/admin/hoc-vi/index'); } } else { $this->_redirect('/admin/hoc-vi/index'); } } }