<?php include "Views/templates/header.php"; ?>
<button class="btn btn-success mb-2 btn-toolbar-status" title='Reporte - Antigüedad de Saldos' type="button" onclick="btnReporteAntiguedadSaldos(active_row);"><i class="fas fa-scale-unbalanced"></i></button>
<button class="btn btn-success mb-2 btn-toolbar-status" title='Reporte - Cuentas por Cobrar' type="button" onclick="btnReporteCuentasxCobrar(active_row);"><i class="fas fa-file-invoice-dollar"></i></button>
<button class="btn btn-warning mb-2 btn-toolbar-status" title='Analisis de Cuentas por Cobrar'type="button" onclick="btnEditarVen(active_row);"><i class="fas fa-chart-pie"></i></button>


<div class="card">
    <div class="card-body">
        <div class="row">
            <div class="col-md-4">
                <label for="">Desde</label>
                <input class="form-control" id="min" type="date" name="vcredito_desde">
            </div>
            <div class="col-md-4">
                <div class="form-group">
                    <label for="">Hasta</label>
                    <input class="form-control" id="max" type="date" name="vcredito_hasta">
                </div>
            </div>
            <div class="col-md-4">
                <div class="form-group">
                    <label for="my-input">Administrar</label><br>
                    <button class="btn btn-outline-primary btn-block" type="button" name="vhistorial_creditos" onclick="mostrarTodo(event)">Mostrar Todo</button>
                </div>
            </div>
        </div>
        <div class="table-responsive">
            <table class="table table-striped table-hover display responsive nowrap" id="t_creditos" style="width: 100%;">
                <thead>
                    <tr>
                        <th>Factura</th>
                        <th>Cliente</th>
                        <th>Fecha</th>
                        <th>Monto</th>
                        <th>Abonos</th>
                        <th>Saldo</th>
                        <th>Estado</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                </tbody>
                <tfoot>
                    <tr>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                </tfoot>
            </table>
        </div>
    </div>
</div>

<div id="nuevo_abono" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="my-modal-title" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header bg-primary">
                <h5 class="modal-title" id="my-modal-title">Nuevo Abono</h5>
                <button class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <form id="formulario" onsubmit="registrarAbono(event);" autocomplete="off">
                <div class="modal-body">
                    <div class="row">
                        <div class="col-md-12">
                            <div class="form-group">
                                <label for="cliente"><i class="fas fa-users"></i> Datos del Cliente</label>
                                <input type="hidden" id="id" name="id">
                                <input type="hidden" id="id_cliente" name="id_cliente">
                                <input class="form-control" type="text" id="cliente" disabled>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="monto_total"><i class="fas fa-money-bill-alt"></i> Monto Total</label>
                                <input class="form-control" type="text" id="monto_total" disabled>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="abonado"><i class="fas fa-credit-card"></i> Abonos</label>
                                <input class="form-control" type="text" id="abonado" disabled>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="restante"><i class="fas fa-info-circle"></i> Saldo</label>
                                <input class="form-control" type="text" id="restante" disabled>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="monto"><i class="fas fa-money-check-alt"></i> Abonar</label>
                                <input id="monto" class="form-control" type="text" name="monto" placeholder="Ingrese Monto" required onkeyup="verificarMonto(event)">
                                <span id="error_monto" class="text-danger"></span>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="fecha"><i class="fas fa-calendar"></i> Fecha</label>
                                <input id="fecha" class="form-control" name="fecha" type="date" required/>
                            </div>
                        </div>
                        
                        <div class="clearfix">&nbsp;</div>
                        
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="tipo"><i class="fas fa-money-check"></i> Tipo</label>
                                <select id="tipo" class="form-control" name="tipo" required></select>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="referencias"><i class="fas fa-keyboard"></i> Referencias</label>
                                <input id="referencias" class="form-control" name="referencias" type="text" required/>
                            </div>
                        </div>

                       <div class="col-md-12">
                            <div class="form-group">
                                <label for="observaciones"><i class="fas fa-comments"></i> Observaciones</label>
                                <textarea style='resize: vertical;' id="observaciones" class="form-control" name="observaciones" maxlength="255"></textarea>
                            </div>
                       </div>                       
                    </div>
                </div>
                <div class="modal-footer">
                    <button class="btn btn-outline-primary d-none" type="submit" id="btnAbonar"><i class="fas fa-save"></i> Guardar</button>
                    <button class="btn btn-outline-danger" type="button" data-dismiss="modal"><i class="fas fa-ban"></i> Cancelar</button>
                </div>
            </form>
        </div>
    </div>
</div>
<?php include "Views/templates/footer.php"; ?>