@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">{{ $data['title'] }}</h5>
			<div class="heading-elements">
				<ul class="icons-list">
					<li><a href="{{ url('upahharian/') }}" class="text-warning"><i class="icon-circle-left2 warning"></i> Kembali</a></li>
		      		<li><a data-action="collapse"></a></li>
		      	</ul>
	       	</div>
	       	<hr>
	    </div>
	    <div class="panel-body">
	    	<div class="row">
	    		<form action="{{ url('upahharian/tambah-form/simpan') }}" method="POST" class="form-horizontal" autocomplete="off">
	    			{{ csrf_field() }}
	    			<input type="hidden" name="id_upah_harian" id="id_upah_harian" value="{{ $data['data']['id_upah_harian'] }}">
	    			<div class="col-md-12">
	    				<div class="col-md-6">
	    					@if($data['is_update'] == True)
	    					<div class="form-group">
	    						<label class="control-label col-md-4">No. Upah</label>
	    						<div class="col-md-8">
	    							<input class="form-control" type="text" name="noupah" id="noupah" placeholder="No. Upah" value="{{ $data['data']['noupah'] }}" readonly="" required/>
	    						</div>
	    					</div>
	    					@endif
	    					<div class="form-group">
	    						<label class="control-label col-md-4">Tanggal Transaksi</label>
	    						<div class="col-md-8">
	    							<input class="form-control datepicker" type="text" name="tanggal" id="tanggal" placeholder="Tanggal" value="{{ $data['data']['tanggal_transaksi'] }}" required/>
	    						</div>
	    					</div>
	    					<div class="form-group">
	    						<label class="control-label col-md-4">Akun Bayar</label>
	    						<div class="col-md-8">
	    							<select class="form-control select-search" name="akun_bayar" id="akun_bayar" required>
			        					<option value="">-- Pilih Akun --</option>
			        					@php
			        						$akun_bayar = $data['data']['akun_bayar'];
			        						if($akun_bayar == ""){
				        						$select = "4";
				        					} else {
					        					$select = $akun_bayar;
					        				}
			        					@endphp
			        					@foreach($data['akun2'] as $key => $value)
			        					    <option value="{{ $key }}" @if($key == $select) selected @endif>{{ $value }}</option>
			        					@endforeach
			        				</select>
	    						</div>
	    					</div>
	    				</div>
	    				<div class="col-md-6">	 
	    					<div class="form-group">
	    						<label class="control-label col-md-4">Pegawai</label>
	    						<div class="col-md-8">
	    							<select class="form-control select-search" name="pegawai" id="pegawai" required>
			        					<option value="" @if($data['data']['id_pegawai'] == "") selected @endif>-- Pilih Pegawai --</option>
			        					@foreach($data['pegawai'] as $key => $val)
			        					<option value="{{ $val->id_pegawai }}" @if($data['data']['id_pegawai'] == $val->id_pegawai) selected @endif>{{ $val->nomor_pegawai }} - {{ strtoupper($val->nama_pegawai) }} ({{ $val->bagian }})</option>
			        					@endforeach
			        				</select>
	    						</div>
	    					</div>
	    					<div class="form-group">
	    						<label class="control-label col-md-4">Lokasi Produksi</label>
	    						<div class="col-md-8">
	    							<select class="form-control select-search" name="lokasi_produksi" id="lokasi_produksi" required>
			        					<option value="" @if($data['data']['lokasi_produksi'] == "") selected @endif>-- Pilih Lokasi Produksi --</option>
			        					@foreach($data['lokasi_produksi'] as $key => $val)
			        					<option value="{{ $val->id_lokasi }}" @if($data['data']['lokasi_produksi'] == $val->id_lokasi) selected @endif>{{ $val->nama_lokasi }}</option>
			        					@endforeach
			        				</select>
	    						</div>
	    					</div>   					
	    					<div class="form-group">
	    						<label class="control-label col-md-4">Jml. Hari Normal</label>
	    						<div class="col-md-8">
	    							<input class="form-control" type="number" min="0" step="0.01" name="jml_hari_normal" id="jml_hari_normal" placeholder="Contoh : 13.00" value="{{ $data['data']['jml_hari_normal'] }}" required onkeyup="changeJumlahHari()" />
	    						</div>
	    					</div>
	    					<div class="form-group">
	    						<label class="control-label col-md-4">Jml. Absen (Hari)</label>
	    						<div class="col-md-8">
	    							<input class="form-control" type="number" min="0" step="0.01" name="jml_absen_hari" id="jml_absen_hari" placeholder="Contoh : 13.00" value="{{ $data['data']['jml_absen_hari'] }}" required onkeyup="changeJumlahHari()" />
	    						</div>
	    					</div>
	    				</div>
	    			</div>
	    			<div class="col-md-12" style="margin-bottom: 10px;">
	    				<h5 class="panel-title">Upah</h5>
	    				<hr>
	    				<div class="table-responsive">
	    					<table class="table table-stripped">
	    						<thead>
	    							<tr>
	    								<th>Jml. Hari Kerja</th>
	    								<th>Upah Perhari</th>
	    								<th>Total</th>
	    							</tr>
	    						</thead>
	    						<tbody>
	    							<tr>
	    								<td>
	    									<input class="form-control" type="number" min="0" step="0.01" name="jml_hari_kerja" id="jml_hari_kerja" placeholder="Contoh : 13.00" value="{{ $data['data']['jml_hari_kerja'] }}" onkeyup="changeUpahPerhari()" />
	    								</td>
	    								<td>
	    									<input class="form-control text-right" type="number" min="0" name="upah_perhari" id="upah_perhari" placeholder="Contoh : 62500" value="{{ $data['data']['upah_perhari'] }}" onkeyup="changeUpahPerhari()" />
	    								</td>
	    								<td id="tot_upah_perhari" class="text-right">{{ rupiah2($data['data']['tot_upah_perhari']) }}</td>
	    								<input type="hidden" name="txt_tot_upah_perhari" id="txt_tot_upah_perhari" value="{{ $data['data']['tot_upah_perhari'] }}">
	    							</tr>
	    						</tbody>
	    					</table>
	    				</div>
	    			</div>
	    			<div class="col-md-12" style="margin-bottom: 10px;">
	    				<h5 class="panel-title">Lembur</h5>
	    				<hr>
	    				<div class="table-responsive">
	    					<table class="table table-stripped">
	    						<thead>
	    							<tr>
	    								<th>Jml. Jam Lembur</th>
	    								<th>Upah Lembur/Jam</th>
	    								<th>Total</th>
	    							</tr>
	    						</thead>
	    						<tbody>
	    							<tr>
	    								<td>
	    									<input class="form-control" type="number" min="0" step="0.01" name="jml_jam_lembur" id="jml_jam_lembur" placeholder="Contoh : 13.00" value="{{ $data['data']['jml_jam_lembur'] }}" onkeyup="changeUpahLemburJam()" />
	    								</td>
	    								<td>
	    									<input class="form-control text-right" type="number" min="0" name="upah_lembur_jam" id="upah_lembur_jam" placeholder="Contoh : 62500" value="{{ $data['data']['upah_lembur_jam'] }}" onkeyup="changeUpahLemburJam()" />
	    								</td>
	    								<td id="tot_upah_lembur_jam" class="text-right">{{ rupiah2($data['data']['tot_upah_lembur_jam']) }}</td>
	    								<input type="hidden" name="txt_tot_upah_lembur_jam" id="txt_tot_upah_lembur_jam" value="{{ $data['data']['tot_upah_lembur_jam'] }}">
	    							</tr>
	    						</tbody>
	    					</table>
	    					<table class="table table-stripped">
	    						<thead>
	    							<tr>
	    								<th>Jml. Hari Lembur</th>
	    								<th>Upah Lembur/Hari</th>
	    								<th>Total</th>
	    							</tr>
	    						</thead>
	    						<tbody>
	    							<tr>
	    								<td>
	    									<input class="form-control" type="number" min="0" step="0.01" name="jml_hari_lembur" id="jml_hari_lembur" placeholder="Contoh : 13.00" value="{{ $data['data']['jml_hari_lembur'] }}" onkeyup="changeUpahLemburHari()" />
	    								</td>
	    								<td>
	    									<input class="form-control text-right" type="number" min="0" name="upah_lembur_hari" id="upah_lembur_hari" placeholder="Contoh : 62500" value="{{ $data['data']['upah_lembur_hari'] }}" onkeyup="changeUpahLemburHari()" />
	    								</td>
	    								<td id="tot_upah_lembur_hari" class="text-right">{{ rupiah2($data['data']['tot_upah_lembur_hari']) }}</td>
	    								<input type="hidden" name="txt_tot_upah_lembur_hari" id="txt_tot_upah_lembur_hari" value="{{ $data['data']['tot_upah_lembur_hari'] }}">
	    							</tr>
	    						</tbody>
	    					</table>
	    					<table class="table table-stripped">
	    						<thead>
	    							<tr>
	    								<th>Jml. Jam UM Lembur</th>
	    								<th>UM Lembur/Jam</th>
	    								<th>Total</th>
	    							</tr>
	    						</thead>
	    						<tbody>
	    							<tr>
	    								<td>
	    									<input class="form-control" type="number" min="0" step="0.01" name="jml_jam_um_lembur" id="jml_jam_um_lembur" placeholder="Contoh : 13.00" value="{{ $data['data']['jml_jam_um_lembur'] }}" onkeyup="changeUMLemburJam()" />
	    								</td>
	    								<td>
	    									<input class="form-control text-right" type="number" min="0" name="um_lembur_jam" id="um_lembur_jam" placeholder="Contoh : 62500" value="{{ $data['data']['um_lembur_jam'] }}" onkeyup="changeUMLemburJam()" />
	    								</td>
	    								<td id="tot_um_lembur_jam" class="text-right">{{ rupiah2($data['data']['tot_um_lembur_jam']) }}</td>
	    								<input type="hidden" name="txt_tot_um_lembur_jam" id="txt_tot_um_lembur_jam" value="{{ $data['data']['tot_um_lembur_jam'] }}">
	    							</tr>
	    						</tbody>
	    					</table>
	    					<table class="table table-stripped">
	    						<thead>
	    							<tr>
	    								<th>Jml. Hari UM Lembur</th>
	    								<th>UM Lembur/Hari</th>
	    								<th>Total</th>
	    							</tr>
	    						</thead>
	    						<tbody>
	    							<tr>
	    								<td>
	    									<input class="form-control" type="number" min="0" step="0.01" name="jml_hari_um_lembur" id="jml_hari_um_lembur" placeholder="Contoh : 13.00" value="{{ $data['data']['jml_hari_um_lembur'] }}" onkeyup="changeUMLemburHari()" />
	    								</td>
	    								<td>
	    									<input class="form-control text-right" type="number" min="0" name="um_lembur_hari" id="um_lembur_hari" placeholder="Contoh : 62500" value="{{ $data['data']['um_lembur_hari'] }}" onkeyup="changeUMLemburHari()" />
	    								</td>
	    								<td id="tot_um_lembur_hari" class="text-right">{{ rupiah2($data['data']['tot_um_lembur_hari']) }}</td>
	    								<input type="hidden" name="txt_tot_um_lembur_hari" id="txt_tot_um_lembur_hari" value="{{ $data['data']['tot_um_lembur_hari'] }}">
	    							</tr>
	    						</tbody>
	    					</table>
	    					<table class="table table-stripped">
	    						<thead>
	    							<tr>
	    								<th>Jml. Hari UM Ke Desa</th>
	    								<th>UM Ke Desa</th>
	    								<th>Total</th>
	    							</tr>
	    						</thead>
	    						<tbody>
	    							<tr>
	    								<td>
	    									<input class="form-control" type="number" min="0" step="0.01" name="jml_hari_um_desa" id="jml_hari_um_desa" placeholder="Contoh : 13.00" value="{{ $data['data']['jml_hari_um_desa'] }}" onkeyup="changeUMDesa()" />
	    								</td>
	    								<td>
	    									<input class="form-control text-right" type="number" min="0" name="um_desa" id="um_desa" placeholder="Contoh : 62500" value="{{ $data['data']['um_desa'] }}" onkeyup="changeUMDesa()" />
	    								</td>
	    								<td id="tot_um_desa" class="text-right">{{ rupiah2($data['data']['tot_um_desa']) }}</td>
	    								<input type="hidden" name="txt_tot_um_desa" id="txt_tot_um_desa" value="{{ $data['data']['tot_um_desa'] }}">
	    							</tr>
	    						</tbody>
	    					</table>
	    					<table class="table table-stripped">
	    						<thead>
	    							<tr>
	    								<th>Jml. Hari UM Ke Kediri</th>
	    								<th>UM Ke Kediri</th>
	    								<th>Total</th>
	    							</tr>
	    						</thead>
	    						<tbody>
	    							<tr>
	    								<td>
	    									<input class="form-control" type="number" min="0" step="0.01" name="jml_hari_um_kediri" id="jml_hari_um_kediri" placeholder="Contoh : 13.00" value="{{ $data['data']['jml_hari_um_kediri'] }}" onkeyup="changeUMKediri()" />
	    								</td>
	    								<td>
	    									<input class="form-control text-right" type="number" min="0" name="um_kediri" id="um_kediri" placeholder="Contoh : 62500" value="{{ $data['data']['um_kediri'] }}" onkeyup="changeUMKediri()" />
	    								</td>
	    								<td id="tot_um_kediri" class="text-right">{{ rupiah2($data['data']['tot_um_kediri']) }}</td>
	    								<input type="hidden" name="txt_tot_um_kediri" id="txt_tot_um_kediri" value="{{ $data['data']['tot_um_kediri'] }}">
	    							</tr>
	    						</tbody>
	    					</table>
	    				</div>
	    			</div>
	    			<div class="col-md-12">
	    				<h5 class="panel-title">Potongan</h5>
	    				<hr>
	    				<div class="table-responsive">
	    					<table class="table table-stripped">
	    						<thead>
	    							<tr>
	    								<th>Jml. Jam Keterlambatan</th>
	    								<th>Potongan Keterlambatan</th>
	    								<th>Total</th>
	    							</tr>
	    						</thead>
	    						<tbody>
	    							<tr>
	    								<td>
	    									<input class="form-control" type="number" min="0" step="0.01" name="jml_jam_keterlambatan" id="jml_jam_keterlambatan" placeholder="Contoh : 13.00" value="{{ $data['data']['jml_jam_keterlambatan'] }}" onkeyup="changePotonganKeterlambatan()" />
	    								</td>
	    								<td>
	    									<input class="form-control text-right" type="number" min="0" name="potongan_keterlambatan" id="potongan_keterlambatan" placeholder="Contoh : 62500" value="{{ $data['data']['potongan_keterlambatan'] }}" onkeyup="changePotonganKeterlambatan()" />
	    								</td>
	    								<td id="tot_potongan_keterlambatan" class="text-right">{{ rupiah2($data['data']['tot_potongan_keterlambatan']) }}</td>
	    								<input type="hidden" name="txt_tot_potongan_keterlambatan" id="txt_tot_potongan_keterlambatan" value="{{ $data['data']['tot_potongan_keterlambatan'] }}">
	    							</tr>
	    						</tbody>
	    					</table>
	    					<table class="table table-stripped">
	    						<thead>
	    							<tr>
	    								<th>Potongan Kas Bon</th>
	    								<th>Total</th>
	    							</tr>
	    						</thead>
	    						<tbody>
	    							<tr>
	    								<td>
	    									<input class="form-control text-right" type="number" min="0" name="potongan_kas_bon" id="potongan_kas_bon" placeholder="Contoh : 62500" value="{{ $data['data']['potongan_kas_bon'] }}" onkeyup="changePotonganKasBon()" />
	    								</td>
	    								<td id="tot_potongan_kas_bon" class="text-right">{{ rupiah2($data['data']['tot_potongan_kas_bon']) }}</td>
	    								<input type="hidden" name="txt_tot_potongan_kas_bon" id="txt_tot_potongan_kas_bon" value="{{ $data['data']['tot_potongan_kas_bon'] }}">
	    							</tr>
	    						</tbody>
	    					</table>
	    				</div>
	    			</div>
	    			<div class="col-md-12"><hr></div>
	    			<div class="col-md-6 pull-right">
	    				<div class="form-group">
	    					<label class="control-label col-md-4">Netto</label>
	    					<div class="col-md-8">
	    						<label class="form-control text-right" id="lbl_netto">{{ rupiah2($data['data']['netto']) }}</label>
	    						<input type="hidden" name="txt_netto" id="txt_netto" value="{{ $data['data']['netto'] }}" />
	    					</div>
	    				</div>
	    				<div class="form-group">
	    					<label class="control-label col-md-4">Pembulatan</label>
	    					<div class="col-md-8">
	    						<input class="form-control text-right" type="number" min="0" name="txt_pembulatan" id="txt_pembulatan" placeholder="Pembulatan" value="{{ $data['data']['pembulatan'] }}" onkeyup="totalAkhir()" />
	    						<!-- <label><input type="checkbox" name="check_pembulatan" id="check_pembulatan" onchange="totalAkhir()"> Pengurangan</label> -->
	    					</div>
	    				</div>
	    				<div class="form-group">
	    					<label class="control-label col-md-4">Total Akhir</label>
	    					<div class="col-md-8">
	    						<label class="form-control text-right" id="lbl_total_akhir">{{ rupiah2($data['data']['total_akhir']) }}</label>
	    						<input type="hidden" name="txt_total_akhir" id="txt_total_akhir" value="{{ $data['data']['total_akhir'] }}" />
	    					</div>
	    				</div>
	    				<div class="pull-right">
	    					<button class="btn btn-primary" type="submit"><i class="fa fa-save"></i> Simpan</button>
	    				</div>
	    			</div>
	    		</form>
	    	</div>
	    </div>
	</div>
