@extends('layout')


@section('content')

<style type="text/css">
	 .table-form>tbody>tr>th, .table-form>tfoot>tr>th, .table-form>thead>tr>td, .table-form>tbody>tr>td, .table-form>tfoot>tr>td{
		    padding: 5px;
		   -- vertical-align: middle;
		}
		table.table-form tbody>tr.selected, table.table-form tbody>tr.selected td, table.table-form tbody>tr>.selected{
		    color: white !important;
		    background-color: #49b6d6 !important;
		}

	 table, th, td, input, textarea, select {
            color:  black !important; 
        }
        .help-block {
 
    margin-top: 0px!important;
    margin-bottom: 0px!important;
}
</style>
<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> Pembelian</a></li>
			<li class="active">Hutang Awal</li>
		</ul>
	</div>
</div>

<div class="content">
	<div class="panel panel-flat">
		<div class="panel-heading">
			<h5 class="panel-title">Edit Hutang Awal</h5>
			<div class="heading-elements">
				<ul class="icons-list">
		      		<li><a data-action="collapse"></a></li>
		      	</ul>
	       	</div>
	    </div>
	    <div class="panel-body">
	    	<form class="form-horizontal" method="post" action="{{ url('pembelian/hutang_awal/'.$data['hutang']['id']) }}" autocomplete="off" >
	    	{{ csrf_field() }}
            {{ method_field('PUT') }}
        	<div class="col-sm-6 col-md-6">
        		<div class="form-group">
        			<label class="control-label col-sm-4">Tanggal Input</label>
        			<div class="col-sm-8">
        				{{ Form::text("tanggal", tgl_full($data["hutang"]['tanggal'], '98'), ['class'=>'form-control', 'required'=>'required', 'readonly'=>'readonly', 'disabled'=>'disabled']) }}
        			</div>
        		</div>
        		<div class="form-group">
        			<label class="control-label col-sm-4">Tanggal Faktur</label>
        			<div class="col-sm-8">
        				{{ Form::text("tanggal_faktur", tgl_full($data["hutang"]['tanggal_faktur'], '98'), ['class'=>'form-control datepicker', 'required'=>'required']) }}
        			</div>
        		</div>
        		<div class="form-group">
        			<label class="control-label col-sm-4">No. Faktur</label>
        			<div class="col-sm-8">
        				{{ Form::text("no_faktur", $data["hutang"]['no_faktur'], ['class'=>'form-control text-uppercase', 'placeholder'=>'No. Faktur', 'required'=>'required']) }}
        			</div>
        		</div>
        		<div class="form-group">
        			<label class="control-label col-sm-4">Keterangan</label>
        			<div class="col-sm-8">
        				{{ Form::textarea("keterangan", $data["hutang"]['keterangan'], ['class'=>'form-control', 'rows'=>'2']) }}
        			</div>
        		</div>
        	</div>
        	<div class="col-sm-6 col-md-6">
        		<div class="form-group">
        			<label class="control-label col-sm-4">Jenis Transaksi</label>
        			<div class="col-sm-8">
        				{{ Form::select("id_transaksi", $data['transaksi'], $data["hutang"]['id_transaksi'], ['class'=>'form-control select-search']) }}
        			</div>
        		</div>

        		<div class="form-group">
        			<label class="control-label col-sm-4">Penyedia</label>
        			<div class="col-sm-8">
        				<select class="form-control select-search" name="id_penyedia">
        					<option value="">--- Pilih Penyedia ---</option>
        					@foreach($data['supplier'] as $s)
        					<option value="{{ $s->id_penyedia }}">{{ $s->pic.' - '.$s->nama }}</option>
        					@endforeach
        				</select>
        			</div>
        		</div>

        		<div class="form-group">
        			<label class="control-label col-sm-4">Nominal</label>
        			<div class="col-sm-8">
        				{{ Form::text("nominal_netto", 0, ['class'=>'form-control text-right', 'onkeyup'=>'setFormatNumber($(this), \'div\')']) }}
        				<span class="help-block text-right" style="font-weight: bold;">0</span>
        			</div>
        		</div>

        		<div class="form-group hidden">
        			<label class="control-label col-sm-4">Cara Bayar</label>
        			<div class="col-sm-8">
	    				<select class="form-control select-search" name="id_carabayar" onchange="ubah_carabayar($(this))">
	    					@foreach($data['cara'] as $s)
	    					<option jenis_bayar="{{ $s->jenis_bayar }}" value="{{ $s->id_carabayar }}">{{ $s->cara.' - '.$s->tipe }}</option>
	    					@endforeach
	    				</select>
        			</div>
        		</div>
        	</div>

	    </div>

	    <div class="panel-footer">
	    	<div class="form-group col-md-12 col-sm-12">
				<a href="{{url('pembelian/hutang_awal')}}" class="btn bg-warning-400">Kembali</a>
				<div class="form-group pull-right">
					<button class="btn btn-primary" type="submit">Simpan</button>
				</div>
			</div>
	    </div>

	    </form>
	</div>
</div>

<script type="text/javascript">

$(document).ready(function (argument) {
    $(".form-horizontal").find("input[name=nominal_netto]").val('{{ $data["hutang"]["nominal_netto"] }}').trigger("keyup");
	$(".form-horizontal").find("select[name=id_penyedia]").val('{{ $data["hutang"]["id_penyedia"] }}').trigger("change");
})

function setFormatNumber(this_, p) {
	var parentz = this_.parents(p);
	var data = this_.val();
	parentz.find(".help-block").text(curr(data));
}
</script>

@endsection