<?php $__env->startSection("content"); ?>
<div>
	<ol class="breadcrumb">
	  <li><a href="<?php echo e(URL::route('user.home')); ?>"><?php echo trans('messages.home'); ?></a></li>
	  <li class="active">Purchase Requests</li>
	</ol>
</div>
<?php if(Session::has('message')): ?>
	<div class="alert alert-info"><?php echo trans(Session::get('message')); ?></div>
<?php endif; ?>
<div class="panel panel-default">
	<div class="panel-heading ">
		<span class="glyphicon glyphicon-list"></span>
		VL & EID Purchase Requests
		<div class="panel-btn">
			<a class="btn btn-sm btn-info" href="<?php echo URL::route('order.create'); ?>" >
				<span class="glyphicon glyphicon-plus-sign"></span>
				New Purchase Request
			</a>
		</div>
	</div>

	<div class="panel-body">

		<table class="table table-striped table-hover table-condensed search-table">
			<thead>
				<tr>
					<th>#</th>
					<th class="text-center">Order Number</th>
					<th class="text-center">Date Prepared</th>
					<th class="text-center">Period</th>
					<th class="text-center">Product Description</th>
					<th class="text-center">Pack Size</th>
					<th class="text-center">Opening Balance</th>
					<th class="text-center">Qty Received <br><small>During the period</small></th>
					<th class="text-center">Consumption <br><small>During the period</small></th>
					<th class="text-center">Losses / Adjustments <br><small>(- / +)</small></th>
					<th class="text-center">Total Closing Balance</th>
					<th class="text-center">Quantity Required</th>
					<th class="text-center">Comments</th>
					<!-- <th class="text-center">Date on wich items are required</th> -->
					<th class="text-center">Status</th>
					<th class="text-center">Options</th>
				</tr>
			</thead>
			<tbody>
				 <?php $row=1; ?>
			<?php foreach($orders as $order): ?>
				<tr>
						<td class="text-center"><?php echo $row; ?></td>
					<td><?php echo $order->order_number; ?></td>
					<td><?php echo $order->date_prepared; ?></td>
					<td><?php echo $order->start_date; ?> - <?php echo $order->end_date; ?></td>
					<td><?php echo $order->commodity->name; ?></td>
					<td><?php echo $order->pack_size; ?></td>
					<td class="text-center"><?php echo $order->opening_balance; ?></td>
					<td class="text-center"><?php echo $order->qty_received; ?></td>
					<td class="text-center"><?php echo $order->consumption; ?></td>
					<td class="text-center"><?php echo $order->losses_adjustments; ?></td>
					<td class="text-center"><?php echo $order->closing_balance; ?></td>
					<td class="text-center"><?php echo $order->qty_required; ?></td>
					<td class="text-center"><?php echo $order->comment; ?></td>
					<!-- <td class="text-center"><?php echo $order->date_required; ?></td> -->
					<td>
					<!-- status -->
					<?php if($order->isApproved()): ?>
						<span class='label label-success'>Approved</span>
					<?php elseif($order->isRejected()): ?>
						<span class='label label-danger'>Rejected</span>
					<?php else: ?>
						<span class='label label-info'>Pending</span>
					</td>
					<td>
					<!--
                    <a class="btn btn-sm btn-info"
                        href="<?php echo URL::route('order.show', $order->id); ?>"
                        title="View Order Details">
                        <span class="glyphicon glyphicon-eye-open"></span>
                        View
                    </a>
					<button class="btn btn-sm btn-danger delete-item-link"
						data-toggle="modal" data-target=".confirm-delete-modal"
						data-id="<?php echo URL::route('order.destroy', array($order->id)); ?>">
						<span class="glyphicon glyphicon-trash"></span>
						<?php echo trans('messages.delete'); ?>

					</button>
					-->
					<!-- edit this commodity (uses the edit method found at GET /inventory/{id}/edit -->
						<a class="btn btn-sm btn-info" href="<?php echo URL::route('order.edit', array($order->id)); ?>" >
							<span class="glyphicon glyphicon-edit"></span>
							<?php echo trans('messages.edit'); ?>

						</a>
						<?php if($order->isApproved()): ?>
						<a class="btn btn-sm btn-primary" href="<?php echo URL::route('order.lpi', array($order->id)); ?>"
							title="Print Order Document">
							<span class="glyphicon glyphicon-print"></span>
							LPI
						</a>
						<a class="btn btn-sm btn-primary" href="<?php echo URL::route('purchase.request', array($order->id)); ?>"
							title="Print Order Document">
							<span class="glyphicon glyphicon-print"></span>
							PR
						</a>
						<?php else: ?>
						<a class="btn btn-sm btn-danger" href="<?php echo URL::route('order.reject', array($order->id)); ?>"
							title="Reject Oder">
							<span class="glyphicon glyphicon-thumbs-down"></span>
							Reject
						</a>
						<a class="btn btn-sm btn-success" href="<?php echo URL::route('order.approve', array($order->id)); ?>"
							title="Approve Order">
							<span class="glyphicon glyphicon-thumbs-up"></span>
							Approve
						</a>
						<?php endif; ?>
					<?php endif; ?>
					</td>
				</tr>
				<?php $row++; ?>
				<?php endforeach; ?>
			</tbody>
			</table>
		<?php Session::put('SOURCE_URL', URL::full());?>
	</div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make("layout", array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>