
<?php $__env->startSection('content'); ?>
    <!-- begin::main content -->
    <main class="main-content">
        <div class="container">
            <!-- begin::page header -->
            <div class="page-header">
                <h3>Assign Fees Master</h3>
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="<?php echo e(asset('superadmin/dashboard')); ?>">Dashboard</a></li>
                        <li class="breadcrumb-item active" aria-current="page">Assign Fees</li>
                    </ol>
                </nav>
            </div>
            <!-- end::page header -->
            <?php if (isset($component)) { $__componentOriginal8a5ba9c90b64d384232e9948b1023e746ba08e74 = $component; } ?>
<?php $component = $__env->getContainer()->make(App\View\Components\FlashMessage::class, []); ?>
<?php $component->withName('flashMessage'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php $component->withAttributes([]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal8a5ba9c90b64d384232e9948b1023e746ba08e74)): ?>
<?php $component = $__componentOriginal8a5ba9c90b64d384232e9948b1023e746ba08e74; ?>
<?php unset($__componentOriginal8a5ba9c90b64d384232e9948b1023e746ba08e74); ?>
<?php endif; ?>
            <div class="card">
                <div class="card-header">
                    <form id="searchform" method="get">
                        <div class="form row">

                            
                            

                            <div class="col-md-3">
                                
                                <div class="form-group">
                                    <label for="class">Class<span class="text-danger">*</span></label>
                                    <select class="form-control select2" name="class" id="class">
                                        <?php if(!empty($classes)): ?>
                                            <option value="">--select-class--</option>
                                            <?php $__currentLoopData = $classes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $class): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option data-code="<?php echo e($class->code); ?>" value="<?php echo e($class->id); ?>">
                                                    <?php echo e($class->class); ?></option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        <?php endif; ?>
                                    </select>
                                </div>
                            </div>
                            <div class="col-md-3">
                                
                                <div class="form-group">
                                    <label for="section">Section</label>
                                    <select class="form-control select2" name="section" id="section" required>
                                    </select>
                                </div>
                            </div>
                            <div class="col-md-3">
                                
                                <div class="form-group">
                                    <label for="gender">Gender</label>
                                    <select class="form-control select2" name="gender" id="gender">
                                        <option value="">--select-gender--</option>
                                        <option value="male">Male</option>
                                        <option value="female">Female</option>
                                    </select>
                                </div>
                            </div>
                            <div class="col-md-12">

                                <a href="<?php echo e(asset('fees_master/assign')); ?>"
                                    class="btn btn-primary btn-square pull-right reset text-white">
                                    <i class="fa fa-recycle pr-1"></i>Reset
                                </a>
                                <button type="submit" class="btn btn-dark btn-square pull-right mr-2">
                                    <i class="fa fa-search pr-1"></i>Search
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="card-body">
                    <div class="message"></div>
                    <?php if(isset($classes)): ?>
                        <div class="table-responsive-md">
                            <table id="feesmaster" class="table table-bordered">
                                <thead>
                                    <tr>
                                        <th>FEES MASTER</th>
                                        <th>STUDENTS</th>
                                        <th>ACTION</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        
                                        <td style="width:35%;">
                                            <?php if(!empty($students)): ?>
                                                <?php if(!empty($feesmasters)): ?>
                                                    <?php $__currentLoopData = $feesmasters; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $fees): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                        <?php if($fees->feesmasters()->count() > 0): ?>
                                                            <ul class="list-group p-1 m-0">
                                                                <?php
                                                                    $feesmasters = $fees
                                                                        ->feesmasters()
                                                                        ->where('class_id', $_GET['class'])
                                                                        ->where(function ($feesmasters) {
                                                                            $feesmasters->where('section_id', $_GET['section'])->orWhereNull('section_id');
                                                                        })
                                                                        ->get();
                                                                ?>
                                                                <?php $__currentLoopData = $feesmasters; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $fees): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                    <li class="list-group-item m-0 p-2">
                                                                        <input class="feesmaster" type="checkbox"
                                                                            name="feesmaster[]" value="<?php echo e($fees->id); ?>">
                                                                        <label
                                                                            class="text-primary mr-2"><?php echo e($fees->code); ?></label>
                                                                        <br><span class="text-bold mr-2">&#8377
                                                                            <?php echo e($fees->amount); ?>/-</span>
                                                                    </li>
                                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                            </ul>
                                                        <?php endif; ?>
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                <?php endif; ?>
                                            <?php endif; ?>
                                        </td>
                                        <td>
                                            <?php if(!empty($students)): ?>
                                                <table class="table table-sm table-bordered font-size-11">
                                                    <thead>
                                                        <tr>
                                                            <th>
                                                                <input type="checkbox" name="checkAll" id="checkAll">
                                                            </th>
                                                            <th>CLASS</th>
                                                            <th>SECTION</th>
                                                            <th>ROLLNO</th>
                                                            <th>FULLNAME</th>
                                                        </tr>
                                                    </thead>
                                                    <?php $__currentLoopData = $students; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                        <tr>
                                                            <td>
                                                                <input class="student" type="checkbox"
                                                                    value="<?php echo e($item->id); ?>" name="student[]">
                                                            </td>
                                                            <td><?php echo e($item->class()->where('classes.id', $_GET['class'])->first()->class); ?>

                                                            </td>
                                                            <td><?php echo e($item->section()->where('sections.id', $_GET['section'])->first()->section); ?>

                                                            </td>
                                                            <td><?php echo e($item->enrollment_no); ?></td>
                                                            <td><?php echo e($item->fullname); ?></td>
                                                        </tr>
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                </table>
                                            <?php endif; ?>
                                        </td>
                                        <td style="width:10%">
                                            <?php if(!empty($students)): ?>
                                                <button id="allotment" class="btn btn-square btn-success text-white">
                                                    <i class="fa fa-share-square-o mr-1"></i>Allotment
                                                </button>
                                            <?php endif; ?>
                                        </td>
                                    </tr>

                                </tbody>
                            </table>
                        </div>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </main>
    <!-- end::main content -->
