
@extends('adminlte::page')
 
 @section('content')
 @include('administrator.pos.form-add-block-time')
 @include('administrator.pos.form-edit-time')
 @include('administrator.pos.form-remove-time')
 <?php Fun::lang()?>
     <div class="title-page">
         <div class="page-bar">
             <ul class="page-breadcrumb">
                 <li><a href="#"><i class="fa fa-dashboard"></i> Dashboard</a></li>
                 <li><a href="#">Manage Block Time</a></li>
                 <li><a href="#">Block Time List</a></li>
             </ul>
         </div>
     </div>
 <div class="page">
     <div class="top-content">
         <div class="row">
             <div class="col-sm-12 col-xs-12">
                 <div class="title-page">
                   <div class="pull-left">
                       <h3>Payment History</h3>
                   </div>
                   @can('POS-Block-Time-Create')
                   <span class="button_success btn-circle pull-right btn-add-time" style="cursor: pointer;"><i class="fa fa-plus"></i> Create New</span>
                   @endcan
               </div>
             </div>
         </div>
     </div>
    <div class="row">
       <div class="col-sm-12 col-xs-12">
         <div class="box-body table-responsive">
           <table id="datatable_block_time" class="table table-striped table-bordered table-hover nowrap">
               <thead>
               <tr>
                   <th width="33.33%">No</th>
                   <th width="33.33%">Hour</th>
                   <th>Action</th>
               </tr>
             </thead>
           </table>
         </div>
       </div>
     </div>
 </div>
 
  @endsection
 @section('js')
 
 <script type="text/javascript">
       $(document).ready(function(){
         $('.main-spinner').show();    
         $('#datatable_block_time').DataTable({
           ordering: false,
           "serverSide": true,
           ajax: "{{ route('block-time.get') }}",
           columns: [
             {data: 'DT_RowIndex'},
             {data: 'hour'},
             {data: 'action'},
           ],  
 
           "initComplete": function(settings, json) {
           $('.main-spinner').hide();
           }        
           });
       });
       $(document).on('click','.btn-add-time',function(){
            $('#add-time').modal('show');
       });
       $(document).on('click','.btn_edit_time',function(){
           var id = $(this).data('id');
           var hour = $(this).data('hour');
       });
       $(document).on('click','.btn_edit_time',function(){
            var id = $(this).data('id');
            var hour = $(this).data('hour');
            var route = "{{route('block-time.update',':id')}}";
            route = route.replace(':id',id);
            $('#hour').val(hour);
            $('#form-edit-time').attr('action',route);
            $('#edit-time').modal('show');
       });
       $(document).on('click','.btn_remove_time',function(){
            var id      = $(this).data('id');
            var route   = "{{route('remove-block-time',':id')}}";
            route       = route.replace(':id',id);
            $('#form-remove-time').attr('action',route);
            $('#remove-time').modal('show');
       });
   </script>
 
 @endsection
 