@extends('layouts.dashboard')
@section('page_title')
BOQ Purchase Requests
@endsection
@section('page_header_title')
BOQ Purchase Requests
@endsection
@php($label_list = EF::getWhiteLabel())

@section('page_body')
{{ Breadcrumbs::render('purchaserequisition') }}
	<div class="row row-cards row-deck">
              <div class="col-12">
                <div class="card">
                	  <div class="card-header">



					     <h3 class="card-title">Purchase Requistions</h3>
							 &nbsp<a class="btn-sm btn-primary" href="{{ route('boq.createboqrequsition')}}">Create Purchase Requisition</a>
					  </div>
                	<div class="card-status card-status-left bg-blue"></div>
                  <div class="table-responsive table-height">
                    <table class="table table-hover table-outline table-vcenter text-nowrap card-table cls_datatable">
                      <thead>
                        <tr>

                          <th>#</th>
                          <th>PR No</th>
                          <th>BOQ No.</th>
													<th>PO No.</th>
                          <!-- <th>Remarks</th> -->
                          <th>Required Date</th>
                          <th>Status</th>
                          <th>Project</th>
                          <th></th>

                   <th style="text-align: center;"><i class="dropdown-icon fa fa-cogs"></i></th>
                        </tr>
                      </thead>
                     <tbody>
                      @if(isset($boq_list))
                      @foreach($boq_list as $rows)
                      <tr>
                        <td>{{$loop->iteration}}</td>
                        <td>PR/000{{$rows->id}}</td>
                        <td>{{$rows->sr_no}}</td>
												<td>
												@if($rows->status == "Approved")
												<?php $mpr = $rows->getPOnumber($rows->id);?>

					                @foreach($mpr as $mp)
														{{$mp->p_number}},
													@endforeach
												@elseif($rows->status == "In Process")
						             ---
					              @elseif($rows->status == "Pending")
					                 ---
					              @else
					                ---
					              @endif
											</td>

                                  <!-- <td><p style="word-wrap: break-word;">{!!wordwrap($rows->remarks,40,'<br>')!!}</p></td> -->
                        <td>{{EF::dateFormat($rows->created_at)}}</td>
                        <td>
                            @if($rows->status == "Approved")
                              <span class="badge badge-success"> {{$rows->status}}</span>
                            @elseif($rows->status == "In Process")
                              <span class="badge badge-warning"> In Process</span>
                            @elseif($rows->status == "Pending")
                              <span class="badge badge-danger"> Not approved yet</span>

                            @elseif($rows->status == "Waiting")
                              <span class="badge badge-danger"> Waiting</span>
                            @elseif($rows->status == "Completed")
                              <span class="badge badge-success"> {{$rows->status}}</span>
                            @else
                              <span class="badge badge-danger"> {{$rows->status}}</span>
                            @endif
                        </td>

                        <td>{{$rows->branch->name}}</td>
                                 <td>
                                      @if(Auth::user()->hasAnyPermission(['All','PR Document']))
                                  <abbr title ="Download Purchase Requisition"><a href="{{ route('downloadPDF.pr', Crypt::encrypt($rows->id))}}" target="_blank"><i class="fa fa-print"></i></a></abbr>
                                  @endif
                                </td>
                                   <td class="text-center">
                                  <div class="item-action dropdown">
                                    <a href="javascript:void(0)" data-toggle="dropdown" class="icon"><i class="fa fa-list-ul"></i></a>

                                    <div class="dropdown-menu dropdown-menu-right">
                                      @if($rows->status == 'Waiting' && Auth::user()->hasAnyPermission(['All','Accept PR']))
                                      <a  href="{{route('boqrequest.details',['id' => Crypt::encrypt($rows->id)])}}"  class="dropdown-item" content="accept boq"><i class="dropdown-icon fa fa-check "></i> Accept</a>
                                      @endif
                                      @if($rows->status == 'Waiting' && Auth::user()->hasAnyPermission(['All','Reject PR']))
                                      <a  href="{{route('boq.reject',['id' => Crypt::encrypt($rows->id)])}}"  class="dropdown-item cls_delete" content="reject pr"><i class="dropdown-icon fa fa-times "></i> Reject</a>
                                      @endif
                                      @if( ($rows->status == 'Approved' || $rows->status == 'In Process') && Auth::user()->hasAnyPermission(['All','Reject PR']))
                                      <a  href="{{route('pr.detail',['id' => Crypt::encrypt($rows->id)])}}"  class="dropdown-item" content="accept boq"><i class="dropdown-icon fa fa-eye "></i> Details</a>
                                      @endif

                                    </div>
                                  </div>
                               </td>
                      </tr>
                      @endforeach
                      @endif
                      </tbody>
                    </table>
                  </div>
                </div>
              </div>
          </div>
					@if(count($alerts) > 0)
					  <!-- Position it -->
					  <!-- <div style="position: fixed; top: 50px; right: 20px;">


							@foreach($alerts as $ra)

				<div class="alert alert-danger alert-dismissible">
    <a href="#" class="close" data-dismiss="alert" aria-label="close"></a>
    <strong>Alert!</strong> Purchase Requisition with # "{{$ra->getBOQById($ra->bill_of_quantity_id)->sr_no}}" is pending.
  </div>
			@endforeach

</div> -->
@endif

@endsection

@section('page_modal')

@endsection

@section('page_script')

@endsection
