<?php
	header('Content-Type: text/html; charset=utf-8');

	include('../../../inc/start.php');
	include('../../../inc/protect.php');

	if(!isset($_POST['token']) || $_SESSION['token'] != clean($_POST['token'], null))
		exit(json_encode(array('status' => 'error', 'text' => 'Неверный токен')));

	$tpl = new Template;
	$tpl->dir = '../tpl/ajax/elements/';

	$date = date('Y-m-d H:i:s');

	$shilings = $pdo->query('SELECT `users`.`id`, `users`.`login`, `users`.`avatar`, `shilings_actions`.`date`, `shilings_actions`.`shilings` FROM `shilings_actions` LEFT JOIN `users` ON `shilings_actions`.`gave_out`=`users`.`id` WHERE `shilings_actions`.`author`="'.$_SESSION['id'].'" AND `shilings_actions`.`type`="11"');
				$shilings->setFetchMode(PDO::FETCH_OBJ);

	$tpl->result['content'] = '';

	while($shiling = $shilings->fetch())
	{
		$tpl->load_template('referal.tpl');
			$tpl->set('{shilings}', $shiling->shilings);
			$tpl->set('{id}', $shiling->id);
			$tpl->set('{login}', $shiling->login);
			$tpl->set('{avatar}', $shiling->avatar);
			$tpl->set('{date}', expand_date($shiling->date, 7));
		$tpl->compile('content');
	}

	if($tpl->result['content'] == '')
	{
		$tpl->load_template('content_none.tpl');
			$tpl->set('{text}', 'Зачислений не производилось');
		$tpl->compile('content');
	}

	echo $tpl->result['content'];
?>