コード例 #1
0
 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ý học hàm - ' . $translate->_('TEXT_DEFAULT_TITLE');
     $this->view->headTitle($this->view->title);
     $hochamModel = new Front_Model_Hocham();
     $error_message = array();
     $success_message = '';
     if ($this->_request->isPost()) {
         $hh_name = trim($this->_arrParam['hh_name']);
         $hh_order = trim($this->_arrParam['hh_order']);
         $hh_status = $this->_arrParam['hh_status'];
         $validator_length = new Zend_Validate_StringLength(array('min' => 2, 'max' => 100));
         if (!is_numeric($hh_order)) {
             $hh_order = 0;
         }
         //kiem tra dữ liệu
         if (!$validator_length->isValid($hh_name)) {
             $error_message[] = 'Tên học hàm 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()');
             $hochamModel->insert(array('hh_name' => $hh_name, 'hh_status' => $hh_status, 'hh_order' => $hh_order, 'hh_date_added' => $current_time, 'hh_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;
 }