@extends('layouts.dashboard')
@section('page_title')
	Purchase Order
@endsection
@section('page_header_title')
	Purchase Order
@endsection
@section('page_body')
{{ Breadcrumbs::render('podetail',Crypt::encrypt($po_detail[0]->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>Purchase Order({{$po_detail[0]->status}})</b> </h3>
                  </div>

                  <div class="card-body">
                    <div class = "card">
                      <div class ="card-body">
                        <div class ="row">
                          <div class="col-md-5">
                            <div class="row">
                            <h4 class="col-md-12" style="background:#656877;padding:5px;color:white">Vendor Detail</h4>
                            <div class="col-md-12">
                              <table style="width:100%">
                                <tr>
                                  <th>Name</th>
                                  <td>{{$po_detail[0]->user->name}}</td>
                                </tr>
                                <tr>
                                  <th>Company </th>
                                  <td>{{$po_detail[0]->user->vendorType->name}}</td>
                                </tr>
																<tr>
                                  <th>NTN </th>
                                  <td>{{$po_detail[0]->user->ntn}}</td>
                                </tr>
																<tr>
                                  <th>STRN </th>
                                  <td>{{$po_detail[0]->user->strn}}</td>
                                </tr>
																<tr>
                                  <th>Sales Tax (Exemption) </th>
                                  <td>{{EF::dateFormat($po_detail[0]->user->saletax_date)}}</td>
                                </tr>
																<tr>
                                  <th>Income Tax (Exemption)  </th>
                                  <td>{{EF::dateFormat($po_detail[0]->user->incometax_date)}}</td>
                                </tr>
                                <tr>
                                  <th>Email</th>
                                  <td>{{$po_detail[0]->user->email}}</td>
                                </tr>
                                <tr>
                                  <th>Contact</th>
                                  <td>{{$po_detail[0]->user->contact}}</td>
                                </tr>
                                <tr>
                                  <th>Address</th>
                                  <td>{{$po_detail[0]->user->per_address}}</td>
                                </tr>
                              </table>
                            </div>
                          </div>
                        </div>
                        <div class="col-md-2"></div>
                        <div class="col-md-5">
                          <div class="row">
                          <h4 class="col-md-12" style="background:#656877;padding:5px;color:white">Puchase Order Detail</h4>
                          <div class="col-md-12">
                            <table style="width:100%">
                              <tr>
                                <th>PO Number</th>
                                <td>{{$po_detail[0]->p_number}}</td>
                              </tr>
                              <tr>
                                <th>Created At</th>
                                <td>{{EF::dateFormat($po_detail[0]->created_at)}}</td>
                              </tr>
                              @if($po_detail[0]->status == 'Approved')
                                <tr>
                                <th>Delivery Date</th>
                                <td>{{EF::dateFormat($po_detail[0]->delivery_date)}}</td>
                              </tr>
                              @endif
                              <!-- <tr>
                                <th>BOQ Number</th>
                                <td>{{$po_detail[0]->boq->sr_no}}</td>
                              </tr>
                              <tr>
                                <th>BOQ Remarks</th>
                                <td>{{$po_detail[0]->boq->remarks}}</td>
                              </tr> -->
                            </table>
                          </div>
                        </div>
                      </div>
                        </div>
                        <!-- <hr style="width:100%;border-top:1px solid #1c35b6"> -->
                        <div class ="row">
                          <div class="col-md-12">
                            <table style="width:100%" class="table table-bordered">
                              <thead style="background:#656877;">
                                <tr>
                                  <th>#</th>
                                  <th>Item</th>
                                  <th>Description</th>
                                  <th>Brand</th>
                                  <th>Remarks</th>
                                  <th>Qty</th>
                                  <th>Unit price </th>
                                  <th>Total</th>
                                </tr>
                              </thead>
                              <tbody>
																@foreach($po_detail as $row)
                                <tr>
                                  <td>1</td>
                                  <td>{{$row->boqitem->item->name}}</td>
                                  <td>{{$row->boqitem->item->description}}</td>
                                  <td>{{$row->brand}}</td>
                                  <td>{{$row->boqitem->item_description}}</td>
                                  <td>{{$row->boqitem->quantity}}</td>
                                  <td>{{$row->unit_price}}</td>
                                  <td><b>{{$row->unit_price*$row->boqitem->quantity}}</b></td>
                                </tr>
																@endforeach
                              </tbody>
                            </table>
                          </div>
                        </div>
                        <div class="row">
                          <div class="col-md-2 pull-right">
                          @if($po_detail[0]->status == 'Pending' && Auth::user()->hasAnyPermission(['All','Accept PO']))


                                    <a  onclick="acceptpofun(this.id)" id="{{Crypt::encrypt($po_detail[0]->p_number)}}" class="btn btn-success" style="width:100%" content="accept purchase order"><i class="dropdown-icon fa fa-check " style="color:white;"></i> Accept</a>
                                   @endif

                         </div>
                         <div class="col-md-2 pull-right">
                           @if($po_detail[0]->status == 'Pending' && Auth::user()->hasAnyPermission(['All','Reject PO']))
                           <a  href="{{route('po.reject',['id' => Crypt::encrypt($po_detail[0]->p_number)])}}"  class="btn btn-danger cls_delete" content="reject purchase order" style="width:100%"><i class="dropdown-icon fa fa-times " style="color:white;"></i> Reject</a>
                           @endif
                         </div>
                        </div>
                      </div>
                    </div>
                </div>
                </div>
              </div>
            </div>
            </div>
          </div>


@endsection

@section('page_modal')
<div class="modal fade" id="md_accept_po" tabindex="-1" role="dialog" aria-labelledby="exampleModallabel" aria-hidden="true">
  <div class="modal-dialog modal-lg" role="document">
    {{ Form::open(array('route' => 'po.accept', 'id' => 'form_md_accept_po', 'class' => 'cls_from ', 'enctype' => 'multipart/form-data')) }}
    <div class="modal-content">
      <div class="modal-header header-margin">
        <h5 class="modal-title" id="exampleModallabel">Accept PO</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">
					<?php
						$mydate = date('Y-m-d');
					?>
         <div class="card-body form-fieldset">
          <div class="row">
            <div class="col-sm-12">
            <label class="label-color">Delivery Date:<i style = "color:red;">*</i></label>
            <small class="form-errors pull-right req" value="*"></small>
            <input type="date" required class="form-control" min="{{$mydate}}" name="po_date"/>
          </div>

          <input type="hidden"  value="" id="modal_id_po" name="po_id"/>

      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button  type="submit"  class="btn btn-primary" content="Accept PO">Accept PO</button>
      </div>
    </div>

  </div>

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

@endsection

@section('page_script')

   @include('inventory_module.scripts.boq')
   <script>
  function acceptpofun(id)
  {
    $("#modal_id_po").val(id);
    $("#md_accept_po").modal('show');
  }
</script>

@endsection
