<?php $__env->startSection('title', 'Import Masterlist'); ?>
<?php $__env->startSection('content'); ?>
<?php $result = session('import_result'); ?>

<div class="row">
    <div class="col-lg-7 mb-4">
        <div class="card">
            <div class="mi-brand-strip rounded-top"></div>
            <div class="card-header pb-0">
                <h6 class="mb-0"><i class="bi bi-file-earmark-spreadsheet me-1"></i>Import Staff from Excel</h6>
                <p class="text-sm text-muted mb-0">Upload the masterlist to create or update staff records.</p>
            </div>
            <form action="<?php echo e(route('import.store')); ?>" method="POST" enctype="multipart/form-data">
                <?php echo csrf_field(); ?>
                <div class="card-body">
                    <div class="mb-3">
                        <label class="form-label text-xs text-uppercase">Spreadsheet file *</label>
                        <input type="file" name="file" accept=".xlsx,.xls,.csv" class="form-control" required>
                        <span class="text-xs text-muted">.xlsx, .xls or .csv — max 20&nbsp;MB</span>
                    </div>
                    <div class="mb-3" style="max-width:200px">
                        <label class="form-label text-xs text-uppercase">Sheet number</label>
                        <input type="number" name="sheet" value="0" min="0" class="form-control">
                        <span class="text-xs text-muted">0 = first sheet</span>
                    </div>
                    <div class="alert alert-secondary text-white text-sm mb-0">
                        <strong>Matching rule:</strong> rows are matched by passport number (or running no.
                        when blank). Existing staff are <strong>updated</strong>, new ones are <strong>created</strong> —
                        so re-importing the same file is safe.
                    </div>
                </div>
                <div class="card-footer text-end">
                    <button class="btn btn-primary btn-sm"><i class="bi bi-upload me-1"></i>Import</button>
                </div>
            </form>
        </div>
    </div>

    <div class="col-lg-5 mb-4">
        <?php if($result): ?>
            <div class="card mb-3">
                <div class="card-header pb-0"><h6 class="mb-0">Last Import Result</h6></div>
                <div class="card-body">
                    <div class="row text-center">
                        <div class="col-4">
                            <h4 class="mb-0 text-success"><?php echo e($result['created']); ?></h4>
                            <span class="text-xs text-uppercase text-muted">Created</span>
                        </div>
                        <div class="col-4">
                            <h4 class="mb-0 text-primary"><?php echo e($result['updated']); ?></h4>
                            <span class="text-xs text-uppercase text-muted">Updated</span>
                        </div>
                        <div class="col-4">
                            <h4 class="mb-0 text-muted"><?php echo e($result['skipped']); ?></h4>
                            <span class="text-xs text-uppercase text-muted">Skipped</span>
                        </div>
                    </div>
                    <hr class="horizontal dark">
                    <div class="text-sm d-flex justify-content-between"><span class="text-muted">Sites</span><span><?php echo e($result['sites']); ?></span></div>
                    <div class="text-sm d-flex justify-content-between"><span class="text-muted">Nationalities</span><span><?php echo e($result['nationalities']); ?></span></div>
                    <div class="text-sm d-flex justify-content-between"><span class="text-muted">Banks</span><span><?php echo e($result['banks']); ?></span></div>

                    <?php if(!empty($result['issues'])): ?>
                        <hr class="horizontal dark">
                        <h6 class="text-xs text-uppercase text-muted"><?php echo e(count($result['issues'])); ?> rows flagged</h6>
                        <ul class="text-xs ps-3 mb-0" style="max-height:150px;overflow:auto">
                            <?php $__currentLoopData = array_slice($result['issues'], 0, 30); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><li><?php echo e($i); ?></li><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </ul>
                    <?php endif; ?>

                    <a href="<?php echo e(route('setup.index')); ?>" class="btn btn-sm btn-primary w-100 mt-3 mb-0">
                        <i class="bi bi-list-check me-1"></i>Complete passport / permit / photos
                    </a>
                </div>
            </div>
        <?php endif; ?>

        <div class="card">
            <div class="card-header pb-0"><h6 class="mb-0">Expected Columns</h6>
                <p class="text-xs text-muted mb-0">In this order, with a header row first.</p></div>
            <div class="card-body pt-2">
                <ol class="text-xs ps-3 mb-0" start="1">
                    <?php $__currentLoopData = $columns; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><li><?php echo e($label); ?></li><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </ol>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /Users/kalaiarasen/projects/myindependent-worker-management/resources/views/import/index.blade.php ENDPATH**/ ?>