<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru">

<head><meta http-equiv='content-type' content='application/xhtml+xml; charset=windows-1251'/>
<link rel="shortcut icon" href="ico.ico" type="image/x-icon" />
<title>Начальник новобранцев</title>
<link rel="stylesheet" href="../styleN.css" type="text/css" />
</head>
<body>

<?
$idIT=$_GET['idIT'];
$itNA=$_GET['itNA'];
$itCO=$_GET['itCO'];
$items=mysql_query("SELECT * FROM bank WHERE B_ID_USERS=\"$NICK\"");
echo "<img src=\"img/al.png\"> <a href=\"game.php?NICK=$NICK&pass=$pass\">в игру</a><br/><img src=\"img/ar.png\"> <a href=\"game.php?NICK=$NICK&pass=$pass&speak=bankir_1\">назад</a><br/>".'выберите предмет который хотите забрать из банка<br/>';
$items3=mysql_query("SELECT * FROM bank WHERE B_IL_ID=\"$idIT\"");
while($items4=mysql_fetch_assoc($items3)){

if(mysql_num_rows($items3)==0){
if(isset($idIT)){echo"в банке нету такого предмета";die;}}

if($items4[B_IL_COUNT]>1){echo"введите кол-во:
<br/>
<form action=\"game.php\" method=\"GET\">
<INPUT NAME=\"NICK\" VALUE=\"$NICK\" type=\"hidden\">
<INPUT NAME=\"pass\" VALUE=\"$pass\" type=\"hidden\">
<INPUT NAME=\"speak\" VALUE=\"bankir_1\" type=\"hidden\">
<INPUT NAME=\"id\" VALUE=\"bankir_1_zab\" type=\"hidden\">
<INPUT NAME=\"idIT\" VALUE=\"$idIT\" type=\"hidden\">
<INPUT NAME=\"itNA\" VALUE=\"$itNA\" type=\"hidden\">
<INPUT NAME=\"itCO\" maxlength=\"10\" size=\"3\"><br/>
<INPUT type=\"submit\" value=\"забрать\">
</form>
";
if($itCO==0){
if(isset($itCO)){
echo"<div class=\"menu\">
<div class=\"line\"></div>
<div class=\"footto\">

<div class=\"foot\"><center><b>кол-во не может быть равно 0</b></center></div>
</div><div class=\"line\"></div>";die;}}
if($itCO<=$items4[B_IL_COUNT]){
if(isset($itCO)){echo"<div class=\"menu\">
<div class=\"line\"></div>
<div class=\"footto\">

<div class=\"foot\"><center><b>вы успешно забрали  $items4[B_IT_NAME] $itCO шт. из банка</b></center></div>
</div><div class=\"line\"></div>";
$pr_IT1=mysql_query("SELECT * FROM inv WHERE IL_NAME=\"$items4[B_IT_NAME]\" AND ID_USERS=\"$NICK\"");

if(mysql_num_rows($pr_IT1)>0){

$ccX2=$items4[B_IL_COUNT]-$itCO;
if($items4[B_IL_COUNT]>$itCO){
while($PR_IT2=mysql_fetch_assoc($pr_IT1)){
$xxs_1=$PR_IT2[IL_COUNT];
$NAME1=$PR_IT2[IL_NAME];
}
$ccXs=$xxs_1+$itCO;

$UPDATE1=mysql_query("UPDATE bank SET B_IL_COUNT=\"$ccX2\" WHERE B_IT_NAME=\"$NAME1\" AND B_ID_USERS=\"$NICK\"");
$UPDATE2=mysql_query("UPDATE inv SET IL_COUNT=\"$ccXs\" WHERE IL_NAME=\"$items4[B_IT_NAME]\" AND ID_USERS=\"$NICK\"");
}


}
$pr_IT111w=mysql_query("SELECT * FROM inv WHERE ID_IL=\"$idIT\" AND ID_USERS=\"$NICK\"");
while($PR_IT222W=mysql_fetch_assoc($pr_IT111w)){
$NAME1aw=$PR_IT222W[B_IT_NAME];
}
if($items4[B_IL_COUNT]==$itCO AND mysql_num_rows($pr_IT111w)>0){
if(mysql_num_rows($items3)==0){
if(isset($idIT)){echo"в банке нету такого предмета";die;}}


$pr_IT111=mysql_query("SELECT * FROM bank WHERE B_IL_ID=\"$idIT\" AND B_ID_USERS=\"$NICK\"");
while($PR_IT222=mysql_fetch_assoc($pr_IT111)){
$NAME1a=$PR_IT222[B_IT_NAME];
}
$pr_IT1111=mysql_query("SELECT * FROM inv WHERE IL_NAME=\"$NAME1a\" AND ID_USERS=\"$NICK\"");
while($PR_IT2222=mysql_fetch_assoc($pr_IT1111)){
$NAME1b=$PR_IT2222[IL_NAME];
$COUNt=$PR_IT2222[IL_COUNT];
}

$ccXsW=$COUNt+$itCO;

$UPDATE1=mysql_query("UPDATE inv SET IL_COUNT=\"$ccXsW\" WHERE IL_NAME=\"$NAME1a\" AND ID_USERS=\"$NICK\"");
$DELETE=mysql_query("DELETE FROM bank WHERE B_IL_ID=\"$idIT\" AND B_ID_USERS=\"$NICK\"");
}

//
if($itCO<$items4[B_IL_COUNT] AND mysql_num_rows($pr_IT111w)==0){
$INSERT=mysql_query("INSERT INTO inv (IL_LVL,IL_NAME,IL_CLASS,IL_ALL_CLASS,IL_KEY,IL_COST,IL_MIN_DMG,IL_MAX_DMG,IL_MAGD_MIN,IL_MAGD_MAX,IL_DEF,IL_STR,IL_DEX,IL_INT,IL_SPD,IL_MIN_PROCH,IL_MAX_PROCH,IL_TREBUET,IL_IMAGE,IL_SRC,ID_USERS,IL_SHANS_BLOCK,IL_UPGRADE,IL_COUNT) VALUES ('$items4[B_IL_LVL]','$items4[B_IT_NAME]','$items4[B_IL_CLASS]','$items4[B_IL_ALL_CLASS]','$items4[B_IL_KEY]','$items4[B_IL_COST]','$items4[B_IL_MIN_DMG]','$items4[B_IL_MAX_DMG]','$items4[B_IL_MAGD_MIN]','$items4[B_IL_MAGD_MAX]','$items4[B_IL_DEF]','$items4[B_IL_STR]','$items4[B_IL_DEX]','$items4[B_IL_INT]','$items4[B_IL_SPD]','$items4[B_IL_MIN_PROCH]','$items4[B_IL_MAX_PROCH]','$items4[B_IL_TREBUET]','$items4[B_IL_IMAGE]','$items4[B_IL_SRC]','$items4[B_ID_USERS]','$items4[B_IL_SHANS_BLOCK]','$items4[B_IL_UPGRADE]','$itCO')");
$ccX2=$items4[B_IL_COUNT]-$itCO;
$UPDATE2=mysql_query("UPDATE bank SET B_IL_COUNT=\"$ccX2\" WHERE B_IL_ID=\"$idIT\" AND B_ID_USERS=\"$NICK\"");




}
}}
if($itCO>$items4[B_IL_COUNT]){
if(isset($itCO)){echo"<div class=\"menu\">
<div class=\"line\"></div>
<div class=\"footto\">

<div class=\"foot\"><center><b>в банке нету такого кол-ва $items4[B_IT_NAME]</b></center></div>
</div><div class=\"line\"></div>";}}
}

}




