Skip to content

Commit

Permalink
Merge pull request #22 from tanhongit/maintain
Browse files Browse the repository at this point in the history
update style and clean code v3
  • Loading branch information
tanhongit authored Apr 22, 2023
2 parents 39f6458 + 04f4435 commit c4e9a13
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 18 deletions.
4 changes: 2 additions & 2 deletions admin/controllers/purchase/confirmed.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
'where' => 'status = 0 and user_id =' . $userNav,
'order_by' => 'createtime DESC'
);
$confirmedOrders = get_all('orders', $options);
$confirmedOrders = get_all('orders', $options);
$title = 'Đơn hàng đã xác nhận';
$yourPurchaseNav = 'class="active open"';
$yourPurchaseNav = 'class="active open"';
$status = array(
0 => 'Đã xác nhận đơn hàng',
2 => 'Đang giao hàng',
Expand Down
6 changes: 5 additions & 1 deletion admin/controllers/role/admin.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<?php

permission_user();

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

$options = array(
'order_by' => 'id ASC'
);
$title = 'Danh sách Admin';
$adminNav = 'class="active open"';
$adminNav = 'class="active open"';
$list_user = get_all('users', $options);

require('admin/views/role/admin.php');
6 changes: 5 additions & 1 deletion admin/controllers/role/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/roles.php');

$roleId = intval($_GET['role_id']);
role_delete($roleId);
roleDestroy($roleId);

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

permission_user();
permission_moderator();

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

$roleId = intval($_GET['user_id']);
user_delete($roleId);
userDestroy($roleId);

header('location:admin.php?controller=role&action=admin');
14 changes: 11 additions & 3 deletions admin/controllers/role/edit.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
<?php

permission_user();
permission_moderator();

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

if (!empty($_POST)) {
role_update();
}
if (isset($_GET['role_id'])) $roleId = intval($_GET['role_id']); else $roleId=0;
$title = ($roleId==0) ? 'Thêm quyền truy cập' : 'Sửa quyền truy cập';
$adminNav = 'class="active open"';

if (isset($_GET['role_id']))
$roleId = intval($_GET['role_id']);
else $roleId = 0;

$title = ($roleId == 0) ? 'Thêm quyền truy cập' : 'Sửa quyền truy cập';
$adminNav = 'class="active open"';
$role = get_a_record('roles', $roleId);

require('admin/views/role/edit.php');
9 changes: 7 additions & 2 deletions admin/controllers/role/index.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
<?php

permission_user();
permission_moderator();

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

if (isset($_POST['role_id'])) {
foreach ($_POST['role_id'] as $roleId) {
$roleId = intval($roleId);
role_delete($roleId);
roleDestroy($roleId);
}
}

$url = 'admin.php?controller=role';
$options = array(
'order_by' => 'id ASC'
);
$title = 'Danh sách quyền truy cập website';
$adminNav = 'class="active open"';
$adminNav = 'class="active open"';
$roles = get_all('roles', $options);

require('admin/views/role/index.php');
6 changes: 5 additions & 1 deletion admin/controllers/shop/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/shop.php');

$categoryId = intval($_GET['cate_id']);
categories_delete($categoryId);
categoryDestroy($categoryId);

header('location:admin.php?controller=shop');
11 changes: 9 additions & 2 deletions admin/controllers/shop/edit.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
<?php

permission_user();
permission_moderator();

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

if (!empty($_POST)) {
category_uodate();
categoryUpdate();
}
if (isset($_GET['cate_id'])) $categoryId = intval($_GET['cate_id']);

if (isset($_GET['cate_id']))
$categoryId = intval($_GET['cate_id']);
else $categoryId = 0;

$title = ($categoryId == 0) ? 'Thêm danh mục' : 'Sửa danh mục';
$category = get_a_record('categories', $categoryId);
$navCategory = 'class="active open"';

require('admin/views/shop/edit.php');
4 changes: 4 additions & 0 deletions admin/controllers/shop/index.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
<?php

permission_user();
permission_moderator();

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

$options = array(
'order_by' => 'id'
);
$title = 'Nhóm Danh mục sản phẩm';
$categories = get_all('categories', $options);
$navCategory = 'class="active open"';

//load view
require('admin/views/shop/index.php');
2 changes: 1 addition & 1 deletion admin/controllers/user/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
require('admin/views/user/result.php');
exit;
} else {
user_delete($userId);
userDestroy($userId);
}
header('location:admin.php?controller=user&action=listall');
2 changes: 1 addition & 1 deletion admin/models/roles.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
function role_delete($id)
function roleDestroy($id)
{
$id = intval($id);
global $linkConnectDB;
Expand Down
4 changes: 2 additions & 2 deletions admin/models/shop.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
function categories_delete($id)
function categoryDestroy($id)
{
$id = intval($id);
require_once('admin/models/products.php');
Expand All @@ -15,7 +15,7 @@ function categories_delete($id)
$sql = "DELETE FROM categories WHERE id=$id";
mysqli_query($linkConnectDB, $sql) or die(mysqli_error($linkConnectDB));
}
function category_uodate()
function categoryUpdate()
{
$name = escape($_POST['name']);
if (strlen($_POST['slug']) >= 5) $slug = slug($_POST['slug']);
Expand Down
2 changes: 1 addition & 1 deletion admin/models/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function userLogin($input, $password)
}
return false;
}
function user_delete($id)
function userDestroy($id)
{
$user = get_a_record('users', $id);
$image = 'public/upload/images/' . $user['user_avatar'];
Expand Down

0 comments on commit c4e9a13

Please sign in to comment.