<?php $__env->stopSection(); ?>
<?php $__env->startPush('footer-script'); ?>
    <!-- begin::dataTable -->
    <script>
        $(document).ready(function() {
            toastr.options = {
                timeOut: 0,
                extendedTimeOut: 0,
                tapToDismiss: true
            }
            $("#checkAll").click(function() {
                $('.student').not(this).prop('checked', this.checked);
            });
            // Get Section
            $("#class").on('change', function() {
                var URL = "<?php echo e(asset('admission/get-section/')); ?>" + "/" + $(this).val();
                $.ajax({
                    type: "GET",
                    url: URL,
                    dataType: "JSON",
                    beforeSend: function() {
                        $("#section").empty();
                        $("#section").append("<option value=''>--select-section--</option>");
                    },
                    success: function(data) {
                        $.map(data, function(item) {
                            $("#section").append("<option data-code='" + item.code +
                                "' value='" + item.id + "'>" + item.text +
                                "</option>");
                        });
                    },
                    complete: function() {
                        $('#section').val("<?php echo e(Request::get('section')); ?>").trigger('change');
                    }
                });
            });
            $('#class').val("<?php echo e(Request::get('class')); ?>").trigger('change');
        });
    </script>
    <?php if(!empty(Request::has('school'))): ?>
        <script>
            $('#schools').val("<?php echo e(Request::get('school')); ?>").trigger('change');
        </script>
    <?php endif; ?>
    <?php if(!empty(Request::has('gender'))): ?>
        <script>
            $('#gender').val("<?php echo e(Request::get('gender')); ?>").trigger('change');
        </script>
    <?php endif; ?>
    <script>
        $(document).ready(function() {

            $('#allotment').on('click', function() {
                var students = $(".student:checked").map(function() {
                    return $(this).val();
                }).get();

                var feesmasters = $(".feesmaster:checked").map(function() {
                    return $(this).val();
                }).get();

                $.ajax({
                    type: "POST",
                    url: "<?php echo e(asset('fees_master/assign')); ?>",
                    dataType: "JSON",
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    },
                    data: {
                        students: students,
                        feesmasters: feesmasters,
                        class: $('#class').val(),
                        section: $('#section').val(),
                    },
                    beforeSend: function() {
                        $('#allotment').prop('disabled', true);
                        $('#allotment').html(
                            '<i class="spinner-border spinner-border-sm mr-2"></i> Loading');
                    },
                    success: function(data) {
                        if (data.status) {
                            toastr.success(data.message);
                            $('.student').prop('checked', false);
                            $('.message').html('<div class="alert alert-success">' + data
                                .message + '</div>');
                        } else {
                            toastr.error(data.message);
                        }
                    },
                    complete: function() {
                        $('#allotment').prop('disabled', false);
                        $('#allotment').html(
                            '<i class="fa fa-share-square-o mr-1"></i>Allotment');
                    }
                });


            });
        });
    </script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layout', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH F:\xampp\htdocs\school_saas_erp\resources\views/fees_masters/assign.blade.php ENDPATH**/ ?>