<section class="content"> 
<div class="row">
	<div class="col-md-12">
		<h1><i class='fa fa-square-o'></i> Ventas Pendientes</h1>
		<div class="clearfix"></div>


<?php
$products=null;

		$products = SellData::getCotizations();



if(count($products)>0){

	?>
<br>
<div class="box box-primary">
<div class="box-header">
<h3 class="box-title">Ventas Pendientes</h3></div>
<table class="table table-bordered table-hover	">
	<thead>
		<th></th>
		<th>Folio</th>
		<th>Mesa</th>
		<th>Pago</th>
		<th>Entrega</th>
		<th>Total</th>
		<th>Fecha</th>
		<th></th>
	</thead>
	<?php foreach($products as $sell):?>

	<tr>
		<td style="width:30px;">
		<a href="index.php?view=onesell&id=<?php echo $sell->id; ?>" class="btn btn-xs btn-default"><i class="glyphicon glyphicon-eye-open"></i></a></td>
		<td>#<?php echo $sell->id; ?></td>

		<td>


<?php
//print_r($sell);
if($sell->item_id!=null){
$mesa = ItemData::getById($sell->item_id);
echo "# ".$mesa->name;
}
//echo count($operations);
?>
</td>
<td><?php echo $sell->getP()->name; ?></td>
<td><?php echo $sell->getD()->name; ?></td>
		<td>

<?php
$operations = OperationData::getAllProductsBySellId($sell->id);
//$total= $sell->total-$sell->discount;
	$total=0;
	foreach($operations as $operation){
		$product  = $operation->getProduct();
		$total += $operation->q*$product->price_out;
	}
		echo "<b>$ ".number_format($total)."</b>";

?>			

		</td>
		<td><?php echo $sell->created_at; ?></td>
		<td style="width:210px;">
		<?php if(isset($_SESSION["user_id"])):?>
<a href="index.php?view=opensell&id=<?php echo $sell->id; ?>" class="btn btn-xs btn-primary"><i class="fa fa-check"></i> Procesar</a>
<a class="btn btn-default btn-xs" target="_blank" href="./ticket-ant.php?id=<?php echo $sell->id;?>">Generar ticket</a>
				<?php endif;?>
		<a href="index.php?view=delsell&id=<?php echo $sell->id; ?>" class="btn btn-xs btn-danger"><i class="fa fa-trash"></i></a>
		</td>
	</tr>

<?php endforeach; ?>

</table>
</div>

<div class="clearfix"></div>

	<?php
}else{
	?>
	<div class="jumbotron">
		<h2>No hay Ventas Pendientes</h2>

	</div>
	<?php
}

?>
<br><br><br><br><br><br><br><br><br><br>
	</div>
</div>
</section>