$user = $_REQUEST['user']; // kiểm tra người dùng tham gia hay không tham gia sự kiện $nguoiDungThamGia = LikesDAO::LayDanhSachLikesTheoMaDT_MaNguoiDung($_REQUEST['id'], $_REQUEST['user']); $res = false; $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>';
$strRes = ""; // kiểm tra người dùng đã like hay chưa $nguoiDungLike = LikesDAO::LayDanhSachLikesTheoMaDT_MaNguoiDung($maDoiTuong, $maNguoiDung); $res = false; $txtLike = ""; if (is_null($nguoiDungLike)) { // thêm likes $likeDto = new LikesDTO(); $likeDto->MaDoiTuong = $maDoiTuong; $likeDto->MaNguoiDung = $maNguoiDung; $likeDto->SoSao = '0'; $res = LikesDAO::ThemLike($likeDto); $txtLike = "Unlike"; } else { //Xóa likes $res = LikesDAO::XoaLike($maDoiTuong, $maNguoiDung); $txtLike = "Like"; } if ($res) { // lấy ds likes $dsLikes = LikesDAO::LayDanhSachLikesTheoMaDoiTuong($maDoiTuong); $soNguoiLike = count($dsLikes); // kết quả trả về $funcLikeBL = "funcLike('" . $maDoiTuong . "','" . $maNguoiDung . "','" . $_REQUEST['kq'] . "', '" . $page . "')"; if ($page == 'BinhLuan_SK') { $strRes = $soNguoiLike . ' người thích <span class="text-color-normal-1 likes" onclick="' . $funcLikeBL . '" >' . $txtLike . '</span>'; } //like sản phẩm if ($page == 'ChiTietSP') { $strRes = $soNguoiLike . ' người thích <span style="cursor:pointer;" class="text-color-bold-1" onclick="' . $funcLikeSP . '" >' . $txtLike . '</span>'; }