@extends('layout')


@section('content')

<div class="page-header page-header-default">
	<div class="breadcrumb-line">
		<ul class="breadcrumb">
			<li><a href="index.html"><i class="icon-home2 position-left"></i> Produksi</a></li>
			<li class="active">Pengembalian Barang</li>
		</ul>
	</div>
</div>

<div class="content">
	<div class="panel panel-flat">
		<div class="panel-heading">
			<h5 class="panel-title">Pengembalian Barang</h5>
			<div class="heading-elements">
				<ul class="icons-list">
		      		<li><a data-action="collapse"></a></li>
		      	</ul>
	       	</div>
	    </div>
	    <div class="panel-body">
	    	<a href="{{url('kembalibarang/tambah')}}" class="btn btn-success" style="margin-bottom: 1%;">Tambah</a>
	    </div>

	    <table class="table dataTable table-stripped">
	    	<thead>
				<tr>
					<th>No</th>
					<th>Nomor</th>
					<th>Tanggal</th>
					<th>Pemroses</th>
					<th>Proses Produksi</th>
                    <th>Status</th>
					<th class="text-center"></th>
				</tr>
			</thead>
			<tbody>
				 

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

<script type="text/javascript">

	var table;
	$(document).ready(function(){
		table = $(".dataTable").DataTable({
			processing: true,
	        serverSide: true,
	        ajax: '{{ url('kembalibarang/get_data') }}',
	        columns: [
	            {data: 'id_kembali', name: 'id_kembali', orderable: false, searchable: false, render : function(data, type, row, meta){
			  		return meta.row+1;
			  	}, className: 'text-center'},
			  	{data: 'nomor', name: 'nomor'},
	            {data: 'tanggal', name: 'tanggal'},
	            {data: 'pemroses', name: 'pemroses'},
	            {data: 'proses', name: 'proses'},
	            {data: 'status', name: 'status', orderable: false, searchable: false},
	            {data: 'aksi', name: 'aksi', orderable: false, searchable: false},
	        ],
	        "order": [[ 6, "desc" ]]
		});
		

	})

	function hapus(id){
		swal({
			title: 'Anda yakin akan menghapus item ini?',
			type: 'warning',
			showCancelButton: true,
			confirmButtonColor: '#3085d6',
			cancelButtonColor: '#d33',
			confirmButtonText: 'Ya',
			cancelButtonText: 'Tidak',
		}).then((result) => {
		 	if(result.value){
		 		$.ajax({
					url: "{{ url('kembalibarang/hapus')}} ",
					type: 'post',
					data: {id : id},
					headers : {
						'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
					},
					success: function(respon){
						table.ajax.reload();
					}
				})
		 	}
		})
	}

	

</script>
@endsection