<?php
define('_IN_JOHNCMS', 1);
$headmod = 'manager';
$textl='Игрок';
require_once("../incfiles/core.php");
require_once("../incfiles/head.php");

if($rights>=7)
{
	if($id){$q=mysql_query("select * from fman_players where id=$id;");
	$a=mysql_fetch_array($q);
	$p="id=".$id;}
	if(!$_POST[submit])
	{
		echo"<h2 align='center'>"; if(!$id)echo"Добавление"; else echo"Изменение"; echo" игрока</h2><form action='admplayer.php?".$p."' method='post'><div class='menu'>Имя:<br/><input type='text' name='name' value='$a[name]'/><br/>
		ID команды:<br/><input type='text' name='team_id' value='$a[team_id]' size='6'/><br/>
		Амплуа:<br/><select name='pos'><option value='1'";
		$a[pos]=$a[ampl]; if($a[pos]==1)echo" selected='selected'"; echo">В</option>
		<option value='2'"; if($a[pos]==2)echo" selected='selected'"; echo">ЛЗ</option>
		<option value='3'"; if($a[pos]==3)echo" selected='selected'"; echo">ЦЗ</option>
		<option value='4'"; if($a[pos]==4)echo" selected='selected'"; echo">ПЗ</option>
		<option value='5'"; if($a[pos]==5)echo" selected='selected'"; echo">ОП</option>
		<option value='6'"; if($a[pos]==6)echo" selected='selected'"; echo">ЛП</option>
		<option value='7'"; if($a[pos]==7)echo" selected='selected'"; echo">ЦП</option>
		<option value='8'"; if($a[pos]==8)echo" selected='selected'"; echo">ПП</option>
		<option value='9'"; if($a[pos]==9)echo" selected='selected'"; echo">АП</option>
		<option value='10'"; if($a[pos]==10)echo" selected='selected'"; echo">Н</option></select><br/>
		Talent (1-20):<br/><input type='text' name='rait' value='$a[rait]' size='6'/><br/>
		Photo URL:<br/><input type='text' name='foto' value='$a[foto]'/><br/>
		Age:<br/><input type='text' name='age' value='$a[age]' size='6'/><br/>
		Height (cm):<br/><input type='text' name='height' value='$a[height]' size='6'/><br/>
		Nationality:<br/><input type='text' name='nationality' value='$a[nationality]' size='6'/><br/>"; if($id)echo"<input type='checkbox' name='del' value='1'/> удалить игрока<br/>"; echo"<input type='submit' name='submit' value='Сохранить'/></div></form>";
	}
	else
	{
		$team_id=$_POST[team_id]; $name=$_POST[name]; $rait=$_POST[rait];
		$pos=$_POST[pos];
		if($team_id>=1 && $name && $rait>=1 && $pos>=1){
		if($id)mysql_query("update fman_players set team_id=$team_id, name='$name', rait=$rait, pos=$pos, ampl=$pos, foto='$_POST[foto]', age='$_POST[age]', height='$_POST[height]', nationality='$_POST[nationality]' where id=$id"); else mysql_query("insert into fman_players set team_id=$team_id, name='$name', rait=$rait, travm=0, trans=0, cena=0, pos=$pos, ampl=$pos, foto='$_POST[foto]', age='$_POST[age]', height='$_POST[height]', nationality='$_POST[nationality]', forma=6, ust=6, nast=6, u=0, vyn=0, drib=0, pas=0, ig=0, otb=0, priem=0, f=0, toch=0, gk=0, ball=0");
		if($_POST[del]==1)mysql_query("delete from fman_players where id=$id;");
		echo"<div class='menu'>Действие успешно выполнено!<br/><a href='admplayer.php?time=".time()."&amp;".$p."'>Назад</a></div>";}
	}
	echo"<div class='phdr'>"; if($id)echo"<a href='admplayer.php?'>Создать нового игрока</a><br/>"; echo"<a href='index.php?'>Фут.менеджер</a></div>";
} 
require_once("../incfiles/end.php"); ?>
