
<?php $__env->startSection('title'); ?> Inicio <?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
<!-- this is breadcrumbs -->
<?php $__env->startComponent('components.breadcrumb'); ?>
<?php $__env->slot('li_1'); ?> Inicio <?php $__env->endSlot(); ?>
<?php $__env->slot('li_2'); ?> Panel Lectura <?php $__env->endSlot(); ?>
<?php $__env->slot('title'); ?> Proyección de Recaudación <?php $__env->endSlot(); ?>
<?php echo $__env->renderComponent(); ?>

<!-- start page content -->
<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-body mb-n3">
                

                <div class="mb-3">
                    <form id="form-recaudado" class="row g-3 mb-4">
                        <?php echo csrf_field(); ?>
                        <div class="col-md-3">
                            <label for="anio" class="form-label">Año</label>
                            <input type="number" id="anio" name="anio" class="form-control" 
                                value="<?php echo e(date('Y')); ?>" min="2000" max="<?php echo e(date('Y')); ?>">
                        </div>
                        <div class="col-md-3">
                            <label for="mes" class="form-label">Mes</label>
                            <select id="mes" name="mes" class="form-control">
                                <?php $__currentLoopData = range(1,12); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $m): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($m); ?>" <?php echo e(date('m') == $m ? 'selected' : ''); ?>>
                                        <?php echo e(\Carbon\Carbon::createFromDate(date('Y'), $m, 1)->locale('es')->translatedFormat('F')); ?>

                                    </option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                        <div class="col-md-3 d-flex align-items-end">
                            <button type="submit" class="btn btn-success w-100">Consultar</button>
                        </div>
                    </form>
                </div>
                 <div id="resultado-recaudado">

                 
            </div>
            <!--end card-body-->
        </div>
        <!--end card-->
    </div>
    <!--end col-->
</div>














<!--end row-->


<?php $__env->stopSection(); ?>
<?php $__env->startSection('script'); ?>
<!-- jQuery y DataTables -->

<!-- jQuery y DataTables -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>

<!-- DataTables Buttons -->
<script src="https://cdn.datatables.net/buttons/2.3.6/js/dataTables.buttons.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
<script src="https://cdn.datatables.net/buttons/2.3.6/js/buttons.html5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.3.6/js/buttons.print.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.3.6/js/buttons.colVis.min.js"></script>

<!-- DataTables CSS -->
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.6/css/jquery.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.3.6/css/buttons.dataTables.min.css">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<!-- tablas -->
<script>
    $(document).ready(function () {
        $("#tablaRecibos").DataTable({
            "responsive": true,
            "lengthChange": true,
            "autoWidth": false,
            "buttons": [
                {
                    extend: 'collection',
                    text: 'Opciones',
                    buttons: [
                        { extend: 'copy', text: 'Copiar' },
                        { extend: 'csv', text: 'CSV' },
                        { extend: 'excel', text: 'Excel', title: 'Periodos Académicos' },
                        { extend: 'pdf', text: 'PDF' },
                        { extend: 'print', text: 'Imprimir' }
                    ]
                },
                { extend: 'colvis', text: 'Visibilidad de Columna' }
            ],
            "paging": true,
            "searching": true,
            "info": true,
            "language": {
                "search": "Buscar:",
                "lengthMenu": "Mostrar _MENU_ registros por página",
                "info": "Mostrando _START_ a _END_ de _TOTAL_ entradas",
                "paginate": {
                    "first": "Primero",
                    "previous": "Anterior",
                    "next": "Siguiente",
                    "last": "Último"
                }
            }
        }).buttons().container().appendTo('#tablaRecibos_wrapper .col-md-6:eq(0)');
    });
</script>


<script>
$(function () {
    $('#form-recaudado').on('submit', function (e) {
        e.preventDefault();

        let form = $(this);

        $.ajax({
            url: "<?php echo e(route('reportes.recaudado_real')); ?>",
            method: "GET",
            data: form.serialize(),
            beforeSend: function () {
                Swal.fire({
                    title: 'Consultando...',
                    text: 'Obteniendo datos de recaudación real.',
                    allowOutsideClick: false,
                    didOpen: () => Swal.showLoading()
                });
            },
            success: function (res) {
                Swal.close();

                if (res.success) {
                    let html = `
                        <div class="card shadow">
                            <div class="card-body">
                                <h5>Resultado</h5>
                                <table class="table table-bordered">
                                    <thead class="table-light">
                                        <tr>
                                            <th>Mes</th>
                                            <th>Total Recaudado (S/.)</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                            <td>${res.mes}</td>
                                            <td class="fw-bold text-success">S/ ${parseFloat(res.total).toFixed(2)}</td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    `;
                    $('#resultado-recaudado').html(html);
                } else {
                    Swal.fire('Sin datos', 'No hay pagos registrados para este periodo.', 'warning');
                    $('#resultado-recaudado').html('');
                }
            },
            error: function () {
                Swal.close();
                Swal.fire('Error', 'Ocurrió un problema al consultar.', 'error');
            }
        });
    });
});
</script>

<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.master', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH D:\SISTEMAS\agua\resources\views/reportes/recaudado_real.blade.php ENDPATH**/ ?>