@extends('layouts.app')

@section('content')
    <!-- Datatables -->
    <link href="{{ url('/') }}/vendors/datatables.net-bs/css/dataTables.bootstrap.min.css" rel="stylesheet">
    <link href="{{ url('/') }}/vendors/datatables.net-buttons-bs/css/buttons.bootstrap.min.css" rel="stylesheet">
    <link href="{{ url('/') }}/vendors/datatables.net-fixedheader-bs/css/fixedHeader.bootstrap.min.css" rel="stylesheet">
    <link href="{{ url('/') }}/vendors/datatables.net-responsive-bs/css/responsive.bootstrap.min.css" rel="stylesheet">
    <link href="{{ url('/') }}/vendors/datatables.net-scroller-bs/css/scroller.bootstrap.min.css" rel="stylesheet">

  <body class="nav-md">
    <div class="container body">
      <div class="main_container">
        @include('partials.sidebar')

        @include('partials.topmenu')

        <!-- page content -->
        <div class="right_col" role="main">

          @if (Session::get('message') != '')
            <div class="alert alert-success alert-dismissible fade in" role="alert">
              <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span>
              </button>
              <strong>{{ Session::get('message') }}</strong>
            </div>
          @endif
          @if (Session::get('errormessage') != '')
            <div class="alert alert-danger alert-dismissible fade in" role="alert">
              <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span>
              </button>
              <strong>{!! Session::get('errormessage') !!}</strong>
            </div>
          @endif
          

          <div class="row">
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h2>Binary Closing<small></small></h2>
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                      </li>
                    </ul>
                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content">
                    <form id="demo-form2" action="{{ url('/cp/adminbinaryclosing') }}" method="post" data-parsley-validate class="form-horizontal form-label-left">
                      {{ csrf_field() }}
                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">Select Date <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <select name="date_closed" class="selectpicker form-control" id="adminbin_closing">
                            @if(count($date_array)>0)
                              @foreach($date_array as $da)
                                <option value="{{$da}}" @if($bin_closing_date == $da) selected="selected" @endif>{{$da}}</option>
                              @endforeach
                            @endif
                          </select>
                          @if ($errors->has('date_closed'))
                            <span class="help-block">
                                <strong>{{ $errors->first('date_closed') }}</strong>
                            </span>
                          @endif
                        </div>
                      </div>
                    </form>
                    <div class="ln_solid"></div>
                    @if($do_closing)
                    <div class="form-group">
                      <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
                        <form id="demo-form2" action="{{ url('/cp/adminbinaryclosing_do') }}" method="post" data-parsley-validate class="form-horizontal form-label-left">
                          {{ csrf_field() }}
                          <input type="hidden" name="bin_closing_date" value="{{ $bin_closing_date }}">
                          <button type="submit" class="btn btn-success">Perform Binary Closing For {{ $bin_closing_date }}</button>
                        </form>
                      </div>
                    </div> 
                    @endif                   
                  </div>
                </div>
              </div>

              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h2>Binary Income History for {{ $bin_closing_date }}</h2>
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                      </li>
                    </ul>
                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content">
                    <table id="datatable-fixed-header" class="table table-striped table-bordered">
                      <thead>
                        <tr>
                          <th>Amount</th>
                          <th>Username</th>
                          <th>Credit/Debit/Lapsed</th>
                          <th>Description</th>
                          <th>Date</th>
                        </tr>
                      </thead>


                      <tbody>
                      @foreach ($incomes as $income)
                        <tr>
                          <td>@if($income->cred_deb == 1 ) <span style="color: #f00;">- @endif ${{ $income->amount }}@if($income->cred_deb == 1 ) </span> @endif</td>
                          <td>{{$income->username}}</td>
                          <td>
                            @if($income->lapsed == 1)
                              lapsed
                            @elseif($income->cred_deb == 0)
                              credit
                            @else
                              debit
                            @endif
                          </td>
                          <td>{{ $income->description }}</td>
                          <td>{{ $income->created_at }}</td>                        </tr>
                      @endforeach
                      </tbody>
                    </table>
                  </div>
                </div>
              </div>


              
            </div>
          </div>
        </div>
        <!-- /page content -->
        @include('partials.footer')
      </div>
    </div>

    <!-- jQuery -->
    <!-- jQuery -->
    <script src="{{ url('/') }}/vendors/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap -->
    <script src="{{ url('/') }}/vendors/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- FastClick -->
    <script src="{{ url('/') }}/vendors/fastclick/lib/fastclick.js"></script>
    <!-- NProgress -->
    <script src="{{ url('/') }}/vendors/nprogress/nprogress.js"></script>
    <!-- iCheck -->
    <script src="{{ url('/') }}/vendors/iCheck/icheck.min.js"></script>
    <!-- Datatables -->
    <script src="{{ url('/') }}/vendors/datatables.net/js/jquery.dataTables.min.js"></script>
    <script src="{{ url('/') }}/vendors/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
    <script src="{{ url('/') }}/vendors/datatables.net-buttons/js/dataTables.buttons.min.js"></script>
    <script src="{{ url('/') }}/vendors/datatables.net-buttons-bs/js/buttons.bootstrap.min.js"></script>
    <script src="{{ url('/') }}/vendors/datatables.net-buttons/js/buttons.flash.min.js"></script>
    <script src="{{ url('/') }}/vendors/datatables.net-buttons/js/buttons.html5.min.js"></script>
    <script src="{{ url('/') }}/vendors/datatables.net-buttons/js/buttons.print.min.js"></script>
    <script src="{{ url('/') }}/vendors/datatables.net-fixedheader/js/dataTables.fixedHeader.min.js"></script>
    <script src="{{ url('/') }}/vendors/datatables.net-keytable/js/dataTables.keyTable.min.js"></script>
    <script src="{{ url('/') }}/vendors/datatables.net-responsive/js/dataTables.responsive.min.js"></script>
    <script src="{{ url('/') }}/vendors/datatables.net-responsive-bs/js/responsive.bootstrap.js"></script>
    <script src="{{ url('/') }}/vendors/datatables.net-scroller/js/dataTables.scroller.min.js"></script>
    <script src="{{ url('/') }}/vendors/jszip/dist/jszip.min.js"></script>
    <script src="{{ url('/') }}/vendors/pdfmake/build/pdfmake.min.js"></script>
    <script src="{{ url('/') }}/vendors/pdfmake/build/vfs_fonts.js"></script>
    <!-- bootstrap-daterangepicker -->
    <script src="{{ url('/') }}/js/moment/moment.min.js"></script>
    <script src="{{ url('/') }}/js/datepicker/daterangepicker.js"></script>
    <!-- Custom Theme Scripts -->
    <script src="{{ url('/') }}/build/js/custom.min.js"></script>
    <!-- Datatables -->
    <script>
      $(document).ready(function() {

        //$('#single_cal1').daterangepicker({
        //  singleDatePicker: true,
        //  calender_style: "picker_1",
        //  minDate: 0,
        //  daysOfWeekDisabled: [0,2,3,4,5,6]
        //}, function(start, end, label) {
        //  console.log(start.toISOString(), end.toISOString(), label);
        //});

        $('#datatable-fixed-header').DataTable({
          fixedHeader: true
        });

        $('#adminbin_closing').on('change', function(e){
            this.form.submit()
          });
      });
    </script>
    <!-- /Datatables -->
  </body>
@endsection
