<?php
define('NTLCMS', 1);
$module = 'panel';
include ('../system/start.php');
include ('../system/function.php');
include ('../system/antidos.php');
$page_title = 'Страница модерации заданий - клик клуба ' . strtoupper($_SERVER['HTTP_HOST']);
include ('../system/head.php');
if (!$active){
header('Location: '.URL);
$_SESSION['fail'] = 'Вы не авторизированы!';
exit;
}
echo '<div class="title"><b>'.razd.' Модерация заданий</b></div>';
if ($_USER['admin'] > '0' && $_USER['admin'] < '3'){
function colorSum($sum){
if ($sum >= 100) return 'red';
return '#000000';
}
if (isset($_GET['accept']) && is_numeric($_GET['accept'])){
$payed = isset($_GET['accept']) ? filter_var($_GET['accept'], FILTER_SANITIZE_NUMBER_INT) : '0';
$task = DB :: run() -> querySingle("select * from `jobs` where `id` = '$payed' and `accept` = '0' limit 1");
if ($task > 0){
DB :: run() -> query("update `jobs` set `accept` = '1' where `id` = '$payed'");
}
}
if (isset($_GET['decline']) && is_numeric($_GET['decline'])){
$payed = isset($_GET['decline']) ? filter_var($_GET['decline'], FILTER_SANITIZE_NUMBER_INT) : '0';
$task = DB :: run() -> querySingle("select * from `jobs` where `id` = '$payed' and `accept` = '0' limit 1");
if ($task > 0){
DB :: run() -> query("update `jobs` set `accept` = '2' where `id` = '$payed' ");
}
}
$k_post = DB :: run() -> querySingle("select count(`id`) from `jobs` where `accept` = '0'"); 
$k_page = k_page($k_post, $onpage); 
$page = page($k_page); 
$start = $onpage * $page - $onpage;
$sql = DB :: run() -> query("select * from `jobs` where `accept` = '0' order by `id` limit ".$start.", ".$onpage);
if ($k_post == 0){
echo '<div class="error"><center><i class="fa fa-close fa-fw"></i> Задания отсутсвуют!</center></div>';
} else {
echo '<div class="menu">';
echo'<style>
TH {
background: #ADD8E6; /* Цвет фона ячеек */
color: black; /* Цвет текста */ 
}</style>	
<BODY><TABLE BORDER WIDTH=100%>
<TR>
<TH><center><b>№</b></center></TH>
<TH><center><b>Логин</b></center></TH>
<TH><center><b>Текст</center></TH>
<TH><center><b>URL</b></center></TH>
<TH><center><b>Действие</b></center></TH></TR>';
while ($row = $sql -> fetch(PDO::FETCH_OBJ)){
echo'<TR>
<TD ALIGN=CENTER><b>'.((int) $row -> id).'</b></font> </TD>
<TD ALIGN=CENTER><font color="#778899">'.login($row -> user, 1).'</b></font></TD>
<TD ALIGN=CENTER><font color="#778899"> '.checkout($row -> about).'</font></TD>
<TD ALIGN=CENTER><font color="#778899"> <a href="http://'.str_ireplace('http://', '', $row -> url).'">'.checkout($row -> url).'</a></font></TD>
<TD ALIGN=CENTER><font color="#778899"><a href="'.URL.'/admtask_yes'.((int) $row -> id).'">Одобрить</a> | <a href="'.URL.'/admtask_no'.((int) $row -> id).'">Отменить</a> </font></TD></TR></BODY> ';
}
echo '<tr><TD colspan=7 ALIGN=CENTER>Всего заявок: <b>'.$k_post.'</b></TD>	';
echo '</table></div>';
if ($k_page > 1) navigation(URL.'/admintask?', $k_page, $page);
}
} else {
header('Location: '.URL);
$_SESSION['fail'] = 'Доступ запрещен!';
}
echo '<div class="block"><i class="fa fa-home fa-fw"></i> <a href="'.URL.'/cabinet">В кабинет</a> | <a href="'.URL.'/tasks">Задания пользователей</a></div>';				
include ('../system/foot.php');
?>