@extends('layouts.app')

@section('content')
<div class="card card-outline-info">
        <div class="card-header">
            <h4 class="m-b-0 text-white">Process Franchise Withdrawal request</h4>
        </div>
<div class="card-body">
    {!! Form::open(['method' => 'POST','id'=> 'register_frm', 'data-parsley-validate'=>'', 'url' => [url('/admin/payments/doProcessPayoutsfrnchs/'.$income->id)]]) !!}
        <div class="form-body control-group">
            <div class="row">
              <div class="col-md-3">
                  <div class="form-group">
                      <label class="control-label" for="remark">Remark*</label>
                      <select id="status" name="status" required="required" class="form-control">
                        <option value="1">Approved</option>
                        <option value="2">Cancel/Reverse</option>
                      </select>
                        @if ($errors->has('remark'))
                          <p class="help-block">
                              <strong>{{ $errors->first('remark') }}</strong>
                          </p>
                        @endif
                  </div>
              </div>
              <div class="col-md-3">
                  <div class="form-group">
                      <label class="control-label" for="remark">Remark*</label>
                      <input type="text" id="remark" name="remark" required="required" class="form-control" value="">
                        @if ($errors->has('remark'))
                          <p class="help-block">
                              <strong>{{ $errors->first('remark') }}</strong>
                          </p>
                        @endif
                  </div>
              </div>
            </div>
            <div class="row" id="emi_payment">
            </div>
            <input type="hidden" name="associate_id" id="associate_id" value="{{$user->id}}">
    {!! Form::submit('Submit', ['class' => 'btn btn-danger']) !!}
    {!! Form::close() !!}
    </div>
</div>
<div class="card">
    <div class="card-body">
        <h3 class="card-title">Balance Detail</h3>
        <div class="row">
          <div class="col-md-6 col-lg-3 col-xlg-3">
              <div class="card card-inverse card-info">
                  <div class="box bg-info text-center">
                      <h1 class="font-light text-white">
                        {{ IND_money_format(($wallet->avbl_total_balance_frnchs)) }}
                      </h1>
                      <h6 class="text-white">Available Amount</h6>
                  </div>
              </div>
          </div>
          
          <div class="col-md-6 col-lg-3 col-xlg-3">
              <div class="card card-inverse card-success">
                  <div class="box text-center">
                      <h1 class="font-light text-white">
                        {{ $totalPayouts }}
                      </h1>
                      <h6 class="text-white">Total Payouts</h6>
                  </div>
              </div>
          </div>

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

<div class="card">
    <div class="card-body">
        <h3 class="card-title">User Detail</h3>
        <div class="row">

          <div class="col-md-3" id="registryAmount">
              <div class="form-group">
                  <label class="control-label font-bold" for="registry_amount">Bank Name : </label>
                  <span class="" id="registry_amount">{{ $user->bank_name }}</span>
              </div>
          </div>
          <div class="col-md-3" id="registryAmount">
              <div class="form-group">
                  <label class="control-label font-bold" for="registry_amount">Account no. : </label>
                  <span class="" id="registry_amount">{{ $user->bank_accnt_no }}</span>
              </div>
          </div>
          <div class="col-md-3" id="registryAmount">
              <div class="form-group">
                  <label class="control-label font-bold" for="registry_amount">Branch Name : </label>
                  <span class="" id="registry_amount">{{ $user->branch_name }}</span>
              </div>
          </div>
          <div class="col-md-3" id="registryAmount">
              <div class="form-group">
                  <label class="control-label font-bold" for="registry_amount">IFSC : </label>
                  <span class="" id="registry_amount">{{ $user->ifsc }}</span>
              </div>
          </div>
          <div class="col-md-3" id="registryAmount">
              <div class="form-group">
                  <label class="control-label font-bold" for="registry_amount">Pan No. : </label>
                  <span class="" id="registry_amount">{{ $user->panno }}</span>
              </div>
          </div>
          <div class="col-md-3" id="registryAmount">
              <div class="form-group">
                  <label class="control-label font-bold" for="registry_amount">Nominee Name : </label>
                  <span class="" id="registry_amount">{{ $user->nom_name }}</span>
              </div>
          </div>
          <div class="col-md-3" id="registryAmount">
              <div class="form-group">
                  <label class="control-label font-bold" for="registry_amount">Nominee Relation : </label>
                  <span class="" id="registry_amount">{{ $user->nom_relation }}</span>
              </div>
          </div>
          <div class="col-md-3" id="registryAmount">
              <div class="form-group">
                  <label class="control-label font-bold" for="registry_amount">Nominee DOB : </label>
                  <span class="" id="registry_amount">{{ $user->nom_dob }}</span>
              </div>
          </div>
        </div>
    </div>
