<?php

	# mark core  v1.0
    # author Drk in
	# date 24.10.19 	

	# core

	require_once ( $_SERVER['DOCUMENT_ROOT']."/_core/system.php" );

	# user

	system::access(true);

	$s =  isset( $_GET['s'] ) ? system::abs($_GET['s']): 0;

	# meta

	$title = 'Мой кабинет » Мобильные WAP сайты';
	$description = system::check($config['description']);
	$keywords = system::check($config['keywords']);
	$tl = 'Тикеты';

	# head

	require_once ( head );

	echo '<div class ="touch"> <a href ="?"> Все</a> | <a href ="?&s=1"> Открытые</a> |  <a href ="?&s=2"> Закрытые</a> </div>';

	if ($s == 1)$sr = 'AND hide = 0'; 
	if ($s == 2)$sr = 'AND hide = 1'; 
	if ($s == 0)$sr = null;

	$cn = DB :: $dbh -> querySingle("SELECT count(id) FROM tk WHERE user = ? {$sr}", array($user['id']));	

	if($cn == 0)echo '<div class="err">Cписок пуст!</div>';

	$page = new page($cn);

	$limit = $cn > $page -> elements ? $page -> limit : null;

	$query = DB :: $dbh -> query("SELECT id FROM tk WHERE user = ? {$sr} ORDER BY time DESC {$limit}", array($user['id']));	

	while ($act = $query -> fetch()):

	$act = cache_tk::check($act['id']);

	echo '
	<div class ="touch"><img src ="'.ico.'tk1.png">
	<a href ="'.site.'office/tk/id'.$act['id'].'"> '.system::num(system::check($act['name']),20).'</a>
	[ID: '.$act['id'].' | '.($act['hide'] == 0 ? '<font color="blue"> Открыт</font>':'<font color="red">Закрыт</font>').'
	| '.system::time($act['time']).']
	<br>
	'.system::num(system::check($act['message']),86).'
	</div>
	';

	endwhile;	
	
	$page -> get($s == 0 ? '?':'?&s='.$s.'&');
	
	echo '
	<a href="'.site.'office/tk/add" class="touch"> Новый запрос</a>
	<a href="'.site.'" class="touch">« На главную</a>
	';

	# foot

	require_once ( foot ) ;

?>

