/***************************************************/
 // 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);
             $idKQ_Like_BL = "kq_like_binhluan_sp_" . $binhLuanDto->MaBL;
             $funcLikeBL = "funcLike('" . $binhLuanDto->MaBL . "','" . $nguoiDung->MaNguoiDung . "','" . $idKQ_Like_BL . "','BinhLuanSP')";
             if (is_null($nguoiDungLikeBL)) {
                 $txtLikeBL = "Like";
             } else {
                 $txtLikeBL = "Unlike";
             }
             $gBinhLuan .= "\r\n\t\t\t\t<div class='comment-wrapper'>                       \t  \t\r\n\t\t\t\t\t<div class='avatar'><img src='{$nguoiDungBL->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={$nguoiDungBL->MaNguoiDung}'>" . $nguoiDungBL->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='kq_like_binhluan_sp_{$binhLuanDto->MaBL}'>\r\n\t\t\t\t\t\t\t{$soNguoiLike} người thích <span class='text-color-normal-1 likes' onclick={$funcLikeBL} >{$txtLikeBL}</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-->";
         }
     }
     // bình luận mới
     $funcThemBinhLuan = 'funcThemBinhLuan("txtNoiDungBL_SP", "' . $sanPham->Ma . '", "' . $_SESSION['IdUser'] . '","kq_binhluan_sp", "BinhLuan_SP")';
     $gBinhLuanMoi = "\r\n\t\t<div id='kq_binhluan_sp'>\r\n\t\t</div>\r\n\t\t<div class='comment-wrapper'>                       \t  \t\r\n\t\t\t<div class='avatar'><img src='{$nguoiDung->AnhDaiDien}' width='1280' height='1024' /></div>\r\n\t\t\t<div class='content'>\r\n\t\t\t\t<div class='title-comment'>\r\n\t\t\t\t\t<span class='text-color-normal-1'>\r\n\t\t\t\t\t\t<a href='trang_ca_nhan.php?id={$nguoiDung->MaNguoiDung}'>" . $_SESSION['UserName'] . "</a>\r\n\t\t\t\t\t</span>\r\n\t\t\t\t</div>\r\n\t\t\t\t\t<textarea name='txtNoiDungBL_SP' id= 'txtNoiDungBL_SP' cols='80' rows='5'></textarea><br /> \r\n\t\t\t\t\t<input name='btnBinhLuan' type='button' value='Bình luận' class='ui-state-default ui-state-hover ui-button-text-only' onclick='" . $funcThemBinhLuan . "' />\r\n\t\t\t\t </form>\r\n\t\t\t</div>                            \r\n\t\t\t<!--end .content-->                           \r\n\t\t</div>\r\n\t\t<!--end .comment-wrapper || đăng bình luận-->";
    $txtButtnThamGia = "";
    if (is_null($nguoiDungThamGia)) {
        // thêm likes
        $likeDto = new LikesDTO();
        $likeDto->MaDoiTuong = $id;
        $likeDto->MaNguoiDung = $user;
        $likeDto->SoSao = '0';
        $res = LikesDAO::ThemLike($likeDto);
        $txtButtnThamGia = "Hủy tham gia sự kiện";
    } else {
        //Xóa likes
        $res = LikesDAO::XoaLike($id, $user);
        $txtButtnThamGia = "Tham gia sự kiện";
    }
    if ($res) {
        // lấy ds likes
        $dsLikes = LikesDAO::LayDanhSachLikesTheoMaDoiTuong($id);
        $soNguoiThamGia = count($dsLikes);
        // kết quả trả về
        if ($_REQUEST['page'] === 'chitietSK') {
            $funcThamGia = "funcThamGiaSuKien('" . $id . "', '" . $user . "','chitietSK')";
            $strRes = '<td>' . $soNguoiThamGia . ' người đã tham gia  </td>                    	
							  <td>
							  	<span style="text-align:right;cursor:pointer;">
									<span onclick="' . $funcThamGia . '"  class="text-color-bold-1" >' . $txtButtnThamGia . '</span>
								</span>
							</td>';
        }
    }
    echo $strRes;
}
<div class="top-shop">
    <div class="top-shop-wrapper">       	  
	  <?php 
