<!DOCTYPE html>
<html>
<head>
  @include('title')
  

  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <!-- Bootstrap 3.3.7 -->
  <link rel="stylesheet" href="{{asset('lte/bower_components/bootstrap/dist/css/bootstrap.min.css')}}">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="{{asset('lte/bower_components/font-awesome/css/font-awesome.min.css')}}">
  <!-- Ionicons -->
  <link rel="stylesheet" href="{{asset('lte/bower_components/Ionicons/css/ionicons.min.css')}}">
  <!-- Theme style -->
  <link rel="stylesheet" href="{{asset('lte/dist/css/AdminLTE.min.css')}}">
  <!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
  <link rel="stylesheet" href="{{asset('lte/dist/css/skins/_all-skins.min.css')}}">
  
  <!-- bootstrap wysihtml5 - text editor -->
  <link rel="stylesheet" href="{{asset('lte/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css')}}">

  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->

  <!-- Google Font -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">

  <!-- iCheck for checkboxes and radio inputs -->
  <link rel="stylesheet" href="{{asset('lte/plugins/iCheck/all.css')}}">
  
  
  <!-- DataTables -->
  <link rel="stylesheet" href="{{asset('lte/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css')}}">

  
</head>
<body class="hold-transition skin-blue fixed sidebar-mini">
<div class="wrapper">
  
  @include('headertag')
  <!-- Left side column. contains the logo and sidebar -->
  @include('leftside')
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
      <!-- Content Header (Page header) -->
      <section class="content-header">
      <h1>
         Customer Pre-Order
        </h1>
        <ol class="breadcrumb">
          <li><a href="{{route('customer.sales.order.list')}}"><i class="fa fa-dashboard"></i> Customer Pre-Order</a></li>
          <li class="active">list</li>
        </ol>
      </section>
      <div class="box-header with-border">
        @if(Session::has('message'))
        <div class="alert alert-success alert-dismissible">
          <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
          Saved Successfully
        </div>
       @endif

        @if(Session::has('update'))
        <div class="alert alert-info alert-dismissible">
          <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
          Updated Successfully
        </div>
        @endif

        @if(Session::has('approved'))
        <div class="alert alert-danger alert-dismissible">
          <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
          Material request allready approved
        </div>
        @endif            
      </div>

      
        <!-- /.modal --> 

          <!-- Main content -->
      <section class="content">

         <!-- Custom tabs (Charts with tabs)-->
            <div class="nav-tabs-custom">
              <!-- Tabs within a box -->
              <!-- <ul class="nav nav-tabs pull-right">
                <li class="active"><a href="#revenue-chart" data-toggle="tab">Area</a></li>
                <li><a href="#sales-chart" data-toggle="tab">Donut</a></li>
                <li class="pull-left header"><i class="fa fa-inbox"></i> Unit</li>
              </ul> -->
              <div class="tab-content no-padding">
               <!-- right column -->
        
       <!-- Horizontal Form -->
             <div class="box box-info">
              
            <!-- /.box-header -->
            <!-- form start -->
             <!-- <form class="form-horizontal" action="{{route('customer.sales.order.search')}}" method="POST">
              <input type="hidden" name="_token" value="{{{ csrf_token() }}}">
              <input type="hidden" name="loc_id" id="loc_id" value="">
              <div class="box-body">
              <br>
                <div class="form-group col-md-6">
                  <label for="inputcategory" class="col-sm-2 control-label">Status <i style="color: red">*</i></label>
                 <div class="col-sm-6">
                    <select class="form-control" name="status" id="status">
                    <option value="">SELECT ALL</option>
                    <option value="APR">CASH RECEIVED </option>
                    <option value="REQ">PENDING</option>
                   
                  </select>
                  </div>
                </div>

                <div class="form-group col-md-4">
                      <button type="submit" class="btn btn-info pull-left"style="margin-left: -167px;">OK</button>
                </div>
              </div>
            </form> -->
          </div>
          <!-- /.box --> 
                
          </div>
          </div>
        
        <!-- Main row -->
        <div class="row">
          <!-- Left col -->
          <section class="col-lg-12 connectedSortable">
            <!-- Custom tabs (Charts with tabs)-->

          <div class="box">
            <div class="box-header">
              <h3 class="box-title">Customer Pre-Order List</h3>
            </div>
            <!-- /.box-header -->
             <form class="form-horizontal" action="{{route('customer.sales.order.integration')}}" method="POST">
            <div class="box-body">
              <table id="example1" class="table table-bordered table-striped">
                <thead>
                <tr>
                  <th>Sl No.</th>
                  <th>MR Number</th>
                  <th>Location</th>
                  <th>Customer</th>
                  <th>Mobile Number</th>
                  <th>Order Date</th>
                  <th>Delivery Dt</th>
                  <th>Status</th>
                  <th>Edit</th>
                  <th>Action</th>
                  <th></th>
                  @if(Auth::user()->name == 'admin')
                  <th>Delete</th>
                  @endif
                  
                </tr>
                </thead>
                <tbody>
                 <?php $c = 1; ?>
                 @foreach($list as $l)
                <tr> 
                  <td>{{$c++}}</td>
                  <td>{{$l->prefix}}{{$l->request_no}}</td>
                  <td>{{$l->entered->name}}</td>
                  <td>{{$l->customer['name']}}</td>
                  <td>{{$l->customer['mobileno']}}</td>
                  <td>{{date('d-m-Y',strtotime($l->request_date))}}: {{date('H:i:s',strtotime($l->created_at)) }}</td>
                  <td>{{is_null($l->delivery_date)? '' : date('d-m-Y', strtotime($l->delivery_date))}}</td>
                  <td>@if($l->status == 'REQ' ||$l->status == 'CHG' )
                    PENDING
                    @elseif($l->status == 'DRT')
                    DRAFT
                    @elseif($l->status == 'CHG')
                    PENDING
                    @elseif($l->status == 'OAPR')
                    ORDER APPROVED
                    @else
                    APPROVED
                    @endif
                  </td>
                  <td class="center"> 
                    @if($l->status != 'APR')
                    <a href="{{route('customer.sales.order.view',$l->id)}}"><i class="fa fa-fw fa-newspaper-o" style="color: blue;"></i></a>
                    @endif
                  </td>
                  <td>
                  <a href="#" class="btn btn-info confirm" id="{{$l->id}}">Approve</a>
                  </td>
                  <td> 

                    @if($l->status == 'REQ' || $l->status == 'APR')
                    
                    <input  type="checkbox" class="btn checkList" name="checkList[]" id="checkList" value="{{$l->id}}"  style="display: inline;">
                    @endif
                  </td>
                   @if(Auth::user()->name == 'admin')

                  <td>
                   <a href="{{route('customer.sale.delete',$l->id)}}"><i class="fa fa-fw fa-bitbucket" style="color: red;"></i></a>
                  </td>
                   
                     @endif
                </tr>
                @endforeach
              </tbody>
              </table>
            </div>
             <div class="box-footer">

               <label class="checkbox inline pull-right" style="margin-left: 13px;"><input type="checkbox" id="selectAll"><b>Select All</b></label><br><br>
                <button type="submit" class="btn btn-info pull-right aprove" style="margin-left: 8px;">Approve</button>
              </div>
          </div>
            <!-- /.nav-tabs-custom -->

            <!-- Chat box -->
            
            <!-- /.box (chat box) -->

            
            <!-- quick email widget -->
          </section>
          <!-- /.Left col -->
          
        </div>
        <!-- /.row (main row) -->

      </section>
      <!-- /.content -->
    </div>
  <!-- /.content-wrapper -->
  
  @include('footertag')

  <!-- Control Sidebar -->
  @include('rightside')
  <!-- /.control-sidebar -->
  <!-- Add the sidebar's background. This div must be placed
       immediately after the control sidebar -->
  <div class="control-sidebar-bg"></div>