while($items2=mysql_fetch_assoc($items)){

if($items2[B_IL_COUNT]==1 AND isset($idIT)){
if(mysql_num_rows($items3)==0){
if(isset($idIT)){echo"в банке нету такого предмета";die;}}




###ТУТ ПРОВЕРКА ЕСЛИ У ИГРОКА ЕСТЬ ТАКОЙ ПРЕДМЕТ И ОН НЕ ПОПАДАЕТ ПОД КАТЕГОРИЮ ТО ОБНОВЛЯЕМ КОЛ_ВО
#ЗАВТРА ДЕЛАТЬ ТУТ НЕ СДЕЛАННО
$ITMSpr=mysql_query("SELECT * FROM inv WHERE IL_NAME=\"$items2[B_IT_NAME]\" AND ID_USERS=\"$NICK\"");
if($items2[B_IL_COUNT]==1 AND isset($idIT) AND $items2[IL_ALL_CLASS]!='weapon' AND $items2[IL_ALL_CLASS]!='armor' AND $items2[IL_CLASS]!='quests' AND mysql_num_rows($ITMSpr)>0){


$xxg1=mysql_query("SELECT * FROM inv WHERE IL_NAME=\"$items2[B_IT_NAME]\" AND ID_USERS=\"$NICK\"");
while($xxg2=mysql_fetch_assoc($xxg1)){$ccX=$xxg2[IL_COUNT]+1;}
echo"<div class=\"menu\">
<div class=\"line\"></div>
<div class=\"footto\">

<div class=\"foot\"><center><b>вы успешно забрали предмет из банка $items2[B_IT_NAME]</b></center></div>
</div><div class=\"line\"></div>";
$UPDATE=mysql_query("UPDATE inv SET IL_COUNT=\"$ccX\" WHERE IL_NAME=\"$items2[B_IT_NAME]\" AND ID_USERS=\"$NICK\"");
$DELETEq=mysql_query("DELETE FROM bank  WHERE B_IL_ID=\"$idIT\" AND B_ID_USERS=\"$NICK\"");
}
###ТУТ ПРОВЕРКА ЕСЛИ В БАНКЕ НЕТУ ТАКОГО ПРЕДМЕТА И ОН НЕ ПОПАДАЕТ ПОД КАТЕГОРИЮ ТО ДОБАВЛЯЕМ ЕГО В БАНК
if($items2[B_IL_COUNT]==1 AND isset($idIT) AND $items2[IL_ALL_CLASS]!='weapon' AND $items2[IL_ALL_CLASS]!='armor' AND $items2[IL_CLASS]!='quests' AND mysql_num_rows($ITMSpr)==0){
echo"<div class=\"menu\">
<div class=\"line\"></div>
<div class=\"footto\">

<div class=\"foot\"><center><b>вы успешно забрали предмет из банка $items2[IL_NAME]</b></center></div>
</div><div class=\"line\"></div>";
$DELETE=mysql_query("DELETE FROM bank  WHERE B_IL_ID=\"$idIT\" AND B_ID_USERS=\"$NICK\"");
$INSERT=mysql_query("INSERT INTO inv (IL_LVL,IL_NAME,IL_CLASS,IL_ALL_CLASS,IL_KEY,IL_COST,IL_MIN_DMG,IL_MAX_DMG,IL_MAGD_MIN,IL_MAGD_MAX,IL_DEF,IL_STR,IL_DEX,IL_INT,IL_SPD,IL_MIN_PROCH,IL_MAX_PROCH,IL_TREBUET,IL_IMAGE,IL_SRC,ID_USERS,IL_SHANS_BLOCK,IL_UPGRADE,IL_COUNT) VALUES ('$items2[B_IL_LVL]','$items2[B_IT_NAME]','$items2[B_IL_CLASS]','$items2[B_IL_ALL_CLASS]','$items2[B_IL_KEY]','$items2[B_IL_COST]','$items2[B_IL_MIN_DMG]','$items2[B_IL_MAX_DMG]','$items2[B_IL_MAGD_MIN]','$items2[B_IL_MAGD_MAX]','$items2[B_IL_DEF]','$items2[B_IL_STR]','$items2[B_IL_DEX]','$items2[B_IL_INT]','$items2[B_IL_SPD]','$items2[B_IL_MIN_PROCH]','$items2[B_IL_MAX_PROCH]','$items2[B_IL_TREBUET]','$items2[B_IL_IMAGE]','$items2[B_IL_SRC]','$items2[B_ID_USERS]','$items2[B_IL_SHANS_BLOCK]','$items2[B_IL_UPGRADE]','1')");//$DELETE=mysql_query("DELETE FROM inv WHERE ID_IL=\"$idIT\" AND ID_USERS=\"$NICK\"");
}



if($items2[IL_COUNT]==1 AND isset($idIT) AND $items2[IL_ALL_CLASS]=='weapon' AND $items2[IL_ALL_CLASS]=='armor' AND $items2[IL_CLASS]=='quests'){
$itemsX=mysql_query("SELECT * FROM inv WHERE ID_IL=\"$idIT\" AND ID_USERS=\"$NICK\"");
$itemsXX=mysql_fetch_assoc($itemsX);
echo"<div class=\"menu\">
<div class=\"line\"></div>
<div class=\"footto\">

<div class=\"foot\"><center><b>вы успешно забрали предмет из банка $itemsXX[B_IT_NAME]</b></center></div>
</div><div class=\"line\"></div>";
//$INSERT=mysql_query("INSERT INTO bank (B_IL_LVL,B_IT_NAME,B_IL_CLASS,B_IL_ALL_CLASS,B_IL_KEY,B_IL_COST,B_IL_MIN_DMG,B_IL_MAX_DMG,B_IL_MAGD_MIN,B_IL_MAGD_MAX,B_IL_DEF,B_IL_STR,B_IL_DEX,B_IL_INT,B_IL_SPD,B_IL_MIN_PROCH,B_IL_MAX_PROCH,B_IL_TREBUET,B_IL_IMAGE,B_IL_SRC,B_ID_USERS,B_IL_SHANS_BLOCK,B_IL_UPGRADE,B_IL_COUNT) VALUES ('$items2[IL_LVL]','$items2[IL_NAME]','$items2[IL_CLASS]','$items2[IL_ALL_CLASS]','$items2[IL_KEY]','$items2[IL_COST]','$items2[IL_MIN_DMG]','$items2[IL_MAX_DMG]','$items2[IL_MAGD_MIN]','$items2[IL_MAGD_MAX]','$items2[IL_DEF]','$items2[IL_STR]','$items2[IL_DEX]','$items2[IL_INT]','$items2[IL_SPD]','$items2[IL_MIN_PROCH]','$items2[IL_MAX_PROCH]','$items2[IL_TREBUET]','$items2[IL_IMAGE]','$items2[IL_SRC]','$items2[ID_USERS]','$items2[IL_SHANS_BLOCK]','$items2[IL_UPGRADE]','$items2[IL_COUNT]')");
//$DELETE=mysql_query("DELETE FROM inv WHERE ID_IL=\"$idIT\" AND ID_USERS=\"$NICK\"");
}
die;}

if(!isset($idIT)){echo "<a href=\"game.php?NICK=$NICK&pass=$pass&speak=bankir_1&id=bankir_1_zab&idIT=$items2[B_IL_ID]&itNA=$items2[B_IL_KEY]\">".$items2[B_IT_NAME]." <font color=\"lime\">($items2[B_IL_COUNT] шт.)</font></a><br/>";
}}
die;
?>
