@extends('layouts.masterHome2')

@section('content')


 
    
    <div dir="rtl"  style="padding-top:15px;margin-right:15px;margin-left:15px">
               
            <div class="card" >
              <!-- /.card-header -->
              <div class="card-body p-0" >
                <table class="table table-striped" >
                  <thead >
                    <tr >
                    <th style="text-align:center;vertical-align: middle;">السريال</th>
                    <th style="text-align:center;vertical-align: middle;">تاريخ الاستحقاق</th>
                      <th style="text-align:center;vertical-align: middle;">البنك</th>
                      <th style="text-align:center;vertical-align: middle;">المبلغ</th>
                      <th style="text-align:center;vertical-align: middle;">العميل</th>
                      <th style="text-align:center;vertical-align: middle;">النوع  </th>
                      <th style="text-align:center;vertical-align: middle;">الحالة  </th>
                    </tr>
                  </thead>
                  <tbody>
                    <tr>
                      <td style="text-align:center;vertical-align: middle;">{{$cheque->serial}}</td>
                      <td style="text-align:center;vertical-align: middle;">{{$cheque->date}}</td>
                      <td style="text-align:center;vertical-align: middle;">{{$cheque->bank->name}}</td>
                      <td style="text-align:center;vertical-align: middle;"> {{$cheque->pay}} </td>

                        @if($cheque->client_id)
                        <th style="text-align:center;vertical-align: middle; "> {{$cheque->client->name}}    </th>
                        @elseif ( $cheque->payment_voucher_id  && $cheque->payment_voucher->budget_id )
                        <th style="text-align:center;vertical-align: middle; "> {{ $cheque->payment_voucher->budget->name}}    </th>
                        @elseif ( $cheque->payment_voucher_id  && $cheque->payment_voucher->employee_id)
                        <th style="text-align:center;vertical-align: middle;">   {{ $cheque->payment_voucher->employee->name }}  </th>
                        @elseif ($cheque->payment_voucher_id  &&  $cheque->payment_voucher->car_id)
                        <th style="text-align:center;vertical-align: middle;">   {{ $cheque->payment_voucher->car_expense->name }}  </th>
                        @elseif ($cheque->payment_voucher_id  && $cheque->payment_voucher->general_name )
                        <th style="text-align:center;vertical-align: middle;">   {{ $cheque->payment_voucher->general_name }}  </th>
                        @else
                        <th style="text-align:center;vertical-align: middle;">     </th>
                        @endif
                        <th style="text-align:center;vertical-align: middle;"> 
                        @if($cheque->invoice_id)
                        <span><a   href='{{url("/invoice/details/$cheque->invoice_id")}}'  > # {{$cheque->invoice_id}} &nbsp;&nbsp; </a>    فاتورة &nbsp;&nbsp; </span>
                        @elseif( $cheque->payment_voucher_id  )
                        <span>  {{ $cheque->payment_voucher->type}}</span>
                        @else( $cheque->client_id && ! $cheque->invoice_id  )
                        <span>  سند  قبض عام </span>
                        @endif

                        </th>
                        <th style="text-align:center;"> 
                        @if($cheque->status == Null)
                        <span class="badge bg-warning"> ...Waiting </span>
                        @elseif( $cheque->status == "Accepted" )
                        <span class="badge bg-success">  تم الصرف</span>
                        @else( $cheque->status == "Rejected"  )
                        <span class="badge bg-danger">  تم الرفض </span>
                        @endif

                  
                      </th>

                    </tr>
                    
                  </tbody>
                </table>
              </div>

              </div>
              <!-- /.card-body -->



















@if($cheque->status == Null)
<div class="row" style="padding:10px">
<div class="col-md-6" style="margin-left:18px"></div>

<div class="col-md-6" style="margin-left:18px">
      <div class="card card-warning">
          <div class="card-header" >
            <h2 class="card-title" style="float: right;">تغيير حالة الشيك  </h2>
          </div>
         
          <form  role="form" method="POST" action="{{ url('/cheque/change') }}">
                        {{ csrf_field() }}
          <div class="box-body">
            <div class="card-body">

             

            <div class="form-group" >
                <h6 style="text-align: right;"> تغيير حالة الشيك  </h6>
                <select class="form-control select2 select2-hidden-accessible"   style="width: 100%;text-align:right" name="status" id="status" required>
                   
                    <option value="Accepted"  >تم الصرف </option>
                    <option value="Rejected"  >تم الرفض </option>
                </select>
            </div>


                <input type="hidden"  value="{{$cheque->id}}" id="cheque_id" name="cheque_id" class="form-control"  placeholder=" " >

                <div class="card-footer" >
                  <button type="submit" class="btn btn-warning">حفظ </button>
                </div>  

              </div>
          </div>


          </form>
      </div>


    </div>
  </div>

@endif













            </div>  

@endsection
