
<?php $__env->startSection('content'); ?>
    <!-- begin::main content -->
    <main class="main-content">
        <div class="container">
            <!-- begin::page header -->
            <div class="page-header">
                <h3><?php echo e(__('message.save')); ?></h3>
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="<?php echo e(asset('dashboard')); ?>"><?php echo e(__('message.dashboard')); ?></a></li>
                        <li class="breadcrumb-item active" aria-current="page"><?php echo e(__('message.import')); ?></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; ?>
            <?php if($errors->any()): ?>
                <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="alert alert-danger"><?php echo e($error); ?></div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            <?php endif; ?>
            <div class="card">

                <div class="card-header">
                    <h3 class="h6 pull-left"><?php echo e(__('message.bulkimportuser')); ?></h3>
                </div>
                <div class="card-body">
                    <form id="import_form" method="POST" action="<?php echo e(asset('admission/import')); ?>" enctype="multipart/form-data">
                        <?php echo csrf_field(); ?>
                        
                        <div class="row mb-3">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <input accept=".csv,.xls,.xlsx" class="form-control" type="file" name="result_csv"
                                        id="result_csv">
                                    <?php if($errors->has('result_csv')): ?>
                                        <div class="text-danger">
                                            <?php echo e($errors->first('result_csv')); ?>

                                        </div>
                                    <?php endif; ?>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <a class="btn btn-default btn-success text-white pull-right"
                                    href="<?php echo e(asset('public/bulk_users_admit.xlsx')); ?>">
                                    <i class="fa fa-download mr-1"></i><?php echo e(__('message.bulkexcelsample')); ?></a>
                                <button class="btn btn-primary pull-right mr-2" type="submit">
                                    <i class="fa fa-upload mr-1"></i><?php echo e(__('message.import')); ?></button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </main>

    
    <?php if(Auth::user()->hasRole('superadmin') || Auth::user()->can('change-student-password')){ ?>

    <div class="modal fade" id="changepasswordModal" tabindex="-1" role="dialog"
        aria-labelledby="changepasswordModalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="changepasswordModalLabel">Reset Password</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <form id="change_password_form">
                        
                        <input type="hidden" name="user_unique_id" id="user_unique_id">

                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label for="password" class="col-form-label">Password</label>
                                    <input type="password" id="password" name="password" class="form-control">
                                </div>
                            </div>
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label for="password_confirmation" class="col-form-label">Confirm Password</label>
                                    <input type="text" id="password_confirmation" name="password_confirmation"
                                        class="form-control">
                                </div>
                            </div>
                        </div>

                        <button type="submit" class="btn btn-success">
                            <i class="fa fa-edit mr-2"></i>Update Password
                        </button>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <?php } ?>

    <!-- end::main content -->
<?php $__env->stopSection(); ?>
<?php $__env->startPush('footer-script'); ?>
    <script src="<?php echo e(asset('public/admin/vendors/dataTable/jquery.dataTables.min.js')); ?>"></script>
    <script src="<?php echo e(asset('public/admin/vendors/dataTable/dataTables.bootstrap4.min.js')); ?>"></script>
    <script src="<?php echo e(asset('public/admin/vendors/dataTable/dataTables.responsive.min.js')); ?>"></script>

    <script>
				// From Post
				// $('#import_form').on('submit', function(e) {
				// 		e.preventDefault();
				// 		$.ajax({
				// 				headers: {
        //             'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        //         },
				// 				type: "POST",
				// 				url: "<?php echo e(asset('admission/import')); ?>",
				// 				data: $(this).serialize(),
				// 				success: function(msg) {
				// 				alert(msg);
				// 				}
				// 		});
				// });

        $(document).on("click", ".change-password", function() {
            $(".modal-body #user_unique_id").val($(this).data('user_unique_id'));
            $('#changepasswordModal').modal('show');
        });

        // Model Submit
        $(document).on('submit', '#change_password_form', function(e) {
            e.preventDefault();
            var formData = new FormData(jQuery('#change_password_form')[0]);
            $.ajax({
                type: 'POST',
                url: "<?php echo e(asset('student/change-password')); ?>",
                data: formData,
                contentType: false,
                processData: false,
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                success: function(data) {
                    $('.error').empty();
                    $('#changepasswordModal').modal('hide');
                    swal({
                            title: "Reset Password",
                            text: data.message,
                            icon: "success"
                        })
                        .then((value) => {
                            $('#changepasswordModal').modal('hide');
                            location.reload();
                        });
                },
                error: function(reject) {
                    $('.error').empty();
                    if (reject.status === 422) {
                        var errors = $.parseJSON(reject.responseText);
                        $.each(errors, function(key, val) {
                            $('<div class="text-danger error">' + val + '</div>')
                                .insertAfter("#" + key);
                        });
                    }
                }
            });
        });

        // Get Section
        $("#class").on('change', function() {
            var URL = "<?php echo e(asset('admission/get-section/')); ?>" + "/" + $(this).val();
            $.ajax({
                type: "GET",
                url: URL,
                dataType: "JSON",
                success: function(data) {
                    $("#section").empty();
                    $("#section").select2({
                        data: data
                    });
                    $("#section").val("<?php echo e(Request::get('section')); ?>").trigger('change');
                }
            });
        });


        $("#checkAll").click(function() {
            $('.studentids').not(this).prop('checked', this.checked);
        });

        // Delete Multiple
        $("#delete-multiple").click(function() {
            var URL = "<?php echo e(asset('student/delete')); ?>";
            var student_ids = [];
            $('.studentids:checkbox:checked').each(function() {
                student_ids.push($(this).val());
            });
            swal({
                title: 'Are you sure?',
                text: 'Once deleted, you will not be recover!',
                icon: 'warning',
                dangerMode: true,
                buttons: ["Cancel", "Yes!"],
            }).then(function(value) {
                if (value) {
                    $.ajaxSetup({
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        }
                    });

                    $.ajax({
                        type: "post",
                        data: {
                            "student_ids": student_ids
                        },
                        url: URL,
                        dataType: "html",
                        success: function(result) {
                            console.log(result);
                        }
                    });
                    swal("success!", "Successfully deleted!", "success");
                    window.location.reload();
                }
            });

        });
    </script>

    <?php if(!empty(Request::get('class'))): ?>
        <script>
            $("#class").val("<?php echo e(Request::get('class')); ?>").trigger('change');
        </script>
    <?php endif; ?>

    <?php if(!empty(Request::get('section'))): ?>
        <script>
            $("#section").val("<?php echo e(Request::get('section')); ?>").trigger('change');
        </script>
    <?php endif; ?>

    <?php if(!empty(Request::get('type'))): ?>
        <script>
            $("#type").val("<?php echo e(Request::get('type')); ?>").trigger('change');
        </script>
    <?php endif; ?>

    <!-- end::dataTable -->
<?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/admission/import.blade.php ENDPATH**/ ?>