<?php
include_once '../../sys/inc/start.php';
include_once '../../sys/inc/compress.php';
include_once '../../sys/inc/sess.php';
include_once '../../sys/inc/home.php';
include_once '../../sys/inc/settings.php';
include_once '../../sys/inc/db_connect.php';
include_once '../../sys/inc/ipua.php';
include_once '../../sys/inc/fnc.php';
include_once '../../sys/inc/user.php';
only_reg();

$action=htmlspecialchars(trim($_GET['a']));
switch ($action){
default:
if (isset($_GET['id']))$id['id']=intval($_GET['id']);
$id=mysql_fetch_array(mysql_query("SELECT * FROM `inter_pal` WHERE `id`='".$id['id']."'"));
$titles='Приемная';
include_once 'head.php';


if (isset($_GET['pac'])&&$id['pac']==0&&$id['id_user']==$user['id'])
{
$inter_pac=mysql_fetch_array(mysql_query("SELECT * FROM `inter_pac` WHERE `id`='".intval($_GET['pac'])."'"));
if($inter_user['uroven']<$inter_pac['urov'])header("Location: index.php?");
mysql_query("UPDATE `inter_pal` SET `pac` = '".intval($_GET['pac'])."', `time` = '".(60*$inter_pac['time']+time())."', `time_dop` = '".(60*5+time())."' WHERE `id` = '".$id['id']."' LIMIT 1");
mysql_query("UPDATE `inter` SET `monet` = '".($inter_user['monet']-$inter_pac['cena'])."' WHERE `id_user` = '".$user['id']."' LIMIT 1");
header("Location: index.php?vipolneno");
}


/////////
function sictime($timediff){
$oneMinute=60; 
$oneHour=60*60; 
$oneDay=60*60*24; 
$dayfield=floor($timediff/$oneDay); 
$hourfield=floor(($timediff-$dayfield*$oneDay)/$oneHour); 
$minutefield=floor(($timediff-$dayfield*$oneDay-$hourfield*$oneHour)/$oneMinute); 
$secondfield=floor(($timediff-$dayfield*$oneDay-$hourfield*$oneHour-$minutefield*$oneMinute)); 
if($dayfield>0)$day=$dayfield.'д. ';
if($hourfield>0)$hour=$hourfield.'ч. ';
if($minutefield>0)$minut=$minutefield.'м. ';
if($secondfield>0)$second=$secondfield.'сек. ';

$time_1="".$day.$hour." ".$minut." ".$secon."";
return $time_1;
}
/////////
if (isset($_GET['vse']))
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `inter_pac`"),0);
else 
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `inter_pac` WHERE `urov` <= '".$inter_user['uroven']."'"),0);
$k_page=k_page($k_post,5);
$page=page($k_page);
$start=5*$page-5;
echo "<ul class='delim-list padtop_s'>";
if (isset($_GET['vse']))
$res = mysql_query("SELECT * FROM `inter_pac` LIMIT $start, 5");
else 
$res = mysql_query("SELECT * FROM `inter_pac` WHERE `urov` <= '".$inter_user['uroven']."' ORDER BY `urov` DESC LIMIT $start, 5");
while ($post = mysql_fetch_array($res)){


echo "<li class='padtop_s first-li'>";
echo "<img class='icon' width='48' height='48' src='img/pac/$post[id].png'>";
echo "<div>";
if (isset($_GET['vse'])){

if($inter_user['uroven']<$post['urov'])
echo '<span class="smallfont minor">'.$post['name'].', <span class="minor"> доступно с '.$post['urov'].' уровня</span></span><br />';
else 
echo '<span class="smallfont minor">'.$post['name'].', <span class="smallfont minor">цена:</span><img width="16" height="16" alt="o" src="icon/coins2.png" /> <span class="smallfont minor">'.$post['cena'].'</span><br /></div>';

}else
echo '<a href="?id='.$id[id].'&pac='.$post[id].'"> '.$post['name'].'</a>, <span class="smallfont minor">цена:</span><img width="16" height="16" alt="o" src="icon/coins2.png" /> <span class="smallfont minor">'.$post['cena'].'</span><br /></div>';
echo ' <div class="smallfont minor" style="margin-left:52px;"><div><span class="smallfont minor">Лечение:</span> <span class="ylwtitle">'.sictime(60*$post['time']).'</span></div><span>Опыт:</span> <img width="16" height="16" src="icon/exp2.png"/><span class="money"> '.$post[opit].'</span> <span>Доход:</span> <img width="16" height="16" src="icon/coins2.png"/><span class="money"> '.$post[monet].'</span>';
echo "</div>";
if (isset($user)&&$user['level']>=4&&isset($_GET['vse']))echo '<img width="16" height="16" alt="o" src="icon/gtk-edit.png" /> <a href="?a=edit&id='.$post[id].'">Изменить</a>';
echo "<div style='clear: both'></div></li>";
}
echo "<center>";

if ($k_page>1){
if (isset($_GET['vse']))
str("?vse&id=$id[id]&",$k_page,$page); // Вывод страниц
else
str("?id=$id[id]&",$k_page,$page); // Вывод страниц

}
echo "</center>";
if (!isset($_GET['vse']))
echo '
<div class="padtop_m">
        <img width="16" height="16" src="icon/Book.png"/>
        <a href="?vse&id='.$id[id].'">Просмотр всех видов пациентов</a>
    </div>
';
echo "</ul>";
break;
case 'nap':
if (isset($_GET['id']))$id['id']=intval($_GET['id']);
$id=mysql_fetch_array(mysql_query("SELECT * FROM `inter_pal` WHERE `id`='".$id['id']."'"));
if (!isset($_GET['id'])&&$id['id_user']!=$user['id'])header("Location: index.php?");
$titles='Напитки';
include_once 'head.php';
echo '<div class="block padtop_s"><ul>';
if (isset($_GET['monet'])&&isset($_GET['opit'])&&isset($_GET['time'])&&isset($_GET['urov'])&&$inter_user['uroven']>=$_GET['urov']&&$id['time_napit']<=$time&&$inter_user['monet']>$_GET['monet'])
{
$_GET['monet']=min(max(@intval($_GET['monet']),10),20000);
$_GET['time']=min(max(@intval($_GET['time']),20),5000);
$_GET['opit']=min(max(@intval($_GET['time']),20),4000);
mysql_query("UPDATE `inter_pal` SET `time` = '".($id['time']-60*intval($_GET['time']))."', `time_napit` = '".($time+rand(60, 300))."' WHERE `id` = '".$id['id']."' LIMIT 1");
mysql_query("UPDATE `inter` SET `opit` = '".($inter_user['opit']+intval($_GET['opit']))."', `monet` = '".($inter_user['monet']-intval($_GET['monet']))."', `monet` = '".($inter_user['monet']-intval($_GET['monet']))."' WHERE `id_user` = '".$user['id']."' LIMIT 1");
header("Location: index.php?vipolneno");
}
echo '
<li class="padtop_s">
        <img width="48" height="48" src="img/napit/1.png" class="icon"/>
';
if ($inter_user['uroven']<4)echo '<span>Брусничный сок</a></span>, <span class="minor"> <span class="smallfont minor">доступно с 4 уровня</span>
';
else echo '
                <span><a href="?a=nap&id='.$id[id].'&monet=10&opit=20&time=20&urov=4">Брусничный сок</a></span><span class="minor">,</span>
                <span class="smallfont minor">цена</span>
                <img width="16" height="16" src="icon/coins2.png"/>
                <span class="ylwtitle">10</span>
';
echo '
        <div class="smallfont">
            <div>
                <span class="minor">Опыт: </span>
                <img width="16" height="16" src="icon/exp2.png"/>
                <span class="money">20</span>
                <br/>
                <span class="minor">При использовании медикаментов,</span>
                <br/>
                <span class="minor">ускоряет выздоровление на </span>
                <span class="money">20 минут</span>
                <br/>
            </div>
        </div>
        <div style="clear: both"></div>
    </li>
';
//////////////
echo '
<li class="padtop_s">
        <img width="48" height="48" src="img/napit/2.png" class="icon"/>
';
if ($inter_user['uroven']<10)echo '<span>Лимонный сок</a></span>, <span class="minor"> <span class="smallfont minor">доступно с 10 уровня</span>
';
else echo '
                <span><a href="?a=nap&id='.$id[id].'&monet=30&opit=40&time=40&urov=10">Лимонный сок</a></span><span class="minor">,</span>
                <span class="smallfont minor">цена</span>
                <img width="16" height="16" src="icon/coins2.png"/>
                <span class="ylwtitle">30</span>
';
echo '
        <div class="smallfont">
            <div>
                <span class="minor">Опыт: </span>
                <img width="16" height="16" src="icon/exp2.png"/>
                <span class="money">40</span>
                <br/>
                <span class="minor">При использовании медикаментов,</span>
                <br/>
                <span class="minor">ускоряет выздоровление на </span>
                <span class="money">40 минут</span>
                <br/>
            </div>
        </div>
        <div style="clear: both"></div>
    </li>
';
/////////////////
echo '
<li class="padtop_s">
        <img width="48" height="48" src="img/napit/3.png" class="icon"/>
';
if ($inter_user['uroven']<15)echo '<span>Чай с малиной</a>, </span><span class="minor"> <span class="smallfont minor">доступно с 15 уровня</span>
';
else echo '
                <span><a href="?a=nap&id='.$id[id].'&monet=1200&opit=800&time=310&urov=15">Чай с малиной</a></span><span class="minor">,</span>
                <span class="smallfont minor">цена</span>
                <img width="16" height="16" src="icon/coins2.png"/>
                <span class="ylwtitle">1200</span>
';
echo '
        <div class="smallfont">
            <div>
                <span class="minor">Опыт: </span>
                <img width="16" height="16" src="icon/exp2.png"/>
                <span class="money">800</span>
                <br/>
                <span class="minor">При использовании медикаментов,</span>
                <br/>
                <span class="minor">ускоряет выздоровление на </span>
                <span class="money">5 час 10 минут</span>
                <br/>
            </div>
        </div>
        <div style="clear: both"></div>
    </li>
';

/////////////////
echo '
<li class="padtop_s">
        <img width="48" height="48" src="img/napit/4.png" class="icon"/>
';
if ($inter_user['uroven']<25)echo '<span>Черничный морс</a>, </span><span class="minor"> <span class="smallfont minor">доступно с 25 уровня</span>
';
else echo '
                <span><a href="?a=nap&id='.$id[id].'&monet=2500&opit=1000&time=600&urov=25">Черничный морс</a></span><span class="minor">,</span>
                <span class="smallfont minor">цена</span>
                <img width="16" height="16" src="icon/coins2.png"/>
                <span class="ylwtitle">2500</span>
';
echo '
        <div class="smallfont">
            <div>
                <span class="minor">Опыт: </span>
                <img width="16" height="16" src="icon/exp2.png"/>
                <span class="money">1000</span>
                <br/>
                <span class="minor">При использовании медикаментов,</span>
                <br/>
                <span class="minor">ускоряет выздоровление на </span>
                <span class="money">10 часов</span>
                <br/>
            </div>
        </div>
        <div style="clear: both"></div>
    </li>
';

/////////////////
echo '
<li class="padtop_s">
        <img width="48" height="48" src="img/napit/5.png" class="icon"/>
';
if ($inter_user['uroven']<28)echo '<span>Витаминная настойка</a>, </span><span class="minor"> <span class="smallfont minor">доступно с 28 уровня</span>
';
else echo '
                <span><a href="?a=nap&id='.$id[id].'&monet=8000&opit=1500&time=1440&urov=28">Витаминная настойка</a></span><span class="minor">,</span>
                <span class="smallfont minor">цена</span>
                <img width="16" height="16" src="icon/coins2.png"/>
                <span class="ylwtitle">8000</span>
';
echo '
        <div class="smallfont">
            <div>
                <span class="minor">Опыт: </span>
                <img width="16" height="16" src="icon/exp2.png"/>
                <span class="money">1500</span>
                <br/>
                <span class="minor">При использовании медикаментов,</span>
                <br/>
                <span class="minor">ускоряет выздоровление на </span>
                <span class="money">1 день</span>
                <br/>
            </div>
        </div>
        <div style="clear: both"></div>
    </li>
';

echo "</ul></div>";
/////////////////
echo '
<li class="padtop_s">
        <img width="48" height="48" src="img/napit/6.png" class="icon"/>
';
if ($inter_user['uroven']<35)echo '<span>Скритый напиток</a>, </span><span class="minor"> <span class="smallfont minor">доступно с 35 уровня</span>
';
else echo '
                <span><a href="?a=nap&id='.$id[id].'&monet=15000&opit=3500&time=4320&urov=35">Скритый напиток</a></span><span class="minor">,</span>
                <span class="smallfont minor">цена</span>
                <img width="16" height="16" src="icon/coins2.png"/>
                <span class="ylwtitle">15000</span>
';
echo '
        <div class="smallfont">
            <div>
                <span class="minor">Опыт: </span>
                <img width="16" height="16" src="icon/exp2.png"/>
                <span class="money">3500</span>
                <br/>
                <span class="minor">При использовании медикаментов,</span>
                <br/>
                <span class="minor">ускоряет выздоровление на </span>
                <span class="money">3 деня</span>
                <br/>
            </div>
        </div>
        <div style="clear: both"></div>
    </li>
';

echo "</ul></div>";
break;
case 'edit':
if (isset($_GET['id']))$id['id']=intval($_GET['id']);
$id=mysql_fetch_array(mysql_query("SELECT * FROM `inter_pac` WHERE `id`='".$id['id']."'"));
if (!isset($_GET['id']))header("Location: index.php?");
if ($user['level']<=4)header("Location: index.php?");
$titles='Редактор поциэнтов';
include_once 'head.php';
if (isset($_GET['vipolneno']))echo '</div><div class="major_event"><ul><li><div class="exp_event"><span><center>Успешно выполнено!</center></span></div></li></ul></div><div class="block"> ';



if (isset($_GET['set']) && isset($_POST['ok']))
{
$name=mysql_real_escape_string(esc(stripcslashes(htmlspecialchars($_POST['name']))));
if (strlen2($name)<3)$err='Короткое имя!';
if (strlen2($name)>32)$err='В имени не должно быть длиннее 32-х символов!';
if (!isset($err))
{
mysql_query("UPDATE `inter_pac` SET `name` = '$name', `opit` = '".intval($_POST['opit'])."', `monet` = '".intval($_POST['monet'])."', `time` = '".intval($_POST['time'])."', `cena` = '".intval($_POST['cena'])."', `urov` = '".intval($_POST['urov'])."' WHERE `id` = '".$id['id']."' LIMIT 1");
header("Location: ?a=edit&id=$id[id]&vipolneno");
}
}
echo "<form method='post' action='?a=edit&id=$id[id]&set'><div>\n";
echo "Название :<br /><input type='text' name='name' value='$id[name]' maxlength='1500' /><br />";
echo "Опыт :<br /><input type='text' name='opit' value='$id[opit]' maxlength='6' /><br />";
echo "Доход :<br /><input type='text' name='monet' value='$id[monet]' maxlength='6' /><br />";
echo "Время выписки (в минутах) :<br /><input type='text' name='time' value='$id[time]' maxlength='6' /><br />";
echo "Цена :<br /><input type='text' name='cena' value='$id[cena]' maxlength='6' /><br />";
echo "Уровень :<br /><input type='text' name='urov' value='$id[urov]' maxlength='6' /><br />";
echo "<input class='doctor' type='submit' name='ok' value='Изменить' />\n";


echo "</ul></div>";

break;
case 'bank':
if (isset($_GET['id']))$id['id']=intval($_GET['id']);
$id=mysql_fetch_array(mysql_query("SELECT * FROM `inter_pac` WHERE `id`='".$id['id']."'"));
$titles='Банк';
include_once 'head.php';
if (isset($_GET['vipolneno']))echo '</div><div class="major_event"><ul><li><div class="exp_event"><span><center>Успешно выполнено!</center></span></div></li></ul></div><div class="block"> ';
if (isset($_GET['set']) && isset($_POST['ok']))
{
$monet=intval($_POST['monet']);
if ($monet<0)$err='Короткое цена!';
if ($user['balls']<$monet)$err='Недостаточно баллов!';
if (!isset($err))
{
mysql_query("UPDATE `inter` SET `monet` = '".($inter_user['monet']+$monet)."' WHERE `id_user` = '".$user['id']."' LIMIT 1");
mysql_query("UPDATE `user` SET `balls` = '".($user['balls']-$monet)."' WHERE `id` = '".$user['id']."' LIMIT 1");
header("Location: ?a=bank&id=$id[id]&vipolneno");
}
}
err();

echo "<form method='post' action='?a=bank&set'>\n";
echo "У вас $user[balls] баллов и $inter_user[monet] монет.<br /> Поменять монеты по курсу 1 монета = 1 балл<br />";
echo "Монет :<br /><input type='text' name='monet' value='' maxlength='10' /><br />";
echo "<input class='doctor' type='submit' name='ok' value='Купить' />\n";

echo "</div>";
break;
case 'obmen':
$titles=Обмен;
include_once 'head.php';
if (isset($_GET['vipolneno']))echo '</div><div class="major_event"><ul><li><div class="exp_event"><span><center>Успешно выполнено!</center></span></div></li></ul></div><div class="block"> ';



if (isset($_GET['almaz'])){
if ($_GET['almaz']==1&&$inter_user['almaz']>=1){
mysql_query("UPDATE `inter` SET `monet` = '".($inter_user['monet']+2000)."', `almaz` = '".($inter_user['almaz']-1)."' WHERE `id_user` = '".$user['id']."' LIMIT 1");
header("Location: ?a=obmen&id=$id[id]&vipolneno");
}else if ($_GET['almaz']==10&&$inter_user['almaz']>=10){
mysql_query("UPDATE `inter` SET `monet` = '".($inter_user['monet']+20000)."', `almaz` = '".($inter_user['almaz']-10)."' WHERE `id_user` = '".$user['id']."' LIMIT 1");
header("Location: ?a=obmen&id=$id[id]&vipolneno");
}
}
if (isset($_GET['monet'])){
if ($_GET['monet']==1000&&$inter_user['monet']>=1){
mysql_query("UPDATE `inter` SET `monet` = '".($inter_user['monet']-1000)."', `almaz` = '".($inter_user['almaz']+1)."' WHERE `id_user` = '".$user['id']."' LIMIT 1");
header("Location: ?a=obmen&id=$id[id]&vipolneno");
}else if ($_GET['monet']==4000&&$inter_user['monet']>=4000){
mysql_query("UPDATE `inter` SET `monet` = '".($inter_user['monet']-4000)."', `almaz` = '".($inter_user['almaz']+4)."' WHERE `id_user` = '".$user['id']."' LIMIT 1");
header("Location: ?a=obmen&id=$id[id]&vipolneno");
}
}
echo '
<div class="content">
    

    
    





<div class="block">
    
<h3>Обменять на монеты</h3>
<ul>
    <li>
        <img src="icon/exchange.png" width="16" height="16"/>
        <a href="?a=obmen&almaz=1">Обменять</a>
        <img src="icon/diamond.png" width="16" height="16"/>
        <span>1 алмаз на</span>
        <img width="16" height="16" src="icon/coins2.png"/>
        <span>2000 монет</span>        
    </li>

    <li>
        <img src="icon/exchange.png" width="16" height="16"/>
        <a href="?a=obmen&almaz=10">Обменять</a>
        <img src="icon/diamond.png" width="16" height="16"/>
        <span>10 алмазов на</span>
        <img width="16" height="16" src="icon/coins2.png"/>
        <span>20000 монет</span>        
    </li>
</ul>
<h3>Обменять на алмазы</h3>
<ul>
    <li>
        <img src="icon/exchange.png" width="16" height="16"/>
        <a href="?a=obmen&monet=1000">Обменять</a>
        <img src="icon/coins2.png" width="16" height="16"/>
        <span>1000 монет на</span>
        <img width="16" height="16" src="icon/diamond.png"/>
        <span>1 алмаз</span>        
    </li>

    <li>
         <img src="icon/exchange.png" width="16" height="16"/>
        <a href="?a=obmen&monet=4000">Обменять</a>
        <img src="icon/coins2.png" width="16" height="16"/>
        <span>4000 монет на</span>
        <img width="16" height="16" src="icon/diamond.png"/>
        <span>4 алмазов</span>          
    </li>
</ul>
</div>
';

echo "</div>";
break;
case 'top':

$titles='Топ докторов';
include_once 'head.php';
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `inter`"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];

echo "<ul class='delim-list padtop_s'>";
$res = mysql_query("select * from `inter` ORDER BY `uroven` DESC  LIMIT $start, $set[p_str];");
while ($post = mysql_fetch_array($res)){
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id`='".$post['id_user']."'"));

echo '<img width="16" height="16" src="icon/polzovat_'.$ank['pol'].'.png"/>';
echo '<a href="?a=pol&id='.$post['id_user'].'">'.$ank['nick'].'</a> ['.$post['uroven'].' уров.]';
echo "<br />";
}
if ($k_page>1)str("?a=top&",$k_page,$page); // Вывод страниц


echo "</ul>";

break;
case 'pol':
if (isset($_GET['id']))$id['id']=intval($_GET['id']);
$id=mysql_fetch_array(mysql_query("SELECT * FROM `inter` WHERE `id_user`='".$_GET['id']."'"));
if (!isset($_GET['id']))header("Location: index.php?");
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id`='".$id['id_user']."'"));

$titles="Доктор - $ank[nick]";
include_once 'head.php';
if (isset($_GET['vipolneno']))echo '</div><div class="major_event"><ul><li><div class="exp_event"><span><center>Успешно выполнено!</center></span></div></li></ul></div><div class="block"> ';

if (isset($_GET['del'])&&$user['level']>=4)
{
mysql_query("DELETE FROM `inter_pal` WHERE `id` = '".mysql_escape_string($_GET['del'])."'");
header("Location: ?a=pol&id=".$_GET['id']."&vipolneno");
}

/////////
function sictime($timediff){
$oneMinute=60; 
$oneHour=60*60; 
$oneDay=60*60*24; 
$dayfield=floor($timediff/$oneDay); 
$hourfield=floor(($timediff-$dayfield*$oneDay)/$oneHour); 
$minutefield=floor(($timediff-$dayfield*$oneDay-$hourfield*$oneHour)/$oneMinute); 
$secondfield=floor(($timediff-$dayfield*$oneDay-$hourfield*$oneHour-$minutefield*$oneMinute)); 
if($dayfield>0)$day=$dayfield.'д. ';
if($hourfield>0)$hour=$hourfield.'ч. ';

$time_1="".$day.$hour." ".$minutefield."м. ".$secondfield." сек.";
return $time_1;
}
/////////
echo "".online($ank['id'])." <img width='16' height='16' alt='o' src='icon/polzovat_".$ank['pol'].".png'/> Доктор - ";
echo " <a href='/info.php?id=$ank[id]'>$ank[nick]</a>";
echo "<ul class='delim-list padtop_s'>";
echo "<li class='padtop_s first-li'>";
if (is_file(H."sys/avatar/$ank[id].gif"))
echo "<img class='icon' src='/sys/avatar/$ank[id].gif' width='48' height='60' border='0' alt='' />\n";
elseif (is_file(H."sys/avatar/$ank[id].jpg"))
echo "<img class='icon' src='/sys/avatar/$ank[id].jpg' width='48' height='60' border='0' alt='' />\n";
elseif (is_file(H."sys/avatar/$ank[id].png"))
echo "<img class='icon' src='/sys/avatar/$ank[id].png' width='48' height='60' border='0' alt='' />\n";
else
echo "<img class='icon' src='icon/userr.png' width='48' height='60' border='0' alt='' />\n";


echo "<div class='smallfont minor' style='margin-left:52px;'><div><img width='16' height='16' alt='o' src='icon/coins2.png'/> <span class='ylwtitle'>$id[monet] монет</span> </div><div><img width='16' height='16' alt='o' src='icon/diamond.png'/> <span class='ylwtitle'>$id[almaz] алмазов</span></div><img width='16' height='16' alt='o' src='icon/polzovat_".$ank['pol'].".png'/> <span class='ylwtitle'>$id[uroven] уровень</span></div>

";
echo "<div style='clear: both'></div></li></ul>";

if (isset($user)&&$user['level']>=4)echo '<img width="16" height="16" alt="o" src="icon/gtk-edit.png" /> <a href="?a=pol_edit&id='.$id[id_user].'">Изменить доктора</a>';
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `inter_pal` WHERE `id_user` = '$user[id]'"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];

echo "<ul class='delim-list padtop_s'>";
$res = mysql_query("select * from `inter_pal` WHERE `id_user` = '$id[id_user]'  LIMIT $start, $set[p_str];");
while ($post = mysql_fetch_array($res)){
echo "<li class='padtop_s first-li'>";
if ($post['pac']==-1) echo " <img class='icon' width='48' height='48' src='img/palata/dirtybed.png'>"; elseif ($post['pac']==0) echo " <img class='icon' width='48' height='48' src='img/palata/bed.png'>"; else echo " <img class='icon' width='48' height='48' src='img/pac/$post[pac].png'>";
$inter_pac=mysql_fetch_array(mysql_query("SELECT * FROM `inter_pac` WHERE `id`='".$post['pac']."'"));
echo "<div>";
if ($post['pac']==-1)echo "<span class='patienttitle'>Грязная палата</span>";
if ($post['pac']==0)echo "<span class='patienttitle'>Свободная палата</span>";

else {
echo ''.$inter_pac['name'].' <br /></div><div class="smallfont minor" style="margin-left:52px;"><div><span class="smallfont minor">Выписка через :</span> </div>';
if($time<$post['time'])echo '<div><span class="ylwtitle">'.sictime($post['time']-$time).'</span></div>'; else echo '<div><span class="ylwtitle">окончена</span></div>';
if($post['time_dop']!=-1&&$time<$post['time']){
if($time<$post['time_dop'])echo '<div><span class="smallfont minor">Осмотр через '.sictime($post['time_dop']-$time).'</span></div>'; 
} 
}

if (isset($user)&&$user['level']>=4)echo '<div><img width="16" height="16" alt="o" src="icon/delete.png" /> <a href="?a=pol&id='.$id['id_user'].'&del='.$post['id'].'">Удалить</a></div>';

echo "<div style='clear: both'></div></li>";
}
if ($k_page>1)str("?a=pol&id=$id[id_user]&",$k_page,$page); // Вывод страниц

echo "</ul>";

break;
case 'pol_edit':
if (isset($_GET['id']))$id['id']=intval($_GET['id']);
$id=mysql_fetch_array(mysql_query("SELECT * FROM `inter` WHERE `id_user`='".$_GET['id']."'"));
if (!isset($_GET['id']))header("Location: index.php?");
if ($user['level']<=4)header("Location: index.php?");
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id`='".$id['id_user']."'"));

$titles="Редактор - $ank[nick]";
include_once 'head.php';
if (isset($_GET['vipolneno']))echo '</div><div class="major_event"><ul><li><div class="exp_event"><span><center>Успешно выполнено!</center></span></div></li></ul></div><div class="block"> ';


if (isset($_GET['set']) && isset($_POST['ok']))
{
mysql_query("UPDATE `inter` SET `monet` = '".intval($_POST['monet'])."', `almaz` = '".intval($_POST['almaz'])."', `opit` = '".intval($_POST['opit'])."', `uroven` = '".intval($_POST['uroven'])."' WHERE `id_user` = '".$id['id_user']."' LIMIT 1");
header("Location: ?a=pol_edit&id=$id[id_user]&vipolneno");
}
echo "<form method='post' action='?a=pol_edit&id=$id[id_user]&set'><div>\n";
echo "Монет :<br /><input type='text' name='monet' value='$id[monet]' maxlength='1500' /><br />";
echo "Алмазов :<br /><input type='text' name='almaz' value='$id[almaz]' maxlength='6' /><br />";
echo "Опыт :<br /><input type='text' name='opit' value='$id[opit]' maxlength='6' /><br />";
echo "Уровень :<br /><input type='text' name='uroven' value='$id[uroven]' maxlength='6' /><br />";
echo "<input class='doctor' type='submit' name='ok' value='Изменить' />\n";

echo "</ul></div>";



break;
}
include_once 'foot.php';


?> Поменять монеты по курсу 1 монета = 1 баллa href="?a=pol&id='.$post['id_user'].'"input type='text' name='almaz' value='$id[almaz]' maxlength='6' /