@extends('layouts.app')

@section('content')
@include('closer.closerheader')

<div class='container'>

<div class="page-title-box">
                <div class="row align-items-center">
                    <div class="col-sm-6">
                        <h4 class="page-title">Orders</h4>
                    </div>
                    <div class="col-sm-6">
                        <ol class="breadcrumb float-right">
                            <li class="breadcrumb-item"><a href="javascript:void(0);">Closer</a></li>
                            <li class="breadcrumb-item active">Orders</li>
                        </ol>
                    </div>
                </div>
                <!-- end row -->
            </div>

        <div class='row d-flex justify-content-center'>
            <div class='col-md-12'>
            <table id="example" class="table table-striped data-table" style="width:100%">
        <thead>
            <tr class='dt-row'>
                <th>ID</th>
                <th>Business Name</th>
                <th>Business Email</th>
                <th>Package</th>
                <th>Order#</th>
                <th>Invoice#</th>
                <th>Payment Method</th>
                <th>Status</th>
                <th>Action</th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
            </div>
        </div>
    </div>

    <script type="text/javascript">
  $(function () {
      
    var table = $('.data-table').DataTable({
        processing: true,
        serverSide: true,
        ajax: "{{ route('closer-orders') }}",
        columns: [
            {data: 'id'},
            {data: 'bname'},
            {data: 'bemail'},
            {data: 'productname'},
            {
            data: 'ordernumber',
            render: function (data) {
                try {
                   
                    return data ? '#'+data: '-'; 
                } catch (error) {
                  
                    console.error('Error in render function:', error);
                    return '-'; 
                }
            }
        },
             {data: 'invoice_id'},
            {data: 'payment_method'},
            {
                data: 'order_status',
                className: 'status-column'
            },
            {data: 'action', name: 'action', orderable: false, searchable: false},

        ]
    });
      
  });
</script>

@endsection

  