<?php
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';
$set['title']='Бармен онлайн';
include_once '../sys/inc/thead.php';
title();
aut();

if(!isset($user)){
  echo "Вы не зарегистрированы";
  include_once '../sys/inc/tfoot.php';
  break;
}

include_once 'inc/start.php';

			
echo "
<div class='".$diz['main']."'>

<img src='i/4.png' /> ".$bar_user['level']."
<img src='i/exp.png' /> ".$bar_user['exp']."
<img src='i/d.png' /> ".$bar_user['money']."
<br/><img src='i/bottle.png' />".$bar_user['alc']." ".nap($bar_user['alc'])."
<div class='".$diz['title2']."'>Мои коктейли</div>
";
$id=abs(intval($_GET['id']));
$total=mysql_result(mysql_query("SELECT COUNT(*) FROM `bar_zakaz` WHERE `id_u`='".$user_id."' AND `id`='".$id."'"),0);

if($total==0)
echo "Ошибка! Такого заказа нет!";
else
{
$arr=mysql_fetch_array(mysql_query("SELECT * FROM `bar_zakaz` WHERE `id_u`='".$user_id."' AND `id`='".$id."'"));

if(isset($_POST['submit']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `bar_coctails` WHERE `id_u`='".$user_id."' AND `act`!='2' AND `id_r`='".$arr['id_r']."'"),0)!=0){
	$exp=mysql_result(mysql_query("SELECT `exp` FROM `bar_recept` WHERE `id`='".$arr['id_r']."'"),0);
	
	mysql_query("UPDATE `bar_user` SET `money`=`money`+".(($bar_user['level']+1)*20).", `exp`=`exp`+".$exp." WHERE `id_u`='".$user_id."'");

	mysql_query("DELETE FROM `bar_zakaz` WHERE `id`='".$id."'");
	mysql_query("DELETE FROM `bar_coctails` WHERE `id_u`='".$user_id."' AND `id_r`='".$arr['id_r']."' LIMIT 1");
	bar_msg($diz['msg'],'Вы успешно продали коктейль!');
	echo "</div>";
ret($diz['ret'],'Мой бар','index.php');
exit;
	}

echo "Посeтитель ".($arr['bot']!=0 ? "<a href='profile.php?id=".$arr['bot']."'>".$arr['name']."</a>" : $arr['name'])." заказaл коктейль &quot;".mysql_result(mysql_query("SELECT `name` FROM `bar_recept` WHERE `id`='".$arr['id_r']."'"),0)."&quot;<br/>";

	if(mysql_result(mysql_query("SELECT COUNT(*) FROM `bar_coctails` WHERE `id_u`='".$user_id."' AND `act`!='2' AND `id_r`='".$arr['id_r']."'"),0)==0)
	echo "У вас нет такого коктейля=(";
	else
	echo "У вас в наличии ".mysql_result(mysql_query("SELECT COUNT(*) FROM `bar_coctails` WHERE `id_u`='".$user_id."' AND `act`!='2' AND `id_r`='".$arr['id_r']."'"),0)." коктейлей &quot;".mysql_result(mysql_query("SELECT `name` FROM `bar_coctails` WHERE `id_u`='".$user_id."' AND `id_r`='".$arr['id_r']."'"),0)."&quot;<br/><form method='post' action='view.zakaz.php?id=".$id."'><input type='submit' name='submit' value='Продать'/></form>";


}
   
echo "</div>";
ret($diz['ret'],'Мой бар','index.php');
 include_once '../sys/inc/tfoot.php';
?>
