@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> Master</a></li>
			<li class="active">Produksi</li>
		</ul>
	</div>
</div>

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

	    <table class="table table_trans table-stripped">
	    	<thead>
				<tr>
					<th width="10%">No</th>
					<th>Motif</th>
					<th>Kode</th>
					<th class="text-center">Aksi</th>
				</tr>
			</thead>
			<tbody>
				
				
			</tbody>
	    </table>
	</div>
</div>
<script type="text/javascript">

	var table_trans;

	$(document).ready(function(){
		table_trans = $(".table_trans").DataTable({
			processing: true,
	        serverSide: true,
	        ajax: '{{ url('motif/get_data') }}',
	        columns: [
	            {data: 'rownum', name: 'rownum', orderable: false, searchable: false, render : function(data, type, row, meta){
			  		return meta.row+1;
			  	}},
	            {data: 'nama_motif', name: 'nama_motif'},
	            {data: 'kode_motif', name: 'kode_motif'},
	            {data: 'aksi', name: 'aksi', orderable: false, searchable: false}
	        ],
		});
		
	})

	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('motif/hapus')}} ",
					type: 'post',
					data: {id : id},
					headers : {
						'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
					},
					success: function(respon){
						table_trans.ajax.reload();
					}
				})
		 	}
		})
	}
</script>


@endsection