<?php $__env->startSection('pageTitle'); ?> <?php echo $__env->make('layouts.includes.title', ['moduleTitle' => __('Import'). __('Teachers')], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?> <?php $__env->stopSection(); ?>

<?php $__env->startSection('pageBreadcrumb'); ?> <?php echo $__env->make('layouts.includes.breadcrumb', ['moduleTitle' => __('Import')." ".__('Teachers')], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?> <?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
<div class="row">
    <div class="col-sm-12">
        <div class="card-box">
            <?php echo $__env->make('layouts.modules.header', [ 'title' => __('Teachers Import')], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
            <div class="p-t-20 p-r-20 pull-right">
                <a target="_blank" href="<?php echo e(asset('assets/sample_csv/staff_sample.csv')); ?>">Click here</a> to download the sample file.
            </div>
            <div class="card-body row">
                <div class="col-lg-12 p-t-20 p-l-20">
                    <div class="alert alert-success upl-success" style="display:none;" role="alert">
                    </div>
                    <div class="alert alert-danger upl-fail" style="display:none;" role="alert">
                    </div>
                </div>
                <div class="col-lg-12 p-t-20">
                    <label class="control-label col-md-3">Upload Import File
                    </label>
                    <div class="col-md-12">
                        <div id="id_dropzone" class="dropzone dz-clickable"><div class="dz-default dz-message"><span>Drop files here to upload</span></div></div>
                    </div>
                </div>
            </div>
        </div>

        <div class="card-box">
            <div class="card-head">
                <header><?php echo e(__('locale.preview')); ?></header>
            </div>
            <div class="card-body row">
                <div class="col-lg-12 p-t-20 p-l-20">
                    <button class="__save_preview_data btn btn-circle btn-primary m-b-10 hide"> <?php echo e(__('locale.import')); ?></button>
                </div>
                <div class="col-lg-12 p-t-20 p-l-20" id="finalized_data_preview">

                </div>
            </div>
        </div>

    </div>
</div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('scripts'); ?>
<link href="<?php echo e(asset('assets/plugins/dropzone/dropzone.css')); ?>" rel="stylesheet"
      type="text/css" />
<script src="../assets/plugins/dropzone/dropzone.js"></script>
<script>
Dropzone.autoDiscover = false;
$(document).ready(function () {
    $("#id_dropzone").dropzone({
        maxFiles: 1,
        maxFilesize: 10, // MB
        acceptedFiles: ".csv, text/csv, application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/csv, text/x-csv, application/x-csv, text/comma-separated-values, text/x-comma-separated-values",
        url: "/import-staffs",
        sending: function (file, xhr, formData) {
            formData.append("_token", "<?php echo e(csrf_token()); ?>");
        },
        success: function (file, response) {
            var data = $.parseJSON(response);
            if (data.success == true) {
                console.log("if");
                $/*(".upl-success").html(data.message);
                $(".upl-fail").fadeOut();
                $(".upl-success").fadeIn(100);*/

                $("#finalized_data_preview").html(data.data);
                $(".__save_preview_data").removeClass('hide');
            } else {
                console.log("else");
                $(".upl-success").fadeOut();
                $(".upl-fail").html(data.message);
                $(".upl-fail").fadeIn(100);
            }
            this.removeAllFiles();
        }
    });
})

$(document).on('click', '.__save_preview_data', function () {
    $.ajax({
        url: '<?php echo e(route("import-teachers.save")); ?>',
        headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
        type: 'POST',
        success: function (data) {
            console.log(data['message'], data.message);
            $(".upl-success").html(data.message);
            $(".upl-fail").fadeOut();
            $(".upl-success").fadeIn(100);

            $("#finalized_data_preview").html('');
            $(".__save_preview_data").addClass('hide');
        },
        error: function () {
            alert("Something Went Wrong!");
        }
    });
});
</script>
<?php $__env->stopSection(); ?>


<?php echo $__env->make('layouts.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/html/sms/app/Modules/Staff/Resources/Views/import.blade.php ENDPATH**/ ?>