<!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')}}">
  
</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>
          Material Request
        </h1>
        <ol class="breadcrumb">
          <li><a href="{{route('material_request.list')}}"><i class="fa fa-dashboard"></i> Material Request</a></li>
          <li class="active">list</li>
        </ol>
      </section>
    <!--  -->
      <br>
      <u style="float: right;margin-right: 15px">
        <i class="fa fa-fw fa-plus" style="color: blue;"></i><a href="{{route('material_request.order.index',$x)}}" style="font-size: 16px;">Add Request</a>
      </u>
      <br>
      <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 

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

      <div class="modal modal-info fade" id="modal-info">
          <div class="modal-dialog">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">Remarks</h4>
              </div>
              <div class="modal-body">
                <form method="POST" action="{{route('material_request.received')}}">
                  <input type="hidden" name="_token" value="{{ csrf_token() }}">
                  <input type="hidden" name="id" value="" id="id">
             
                  <div class="box-body">

                    <div class="form-group">
                      
                      <div class="col-sm-6">
                        <textarea name="remarks" cols="80" rows="3" style="color: black;" autofocus=""></textarea>
                      </div>
                    </div>
                
                  </div>

              <!-- /.box-body -->
              <div style="margin-left: 79%;">
                  <button type="submit" class="btn btn-outline">Received</button>
              </div>
                  <!-- /.box-footer -->

              </div>
              <div class="modal-footer">
                <button type="button" class="btn btn-outline pull-left" data-dismiss="modal">Close</button>
              </div>
              </form>
            </div>
            <!-- /.modal-content -->
          </div>
          <!-- /.modal-dialog -->
        </div>
        <!-- /.modal --> 

          <!-- Main content -->
      <section class="content">
        
        <!-- 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">Material Request List</h3>
            </div>

            <!-- /.box-header -->
            <form class="form-horizontal" action="{{route('credit.confirm')}}" 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>Customer</th>
                  <th>Location</th>
                  <th>Request Date</th>
                  <th>Status</th>
                  <th></th>
                  <th>Edit</th>
                  
                </tr>
                </thead>
                <tbody>
                 <?php $c = 1; ?>
                 @foreach($list as $l)
                <tr> 
                  <td>{{$c++}}</td>
                  <td>{{$l->request_no}}</td>
                  <td>{{$l->customer->name ?? ''}}</td>
                  <td>{{$l->parent->name ?? ''}}</td>
                  <td>{{date('d-m-Y',strtotime($l->request_date))}}</td>
                  <td>@if($l->status == 'REQ')
                    PENDING
                    @elseif($l->status == 'DRT')
                    DRAFT
                    @else
                    APPROVED
                    @endif
                  </td>
                  <td>
                  @if($l->status == 'DRT')
                  <input  type="checkbox" class="btn checkList" name="checkList[]" id="checkList" value="{{$l->id}}" checked="" style="display: inline;">
                  @endif</td>
                  <td class="center">@if($l->status != 'APR' && $l->status != 'REQ')<a href="{{route('material_request.edit',$l->id)}}"><i class="fa fa-fw fa-pencil" style="color: blue;"></i></a> 
                  @else <a href="{{route('mr_approved.view',$l->id)}}"><i class="fa fa-fw fa-newspaper-o" style="color: blue;"></i></a>&nbsp;&nbsp;&nbsp;
                  <button type="button" class="btn btn-info" data-toggle="modal" data-target="#modal-info" onclick="jsReceived({{$l->id}})" style="background-color: transparent;border: none;"><i class="fa fa-fw fa-check-square-o" style="color: red;"></i></button>
                  @endif</td>
                </tr>
                @endforeach
              </tbody>
              </table>
            </div>
            <div class="box-footer">
                <button type="submit" class="btn btn-info pull-right" style="margin-left: 8px;">Confirm</button>
              </div>
            </form>
          </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>

  <!-- 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>
