<?
include_once '../../sys/fnc.php';
echo '<div id="page-wrapper"><div class="main-page"><div class="blank-page widget-shadow scroll" id="style-2 div1"><p>';
/* ---- */	
if (!isset($user) || $user->position != 'admin') {
    header('location: /');
    exit;
}
/* ---- */	
$title = 'Массовое добавление дней';
include_once '../../sys/head.php';

if (isset($_POST['save']))
{

$q=mysql_query("SELECT `id`,`works_to` FROM `my_orders` WHERE `status` = '1'");
while ($us = mysql_fetch_array($q))
{
mysql_query("UPDATE `my_orders` SET `works_to` = '".($us['works_to']+60 * 60 * 24 * intval($_POST['days']))."' WHERE `id` = '". $us['id'] ."'");
}

mysql_query("INSERT INTO `logs_bill` (`id_user`, `time`, `razd`, `text`) values('".$user->id."', '".time()."', 'Добавление дней всем', 'Добавили ".intval($_POST['days'])." дн.')"); // Записуем лог
header('Location: ?');


}
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `my_orders` WHERE `status` = '1'"),0);

echo '<div class="post">Всего активных услуг: <b>'.$count.'</b><br/>';
echo "<form method=\"post\" action=\"?\">\n";
echo '<b>Сколько дней +:</b><br /><input type="text" name="days" maxlength="32" /><br />';
echo "<input value=\"Добавить\" name='save' type=\"submit\" />\n";
echo "</form></div>\n";

if ($user->position == 'admin')echo $div->div_menu.' » <a href="/admin">Админ управление</a></div>';
echo '</p></div></div></div>';
include_once '../../sys/foot.php';
?>