View file includes/adm/finance/schet_pay.php

File size: 2.92Kb
<?php
# Выбор счета
$q3=@mysql(DBName,"SELECT * FROM `finance_schet` WHERE `id` = '$query3' LIMIT 0, 1");
$s=@mysql_num_rows($q3);

$paysum=$HTTP_POST_VARS['pay']+0;

if ($s>0)
	{
	$datas=@mysql_fetch_array($q3);

	if ($paysum>0)
		{
		# Считываем баланс пользователя
		$qh=@mysql(DBName,"SELECT `sum` FROM `finance_billing` WHERE `id_user` = '".$datas['id_user']."' ORDER BY `time` DESC LIMIT 0, 1");
		$datah=@mysql_fetch_array($qh);
		$balance=$datah['sum'];

		# Зачисляем на баланс по счету
		@mysql(DBName,"INSERT INTO `finance_billing` ( `id_user` , `time` , `direct` , `sum` , `pay` , `descr` ) VALUES ( '".$datas['id_user']."' , '".time()."' , '+' , '".($datah['sum']+$paysum)."' , '".$paysum."' , 'Зачисление по счету KMX/".$datas['id_user']."/".$datas['id']."' )");

		# Ставим проплату счета
	    @mysql(DBName,"UPDATE `finance_schet` SET `paytime` = '".time()."', `value` = '".$paysum."', `comment` = 'Обработано (".$user.")' WHERE `id` = '$query3' LIMIT 1");

		include($admpath.'finance/schet_info.php');
		}

	print '<form action="/?'.$id.'/finance/schet/pay/'.$query3.'" method=post>';
	print '<table border=0 bgcolor=#70E2A0>';
	print '<tr bgcolor=#D8998B><th width=200><b>Счет</b></th><th>&nbsp;KMX&nbsp;/&nbsp;'.$datas['id_user'].'&nbsp;/&nbsp;'.$datas['id'].'&nbsp;</th></tr>';

	$q__=@mysql(DBName,"SELECT * FROM `users` WHERE `num` = '".$datas['id_user']."' LIMIT 0, 1");
	$data__=mysql_fetch_array($q__);
	print '<tr bgcolor=#96BDE0><th width=200><b>Пользователь</b></th><th>&nbsp;'.$data__['login'].'.'.$data__['domain'].'.ru&nbsp;</th></tr>';

	print '<tr bgcolor=#7AABD8><th width=200><b>Сумма</b></th><th>'.sprintf ("%01.2f",$datas['value']).'</th></tr>';
	print '<tr bgcolor=#96BDE0><th width=200><b>Выписан</b></th><th>'.date("j.m H:i ",$datas['createtime']).'</th></tr>';
	if ($datas['paytime']>0)         print '<tr bgcolor=#7AABD8><th width=200><font color=red><b>ЗАЧИСЛЕН</b></font></th><th>'.date("j.m H:i ",$datas['paytime']).'</th></tr>';
	print '<tr bgcolor=#96BDE0><th width=200><b>Описание</b></th><th>'.$datas['descr'].'</th></tr>';
	if ($datas['comment']=='delete') print '<tr bgcolor=#7AABD8><th width=200><b>Комментарий</b></th><th><font color=gray><i>аннулирован</i></font></th></tr>';
	else                             print '<tr bgcolor=#7AABD8><th width=200><b>Комментарий</b></th><th>'.$datas['comment'].'</th></tr>';
	if ($datas['paytime']==0)        print '<tr bgcolor=#FC3910><th width=200><b>К зачислению:</b></th><th><input type=text name=pay size=6 value="'.sprintf ("%01.2f",$datas['value']).'">&nbsp;<input type=submit value="Зачислить"></th></tr>';
	print '</table>';
	print '</form>';
	}
else
	{
	print '<table border=0 bgcolor=#70E2A0>'.
	'<tr bgcolor=#D8998B><th width=200><b>Счет</b></th><th>&nbsp;KMX&nbsp;/&nbsp;???&nbsp;/&nbsp;'.$query3.'&nbsp;</th></tr>'.
	'<tr bgcolor=#000000><th colspan=2><font color=red><b>Счет не найден</b></font></th></tr>'.
	'</table>';
	}

exit;
?>