$( document ).ready(function() {
    // Merchant listing using datatables plugin
    $('#merchant-list').DataTable({
        "processing": true,
        "serverSide": true,
        "ajax": {
            "url": base_url + "/merchant/merchant_data",
            "type": "POST"
        }
        // "scrollY": 400,
        // "scrollX": true
    });

    // Merchant details button click event
    $(document).on('click', '.merchant-view', function (event) {
        event.preventDefault();
        var button = $(this)
        var merchant_id = button.data('merchant-id');

        $.get(base_url + '/merchant/merchant_details/' + merchant_id, function(response) {
          if (response.status === 'success') {
            $('#merchant-detail-table tbody tr').html(response.data);
            $('#merchant-detail-modal').modal('show');
          } else {
            bootbox.alert(response.message);
          }
      });
    });
});