@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">Upah Harian</li>
		</ul>
	</div>
</div>

<div class="content">
	<div class="panel panel-flat">
		<div class="panel-heading">
			<h5 class="panel-title">Upah Harian</h5>
			<div class="heading-elements">
				<ul class="icons-list">
		      		<li><a data-action="collapse"></a></li>
		      	</ul>
	       	</div>
	    </div>
	    
	    <div class="panel-body">
	    	<div class="col-md-12">
	    		@if(Session::has('flash_message_error'))
	    		<div class="alert alert-error alert-block">
	    			<button type="button" class="close" data-dismiss="alert">x</button>
	    			<strong>{!! session('flash_message_error') !!}</strong>
	    		</div>
	    		@endif
	    		@if(Session::has('flash_message_success'))
	    		<div class="alert alert-success alert-block">
	    			<button type="button" class="close" data-dismiss="alert">x</button>
	    			<strong>{!! session('flash_message_success') !!}</strong>
	    		</div>
	    		@endif
	    	</div>
	    	<a href="{{url('upahharian/tambah')}}" class="btn btn-success" style="margin-bottom: 1%;">Tambah (Template Excel)</a>
	    	<a href="{{url('upahharian/tambah-form')}}" class="btn btn-primary" style="margin-bottom: 1%;">Tambah (Form)</a>
	    	<!-- <a href="{{url('upahharian/laporan')}}" class="btn btn-success pull-right" style="margin-bottom: 1%;"><i class="fa fa-list"></i> Laporan Gaji Karyawan</a> -->
	    </div>

	    <table class="table datatable-basic table-stripped table_bonbahan">
	    	<thead>
				<tr>
					<th>No</th>
					<th>Nomor Transaksi</th>
					<th>Tanggal</th>				
					<th>Pegawai</th>
					<th>Upah</th>
					<!-- batas  -->
					<th>Aksi</th>
					<!-- <th>Gaji Jam Lembur</th>
					<th>Gaji Pokok</th>
					<th>Premi Produksi</th>
					<th></th> --><!-- 
					<th class="text-center"></th> -->
				</tr>
			</thead>
			<tbody>
				 
			</tbody>
	    </table>
	</div>
</div>

<script type="text/javascript">
	var tb;
	$(document).ready(function(){
		loadTabelUpahHarian();		
	});

	function loadTabelUpahHarian() {
		tb = $(".table_bonbahan").DataTable({
			processing: true,
	        serverSide: true,
	        ajax: '{{ url('upahharian/get_data') }}',
	        columns: [
	            {data: 'rownum', name: 'rownum', orderable: false, searchable: false, render : function(data, type, row, meta){
			  		return meta.row+1;
			  	}},	            
	            {data: 'no_trans', name: 'no_trans'},
	            {data: 'tanggal', name: 'tanggal'},
	            {data: 'pegawai', name: 'pegawai'},
	            {data: 'upah', name: 'upah'},
	            {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('upahharian/hapus')}} ",
					type: 'post',
					data: {id : id},
					headers : {
						'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
					},
					success: function(respon){
						if (respon.status == "Success") {
							tb.ajax.reload();
						} else {
							swal({
								title: "Data gagal dihapus!",
								type: 'info',
								confirmButtonColor: '#3085d6',
								confirmButtonText: 'Ya'
							}).then((result) => {
								
							});
						}
					}
				})
		 	}
		})
	}


</script>
@endsection