Skip to content

Commit 1fa87d8

Browse files
committed
a lot
1 parent 261a1d6 commit 1fa87d8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1744
-552
lines changed

README.md

-2
This file was deleted.

admin/binhluan/duyet.php

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?php
2+
3+
$dsbinhluan = $qt->laybinhluan(0, $totalrows);
4+
5+
?>
6+
<h2 class="">Bình luận chưa duyệt</h2>
7+
8+
<table class="table table-striped">
9+
<thead>
10+
<tr>
11+
<th>ID</th>
12+
<th>Sản phẩm</th>
13+
<th>Tên</th>
14+
<th>Email</th>
15+
<th>Nội dung <small>(Rê chuột để xem nhanh)</small></th>
16+
<th><b class="glyphicon glyphicon-ok text-sucess" id="duyet"></b>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <b class="glyphicon glyphicon-remove text-danger" id="xoa" style="opacity: 0;"></b></th>
17+
</tr>
18+
</thead>
19+
<tbody id="dsbinhluan">
20+
<?php foreach($dsbinhluan as $binhluan){ ?>
21+
<tr>
22+
<td><?php echo $binhluan['id_comment'];?></td>
23+
<td><a class='text-primary' href="http://localhost/banhang/index.php?idSP=<?php echo $binhluan['idSP'];?>"><?php echo $qt->laytensanpham($binhluan['idSP']);?></a></td>
24+
<td><?php echo $binhluan['hoten'];?></td>
25+
<td><?php echo $binhluan['email'];?></td>
26+
<td><span title="<?php echo $binhluan['noidung'];?>"><?php if(strlen($binhluan['noidung']) > 30) echo mb_substr($binhluan['noidung'], 0, strpos($binhluan['noidung'], ' ', 30))."..."; else echo $binhluan['noidung'];?><span></span></td>
27+
<td><a href="#" class="duyet" idbl="<?php echo $binhluan['id_comment'];?>">Duyệt</a> / <a onclick="xacnhan();" href="#" class="xoa" idbl="<?php echo $binhluan['id_comment'];?>">Xóa</a></td>
28+
</tr>
29+
<?php }?>
30+
<tr><td colspan="6"><b>Còn:</b> <?php echo $totalrows;?> bình luận chưa duyệt</td></tr>
31+
</tbody>
32+
</table>
33+
<script>
34+
$(document).ready(function(){
35+
$("#dsbinhluan").on('click',".duyet", function(){
36+
var idBL = $(this).attr("idbl");
37+
duyetbinhluan(idBL);
38+
laybinhluan();
39+
$("#duyet").animate({'opacity': 1, 'font-size': '16px', 'color':'green'});
40+
anduyet();
41+
});
42+
43+
$("#dsbinhluan").on('click', '.xoa', function(){
44+
var idBL = $(this).attr("idbl");
45+
xoabinhluan(idBL);
46+
laybinhluan();
47+
$("#xoa").animate({'opacity': 1, 'font-size': '16px', 'color':'red'});
48+
anxoa();
49+
});
50+
});
51+
52+
function duyetbinhluan(idBL){
53+
$.ajax({
54+
url: "process.php",
55+
type: "get",
56+
data: "duyetbinhluan="+idBL
57+
});
58+
}
59+
60+
function xoabinhluan(idBL){
61+
$.ajax({
62+
url: "process.php",
63+
type: "get",
64+
data: "xoabinhluan="+idBL
65+
});
66+
}
67+
68+
function laybinhluan(){
69+
$.ajax({
70+
url: "process.php",
71+
type: "get",
72+
data: "laybinhluan=1",
73+
success: function(data){
74+
$("#dsbinhluan").html(data);
75+
}
76+
});
77+
}
78+
79+
function anduyet(){
80+
setTimeout(function(){
81+
$("#duyet").animate({'opacity': 0, 'color':'green'})
82+
}, 1000);
83+
}
84+
85+
function anxoa(){
86+
setTimeout(function(){
87+
$("#xoa").animate({'opacity': 0, 'color':'red'})
88+
}, 1000);
89+
}
90+
</script>

