public function addAction() { $layoutPath = APPLICATION_PATH . '/templates/' . TEMPLATE_USED; $option = array('layout' => 'hethong/layout', 'layoutPath' => $layoutPath); Zend_Layout::startMvc($option); $translate = Zend_Registry::get('Zend_Translate'); $this->view->title = 'Quản lý bằng cấp - ' . $translate->_('TEXT_DEFAULT_TITLE'); $this->view->headTitle($this->view->title); $bangcapModel = new Front_Model_Bangcap(); $error_message = array(); $success_message = ''; if ($this->_request->isPost()) { $bc_name = trim($this->_arrParam['bc_name']); $bc_order = trim($this->_arrParam['bc_order']); $bc_status = $this->_arrParam['bc_status']; $validator_length = new Zend_Validate_StringLength(array('min' => 2, 'max' => 100)); if (!is_numeric($bc_order)) { $bc_order = 0; } //kiem tra dữ liệu if (!$validator_length->isValid($bc_name)) { $error_message[] = 'Tên bằng cấp phải bằng hoặc hơn 2 ký tự và nhỏ hơn hoặc bằng 100 ký tự.'; } if (!sizeof($error_message)) { $current_time = new Zend_Db_Expr('NOW()'); $bangcapModel->insert(array('bc_name' => $bc_name, 'bc_status' => $bc_status, 'bc_order' => $bc_order, 'bc_date_added' => $current_time, 'bc_date_modified' => $current_time)); $success_message = 'Đã thêm mới thành công.'; } } $this->view->success_message = $success_message; $this->view->error_message = $error_message; }