<?php
define('_IN_JOHNCMS', 1);
$headmod = 'manager';
$textl='O`yingoh'; 
require_once("../incfiles/core.php");
require_once("../incfiles/head.php");
require_once("manfunc.php"); 

$q=mysql_query("select * from fman_clubs where id=$id;");
$a=mysql_fetch_array($q);
switch($act)
{
	default:
	echo"<h2 align='center'>O`yingoh</h2><br /><img src='img/stadium.png' />
	<div class='menu'>Nomi: <b>$a[stadion]</b></div>
	<div class='menu'>Shahar: <b>$a[city]</b></div>
	<div class='menu'>Jamoa: <b>$a[name]</b></div>
	<div class='menu'>Sig`imi: <b>".number_format($a[stadv],0,',',' ')."</b> o`rin</div>
	<div class='menu'>O`yingohni saqlash: $".number_format(($a[stadv]*20),0,',',' ')." virtual xaftada.</div>";
	if($club_id==$id && !$a[stad_ned])echo"<div class='gmenu'>[<a href='stad.php?id=$id&amp;act=rek'>qayta tamirlash</a>]</div>";
	
	if($a[stad_ned] && $club_id==$id)
	{
		echo"<div class='phdr'>Qurish</div>
		<div class='menu'>O`yingoh: ".number_format($a[stad_work],0,'.',' ')." o`rin</div>
		<div class='menu'>Ishlarning tugash vaqti $a[stad_ned] virtual xaftadan so`ng</div>";
	}
	break;
	
	case 'rek':
	if(!$_POST[submit])
	{
		echo"<h2 align='center'>O`yingohni qayta tamirlash $a[stadion]</h2>
		<form action='stad.php?id=$id&amp;act=rek' method='post'><div class='menu'>O`rinlar soni:<br/><select name='mest'>";
		for($i=1;$i<51;$i++)echo"<option value='$i'>".($i*1000)."</option>";
		echo"</select><br/>Qilinadigan ishlar:<br/><select name='vid'><option value='1'>qurish</option><option value='2'>buzish</option></select><br/>
		<input type='submit' name='submit' value='Qayta tamirlash'/></div>
		<div class='bmenu'>O`yingohni 1000 o`ringa qurish yoki buzish $2 mln turadi. O`yingohni maksimal sig`imi 200 ming o`rin. Bir virtual xaftada ishchilar 2000 o`rinni qurishlari yoki buzishlari mumkin.</div></form>";
	}
	else
	{
		$stoim=$_POST[mest]*2000000;
		if($dataclub[budj]<$stoim)$e="Sizda o`yingohda bu ishlarni bajarish uchun mablag` yetarli emas!";
		if(($dataclub[stadv]+($_POST[mest]*1000))>200000)$e="O`yingohning maksimal sig`imi 200 ming o`rin!";
		if($_POST[vid]==2)$_POST[mest]=0-$_POST[mest];
		if(($dataclub[stadv]+($_POST[mest]*1000))<500)$e="O`yingohning minimal sig`imi 500 o`rin!";
		if($e)echo"<div class='menu'>$e</div>"; else{
		$mest=$_POST[mest];
		mysql_query("update fman_clubs set stad_work=".($a[stadv]+($_POST[mest]*1000)).", stad_ned=".round($mest/2)." where id=$id");

		mysql_query("update fman_clubs set budj=".($dataclub[budj]-$stoim)." where id=$club_id");
		echo"<div class='menu'>O`yingohni qayta tamirlashga so`rov qabul qilindi! Ishlarning borishini o`yingoh sahifasida kuzating.</div>";}
	}

	echo"<div class='phdr'><a href='stad.php?id=$id'>O`yingoh $a[stadion]</a></div>";
	break;
}
echo"<div class='phdr'><a href='club.php?id=$id'>$a[name]</a><br/><a href='index.php'>Futbol menejer</a></div>";
require_once("../incfiles/end.php"); 
?>
