<? include('checkcookie.php'); ?>
<h3>Задания,ожидающие модерации</h3>
<br>
<?
if(isset($_POST["del"])){
$id = intval($_POST["id"]);
if(isset($_POST["beck_money"]) && intval(trim($_POST["beck_money"])) == 1){
$sql = mysql_query("SELECT `fromid`, `balance` FROM `seo_tasks` WHERE `id`='$id'") or die(mysql_error());
$row = mysql_fetch_assoc($sql);
mysql_query("UPDATE `b_users` SET `money`=`money`+'".$row["balance"]."' WHERE `id`='".$row["fromid"]."'") or die(mysql_error());
}
mysql_query("DELETE FROM `seo_tasks` WHERE `id`='$id'") or die(mysql_error());
echo "<div style='text-align:center;margin-top: -10px;padding: 10px;'>Задание удалено!</div>";
}
if(isset($_POST["ok"])){
$id = intval($_POST["id"]);
mysql_query("UPDATE `seo_tasks` SET `modered`='1' WHERE `id`='$id'") or die(mysql_error());
echo "<div style='text-align:center;margin-top: -10px;padding: 10px;'>Задание одобрено!</div>";
}
if(isset($_POST["no"])){
$id = intval($_POST["id"]);
if(isset($_POST["reas"])){
$reas = $_POST["reas"];
mysql_query("UPDATE `seo_tasks` SET `modered`='2',`reas`='$reas' WHERE `id`='$id'") or die(mysql_error());
echo "<div style='text-align:center;margin-top: -10px;padding: 10px;'>Задание отклонено</div>";
}else{
?>
<center><form action='' method='post'>
<input type='hidden' name='no' value='no'>
<input type='hidden' name='id' value='<?=$id ?>'>
<input type='text' name='reas' value='введите причину'>
<input type='submit' value='подтвердить отклонение'>
</form>
<?
}
}
?>
<table class="adn">
<tr class="lineb">
<td width="50">№</th>
<td>линк на залдание</td>
<td>Стоимость</td>
<td>Разместил</td>
<td>Балланс</td>
<td>Выполнено</td>
<td>Ожидает</td>
<td>Отказано</td>
</tr>
<?
if(isset($_GET["deleted"]) && intval($_GET["deleted"]) == 1) {
$zapros = "`modered`='1'";
}else{
$zapros = "`modered`='1'";
}
$tabla = mysql_query("SELECT * FROM `seo_tasks` WHERE $zapros ORDER BY `up_task` DESC, `id` DESC");
while($registro = mysql_fetch_array($tabla)) {
$row=mysql_fetch_assoc(mysql_query("SELECT `username` FROM `b_users` WHERE `id`='".$registro["fromid"]."'"));
$uname = $row["username"];
$money = $registro["balance"];
$short_link = substr($money, 0, 4);
echo "<tr class='liney ell' style='border-bottom:1px solid #80A2D9;'>
<td align=center>". $registro["id"] ."</td>
<td align=center><a href='http://".$_SERVER["HTTP_HOST"]."/tasks.php?view=".$registro["id"]."' target='_blank'>".$registro["name"]."</a></td>
<td align=center>". $registro["price"] ."</td>
<td align=center>$uname</a></td>
<td align=center>$short_link</a></td>
<td align=center>$registro[goods]</a></td>
<td align=center>$registro[waits]</a></td>
<td align=center>$registro[no]</a></td></tr>";

if(isset($_GET["deleted"]) && intval($_GET["deleted"]) == 1) {
echo "<td align='center'>";
echo "<form action='' method='post'>";
echo "<input type='hidden' name='id' value='".$registro["id"]."'>";
echo "Вернуть деньги <input type='checkbox' name='beck_money' value='1'>";
echo "</td><td align='center'>";
echo "<input type='submit' name='del' value='Удалить'>";
echo "</form></td>";
}else{?>

<?
}
} 
?>
</table>