@extends('layout.base') @section('content')
<div class="panel panel-default">
	<div class="panel-heading">Editar Cuota - <a href="{{url('', ['p' => 'pies', 'a' => 'resumen', 'pie' => $cuota->pie()->id])}}">Departamento {{$cuota->pie()->venta()->unidad()->descripcion}}</a> - {{$cuota->pie()->venta()->proyecto()->descripcion}}</div>
	<div class="panel-body">
		<form class="form-horizontal" method="post" action="{{url('', ['p' => 'cuotas', 'a' => 'editar', 'cuota' => $cuota->id])}}">
			<?php $f = \Carbon\Carbon::parse($cuota->fecha, config('app.timezone')); $t = \Carbon\Carbon::today(config('app.timezone')) ?>
			<div class="form-group">
				<div class="col-md-2">#</div>
				<div class="col-md-2"><input type="text" size="2" maxlength="2" class="form-control" name="numero" value="{{$cuota->numero}}" /></div>
			</div>
			<div class="form-group">
				<div class="col-md-2">Fecha</div>
				<div class="col-md-1"><select name="day" class="form-control">
				@for ($i = 0; $i < 31; $i ++)
					<option value="{{$i + 1}}"
					@if ($i + 1 == $f->day)
					selected="selected"
					@endif
					>{{str_pad($i + 1, 2, '0', STR_PAD_LEFT)}}</option>
				@endfor
				</select></div>
				<div class="col-md-1"><select name="month" class="form-control">
				@for ($i = 0; $i < 12; $i ++)
					<option value="{{$i + 1}}"
					@if ($i + 1 == $f->month)
					selected="selected"
					@endif
					>{{str_pad($i + 1, 2, '0', STR_PAD_LEFT)}}</option>
				@endfor
				</select></div>
				<div class="col-md-2"><select name="year" class="form-control">
				@for ($i = $t->year + 4; $i > $t->year - 5; $i --)
					<option value="{{$i}}"
					@if ($i == $f->year)
						selected="selected"
					@endif
					>{{$i}}</option>
				@endfor
				</select></div>
			</div>
			<div class="form-group">
				<div class="col-md-2">Banco</div>
				<div class="col-md-5"><input type="text" name="banco" id="banco" class="form-control" value="{{($cuota->pago()->banco != 0) ? $cuota->pago()->banco()->nombre : ''}}" autocomplete="off" /></div>
			</div>
			<div class="form-group">
				<div class="col-md-2">Identificador</div>
				<div class="col-md-5"><input type="text" name="identificador" class="form-control" value="{{$cuota->pago()->identificador}}" /></div>
			</div>
			<div class="form-group">
				<div class="col-md-2">Valor [$]</div>
				<div class="col-md-4"><input type="text" name="valor" class="form-control" value="{{$cuota->pago()->valor}}" /></div>
			</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