@extends('layout.base')

@section('content')
<div class="panel panel-default">
	<div class="panel-heading">Editar Crédito - {{$venta->unidad()->descripcion}} - {{$venta->proyecto()->descripcion}}</div>
	<div class="panel-body">
	<form action="{{url('', ['p' => 'creditos', 'a' => 'editado', 'venta' => $venta->id])}}" method="post" class="form-horizontal">
		<div class="form-group">
			<div class="col-md-2">Banco</div>
			<div class="col-md-5"><input type="text" name="banco" class="form-control" id="banco" autocomplete="off" 
			@if ($venta->credito()->pago()->banco != 0)
				value="{{$venta->credito()->pago()->banco()->nombre}}"
			@endif
			/></div>
		</div>
		<div class="form-group">
			<div class="col-md-2">Valor [UF]</div>
			<div class="col-md-4"><input type="text" name="valor" class="form-control" value="{{$venta->credito()->pago()->valor('ufs')}}" /></div>
			<div class="col-md-1">UF</div>
		</div>
		<div class="form-group">
			<div class="col-md-2">Fecha</div>
			<?php $f = \Carbon\Carbon::parse($venta->credito()->pago()->fecha, config('app.timezone')) ?>
			@include('form.fecha')
		</div>
		<div class="form-group">
			<div class="col-md-offset-2 col-md-3"><input type="submit" value="Editar" class="form-control" /></div>
		</div>
	</form>
	</div>
</div>
@endsection

@push('scripts')
<script type="text/javascript">
$(document).ready(function() {
	$.getJSON('{!!url('', ['p' => 'ajax', 'a' => 'buscar', 't' => 'bancos'])!!}', function(data, status, xhr) {
		$('#banco').typeahead({"source": data});
	});
});
</script>
@endpush