admin/binhluan/sua.php

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
if(!isset($_GET['id_comment']) || $_GET['id_comment'] < 1) header("location: index.php?c=loaisp&a=xem");
4+
5+
$binhluan = $qt->lay1binhluan($_GET['id_comment']);
6+
7+
if(isset($_POST['suabinhluan'])) $qt->suabinhluan($_GET['id_comment']);
8+
9+
?>
10+
<h2>Sửa comment</h2>
11+
<div class="">
12+
<?php foreach($qt->errors as $error){?>
13+
<p><?php echo $error;?></p>
14+
<?php }?>
15+
<form method="post" action="" class="col-md-6">
16+
<div class="form-group">
17+
<label for="hoten">Tên</label>
18+
<input type="text" name="hoten" value="<?php echo $binhluan['hoten']; ?>" class="form-control">
19+
</div>
20+
21+
<div class="form-group">
22+
<label for="email">Email</label>
23+
<input type="email" name="email" value="<?php echo $binhluan['email']; ?>" class="form-control">
24+
</div>
25+
26+
<div class="form-group">
27+
<label for="noidung">Nội dung</label>
28+
<textarea name="noidung" class="form-control" rows="5"><?php echo $binhluan['noidung']; ?></textarea>
29+
</div>
30+
31+
<div class="form-group">
32+
<input type="submit" name="suabinhluan" class="btn btn-primary" />
33+
</div>
34+
</form>
35+
</div>

admin/binhluan/xem.php

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
$dsbinhluan = $qt->laybinhluan(1, $totalrows);
4+
5+
?>
6+
<h2 class="">Bình luận đã duyệt</h2>
7+
8+
<table class="table table-striped">
9+
<thead>
10+
<tr>
11+
<th>ID</th>
12+
<th>Sản phẩm</th>
13+
<th>Tên</th>
14+
<th>Email</th>
15+
<th>Nội dung <small>(Rê chuột để xem nhanh)</small></th>
16+
<th>Thao tác</th>
17+
</tr>
18+
</thead>
19+
<tbody id="dsbinhluan">
20+
<?php foreach($dsbinhluan as $binhluan){ ?>
21+
<tr>
22+
<td><?php echo $binhluan['id_comment'];?></td>
23+
<td><a class='text-primary' href="http://localhost/banhang/index.php?idSP=<?php echo $binhluan['idSP'];?>"><?php echo $qt->laytensanpham($binhluan['idSP']);?></a></td>
24+
<td><?php echo $binhluan['hoten'];?></td>
25+
<td><?php echo $binhluan['email'];?></td>
26+
<td><span title="<?php echo $binhluan['noidung'];?>"><?php if(strlen($binhluan['noidung']) > 30) echo mb_substr($binhluan['noidung'], 0, strpos($binhluan['noidung'], ' ', 30))."..."; else echo $binhluan['noidung'];?><span></span></td>
27+
<td><a href="index.php?a=binhluan-sua&id_comment=<?php echo $binhluan['id_comment'];?>">Sửa</a> / <a href="index.php?a=binhluan-xoa&id_comment=<?php echo $binhluan['id_comment'];?>">Xóa</a></td>
28+
</tr>
29+
<?php }?>
30+
<tr><td colspan="6"><b>Tổng:</b> <?php echo $totalrows;?> bình luận</td></tr>
31+
</tbody>
32+
</table>
33+
<script>
34+
</script>

admin/binhluan/xoa.php

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
if(!isset($_GET['id_comment'])) header("location: index.php?a=binhluan-xem");
4+
5+
settype($_GET['id_comment'], "int");
6+
7+
if($_GET['id_comment'] == 0) header("location: index.php?a=binhluan-xem");
8+
9+
$qt->xoabinhluan($_GET['id_comment']);
10+
11+
header("location: index.php?a=binhluan-xem");

admin/chungloai/sua.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<?php
22

3-
if(!isset($_GET['idCL']) || $_GET['idCL'] < 1) header("location: index.php?c=chungloai&a=xem");
3+
if(!isset($_GET['idCL']) || $_GET['idCL'] < 1) header("location: index.php?a=chungloai-xem");
44

55
$idCL = $_GET['idCL'];
66

77
$chungloai = $qt->laychungloai($idCL);
88

99
if(isset($_POST['btnsuachungloai'])) $qt->suachungloai($idCL);
10+
1011
?>
1112
<h2>Cập nhật chủng loại</h2>
1213
<div class="">

admin/chungloai/xem.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
$listchungloai = $qt->laychungloai(0);
3+
$listchungloai = $qt->laychungloai(0, -1);
44

