Файл: vk/admin/shop.php
Строк: 117
<?php
if($_GET['action'] == "delete" && isset($_GET['id'])){
$q = $db->mysql_qw("SELECT * FROM gifts_r WHERE id = ?;",$_GET['id']);
if(mysql_num_rows($q)>0){
if(isset($_POST['delete'])){
$db->mysql_qw("DELETE FROM gifts_r WHERE id = ?;",$_GET['id']);
echo "
<div class='alert alert-success'>
<b>Заказ успешно удален!</b>
</div>
";
}else{
echo "
<center>
<b>Вы действительно хотите удалить Заказ?</b>
<form method='post'>
<input type='hidden' name='delete' value='1'>
<input type='submit' class='btn btn-info' value='Удалить'>
<input type='button' class='btn btn-danger' value='Отменить' onClick='window.location.href="?page=notes&gpage=".$_GET['gpage']."";'>
</form>
</center>
";
}
}else{
echo "
<div class='alert alert-error'>
<b>Заказ с данным ID не найдена!</b>
</div>
";
}
exit();
}
if($_GET['action'] == "edit" && isset($_GET['id'])){
if(isset($_POST['num'])){
foreach($_POST as $key=>$val){
if($key == "date"){
$val = strtotime($val);
}
$string .= ",".$key."='".$val."'";
}
$string = substr($string, 1);
mysql_query("UPDATE gifts_r SET ".$string." WHERE id = ".$_GET['id'].";");
echo "
<div class='alert alert-success'>
<b>Заявка отредактирована!</b>
</div>
";
}
$q = $db->mysql_qw("SELECT r.*,g.img FROM gifts_r AS r LEFT OUTER JOIN gifts AS g ON r.gift = g.id WHERE r.id = ?",$_GET['id']);
if(mysql_num_rows($q)>0){
while($val = mysql_fetch_assoc($q)){
$date = date("H:i d.m.Y",$val['date']);
if($val['gift'] == 0){
$type = "Голоса ВК";
}else{
$type = "<img src='".$val['img']."'>";
}
if($val['status'] == 1){
$status = "
<select name='status' class='tselect'>
<option value='0'>Ожидает</option>
<option value='1' selected>Отказано</option>
<option value='2'>Успешно</option>
</select>
";
}else if($val['status'] == 2){
$status = "
<select name='status' class='tselect'>
<option value='0'>Ожидает</option>
<option value='1'>Отказано</option>
<option value='2' selected>Успешно</option>
</select>
";
}else{
$status = "
<select name='status' class='tselect'>
<option value='0' selected>Ожидает</option>
<option value='1'>Отказано</option>
<option value='2'>Успешно</option>
</select>
";
}
echo "
<form method='post'>
<table class='admint'>
<tr>
<td>Тип</td>
<td>".$type."</td>
</tr>
<tr>
<td>Количество</td>
<td><input type='text' name='num' value='".$val['num']."'></td>
</tr>
<tr>
<td>Заказал</td>
<td><input type='text' name='user' value='".$val['user']."'></td>
</tr>
<tr>
<td>Кому отправить</td>
<td><input type='text' name='to_u' value='".$val['to_u']."'></td>
</tr>
<tr>
<td>Описание</td>
<td><input type='text' name='about' value='".$val['about']."'></td>
</tr>
<tr>
<td>Дата</td>
<td><input type='text' name='date' value='".$date."'></td>
</tr>
<tr>
<td>Статус</td>
<td>".$status."</td>
</tr>
<tr>
<td>Причина отказа</td>
<td><input type='text' name='reason' value='".$val['reason']."'></td>
</tr>
</table>
<br>
<input type='submit' class='btn btn-info' value='Сохранить'> <input type='button' class='btn btn-danger' value='Отменить' onClick='window.location.href="?page=shop&gpage=".$_GET['gpage']."";'>
</form>
";
}
}else{
echo "
<div class='alert alert-error'>
<b>Заявка с данным ID не найдена!</b>
</div>
";
}
}else{
$q = $db->mysql_qw("SELECT r.*,g.img FROM gifts_r AS r LEFT OUTER JOIN gifts AS g ON r.gift = g.id ORDER BY r.status;");
$on_page = 10;
$pages = ceil(mysql_num_rows($q) / $on_page);
if($pages == 0){
echo "<center><h3>Не найдено ни одной заявки</h3></center>";
}else{
if(!isset($_GET['gpage'])){
$page_now = 1;
}else{
$page_now = $_GET['gpage'];
}
echo "Выберите страницу: ";
for($c=1;$c<=$pages;$c++){
if($c == $page_now){
echo "<b>".$c."</b> ";
}else{
echo "<a href='?page=shop&gpage=".$c."'>".$c."</a> ";
}
}
$sd = $page_now * $on_page - $on_page;
echo "
<table class='admint'>
<tr>
<td>Тип</td>
<td>Количество</td>
<td>Заказал</td>
<td>Кому отправить</td>
<td>Описание</td>
<td>Дата</td>
<td>Статус</td>
<td>Причина</td>
<td></td>
</tr>
";
$q = $db->mysql_qw("SELECT r.*,g.img FROM gifts_r AS r LEFT OUTER JOIN gifts AS g ON r.gift = g.id ORDER BY r.status LIMIT ?,?",$sd, $on_page);
while($val = mysql_fetch_assoc($q)){
if($val['gift'] == 0){
$type = "Голоса ВК";
}else{
$type = "<img src='".$val['img']."'>";
}
if($val['status'] == 0){
$status = "<font class='status-wait'>Ожидает</font>";
}else if($val['status'] == 1){
$status = "<font class='status-fail'>Отказано</font>";
}else if($val['status'] == 2){
$status = "<font class='status-okay'>Успешно</font>";
}
$date = date("H:i d.m.Y",$val['date']);
echo "
<tr>
<td>".$type."</td>
<td>".$val['num']."</td>
<td>".$val['user']."</td>
<td>".$val['to_u']."</td>
<td>".$val['about']."</td>
<td>".$date."</td>
<td>".$status."</td>
<td>".$val['reason']."</td>
<td>
<a href='?page=shop&gpage=".$page_now."&id=".$val['id']."&action=edit'><img src='http://cdn2.iconfinder.com/data/icons/diagona/icon/16/018.png' class='editt'></a>
<a href='?page=shop&gpage=".$page_now."&id=".$val['id']."&action=delete'><img src='http://cdn2.iconfinder.com/data/icons/diagona/icon/16/101.png' class='deletet'></a>
</td>
</tr>
";
}
echo "</table>";
}
}
?>