<?php




define('_IN_JOHNCMS', 1);
$headmod = 'manager';
$textl='Trasfer bozori'; require_once("../incfiles/core.php");
require_once("../incfiles/head.php");
require_once("manfunc.php");
switch($act){
default:
 $gconf=mysql_fetch_array(mysql_query("SELECT * FROM `manager`"));
if($gconf[0]['open']!=1){
$q=mysql_query("select * from fman_players where trans=1 order by trans_time asc limit $start,$kmess;");
echo"<div class='phdr' align='center'>Transferlar</div>";
$qr=mysql_query("SELECT COUNT(*) FROM `fman_players` WHERE `trans`='1';");
$total=mysql_result($qr,0);
	echo'<table class="table" width="100%" cellspacing="1" cellpadding="4"><tbody>
		<tr class="un_table" align="center">
		<td width="70%"><b>Futbolchi</b></td>
		<td width="15%"><b>Narxi</b></td>
		<td width="15%"><b>Tugash vaqti</b></td></tr>';
		$i=1;
while($a=mysql_fetch_array($q)){

if(!$a[team_id] || $a[team_id]!=$club_id){
	echo $i % 2 ? '<tr class="list1">' : '<tr class="list2">';
			echo"<td align='left'><a href='player.php?id=$a[id]'>$a[name]</a> [".strtr($a[ampl],array(1=>'D',2=>'CHh',3=>'Mh',4=>'Yh',5=>'Tyh',6=>'CHyh',7=>'Myh',8=>'O`yh',9=>'Hyh',10=>'H'))."]";
			echo'<div class="sub">Yoshi: '.$a['age'].'; Bo\'yi: '.$a['height'].'sm<br />
			Iqtidori: '.$a['rait'].'</div></td>';
			echo"
			<td align='center'>".number_format($a[cena],0,'.',' ')."$</td>
			<td align='center'>".functions::display_date($a[trans_time])."</td>
			</tr>";
++$i;
}}
echo"</table>";
echo '<div class="bmenu">Hammasi: ' . $total . '</div>';
if ($total > $kmess) {
echo '<div class="topmenu">' . functions::display_pagination('trans.php?', $start, $total, $kmess) . '</div>' .
'<form action="trans.php?" method="post"><p>' .
'<input type="text" name="page" size="2"/>' .
'<input type="submit" value="' . $lng['to_page'] . ' &gt;&gt;"/>' .
'</p></form>';}
}else{echo '<div class="msg">Transfer bozori adminstrator tomonidan yopilgan!</div>';};
break;

case 'buy':
$qms=mysql_query("select id from fman_matches where time<$realtime and end=0;");
if($qms)$cums=mysql_num_rows($qms);
if(!$cums){
echo"<h2 align='center'>Sotib olish</h2>";
$q=mysql_query("select * from fman_players where id=$id;");
$a=mysql_fetch_array($q);
if($dataclub[budj]<$a[cena])echo"<div class='menu'>Sizda bu o`yinchini sotib olish uchun mablag` yetishmaydi!</div>";

if($dataclub[buy_count]>=2)echo"<div class='menu'>Bir virtual haftada 2 tadan ortiq o`yinchi sotib olish mumkin emas!</div>";
if($club_id && $dataclub[budj]>=$a[cena] && $a[trans]==1 && $dataclub[buy_count]<2){
if(!$_GET[yes]){
echo"<div class='menu'>Siz <a href='player.php?id=$a[id]'>$a[name]</a> ni sotib olishga ishonchingiz komilmi? U sizga   <b>$".$a[cena]."</b> tushadi.<br/>
<form action='trans.php?id=$id&amp;act=buy&amp;yes=yes' method='post'>
<input type='submit' value='Sotib olish'/></form></div>";}else{mysql_query("update `fman_players` set `team_id`='$club_id', `trans`='0', `cena`='0' where `id`='$id'");
$s1=$dataclub[budj]-$a[cena]; $j1=$dataclub[buy_count]+1;
mysql_query("update `fman_clubs` set `budj`='$s1', buy_count='$j1' where `id`='$club_id'");


if($a[team_id]){
$qt=mysql_query("select * from fman_clubs where id=$a[team_id];");
$tdata=mysql_fetch_array($qt);
zamena($tdata,$a);
$qu=mysql_query("select name from users where id=$tdata[user_id];");
$udata=mysql_fetch_array($qu);
$s2=$tdata[budj]+$a[cena];
mysql_query("update `fman_clubs` set `budj`='$s2' where `id`='$a[team_id]'");
$text='O`yinchi <b>'.$a[name].'</b> sizning jamoangizdan <a href="/man/club.php?id='.$club_id.'">'.$club_name.'</a> ga o`tdi  <b>$'.$a[cena].'</b>';
mysql_query("insert into `privat` set `user`='$udata[name]', `text`='$text', `time`='$realtime', `author`='Futbol Menejer', `type`='in', `chit`='no', `temka`='".$a[name]." jamoani tark etdi'");}
mysql_query("insert into fman_news set time=$realtime, pl_id=$a[id], name='$a[name]', id1='$a[team_id]', id2=$club_id, cena='$a[cena]'");
echo"<div class='menu'>Siz o'yinchi $a[name] ni $".$a[cena]." ga sotib oldingiz!</div>
<div class='phdr'><a href='list-of-players.php?id=$club_id'>Mening jamoam o'yinchlari ro'yxati</a></div>";
}}
echo"<div class='phdr'><a href='trans.php'>Transferlar</a></div>";}else echo"<div class='menu'>O`yin bo`layotgan vaqtda transfer bozorida ish bajarish taqiqlanadi. O`yinni tugashini kuting.</div>";
break;
}




echo"<div class='phdr'><a href='index.php'>Futbol menejer</a></div>";
require_once("../incfiles/end.php"); ?>