text: function dataTransaksi() {
      $.ajax({
          type: "get",
          url: "/admin/detail-transaksi/render",
          dataType: "json",
          success: function (response) {
              $(".data-rendered").html(response.data);
          },
          error: function (error) {
              console.log("Error", error);
          },
      });
  }
  
  function toRupiah(number)
  {
      reverse = number.toString().split('').reverse().join(''),
  	ribuan 	= reverse.match(/\d{1,3}/g);
  	ribuan	= ribuan.join('.').split('').reverse().join('');
  
      return "Rp. " + ribuan;
  }
  
  $(document).ready(function () {
      dataTransaksi();
  
      $('body').on('click', '.btn-detail', function() {
          let id = $(this).data('id');
          $('#modalDetailData').modal('show');
          $('.table-detail tbody').empty();
          // let button = '<button type="button" class="btn btn-light-danger text-danger font-weight-medium waves-effect text-start btn-delete" data-id='+id+'>Hapus Transaksi</button>';
          // $('#modalDetailData .modal-footer').empty().append(button)
          $.get("/admin/detail-transaksi/detail/"+id, function (data) {
              $.each(data, function (index, value) {
                  let total = value.barang.harga*value.kuantitas;
                  let tbody = '<tr style="text-align: center;">'+
                      '<td>'+value.barang.nama+'</td>'+
                      '<td>'+value.kuantitas+'</td>'+
                      '<td>'+toRupiah(value.barang.harga)+'</td>'+
                      '<td style="text-align: right;" id="total'+(index+1)+'" data-total='+total+'>'+toRupiah(total)+'</td>'+
                  '</tr>';
  
                  $('.table-detail tbody').append(tbody);
              });
  
              let total = 0;
              for(let i = 1; i <= $('[id^=total]').length; i++) {
                  total += parseInt($('[id^=total'+i+']').data('total'));
              }
              $('.sub-total').empty().append(toRupiah(total));
          });
      });
  
      $('body').on('click', '.btn-change-status', function(){
          let status = $(this).data('status');
          let id = $(this).data('id');
          let title = '';
          let text = '';
          let requestStatus = '';
          if(status == true) {
              title = 'Aktifkan status transaksi ini?';
              text = 'aktifkan';
              requestStatus = 1
          } else {
              title = 'Non-aktifkan status transaksi ini?';
              text = 'non-aktifkan';
              requestStatus = 0
          }
  
          Swal.fire({
              icon: 'warning',
              title: title,
              text: text,
              showCancelButton: true,
              confirmButtonText: "Proses",
              showLoaderOnConfirm: true,
              preConfirm: function () {
                  return new Promise(function (resolve) {
                      $.ajaxSetup({
                          headers: {
                              "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr(
                                  "content"
                              ),
                          },
                      });
                      $.ajax({
                          type: "POST",
                          url: "/admin/transaksi/change-status",
                          data: {
                              id: id,
                              status: requestStatus,
                          },
                      })
                          .done(function (response) {
                              dataTransaksi();
                              Swal.fire(
                                  response.title,
                                  response.message,
                                  response.status
                              );
                          })
                          .fail(function () {
                              Swal.fire(
                                  response.title,
                                  response.message,
                                  response.status
                              );
                          });
                  });
              },
              allowOutsideClick: false,
          });
      });
  });