</div>
<div class="card">
    <div class="card-body">
        <h3 class="card-title">Previous withdrawal requests</h3>
        <div class="table-responsive">
            <table class="table table-bordered" id="users-table">
                    <thead>
                        <tr>
                            <th>S. No.</th>
                            <th>Business Partner Name</th>                            
                            <th>Business Partner ID</th>
                            <th>Amount</th>
                            <th>TDS</th>
                            <th>Request Date</th>
                            <th>Status</th>
                            <th>Remark</th>
                        </tr>
                    </thead>
                </table>
        </div>
    </div>
</div>
<div class="modal fade" id="loadModalAjax" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="display: none;" aria-hidden="true">
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
    </div>
    <!-- /.modal-content -->
   </div>
  <!-- /.modal-dialog -->
</div>

@stop

@section('javascript')
    <script>
        var t = $('#users-table').DataTable({
                processing: true,
                serverSide: true,
                ajax: '{!! url('/') !!}/admin/payments/getProcessedPayoutsfrnchs',
                dom: 'frtip',
                'lengthMenu': [ [10, 25, 50, -1], [10, 25, 50, "All"] ],
                columns: [
                    { data: 'id', name: 'id' },
                    { data: 'full_name', name: 'full_name' },
                    { data: 'username', name: 'username' },
                    { data: 'income_amount', name: 'income_amount' },
                    { data: 'tds', name: 'tds' },
                    { data: 'created_at', name: 'created_at' },
                    { data: 'payment_status', name: 'payment_status' },
                    { data: 'remark', name: 'remark' }
                ],
                "columnDefs": [
                    {
                        "render": function ( data, type, row, meta) {
                            return meta.row + meta.settings._iDisplayStart + 1;
                         },
                        "targets": 0
                    },
                    {
                        "render": function ( data, type, row ) {
                          return data - row.tds;
                        },
                        "targets": 4
                    },
                    {
                        "render": function ( data, type, row ) {
                        if(data==0){
                            return '<span class="label label-warning">Pending</span>';
                        }else if(data==1){
                            return '<span class="label label-success">Approved</span>';
                        }else if(data==2){
                            return '<span class="label label-danger">Cancelled</span>';
                        }
                        },
                        "targets": 6
                    },
                    {
                        "render": function ( data, type, row ) {
                        return data.replace(/(?:\r\n|\r|\n)/g, '<br />')
                        },
                        "targets": 7
                    }
                ],
                'order': [[5, 'asc']],
                drawCallback: function( settings ) {
                    openModal();
                  }
            });
            
            function openModal(){
              $('.openModal').click(function(){
              	 $('#loadModalAjax .modal-content').load('{{ url('/') }}/users/' + $(this).attr('data-id'),function(result){
            	    $('#loadModalAjax').modal({show:true});
                  //init_validation('#updateStudentForm', rules, messages);
            	   });
              });
              $('.openModalInvoices').click(function(){
              	 $('#loadModalAjax .modal-content').load('/student_invoices_modal.php?id=' + $(this).attr('data-id'),function(result){
            	    $('#loadModalAjax').modal({show:true});
                  //init_validation('#updateStudentForm', rules, messages);
            	   });
              });
            }

    </script>
@endsection
