<?php
echo "<div class='event'><h1><a href='?collective=$ct[id]'>".hsc($mc['name'])."</a> / История</h1></div>";
echo '<div class="content">
<div class="block">';
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `$db_base`.`kolhoz_collective_history` WHERE `id_collective` = '$ct[id]'"),0);
if ($k_post==0)
{
echo "Список пуст...";
}
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$num=($page-1)*$k_page;
$q=mysql_query("SELECT * FROM `$db_base`.`kolhoz_collective_history` WHERE `id_collective` = '$ct[id]' ORDER BY `time` DESC LIMIT $start, 10");
echo "<ul>";
while($post=mysql_fetch_array($q))
{
$num++;
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `$db_base`.`kolhoz_user` WHERE `id` = '$post[id_user]'"));
$au=$ank;
$who=mysql_fetch_array(mysql_query("SELECT * FROM `$db_base`.`kolhoz_user` WHERE `id` = '$post[id_who]'"));
$whou=$who;
if($au['pol']==1)$post['status_name']='колхозник';else $post['status_name']='колхозница';
if($post['status']==1)$post['status_name']='председатель';
elseif($post['status']==2)$post['status_name']='зампред';
elseif($post['status']==3)$post['status_name']='агроном';
elseif($post['status']==4)$post['status_name']=($au['pol']==1?'бригадир':'хозяйка');
elseif($post['status']==5)$post['status_name']='староста';
elseif($post['status']==6)$post['status_name']=($au['pol']==1?'механизатор':'товаровёд');
echo "<li>";
if($post['type']=='in')
{
echo "<span>";
echo on_k($who['id']);
echo "<a href='?user=$who[id]'><span>".nc($who['id'])."</span></a></span> <span>принял".($whou['pol']==0?'a':null)." в колхоз</span> <span>".hsc($ct['name'])."</span> <span>";
echo on_k($ank['id']);
echo "<a href='?user=$ank[id]'><span>".nc($ank['id'])."</span></a></span>";
}
elseif($post['type']=='out')
{
if($post['dei']=='user')
{
echo "<span>";
echo on_k($ank['id']);
echo "<a href='?user=$ank[id]'><span>".nc($ank['id'])."</span></a></span> <span>покинул".($whou['pol']==0?'a':null)." колхоз</span> <span>".hsc($ct['name'])."</span>";
}
else
{
echo "<span>";
echo on_k($who['id']);
echo "<a href='?user=$who[id]'><span>".nc($who['id'])."</span></a></span> <span>исключил".($whou['pol']==0?'a':null)." из колхоза</span> <span>".hsc($ct['name'])."</span> <span>";
echo on_k($ank['id']);
echo "<a href='?user=$ank[id]'><span>".nc($ank['id'])."</span></a></span>";
}
}
elseif($post['type']=='st_up')
{
echo "<span>";
echo on_k($who['id']);
echo "<a href='?user=$who[id]'><span>".nc($who['id'])."</span></a></span> <span>повысил".($whou['pol']==0?'a':null)."</span> <span>";
echo on_k($ank['id']);
echo "<a href='?user=$ank[id]'><span>".nc($ank['id'])."</span></a></span> до <span>$post[status_name]</span>";
}
elseif($post['type']=='st_down')
{
echo "<span>";
echo on_k($who['id']);
echo "<a href='?user=$who[id]'><span>".nc($who['id'])."</span></a></span> <span>понизил".($whou['pol']==0?'a':null)."</span> <span>";
echo on_k($ank['id']);
echo "<a href='?user=$ank[id]'><span>".nc($ank['id'])."</span></a></span> до <span>$post[status_name]</span>";
}
echo " <span class='minor'><span>".vremja($post['time'])."</span></span></li>";
}
echo "</ul>";
if ($k_page>1)str("?collective=$ct[id]&selsovet&history&",$k_page,$page); // Вывод страниц
echo "</div>";
include_once 'inc/foot.php';
?>