Example #1
0
 public function dang_ky_hen_kham_submit()
 {
     if (!$this->input->post('btn_gui')) {
         $_SESSION['err'] = "Không hợp lệ!";
         $err = "Không hợp lệ!";
         $file = fopen("err.txt", "w+");
         fwrite($file, $err);
         fclose($file);
         header('Location:./dang-ky-lich-hen-kham.html');
         exit;
     }
     // Kiem tra rong
     if (!$this->input->post('txt_hoten1') || !$this->input->post('datepicker_ngaysinh1') || !$this->input->post('txt_dienthoai1') || !$this->input->post('datepicker_ngaykham1') || !$this->input->post('txt_giokham1') || !$this->input->post('txt_noidungkham1') || !$this->input->post('txt_email1')) {
         $_SESSION['err'] = "<p class='p_info'>Vui lòng nhập đầy đủ thông tin</p>";
         $err = "<p class='p_info'>Vui lòng nhập đầy đủ thông tin</p>";
         $file = fopen("err.txt", "w+");
         fwrite($file, $err);
         fclose($file);
         header('Location:./dang-ky-lich-hen-kham.html');
         exit;
     }
     $HoTen = $this->input->post('txt_hoten1');
     $GioiTinh = $this->input->post('ra_gioitinh1');
     $NgaySinh = $this->input->post('datepicker_ngaysinh1');
     $DienThoai = $this->input->post('txt_dienthoai1');
     $NgayKham = $this->input->post('datepicker_ngaykham1');
     $GioKham = $this->input->post('txt_giokham1');
     $NoiDung = $this->input->post('txt_noidungkham1');
     $Email = $this->input->post('txt_email1');
     if ($GioKham < 8 || $GioKham > 19) {
         $err = "<p class='p_err'>Vui lòng nhập giờ hẹn trong khoảng 8h đến 19h{$GioKham}</p>";
         $file = fopen("err.txt", "w+");
         fwrite($file, $err);
         fclose($file);
         header('Location:./dang-ky-lich-hen-kham.html');
         exit;
     }
     $support = new SupportDB();
     $result = $support->LuuSupport_DatHenKham($HoTen, $GioiTinh, $NgaySinh, $DienThoai, $Email, $NgayKham, $NoiDung, $GioKham);
     if ($result == 0) {
         $_SESSION['err'] = "<p class='p_err'>Lỗi trong quá trình xử lý</p>";
         $err = "<p class='p_err'>Lỗi trong quá trình xử lý</p>";
         $file = fopen("err.txt", "w+");
         fwrite($file, $err);
         fclose($file);
         header('Location:./dang-ky-lich-hen-kham.html');
         exit;
     } else {
         $_SESSION['err'] = "<p class='p_info p_success'>Đăng ký thành công<br>Chúng tôi sẽ liên hệ với bạn ngay bây giờ.</p>";
         $err = "<p class='p_info p_success'>Đăng ký thành công<br>Chúng tôi sẽ liên hệ với bạn ngay bây giờ.</p>";
         $file = fopen("err.txt", "w+");
         fwrite($file, $err);
         fclose($file);
         header('Location:./dang-ky-lich-hen-kham.html');
         exit;
     }
 }
 public function Dat_hen_kham()
 {
     session_start();
     $postDB = new PostDB();
     $catDB = new CatalogDB();
     $spDB = new SupportDB();
     $catList = $catDB->getAllCategory();
     $catMenu = $catList->getCatalogParent();
     $catList = $catDB->getAllCategory();
     $catMenu = $catList->getCatalogParent();
     $postTopRead = $postDB->getTopPopularRead(5);
     $breadcum = "<a href='" . base_url() . "dat-hen-kham.html'>Đặt hẹn</a>";
     $btnGui = $this->input->post('btnGui');
     if ($btnGui) {
         $sp = new SupportClass();
         $sp->setHoTen($this->input->post('hoten'));
         $sp->setGioiTinh($this->input->post('gioitinh'));
         $sp->setTuoi($this->input->post('ngaysinh'));
         $sp->setDienThoai($this->input->post('dienthoai'));
         $sp->setEmail($this->input->post('email'));
         $sp->setNgayKham($this->input->post('ngaykham'));
         $sp->setGioKham($this->input->post('giokham'));
         $sp->setNoiDung($this->input->post('tinhtrang'));
         $kq = $spDB->Insert_support($sp);
         $message = '';
         if ($kq) {
             $message = 'success';
             $data = array("breadcum" => $breadcum, "CatMenu" => $catMenu, "catList" => $catList, 'message' => $message, 'postTopRead' => $postTopRead->getList());
             $data['catDB'] = $catDB;
             $data['menu'] = $this->CatalogDB->showMenu();
             $this->load->view('dat-hen/dat-hen-xu-ly', $data);
         } else {
             $message = 'failed';
             $data = array("breadcum" => $breadcum, "CatMenu" => $catMenu, "catList" => $catList, 'message' => $message, 'postTopRead' => $postTopRead->getList());
             $data['catDB'] = $catDB;
             $data['menu'] = $this->CatalogDB->showMenu();
             $this->load->view('dat-hen/dat-hen-kham', $data);
         }
     } else {
         $message = 'failed';
         $data = array("breadcum" => $breadcum, "CatMenu" => $catMenu, "catList" => $catList, 'message' => $message, 'postTopRead' => $postTopRead->getList());
         $data['catDB'] = $catDB;
         $data['err'] = '';
         $data['menu'] = $this->CatalogDB->showMenu();
         $this->load->view('dat-hen/dat-hen-kham', $data);
     }
 }