function bill_detail() { $data = array(); $user = adminLogged(); if (!adminLogged()) { redirect('/index.php?c=admin&m=login'); } else { $bill_detail = model('bill')->getBillDetails($_GET['id']); $data['total'] = 0; foreach ($bill_detail as $key => $b) { $book = model('book')->getSingle($b['book_id']); $bill_detail[$key]['name'] = $book['name']; $bill_detail[$key]['price'] = intval($book['price']); $bill_detail[$key]['total'] = $book['price'] * $b['quantity']; $bill_detail[$key]['image'] = $book['image']; $data['total'] += $book['price'] * $b['quantity']; } $data['bill_detail'] = $bill_detail; } $data['statuses'] = array('Chờ duyệt', 'Đang giao hàng', 'Đã giao hàng', 'Hủy'); $data['stt'] = model('bill')->getOneBy($_GET['id'], null)['status']; if (isPostRequest()) { $postData = postData(); db_update('bills', $postData, 'id=' . $_GET['id']); $data['stt'] = $postData['status']; $data['error'] = 'Tình trạng đơn hàng update thành công.'; } $data['user'] = model('user')->getOneBy(model('bill')->getOneBy($_GET['id'], null)['user_id'], null); $data['template_file'] = 'bill/detail.php'; render('layout.php', $data); }
function book_delete() { $currentUser = adminLogged(); if ($currentUser && model('book')->delete($_GET['bookid'])) { redirect('/admin/index.php?c=book&m=list'); } }
//compatibility ($SUBS['ACTION'] = $_SERVER['SCRIPT_NAME']) || ($SUBS['ACTION'] = '/admin/admin.php'); if (init()) { if ($HTTP_POST_VARS['Login']) { if (!logAdmin()) { $PARAM['cmd'] = 'login'; //login title $SUBS['ERROR'] = $MSG[20001]; //invalid password $SUBS['LOGIN_ERROR'] = fileParse('_admin_error.htmlt'); printPage('_admin_login.htmlt'); } else { adminMenu(); } //default; } elseif (!adminLogged()) { if ($PARAM['cmd'] != '' && $PARAM['cmd'] != 'logout') { $SUBS['ERROR'] = $MSG[20002]; //access denies $SUBS['LOGIN_ERROR'] = fileParse('_admin_error.htmlt'); } $PARAM['cmd'] = 'login'; //login title printPage('_admin_login.htmlt'); } else { switch ($PARAM['cmd']) { case 'charts': manageCharts(); break; case 'manage_chart': setCharts();
<h3>Menu Chính</h3> <ul class="nav nav-tabs nav-stacked"> <?php if ($logged = adminLogged()) { ?> <li><a href="index.php?c=bill&m=list">Welcome <strong><?php echo $logged['username']; ?> </strong></a></li> <li><a href="index.php?c=admin&m=logout">Logout</a></li> <?php } else { ?> <li><a href="index.php?c=admin&m=login">Login</a></li> <?php } ?> </ul> <ul class="nav nav-tabs nav-stacked"> <li><a href="index.php?c=bill&m=list">Quản lý đơn hàng</a></li> <li><a href="index.php?c=book&m=list">Quản lý sách</a></li> </ul>
function admin_index() { redirect('/admin/index.php' . (adminLogged() ? '?c=bill&m=list' : '?c=admin&m=login')); }