<?php
if (!defined('webid')) {
    exit();
}
if (!(isset($_SESSION["username"]) && isset($_SESSION["password"]))) {
    header("Location: /");
	exit();
}
?>
<style type="text/css">
.con_btn {
    background: #d5d5d5;
    width: 217px;
    height: 31px;
    padding-top: 1px;
    padding-left: 1px;
    -moz-border-radius: 3px;
    -webkit-border-radius: 3px;
    -khtml-border-radius: 3px;
    border-radius: 3px;
    box-shadow: 0 1px 1px rgba(0,0,0,0.2) inset;
}
a.bt1, a.bt2, a.bt3, a.bt4, a.bt5, a.bt6, a.bt7 {
    position: relative;
    display: inline-block;
    width: 30px;
    height: 30px;
    margin-right: 1px;
}
a.bt1 {
    -moz-border-radius: 3px 0 0 3px;
    -webkit-border-radius: 3px 0 0 3px;
    -khtml-border-radius: 3px 0 0 3px;
    border-radius: 3px 0 0 3px;
}
a.bt7 {
    -moz-border-radius: 0 3px 3px 0;
    -webkit-border-radius: 0 3px 3px 0;
    -khtml-border-radius: 0 3px 3px 0;
    border-radius: 0 3px 3px 0;
}
a.bt1 {
    background: url(theme/img/history/bt1.png) center center no-repeat;
    background-color: #ebebeb;
}
a.bt2 {
    background: url(theme/img/history/bt2.png) center center no-repeat;
    background-color: #ebebeb;
}
a.bt3 {
    background: url(theme/img/history/bt3.png) center center no-repeat;
    background-color: #ebebeb;
}
a.bt4 {
    background: url(theme/img/history/bt4.png) center center no-repeat;
    background-color: #ebebeb;
}
a.bt5 {
    background: url(theme/img/history/bt5.png) center center no-repeat;
    background-color: #ebebeb;
}
a.bt6 {
    background: url(theme/img/history/bt6.png) center center no-repeat;
    background-color: #ebebeb;
}
a.bt7 {
    background: url(theme/img/history/bt7.png) center center no-repeat;
    background-color: #ebebeb;
}
a.bt1:hover, a.bt2:hover, a.bt3:hover, a.bt4:hover, a.bt5:hover, a.bt6:hover, a.bt7:hover {
    background-color: #ffffff;
}
.nav_link {
    color: #1C62B9;
    text-decoration: none;
}
.nav_link:hover {
    text-decoration: underline;
}
</style>
<script type="text/javascript">
$('a.bt1, a.bt2, a.bt3, a.bt4, a.bt5, a.bt6, a.bt7').tipTip();
</script>
<h3 style="border-bottom: 1px dotted #cccccc; color: #1c62b9; text-shadow: 0 1px 0 #fafafa;">История операций</h3>
<center><div class="con_btn"><a href="/history" class="bt1" title="Все операции"></a><a href="/history/type=3" class="bt2" title="Новые рефералы"></a><a href="/history/type=4" class="bt3" title="Все что оплачивал(а)"></a><a href="/history/type=1" class="bt4" title="Изменение профиля"></a><a href="/history/type=5" class="bt5" title="Выплаты"></a><a href="/history/type=2" class="bt6" title="Рекламные площадки"></a><a href="/history/type=7" class="bt7" title="Разное"></a></div></center>
<?php
$type = intval($_GET[type]);
if ($type == '') $type = 0;
$zapros = " and `doing`='$type'";
if ($type == 0) $zapros = '';

$kolvo = 10;
$all = mysql_num_rows(mysql_query("SELECT id FROM tb_allhistory where idus='$_SESSION[iduser]'$zapros"));
$allpage = ceil($all/$kolvo);
$this_page = (isset($_GET['pg'])) ? intval($_GET['pg']) : 1 ;
if ($this_page < 1) $this_page = 1;
if ($this_page > $allpage) $this_page = $allpage;
$start = $this_page * $kolvo - $kolvo;
if ($start == -10) { $start = 1; }

include_once 'functiones.php';

echo "<br /><table width='100%' style='margin-bottom: 5px;'><tr><td nowrap='nowrap'>";
$nextp = $this_page + 1;
$lastp = $this_page - 1;
if ($this_page > 1) { echo "<a href='/history/type=$type&pg=$lastp' class=\"link\"><span class='text14'>"; } else { echo "<span class='textgray'>"; } echo "&larr;&nbsp;Предыдущие</span>";
if ($this_page == 1) { echo "</a>"; } echo "</td><td width='90%' align='center'>". navigation($allpage,'/history/type='.$type.'&pg=',1,1)."</td><td nowrap='nowrap'>";
if ($this_page == $allpage) { echo "<span class='textgray'>"; } else { echo "<a href='/history/type=$type&pg=$nextp' class=\"link\"><span class='text14'>"; } echo "Следующие&nbsp;&rarr;</span>"; 
if ($this_page == $allpage) { echo "</a>"; } echo "</td></tr></table>";
?>

<table class="otab" width="100%" border="0" cellpadding="0" cellspacing="1">
<thead>
<tr>
<th colspan="3" style="padding: 5px; background: #ebebeb;"><span style="position: relative; left: -148px;">Дата и время</span><span>Событие</span></th>
</tr>
</thead>
<?
$sql = mysql_query("SELECT * FROM tb_allhistory WHERE idus='$_SESSION[iduser]'$zapros ORDER by data DESC limit $start,$kolvo") or die(mysql_error());
while ($row = mysql_fetch_assoc($sql)) {
    $datenow = date("d.m");
    $datedo = date("d.m", $row[data]);
    if ($datedo == $datenow) {
        $prtdt = "<b>Сегодня</b><br />" . date("H:i", $row[data]);
    } else {
        $prtdt = date("d.m.Y", $row[data]) . "<br>" . date("H:i", $row[data]);
    }
    if ($row[doing] == 2) { $ico = "bt6"; $row[title] = "<b>Добавлена рекламная площадка</b><br>$row[title]"; }
    if ($row[doing] == 3) $ico = "bt2";
    if ($row[doing] == 1) $ico = "bt4";
    if ($row[doing] == 4) $ico = "bt3";
    if ($row[doing] == 5) $ico = 'bt5';
    if ($row[doing] == 7) $ico = "bt7";
?>
<tr align="center"><td class='rt' width="24"><img src='theme/img/history/<?=$ico ?>.png' width='24' height='24' /></td>
<td class='lt' align="center"><?=$prtdt ?></td>
<td class="rt" align="left" width="370"><?=$row[title] ?></td>
</tr>
<?
}
?>
</table>
