@extends('layouts.dashboard')
@section('page_title')
	Manage Contractor
@endsection
@section('page_header_title')
	Manage Contractor
@endsection
@section('page_body')
{{ Breadcrumbs::render('addboqform') }}
@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>Add Bill Of Quantity (BOQ)</b></h3>
                  </div>
  				{{ Form::open(array('route' => 'boq.store', 'id' => 'form_add_boq', 'class' => 'cls_from ', 'enctype' => 'multipart/form-data')) }}
                  <div class="card-body">
										<div class = "col-md-12">
											 <label class="label-color">{{ucwords(str_replace('_',' ',$label_list['branch']))}}: <i style = "color:red;">*</i></label>
			<small class="form-errors pull-right req" value="*">{{ $errors->first($label_list['branch'],":message") }}</small>

			<div class="input-group mb-3">

				@php($branch_label = EF::branchWhiteLabel())
				<select name="project"  required class="form-control form-control-sm cls_selection branch" id="b_id" onChange="getPlotTypeList(event,this)">
					 <option value="0">Select {{ucwords(str_replace('_',' ',$branch_label['module']))}}</option>
					@foreach($branch as $rows)
							@if(Auth::user()->usertoprojectCheck($rows->id) == 1 || Auth::user()->type="Super Admin")
						<option @if(isset($current_branch) && $rows->id === $current_branch) selected  @endif value="{{Crypt::encrypt($rows->id)}}">{{$rows->code}} {{$rows->name}}</option>
						@endif
					@endforeach
				</select>
			</div>
			<!-- <input type="hidden" name="project"  id="setpid" /> -->
			<!-- <input type="hidden" name="au_user"  id="setuid" /> -->
			</div>
			<div class = "col-md-12">
					<label class="label-color">Designation: <i style = "color:red;">*</i></label>
			<div class="input-group mb-3">
			<select name="dl_id" onchange="getUserlist()" required class="form-control form-control-sm cls_selection branch" id="dl_id" >
			<option  value="0" id="mydegid">Please Select Designation</option>
			@foreach($designation_list as $dl)
			<option  value="{{Crypt::encrypt($dl->id)}}">{{$dl->title}}</option>
			@endforeach
			</select>
			</div>
			</div>


			<div class = "col-md-12">
					<label class="label-color">Demanded By: <i style = "color:red;">*</i></label>
			<div class="input-group mb-3">
			<select name="au_user" required class="form-control form-control-sm cls_selection branch" id="au_id" required>

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

			<div class = "col-md-12">
				<label class="label-color">Floor: <i style = "color:red;">*</i></label>
					<small class="form-errors pull-right req" value="*">{{ $errors->first('floor_list',":message") }}</small>
					<div class="input-group mb-3">
				<select  class="form-control form-control-sm  select1 floor_list cls_selection" onchange="addOtherFloor(event,this);" name= "floor_list">
						<option value = "0">Select Floor</option>
						@foreach($floor_list as $rows)
								<option value = "{{$rows->floor}}">{{ucwords($rows->floor)}}</option>
						@endforeach
							<option value = "Other">Other</option>
					</select>
					</div>
					</div>
					<div class = "col-md-12 floor_div" style ="display:none;" >
					<label class="label-color">Added Floor: </label>
					 <input type ="text" name="new_floor" class = "form-control form-control-sm floor"/>
					 </div>
					 <?php $cudate = date('Y-m-d'); ?>
					<div class = "col-md-12">
						<label class="label-color">Required Date<i style = "color:red;">*</i>:</label>
 <input type ="date" name= "item_date" min="{{$cudate}}" class = "form-control form-control-sm date" required/>
			</div>

			<div class="col-md-12">
			<label class="label-color">Remarks:</label>
				{{Form::textarea('remarks', '', ['class' => 'form-control form-control-sm', 'placeholder' => 'Remarks' ,'rows'=>'3', 'aria-label' => 'Default', 'aria-describedby' => 'inputGroup-sizing-default'])}}

			</div>
		<div class = "card">
			<div class ="card-body">
			<div class = "row">
			<div class = "col-md-12">
				<div class ="card box" style = "margin-top:2%; border:2px solid #82a4bb;">
					<div class ="card-header">
						<center><h5>BOQ ITEMS</h5></center>
					</div>
					<div class = "card-body">
					<div class="table-responsive ">
						<table class="table table-bordered table-stripped table-hover table-fixed  table-outline table-vcenter text-nowrap card-table " id="boq_item_table" style ="margin-bottom:4%;">
						<thead>
						<tr>
						<th>Product/Item<i style = "color:red;">*</i></th>
						<th>Required Quantity</th>
						<th>Unit</th>
						<th>Description</th>
						</tr>
						</thead>
							<tbody>
								<!-- 1 -->
								<?php $tb_count = 20; ?>
								<?php for($i=0;$i<$tb_count;$i++){ ?>
								<tr id="'trid_{{$i}}">
									<td>

							<select class="form-control    select2" placeholder="Select Your Favorite" name= "item[]"    >
									<option value = "{{Crypt::encrypt(0)}}">Select Item</option>
									@foreach($items as $rows)
									<option value="{{Crypt::encrypt($rows->id)}}"  >{{$rows->code}} | {{$rows->name}}</option>
									@endforeach
							</select>

									</td>
									<td>
										<div class = "col-md-12">
											<input type ="number" name= "item_quantity[]" class = "form-control form-control-sm quantity" placeholder = "Qty" />
											</div>
									</td>
								<td>
									<div class = "col-md-12">
							<select class="form-control item_unit select2" name= "item_unit[]">
									<option value = "{{Crypt::encrypt(0)}}">Select Unit</option>
									@foreach($unit_list as $rows)
									<option value="{{Crypt::encrypt($rows->id)}}">{{$rows->name}}</option>
									@endforeach
							</select>
							<small class="btn-sm btn-primary" onclick="showModal('form_add_unit','md_add_unit')"><i class="fa fa-plus"> </i></small>
									</div>
								</td>
								<td>
								{{Form::textarea('item_description[]', '', ['class' => 'form-control form-control-sm', 'placeholder' => 'Description' ,'rows'=>'3', 'aria-label' => 'Default', 'aria-describedby' => 'inputGroup-sizing-default'])}}
								</td>
							</tr>
							<?php };?>
								</tbody>
								<tfoot >
								</tfoot>
						</table>
					</div>
						<input type="submit" class="btn btn-primary pull-right" value="Add BOQ"></input>
					</div>

					</div>
					</div>
				</div>
                      </div>
                    </div>
										</div>
                    {{ Form::close() }}
                </div>
              </div>
            </div>
          </div>
@endsection
@section('page_modal')
  <div class="modal fade" id="md_add_unit" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  {{ Form::open(array('route' => 'inventory_unit.store' , 'id' => 'form_add_unit', 'class' => 'cls_form' , 'method' => 'POST' , 'enctype'=>'multipart/form-data'
)) }}
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Add Unit</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true"></span>
        </button>
      </div>
      <div class="modal-body ">
        <div class ="card">
          <div class = "card-body form-fieldset">
          <div class="row">


            <div class="col-sm-12">
            <label class="label-color"> Name: <i style = "color:red;">*</i></label>
            <div class="input-group mb-3">
              <input type="text" name="name" class="form-control " required id="name" />
            </div>
            </div>


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


      <div class="modal-footer">

        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>

        <button type="submit" onClick="storeInventoryUnit(event,this)" class="btn btn-primary"   content="add unit">Add Unit</button>

      </div>
      {{ Form::close() }}
    </div>
  </div>

</div>



@endsection

@section('page_script')

   @include('inventory_module.scripts.boq')

@endsection
