<?php
	
	include_once __DIR__ . '/include/common.php';
	include_once __DIR__ . '/include/general_functions.php';
	include_once __DIR__ . '/include/utils.php';	
	include_once __DIR__ . '/include/user.php';
	
	if ( ! @$user)
			redirect('/');
	
	$params	=	[];
	
	$params['title']	=	'Магазин снаряжения';
	$params['list_errors']	=	[];
	
	ob_start();
	
	include_once __DIR__ . '/include/header.php';
	
		$quality	=	min(5, intval(@$_GET['quality']));
	if ($quality!=	0)
	{
		
		//	получаем кол-во мастерства выьранного качества
		$skill	=	get_item_skill(
			$quality
		);
		
		if ($user['skill'] < $skill)
			redirect('/shop/');
	
		$query		=	@mysql_query(sprintf(
			'SELECT
					*
				FROM
					`complects`
				WHERE
					`quality`	=	%d',
			$quality
		));
		
		if (@mysql_num_rows($query) != 0)
		{
			
		?>
		<ul class='menu'>
		<?php
			while	(
				$complect	=	@mysql_fetch_assoc($query)
			)
			{
				
		?>
			<li><img src='/images/icon/quality/<?=$quality?>.png' alt='' /> <a href='/complect/<?=$complect['id']?>'><?=$complect['name']?></a></li>
			<li class='cntr'>
				<img src='/manekenImage/<?=$user['sex']?>/<?=$complect[1]?>/<?=$complect[2]?>/<?=$complect[3]?>//<?=$complect[4]?>/<?=$complect[5]?>/<?=$complect[6]?>/<?=$complect[7]?>/<?=$complect[8]?>' alt='' />
			</li>
		<?php
				
			}
		?>
		</ul>
		<?php
			
		}
		else
		{
	
	?>
	<div class='container cntr c_grey'>Комплектов нет</div>
	<?php
		}
		
	?>
	<div class='min-line'></div>
	<ul class='list'>
		<li><a href='/shop/'><img src='/images/icon/arrow.png' alt='' /> Вернуться</a></li>
	</ul>
	<?php
	}
	else
	{
	?>
	<ul class='menu'>
		<li class='cntr'><img src='/images/places/shop.png' alt='' /></li>
		<li class='cntr c_blue'>Лучшее снаряжение только тут</li>
	</ul>
	<div class='min-line'></div>
	<?php
		
		if ($user['skill']	>	0)
		{
	
	?>
	<ul class='list'>
	<?php
	
			if ($user['skill']	>=	200)
			{
		
	?>
		<li>
			<a href='/shop/?quality=5' class='quality-5'>
				<img src='/images/icon/quality/5.png' alt='' /> Божественные вещи<br />
				<span class='small c_white'>Требуется <img src='/images/icon/skill.png' alt='' />  200</span>
			</a>
		</li>
	<?php			
		
			}
			
			if ($user['skill']	>=	48)
			{
	?>
		<li>
			<a href='/shop/?quality=4' class='quality-4'>
				<img src='/images/icon/quality/4.png' alt='' /> Легендарные вещи<br />
				<span class='small c_white'>Требуется <img src='/images/icon/skill.png' alt='' />  48</span>
			</a>
		</li>
	<?php
			}
			
			if ($user['skill']	>=	24)
			{
	?>
		<li>
			<a href='/shop/?quality=3' class='quality-3'>
				<img src='/images/icon/quality/3.png' alt='' /> Эпические вещи<br />
				<span class='small c_white'>Требуется <img src='/images/icon/skill.png' alt='' />  24</span>
			</a>
		</li>
	<?php
			}
			
			if ($user['skill']	>=	10)
			{
	?>
		<li>
			<a href='/shop/?quality=2' class='quality-2'>
				<img src='/images/icon/quality/2.png' alt='' /> Редкие вещи<br />
				<span class='small c_white'>Требуется <img src='/images/icon/skill.png' alt='' />  10</span>
			</a>
		</li>
	<?php
		
			}
	?>
		<li>
			<a href='/shop/?quality=1' class='quality-1'>
				<img src='/images/icon/quality/1.png' alt='' /> Обычные вещи<br />
				<span class='small c_white'>Требуется <img src='/images/icon/skill.png' alt='' /> 1</span>
			</a>
		</li>
	</ul>
	<?php
		}
		else
		{
	?>
	<div class='container c_grey'>Нужно минимум <img src='/images/icon/skill.png' alt='' /> 1 мастерства.</div>
	<?php
		}
	
	}
	
	?>
	<div class='min-line'></div>
	<div class='container'>
	<img src='/images/icon/skill.png' alt='' /> Мастерство: <b><?=$user['skill']?></b>
	</div>
	<?php
	
	include_once __DIR__ . '/include/footer.php';
	
	setContentType('text/html; charset=UTF-8');
	render(
		__DIR__ . '/include/template.php',
		ob_get_clean(),
		$params
	);
	
	?>
	