<?php
$title->SetTitle('Маркет - Моя корзина');
$title->GetHeader();
echo'<div class="tile"><div class="t-header th-alt bg-teal"><div class="th-title"><i class="zmdi zmdi-widgets"></i><a href="/"style="text-decoration:none; color:white;"> Главная</a> :: <a href="/market"style="text-decoration:none; color:white;"> Маркет</a> :: <a href="uskab"style="text-decoration:none; color:white;"> Кабинет </a> :: Моя корзина</div></div></div>';
if (isset($_GET['del'])) {
$del = DB::$dbs->queryFetch("SELECT * FROM magazin_korz WHERE id = ? LIMIT 1", [abs((int)$_GET['del'])]);
if ($del['user_id'] == $b['id']) {
DB::$dbs->query("DELETE FROM magazin_korz WHERE id = ? LIMIT 1", [abs((int)$_GET['del'])]);
header('location: ?');
}
}
$count = DB::$dbs->querySingle("SELECT count(id) FROM magazin_korz WHERE user_id = ?", [$b['id']]);
$array = DB::$dbs->query("SELECT * FROM magazin_korz WHERE user_id = ? ORDER BY time DESC", [$b['id']]);
if ($count==0) {
echo '<div class="alert alert-danger"role="alert">Корзина пуста</div>';
}
echo'<div class="t-body"><div class="list-group lg-alt">';
while($arr = $array->fetch()) {
$file = DB::$dbs->queryFetch("SELECT name,price,id FROM magazin_file WHERE id = ? LIMIT 1", [$arr['file']]);
$screen = DB::$dbs->queryFetch("SELECT * FROM `magazin_screen` WHERE `file` = ? ORDER BY `id` DESC LIMIT 1",[$file['id']]);
echo '<a href="/market/file/'.$file['id'].'" class="list-group-item media"><div class="pull-left"><img class="img-circle pull-left" src="/files/mag_screen/'.$screen['screen'].'" alt="" width="40" height="40"></div><div class="media-body"><div class="list-group-item-heading">'.$file['name'].' </div><small class="list-group-item-text">Стоимость: <b><font color="green">'.$file['price'].'</font></b> р.</small></div></a>';
}
echo'</div></div>';
?>