<?php

require_once('conf/dbc.php');
require_once('conf/session_start.php');
require_once('conf/ban.php');
if ((!isset($_SESSION['id'])) or (!isset($_SESSION['nick'])))  {
?>
<script type="text/javascript">
  document.location.href = "login.php";
</script>
<?php
}
$page_title = 'Суслов';
require_once('conf/head.php');
require_once('conf/top.php');
$user_id = abs(intval($_SESSION['id']));
  $query = "Select * from users where id = '$user_id'";
  $result = mysqli_query($dbc, $query) or die ('Ошибка передачи запроса к БД');
  $row = mysqli_fetch_array($result);
  $money = $row['money'];
  $vip = $row['vip'];
  $habar = $row['habar'];
  $lvl = $row['lvl'];
$type = abs(intval($_GET['type']));

  if ($type <> 1 and $type <> 2 and $type <> 3 and $type <> 4 and $type <> 5 and $type <> 6) {
    if ($lvl >=21) {$type = 4;}
    if ($lvl >12 and $lvl <21) {$type = 3;}
    if ($lvl >=3 and $lvl <12 ) {$type = 2;}
    if ($lvl <3) {$type = 1;}
  }
?>
<div id="main">

    <center><p class="name">Торговец Суслов</p></center>
  </div>
  <div class="stats">
    <p><img src="img/ico/syslov.png"  width="110" height="170"/></p>
<div class="zx">
    <p class="net"> - Дарова STALKER. Как жизнь? Снаряга на витрине.. Смотри - выбирай..</p>
  </div>
<div class="stats"><p>[<a <?php if ($type == 1) {?>class="white"<?php }?> href="salesman.php?type=1">Нов</a>] [<a <?php if ($type == 2) {?>class="white"<?php }?> href="salesman.php?type=2">Быв</a>] [<a <?php if ($type == 3) {?>class="white"<?php }?> href="salesman.php?type=3">Вет</a>] [<a <?php if ($type == 4) {?>class="white"<?php }?> href="salesman.php?type=4">Лег</a>]</p>
  </div>
  <?php 
  ?>
    <p>[<img src="img/ico/money.png" width="12" height="12"/> <span class="white"><?php echo "$money"; ?></span>] [<img src="img/ico/materials.png" width="12" height="12"/> <span class="white"><?php echo "$habar"; ?></span>]</p>
	<div class="zx">
	<p class="bonus">Советы:</p>
<p class="clothes"><span class="bonus"><img src="img/ico/money.png" width="12" height="12"/> Нет у тебя RUB ? [<a href="paymoney.php">пополни счет</a>]</span></p>
  </div>
<p class="podmenu"><?php 
  if ($type == 1) {?><img src="img/ico/class1.png" width="12" height="12"/> Новичок<?php }
  if ($type == 2) {?><img src="img/ico/class2.png" width="12" height="12"/> Бывалый<?php }
  if ($type == 3) {?><img src="img/ico/class3.png" width="12" height="12"/> Ветеран<?php }
  if ($type == 5) {?><img src="img/ico/class3.png" width="12" height="12"/> VIP<?php }
  if ($type == 6) {?><img src="img/ico/class3.png" width="12" height="12"/>Артефакты</br><?php }
  if ($type == 4) {?><img src="img/ico/class4.png" width="12" height="12"/> Легенда<?php }?>
  </p>
  <div class="stats">

	
	<?php

	$query_c = "Select name,shlem_id,price, price_hab,lvl_need,screen,klass from shlem where klass = '$type'";
    $result_c = mysqli_query($dbc, $query_c) or die ('Ошибка передачи запроса к БД');
    while ($row_cl = mysqli_fetch_array($result_c)) {
?><a  style="text-decoration:none;" href="sale_thing.php?thing=<?php echo $row_cl['shlem_id'];?>&type=1"><font color=#316F6F><b><?php echo $row_cl['name'];?></b></font><?php
if($row_cl['lvl_need']>=$row['lvl']){echo'  (<span class="bonus">'.$row_cl[lvl_need].'</span> ур)</a></p>';}
else{echo'  (<span class="red">'.$row_cl[lvl_need].'</span> ур)</a></p>';}
	}
	
	////////////////////конец шлемам
  echo'<center><p class="name">Одежда</p></center><div class=inoy>';
	$query_c = "Select name,clothes_id,price, price_hab,lvl_need,screen,klass from clothes where klass = '$type'";
    $result_c = mysqli_query($dbc, $query_c) or die ('Ошибка передачи запроса к БД');
    while ($row_cl = mysqli_fetch_array($result_c)) {
?><a  style="text-decoration:none;" href="sale_thing.php?thing=<?php echo $row_cl['clothes_id'];?>&type=1"><font color=#316F6F><b><?php echo $row_cl['name'];?></b></font><?php
if($row_cl['lvl_need']>=$row['lvl']){echo'  (<span class="bonus">'.$row_cl[lvl_need].'</span> ур)</a></p>';}
else{echo'  (<span class="red">'.$row_cl[lvl_need].'</span> ур)</a></p>';}
	}
	////////////////////Конец одежде.
	////////////////////Пистолет
  echo'<center><p class="name">Пистолеты</p></center></div><div class=inoy>';
	$query_c = "Select name,pistols_id,price, price_hab,lvl_need,screen,klass from pistols where klass = '$type'";
    $result_c = mysqli_query($dbc, $query_c) or die ('Ошибка передачи запроса к БД');
    while ($row_cl = mysqli_fetch_array($result_c)) {
?><a  style="text-decoration:none;" href="sale_thing.php?thing=<?php echo $row_cl['pistols_id'];?>&type=1"><font color=#316F6F><b><?php echo $row_cl['name'];?></b></font><?php
if($row_cl['lvl_need']>=$row['lvl']){echo'  (<span class="bonus">'.$row_cl[lvl_need].'</span> ур)</a></p>';}
else{echo'  (<span class="red">'.$row_cl[lvl_need].'</span> ур)</a></p>';}
	}
   echo'<center><p class="name">Автоматы</p></center></div><div class=inoy>';
	$query_c = "Select name,weapons_id,price, price_hab,lvl_need,screen,klass from weapons where klass = '$type'  order by max_stats_yron ASC";
    $result_c = mysqli_query($dbc, $query_c) or die ('Ошибка передачи запроса к БД');
    while ($row_cl = mysqli_fetch_array($result_c)) {
?><a  style="text-decoration:none;" href="sale_thing.php?thing=<?php echo $row_cl['weapons_id'];?>&type=1"><font color=#316F6F><b><?php echo $row_cl['name'];?></b></font><?php
if($row_cl['lvl_need']>=$row['lvl']){echo'  (<span class="bonus">'.$row_cl[lvl_need].'</span> ур)</a></p>';}
else{echo'  (<span class="red">'.$row_cl[lvl_need].'</span> ур)</a></p>';}
	}
    ?></div>
  <div class="r2"><a style="text-decoration:none;" href="baza_chn.php" ><img src="img/ico/left.png" alt="."/>Выйти</a></div>

<?php
require_once('conf/navig.php');
require_once('conf/foot.php');
mysqli_close($dbc);
?>

</body>
</html>