<?
include './system/common.php';   
include './system/functions.php';
include './system/user.php';
    
if(!$user) {
header('location: /');  
exit;}

$id = _string(_num($_GET['id']));
  $inv = mysql_query('SELECT * FROM `inv` WHERE `id` = "'.$id.'"');
  $inv = mysql_fetch_array($inv);

  if(!$inv) {
header('location: /');
exit;}
 
  $item = mysql_query('SELECT * FROM `items` WHERE `id` = "'.$inv['item'].'"');
  $item = mysql_fetch_array($item);
    
$title = $item['name'];
include './system/h.php';

  $quality = [	'1'=>'Обычный',
				'2'=>'Необычный',
				'3'=>'Редкий',
				'4'=>'Эпический',
				'5'=>'Легендарный',
				'6'=>'Мифический'
		];
$quality_color=['1'=>'#999999',
				'2'=>'#B1D689',
				'3'=>'#6BA0E7',
				'4'=>'#C780DB',
				'5'=>'#FF8E94',
				'6'=>'#FE7E01'
		];
		
$w = [	'1'=>'Голова',
		'2'=>'Плечи',
		'3'=>'Торс',
		'4'=>'Перчатки',
		'5'=>'Левая рука',
		'6'=>'Правая рука',
		'7'=>'Ноги',
		'8'=>'Обувь'
		];


echo'
<div class="title">'.$title.'</div>
<div class="empty_block">
<table cellpadding="0" cellspacing="0">
<tr>
  <td width="15%"><img src="/images/items/'.$item['id'].'.png" alt="*"/></td>
  <td><img src="/images/ico/quality/'.$item['quality'].'.png" alt="*"/> <font color="#fff">'.$item['name'].'</font> '.($inv['smith'] > 0 ? '<font color="#90b0c0"><small>+'.$inv['smith'].'</small></font>':'').'
  <br/>
  <small><font color="#'.(($user['level'] < $item['level']) ? 'c06060':'fff').'"><img src="/images/ico/png/up.png" alt="*" width="12"/>'.$item['level'].' ур,</font>
  <font color="'.$quality_color[$item['quality']].'">'.$quality[$item['quality']].'</font>, '.$w[$item['w']].'<br/>';

echo'</small></td>
</tr></table>
</div>
<div class="line"></div>';







echo'<div class="empty_block">
<font color="#90b0c0">';

    $equip_item = mysql_query('SELECT * FROM `inv` WHERE `id` = "'.$user['w_'.$item['w']].'"');
    $equip_item = mysql_fetch_array($equip_item);
    $diff = 0;

echo'<img src="/images/ico/png/attack.png" alt="*"/> Сила: <font color="';
  
    if($inv['_str'] > $equip_item['_str']) { 
$diff += $inv['_str'] - $equip_item['_str'];
    
echo'#3c3'; 
}else{
echo'#c66';
}
echo'"> '.$inv['_str'],'</font><br/>';

echo'<img src="/images/ico/png/hp.png" alt="*"/> Жизнь: <font color="';

    if($inv['_vit'] > $equip_item['_vit']) {
$diff += $inv['_vit'] - $equip_item['_vit'];

echo'#3c3';
}else{
echo'#c66';
}
echo'"> '.$inv['_vit'].'</font><br/>';



echo'<img src="/images/ico/png/def.png" alt="*"/> Защита: <font color="';

    if($inv['_def'] > $equip_item['_def']) {
      $diff += $inv['_def'] - $equip_item['_def'];
echo'#3c3';
}else{
echo'#c66';
}
echo'"> '.$inv['_def'].'</font><br';

  
  if($user['w_'.$item['w']] != 0) {
    if($inv['_str'] > $equip_item['_str'] OR $inv['_vit'] > $equip_item['_vit'] OR $inv['_def'] > $equip_item['_def']) {
echo'<br> </br> <font color="#3c3">Лучше +'.$diff.'</font>';
    }
  
  }
    
	




    if($inv['rune']) {
$rune_stats = [ '1'=>'15',
				'2'=>'30',
				'3'=>'60',
				'4'=>'200',
				'5'=>'500',
				'6'=>'1000'
		];
$rune_color=[   '1'=>'#999999',
				'2'=>'#B1D689',
				'3'=>'#6BA0E7',
				'4'=>'#C780DB',
				'5'=>'#FF8E94',
				'6'=>'#FE7E01'
		];




}


echo'</div></font></div>
<div class="line"></div>
<div class="empty_block">
<font color="#90b0c0">
<img src="/images/ico/png/grind.png" alt="*"/> Заточка: +'.$inv['smith'].' ';
  if($inv['smith'] < 80 && $inv['user'] == $user['id']) { echo'<a href="/shop/smith/'.$inv['id'].'/"><font color="#fff"> <u>Заточить</u></font></a>';}
echo'</br>
<img src="/images/ico/png/rune.png" alt="*"/> Руна: '.($inv['rune'] ? '<img src="/images/ico/rune/small_'.$inv['rune'].'.png" alt="*"/> <font color="'.$rune_color[$inv['rune']].'">+'.$rune_stats[$inv['rune']].' к параметрам</font>':'отсутствует').' ';
if($inv['rune'] < 6 && $inv['user'] == $user['id']) { echo'<a href="/shop/runes/'.$inv['id'].'/"><font color="#fff"> <u>Установить</u></font></a>';}


