Example #1
0
 public function themSuaDatVeAction()
 {
     $this->view->headTitle("Thêm - Sửa đặt vé");
     $pk = $this->_request->getParam("pk", "");
     $m_datve = new Default_Model_Datve();
     if ($pk != "") {
         $kq_datve = $m_datve->getWhereDatVe($pk);
         $this->view->kq_datve = $kq_datve;
     }
     if ($this->_request->isPost()) {
         $params = $this->_request->getParams();
         $pk = $params['pk'];
         if ($params['date'] != "" && $params['phone'] != "" && $params['content'] != "") {
             if ($pk == "") {
                 if ($m_datve->insertDatVe($params)) {
                     echo "<script>\n                            alert('Thêm thành công');\n                            location.href ='/public/dat-ve/';\n                        </script>";
                 } else {
                     echo "<script>alert('Thêm thất bại')</script>";
                 }
             } else {
                 if ($m_datve->updateDatVe($params)) {
                     echo "<script>\n                            alert('Cập nhật thành công');\n                            location.href ='/public/dat-ve/';\n                        </script>";
                 } else {
                     echo "<script>alert('Cập nhật thất bại')</script>";
                 }
             }
         } else {
             echo "<script>alert('Xin vui lòng điền đủ thông tin');</script>";
         }
     }
 }