@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">Bon Bahan</li>
		</ul>
	</div>
</div>

<div class="content">
	<div class="panel panel-flat">
		<div class="panel-heading">
			<h5 class="panel-title">Bon Bahan</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('barangkeluar/tambah')}}" class="btn btn-success" style="margin-bottom: 1%;">Tambah</a>
	    </div>

	    <table class="table datatable-basic table-stripped table_bonbahan">
	    	<thead>
				<tr>
					<th>No</th>
					<th>Nomor</th>
					<th>Nomor Order</th>
					<th>Tanggal</th>
					<th>Proses Produksi</th>
					<th>Pemroses</th>
                    <th>Status</th>
					<th class="text-center"></th>
				</tr>
			</thead>
			<tbody>
				 
			</tbody>
	    </table>
	</div>
</div>

<script type="text/javascript">
	var tb;

	$(document).ready(function(){
		tb = $(".table_bonbahan").DataTable({
			processing: true,
	        serverSide: true,
	        searchDelay: 2000,
	        defferRender : true,
	        ajax: '{{ url('barangkeluar/get_data') }}',
	        columns: [
	            {data: 'rownum', name: 'rownum', orderable: false, searchable: false, render : function(data, type, row, meta){
			  		return meta.row+1;
			  	}},
			  	{data: 'nomor', name: 'nomor'},
	            {data: 'no_workorder', name: 'no_workorder'},
	            {data: 'tanggal', name: 'tanggal'},
	            {data: 'nama_proses', name: 'nama_proses'},
	            {data: 'pekerja', name: 'pekerja'},
	            {data: 'status', name: 'status'},
	            {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('barangkeluar/hapus')}} ",
					type: 'post',
					data: {id : id},
					headers : {
						'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
					},
					success: function(respon){
						tb.ajax.reload();
					}
				})
		 	}
		})
	}


</script>
@endsection