@extends('layout.base')

@section('content')
<div class="panel panel-default">
	<div class="panel-heading">Editar Pago de Escritura - {{$venta->unidad()->descripcion}} - {{$venta->proyecto()->descripcion}}</div>
	<div class="panel-body">
		<form class="form-horizontal" method="post" action="{{url('', ['p' => 'escrituras', 'a' => 'editar', 'venta' => $venta->id])}}">
		<div class="form-group">
			<div class="col-md-2">Valor [$]</div>
			<div class="col-md-4"><input type="text" name="valor" value="{{$venta->escritura()->pago()->valor}}" class="form-control" /></div>
		</div>
		<div class="form-group">
			<div class="col-md-2">(Valor [UF])</div>
			<div class="col-md-4"><input type="text" name="valor_uf" value="{{$venta->escritura()->pago()->valor('ufs')}}" class="form-control" /></div>
		</div>
		<div class="form-group">
			<div class="col-md-2">Fecha</div>
			<?php $f = \Carbon\Carbon::parse($venta->escritura()->pago()->fecha, config('app.timezone')) ?>
			<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 = $f->year + 1; $i > $f->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-offset-2 col-md-3"><input type="submit" value="Editar" class="form-control" /></div>
		</div>
		</form>
	</div>
</div>
@endsection