@extends('layout')


@section('content')

<div class="page-header page-header-default">
	<div class="breadcrumb-line">
		<ul class="breadcrumb">
			<li><a href="#"><i class="icon-home2 position-left"></i> Keuangan</a></li>
			<li><a href="#">Sumber Dana</a></li>
			<li class="active">Transaksi : Detail</li>
		</ul>
	</div>
</div>

<div class="content">
	<div class="panel panel-flat">
		<div class="panel-heading">
			<h5 class="panel-title">Transaksi : <strong>{{ $akun->kode_perkiraan." ".$akun->nama_perkiraan}}</strong></h5>

			<div class="heading-elements">
				<ul class="icons-list">
		      		<li><a href="{{ url('sumberdana') }}" class="text-warning"><i class="icon-circle-left2 warning"></i> Kembali</a></li>
		      	</ul>
	       	</div>
	    </div>
	    <div class="panel-body">

		    <table class="table datatable-basic table-stripped" id="tabel-transaksi-sumberdana">
		    	<thead>
					<tr>
						<th>No</th>
						<th>Tanggal</th>
						<th>Transaksi</th>
						<th>Nomor</th>
						<th class="text-center">Aksi</th>
					</tr>
				</thead>
				<tbody>

				</tbody>
		    </table>
	    	
	    </div>

	</div>
</div>

<script type="text/javascript">
	var tabelTransaksiSumberdana;
	var idDariAkun = "{{ $akun->id }}";

	$(document).ready(function () {
		loadTableTransaksiSumberdana();
	});

	function loadTableTransaksiSumberdana() {
		tabelTransaksiSumberdana = $("#tabel-transaksi-sumberdana").DataTable({
			serverSide : true,
			processing : true,
			ajax : "{{ url('sumberdana/load_transaksi_sumberdana') }}/"+idDariAkun,
			columns : [
			  {data:'id', name:'id', searchable:false, render : function(data, type, full, meta){
			  	return meta.row+1;
			  }},
			  {data:'tanggal_transaksi', name:'tanggal_transaksi'},
			  {data:'transaksi', name:'transaksi'},
			  {data:'nomor_transaksi', name:'nomor_transaksi'},
			  {data:'action', name:'action', orderable:false},
			],
			createdRow : function( row, data, dataIndex ) {
				$(row).attr('data-transaksi', data['id']);
			},
		});
	}

	function btnDeleteTransaksi(this_) {
		var id_transaksi = this_.parents("tr").data("transaksi");
		
		swal({
			title: 'Anda yakin akan menghapus data ini?',
			text : 'Menghapus data akan mempengaruhi transaksi Anda.',
			type: 'warning',
			showCancelButton: true,
			confirmButtonColor: '#d33',
			cancelButtonColor: '#3085d6',
			confirmButtonText: 'Hapus',
			cancelButtonText: 'Batal',
		}).then((result) => {
			
		 	if(result.value){
		 		$.ajax({
					url: "{{ url('sumberdana/transaksi/hapus_transaksi')}} ",
					type: 'post',
					data: {id : id_transaksi},
					headers : {
						'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
					},
					success: function(respon){
						location.reload();
					}
				})
		 	}
		})
	}
</script>

@endsection