@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> Keuangan</a></li>
			<li class="active">Biaya Overhead Pabrik</li>
		</ul>
	</div>
</div>

<div class="content">
	<div class="panel panel-flat">
		<div class="panel-heading">
			<h5 class="panel-title">Tambah Biaya Overhead Pabrik</h5>
			<div class="heading-elements">
				<ul class="icons-list">
		      		<li>&nbsp;</li>
		      	</ul>
	       	</div>
	    </div>
	    
	    <form class="form-horizontal" id="form-overhead" method="post" action="{{ url('overhead_pabrik/simpan') }}">
	    	{{ Form::token() }}
	    <div class="panel-body">
	    	<div class="form-group">
	    		{{ Form::label("Tanggal", "", ['class'=>'control-label col-sm-2 col-md-2']) }}
	    		<div class="col-sm-3 col-md-3">
	    			{{ Form::text("tanggal_bop", date('d-m-Y'), ['class'=>'form-control set_datepicker', 'readonly'=>'']) }}
	    		</div>
	    	</div>
	    	<div class="form-group">
	    		{{ Form::label("Nomor", "", ['class'=>'control-label col-sm-2 col-md-2']) }}
	    		<div class="col-sm-3 col-md-3">
	    			{{ Form::text("nomor_bop", "", ['class'=>'form-control']) }}
	    		</div>
	    	</div>
	    	<div class="form-group">
	    		{{ Form::label("Bulan", "", ['class'=>'control-label col-sm-2 col-md-2']) }}
	    		<div class="col-sm-3 col-md-3">
	    			{{ Form::select("bulan_bop", $bulan, [null], ['class'=>'form-control']) }}
	    		</div>
	    		<div class="col-sm-2 col-md-2">
	    			{{ Form::selectRange('tahun_bop', date('Y')+1, 2010, date('Y'), ['class'=>'form-control']) }}
	    		</div>
	    	</div>

	    	<div class="form-group">
	    		<div class="responsive">
	    			<table class="table" id="tabel-akun-bop">
	    				<thead>
	    					<tr>
	    						<th>Akun BOP</th>
	    						<th>Keterangan</th>
	    						<th>Nominal</th>
	    						<th>&nbsp;</th>
	    					</tr>
	    				</thead>
	    				<tbody>
	    					
	    				</tbody>
	    				<tfoot>
	    					<tr>
	    						<td colspan="4">
	    							<button type="button" class="btn btn-xs btn-primary" onclick="tambah_row_akun()"><i class="icon-plus2"></i> Tambah</button>
	    						</td>
	    					</tr>
	    				</tfoot>
	    			</table>
	    		</div>
	    	</div>
	    </div>
	    <div class="panel-footer">
	    	<div class="col-sm-12 col-md-12 text-right">
	    		<a href="{{ url('overhead_pabrik') }}" class="btn btn-md btn-default">Batal</a>
	    		<button type="submit" class="btn btn-md btn-success">Simpan</button>
	    	</div>
	    </div>
		</form>

	</div>
</div>

<script type="text/javascript">
$(document).ready(function () {
	$(".set_datepicker").datepicker({
		format : 'dd-mm-yyyy',
		autoclose : true,
		zIndexOffset : 9999,
	})
});

function tambah_row_akun() {
	var rows = "<tr>"+
          "<td class='hide'>"+
          	"<input type='text' name='id_bop_detail[]' value=''  class='form-control' />"+
          	"<input type='text' name='tipe_id_akun_realisasi[]' value='debet'  class='form-control' />"+
          "</td>"+
          "<td style='vertical-align:top;' width='35%'><select name='id_akun[]' class='form-control set_select2'><?php foreach ($id_akun as $key => $value){ echo "<option value='$key'>$value</option>"; } ?></select></td>"+
          "<td style='vertical-align:top;'><input type='text' name='keterangan[]' value='-'  class='form-control' /></td>"+
          "<td style='vertical-align:top;'><input type='text' name='nominal_bop[]' value='0'  class='form-control text-right' onkeyup='setFormatMoney($(this), \"td\")' /><strong><span class='help-block text-right'>0,00</span></strong></td>"+
          "<td style='vertical-align:top;'><button type='button' class='btn btn-xs btn-link text-danger' onclick='hapusRowAkun($(this))'><i class='icon-trash'></i></button></td>"+
        "</tr>";
  	$("table#tabel-akun-bop > tbody").append(rows);
	$(".set_select2").select2();

}

function hapusRowAkun(this_) {
	var row = this_.parents("tr");
	row.remove();
}

function setFormatMoney(this_, p) {
	var div = this_.parents(p);
	var data = this_.val();
	if(data==""){
		data = 0;
	}
	div.find(".help-block").html(curr(data));
}
</script>
@endsection