55
?>
66
<h2 class="">Chủng loại </h2>
@@ -12,7 +12,7 @@
1212
<th>Tên</th>
1313
<th>Thứ tự</th>
1414
<th>Ẩn/Hiện</th>
15-
<th><a class="btn btn-sm btn-success btn-them" href="index.php?c=chungloai&a=them"><span class="glyphicon glyphicon-plus"></span>Thêm mới</a></th>
15+
<th><a class="btn btn-sm btn-success btn-them" href="index.php?a=chungloai-them"><span class="glyphicon glyphicon-plus"></span>Thêm mới</a></th>
1616
</tr>
1717
</thead>
1818
<?php foreach($listchungloai as $row){?>
@@ -21,7 +21,7 @@
2121
<td><?php echo $row['TenCL'];?></td>
2222
<td><?php echo $row['ThuTu'];?></td>
2323
<td><?php if($row['AnHien']==0) echo "Ẩn"; else echo "Hiện" ;?></td>
24-
<td><a href="index.php?c=chungloai&a=sua&idCL=<?php echo $row['idCL'];?>">Sửa</a> / <a href="index.php?c=chungloai&a=xoa&idCL=<?php echo $row['idCL'];?>">Xóa</a></td>
24+
<td><a href="index.php?a=chungloai-sua&idCL=<?php echo $row['idCL'];?>">Sửa</a> / <a href="index.php?a=chungloai-xoa&idCL=<?php echo $row['idCL'];?>">Xóa</a></td>
2525
</tr>
2626
<?php }?>
2727
</table>

admin/classquantri.php

+86-27
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,40 @@ function __construct(){
66
parent::__construct();
77
}
88

