<?

    include './system/common.php';
    
 include './system/functions.php';
         
      include './system/user.php';
    
if(!$user) {

  header('location: /');
  exit;

}

      $id = _string(_num($_GET['id']));
$complect = mysql_fetch_array(mysql_query('SELECT * FROM `complects` WHERE `id` = \''.$id.'\''));
 
  if(!$complect) {

    header('location: /');
    exit;

  }
    

$title = $complect['name'];

include './system/h.php';

echo '<div class=\'title\'>'.$title.'</div>
<div class=\'line\'></div>
<div class=\'content\'>
  <img src=\'/manekenImage/'.$user['sex'].'/'.$complect['w_1'].'/'.$complect['w_2'].'/'.$complect['w_3'].'/'.$complect['w_4'].'/'.$complect['w_5'].'/'.$complect['w_6'].'/'.$complect['w_7'].'/'.$complect['w_8'].'/\'/>
</div>
<div class=\'line\'></div>';

$cost = 0;

for($w = 1; $w < 9; $w++) {

  $itemshop = mysql_fetch_array(mysql_query('SELECT * FROM `shop` WHERE `id` = \''.$complect['w_'.$w].'\''));

  $cost += $itemshop['cost'];

}

echo '<div class=\'list\'>
  <li class=\'no_b\'><a href=\'/shop/?buy_complect='.$complect['id'].'\'><img src=\'/images/icon/arrow.png\' alt=\'*\'/> Купить весь комплект за <img src=\'/images/icon/gold.png\' alt=\'*\'/> '.$cost.' золота</a></li>
</div>
<div class=\'line\'></div>';

for($w = 1; $w < 9; $w++) {

  echo '<div class=\'content\'>
  <table cellpadding=\'0\' cellspacing=\'0\'><tr>';

  $itemshop = mysql_fetch_array(mysql_query('SELECT * FROM `shop`  WHERE `id` = \''.$complect['w_'.$w].'\''));
  $item = mysql_fetch_array(mysql_query('SELECT * FROM `items` WHERE `id` = \''.$complect['w_'.$w].'\''));

  $itemquality = array('Простой', 'Обычный', 'Редкий', 'Эпический', 'Легендарный', 'Божественный', 'Сверх Божественный');
  $quality_col = array('#9b8869', '#9b8869', '#9bcd69', '#529ce4', '#d67bfc', '#f96c27', '#989898');
  $itembonus   = array(0,5,10,15,20,50,65);

  echo '<td><img src=\'/itemImage.php?id='.$itemshop['id'].'\' alt=\'*\'/></td>
  <td valign=\'top\' style=\'padding-left: 5px;\'><img src=\'/images/icon/quality/'.$itemshop['quality'].'.png\' alt=\'*\'/> <a href=\'/itemshop/'.$itemshop['id'].'/\'>'.$item['name'].'</a><br/>
  <small><small><font color=\''.$quality_col[$itemshop['quality']].'\'>'.$itemquality[$itemshop['quality']].' ['.$itemshop['bonus'].'/'.$itembonus[$itemshop['quality']].']</font> ';

  if($user['w_'.$item['w']]) {

    $equipitem = mysql_fetch_array(mysql_query('SELECT * FROM `inv` WHERE `id` = \''.$user['w_'.$item['w']].'\''));      
    
    if( ($itemshop['_str'] + $itemshop['_vit'] + $itemshop['_agi'] + $itemshop['_def']) - ($equipitem['_str'] + $equipitem['_vit'] + $equipitem['_agi'] + $equipitem['_def']) > 0) echo '<font color=\'#30c030\'>+'.(($itemshop['_str'] + $itemshop['_vit'] + $itemshop['_agi'] + $itemshop['_def']) - ($equipitem['_str'] + $equipitem['_vit'] + $equipitem['_agi'] + $equipitem['_def'])).'</font>';
    
  }
  else
  {
    
    echo '<font color=\'#30c030\'>+'.($itemshop['_str'] + $itemshop['_vit'] + $itemshop['_agi'] + $itemshop['_def']).'</font>';

  }
  
  echo '</small></small></td>
  </tr></table>
  <br/>
  <div align=\'center\'><a href=\'/shop/?buy_item='.$itemshop['id'].'\' class=\'button\'>Купить за <img src=\'/images/icon/gold.png\' alt=\'*\'/> '.$itemshop['cost'].' золота</a></div>
</div>
<div class=\'line\'></div>';

}

echo '<div class=\'list\'>
  <li><a href=\'/shop/'.$complect['quality'].'/\'><img src=\'/images/icon/equip.png\' alt=\'*\'/> Комплекты</a></li>
  <li class=\'no_b\'><a href=\'/shop/\'><img src=\'/images/icon/equip.png\' alt=\'*\'/> Магазин снаряжения</a></li>
</div>';

include './system/f.php';

?>