@extends('layouts.dashboard')
@section('page_title')
	Manage PO
@endsection
@section('page_header_title')
	Manage PO
@endsection
@section('page_body')
{{ Breadcrumbs::render('pocreate',Crypt::encrypt($boq_detail->id)) }}
@php($label_list = EF::getWhiteLabel())
 <div class="my-3 my-md-5">
          <div class="container">
            <div class="row">
              <div class="col-md-12">
                <div class="card">
                  <div class="card-header">
                    <h3 class="card-title"><b>Create PO against ({{$boq_detail->sr_no}})</b> <span class="label label-danger"> Pending </span></h3>
                  </div>

                  <div class="card-body">
                    <div class = "card">
                      <div class ="card-body">
                        <div class ="row">
                          <div class="col-md-4"> <h5>Sr # <b> {{$boq_detail->sr_no}}</b></h5></div>
                          <div class="col-md-4"> <h5>Project : <b>{{$boq_detail->branch->name}}</b></h5></div>
                          <div class="col-md-4"> <h5>Created At : <b> {{EF::dateFormat($boq_detail->created_at)}}</b></h5></div>
                          <div class="col-md-12"> <h5>Remarks: <b> {{$boq_detail->remarks}}</b></h5></div>
                        </div>
                        <hr style="width:100%;border-top:1px solid #1d55a5 !important">

                        <div class ="row">
                          <div class="col-md-12"> <h3>List of Items requested in Purchase Requisition</h3></div>
                        </div>	
						{{ Form::open(array('route' => 'boq.accept', 'id' => 'form_accept_boq', 'class' => 'cls_from ', 'enctype' => 'multipart/form-data')) }}

                        @if(isset($boq_items_lists))
						<div class="row" style="border: 1px solid #1c55a5;padding: 5px;box-shadow: 0px 5px 8px 0px #888888;">
                          <div class="col-md-12 wrapper">
							<table class="table table-bordered table-stripped">
								<thead>
									<tr>
										<td>Sr#</td>
										<td>Item Name</td>
										<td>Suppliers<i style = "color:red;">*</i></td>
										<td>Brand: <i style = "color:red;">*</i></td>
										<td></td>
										<td>Unit Price<i style = "color:red;">*</i></td>
										<td>Required Quantity</td>

										<td>Remarks</td>
										<td>Upload Quotation</td>
										<!-- <td>Type</td>
										<td>Category</td>
										<td>Quantity Range</td>
										<td>Unit</td>
										<td>Required Qty</td>
										<td>Remarks</td> -->
									</tr>
								</thead>
								<tbody>
                          @foreach($boq_items_lists as $row)
						
							<tr>
								<td>{{$loop->iteration}}</td>
								<td>{{$row->item->name}}</td>
								@if($row->item->type == "Service")
								<td>
									Contractors<i style = "color:red;">*</i>
									<small class="form-errors pull-right req" value="*">{{ $errors->first('user_id[]',":message") }}</small>
									<div class="input-group mb-3">
									<select  class="form-control form-control-sm category_list select1" name= "user_id[]" required>
										<option value = "{{Crypt::encrypt(0)}}">Select Contractor</option>
										@foreach($contractors as $contractor)
										<option value="{{Crypt::encrypt($contractor->id)}}">{{$contractor->name}}</option>
										@endforeach
									</select>
									</div>
								</td>
								<td></td>
								<td></td>
								@endif
								@if($row->item->type == "Product")
								<td>

								<small class="form-errors pull-right req" value="*">{{ $errors->first('user_id[]',":message") }}</small>
								<div class="input-group mb-3">
								<select  class="form-control form-control-sm select1" name= "user_id[]" required>
									<option value = "{{Crypt::encrypt(0)}}">Select Supplier</option>
									@foreach($suppliers as $supplier)
									<option value="{{Crypt::encrypt($supplier->id)}}">{{$supplier->name}}</option>
									@endforeach
								</select>
								</div>
								</td>
								
								<td>
								<small class="form-errors pull-right req" value="*">{{ $errors->first('brand_list',":message") }}</small>

								<div class="input-group mb-3">
								<select  class="form-control form-control-sm  select1 brand_list{{$loop->iteration}} cls_selection" onchange="addOtherBrand(event,this,'{{$loop->iteration}}');" name= "brand_list[]">
									<option value = "0">Select Brand</option>
									@foreach($brand_list as $rows)
										<option value = "{{$rows->brand}}">{{ucwords($rows->brand)}}</option>
									@endforeach

									<option value = "Other">Other</option>
								</select>
								</div>
								</td>
								<td>
								<div class = "col-md-12" style ="display:none;width:100%" id="brand_div{{$loop->iteration}}" >
								Added Brand:
									<input type ="text" name="new_brand[]" class = "form-control form-control-sm brand"/>
								</div>
								</td>
								
								@endif

								<td>
									<small class="form-errors pull-right req" value="">{{ $errors->first('unit_price[]',":message") }}</small>
									<div class="input-group mb-3">
									{{Form::text('unit_price[]', '', ['class' => 'form-control form-control-sm cls_required', 'placeholder' => 'Unit Price' , 'aria-label' => 'Default', 'aria-describedby' => 'inputGroup-sizing-default' , 'required'=>'required' ,'min'=>'1'])}}
									</div>
								</td>

								<td>{{$row->quantity}}</td>

								<td>
									<small class="form-errors pull-right req" value="">{{ $errors->first('remarks[]',":message") }}</small>
									<div class="input-group mb-3">
									{{Form::text('remarks[]', '', ['class' => 'form-control form-control-sm cls_required', 'placeholder' => 'Remarks' , 'aria-label' => 'Default', 'aria-describedby' => 'inputGroup-sizing-default'])}}
								</div>
								</td>

								<td>

								<small class="form-errors pull-right " value="">{{ $errors->first('quotation[]',":message") }}</small>
								<div class="input-group mb-3">
									<div class="input-group-prepend">
										<span class="input-group-text" id="inputGroup-sizing-default">
											<i class="fa fa-file "></i>
										</span>
									</div>
									<input type="file" name="quotation[]" class="form-control form-control-sm btn-xsm" required>
								<div class="input-group-prepend">
										<span class="input-group-text" id="inputGroup-sizing-default">
											<i class ="userimage" >PDF,DOC,DOCX,XLS</i>
										</span>
									</div>

								</div>
								</td>
							<input type="hidden" value="{{Crypt::encrypt($boq_detail->id)}}" name="boq_id[]"/>
							<input type="hidden" value="{{Crypt::encrypt($row->id)}}" name="boq_item_id[]"/>
							<!-- <td>{{$row->item->type}}</td>
							<td>{{$row->item->inventoryCategory->name}}</td>
							<td>{{$row->item->minimum}} {{$row->item->maximum}}</td>
							<td>{{$row->item->inventoryUnit->name}}</td>
							<td>{{$row->quantity}}</td>
							<td>{{$row->item_description}}</td> -->
						</tr>

						@endforeach
							</tbody>
						</table>

						</div>
					</div>
				@endif


				<div class="row">
					<div class="col-md-12" style="margin-top:15px;">
						<button class="btn btn-success cls_submit" content="Approve PO " style="width:100%">Approve PO</button>
					</div>
				</div>
				{{ Form::close() }}

                </div>
                </div>
              </div>
            </div>
            </div>
          </div>


@endsection

@section('page_modal')

@endsection

@section('page_script')

   @include('inventory_module.scripts.boq')

@endsection
