@extends('backend.layouts.master')

@section('title', 'Stock List')

@push('css')

@endpush

@section('content')
	<div class="right_col" role="main">
        <div class="">
            <div class="clearfix"></div>
            <div class="row">
                <div class="col-md-12 col-sm-12 col-xs-12">
                    <div class="x_panel">
                        <div class="x_title">
                            <a href="{{ route('purchase.create')}}" calss="btn" ><h2><i class="fa fa-mail-reply"></i></h2></a>
                            <h2>Stock List</h2>
                            <ul class="nav navbar-right panel_toolbox">
                                <li><a class="collapse-" onclick="printDiv('printableArea')" ><i class="fa fa-print fa-2x"></i></a>
                                <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                                </li>
                                <li class="dropdown">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                                    <ul class="dropdown-menu" role="menu">
                                        <li><a href="#">Settings 1</a>
                                        </li>
                                        <li><a href="#">Settings 2</a>
                                        </li>
                                    </ul>
                                </li>
                                <li><a class="close-link"><i class="fa fa-close"></i></a>
                                </li>
                            </ul>
                            <div class="clearfix"></div>
                        </div>
                        <div class="x_content">
							<!--<div class="row search-section">
								<form action="{{route('stock.stocks')}}" id="searchForm" method="Post">
									{{csrf_field() }}
									<div class="col-sm-2">
									</div>
									<div class="col-sm-4">
										<div class="form-group">
											<label class="col-sm-4 control-label no-padding-right" for="form-field-1"> Search By</label>
											<div class="col-sm-8">
												<select class="form-control" name="search_by" id="show">
													<option value="product_name">Product Name</option>
													<option value="model_no">Code Number</option>
												</select>
											</div>
										</div>
									</div>
									<div class="col-sm-5">
										<div class="form-group">
											<label class="col-sm-4 control-label no-padding-right" for="form-field-1"> Search Value</label>
											<div class="col-sm-8">
												<div class="input-group">
													<input type="text" id="" name="search_value" class="form-control" placeholder="Search Value">
													<span class="input-group-btn">
														<button type="submit" class="btn btn-purple btn-sm">
														<span class="ace-icon fa fa-search icon-on-right bigger-110"></span></button>
													</span>
												</div>
											</div>
										</div>
									</div>
								</form>
							</div>-->
							<div class="">
									<div class="col-sm-12">
											<div class="input-group">
												<input type="text" id="myInput" class="form-control" placeholder="Search">
												<span class="input-group-btn">
													<button type="button" class="btn btn-primary">
													<span class="ace-icon fa fa-search icon-on-right bigger-110"></span></button>
												</span>
											</div>
									</div>
								</div><br/>
							<hr/>
							<div class="table-content" id="printableArea">
								<div class="text-center">
									<h5>{{about()->bangla_name}}</h5>
									{{about()->address}}<br/>
								</div>
								<br/>
								<table id="" class="table table-bordered table-condensed" role="grid" aria-describedby="dynamic-table_info">
									<thead>
										<tr class="bg-primary">
											<th>SL</th>
											<th>Product</th>
											<th>Code</th>
											<th>Category</th>
											<th>Unit</th>
											<th>Stock</th>
											<!--<th>Action</th>-->
										</tr>
									</thead>
									<tbody>
										@php
											$total_stock = 0;
										@endphp
										@foreach($products as $key=>$pro)
											@php
												$total_stock = $total_stock + $pro->product_stock;
											@endphp
											<tr class="{{$pro->product_stock < $pro->re_order_label ? 'bg-danger' : 'bg-info'}} ">
												<td>{{$key + 1}}</td>
												<td>{{$pro->product_name}}</td>
												<td>{{$pro->code}}</td>
												<td>{{$pro->category_name}}</td>
												<td>{{$pro->unit_name}}</td>
												<td>{{$pro->product_stock}}</td>
												<!--<td>
												@can('stock-list')
													<a  href="{{route('admin.order.create')}}" title="Order the Product"><i class="ace-icon fa fa-shopping-cart bigger-130"></i></a>
												@endcan
												</td>-->
											</tr>
										@endforeach
											<tr>
												<td colspan="4"></td>
												<td>Total =</td>
												<td>{{$total_stock}}</td>
											</tr>
									</tbody>
								</table>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		
	</div>
@endsection

@push('js')
<script>
	$(document).ready(function(){
		// select2 section
		$('.select2').select2()	;
		/*-------search section------------*/

	})
	/*---------print section-------------*/
	function printDiv(divName) {
		 var printContents = document.getElementById(divName).innerHTML;
		 var originalContents = document.body.innerHTML;

		 document.body.innerHTML = printContents;

		 window.print();

		 document.body.innerHTML = originalContents;
		}
	</script>
@endpush									