<?

///TEHNIKA

if($ku['tehnika']>=100 AND $ku['tdlevel']==4)
{
mysql_query("UPDATE `kolhoz_user` SET `tdlevel` = '5' WHERE `id` = '$ku[id]'");
}
elseif($ku['tehnika']>=75 AND $ku['tdlevel']==3)
{
mysql_query("UPDATE `kolhoz_user` SET `tdlevel` = '4' WHERE `id` = '$ku[id]'");
}
elseif($ku['tehnika']>=50 AND $ku['tdlevel']==2)
{
mysql_query("UPDATE `kolhoz_user` SET `tdlevel` = '3' WHERE `id` = '$ku[id]'");
}
elseif($ku['tehnika']>=30 AND $ku['tdlevel']==1)
{
mysql_query("UPDATE `kolhoz_user` SET `tdlevel` = '2' WHERE `id` = '$ku[id]'");
}
elseif($ku['tehnika']>=10 AND $ku['tdlevel']==0)
{
mysql_query("UPDATE `kolhoz_user` SET `tdlevel` = '1' WHERE `id` = '$ku[id]'");
}
///SADOVOD
if($ku['sadovod']>=2000 AND $ku['sdlevel']==4)
{
mysql_query("UPDATE `kolhoz_user` SET `sdlevel` = '5' WHERE `id` = '$ku[id]'");
}
elseif($ku['sadovod']>=1000 AND $ku['sdlevel']==3)
{
mysql_query("UPDATE `kolhoz_user` SET `sdlevel` = '4' WHERE `id` = '$ku[id]'");
}
elseif($ku['sadovod']>=200 AND $ku['sdlevel']==2)
{
mysql_query("UPDATE `kolhoz_user` SET `sdlevel` = '3' WHERE `id` = '$ku[id]'");
}
elseif($ku['sadovod']>=50 AND $ku['sdlevel']==1)
{
mysql_query("UPDATE `kolhoz_user` SET `sdlevel` = '2' WHERE `id` = '$ku[id]'");
}
elseif($ku['sadovod']>=10 AND $ku['sdlevel']==0)
{
mysql_query("UPDATE `kolhoz_user` SET `sdlevel` = '1' WHERE `id` = '$ku[id]'");
}
///VODOLEY
if($ku['vodoley']>=2000 AND $ku['vdlevel']==4)
{
mysql_query("UPDATE `kolhoz_user` SET `vdlevel` = '5' WHERE `id` = '$ku[id]'");
}
elseif($ku['vodoley']>=1000 AND $ku['vdlevel']==3)
{
mysql_query("UPDATE `kolhoz_user` SET `vdlevel` = '4' WHERE `id` = '$ku[id]'");
}
elseif($ku['vodoley']>=200 AND $ku['vdlevel']==2)
{
mysql_query("UPDATE `kolhoz_user` SET `vdlevel` = '3' WHERE `id` = '$ku[id]'");
}
elseif($ku['vodoley']>=50 AND $ku['vdlevel']==1)
{
mysql_query("UPDATE `kolhoz_user` SET `vdlevel` = '2' WHERE `id` = '$ku[id]'");
}
elseif($ku['vodoley']>=10 AND $ku['vdlevel']==0)
{
mysql_query("UPDATE `kolhoz_user` SET `vdlevel` = '1' WHERE `id` = '$ku[id]'");
}
///AGRONOM
if($ku['agronom']>=2000 AND $ku['agdlevel']==4)
{
mysql_query("UPDATE `kolhoz_user` SET `agdlevel` = '5' WHERE `id` = '$ku[id]'");
}
elseif($ku['agronom']>=1000 AND $ku['agdlevel']==3)
{
mysql_query("UPDATE `kolhoz_user` SET `agdlevel` = '4' WHERE `id` = '$ku[id]'");
}
elseif($ku['agronom']>=200 AND $ku['agdlevel']==2)
{
mysql_query("UPDATE `kolhoz_user` SET `agdlevel` = '3' WHERE `id` = '$ku[id]'");
}
elseif($ku['agronom']>=50 AND $ku['agdlevel']==1)
{
mysql_query("UPDATE `kolhoz_user` SET `agdlevel` = '2' WHERE `id` = '$ku[id]'");
}
elseif($ku['agronom']>=10 AND $ku['agdlevel']==0)
{
mysql_query("UPDATE `kolhoz_user` SET `agdlevel` = '1' WHERE `id` = '$ku[id]'");
}
///gifter
$ku['gifter']=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_gifts` WHERE `id_kont` = '$ku[id]'"),0);
if($ku['gifter']>=30 AND $ku['gdlevel']==4)
{
mysql_query("UPDATE `kolhoz_user` SET `gdlevel` = '5' WHERE `id` = '$ku[id]'");
}
elseif($ku['gifter']>=20 AND $ku['gdlevel']==3)
{
mysql_query("UPDATE `kolhoz_user` SET `gdlevel` = '4' WHERE `id` = '$ku[id]'");
}
elseif($ku['gifter']>=10 AND $ku['gdlevel']==2)
{
mysql_query("UPDATE `kolhoz_user` SET `gdlevel` = '3' WHERE `id` = '$ku[id]'");
}
elseif($ku['gifter']>=5 AND $ku['gdlevel']==1)
{
mysql_query("UPDATE `kolhoz_user` SET `gdlevel` = '2' WHERE `id` = '$ku[id]'");
}
elseif($ku['gifter']>=1 AND $ku['gdlevel']==0)
{
mysql_query("UPDATE `kolhoz_user` SET `gdlevel` = '1' WHERE `id` = '$ku[id]'");
}
///botanik
if($ku['botanik']>=2000 AND $ku['bdlevel']==4)
{
mysql_query("UPDATE `kolhoz_user` SET `bdlevel` = '5' WHERE `id` = '$ku[id]'");
}
elseif($ku['botanik']>=1000 AND $ku['bdlevel']==3)
{
mysql_query("UPDATE `kolhoz_user` SET `bdlevel` = '4' WHERE `id` = '$ku[id]'");
}
elseif($ku['botanik']>=200 AND $ku['bdlevel']==2)
{
mysql_query("UPDATE `kolhoz_user` SET `bdlevel` = '3' WHERE `id` = '$ku[id]'");
}
elseif($ku['botanik']>=50 AND $ku['bdlevel']==1)
{
mysql_query("UPDATE `kolhoz_user` SET `bdlevel` = '2' WHERE `id` = '$ku[id]'");
}
elseif($ku['botanik']>=10 AND $ku['bdlevel']==0)
{
mysql_query("UPDATE `kolhoz_user` SET `bdlevel` = '1' WHERE `id` = '$ku[id]'");
}
$ku['planter']=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]'"),0);
///planter
if($ku['planter']>=10 AND $ku['pdlevel']==4)
{
mysql_query("UPDATE `kolhoz_user` SET `pdlevel` = '5' WHERE `id` = '$ku[id]'");
}
elseif($ku['planter']>=9 AND $ku['pdlevel']==3)
{
mysql_query("UPDATE `kolhoz_user` SET `pdlevel` = '4' WHERE `id` = '$ku[id]'");
}
elseif($ku['planter']>=8 AND $ku['pdlevel']==2)
{
mysql_query("UPDATE `kolhoz_user` SET `pdlevel` = '3' WHERE `id` = '$ku[id]'");
}
elseif($ku['planter']>=7 AND $ku['pdlevel']==1)
{
mysql_query("UPDATE `kolhoz_user` SET `pdlevel` = '2' WHERE `id` = '$ku[id]'");
}
elseif($ku['planter']>=6 AND $ku['pdlevel']==0)
{
mysql_query("UPDATE `kolhoz_user` SET `pdlevel` = '1' WHERE `id` = '$ku[id]'");
}
$ku['petplanter']=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_petground` WHERE `id_user` = '$ku[id]'"),0);
///petplanter
if($ku['petplanter']>=10 AND $ku['ppdlevel']==4)
{
mysql_query("UPDATE `kolhoz_user` SET `ppdlevel` = '5' WHERE `id` = '$ku[id]'");
}
elseif($ku['petplanter']>=9 AND $ku['ppdlevel']==3)
{
mysql_query("UPDATE `kolhoz_user` SET `ppdlevel` = '4' WHERE `id` = '$ku[id]'");
}
elseif($ku['petplanter']>=8 AND $ku['ppdlevel']==2)
{
mysql_query("UPDATE `kolhoz_user` SET `ppdlevel` = '3' WHERE `id` = '$ku[id]'");
}
elseif($ku['petplanter']>=7 AND $ku['ppdlevel']==1)
{
mysql_query("UPDATE `kolhoz_user` SET `ppdlevel` = '2' WHERE `id` = '$ku[id]'");
}
elseif($ku['petplanter']>=6 AND $ku['ppdlevel']==0)
{
mysql_query("UPDATE `kolhoz_user` SET `ppdlevel` = '1' WHERE `id` = '$ku[id]'");
}
$ku['pdpool']=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_pool` WHERE `id_user` = '$ku[id]'"),0);
///planter
if($ku['pdpool']>=25 AND $conf['pclevel']==4)
{
mysql_query("UPDATE `kolhoz_setting` SET `pclevel` = '5' WHERE `id_user` = '$ku[id]'");
}
elseif($ku['pdpool']>=17 AND $conf['pclevel']==3)
{
mysql_query("UPDATE `kolhoz_setting` SET `pclevel` = '4' WHERE `id_user` = '$ku[id]'");
}
elseif($ku['pdpool']>=12 AND $conf['pclevel']==2)
{
mysql_query("UPDATE `kolhoz_setting` SET `pclevel` = '3' WHERE `id_user` = '$ku[id]'");
}
elseif($ku['pdpool']>=8 AND $conf['pclevel']==1)
{
mysql_query("UPDATE `kolhoz_setting` SET `pclevel` = '2' WHERE `id_user` = '$ku[id]'");
}
elseif($ku['pdpool']>=5 AND $conf['pclevel']==0)
{
mysql_query("UPDATE `kolhoz_setting` SET `pclevel` = '1' WHERE `id_user` = '$ku[id]'");
}
///Рыбарь
if($conf['pool_fish_count']>=50000 AND $conf['pcclevel']==4)
{
mysql_query("UPDATE `kolhoz_setting` SET `pcclevel` = '5' WHERE `id_user` = '$ku[id]'");
}
elseif($conf['pool_fish_count']>=30000 AND $conf['pcclevel']==3)
{
mysql_query("UPDATE `kolhoz_setting` SET `pcclevel` = '4' WHERE `id_user` = '$ku[id]'");
}
elseif($conf['pool_fish_count']>=15000 AND $conf['pcclevel']==2)
{
mysql_query("UPDATE `kolhoz_setting` SET `pcclevel` = '3' WHERE `id_user` = '$ku[id]'");
}
elseif($conf['pool_fish_count']>=5000 AND $conf['pcclevel']==1)
{
mysql_query("UPDATE `kolhoz_setting` SET `pcclevel` = '2' WHERE `id_user` = '$ku[id]'");
}
elseif($conf['pool_fish_count']>=1000 AND $conf['pcclevel']==0)
{
mysql_query("UPDATE `kolhoz_setting` SET `pcclevel` = '1' WHERE `id_user` = '$ku[id]'");
}
///kormer
if($ku['kormer']>=2000 AND $ku['kdlevel']==4)
{
mysql_query("UPDATE `kolhoz_user` SET `kdlevel` = '5' WHERE `id` = '$ku[id]'");
}
elseif($ku['kormer']>=1000 AND $ku['kdlevel']==3)
{
mysql_query("UPDATE `kolhoz_user` SET `kdlevel` = '4' WHERE `id` = '$ku[id]'");
}
elseif($ku['kormer']>=200 AND $ku['kdlevel']==2)
{
mysql_query("UPDATE `kolhoz_user` SET `kdlevel` = '3' WHERE `id` = '$ku[id]'");
}
elseif($ku['kormer']>=50 AND $ku['kdlevel']==1)
{
mysql_query("UPDATE `kolhoz_user` SET `kdlevel` = '2' WHERE `id` = '$ku[id]'");
}
elseif($ku['kormer']>=10 AND $ku['kdlevel']==0)
{
mysql_query("UPDATE `kolhoz_user` SET `kdlevel` = '1' WHERE `id` = '$ku[id]'");
}
///pugach
if($ku['pugach']>=1000 AND $ku['pgdlevel']==4)
{
mysql_query("UPDATE `kolhoz_user` SET `pgdlevel` = '5' WHERE `id` = '$ku[id]'");
}
elseif($ku['pugach']>=200 AND $ku['pgdlevel']==3)
{
mysql_query("UPDATE `kolhoz_user` SET `pgdlevel` = '4' WHERE `id` = '$ku[id]'");
}
elseif($ku['pugach']>=50 AND $ku['pgdlevel']==2)
{
mysql_query("UPDATE `kolhoz_user` SET `pgdlevel` = '3' WHERE `id` = '$ku[id]'");
}
elseif($ku['pugach']>=10 AND $ku['pgdlevel']==1)
{
mysql_query("UPDATE `kolhoz_user` SET `pgdlevel` = '2' WHERE `id` = '$ku[id]'");
}
elseif($ku['pugach']>=2 AND $ku['pgdlevel']==0)
{
mysql_query("UPDATE `kolhoz_user` SET `pgdlevel` = '1' WHERE `id` = '$ku[id]'");
}
///БОЕЦ
if($conf['arena_win']>=4000 AND $conf['arena_dost']==4)
{
mysql_query("UPDATE `kolhoz_setting` SET `arena_dost` = '5' WHERE `id_user` = '$ku[id]'");
}
elseif($conf['arena_win']>=1000 AND $conf['arena_dost']==3)
{
mysql_query("UPDATE `kolhoz_setting` SET `arena_dost` = '4' WHERE `id_user` = '$ku[id]'");
}
elseif($conf['arena_win']>=250 AND $conf['arena_dost']==2)
{
mysql_query("UPDATE `kolhoz_setting` SET `arena_dost` = '3' WHERE `id_user` = '$ku[id]'");
}
elseif($conf['arena_win']>=50 AND $conf['arena_dost']==1)
{
mysql_query("UPDATE `kolhoz_setting` SET `arena_dost` = '2' WHERE `id_user` = '$ku[id]'");
}
elseif($conf['arena_win']>=25 AND $conf['arena_dost']==0)
{
mysql_query("UPDATE `kolhoz_setting` SET `arena_dost` = '1' WHERE `id_user` = '$ku[id]'");
}
///nanimatel
if($conf['garden_dost_count']>=3000 AND $conf['garden_dost']==4)
{
mysql_query("UPDATE `kolhoz_setting` SET `garden_dost` = '5' WHERE `id_user` = '$ku[id]'");
}
elseif($conf['garden_dost_count']>=1000 AND $conf['garden_dost']==3)
{
mysql_query("UPDATE `kolhoz_setting` SET `garden_dost` = '4' WHERE `id_user` = '$ku[id]'");
}
elseif($conf['garden_dost_count']>=200 AND $conf['garden_dost']==2)
{
mysql_query("UPDATE `kolhoz_setting` SET `garden_dost` = '3' WHERE `id_user` = '$ku[id]'");
}
elseif($conf['garden_dost_count']>=50 AND $conf['garden_dost']==1)
{
mysql_query("UPDATE `kolhoz_setting` SET `garden_dost` = '2' WHERE `id_user` = '$ku[id]'");
}
elseif($conf['garden_dost_count']>=2 AND $conf['garden_dost']==0)
{
mysql_query("UPDATE `kolhoz_setting` SET `garden_dost` = '1' WHERE `id_user` = '$ku[id]'");
}
//kulinar
if($conf['recip_dost_count']>=5000 AND $conf['recip_dost']==4)
{
mysql_query("UPDATE `kolhoz_setting` SET `recip_dost` = '5' WHERE `id_user` = '$ku[id]'");
}
elseif($conf['recip_dost_count']>=4000 AND $conf['recip_dost']==3)
{
mysql_query("UPDATE `kolhoz_setting` SET `recip_dost` = '4' WHERE `id_user` = '$ku[id]'");
}
elseif($conf['recip_dost_count']>=3000 AND $conf['recip_dost']==2)
{
mysql_query("UPDATE `kolhoz_setting` SET `recip_dost` = '3' WHERE `id_user` = '$ku[id]'");
}
elseif($conf['recip_dost_count']>=2000 AND $conf['recip_dost']==1)
{
mysql_query("UPDATE `kolhoz_setting` SET `recip_dost` = '2' WHERE `id_user` = '$ku[id]'");
}
elseif($conf['recip_dost_count']>=1000 AND $conf['recip_dost']==0)
{
mysql_query("UPDATE `kolhoz_setting` SET `recip_dost` = '1' WHERE `id_user` = '$ku[id]'");
}
//zagotovshik
$ku['planter']=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_polka2` WHERE `id_user` = '$ku[id]'"),0);

