<?php $__env->startSection("content"); ?>

<!-- Main content -->
<section class="content">
	<!-- Small boxes (Stat box) -->
	<div class="row">


				<div class="col-lg-2 col-xs-3">
					<!-- small box -->
					<div class="small-box bg-blue">
						<div class="inner">
							<p>You Have</p>
							<h3><?php echo $count = Inhouse::where('user_id', '=', Auth::user()->id)->orWhere('incharge_mail', '=', Auth::user()->email)->count(); ?></h3>
							<p> Requests</p>
						</div>
						<div class="icon">
							<i class="ion-social-dropbox	"></i>
						</div>
						<a href="<?php echo URL::route('inhouserequest.index'); ?>" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
					</div>
				</div>

		<div class="col-lg-2 col-xs-3">
			<!-- small box -->
			<div class="small-box bg-gray">
				<div class="inner">
					<h3><?php echo $count = Inhouse::where('request_status_id', '=', '0')->count(); ?></h3>

					<p>PENDING REQUESTS</p>
				</div>
				<div class="icon">
					<i class="fa fa-circle-o-notch fa-spin fa-1x fa-fw"></i>
				</div>

			</div>
		</div>

		<div class="col-lg-2 col-xs-3">
			<!-- small box -->
			<div class="small-box bg-green">
				<div class="inner">
					<h3><?php echo $count = Inhouse::where('request_status_id', '=', '1')->count(); ?><sup style="font-size: 20px">%</sup></h3>

					<p>APPROVED REQUESTS</p>
				</div>
				<div class="icon">
					<i class="ion-android-checkmark-circle"></i>
				</div>
				<a href="<?php echo URL::route('inhouserequest.approved'); ?>" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
			</div>
		</div>

		<div class="col-lg-2 col-xs-3">
			<!-- small box -->
			<div class="small-box bg-aqua">
				<div class="inner">
					<h3><?php echo $count = Inhouse::where('request_status_id', '=', '3')->count(); ?></h3>

					<p>ISSUED REQUESTS</p>
				</div>
				<div class="icon">
					<i class="ion-ios-cart"></i>
				</div>
				<a href="#" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
			</div>
		</div>

		<div class="col-lg-2 col-xs-3">
			<!-- small box -->
			<div class="small-box bg-red">
				<div class="inner">
					<h3><?php echo $count = Inhouse::where('request_status_id', '=', '2')->count(); ?></h3>

					<p>REJECTED REQUESTS</p>
				</div>
				<div class="icon">
					<i class="ion-android-close"></i>
				</div>
				<a href="#" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
			</div>
		</div>
	</div>

	<div class="row">
		<div class="col-md-12">
			<div class="box">
				<!-- TABLE: LATEST ORDERS -->
				<div class="box box-info">
					<div class="box-header with-border">
						<h3 class="box-title">Pending Dept Requests</h3><br><br>
						<a href="<?php echo URL::route('inhouserequest.inhousecreate'); ?>" class="btn btn-sm btn-info btn-flat pull-left">Place New Order</a>

						<div class="box-tools pull-right">
							<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
							</button>
							<button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
						</div>
					</div>
					<!-- /.box-header -->
					<div class="box-body">
						<div class="table-responsive">
							<table id='example1' class="table table-striped table-hover table-bordered search-table">
								<thead>
									<tr>
										<th class="text-center">Folio Number</th>
										<th class="text-center">Item</th>
										<!--<th class="text-center">Issue Unit</th>-->
										<th class="text-center">Quantity</th>
										<th class="text-center">Requested By</th>
										<th class="text-center">Requestor's Email</th>
										<th class="text-center">Department</th>
										<th class="text-center">Incharge's Email</th>
										<th class="text-center">Approved <br> <i>or</i><br> Rejected By <br><i><b>(HoD)</b></i></th>
										<th class="text-center">Approved <br> <i>or</i><br> Rejected By <br><i><b>(Stores)</b></i></th>
										<th class="text-center">Stock Issued By</th>
										<th class="text-center">Request Date</th>
										<th class="text-center">Status</th>
										<th class="text-center"></th>
									</tr>
								</thead>

								<tbody>

									<?php $row=1; ?>
									<?php foreach($pending as $value): ?>
									<tr>
										<td class="text-center"><?php echo $row; ?></td>
										<?php if($value->commodity_id == 0): ?>
										<td class="text-center" style="color:red"><i>no commodity selected</i></td>
										<?php else: ?>
										<td><?php echo $value->commodity->name; ?></td>
										<?php endif; ?>
										<td class="text-center"><?php echo $value->quantity; ?></td>
										<td><?php echo $value->requested_by; ?></td>
										<td><?php echo $value->requestor_email; ?></td>
										<?php if($value->department == ''): ?>
										<td class="text-center" style="color:red"><i>no dept selected</i></td>
										<?php else: ?>
										<td><?php echo $department[$value->department]; ?></td>
										<?php endif; ?>
										<td><?php echo $value->incharge_mail; ?></td>
										<td><?php echo $value->approved_by; ?></td>
										<td><?php echo $value->store_approved_by; ?></td>
										<td><?php echo $value->issued_by; ?></td>
										<td class="text-center"><?php echo $value->created_at; ?></td>
										<td>
											<!-- status -->
											<?php if($value->isApproved()): ?>
											<span class='label label-success'>Approved</span>
											<?php elseif($value->isRejected()): ?>
											<span class='label label-danger'>Rejected</span>
											<?php elseif($value->isIssued()): ?>
											<span class='label label-default'>Stock Issued</span>
											<?php elseif($value->isStoreApproved()): ?>
											<span class='label label-info'>Approved By Stores</span>
											<?php else: ?>
											<span class='label label-warning'>Pending</span>
											<?php endif; ?>
										</td>
										<td>
											<?php if($value->isStoreApproved() && !$value->isPending() && (Entrust::can('manage_inventory'))): ?>
											<a class="btn btn-sm btn-success" href="<?php echo URL::route('inhouserequest.issuestock', array($value->id)); ?>"title="issue_stock">
												<span class="glyphicon glyphicon-eye-open"></span> Issue Stock</a>

												<a class="btn btn-sm btn-primary" href="#"title="Print Request Document">
													<span class="glyphicon glyphicon-print"></span> View</a>

													<?php elseif(Auth::user()->id == $value->user_id && $value->isPending()): ?>
													<!-- Delete or edit only what you have initiated -->
													<button class="btn btn-sm btn-danger delete-item-link" data-toggle="modal" data-target=".confirm-delete-modal"
													data-id="<?php echo URL::route('inhouserequest.delete', array($value->id)); ?>">
													<span class="glyphicon glyphicon-trash"></span>
													<?php echo trans('messages.delete'); ?>

												</button>

												<!--  edit requisition-->
												<a class="btn btn-sm btn-info" href="<?php echo URL::route('inhouserequest.edit', array($value->id)); ?>" >
													<span class="glyphicon glyphicon-edit"></span><?php echo trans('messages.edit'); ?></a>

													<?php elseif(Entrust::can('approve_dept_request') && $value->request_status_id =='0' && Auth::user()->id != $value->user_id &&  Auth::user()->email == $value->incharge_mail): ?>
													<a class="btn btn-sm btn-danger" href="<?php echo URL::route('inhouserequest.reject', array($value->id)); ?>"title="Reject request">
														<span class="glyphicon glyphicon-thumbs-down"></span>	Reject</a>
														<a class="btn btn-sm btn-success" href="<?php echo URL::route('inhouserequest.approve', array($value->id)); ?>"title="Approve Requisition">
															<span class="glyphicon glyphicon-thumbs-up"></span>	Approve	</a>
															<?php endif; ?>
											</td>
										</tr>
										<?php $row++; ?>
										<?php endforeach; ?>
									</tbody>

								</table>
								<?php Session::put('SOURCE_URL', URL::full());?>
							</div>
						</div>
						<!-- /.box-body -->
						<div class="box-footer clearfix">

							<a href="javascript:void(0)" class="btn btn-sm btn-default btn-flat pull-right">View All Orders</a>
						</div>
					</div>
				</div>
			</div>
		</section>
	</div>
	<?php $__env->stopSection(); ?>

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