Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintain #21

Merged
merged 2 commits into from
Apr 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion admin/controllers/feedback/add.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}

$order = get_a_record('orders', $orderId);
$orderDetail = order_detail($orderId);
$orderDetail = orderDetail($orderId);

if (isset($userNav)) {
$user_action = get_a_record('users', $userNav);
Expand Down
2 changes: 1 addition & 1 deletion admin/controllers/feedback/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
$feedback = get_a_record('feedbacks', $feedbackId);

if ($feedback['order_id'] <> 0) {
$orderDetail = order_detail($feedback['order_id']);
$orderDetail = orderDetail($feedback['order_id']);
$order = get_a_record('orders', $feedback['order_id']);
}
if ($feedback['product_id'] <> 0) {
Expand Down
2 changes: 1 addition & 1 deletion admin/controllers/feedback/reply.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
require_once('admin/models/order.php');

if (!empty($_POST)) {
feedback_reply_email($_POST['html-content'], $_POST['feedback_email']);
feedbackReplyMail($_POST['html-content'], $_POST['feedback_email']);
}

if (isset($_GET['feedback_id'])) {
Expand Down
2 changes: 1 addition & 1 deletion admin/controllers/feedback/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
$feedback = get_a_record('feedbacks', $feedbackId);

if ($feedback['order_id'] <> 0) {
$orderDetail = order_detail($feedback['order_id']);
$orderDetail = orderDetail($feedback['order_id']);
$order = get_a_record('orders', $feedback['order_id']);
}

Expand Down
4 changes: 2 additions & 2 deletions admin/controllers/home/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
if (!empty($_POST)) {
$email = escape($_POST['email']);
$password = md5($_POST['password']);
user_login($email, $password);
userLogin($email, $password);
}

if (isset($_SESSION['user'])) {
$user = $_SESSION['user'];

updateCartSession();
update_cart_user_db();
mergeCartSessionWithDB();

if ($user['role_id'] == 1 || $user['role_id'] == 2) {
header('location:admin.php');
Expand Down
2 changes: 1 addition & 1 deletion admin/controllers/home/logout.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
$user_login = get_a_record('users', $userNav);

unset($_SESSION['user']);
cart_destroy();
cartDestroy();

if ($user_login['role_id'] == 0) {
header('location:index.php');
Expand Down
4 changes: 2 additions & 2 deletions admin/controllers/media/add.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require_once('admin/models/media.php');

if (!empty($_POST)) {
media_add();
mediaStore();
}

if (isset($_GET['media_id'])) {
Expand All @@ -16,6 +16,6 @@

$title = ($mediaId == 0) ? '' : 'Cập nhật ảnh';
$navMedia = 'class="active open"';
$media_info = get_a_record('media', $mediaId);
$mediaInfo = get_a_record('media', $mediaId);

require('admin/views/media/add.php');
2 changes: 1 addition & 1 deletion admin/controllers/media/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
require_once('admin/models/media.php');

$mediaId = intval($_GET['media_id']);
media_delete($mediaId);
mediaDestroy($mediaId);

header('location:admin.php?controller=media');
4 changes: 2 additions & 2 deletions admin/controllers/media/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
require_once('admin/models/media.php');

if (!empty($_POST)) {
media_update();
mediaUpdate();
}

if (isset($_GET['media_id'])) {
Expand All @@ -17,6 +17,6 @@

$title = ($mediaId == 0) ? 'Thêm Ảnh mới' : 'Cập nhật ảnh';
$navMedia = 'class="active open"';
$media_info = get_a_record('media', $mediaId);
$mediaInfo = get_a_record('media', $mediaId);

require('admin/views/media/edit.php');
6 changes: 5 additions & 1 deletion admin/controllers/order/complete.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?php

permission_user();

require_once('admin/models/order.php');

//submit form click
if (!empty($_POST)) {
order_complete($_POST['order_id']);
orderComplete($_POST['order_id']);
}

header('location:admin.php?controller=order');
8 changes: 6 additions & 2 deletions admin/controllers/order/delete.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?php

permission_user();
permission_moderator();
//load model

require_once('admin/models/order.php');

$orderId = intval($_GET['order_id']);
order_delete($orderId);

orderDestroy($orderId);

header('location:admin.php?controller=order');
7 changes: 6 additions & 1 deletion admin/controllers/order/index.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
<?php

permission_user();

if (isset($_POST['order_id'])) {
foreach ($_POST['order_id'] as $orderId) {
$orderId = intval($orderId);
}
}

$options = array(
'order_by' => 'status ASC, id DESC'
);

$url = 'admin.php?controller=order';
$totalRows = get_total('orders', $options);
$title = 'Đơn hàng';
$orderNav = 'class="active open"';
$orderNav = 'class="active open"';
$orders = get_all('orders', $options);

$status = array(
0 => 'Chưa xử lý',
1 => 'Đã xử lý',
Expand Down
8 changes: 6 additions & 2 deletions admin/controllers/order/inprocess.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?php
<?php

permission_user();

require_once('admin/models/order.php');

//submit form click
if (!empty($_POST)) {
order_inprocess($_POST['order_id']);
orderInProcess($_POST['order_id']);
}

header('location:admin.php?controller=order');
8 changes: 6 additions & 2 deletions admin/controllers/order/order-cancell.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
<?php

permission_user();

$options = array(
'where' => 'status = 3',
'order_by' => 'createtime DESC'
);
$orderComplete = get_all('orders', $options);

$orderComplete = get_all('orders', $options);

$title = 'Đơn hàng đã bị hủy';
$orderNav = 'class="active open"';
$orderNav = 'class="active open"';
$status = array(
0 => 'Chưa xử lý',
1 => 'Đã xử lý',
2 => 'Đang xử lý',
3 => 'Đã bị hủy'
);

require('admin/views/order/order-cancell.php');
6 changes: 4 additions & 2 deletions admin/controllers/order/order-complete.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<?php

permission_user();

$options = array(
'where' => 'status = 1',
'order_by' => 'createtime DESC'
);
$orderComplete = get_all('orders', $options);
$orderComplete = get_all('orders', $options);

$title = 'Đơn hàng đã xử lý';
$orderNav = 'class="active open"';
$orderNav = 'class="active open"';
$status = array(
0 => 'Chưa xử lý',
1 => 'Đã xử lý',
Expand Down
5 changes: 4 additions & 1 deletion admin/controllers/order/order-inprocess.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

permission_user();

$title = 'Đơn hàng đang xử lý';
$orderNav = 'class="active open"';
$orderNav = 'class="active open"';

require('admin/views/order/order-inprocess.php');
5 changes: 4 additions & 1 deletion admin/controllers/order/order-noprocess.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

permission_user();

$title = 'Đơn hàng chưa xử lý';
$orderNav = 'class="active open"';
$orderNav = 'class="active open"';

require('admin/views/order/order-noprocess.php');
15 changes: 12 additions & 3 deletions admin/controllers/order/view.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
<?php
permission_user();

require_once('admin/models/order.php');
if (isset($_GET['order_id'])) $orderId = intval($_GET['order_id']); else $orderId=0;

if (isset($_GET['order_id']))
$orderId = intval($_GET['order_id']);
else $orderId = 0;

$order = get_a_record('orders', $orderId);

if (!$order) {
show_404();
}

$title = 'Chi tiết đơn hàng';
$orderNav = 'class="active open"';
$orderDetail = order_detail($orderId);
$orderNav = 'class="active open"';

$orderDetail = orderDetail($orderId);

$status = array(
0 => 'Đã xác nhận đơn hàng',
2 => 'Đang giao hàng',
Expand Down
13 changes: 9 additions & 4 deletions admin/controllers/page/add.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
<?php

permission_user();
//load model

require_once('admin/models/posts.php');

if (!empty($_POST)) {
page_add();
}

if (isset($_GET['post_id'])) $postId = intval($_GET['post_id']);
if (isset($_GET['post_id']))
$postId = intval($_GET['post_id']);
else $postId = 0;
$post = get_a_record('posts', $postId);
$pageNav = 'class="active open"';

$post = get_a_record('posts', $postId);
$pageNav = 'class="active open"';
$title = 'Thêm trang mới - Chị Kòi Quán';

require('admin/views/page/add.php');
6 changes: 5 additions & 1 deletion admin/controllers/page/delete.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<?php

permission_user();
permission_moderator();

require_once('admin/models/posts.php');

$pageId = intval($_GET['page_id']);
post_delete($pageId);
postDelete($pageId);

header('location:admin.php?controller=page');
6 changes: 5 additions & 1 deletion admin/controllers/page/draft.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<?php

permission_user();
permission_moderator();

require_once('admin/models/posts.php');

$pageId = intval($_GET['page_id']);
post_draft($pageId);
postDraft($pageId);

header('location:admin.php?controller=page&action=viewdraft');
18 changes: 13 additions & 5 deletions admin/controllers/page/edit.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
<?php

permission_user();
//load model

require_once('admin/models/posts.php');

if (!empty($_POST)) {
page_update();
}
if (isset($_GET['post_id'])) $postId = intval($_GET['post_id']);

if (isset($_GET['post_id']))
$postId = intval($_GET['post_id']);
else $postId = 0;

$title = 'Sửa trang - Chị Kòi Quán';
$pageNav = 'class="active open"';
$pageNav = 'class="active open"';
$post = get_a_record('posts', $postId);
global $userNav;
$loginUser = get_a_record('users', $userNav);

if ($loginUser['role_id'] == 2) {
if ($post['post_author'] == $userNav) require('admin/views/page/edit.php');
else header('location:admin.php?controller=page');
} else require('admin/views/page/edit.php');
if ($post['post_author'] == $userNav)
require('admin/views/page/edit.php');
else header('location:admin.php?controller=page');
} else require('admin/views/page/edit.php');
13 changes: 9 additions & 4 deletions admin/controllers/page/index.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<?php

permission_user();

require_once('admin/models/posts.php');

$title = 'All Page - Chị Kòi Quán';
$pageNav = 'class="active open"';
if (isset($_GET['page'])) $page = intval($_GET['page']);
$pageNav = 'class="active open"';

if (isset($_GET['page']))
$page = intval($_GET['page']);
else $page = 1;

$page = ($page > 0) ? $page : 1;
Expand All @@ -17,11 +21,12 @@
'offset' => $offset,
'order_by' => 'id DESC'
);
$pages = get_all('posts', $options);
$pages = get_all('posts', $options);

$url = 'admin.php?controller=page';
$totalRows = get_total('posts', $options);
$total = ceil($totalRows / $limit);

$pagination = pagination_admin($url, $page, $total);
$pagination = adminPagination($url, $page, $total);

require('admin/views/page/index.php');
Loading