<?php
include_once '../../sys/fnc.php';

if (!isset($user)) {
    header('location: /');
    exit;
}
$title = 'Услуги';
include_once '../../sys/head.php';

$hist_money = mysql_num_rows(mysql_query("SELECT * FROM `history_money` WHERE `user` = '$user->id'"));
$products_kol = mysql_num_rows(mysql_query("SELECT * FROM `my_orders` WHERE `id_user` = '$user->id'"));
// $s_notice = mysql_num_rows(mysql_query("SELECT * FROM `system_notice` WHERE `id_user` = '$user->id'"));
// $new_notice = mysql_num_rows(mysql_query("SELECT * FROM `system_notice` WHERE `id_user` = '$user->id' AND `chit` = '1'"));
$ref_kol = mysql_num_rows(mysql_query("SELECT * FROM `userref` WHERE `user_id` = '$user->id'"));
$ref_suma = mysql_result(mysql_query("SELECT sum(profit_suma) FROM `userref` WHERE `user_id` = '$user->id'"), 0);
$logs_user = mysql_result(mysql_query("SELECT COUNT(*) FROM `logs_user` WHERE `id_user` = '$user->id'"),0);



$c_p = mysql_result(mysql_query("SELECT COUNT(*) FROM `my_orders` WHERE `id_user` = '".$user->id."'"),0);
$p_page = '10';
$k_page = k_page($c_p, $p_page);
$page = page($k_page);
$start = $p_page*$page-$p_page;

if ($c_p == 0) {
	echo '<div class="err">Ошибка! У Вас отсутсвуют заказы!</div>';
}else{

$query = mysql_query("SELECT * FROM `my_orders` WHERE `id_user` = '".$user->id."' ORDER BY `id` DESC LIMIT $start, ". $p_page);
while ($post = mysql_fetch_assoc($query)) {
// Вывод статуса
$status_k = array(0 => '<font color="#858513">Заказан №'.$post['id'].'</font>', 1 => '<font color="#009900">Активен</font>', 2 => '<font color="red">Остановлен</font>', 3 => '<font color="#181818">Обрабатывается</font>');

//Вводим дату, до которой считать

$date_to = $post['works_to'];

$date_now = time();  //текущая дата

$date_left = $date_to-$date_now;//сколько осталось

$gtdate = getdate($date_left); // переводим в массив

?><hr><br><hr>
				<div class="row-one">
					<div class="col-md-4 widget">
						<div class="stats-left ">
							<h5>Тариф</h5>
							<h4><?= html($post['name']) ?></h4>
						</div>
						<div class="stats-right">
							<label>Х</label>
						</div>
						<div class="clearfix"> </div>	
					</div>
					<div class="col-md-4 widget states-mdl">
						<div class="stats-left">
							<h5>Логин</h5>
							<h4><?= html($post['isp_login']) ?></h4>
						</div>
						<div class="stats-right">
							<label>Х</label>
						</div>
						<div class="clearfix"> </div>	
					</div>
					<div class="col-md-4 widget states-last">
						<div class="stats-left">
							<h5>Пароль</h5>
							<h4><?= html($post['isp_password']) ?></h4>
						</div>
						<div class="stats-right">
							<label>Х</label>
						</div>
						<div class="clearfix"> </div>	
					</div>
					<div class="clearfix"> </div>	
				</div>
				
				<div class="row-one">
					<div class="col-md-4 widget">
						<a href="https://<?= $server ?>/manager/ispmgr?func=auth&username=<?= strtolower($post['isp_login']) ?>&password=<?= $post['isp_password'] ?>&checkcookie=no"><div class="stats-left ">
							<h5>WEB</h5>
							<h4>ISP</h4>
						</div>
						<div class="stats-right">
							<label>Go</label>
						</div>
						<div class="clearfix"> </div>	
					</div></a>
					<div class="col-md-4 widget states-mdl">
						<a href="/isp/index.php?username=<?= strtolower($post['isp_login']) ?>&password=<?= $post['isp_password'] ?>"" target="_blank"><div class="stats-left">
							<h5>WAP</h5>
							<h4>ISP</h4>
						</div>
						<div class="stats-right">
							<label>Go</label>
						</div>
						<div class="clearfix"> </div>	
					</div></a>
					<div class="col-md-4 widget states-last">
						<a href="/scripts/products.php?editing=<?= $post['id'] ?>"><div class="stats-left">
							<h5>Оплатить</h5>
							<h4>услугу</h4>
						</div>
						<div class="stats-right">
							<label>Go</label>
						</div>
						<div class="clearfix"> </div>	
					</div>
					<div class="clearfix"> </div>	
				</div></a>

				

<?
if (time() > $post['works_to'] && $post['status'] != '0' && $post['status'] != '3'){
echo '<div class="menu">';
echo '<font color="red">Срок действия услуги вышел!</font>';
echo '</div>';
}

}
if ($k_page > 1) str('/scripts/user/cabinet?', $k_page, $page);
}
include_once '../../sys/foot.php';
?>