<?include('header.php');?>
<div class="menucenter">
<?php

if(!isset($_SESSION["username"]) && !isset($_SESSION["password"]))
{
	echo '<div class=error>Ошибка! Для доступа к данной странице необходимо зарегистрироваться!</div>';
	include('footer.php');
	exit();
}else{
	$username = text($_SESSION["username"]);

	require('config.php');
	require('stat_task.php');
        echo '<br />';
	$KOL_ZP = "20";
	if (isset($_GET["page"]))
		{
			if(preg_match("|^[\d]*$|",$_GET['page']))
				{
					$page = intval($_GET["page"]);
					if($page>0) {$start = abs(($page - 1) * $KOL_ZP);}else{$page = "1"; $start = "0";}
				}else{
					$page = "1";
					$start = "0";
				}
		}else{
			$start = "0";
			$page = "1";
		}
	$sql_page = mysql_query("SELECT id FROM seelf_task_pay WHERE nameuser='$username'");
	$kol_page = mysql_num_rows($sql_page);

	$sql = mysql_query("SELECT * FROM seelf_task_pay WHERE nameuser='$username' ORDER BY id DESC limit $start,$KOL_ZP");

	if(mysql_num_rows($sql)>0)
		{
			?>

<table class='reyt' width='100%' border='0' cellpadding='0' cellspacing='0'>
<thead><tr>
<th width="5%" align="center" class="top">ID</th>
<th width="25%"  align="center" class="top">Дата</th>
<th width="10%"  align="center" class="top">Стоимость</th>
<th width="15%"  align="center" class="top">Рекламодатель</th>
<th width="15%"  align="center" class="top">Статус</th>
</tr></thead>
				</tr>

<?

			while ($row = mysql_fetch_assoc($sql))
				{
					$id = $row["id"];
					$namep = $row["namep"];
					$ident = $row["ident"];
					$time = $row["time"]; $time = DATE("d.m.Yг. в H:i",$time);
					$tipo = $row["tipo"];
					$pay = $row["pay"];

					if($tipo=="")
						$status='Ожидает..<br><img src="img/alert.gif" width="16" height="16" border="0" align="absmiddle" alt="" />&nbsp;<a href="ban_task.php?ban2id='.$id.'">Жалоба</a>';
					elseif($tipo=="good")
						$status='<font color="green"><b>Выполнено</b></font>';
					elseif($tipo=="bad")
						$status='<font color="red"><b>Не выполнено</b></font><br><img src="img/alert.gif" width="16" height="16" border="0" align="absmiddle" alt="" />&nbsp;<a href="ban_task.php?ban2id='.$id.'">Жалоба</a>';
					else $status='Ожидает..<br><img src="img/alert.gif" width="16" height="16" border="0" align="absmiddle" alt="" />&nbsp;<a href="ban_task.php?ban2id='.$id.'">Жалоба</a>';

					?><tr bgcolor="">
						<td align="center"><?php echo $ident;?></td>
						<td align="center"><?php echo $time;?></td>
						<td align="center"><?php echo $pay;?></td>
						<td align="center"><?php echo $namep;?></td>
						<td align="center"><?php echo $status;?></td>
					</tr><?
				}
			echo "</table>";
		}else{
			if($kol_page>0) {echo '<div class=error>Ошибка такой страницы не существует!</div>'; include('footer.php'); exit();}
		}
	if($kol_page>$KOL_ZP){
		echo '<br><b>Страницы:</b>&nbsp;';
		$num_pages=ceil($kol_page/$KOL_ZP);
		for($i=1;$i<=$num_pages;$i++)
		{
			if($i == $page)
			{
				echo '<font color="red"><b>'.$i.'</b></font>&nbsp;';
			}else{
				echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$i.'"><b>'.$i.'</b></a>&nbsp;';
			}
		}
	}

}
include('footer.php');?>