<?
$time=time();
include_once '../inc/start_sess.php';
$x=mysql_query("SELECT * FROM `kolhoz_user` WHERE `worker4` = '4' AND `worker4_time` = '$time' ");
while($ku=mysql_fetch_array($x))
{
include_once '../inc/functions.php';
include_once '../inc/tehnika.php';
/////вскопать//////
$count1=6;
$count1=floor($ku['dostig']/5)+$count1;
$count1=floor($ku['cook_mas']/500)+$count1;
if(isset($flowerbed_act))$count1=$count1+$flowerbed_act;
$time_rub=floor(86400/$count1);
$time1=$time-$ku['time_obmen'];
$col_rub=floor($time1/$time_rub);
if($col_rub>$count1)$col_rub=$count1;
if($ku['worker4_use']==$time)
{
if($col_rub>0 AND mysql_result) 
{
$need_mcr=1000*$col_rub;
if($ku['money']>=$need_mcr)
{
if($col_rub>=$count1)
{
mysql_query("UPDATE `kolhoz_user` SET `time_obmen` = '$time', `rubies` = '".($ku['rubies']+$col_rub)."', `money` = '".($ku['money']-$need_mcr)."' WHERE `id` = '$ku[id]'");
}
else mysql_query("UPDATE `kolhoz_user` SET `time_obmen` = '".($ku['time_obmen']+($col_rub*$time_rub))."', `rubies` = '".($ku['rubies']+$col_rub)."', `money` = '".($ku['money']-$need_mcr)."' WHERE `id` = '$ku[id]'");
}
else $_SESSION['no_money']=$need_mcr-$ku['money'];

echo"<div class='feedback'><ul class='feedbackPanel'><li class='feedbackPanelINFO'><span class='feedbackPanelINFO'>
<img width=\"16\" height=\"16\" src=\"images/icons/worker".$ku['worker3'].".png\" alt=\"\"> Работник ".$namew4." обменял $col_rub рубина
</span></li></ul></div>";
}
$timee=3600;
mysql_query("UPDATE `kolhoz_user` SET `worker4_use` = '".($time+$timee)."' WHERE `id` = '$ku[id]'");
}

}
?>