@extends('layout.base')

@section('content')
<div class="row page-heading">
	<h3>Editar Pago</h3>
</div>
<br />
<form class="form-horizontal" method="post" action="{{url('', ['p' => 'pagos', 'a' => 'editar', 'pago' => $pago->id, 'asociado' => $asociado, $asociado => $id_asociado])}}">
<div class="form-group">
	<div class="col-md-2">Fecha</div>
	<?php $f = \Carbon\Carbon::parse($pago->fecha, config('app.timezone')) ?>
	@include('form.fecha')
</div>
<div class="form-group">
	<div class="col-md-2">Tipo</div>
	<div class="col-md-3"><select name="tipo" class="form-control">
	@foreach ($tipos as $tipo)
		<option value="{{$tipo->id}}"
		@if ($pago->tipo() and $tipo->id == $pago->tipo()->id)
			selected="selected"
		@endif
		>{{ucwords($tipo->descripcion)}}</option>
	@endforeach
	</select></div>
</div>
<div class="form-group">
	<div class="col-md-2">(Identificador)</div>
	<div class="col-md-4"><input type="text" name="identificador" class="form-control" value="{{$pago->identificador}}" /></div>
</div>
<div class="form-group">
	<div class="col-md-2">Banco</div>
	<div class="col-md-3"><input type="text" name="banco" class="form-control"
	@if ($pago->banco())
		value="{{$pago->banco()->nombre}}"
	@endif
	id="banco" autocomplete="off" /></div>
</div>
<div class="form-group">
	<div class="col-md-2">Valor [$]</div>
	<div class="col-md-3"><input type="text" name="valor" class="form-control" value="{{$pago->valor}}" /></div>
</div>
<div class="form-group">
	<div class="col-md-2">(Pagador)</div>
	<div class="col-md-5"><input type="text" name="pagador" class="form-control" value="{{$pago->pagador}}" /></div>
</div>
<div class="form-group">
	<div class="col-md-2">Estado</div>
	<div class="col-md-3"><select name="estado" class="form-control">
	@foreach ($estados as $estado)
		<option value="{{$estado->id}}"
		@if ($estado->id == $pago->estado()->estado)
		selected="selected"
		@endif
		>{{ucwords($estado->descripcion)}}</option>
	@endforeach
	</select></div>
</div>
<div class="form-group">
	<div class="col-md-2">Fecha Estado</div>
	<?php $f = \Carbon\Carbon::parse($pago->estado()->fecha, config('app.timezone')); $id = 'estado' ?>
	@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>
@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
