}
 } else {
     $like = "Like";
 }
 $funcDanhGiaSP = 'funcDanhGiaSP("' . $sanPham->Ma . '", "' . $_SESSION['IdUser'] . '","kq_danhgia_sp", "ChiTietSP")';
 /***************************************************/
 $gInfo = "<div class='product-image'>\r\n            <img src='{$sanPham->HinhAnh}' width='200' height='167' /><br />\r\n            <a href=''> Xem hình phóng to </a>\r\n        </div>\r\n        <div class='info'>                    \t\r\n            <div class='name'>{$sanPham->TenSanPham}</div>\r\n            <div class='new-price' >{$donGiaBan} VND\r\n\t\t\t\t<input type='hidden' id= 'idDonGiaBan' value='{$sanPham->DonGiaBan}'/>\r\n\t\t\t</div>\r\n            <div class='old-price'>{$donGiaGoc} VND</div>                        \r\n            <div class='views'>{$sanPham->LuotXem} lượt xem</div>                           \r\n            <div class='stars' id='kq_danhgia_sp' >                       \t\t\r\n                {$soSao} sao | \r\n\t\t\t\t<span class='text-color-bold-1' id='btnDanhGiaSP' style='cursor:pointer;'>Đánh giá</span>\r\n            </div>\t\t\t\t\r\n            <div class='time-upload'>\r\n\t\t\t\tĐăng bởi <a href='trang_ca_nhan.php' > {$nguoiUpSP->UserName} </a> lúc {$ngayDangSP}\r\n\t\t\t</div>\r\n        </div>\r\n        <!--end .info-->";
 /***************************************************/
 // add cart
 $gAddCart = "\r\n\t\t<div class='add-cart'>\t\r\n\t\t\t<h2>Đặt mua</h2>\r\n\t\t\t\t<div class='line'>\r\n\t\t\t\t\t<label for='txtSoLuongSPThemVaoSoGio'>Số lượng:</label><input name='txtSoLuongSPThemVaoSoGio' id='txtSoLuongSPThemVaoSoGio' type='text' size='10' style='text-align:right;' onchange='updateThanhTien(this.id)' />                    \r\n\t\t\t\t\t<input type='hidden' id='hidMaSanPham' name= 'hidMaSanPham' value='{$maSanPham}'/>\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class='line'>\r\n\t\t\t\t\t<label>Thành tiền: <span class='new-price'><span id='idThanhTien'>0</span> VND </span></label>\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class='line'>\r\n\t\t\t\t\t<input name='btnThemVaoGioHang' type='submit' class='button ui-state-default ui-button-text-icon-primary' value='Thêm vào giỏ hàng' onclick='funcThemVaoGioHang()' />                                   \r\n\t\t\t\t</div>\t\t\t\r\n        </div>\r\n        <!--end .add-cart-->";
 /***************************************************/
 //thông tin chi tiết
 $gInfoDetail = "<div class='content'>{$sanPham->DacDiemSP}</div>\r\n        <!--end .content-->";
 /***************************************************/
 // BÌNH LUẬN SẢN PHẨM
 $lstBinhLuan = BinhLuanDAO::LayDSBL_TheoMaDoiTuong($maSanPham, 0);
 $gSoBinhLuan = count($lstBinhLuan);
 if ($_SESSION['IsLogin'] == 0) {
     $gBinhLuan = "Bạn phải đăng nhập mới được quyền xem bình luận";
 } else {
     $nguoiDung = NguoiDungDAO::LayThongTinNguoiDungTheoMa($_SESSION['IdUser']);
     // ds các bình luận
     if ($gSoBinhLuan > 0) {
         foreach ($lstBinhLuan as $binhLuanDto) {
             $nguoiDungBL = NguoiDungDAO::LayThongTinNguoiDungTheoMa($binhLuanDto->NguoiBL);
             $thoiGianBL = date_create($binhLuanDto->NgayBL);
             $gioBL = $thoiGianBL->format('H:i');
             $ngayBL = $thoiGianBL->format('d-m-Y');
             $dsLikes = LikesDAO::LayDanhSachLikesTheoMaDoiTuong($binhLuanDto->MaBL);
             $soNguoiLike = count($dsLikes);
             $nguoiDungLikeBL = LikesDAO::LayDanhSachLikesTheoMaDT_MaNguoiDung($binhLuanDto->MaBL, $nguoiDung->MaNguoiDung);
<?php

require_once '../class/BinhLuanDAO.php';
$maBL = $_REQUEST['maBinhLuan'];
$bl = BinhLuanDAO::LayBinhLuanTheoMaBL($maBL);
$res = BinhLuanDAO::XoaBL($maBL);
if (!$res) {
    return;
} else {
    $lstBL = BinhLuanDAO::LayDSBL_TheoMaDoiTuong($bl->DoiTuongBL);
    $soluong = count($lstBL);
    echo $soluong;
}
 $noiDungBL = $_REQUEST['noiDungBL'];
 $nguoiBL = NguoiDungDAO::LayThongTinNguoiDungTheoMa($_REQUEST['user']);
 // tạo đối tượng
 $maBL = DoiTuongDAO::ThemDoiTuong('Binh luan');
 if ($maBL > 0) {
     // nếu tạo tối tượng thành công --> thêm bình luận
     $binhLuan = new BinhLuanDTO();
     $binhLuan->MaBL = $maBL;
     $binhLuan->NoiDungBL = $noiDungBL;
     $binhLuan->NguoiBL = $nguoiBL->MaNguoiDung;
     $binhLuan->DaXoa = 0;
     $binhLuan->DoiTuongBL = $maDoiTuong;
     $binhLuan->NgayBL = date('Y-m-d');
     if (BinhLuanDAO::ThemBL($binhLuan)) {
         // nếu thêm thành công
         $binhLuanDto = BinhLuanDAO::LayBinhLuanTheoMaBL($maBL);
         $thoiGianBL = date_create($binhLuanDto->NgayBL);
         $gioBL = $thoiGianBL->format('H:i');
         $ngayBL = $thoiGianBL->format('d-m-Y');
         $soNguoiLike = 0;
         if ($_REQUEST['page'] == "BinhLuan_SP") {
             $idKQ_Like_BL = "kq_like_binhluan_sp_" . $binhLuanDto->MaBL;
             $funcLikeBL = "funcLike('" . $binhLuanDto->MaBL . "','" . $nguoiBL->MaNguoiDung . "','" . $idKQ_Like_BL . "','BinhLuanSP')";
         }
         if ($_REQUEST['page'] == "BinhLuan_SK") {
             $idKQ_Like_BL = "kq_like_binhluan_sk_" . $binhLuanDto->MaBL;
             $funcLikeBL = "funcLike('" . $binhLuanDto->MaBL . "','" . $nguoiBL->MaNguoiDung . "','" . $idKQ_Like_BL . "','BinhLuanSP')";
         }
         echo "\t\t\t\t\r\n\t\t\t\t<div class='comment-wrapper'>                       \t  \t\r\n\t\t\t\t\t<div class='avatar'><img src='{$nguoiBL->AnhDaiDien}' width='1280' height='1024' /></div>\r\n\t\t\t\t\t<div class='content'>\r\n\t\t\t\t\t\t <div class='title-comment'>\r\n\t\t\t\t\t\t\t<span class='text-color-normal-1'>\r\n\t\t\t\t\t\t\t\t<a href='trang_ca_nhan.php?id={$nguoiBL->MaNguoiDung}'>" . $nguoiBL->UserName . "</a>\r\n\t\t\t\t\t\t\t</span> bình luận lúc {$gioBL} ngày {$ngayBL}.\r\n\t\t\t\t\t\t </div>\r\n\t\t\t\t\t\t <div class='primary-comment'>\r\n\t\t\t\t\t\t\t\t{$binhLuanDto->NoiDungBL}\r\n\t\t\t\t\t\t </div>\r\n\t\t\t\t\t\t <div class='action' id='{$idKQ_Like_BL}'>\r\n\t\t\t\t\t\t\t0 người thích <span class='text-color-normal-1 likes' onclick={$funcLikeBL} > Like </span>\r\n\t\t\t\t\t\t </div>\r\n\t\t\t\t\t\t \r\n\t\t\t\t\t</div>                            \r\n\t\t\t\t\t<!--end .content-->\r\n\t\t\t\t\t<div class='button'>\r\n\t\t\t\t\t\t<span class='remove ui-icon ui-icon-close' title='Xóa'>&nbsp;</span>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>\r\n\t\t\t\t<!--end .comment-wrapper-->";
     }
 }
require_once 'class/BinhLuanDAO.php';
require_once 'class/NguoiDungDAO.php';
require_once 'class/LikesDAO.php';
$gChiTietSK = "";
$gBinhLuanSK = "";
$gBinhLuanMoi = "";
if (!isset($_REQUEST['id'])) {
    header("Location:ds_su_kien.php");
} else {
    $suKienDto = SuKienDAO::LaySuKienTheoMaSuKien($_REQUEST['id']);
    if (is_null($suKienDto)) {
        header("Location:ds_su_kien.php?maGianHang=" . $_REQUEST['maGianHang']);
        return;
    } else {
        $gianHangDto = GianHangDAO::LayGianHangTheoMa($suKienDto->MaGianHang, 0);
        $dsBinhLuan = BinhLuanDAO::LayDSBL_TheoMaDoiTuong($suKienDto->MaSuKien, 0);
        $dsLikes = LikesDAO::LayDanhSachLikesTheoMaDoiTuong($suKienDto->MaSuKien);
        $soNguoiThamGia = count($dsLikes);
        $ngayBD = date_create($suKienDto->NgayBatDau);
        $ngayBD = $ngayBD->format('d-m-Y');
        $ngayKT = date_create($suKienDto->NgayKetThuc);
        $ngayKT = $ngayKT->format('d-m-Y');
        $func = "funcXoaSuKien('" . $suKienDto->MaSuKien . "')";
        // nếu chưa tham gia --> hiện nút tham gia
        $nguoiDungThamGiaSK = LikesDAO::LayDanhSachLikesTheoMaDT_MaNguoiDung($suKienDto->MaSuKien, $_SESSION['IdUser']);
        if (is_null($nguoiDungThamGiaSK)) {
            $txtButtonThamGia = "Tham gia sự kiện";
        } else {
            // ngược lại thì không tham gia
            $txtButtonThamGia = "Hủy tham gia sự kiện";
        }