View file includes/adm/finance/history_user.php

File size: 3.9Kb
<?php
$k=$query4;
if ($k<1) $k=1;

$p_user=stripslashes(trim($HTTP_POST_VARS['p_user']));
$p_login=stripslashes(trim($HTTP_POST_VARS['p_login']));
if ($query3!='') $p_user=$query3;

if (($p_user=='')&&($p_login==''))
	{
	print '<form action="/?'.$id.'/finance/history/user" method=post>'.
	'<b>'.
	'ID_user:&nbsp;'.
	'<input type=text name=p_user size=6 value="">'.
	'</b>&nbsp;'.
	'<input type=submit value="Искать">'.
	'</form>'.
	'<form action="/?'.$id.'/finance/history/user" method=post>'.
	'<b>'.
	'Логин:&nbsp;'.
	'<input type=text name=p_login size=16 value="">'.
	'</b>&nbsp;'.
	'<input type=submit value="Искать">'.
	'</form>';
	exit;
	}

if ($p_login!='') $msg='логином '.$p_login;
if ($p_user!='')  $msg='ID='.$p_user;

if (($p_user=='')&&($p_login!=''))
	{
	# Выбор пользователя
	$q_=@mysql(DBName,"SELECT * FROM `users` WHERE `login` = '$p_login' LIMIT 0, 5");
	$s=@mysql_num_rows($q_);

	if ($s==1)
		{
		$data_=@mysql_fetch_array($q_);
		$p_user=$data_['num'];
		}
	elseif ($s>1)
		{
		print '<table border=0 bgcolor=#70E2A0>';
		print '<tr bgcolor=#D8998B><th>&nbsp;Пользователь&nbsp;</th><th>&nbsp;ID&nbsp;</th></tr>';
		for ($i=0;$i<$s;$i++)
			{
			$data_=@mysql_fetch_array($q_);
			if ($col) {$color='#96BDE0';$col=false;} else {$color='#7AABD8';$col=true;}
			print '<tr bgcolor='.$color.'>';
			print '<th>&nbsp;<a href="?'.$id.'/finance/history/user/'.$data_['num'].'">'.$data_['login'].'.'.$data_['domain'].'.ru</a>&nbsp;</th>';
			print '<th>&nbsp;'.$data_['num'].'&nbsp;</th>';
			print '</tr>';
			}
		print '</table>';
		exit;
		}
	else
		{
		print '<table border=0 bgcolor=#70E2A0>'.
		'<tr bgcolor=#D8998B><th>&nbsp;Пользователь&nbsp;</th><th>&nbsp;ID&nbsp;</th></tr>'.
		'<tr bgcolor=#000000><th colspan=2><font color=red><b>Пользователь с '.$msg.' не найден</b></font></th></tr>'.
		'</table>';
		exit;
		}
	}

if (($p_user+0)==0)
	{
	# Выбор пользователя
	$q_=@mysql(DBName,"SELECT * FROM `users` WHERE `num` = '$p_user' LIMIT 0, 5");
	$s=@mysql_num_rows($q_);
	if ($s<1)
		{
		print '<table border=0 bgcolor=#70E2A0>'.
		'<tr bgcolor=#D8998B><th>&nbsp;Пользователь&nbsp;</th><th>&nbsp;ID&nbsp;</th></tr>'.
		'<tr bgcolor=#000000><th colspan=2><font color=red><b>Пользователь с '.$msg.' не найден</b></font></th></tr>'.
		'</table>';
		exit;
		}
	}

# Выбор списка услуг
$q3=@mysql(DBName,"SELECT * FROM `finance_billing` WHERE `id_user` = '$p_user' ORDER BY `time` DESC LIMIT ".($k-1).", 26");
$s=@mysql_num_rows($q3);

print '<table border=0 width=100% bgcolor=#70E2A0><tr bgcolor=#D8998B>'.
'<th><b>ID</b></th>'.
'<th><b>Дата/Время</b></th>'.
'<th><b>Пользователь</b></th>'.
'<th><b>ID_user</b></th>'.
'<th><b>Тип</b></th>'.
'<th><b>Сумма</b></th>'.
'<th><b>Описание</b></th>'.
'<th><b>Остаток</b></th>'.
'</tr>';

if ($s>25) {$s=25;$nextp=true;} else $nextp=false;
for ($i=0;$i<$s;$i++)
	{
	$data3=@mysql_fetch_array($q3);

	if ($col) {$color='#96BDE0';$col=false;} else {$color='#7AABD8';$col=true;}

	print '<tr bgcolor='.$color.'>';
	print '<th>'.($k+$i).'</th>';
	print '<th>&nbsp;'.date("j.m.Y H:i",$data3['time']).'</a>&nbsp;</th>';
	$q__=@mysql(DBName,"SELECT * FROM `users` WHERE `num` = '".$data3['id_user']."' LIMIT 0, 1");
	$data__=mysql_fetch_array($q__);
	print '<th>&nbsp;<a href="?'.$id.'/finance/users/'.$data3['id_user'].'">'.$data__['login'].'.'.$data__['domain'].'.ru</a>&nbsp;</th>';
	print '<th>&nbsp;'.$data3['id_user'].'&nbsp;</th>';
	print '<th>'.$data3['direct'].'</th>';
	print '<th>'.sprintf ("%01.2f",$data3['pay']).' у.е.</th>';
	print '<th>'.$data3['descr'].'</th>';
	print '<th>'.sprintf ("%01.2f",$data3['sum']).' у.е.</th>';
	print '</tr>';
	}

print '</table>';

if ($k>1) print '<b><a href="?'.$id.'/finance/history/user/'.$p_user.'/'.($k-25).'">&lt;&lt;&lt;Назад</a>';
if ($nextp) print '&nbsp;<a href="?'.$id.'/finance/history/user/'.$p_user.'/'.($k+25).'">Далее&gt;&gt;&gt;</a></b>';

exit;
?>