	
		<div class="page-wrapper">

<div class="page-content">

<div class="d-flex justify-content-between align-items-center flex-wrap grid-margin">
<div>
<h4 class="mb-3 mb-md-0">List Invoice</h4>
</div>
<div class="d-flex align-items-center flex-wrap text-nowrap">
<div class="input-group date datepicker dashboard-date mr-2 mb-2 mb-md-0 d-md-none d-xl-flex" >
  <span class="input-group-addon "><i data-feather="calendar" class=" text-primary"></i></span>
  <input  type="date" class="form-control" id="tanggal_order" name="tanggal_order" autocomplete="off">
        
</div>

</div>
</div>


    <div class="row">
          <div class="col-12 col-xl-12 grid-margin stretch-card">
                    <div class="card">
                        <div class="card-body">
                            <h6 class="card-title">Manage Invoice</h6>
                            <div class="table-wrap">
                                <div class="table-responsive">
                                    <table id="orders-table" class="table table-hover w-100 display pb-30 dataTable dtr-inline collapsed" style="width:100%">
                                        <thead>
                                            <tr>
                                                <th>Date Time</th>
                                                <th>No Invoice</th>
                                                <th>Customer Name</th>
                                                <th>Net Amount</th>
                                                <th>Paid Status</th>
                                                <th>Action</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                        </tbody>
                                    </table>
                                </div>    
                                </div> 
                            <button  class="btn btn-danger btn-icon deleteBtn" name="deleteBtn" data-url="' . base_url('invoice/deleteorder?kode=') . $order['bill_no'] . '"><i class="fa-solid fa-trash"></i></button>
                            <a class="btn btn-primary"  data-value="toy-pictures-latest"  onclick="contoh('aaaa')">Klik disini</a>

                              
                            <!--- Card Body END -->
                        </div>
                    </div>
            </div>
        </div>
    <!---ROW END -->


</div>

<script src="https://texapp.is3.cloudhost.id/api/v2/assets/vendors/sweetalert2/sweetalert2.min.js"></script>
  <script src="https://texapp.is3.cloudhost.id/api/v2/assets/vendors/promise-polyfill/polyfill.min.js"></script> 
<script type="text/javascript">


        $(document).ready(function () {

            
            var dataTable = $('#orders-table').DataTable({
                "processing": true,
                "serverSide": true,
                
                "ajax": {
                    "url": "<?php echo base_url('invoice/getData'); ?>",
                    "type": "POST",
                    "data": function(d){
                        d.length = $('#orders-table').DataTable().page.len();
                    }
                }
            });

            $('#apply_filter').click(function(){
                var customerName = $('#customer_name').val();
                var startDate = $('#start_date').val();
                var endDate = $('#end_date').val();

                dataTable.clear().draw();
                dataTable.ajax.url("<?php echo base_url('invoice/getData'); ?>").load({
                    customer_name: customerName,
                    startDate: startDate,
                    endDate: endDate
                });
            });

            $('#clear_filter').click(function(){
                $('#customer_name').val('');
                $('#start_date').val('');
                $('#end_date').val('');

                dataTable.clear().draw();
                dataTable.ajax.url("<?php echo base_url('invoice/getData'); ?>").load();
            });
            $('deleteBtn').on('click', function(e){
            e.preventDefault();
            var url = $(this).data('url');
            showSwal = function(type) {
                'use strict';
                    swal.fire({
                        text: 'Any fool can use a computer',
                        confirmButtonText: 'Close',
                        confirmButtonClass: 'btn btn-danger',
                    })


        }});
                
        });

        function contoh(e) {

var url = "<?php echo base_url('invoice/deleteOrder'); ?>?kode=" + e;
console.log(e);
const swalWithBootstrapButtons = Swal.mixin({
    customClass: {
      confirmButton: 'btn btn-success',
      cancelButton: 'btn btn-danger mr-2'
    },
    buttonsStyling: false,
  })
  
  swalWithBootstrapButtons.fire({
    title: 'Are you sure?',
    text: "You won't be able to revert this!",
    icon: 'warning',
    showCancelButton: true,
    confirmButtonClass: 'mr-2',
    confirmButtonText: 'Yes, delete it!',
    cancelButtonText: 'No, cancel!',
    reverseButtons: true
  }).then((result) => {
    if (result.value) {
        $.getJSON(url, function(data) {
           console.log(data);

           
         }),
      swalWithBootstrapButtons.fire(
        'Deleted!',
        'Your file has been deleted.',
        'success'
      )

      setTimeout(function() {
            location.reload();
        }, 2000);

    } else if (
      // Read more about handling dismissals
      result.dismiss === Swal.DismissReason.cancel
    ) {
      swalWithBootstrapButtons.fire(
        'Cancelled',
        'Your imaginary file is safe :)',
        'error'
      )
    }
  })
  

}

    </script>

