<?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"><?php echo Lang::choice('messages.report',2); ?></li>
	  <li class="active"><?php echo trans('messages.stock-level-report'); ?></li>
	</ol>
</div>

<?php echo Form::open(array('route' => array('reports.inventory'), 'class' => 'form-inline', 'role' => 'form')); ?>


<div class='container-fluid'>
	<div class="row">
		<div class="col-md-4"><!-- From Datepicker-->
	    	<div class="row">
				<div class="col-md-2">
					<?php echo Form::label('start', trans("messages.from")); ?>

				</div>
				<div class="col-md-10">
					<?php echo Form::text('start', isset($input['start'])?$input['start']:date('Y-m-d'),
				        array('class' => 'form-control standard-datepicker')); ?>

			    </div>
	    	</div><!-- /.row -->
	    </div>
	    <div class="col-md-4"><!-- To Datepicker-->
	    	<div class="row">
				<div class="col-md-4">
			    	<?php echo Form::label('end', trans("messages.to")); ?>

			    </div>
				<div class="col-md-8">
				    <?php echo Form::text('end', isset($input['end'])?$input['end']:date('Y-m-d'),
				        array('class' => 'form-control standard-datepicker')); ?>

		        </div>
	    	</div><!-- /.row -->
	    </div>

    </div><!-- /.row -->
    <br />
	<div class="row">
          <div class="col-md-4">
	    	<div class="row">
		        <div class="col-md-4">
		        	<?php echo Form::label('report_type', Lang::choice('messages.report-type',1)); ?>

		        </div>
		        <div class="col-md-8">
		            <?php echo Form::select('report_type', $reportTypes,
		            	isset($input['report_type'])?$input['report_type']:0, array('class' => 'form-control')); ?>

		        </div>
	        </div>
	    </div>
	    <div class="col-md-4">
	    <div class="row">
	    <div class="col-md-8">
		    <?php echo Form::button("<span class='glyphicon glyphicon-filter'></span> ".trans('messages.view'),
		        array('class' => 'btn btn-info', 'id' => 'filter', 'type' => 'submit')); ?>

		        </div>
		        </div>
        </div>
	</div><!-- /.row -->
</div><!-- /.container-fluid -->

<?php echo Form::close(); ?>


<br />

<div class="panel panel-primary">

	<div class="panel-heading ">
		<span class="glyphicon glyphicon-user"></span>
		<?php echo trans('messages.stock-level-report'); ?>

	</div>

	<div class="panel-body">
		<?php if(Session::has('message')): ?>
			<div class="alert alert-info"><?php echo trans(Session::get('message')); ?></div>
		<?php endif; ?>

		<div class="table-responsive">
			<div><strong><?php echo $reportTitle; ?></strong></div><br />
			<table class="table table-striped table-hover table-bordered table-condensed search-table">
				<?php if($selectedReport==0): ?> <!-- monthly Report-->
					<thead>
						<tr>
							<th>#</th>
							<th><?php echo Lang::choice('messages.commodity',1); ?></th>
							<th><?php echo Lang::choice('messages.batch-no',1); ?></th>
							<th>Quantity Received</th>
							<th><?php echo Lang::choice('messages.qty-issued',1); ?></th>
							<th><?php echo Lang::choice('messages.current-bal',1); ?></th>
							<th><?php echo Lang::choice('messages.expiry-date',1); ?></th>
						</tr>
					</thead>
					<tbody>

						<?php $i = 1;?>
						<?php $__empty_1 = true; foreach($reportData as $row): $__empty_1 = false; ?>


							<tr>
								<td><?php echo $i++; ?></td>
								<td><?php echo Commodity::find($row->commodity_id)->name; ?></td>
								<td><?php echo $row->batch_number; ?></td>
								<td><?php echo $row->quantity_in; ?></td>
								<td><?php echo $row->quantity_out; ?></td>
								<td><?php echo $row->balance; ?></td>
								<td><?php echo date('d M Y', strtotime($row->expiry_date)); ?></td>
							</tr>
						<?php endforeach; if ($__empty_1): ?>
							<tr>
								<td><?php echo Lang::choice('messages.no-data-found',1); ?></td>
							</tr>
						<?php endif; ?>

					</tbody>

				<?php elseif($selectedReport == 1): ?> <!-- quarterly Report-->
					<thead>
						<tr>
							<th>#</th>
							<th><?php echo Lang::choice('messages.commodity',1); ?></th>
							<th><?php echo Lang::choice('messages.supplier',1); ?></th>
							<th><?php echo Lang::choice('messages.batch-no',1); ?></th>
							<th><?php echo Lang::choice('messages.quantity',1); ?></th>
							<th><?php echo Lang::choice('messages.expiry-date',1); ?></th>
							<th><?php echo Lang::choice('messages.qty-issued',1); ?></th>
							<th><?php echo Lang::choice('messages.current-bal',1); ?></th>
						</tr>
					</thead>
					<tbody>

						<?php $i = 1;?>
						<?php $__empty_1 = true; foreach($reportData as $row): $__empty_1 = false; ?>

							<tr>
								<td><?php echo $i++; ?></td>
								<td><?php echo $row->balance; ?></td>
								<td><?php echo $row->sourceOfStock($row->to_from_type,$row->to_from)->name; ?></td>
								<td><?php echo $row->batch_number; ?></td>
								<td><?php echo $row->quantity; ?></td>
								<td><?php echo date('d M Y', strtotime($row->expiry_date)); ?></td>
								<td></td>
								<td><?php echo $row->balance; ?></td>
							</tr>
						<?php endforeach; if ($__empty_1): ?>
							<tr>
								<td colspan='6'><?php echo Lang::choice('messages.no-data-found',1); ?></td>
							</tr>
						<?php endif; ?>
					</tbody>
				<?php endif; ?>

			</table>
		</div><!--/.table-responsive -->
	</div>
</div><!--/.panel -->

<?php $__env->stopSection(); ?>

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