Merge pull request #116 from Kuzirashi/master

Added displaying orders from shop in Shop Admin page.
This commit is contained in:
Stefan A. Brannfjell 2014-05-17 06:56:12 +02:00
commit 309c17eca3
3 changed files with 51 additions and 0 deletions

41
admin_shop.php Normal file
View File

@ -0,0 +1,41 @@
<?php
require_once 'engine/init.php';
include 'layout/overall/header.php';
protect_page();
admin_only($user_data);
$orders_ammount = isset($_GET['orders_ammount']) && $_GET['orders_ammount'] > 0 && $_GET['orders_ammount'] <= 200 ? (int)$_GET['orders_ammount'] : 50;
$orders = mysql_select_multi('SELECT * FROM `znote_shop_orders` ORDER BY `id` DESC LIMIT ' . $orders_ammount);
$order_types = array(1 => 'Item', 2 => 'Premium Days', 3 => 'Sex Change', 4 => 'Custom');
?>
<h1>Admin Shop</h1>
<h2>Shop Orders</h2>
<p>Shows latest <?php echo $orders_ammount; ?> shop orders.</p>
<form action="" method="get">
<label for="orders_length">Enter ammount of orders to show:</label> <input type="number" max="200" min="1" name="orders_ammount" value="<?php echo $orders_ammount; ?>"/>
<input type="submit" value="Submit"/>
</form>
<table>
<thead>
<th>Id</th>
<th>Account</th>
<th>Type</th>
<th>Item</th>
<th>Count</th>
<th>Date</th>
</thead>
<tbody>
<?php foreach(($orders ? $orders : array()) as $order) { ?>
<tr>
<td><?php echo $order['id']; ?></td>
<td><?php echo user_account_id_from_name($order['account_id']); ?></td>
<td><?php echo $order_types[$order['type']] ?></td>
<td><?php echo getItemNameById($order['itemid']) . ' (' . $order['itemid'] . ')' ?></td>
<td><?php echo $order['count'] ?></td>
<td><?php echo date('Y/m/d H:i', $order['time']) ?></td>
</tr>
<?php } ?>
</tbody>
</table>
<?php
include 'layout/overall/footer.php';
?>

View File

@ -933,6 +933,13 @@ function user_account_id_from_password($password) {
return $tmp['id']; return $tmp['id'];
} }
// Get account name from id.
function user_account_id_from_name($id) {
$id = (int)$id;;
$result = mysql_select_single("SELECT `name` FROM `accounts` WHERE `id` = '" . $id . "' LIMIT 1;");
return $result['name'];
}
// Add additional premium days to account id // Add additional premium days to account id
function user_account_add_premdays($accid, $days) { function user_account_add_premdays($accid, $days) {
$accid = (int)$accid; $accid = (int)$accid;

View File

@ -17,6 +17,9 @@
<li> <li>
<a href='admin_reports.php'>Admin Reports</a> <a href='admin_reports.php'>Admin Reports</a>
</li> </li>
<li>
<a href='admin_shop.php'>Admin Shop</a>
</li>
<?php <?php
$new = 0; $new = 0;
$cat = 4; //Category ID for feedback section $cat = 4; //Category ID for feedback section