<?php
$title = 'Заказы';
include_once($_SERVER["DOCUMENT_ROOT"].'/php/style/head.php');
admin(3);
?>
<div class="container theme-showcase" role="main">
	<div class="jumbotron">
		<h1>Заказы</h1>
		<p>В данном разделе Вы можете узнать о новых заказах, а так-же изменить их статус</p>
	</div>

	<div class="page-header">
		<h2>Список заказов</h2>
	</div>
	<div class="row">
		<div class="panel panel-default">
		  <div class="panel-heading">Заказы</div>
		  <table class="table">
		    <thead>
		    	<tr>
		    		<th>ID</th>
		    		<th>Пользователь</th>
		    		<th>Товар</th>
		    		<th>Кол-во</th>
		    		<th>Адрес / Сот.</th>
		    		<th>Статус</th>
		    		<th>Действие</th>
		    	</tr>
		    </thead>
		    <tbody>
		    	<?
		    	$query = $db->query("SELECT * FROM `purchased`");
		    	while($pur = $query->fetch_assoc()){
		    		?>
		    		<tr>
		    			<th><?=$pur['id']?></th>
		    			<th><?=outNick($pur['id_user'])?></th>
		    			<th><?=outputNameProduct($pur['id_product'], 1)?></th>
		    			<th><?=$pur['col']?></th>
		    			<th><?if($pur['delivery']==0){?><?=output($pur['number_phone'])?><?}else{?><?=output('г. '.$pur['city'].', '.$pur['street'].', '.$pur['house'].', '.$pur['kv'])?><?}?></th>
		    			<th><?=statusOrder($pur['id'])?></th>
		    			<th>
		    				<?if($pur['delivery'] == 0){
		    					if($pur['status'] == 0){
			    					?>
			    					<a href="/admin/orders/<?=$pur['id']?>/ok">
				    					<button type="button" class="btn btn-success">
											<span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
										</button>
									</a>
			    					<?
			    				}
		    				}else{
		    					if($pur['status'] == 1){
		    						?>
		    						<a href="/admin/orders/<?=$pur['id']?>/ok">
			    						<button type="button" class="btn btn-success">
											<span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
										</button>
									</a>
		    						<?
		    					}elseif($pur['status']==0){?>
		    						<a href="/admin/orders/<?=$pur['id']?>/send">
				    					<button type="button" class="btn btn-warning">
											<span class="glyphicon glyphicon-plane" aria-hidden="true"></span>
										</button>
									</a>
		    					<?}
		    				}?>
		    				<a href="/admin/orders/delete/<?=$pur['id']?>">
			    				<button type="button" class="btn btn-danger">
									<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
								</button>
							</a>
		    			</th>
		    		</tr>
		    		<?
		    	}
		    	?>
		    </tbody>
		  </table>
		</div>
			</div>
</div>
<?
include_once($_SERVER["DOCUMENT_ROOT"].'/php/style/foot.php');
?>