<?php
/*
* @ServerMon v1.1
* @Developed by Maksa988
* @www.Server-Mon.ru
* @Copyright (C) 2014
*/
 if(!defined('SMON'))
	die('Hacking attempt!');
	
class user extends Controller {
	public function __construct() {
		$this->header();
		$this->data['activeSection'] = 'balance';
		$this->data['navbarName'] = 'Баланс пользователя';

		if(empty($_SESSION['user_id'])):
			return $this->view(array('common/header', 'user/access', 'common/footer'), $this->data); //Загружаем шаблон
		endif;
		
		$this->model('users');
		$this->data['user'] = $this->usersModel->getUser($_SESSION['user_id']);
		
		if($this->POST('balance')):
			if($this->POST('sum') >= '1'):
				$this->data['loading'] = '
					<form action="https://unitpay.ru/pay/7491-3d2aa" method="post" id="pay" style="display: none;">
						<input type="hidden" name="sum" value="'.$this->POST('sum').'" />
						<input type="hidden" name="account" value="'.$_SESSION['user_id'].'" />
						<input type="hidden" name="desc" value="Пополнение баланса аккаунта (#'.$_SESSION['user_id'].')" />
						<input type="hidden" name="hideBackUrl" value="true" />
					</form>
					<script type="text/javascript">setTimeout(\'$("#pay").submit()\', 1000);</script>';
			else:
				$this->data['error'] = 'Укажите ссылку на аватар!';
			endif;
		endif;
		
		return $this->view(array('common/header', 'user/balance', 'common/footer'), $this->data); //Загружаем шаблон
	}
}