9-
public function laychungloai($idCL=0){
9+
public function laydsdonhang($daxuly, &$totalrows){
10+
$sql = "SELECT idDH, idUser, ThoiDiemDatHang, TenNguoiNhan, DTNguoiNhan, DiaChi, DaTraTien FROM donhang WHERE DaXuLy=$daxuly ORDER BY idDH DESC";
11+
if(!$result = $this->db->query($sql)) die("Loi ket noi");
12+
$totalrows = $result->num_rows;
13+
14+
$data = array();
15+
while($row = $result->fetch_assoc()){
16+
$data[] = $row;
17+
}
18+
return $data;
19+
}
20+
21+
public function laychitietdonhang($idDH){
22+
$sql = "SELECT * FROM donhangchitiet WHERE idDH=$idDH";
23+
if(!$result = $this->db->query($sql)) die("Loi ket noi");
24+
25+
$data = array();
26+
while($row = $result->fetch_assoc()){
27+
$data[] = $row;
28+
}
29+
return $data;
30+
}
31+
32+
public function laythongtindonhang($idDH){
33+
$sql = "SELECT * FROM donhang WHERE idDH=$idDH";
34+
if(!$result = $this->db->query($sql)) die("Loi ket noi");
35+
$data = $result->fetch_assoc();
36+
return $data;
37+
}
38+
39+
public function laychungloai($idCL=0, $AnHien=1){
1040
// $idCL == 0 -> lay het tat ca;
11-
if($idCL > 0) $sql = "select * from chungloai where idCL=$idCL";
12-
else $sql = "select * from chungloai";
41+
if($idCL > 0) $sql = "select * from chungloai where idCL=$idCL AND (AnHien=$AnHien OR $AnHien=-1)";
42+
else $sql = "select * from chungloai WHERE AnHien=$AnHien OR $AnHien=-1";
1343

1444
if(!$result = $this->db->query($sql)) die("loi ket noi");
1545
$data = array();
@@ -343,7 +373,59 @@ public function xoasanpham($idSP){
343373
$sql = "DELETE FROM sanpham WHERE idSP=$idSP";
344374
if(!$result = $this->db->query($sql)) die("Loi ket noi");
345375
if(!empty($urlHinh)) unlink($path);
346-
header("Location: index.php?c=sanpham&a=xem");
376+
header("Location: index.php?a=sanpham-xem");
377+
}
378+
379+
public function laytensanpham($idSP){
380+
$sql = "SELECT TenSP from sanpham WHERE idSP=$idSP";
381+
if(!$result = $this->db->query($sql));
382+
$row = $result->fetch_row();
383+
return $row[0];
384+
}
385+
386+
public function laybinhluan($kiem_duyet=0, &$totalrows, $current_page=1, $per_page=10){
387+
$sql = "SELECT count(id_comment) FROM sanpham_comment WHERE kiem_duyet=$kiem_duyet";
388+
if(!$result = $this->db->query($sql));
389+
$row = $result->fetch_row();
390+
$totalrows = $row[0];
391+
392+
$start = ($current_page-1)*$per_page;
393+
394+
$sql = "SELECT * FROM sanpham_comment WHERE kiem_duyet=$kiem_duyet ORDER BY id_comment DESC LIMIT $start, $per_page";
395+
if(!$result = $this->db->query($sql));
396+
$data = array();
397+
while($row = $result->fetch_assoc()){
398+
$data[] = $row;
399+
}
400+
return $data;
401+
}
402+
403+
public function lay1binhluan($idBL){
404+
$sql = "SELECT * FROM sanpham_comment WHERE id_comment=$idBL";
405+
if(!$result = $this->db->query($sql));
406+
$data = $result->fetch_assoc();
407+
return $data;
408+
}
409+
410+
public function duyetbinhluan($idBL){
411+
$sql = "UPDATE sanpham_comment SET kiem_duyet=1 WHERE id_comment=$idBL";
412+
if(!$result = $this->db->query($sql)) die($sql);
413+
echo "duyet thanh cong";
414+
}
415+
416+
public function suabinhluan($idBL){
417+
$hoten = $this->db->escape_string($_POST['hoten']);
418+
$email = $this->db->escape_string($_POST['email']);
419+
$noidung = $this->db->escape_string($_POST['noidung']);
420+
$noidung = nl2br($noidung);
421+
422+
$sql = "UPDATE sanpham_comment SET hoten='$hoten', email='$email', noidung='$noidung' WHERE id_comment=$idBL";
423+
if(!$result = $this->db->query($sql)) die($sql);
424+
}
425+
426+
public function xoabinhluan($idBL){
427+
$sql = "DELETE FROM sanpham_comment WHERE id_comment=$idBL";
428+
if(!$result = $this->db->query($sql)) die($sql);
347429
}
348430

349431
public function layuser($idUser = 0){
@@ -356,27 +438,4 @@ private function validate($input){
356438
return $input;
357439
}
358440

359-
protected function changeTitle($str){
360-
$unicode = array(
361-
'a'=>'á|à|ả|ã|ạ|ă|ắ|ằ|ẳ|ẵ|ặ|â|ấ|ầ|ẩ|ẫ|ậ', 'A'=>'Á|À|Ả|Ã|Ạ|Ă|Ắ|Ằ|Ẳ|Ẵ|Ặ|Â|Ấ|Ầ|Ẩ|Ẫ|Ậ',
362-
'd'=>'đ','D'=>'Đ',
363-
'e'=>'é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ', 'E'=>'É|È|Ẻ|Ẽ|Ẹ|Ê|Ế|Ề|Ể|Ễ|Ệ',
364-
'i'=>'í|ì|ỉ|ĩ|ị', 'I'=>'Í|Ì|Ỉ|Ĩ|Ị',
365-
'o'=>'ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ', 'O'=>'Ó|Ò|Ỏ|Õ|Ọ|Ô|Ố|Ồ|Ổ|Ỗ|Ộ|Ơ|Ớ|Ờ|Ở|Ỡ|Ợ',
366-
'u'=>'ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự', 'U'=>'Ú|Ù|Ủ|Ũ|Ụ|Ư|Ứ|Ừ|Ử|Ữ|Ự',
367-
'y'=>'ý|ỳ|ỷ|ỹ|ỵ', 'Y'=>'Ý|Ỳ|Ỷ|Ỹ|Ỵ'
368-
);
369-
370-
foreach($unicode as $khongdau => $codau){
371-
$arr = explode("|", $codau);
372-
$str = str_replace($arr, $khongdau, $str);
373-
}
374-
$str = str_replace(array('?', '&', '+', '%', "'", '"','\''), "", $str);
375-
$str = trim($str);
376-
while(strpos($str, ' ') > 0) $str = str_replace(" ", " ", $str);
377-
$str = mb_convert_case($str, MB_CASE_LOWER, 'utf-8');
378-
$str = str_replace(" ", "-", $str);
379-
return $str;
380-
}
381-
382441
}

0 commit comments

Comments
 (0)