require_once 'class/GianHangDAO.php';
require_once 'class/SanPhamDAO.php';
require_once 'class/LikesDAO.php';
$dsGianHang = GianHangDAO::LayTatCaGianHangTheoNgayTao(8);
if (count($dsGianHang) == 0 || is_null($dsGianHang)) {
    $topShop = "<p><br>Chưa có gian hàng nào được tạo.<p>";
} else {
    $gianHangViewCaoNhat = $dsGianHang[0];
    $dsLikeGianHang = LikesDAO::LayDanhSachLikesTheoMaDoiTuong($gianHangViewCaoNhat->MaGianHang);
    $soNguoiLikeGH = count($dsLikeGianHang);
    $topShop = "\r\n\t\t  \t\t<div class='top-shop-image'>\r\n\t\t  \t\t<a href='#'><img src='{$gianHangViewCaoNhat->Theme}' width='300' height='250' /></a>\r\n\t\t\t\t</div>\r\n\t\t\t  <!--end .top-shop-image-->\r\n\t\t\t  <div class='top-shop-info'>\r\n\t\t\t\t<div class='top-shop-info-line'>\r\n\t\t\t\t\t<div class='name'>\r\n\t\t\t\t\t\t<a href='gian_hang.php?maGianHang={$gianHangViewCaoNhat->MaGianHang}'>\r\n\t\t\t\t\t\t\t{$gianHangViewCaoNhat->TenGianHang}\r\n\t\t\t\t\t\t</a>\r\n\t\t\t\t\t</div>           \t\t\r\n\t\t\t\t</div>\r\n\t\t\t\t<!--end .top-shop-info-line || name-->\r\n\t\t\t\t<div class='top-shop-info-line'>            \t\r\n\t\t\t\t\t<div class='slogan'>Content for  class 'top-shop-slogan' Goes Here Content for  class 'top-shop-slogan' Goes Here \r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>\r\n\t\t\t\t<!--end .top-shop-info-line | slogan--> \r\n\t\t\t\t<div class='top-shop-info-line'>            \t\r\n\t\t\t\t\t<div class='views'>{$gianHangViewCaoNhat->LuotXem} lượt xem </div>\r\n\t\t\t\t\t\r\n\t\t\t\t\t<div class='likes'>\r\n\t\t\t\t\t\t<a href='#'><img src='image/add_to_favorites_24.png' width='24' height='24' /></a>\r\n\t\t\t\t\t\t{$soNguoiLikeGH} bình chọn\r\n\t\t\t\t\t</div>               \r\n\t\t\t\t</div>\r\n            <!--end .top-shop-info-line | view - bình chọn--> \r\n\t\t\t<div class='top-shop-info-line'>  \r\n            \t<div class='recieve-email'>\r\n                \t<a href='#'><img src='image/yellow_mail_receive_24.png' width='24' height='24'/>\r\n\t\t\t\t\tĐăng ký nhận email</a>\r\n                </div>\t\t\t\t\r\n            </div>\r\n            <!--end .top-shop-info-line || subcribe-->     \r\n\t\t\t<div class='top-shop-info-line'>            \t\r\n\t\t\t\t\t<div class='view-shop'>\r\n\t\t\t\t\t\t<a href='gian_hang.php?maGianHang={$gianHangViewCaoNhat->MaGianHang}'>\r\n\t\t\t\t\t\t\tXem chi tiết >>\r\n\t\t\t\t\t\t</a>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>            \r\n\t\t\t\t<!--end .top-shop-info-line | xem chi tiết--> \r\n\t\t\t  </div>\r\n\t\t\t  <!--end .top-shop-info-->";
}
echo $topShop;
?>
		  
	</div>
	<!--end .top-shop-wrapper-->
    <div class="list-top-shop-wrapper">
	<?php 
// ds những gian hàng còn lại
$topOtherShop = "";
if (count($dsGianHang) <= 1) {
    $topOtherShop .= "";
} else {
    for ($i = 1; $i < count($dsGianHang); $i++) {
        $otherShop = $dsGianHang[$i];
        $topOtherShop .= "\r\n\t\t\t\t\t\t<div class='list-top-shop-item'>\r\n\t\t\t\t\t\t\t<a href='gian_hang.php?maGianHang={$otherShop->MaGianHang}'>\r\n\t\t\t\t\t\t\t\t<img src='{$otherShop->Theme}' width='80' height='80' class='reflect' />\r\n\t\t\t\t\t\t\t</a>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<!--end .list-top-shop-item-->";
    }