<?php echo $__env->make('dashboard.include.header', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

  
  <div class="content-wrapper">
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 class="m-0">Add Banned Customers</h1>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="/home">Home</a></li>
              <li class="breadcrumb-item active">Add Banned Customers</li>
            </ol>
          </div>
        </div>
      </div>
    </div>
   
    <section class="content">
      <div class="container-fluid">
      <div class="card">
            <div class="card-body">
            <form class="form-horizontal" method="POST" action="/addbanned">
                <?php echo e(csrf_field()); ?>

            <div class="row">
                <div class="col-md-2">
                    <div class="form-group">
                        <label for="">Phone Number</label><input type="number" class="form-control" id="Phone_Number" name="Phone_Number" placeholder="Phone Number" required>
                    </div>
                </div>
                <div class="col-md-8"> 
                    <div class="form-group">
                        <label for="">Reason</label><input type="text" class="form-control" name="reason" placeholder="Reason" required>
                    </div>
                </div>
                <div class="col-md-2" style="padding-top:30px;"><button type="submit" class="btn btn-block btn-primary">Banned</button> </div>
           
            </div> 
            </form>
            </div>
            </div>
            <div class="card">
            <div class="card-body">
                <div class="row">
                    <div class="col-md-12">
                    <table id="example" class="table table-bordered" style="width:100%">
                        <thead>
                            <tr>
                                <th>ID</th>
                                <th>Phone Number</th>
                                <th>Reason</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody>
                    <?php $__currentLoopData = $item; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td><?php echo e($data->id); ?></td>
                            <td><?php echo e($data->phoneno); ?></td>
                            <td><?php echo e($data->reason); ?></td>
                            <td class="text-center">
                                <button type="button" class="btn btn-primary btn-xs supmodel" data-id="<?php echo e($data->id); ?>" data-phone="<?php echo e($data->phoneno); ?>" data-reason="<?php echo e($data->reason); ?>" data-toggle="modal" data-target="#supmodel">Edit</button>
                                <a href="" data-id="<?php echo e($data->id); ?>" class="btn btn-danger btn-xs button deletesupplier" data-url="">Delete </a>
                            </td>                        
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                    </table>
                    
                    </div>
                </div>


            </div>
        </div>
      </div>
    </section>
  </div>
 
  <div class="modal fade" id="supmodel" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content">
        <div class="modal-header">
            <h5 class="modal-title" id="exampleModalLongTitle">Banned details Change</h5>
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">&times;</span>
            </button>
        </div>
        <form class="form-horizontal" method="POST" action="/updatebannedcus">
            <?php echo e(csrf_field()); ?>

        <div class="modal-body"> 
            <input type="hidden" name="id" id="id">    
            <div class="form-group">
                <label for="">Phone Number</label><input type="number" class="form-control" id="Phone_Number" name="Phone_Number"  required>
            </div>
            <div class="form-group">
                <label for="">Reason</label><input type="text" class="form-control" id="reason" name="reason" required>
            </div>   

        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
            <button type="submit" class="btn btn-primary">Save changes</button>
        </div>
        </form>
        </div>
    </div>
</div>


  <?php echo $__env->make('dashboard.include.footer', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>;

<script>
$(document).ready(function() {
    $('#example').DataTable();
} );
</script>
<script>
$(document).on('click', '.deletesupplier', function (e) {
    e.preventDefault();
    var id = $(this).data('id');
    let ele = this;
    console.log(id);

                swal({
                title: "Are you sure?",
                text: "Are you Sure to Remove This Banned Customer",
                icon: "warning",
                showCancelButton: true,
    confirmButtonColor: '#3085d6',
    cancelButtonColor: '#d33',
    confirmButtonText: 'Yes, delete it!',
                dangerMode: true,
            }).then(function(isConfirm) {
                
                if (isConfirm.value===true) {

                        $.ajax({
                            url: "<?php echo e(url('/deletebannedcus')); ?>/"+id ,
                            method: "POST",
                            headers: {
                                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                            },
                            cache: false,
                            contentType: false,
                            processData: false,
                            dataType: 'JSON',
                            data:{
                                "id":id
                            },
                            success: function (result, code, ex) {
                                swal("Done!", "It was successfully deleted!", "success");
                                $(ele).closest('tr').hide();
                                // $("#here").load(location.href + " #here");
                                // window.location.href = "/supplier";
                            },
                            error: function (jqXHR, textStatus, errorThrown) {
                                swal("Warning", "Unable to Process your request", "error");
                            },
                        });

                } else {
                    swal("Cancelled", "No Removed", "error");
                }
            })
});


$('#supmodel').on('show.bs.modal', function (event) {

var button = $(event.relatedTarget) // Button that triggered the modal
var recipient = button.data('id') 
var reason = button.data('reason') 
var number = button.data('phone') 

var modal = $(this)
modal.find('.modal-body #id').val(recipient)
modal.find('.modal-body #Phone_Number').val(number)
modal.find('.modal-body #reason').val(reason)
})


$(document).ready(function(){

$('#Phone_Number').on('input', function() { 
var mobNum = $(this).val();
var filter = /^\d*(?:\.\d{1,2})?$/;

if (filter.test(mobNum)) {
    if(mobNum.length==10){

        toastr.success('Valid Phone Number')
        $("#Phone_Number").removeClass("is-invalid");
        $("#Phone_Number").addClass("is-valid");
        } else {
        // toastr.error('Please Put 10  Digit Mobile Number')
        $("#Phone_Number").removeClass("is-valid");
        $("#Phone_Number").addClass("is-invalid");
        
        }
    }
    else {
        toastr.error('Not a Valid Number')
        $("#Phone_Number").removeClass("is-valid");
        $("#Phone_Number").addClass("is-invalid");
        
    }


});
});


</script>



