
<?php $__env->startSection('content'); ?>

<!-- Responsive Datatable -->
<section id="responsive-datatable">
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-header border-bottom">
                    <h4 class="card-title"><?php echo e(trans("general.student_financials", [ 'student' => $student->first_name. ' ' .$student->last_name] )); ?></h4>
                    <button type="button" id="addStudentFinancialModalButton" class="btn btn-outline-primary" data-bs-toggle="modal" data-bs-target="#addStudentFinancialModal">
                        <?php echo e(trans("general.add_record")); ?>

                    </button>
                </div>
                <div class="card-body">
                    <div class="mt-2 ">
                        <div class="row">
                            <div class="col-md-6">
                                <div class="row">
                                    <div for="paid" class="col-sm-6"><?php echo e(trans('general.total_paid')); ?></div>
                                    <div class="col-sm-6">
                                        <?php echo e($totalPaid); ?>

                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="row">
                                    <div for="unpaid" class="col-sm-6"><?php echo e(trans('general.total_unpaid')); ?></div>
                                    <div class="col-sm-6">
                                        <?php echo e($totalUnpaid); ?>

                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <hr>
                </div>
                <div class="card-datatable">
                    <?php echo e($dataTable->table([
                    "class" => "dt-responsive table",
                    "style" => ""
                        ])); ?>

                </div>
            </div>
        </div>
    </div>
</section>
<!--/ Responsive Datatable -->



<!-- Vertical modal -->
<div class="vertical-modal-ex">
    <!-- Modal -->
    <div class="modal fade" id="addStudentFinancialModal" tabindex="-1" aria-labelledby="addStudentFinancialModalTitle" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered">
            <div class="modal-content">
                <form onsubmit="addStudentFinancial(this); return false;">
                    <?php echo csrf_field(); ?>
                    <input type="hidden" name="student_id" value="<?php echo e($student->id); ?>">
                    <div class="modal-header">
                        <h5 class="modal-title" id="addStudentFinancialModalTitle"><?php echo e(trans('general.new_form')); ?></h5>
                        <button type="button" id="dismissModalButton" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                    </div>
                    <div class="modal-body">
                        <div class="col-12">
                            <div class="mb-1">
                                <label class="form-label" for="amount"><?php echo e(trans('general.amount')); ?></label>
                                <input type="number" class="form-control" name="amount" id="amount">
                            </div>
                        </div>
                        <div class="col-12">
                            <div class="mb-1">
                                <label class="form-label" for="transactioType"><?php echo e(trans('general.transaction_type')); ?></label>
                                <select required name="transactioType" class="form-select" id="transactioType">
                                    <option value="">--</option>
                                    <?php $__currentLoopData = $transactiosTypes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $transactioType): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($transactioType->id); ?>">
                                        <?php echo e($transactioType->title); ?>

                                    </option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>
                        </div>
                        <div class="col-12">
                            <div class="mb-1">
                                <label class="form-label" for="transaction_number"><?php echo e(trans('general.transaction_number')); ?></label>
                                <input type="text" class="form-control" name="transaction_number" id="transaction_number">
                            </div>
                        </div>
                        <div class="col-12">
                            <div class="mb-1">
                                <label class="form-label" for="date"><?php echo e(trans('general.date')); ?></label>
                                <input type="text" name="date" id="date" class="form-control flatpickr-basic" value="<?php echo e(old('birth_date')? old('birth_date') : ''); ?>" placeholder="YYYY-MM-DD" />
                            </div>
                        </div>
                        <div class="col-12">
                            <div class="mb-1">
                                <label class="form-label" for="note"><?php echo e(trans('general.note')); ?></label>
                                <textarea required name="note" id="note" class="form-control"></textarea>
                            </div>
                        </div>

                    </div>
                    <div class="modal-footer">
                        <button class="btn btn-primary"><?php echo e(trans('general.save')); ?></button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<!-- Vertical modal end-->



<?php $__env->startPush('scripts'); ?>


<?php echo $dataTable->scripts(); ?>

