<?php $__env->startSection('content'); ?>
    <div id="page1" class="container">

        <?php echo $__env->make('layouts.commons.errors', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
        <?php echo $__env->make('layouts.commons.success', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
        <h2 class="pb-2 mb-5">Import Cartographie</h2>

        <form method="POST" action="<?php echo e(route('import-cartographie.index')); ?>" enctype="multipart/form-data">
            <?php echo csrf_field(); ?>
            <div class="form-group row">
                <div class="col-sm-4">

                    <label>Sélectionner un client :</label>
                    <select id="customer-select" name="customer" class="form-control">
                        <option value="">Rechercher un client</option>
                        <?php if(is_array($customers ?? '') && count($customers ?? '') > 0): ?>
                            <?php $__currentLoopData = $customers ?? ''; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $customer): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option
                                        value="<?php echo e($customer['id']); ?>"><?php echo e($customer['nom']); ?>

                                    </option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        <?php endif; ?>
                    </select>

                <div class="input-group d-flex flex-column mt-5">
                    <label>Choisissez un fichier client :</label>
                        <input type="file"
                               class="btn btn-primary p-3"
                               id="cartography"
                               value="<?php echo e(old('cartography')); ?>"
                               name="cartography"
                               aria-describedby="nomenclature"
                               accept=".csv"
                        >
                        <button
                            class="btn btn-primary p-3 mt-5" id="submit-button-csv" type="submit">
                            Importer
                        </button>
                </div>
                </div>
            </div>
        </form>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('unique-js'); ?>
    <script>
        document.addEventListener('DOMContentLoaded', function () {

            const elements = [document.getElementById("customer-select"), document.getElementById("cartography")];

            elements.forEach(elem => {
                elem.addEventListener("change", () => {
                    const allFilled = elements.every(elem => elem.value.trim() !== '');
                    document.getElementById("submit-button-csv").disabled = !allFilled;
                });
            });

            document.getElementById('customer-select').dispatchEvent(new Event('change'));
            document.getElementById('cartography').dispatchEvent(new Event('change'));
        });

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

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/html/resources/views/parametres/import-cartographie/index.blade.php ENDPATH**/ ?>