<?php $__env->startSection('content'); ?>
<div class="container">
    <div class="container-header">
        <h1><?php echo e($title); ?></h1>
        <a href="<?php echo e(route('backend.smm-providers.index')); ?>" class="btn btn-secondary">Back to providers</a>
    </div>

    <div class="card mb-25">
        <div class="card-body">
            <p class="text-muted">Services returned from the provider API. Select a category and price increase, then check services to import.</p>
            <form action="<?php echo e(route('backend.smm-providers.import-services')); ?>" method="post" id="import-services-form">
                <?php echo csrf_field(); ?>
                <input type="hidden" name="api_id" value="<?php echo e($provider->id); ?>">
                <div class="row">
                    <div class="form-group width-50">
                        <label class="form-label">Category<span class="required">*</span></label>
                        <select class="form-control" name="cate_id" required>
                            <option value="">Select category</option>
                            <?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $c): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($c->id); ?>"><?php echo e($c->name); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                    <div class="form-group width-50">
                        <label class="form-label">Price increase %<span class="required">*</span></label>
                        <input type="number" class="form-control" name="price_percentage_increase" value="30" min="0" required>
                    </div>
                </div>
                <div class="row">
                    <div class="form-group width-100">
                        <label class="form-label">Select services to import</label>
                        <div class="table-responsive">
                            <table class="table">
                                <thead>
                                    <tr>
                                        <th><input type="checkbox" id="select-all-services" class="form-control"></th>
                                        <th>#</th>
                                        <th>Service ID</th>
                                        <th>Name</th>
                                        <th>Rate</th>
                                        <th>Min / Max</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php $apiItems = is_array($items) ? $items : []; ?>
                                    <?php $__empty_1 = true; $__currentLoopData = $apiItems; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $idx => $svc): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                    <?php
                                        $sid = $svc['service'] ?? $svc['id'] ?? $idx;
                                        $name = $svc['name'] ?? 'Service ' . $sid;
                                        $rate = $svc['rate'] ?? $svc['price'] ?? 0;
                                        $min = $svc['min'] ?? 0;
                                        $max = $svc['max'] ?? 0;
                                    ?>
                                    <tr>
                                        <td><input type="checkbox" name="ids[]" value="<?php echo e($sid); ?>" class="service-checkbox"></td>
                                        <td><?php echo e($loop->iteration); ?></td>
                                        <td><?php echo e($sid); ?></td>
                                        <td><?php echo e($name); ?></td>
                                        <td><?php echo e($rate); ?></td>
                                        <td><?php echo e($min); ?> / <?php echo e($max); ?></td>
                                    </tr>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                    <tr><td colspan="6" class="text-center">No services returned from API or API could not be reached.</td></tr>
                                    <?php endif; ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <?php if(!empty($apiItems)): ?>
                <button type="submit" class="btn btn-primary">Import selected services</button>
                <?php endif; ?>
            </form>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('script'); ?>
<script>
document.getElementById('select-all-services')?.addEventListener('change', function() {
    document.querySelectorAll('.service-checkbox').forEach(function(cb) {
        cb.checked = this.checked;
    }.bind(this));
});
</script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('backend.layout.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\HP\Desktop\social\socialstack\core\resources\views/backend/smm/providers/services.blade.php ENDPATH**/ ?>