</div>

@endsection

<script type="text/javascript">
	var BASE_URL = "{{ url('/') }}";

	function changeJumlahHari()
	{
		var jml_hari_normal = $("#jml_hari_normal").val(),
			jml_absen_hari 	= $("#jml_absen_hari").val(),
			tot_jml_hari	= 0;

			if (isNaN(jml_hari_normal)) {
				jml_hari_normal = 0;
			}

			if (isNaN(jml_absen_hari)) {
				jml_absen_hari = 0;
			}

			tot_jml_hari += parseFloat(jml_hari_normal)-parseFloat(jml_absen_hari);

			if (isNaN(tot_jml_hari)) {
				tot_jml_hari = 0;
			}

			$("#jml_hari_kerja").val(tot_jml_hari);
			changeUpahPerhari();
	}

	function changeUpahPerhari()
	{
		var jml_hari_kerja 	= $("#jml_hari_kerja").val(),
			upah_perhari 	= $("#upah_perhari").val(),
			tot_upah_perhari= 0;

		if (isNaN(jml_hari_kerja)) {
			jml_hari_kerja = 0;
		}

		if (isNaN(upah_perhari)) {
			upah_perhari = 0;
		}

		tot_upah_perhari += parseFloat(upah_perhari)*parseFloat(jml_hari_kerja);

		if (isNaN(tot_upah_perhari)) {
			tot_upah_perhari = 0;
		}

		$("#txt_tot_upah_perhari").val(tot_upah_perhari);
		$("#tot_upah_perhari").html(new Intl.NumberFormat('de-DE').format(tot_upah_perhari));
		hitungNetto();
	}

	function changeUpahLemburJam()
	{
		var jml_jam_lembur 		= $("#jml_jam_lembur").val(),
			upah_lembur_jam 	= $("#upah_lembur_jam").val(),
			tot_upah_lembur_jam = 0;

		if (isNaN(jml_jam_lembur)) {
			jml_jam_lembur = 0;
		}

		if (isNaN(upah_lembur_jam)) {
			upah_lembur_jam = 0;
		}

		tot_upah_lembur_jam += parseFloat(upah_lembur_jam)*parseFloat(jml_jam_lembur);

		if (isNaN(tot_upah_lembur_jam)) {
			tot_upah_lembur_jam = 0;
		}

		$("#txt_tot_upah_lembur_jam").val(tot_upah_lembur_jam);
		$("#tot_upah_lembur_jam").html(new Intl.NumberFormat('de-DE').format(tot_upah_lembur_jam));
		hitungNetto();
	}

	function changeUpahLemburHari()
	{
		var jml_hari_lembur 		= $("#jml_hari_lembur").val(),
			upah_lembur_hari 		= $("#upah_lembur_hari").val(),
			tot_upah_lembur_hari 	= 0;

		if (isNaN(jml_hari_lembur)) {
			jml_hari_lembur = 0;
		}

		if (isNaN(upah_lembur_hari)) {
			upah_lembur_hari = 0;
		}

		tot_upah_lembur_hari += parseFloat(upah_lembur_hari)*parseFloat(jml_hari_lembur);

		if (isNaN(tot_upah_lembur_hari)) {
			tot_upah_lembur_hari = 0;
		}

		$("#txt_tot_upah_lembur_hari").val(tot_upah_lembur_hari);
		$("#tot_upah_lembur_hari").html(new Intl.NumberFormat('de-DE').format(tot_upah_lembur_hari));
		hitungNetto();
	}

	function changeUMLemburJam()
	{
		var jml_jam_um_lembur 	= $("#jml_jam_um_lembur").val(),
			um_lembur_jam 		= $("#um_lembur_jam").val(),
			tot_um_lembur_jam 	= 0;

		if (isNaN(jml_jam_um_lembur)) {
			jml_jam_um_lembur = 0;
		}

		if (isNaN(um_lembur_jam)) {
			um_lembur_jam = 0;
		}

		tot_um_lembur_jam += parseFloat(um_lembur_jam)*parseFloat(jml_jam_um_lembur);

		if (isNaN(tot_um_lembur_jam)) {
			tot_um_lembur_jam = 0;
		}

		$("#txt_tot_um_lembur_jam").val(tot_um_lembur_jam);
		$("#tot_um_lembur_jam").html(new Intl.NumberFormat('de-DE').format(tot_um_lembur_jam));
		hitungNetto();
	}

	function changeUMLemburHari()
	{
		var jml_hari_um_lembur 	= $("#jml_hari_um_lembur").val(),
			um_lembur_hari 		= $("#um_lembur_hari").val(),
			tot_um_lembur_hari 	= 0;

		if (isNaN(jml_hari_um_lembur)) {
			jml_hari_um_lembur = 0;
		}

		if (isNaN(um_lembur_hari)) {
			um_lembur_hari = 0;
		}

		tot_um_lembur_hari += parseFloat(um_lembur_hari)*parseFloat(jml_hari_um_lembur);

		if (isNaN(tot_um_lembur_hari)) {
			tot_um_lembur_hari = 0;
		}

		$("#txt_tot_um_lembur_hari").val(tot_um_lembur_hari);
		$("#tot_um_lembur_hari").html(new Intl.NumberFormat('de-DE').format(tot_um_lembur_hari));
		hitungNetto();
	}

	function changeUMDesa()
	{
		var jml_hari_um_desa 	= $("#jml_hari_um_desa").val(),
			um_desa 			= $("#um_desa").val(),
			tot_um_desa 		= 0;

		if (isNaN(jml_hari_um_desa)) {
			jml_hari_um_desa = 0;
		}

		if (isNaN(um_desa)) {
			um_desa = 0;
		}

		tot_um_desa += parseFloat(um_desa)*parseFloat(jml_hari_um_desa);

		if (isNaN(tot_um_desa)) {
			tot_um_desa = 0;
		}

		$("#txt_tot_um_desa").val(tot_um_desa);
		$("#tot_um_desa").html(new Intl.NumberFormat('de-DE').format(tot_um_desa));
		hitungNetto();
	}

	function changeUMKediri()
	{
		var jml_hari_um_kediri 	= $("#jml_hari_um_kediri").val(),
			um_kediri 			= $("#um_kediri").val(),
			tot_um_kediri 		= 0;

		if (isNaN(jml_hari_um_kediri)) {
			jml_hari_um_kediri = 0;
		}

		if (isNaN(um_kediri)) {
			um_kediri = 0;
		}

		tot_um_kediri += parseFloat(um_kediri)*parseFloat(jml_hari_um_kediri);

		if (isNaN(tot_um_kediri)) {
			tot_um_kediri = 0;
		}

		$("#txt_tot_um_kediri").val(tot_um_kediri);
		$("#tot_um_kediri").html(new Intl.NumberFormat('de-DE').format(tot_um_kediri));
		hitungNetto();
	}

	function changePotonganKeterlambatan()
	{
		var jml_jam_keterlambatan 	= $("#jml_jam_keterlambatan").val(),
			potongan_keterlambatan 	= $("#potongan_keterlambatan").val(),
			tot_potongan_keterlambatan = 0;

		if (isNaN(jml_jam_keterlambatan)) {
			jml_jam_keterlambatan = 0;
		}

		if (isNaN(potongan_keterlambatan)) {
			potongan_keterlambatan = 0;
		}

		tot_potongan_keterlambatan += parseFloat(potongan_keterlambatan)*parseFloat(jml_jam_keterlambatan);

		if (isNaN(tot_potongan_keterlambatan)) {
			tot_potongan_keterlambatan = 0;
		}

		$("#txt_tot_potongan_keterlambatan").val(tot_potongan_keterlambatan);
		$("#tot_potongan_keterlambatan").html(new Intl.NumberFormat('de-DE').format(tot_potongan_keterlambatan));
		hitungNetto();
	}

	function changePotonganKasBon()
	{
		var potongan_kas_bon 	= $("#potongan_kas_bon").val(),
			tot_potongan_kas_bon = 0;

		if (isNaN(potongan_kas_bon)) {
			potongan_kas_bon = 0;
		}

		tot_potongan_kas_bon += parseFloat(potongan_kas_bon);

		if (isNaN(tot_potongan_kas_bon)) {
			tot_potongan_kas_bon = 0;
		}

		$("#txt_tot_potongan_kas_bon").val(tot_potongan_kas_bon);
		$("#tot_potongan_kas_bon").html(new Intl.NumberFormat('de-DE').format(tot_potongan_kas_bon));
		hitungNetto();
	}

	function hitungNetto()
	{
		var tot_upah_perhari = $("#txt_tot_upah_perhari").val(),
			tot_upah_lembur_jam = $("#txt_tot_upah_lembur_jam").val(),
			tot_upah_lembur_hari = $("#txt_tot_upah_lembur_hari").val(),
			tot_um_lembur_jam = $("#txt_tot_um_lembur_jam").val(),
			tot_um_lembur_hari = $("#txt_tot_um_lembur_hari").val(),
			tot_um_desa = $("#txt_tot_um_desa").val(),
			tot_um_kediri = $("#txt_tot_um_kediri").val(),
			tot_potongan_keterlambatan = $("#txt_tot_potongan_keterlambatan").val(),
			tot_potongan_kas_bon = $("#txt_tot_potongan_kas_bon").val(),
			total_upah = 0,
			total_potongan = 0,
			total_netto = 0;

		total_upah += parseFloat(tot_upah_perhari)+parseFloat(tot_upah_lembur_jam)+parseFloat(tot_upah_lembur_hari)+parseFloat(tot_um_lembur_jam)+parseFloat(tot_um_lembur_hari)+parseFloat(tot_um_desa)+parseFloat(tot_um_kediri);

		total_potongan += parseFloat(tot_potongan_keterlambatan)+parseFloat(tot_potongan_kas_bon);

		total_netto += parseFloat(total_upah)-parseFloat(total_potongan);

		$("#txt_netto").val(total_netto);
		$("#lbl_netto").html(new Intl.NumberFormat('de-DE').format(total_netto));

		totalAkhir();
	}

	function totalAkhir()
	{
		var netto = $("#txt_netto").val(),
			pembulatan = $("#txt_pembulatan").val();

		if (netto == "") {netto=0;}
		if (pembulatan == "") {pembulatan=0;}

		 var hasil = parseFloat(netto) + parseFloat(pembulatan);

		$("#txt_total_akhir").val(hasil);
		$("#lbl_total_akhir").html(new Intl.NumberFormat('de-DE').format(hasil));
	}

	// function totalAkhir()
	// {
	// 	var netto = $("#txt_netto").val(),
	// 		pembulatan = $("#txt_pembulatan").val();

	// 	if (netto == "") {netto=0;}
	// 	if (pembulatan == "") {pembulatan=0;}

	// 	if($("#check_pembulatan").is(':checked')){
	// 	    var hasil = parseFloat(netto) - parseFloat(pembulatan);
	// 	} else {
	// 	    var hasil = parseFloat(netto) + parseFloat(pembulatan);
	// 	}

	// 	$("#txt_total_akhir").val(hasil);
	// 	$("#lbl_total_akhir").html(new Intl.NumberFormat('de-DE').format(hasil));
	// }
</script>