<?php

/**
 * @package     JohnCMS
 * @link        http://johncms.com
 * @copyright   Copyright (C) 2008-2011 JohnCMS Community
 * @license     LICENSE.txt (see attached file)
 * @version     VERSION.txt (see attached file)
 * @author      http://johncms.com/about
 */
echo '<title>Вывод средств</title>';
define('_IN_JOHNCMS', 1);
require('incfiles/core.php');
require('incfiles/head.php');


// Проверяем права доступа
if ($rights < 9) {
    header('Location: http://johncms.com/?err');
    exit;
}
$user = functions::get_user($user);
if (!$user) {
    require('incfiles/head.php');
    echo functions::display_error($lng['user_does_not_exist']);
    require('incfiles/end.php');
    exit;
}
$user = functions::get_user($user);
echo '<div class="phdr"><a href="index.php"><b>' . $lng['admin_panel'] . '</b></a> | Вывод средств</div>';

	if (isset($_GET['id'])){
		$user = functions::get_user($user);
		$time = time();	 
    $id=intval($_GET['id']);
	$rub=intval($_GET['rub']);
$useri=intval($_GET['useri']);
   mysql_query('UPDATE `out_money` SET `status` = "1", `time_ok` = "'.$time.'" WHERE `id` = "'.$id.'" LIMIT 1');
mysql_query("UPDATE `users` SET `balansou` = '".($user['balansou']+$rub)."' WHERE `id` = ".$useri." LIMIT 1");

}
if (isset($_GET['idi'])){
			$user = functions::get_user($user);
		$time = time();	 
    $idi=intval($_GET['idi']);
	$rubi=intval($_GET['rubi']);
	$useri=intval($_GET['useri']);
   mysql_query('UPDATE `out_money` SET `status` = "3", `time_ok` = "'.$time.'" WHERE `id` = "'.$idi.'" LIMIT 1');
mysql_query("UPDATE `users` SET `balans` = '".($user['balans']+$rubi)."' WHERE `id` = ".$useri." LIMIT 1");

}

$q = mysql_query("SELECT * FROM `out_money` ORDER BY id DESC LIMIT $start,$kmess");
 $total = mysql_result(mysql_query("SELECT COUNT(*) FROM `out_money`"), 0);       

while ($post = mysql_fetch_assoc($q))
{
	
	echo '<div class="menu">';
	echo 'ID: '.$post['id_user'];
echo "<br />Время запроса: ".functions::display_date($post['time'])."</br>";
echo 'Кошелек ';
if ($post['tip']==1){
	echo 'WM: ';
}
else {
	echo 'QIWI: ';}
echo htmlentities($post['wmr']);
echo '<br />Сумма: ';
echo htmlentities($post['rub']);
echo ' рублей<br />Статус: '; if ($post['status']==1) {
echo '<font color="green"><b>Выплачено</b></font>';
echo "<br />Время выплаты: ".functions::display_date($post['time_ok'])."";
}elseif ($post['status']==3) {
echo '<font color="red"><b>Отменено</b></font>';
}else{
	
echo '<font color="blue"><b>В ожидание</b></font>';}
if ($post['status']==0) {
echo '<br /><a class="btn btn-default" href="?id='.$post['id'].'&rub='.$post['rub'].'&useri='.$post['id_user'].'">Вывести</a>';
echo ' <a class="btn btn-default" href="?idi='.$post['id'].'&rubi='.$post['rub'].'&useri='.$post['id_user'].'">Отменить</a>';
//echo '<br /><form action="/out.php?" method=\"get\">
//<input type="hidden" name="idi" value="'.$post['id'].'"/>
//<input type="hidden" name="rubi" value="'.$post['rub'].'"/>
//<input type="submit" value="Отменить" class="btn btn-default""/>
//</form>';

}
echo'</div>';}

 if ($total > $kmess)
        echo '<div class="topmenu">' . functions::display_pagination('?&amp;', $start, $total, $kmess) . '</div>';
     

   require('incfiles/end.php');
?>