<script src="<?php echo e(url('design')); ?>/app-assets/vendors/js/tables/datatable/jquery.dataTables.min.js"></script>
<script src="<?php echo e(url('design')); ?>/app-assets/vendors/js/tables/datatable/dataTables.bootstrap5.min.js"></script>
<script src="<?php echo e(url('design')); ?>/app-assets/vendors/js/tables/datatable/dataTables.responsive.min.js"></script>
<script src="<?php echo e(url('design')); ?>/app-assets/vendors/js/tables/datatable/responsive.bootstrap5.js"></script>

<script src="<?php echo e(url('design')); ?>/app-assets/vendors/js/pickers/flatpickr/flatpickr.min.js"></script>
<script>
    function addStudentFinancial(element) {

        formData = $(element).serializeArray().reduce(function(obj, item) {
            obj[item.name] = item.value;
            return obj;
        }, {});


        var jqxhr = $.ajax({
                url: "<?php echo e(route('admin.financial.student.add', $student->id)); ?>",
                method: "POST",
                timeout: 0,
                data: formData
            })
            .done(function(response) {
                console.log(response);
                toastr.success("<?php echo e(trans('general.record_added_successfully')); ?>");
                $('#studentfinancialrecords-table').DataTable().ajax.reload();
                $('#dismissModalButton').click();
                resetForm();
            })
            .fail(function(response) {
                console.log(response);
                toastr.error(response.responseJSON.msg, '<?php echo e(trans("general.error")); ?>');
            });

    }

    function resetForm() {
        $("#amount").val('');
        $("#transactioType").val('');
        $("#transaction_number").val('');
        $("#date").val('');
        $("#note").val('');
    }

    (function(window, document, $) {
        'use strict';
        $('.flatpickr-basic').flatpickr();
    })(window, document, jQuery);
</script>


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

<?php $__env->startPush('header'); ?>

<!-- BEGIN: Vendor CSS-->
<link rel="stylesheet" type="text/css" href="<?php echo e(url('design')); ?>/app-assets/vendors/css/vendors-rtl.min.css">
<link rel="stylesheet" type="text/css" href="<?php echo e(url('design')); ?>/app-assets/vendors/css/tables/datatable/dataTables.bootstrap5.min.css">
<link rel="stylesheet" type="text/css" href="<?php echo e(url('design')); ?>/app-assets/vendors/css/tables/datatable/responsive.bootstrap5.min.css">
<link rel="stylesheet" type="text/css" href="<?php echo e(url('design')); ?>/app-assets/vendors/css/pickers/flatpickr/flatpickr.min.css">
<!-- END: Vendor CSS-->

<!-- BEGIN: Theme CSS-->
<link rel="stylesheet" type="text/css" href="<?php echo e(url('design')); ?>/app-assets/css-rtl/bootstrap.css">
<link rel="stylesheet" type="text/css" href="<?php echo e(url('design')); ?>/app-assets/css-rtl/bootstrap-extended.css">
<link rel="stylesheet" type="text/css" href="<?php echo e(url('design')); ?>/app-assets/css-rtl/colors.css">
<link rel="stylesheet" type="text/css" href="<?php echo e(url('design')); ?>/app-assets/css-rtl/components.css">
<link rel="stylesheet" type="text/css" href="<?php echo e(url('design')); ?>/app-assets/css-rtl/themes/dark-layout.css">
<link rel="stylesheet" type="text/css" href="<?php echo e(url('design')); ?>/app-assets/css-rtl/themes/bordered-layout.css">
<link rel="stylesheet" type="text/css" href="<?php echo e(url('design')); ?>/app-assets/css-rtl/themes/semi-dark-layout.css">

<!-- BEGIN: Custom CSS-->
<link rel="stylesheet" type="text/css" href="<?php echo e(url('design')); ?>/app-assets/css-rtl/custom-rtl.css">
<link rel="stylesheet" type="text/css" href="<?php echo e(url('design')); ?>/assets/css/style-rtl.css">
<!-- END: Custom CSS-->


<link rel="stylesheet" type="text/css" href="<?php echo e(url('design')); ?>/app-assets/vendors/css/pickers/flatpickr/flatpickr.min.css">

<?php $__env->stopPush(); ?>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.index', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\Users\nobalaa-dev\Desktop\New folde2r\portal\resources\views/admin/students/financials/student-financials.blade.php ENDPATH**/ ?>