$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; }
$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'> </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-->"; } }
$maDoiTuong = $_REQUEST['id']; $maNguoiDung = $_REQUEST['user']; $page = $_REQUEST['page']; $strRes = ""; // kiểm tra người dùng đã đánh giá hay chưa $nguoiDungDanhGia = LikesDAO::LayDanhSachLikesTheoMaDT_MaNguoiDung($maDoiTuong, $maNguoiDung); $res = false; $txtLike = ""; if (is_null($nguoiDungDanhGia)) { // thêm đánh giá $likeDto = new LikesDTO(); $likeDto->MaDoiTuong = $maDoiTuong; $likeDto->MaNguoiDung = $maNguoiDung; $likeDto->SoSao = $soSao; $res = LikesDAO::ThemLike($likeDto); //$txtLike = "Unlike"; } else { //Cập nhật đánh giá $res = LikesDAO::CapNhatLike($maDoiTuong, $maNguoiDung, $soSao); //$txtLike = "Like"; } if ($res) { // kết quả trả về if ($page === 'ChiTietSP') { $SoSaoTB = LikesDAO::TinhSoSaoTBCuaMotDoiTuong($maDoiTuong); $strRes = $SoSaoTB . ' sao | <span class="text-color-bold-1" id="btnDanhGiaSP" style="cursor:pointer;">Đánh giá</span>'; } } echo $strRes; }
<div class="top-list-product-item-back"> </div> <!--end .top-list-product-item-back--> <?php require_once 'class/SanPhamDAO.php'; $dsTopSanPham = SanPhamDAO::LayDanhSachSanPham(5); $strOutput = ""; if (count($dsTopSanPham) == 0) { $strOutput = "<p><i>Website chưa có sản phẩm nào.</i></p>"; } else { for ($i = 0; $i < count($dsTopSanPham); $i++) { $sanPham = $dsTopSanPham[$i]; $maGH = SanPhamDAO::LayMaGianHangCuaSanPham($sanPham->Ma); $donGiaBan = formatMoney($sanPham->DonGiaBan); $donGiaGoc = formatMoney($sanPham->DonGiaGoc); $soSao = LikesDAO::TinhSoSaoTBCuaMotDoiTuong($sanPham->Ma); $ngayDangSP = date_create($sanPham->NgayDang); $ngayDangSP = $ngayDangSP->format('H:i:s d-m-Y '); $strOutput .= "<div class='top-list-product-item'>\r\n\t\t\t\t\t\t\t\t<a href='chi_tiet_san_pham?maSanPham={$sanPham->Ma}&maGianHang={$maGH}'>\r\n\t\t\t\t\t\t\t\t\t<img src='{$sanPham->HinhAnh}' width='350' height='350' />\r\n\t\t\t\t\t\t\t\t</a>\r\n\t\t\t\t\t\t\t\t<div class='name'>\r\n\t\t\t\t\t\t\t\t<a href='chi_tiet_san_pham?maSanPham={$sanPham->Ma}&maGianHang={$maGH}'>\r\n\t\t\t\t\t\t\t\t\t{$sanPham->TenSanPham}\r\n\t\t\t\t\t\t\t\t</a>\r\n\t\t\t\t\t\t\t\t</div>"; //kiểm tra giá bán có thấp hơn so với giá gốc hay không if ($donGiaBan < $donGiaGoc) { $strOutput .= "<div class='new-price'>{$donGiaBan} VND</div>\r\n\t\t\t\t\t\t\t\t\t\t<div class='old-price'>{$donGiaGoc} VND</div>"; } else { $strOutput .= "<div class='new-price'>{$donGiaGoc} VND</div>"; } $strOutput .= "\r\n\t\t\t\t\t\t\t\t<div class='top-list-product-item-info'>\r\n\t\t\t\t\t\t\t\t <a href='#'><div class='views'>{$sanPham->LuotXem}</div></a>\r\n\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t <a href='#'><div class='stars'>{$soSao}</div></a>\r\n\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t\t <div class='top-list-product-item-info'> "; $strOutput .= " <a href='#'><div class='time-upload'>{$ngayDangSP}</div></a>\r\n\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t</div>"; } } echo $strOutput; ?>
<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-->"; }
/**********************************************************/ // ds bình luận sự kiện $gBinhLuanSK .= "\r\n\t\t\t\t <div class='row'>\r\n\t\t\t\t\t<div class='title'>\r\n\t\t\t\t\t\t\tBình luận sự kiện\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<!--end title--> \r\n\t\t\t\t\t\t<div class='comment'>"; //kiểm tra đăng nhập hay chưa if ($_SESSION['IsLogin'] == 0) { $gBinhLuanSK .= "Bạn phải đăng nhập hoặc đăng ký thành viên mới được phép xem bình luận."; } else { if (!is_null($dsBinhLuan)) { foreach ($dsBinhLuan 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, $_SESSION['IdUser']); $idKQ_Like_BL = "kq_like_binhluan_sk_" . $binhLuanDto->MaBL; $funcLikeBL = "funcLike('" . $binhLuanDto->MaBL . "','" . $_SESSION['IdUser'] . "','" . $idKQ_Like_BL . "','BinhLuan_SK')"; if (is_null($nguoiDungLikeBL)) { $txtLikeBL = "Like"; } else { $txtLikeBL = "Unlike"; } $gBinhLuanSK .= "\r\n\t\t\t\t\t\t\t\t\t<div class='comment-wrapper'> \t \t\r\n\t\t\t\t\t\t\t\t\t\t<div class='avatar'><img src='{$nguoiDungBL->AnhDaiDien}' width='1280' height='1024' /></div>\r\n\t\t\t\t\t\t\t\t\t\t<div class='content'>\r\n\t\t\t\t\t\t\t\t\t\t\t <div class='title-comment'>\r\n\t\t\t\t\t\t\t\t\t\t\t\t<span class='text-color-normal-1'>\r\n\t\t\t\t\t\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\t\t\t\t\t</span> bình luận lúc {$gioBL} ngày {$ngayBL}.\r\n\t\t\t\t\t\t\t\t\t\t\t </div>\r\n\t\t\t\t\t\t\t\t\t\t\t <div class='primary-comment'>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t{$binhLuanDto->NoiDungBL}\r\n\t\t\t\t\t\t\t\t\t\t\t </div>\r\n\t\t\t\t\t\t\t\t\t\t\t <div class='action' id='kq_like_binhluan_sk_{$binhLuanDto->MaBL}'>\r\n\t\t\t\t\t\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\t\t\t\t\t </div>\r\n\t\t\t\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t\t\t</div> \r\n\t\t\t\t\t\t\t\t\t\t<!--end .content-->\r\n\t\t\t\t\t\t\t\t\t\t<div class='button'>\r\n\t\t\t\t\t\t\t\t\t\t\t<span class='remove ui-icon ui-icon-close' title='Xóa'> </span>\r\n\t\t\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t\t\t<!--end .comment-wrapper-->"; } } else { $gBinhLuanSK .= "Không có bình luận nào."; } /**********************************************************/ // bình luận mới $curUser = NguoiDungDAO::LayThongTinNguoiDungTheoMa($_SESSION['IdUser']);