if($ku['planter']>=18 AND $conf['zagotov_dost']==4)
{
mysql_query("UPDATE `kolhoz_setting` SET `zagotov_dost` = '5' WHERE `id_user` = '$ku[id]'");
}
elseif($ku['planter']>=14 AND $conf['zagotov_dost']==3)
{
mysql_query("UPDATE `kolhoz_setting` SET `zagotov_dost` = '4' WHERE `id_user` = '$ku[id]'");
}
elseif($ku['planter']>=11 AND $conf['zagotov_dost']==2)
{
mysql_query("UPDATE `kolhoz_setting` SET `zagotov_dost` = '3' WHERE `id_user` = '$ku[id]'");
}
elseif($ku['planter']>=8 AND $conf['zagotov_dost']==1)
{
mysql_query("UPDATE `kolhoz_setting` SET `zagotov_dost` = '2' WHERE `id_user` = '$ku[id]'");
}
elseif($ku['planter']>=6 AND $conf['zagotov_dost']==0)
{
mysql_query("UPDATE `kolhoz_setting` SET `zagotov_dost` = '1' WHERE `id_user` = '$ku[id]'");
}
//Сборщик сюрпризов

if($conf['surprize_dost_count']>=1000 AND $conf['surprize_dost']==4)
{
mysql_query("UPDATE `kolhoz_setting` SET `surprize_dost` = '5' WHERE `id_user` = '$ku[id]'");
}
elseif($conf['surprize_dost_count']>=500 AND $conf['surprize_dost']==3)
{
mysql_query("UPDATE `kolhoz_setting` SET `surprize_dost` = '4' WHERE `id_user` = '$ku[id]'");
}
elseif($conf['surprize_dost_count']>=250 AND $conf['surprize_dost']==2)
{
mysql_query("UPDATE `kolhoz_setting` SET `surprize_dost` = '3' WHERE `id_user` = '$ku[id]'");
}
elseif($conf['surprize_dost_count']>=100 AND $conf['surprize_dost']==1)
{
mysql_query("UPDATE `kolhoz_setting` SET `surprize_dost` = '2' WHERE `id_user` = '$ku[id]'");
}
elseif($conf['surprize_dost_count']>=20 AND $conf['surprize_dost']==0)
{
mysql_query("UPDATE `kolhoz_setting` SET `surprize_dost` = '1' WHERE `id_user` = '$ku[id]'");
}

$count=$ku['tdlevel']+$ku['sdlevel']+$ku['vdlevel']+$ku['agdlevel']+$ku['gdlevel']+$ku['bdlevel']+$ku['pdlevel']+$ku['ppdlevel']+$ku['kdlevel']+$ku['pgdlevel']+$conf['garden_dost']+$conf['zagotov_dost']+$conf['recip_dost']+$conf['arena_dost']+$conf['pclevel']+$conf['pcclevel'];
if($count!==$ku['dostig'])mysql_query("UPDATE `kolhoz_user` SET `dostig` = '$count' WHERE `id` = '$ku[id]'");
?>