<?
$title = $l = 'Баг-трекер - Добавить отчет';
require (CORE.'head.php');
if (isset($_POST['cfms']))
{
if (!isset($_POST['title']) || $_POST['title'] == NULL || system::utf_strlen(system::check($_POST['title'])) < 1)
{
$errMsg = 'Пустое название!';
}
else if (system::utf_strlen(system::check($_POST['title'])) > 20)
{
$errMsg = 'Название превышает 20 знаков!';
}
else if (!isset($_POST['opis']) || $_POST['opis'] == NULL || system::utf_strlen(system::check($_POST['opis'])) < 1)
{
$errMsg = 'Пустое описание!';
}
else if (!isset($_POST['id_type']) || $_POST['id_type'] == NULL || !is_numeric($_POST['id_type']) || $_POST['id_type'] < 0 || DB::$pdo -> querySingle("SELECT COUNT(*) FROM `bag_tracker_types` WHERE `id` = '".abs(intval($_POST['id_type']))."'") == 0)
{
$errMsg = 'Укажите тип!';
}
else if (!isset($_POST['id_kat']) || $_POST['id_kat'] == NULL || !is_numeric($_POST['id_kat']) || $_POST['id_kat'] < 0 || DB::$pdo -> querySingle("SELECT COUNT(*) FROM `bag_tracker_kat` WHERE `id` = '".abs(intval($_POST['id_kat']))."'") == 0)
{
$errMsg = 'Укажите категорию!';
}
else if (!isset($_POST['prioritet']) || $_POST['prioritet'] == NULL || !is_numeric($_POST['prioritet']) || $_POST['prioritet'] < 0 || $_POST['prioritet'] > 2)
{
$errMsg = 'Укажите приоритет!';
}
if (!isset($errMsg))
{
if (DB::$pdo -> query("INSERT INTO `bag_tracker` (`id_user`, `id_type`, `id_kat`, `prioritet`, `title`, `opis`, `time`) VALUES ('".$user['id']."', '".abs(intval($_POST['id_type']))."', '".abs(intval($_POST['id_kat']))."', '".abs(intval($_POST['prioritet']))."', '".system::check($_POST['title'])."', '".system::check($_POST['opis'])."', '".time()."');"))
{
system::redirect('Отчет успешно добавлен!', '/bag_tracker/?add_tracker');
} else {
$errMsg = 'Неизвестная ошибка!';
}
}
}
if (isset($errMsg))
{
system::show($errMsg);
}
?>
<div class="app-block">
<div class="list">
<form method="post" class="post-add" data-type="arbour" action="/bag_tracker/?add_tracker">
<div class="_gray _dbl">
Название:
</div>
<input class="main-input _w-100" type="text" name="title" />
<div class="_gray _dbl">
Описание:
</div>
<textarea name="opis"></textarea>
<div class="_gray _dbl">
Тип:
</div>
<select class="main-input _w-100" name="id_type">
<?
$query_gifts = DB :: $pdo -> query("SELECT * FROM `bag_tracker_types` ORDER BY `name` ASC");
while($r = $query_gifts -> fetch())
{
?>
<option value="<?echo $r['id'];?>">
<?echo stripcslashes(htmlspecialchars($r['name']));?>
</option>
<?
}
?>
</select>
<div class="_gray _dbl">
Категория:
</div>
<select class="main-input _w-100" name="id_kat">
<?
$query_gifts = DB :: $pdo -> query("SELECT * FROM `bag_tracker_kat` ORDER BY `name` ASC");
while($r = $query_gifts -> fetch())
{
?>
<option value="<?echo $r['id'];?>">
<?echo stripcslashes(htmlspecialchars($r['name']));?>
</option>
<?
}
?>
</select>
<div class="_gray _dbl">
Приоритет:
</div>
<select class="main-input _w-100" name="prioritet">
<option value="0">
Низкий
</option>
<option value="1">
Средний
</option>
<option value="2">
Высокий
</option>
</select>
<div class="_center" style="margin-top: 3px;">
<input type="submit" class="main-btn _w-100" name="cfms" value="Продолжить" />
</div>
</form>
</div>
<a class="app-action" href="/bag_tracker/">
<?echo system::icon('arr-l')?> Назад
</a>
<?
require (CORE.'foot.php');
exit;
?>