<?php $__env->startSection('title', 'Imports – Gap Finder Analytics'); ?>

<?php $__env->startSection('content'); ?>
    <h1>Imports</h1>
    <p class="muted">Upload visit (field activity) or location (ground team) sheets.</p>

    <div class="card mt-2">
        <h2>1. Field activity / visits</h2>
        <form action="<?php echo e(route('imports.upload')); ?>" method="POST" enctype="multipart/form-data">
            <?php echo csrf_field(); ?>
            <div class="form-row">
                <label for="file">Excel (MR, date, doctor, clinic, lat/lng):</label>
                <input type="file" name="file" id="file" accept=".xlsx,.xls,.csv" required>
                <button type="submit" class="btn btn-primary">Import visits</button>
            </div>
        </form>
    </div>

    <div class="card">
        <h2>2. Ground team / location sheet (doctor_db.xlsx format)</h2>
        <p class="muted">Expected columns: EmployeeReferenceId, EmployeeName, DesignationName, BaseTownName, TeamName, DoctorCode, DoctorName, DoctorSpecialty, pLat, pLng. Territory is derived from TeamName when not present.</p>
        <form action="<?php echo e(route('imports.location')); ?>" method="POST" enctype="multipart/form-data">
            <?php echo csrf_field(); ?>
            <div class="form-row">
                <label for="location_file">Excel file:</label>
                <input type="file" name="file" id="location_file" accept=".xlsx,.xls,.csv" required>
                <button type="submit" class="btn btn-primary">Import location sheet</button>
            </div>
        </form>
    </div>

    <h2 class="mt-2">Visit import batches</h2>
    <div class="card">
        <div class="table-wrap"><table>
            <thead>
                <tr>
                    <th>File</th>
                    <th>Status</th>
                    <th>Rows</th>
                    <th>Date</th>
                    <th></th>
                </tr>
            </thead>
            <tbody>
                <?php $__empty_1 = true; $__currentLoopData = $batches; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $batch): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr>
                        <td><?php echo e($batch->file_name); ?></td>
                        <td><?php echo e($batch->status); ?></td>
                        <td><?php echo e($batch->staging_rows_count ?? 0); ?></td>
                        <td><?php echo e($batch->created_at->format('M j, Y H:i')); ?></td>
                        <td><a href="<?php echo e(route('imports.show', $batch)); ?>">View</a></td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr><td colspan="5" class="muted">No visit imports yet.</td></tr>
                <?php endif; ?>
            </tbody>
        </table></div>
        <div class="mt-1"><?php echo e($batches->links()); ?></div>
    </div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\gap-finder-analytics\resources\views/imports/index.blade.php ENDPATH**/ ?>