</div>
<!-- ./wrapper -->

  <!-- jQuery 3 -->
  <script src="{{asset('lte/bower_components/jquery/dist/jquery.min.js')}}"></script>
  <!-- jQuery UI 1.11.4 -->
  <script src="{{asset('lte/bower_components/jquery-ui/jquery-ui.min.js')}}"></script>
  <!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
  <script>
    $.widget.bridge('uibutton', $.ui.button);
  </script>
  <!-- Bootstrap 3.3.7 -->
  <script src="{{asset('lte/bower_components/bootstrap/dist/js/bootstrap.min.js')}}"></script>
  
  <!-- Sparkline -->
  <script src="{{asset('lte/bower_components/jquery-sparkline/dist/jquery.sparkline.min.js')}}"></script>
  
  <!-- Bootstrap WYSIHTML5 -->
  <script src="{{asset('lte/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js')}}"></script>
  <!-- Slimscroll -->
  <script src="{{asset('lte/bower_components/jquery-slimscroll/jquery.slimscroll.min.js')}}"></script>
  <!-- FastClick -->
  <script src="{{asset('lte/bower_components/fastclick/lib/fastclick.js')}}"></script>
  <!-- AdminLTE App -->
  <script src="{{asset('lte/dist/js/adminlte.min.js')}}"></script>
  
  <!-- AdminLTE for demo purposes -->
  <script src="{{asset('lte/dist/js/demo.js')}}"></script>

  <!-- DataTables -->
<script src="{{asset('lte/bower_components/datatables.net/js/jquery.dataTables.min.js')}}"></script>
<script src="{{asset('lte/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js')}}"></script>

  <!-- iCheck 1.0.1 -->
<script src="{{asset('lte/plugins/iCheck/icheck.min.js')}}"></script>
</body>

</html>

<script type="text/javascript">
  function jsReceived(value){
    $('#id').val(value);
  }
</script>

<script>
  $(function () {
    $('#example1').DataTable()
   
  })

    $(function() {
 
    $('#selectAll').click(function() {
      var table = $('#example1').DataTable();
      table.destroy();

        if ($(this).prop('checked')) {
            $('.checkList').prop('checked', true);
        } else {
            $('.checkList').prop('checked', false);
        }
        $('#example1').DataTable();
  
    });

});

    $('.aprove').on( 'click', function () {
      var table = $('#example1').DataTable();
      table.destroy();
    });

    // $(".confirm").on('clcik', function(){
    //   alert(); 
    // });
    $(document).on("click",".confirm", function() {console.log(1);
        if(confirm("Do you want to confirm this order?") == true){
          var id = $(this).attr("id");
          window.location = "{{URL::to('customer/preorder/approve')}}"+'/'+id;
        }
    });

</script>
