@extends('template.layout')
@section('styles')

@endsection
@section('content')
    <h1 class="page-title">
        <a href="{{ url('tesoreria/eventos') }}"><i class="icon-action-undo"></i></a>
        Tesorer&iacute;a
    </h1>
    <div class="portlet light bordered">
        <div class="portlet-title">
            <div class="caption">
                <h4 class="modal-title caption-subject font-blue-secondary sbold uppercase">Generar Recibo de Pago</h4>
            </div>
        </div>
        <div class="portlet-body">
                <div class="row">
                    <div class="col-md-offset-6 col-md-6">
                        <div class="form-group form-md-line-input">
                            <div class="col-md-12">
                                <h4 style="text-align:center">N&uacute;mero de recibo: {{ $recibo->numero }}</h4>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="col-md-6">
                        <div class="form-group form-md-line-input">
                            <label class="col-md-4" for="fecha"> Fecha </label>
                            <div class="col-md-8">
                                <input type="text" class="form-control" value="{{ Carbon\Carbon::now()->format('d-m-Y')  }}" id="fecha" name="fecha" readonly>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group form-md-line-input">
                            <label class="col-md-4" for="fecha"> Turno </label>
                            <div class="col-md-8">
                                @if ($recibo->turno->turno == config('constants.TURNO.MAÑANA'))
                                    <input type="text" class="form-control" value="Mañana" id="turno" name="turno" readonly>
                                @else
                                    <input type="text" class="form-control" value="Tarde" id="turno" name="turno" readonly>
                                @endif
                            </div>
                        </div>
                    </div>
                </div>

                <div class="row">
                    @if($recibo->usuario)
                        <div class="col-md-6">
                            <div class="form-group form-md-line-input">
                                <label class="col-md-4" for="form_control_1">C&oacute;digo del usuario</label>
                                <div class="col-md-8">
                                    <input type="text" class="form-control" value="{{ $recibo->usuario->username }}" id="codigo" name="codigo" readonly>
                                </div>
                            </div>
                        </div>
                    @endif
                    <div class="col-md-6">
                        <div class="form-group form-md-line-input">
                            <label class="col-md-4" for="nombre">Nombre Completo
                            </label>
                            <div class="col-md-8">
                                <input type="text" class="form-control" value="{{ $recibo->nombre_cliente }}" id="nombre" name="nombre" readonly>
                                <div class="form-control-focus"> </div>
                                <span class="help-block">Nombre</span>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <table class="table table-hover nowrap dataTable dtr-inline" id="tb-recibo">
                        <thead class="thead-default">
                        <tr>
                            <th>Concepto</th>
                            <th>Costo</th>
                        </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
                <div class="form-group form-md-line-input">
                    <div class="col-md-offset-6 col-md-6">
                        <h4 id="monto_total" style="text-align:center">Monto total: S/. {{ $recibo->monto }} </h4>
                    </div>
                </div>
            {{ Form::open(['route' => 'pagos.recibo.post','class'=>'form-horizontal','id' => 'form-recibo']) }}
                <div class="form-group">
                    <div class="col-md-2">
                        <label>Tipo de Pago</label>
                    </div>
                    <div class="col-md-8">
                        <div class="mt-radio-inline">
                            <label class="mt-radio">
                                <input type="radio" name="tipo_pago" id="tipo_pago" value="1" {{ ($recibo->metodo_pago == 1 ? 'checked="checked"' : '') }} {{ $recibo->cancelado ? 'disabled="disabled"' : '' }}> Efectivo
                                <span></span>
                            </label>
                            <label class="mt-radio">
                                <input type="radio" name="tipo_pago" id="tipo_pago" value="2" {{ ($recibo->metodo_pago == 2 || $recibo->metodo_pago == 0 ? 'checked="checked"' : '') }} {{ $recibo->cancelado ? 'disabled="disabled"' : '' }}> Voucher de Pago
                                <span></span>
                            </label>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div id="voucher-container" class="col-md-6" style="{{ ($recibo->metodo_pago == 1 ? 'display: none' : '') }}">
                        <div><button class="btn btn-primary" type="button" data-toggle="modal" data-target="#modal"><i class="fa fa-plus"></i> Agregar Voucher</button></div>
                        <table class="table table-hover nowrap dataTable dtr-inline" id="tb-voucher">
                            <thead class="thead-default">
                            <tr>
                                <th>C&oacute;digo</th>
                                <th>Monto</th>
                                <th>Opciones</th>
                            </tr>
                            </thead>
                            <tbody>
                            </tbody>
                        </table>
                    </div>
                </div>
                <input type="hidden" name="id" value="{{ $recibo->id }}" />
            <div class="form-group">
                <div class="col-md-6">
                    <div class="row">
                        <div class="col-md-5">
                            <button id="cancelar" style="width: 100%" data-id="{{ $recibo->id }}" class="btn btn-default" type="button"> Cancelar Recibo </button>
                        </div>
                        <div class="col-md-5">
                            <a id="descargar" href="{{ url('tesoreria/pagos/imprimir/' . $recibo->id) }}" style="width: 100%" data-id="{{ $recibo->id }}" class="btn btn-default" type="button"> Descargar Excel </a>
                        </div>
                    </div>
                </div>
                <div class="col-md-6">
                    <button style="width: 100%" id="submitRecibo" type="submit" class="btn btn-primary ladda-button" data-style="slide-down">
                        <span id="submitTexto" class="ladda-label"> {{ ($recibo->cancelado == 1 ? 'Imprimir Recibo' : 'Generar Recibo') }} </span>
                        <span class="ladda-spinner"></span>
                    </button>
                </div>
            </div>
                {!! Form::close() !!}
        </div>
    </div>
    @include('pages.tesoreria.pagos.partials.voucher')
@endsection

@section('scripts')
    <script src="{{asset('plugins/datatables/plugins/datatables.celledit.js')}}"></script>
    <script src="{{asset('plugins/datatables/plugins/datatables.sum.min.js')}}"></script>
    <script>
        var urlBase = '{{ url('tesoreria/pagos') }}';
        var urlConceptos = '{{ route('pagos.conceptos.get',['id' => $recibo->id]) }}';
        var urlVouchers = '{{ route('pagos.vouchers.get',['id' => $recibo->id]) }}';
    </script>
    <script src="{{asset('js/pages/tesoreria.eventos.recibo.min.js')}}"></script>

@endsection