echo'</font></div>';



    if($inv['user'] == $user['id']) {

      if($user['w_'.$item['w']] == $inv['id'] OR !$user['w_'.$item['w']] OR $user['w_'.$item['w']] != $inv['id']) {

?>

  <div class='line'></div>
<div class="empty_block">

<?

      if($user['w_'.$item['w']] == $inv['id']) { 
echo'<div class="link_center"><a href="/inv/move/'.$inv['id'].'/">В сумку</a></div>';
}

    if(!$user['w_'.$item['w']]) {
echo''.(($user['level'] < $item['skill']) ? '<div class="link_center_h"><a> с '.$item['skill'].' уровня </a></div>':'
<div class="link_center"><a href="/inv/wear/'.$inv['id'].'/">Надеть</a></div>').' ';
}
    
    if($user['w_'.$item['w']] != $inv['id']) {

switch($item['quality']) {
case 1:
$_s = 100;
$_g = 0;
break;
case 2:
$_s = 250;
$_g = 0;
break;
case 3:
$_s = 500;
$_g = 0;
break;
case 4:
$_s = 1000;
$_g = 0;
break;
case 5:
$_s = 50000;
$_g = 0;
break;
case 6:
$_s = 50000;
$_g = 0;
break;
}



echo' <div class="link_center"><a href="/inv/?sell='.$inv['id'].'">Продать за '.($_s ? "<img src='/images/ico/png/silver.png' alt='*' width='16'/> $_s":"<img src='/images/ico/png/gold.png' alt='*' width='16'/> $_g").'</a></div>';
 }

echo'</div>';

  }

  }

  
 /////////////////////////////////////////////////////////////// 
 //Сравниваем вещи
 ///////////////////////////////////////////////////////////////  
  
  if($equip_item && $inv['user'] != $user['id'] && $user['w_'.$item['w']]) {

    $i_equip_item = mysql_query('SELECT * FROM `items` WHERE `id` = "'.$equip_item['item'].'"');
    $i_equip_item = mysql_fetch_array($i_equip_item);

  $quality = [	'1'=>'Обычный',
				'2'=>'Необычный',
				'3'=>'Редкий',
				'4'=>'Эпический',
				'5'=>'Легендарный',
				'6'=>'Мифический'
		];
$quality_color=['1'=>'#999999',
				'2'=>'#B1D689',
				'3'=>'#6BA0E7',
				'4'=>'#C780DB',
				'5'=>'#FF8E94',
				'6'=>'#FE7E01'
		];
		
$w = [	'1'=>'Голова',
		'2'=>'Плечи',
		'3'=>'Торс',
		'4'=>'Перчатки',
		'5'=>'Левая рука',
		'6'=>'Правая рука',
		'7'=>'Ноги',
		'8'=>'Обувь'
		];

echo'<div class="line"></div>';
echo'<div class="title">На вас надето</div>
<div class="line"></div>

<div class="empty_block">
<table cellpadding="0" cellspacing="0">
<tr>
  <td width="15%"><img src="/images/items/'.$equip_item['item'].'.png" alt="*"/></td>
  <td><img src="/images/ico/quality/'.$i_equip_item['quality'].'.png" alt="*"/> <font color="#fff">'.$i_equip_item['name'].'</font>
  <br/>
  <small><font color="#'.($i_equip_item['level'] > $user['level'] ? 'c06060':'fff').'">  <img src="/images/ico/png/up.png" alt="*" width="12"/>'.$i_equip_item['level'].' ур, </font>
  <font color="'.$quality_color[$i_equip_item['quality']].'">  '.$quality[$i_equip_item['quality']].'</font>, '.$w[$i_equip_item['w']].'<br/>';

    if($equip_item['rune']) {
$rune_stats = [ '1'=>'15',
				'2'=>'30',
				'3'=>'60',
				'4'=>'200',
				'5'=>'500',
				'6'=>'1000'
		];
$rune_color=[   '1'=>'#999999',
				'2'=>'#B1D689',
				'3'=>'#6BA0E7',
				'4'=>'#C780DB',
				'5'=>'#FF8E94',
				'6'=>'#FE7E01'
		];

  echo'
  <img src="/images/ico/rune/small_'.$equip_item['rune'].'.png" alt="*"/> <font color="'.$rune_color[$equip_item['rune']].'">+'.$rune_stats[$equip_item['rune']].' к параметрам </font><br/>';
	}
  
  echo'</small></td>
</tr></table>
</div><div class="line"></div>';

echo'<div class="empty_block">
<font color="#90b0c0">
  <img src="/images/ico/png/attack.png" alt="*"/> Сила:  '.$equip_item['_str'].' <br/>
  <img src="/images/ico/png/hp.png" alt="*"/> Жизнь: '.$equip_item['_vit'].' <br/>
  <img src="/images/ico/png/def.png" alt="*"/> Защита: '.$equip_item['_def'].' <br/>
  </font>
</div>';
 
}
echo'<div class="line"></div>';
include './system/f.php';

?>