

<?php $__env->startSection('title', 'SMS Templates'); ?>

<?php $__env->startSection('content'); ?>
<div class="admin-page-header d-flex justify-content-between align-items-center flex-wrap gap-2">
    <h1>SMS Templates</h1>
</div>

<div class="row g-2">
    
    <div class="col-12 col-md-4 col-lg-3">
        <div class="admin-card h-100">
            <div class="card-body p-0">
                <nav class="nav flex-column">
                    <?php $__currentLoopData = $templates; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $t): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <a href="<?php echo e(route('admin.sms-templates.show', ['identifier' => $t->identifier])); ?>"
                           class="nav-link py-3 px-4 rounded-0 border-0 border-bottom border-light text-dark text-decoration-none <?php echo e(($template && $template->id === $t->id) ? 'bg-opacity-10' : ''); ?>"
                           style="<?php echo e(($template && $template->id === $t->id) ? 'background-color: rgba(13, 148, 136, 0.12); color: var(--admin-primary); font-weight: 600;' : ''); ?>">
                            <?php echo e($t->name); ?>

                        </a>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </nav>
            </div>
        </div>
    </div>

    
    <div class="col-12 col-md-8 col-lg-9">
        <?php if($template): ?>
            <div class="admin-card">
                <div class="card-body">
                    <div class="d-flex justify-content-between align-items-center  gap-2 mb-4">
                        <h5 class="mb-0" style="color: var(--admin-primary);">
                            SMS Template for <?php echo e($template->name); ?>

                        </h5>
                        <a href="<?php echo e(route('admin.sms-templates.create')); ?>" class="btn text-white" style="background: var(--admin-primary);">
                            <i class="bi bi-plus-lg"></i> Create SMS Template
                        </a>
                    </div>

                    <form action="<?php echo e(route('admin.sms-templates.update', ['identifier' => $template->identifier])); ?>" method="POST">
                        <?php echo csrf_field(); ?>
                        <?php echo method_field('PUT'); ?>

                        <div class="mb-4">
                            <label class="form-label fw-semibold">Active</label>
                            <div class="form-check form-switch">
                                <input class="form-check-input" type="checkbox" name="is_active" value="1"
                                       id="sms_active" <?php echo e(old('is_active', $template->is_active) ? 'checked' : ''); ?>

                                       style="width: 3rem; height: 1.5rem; margin-right:0.5rem;">
                                <label class="form-check-label" for="sms_active">Enable this template</label>
                            </div>
                        </div>

                        <div class="mb-4">
                            <label for="sms_body" class="form-label fw-semibold"><span class="text-danger">*</span> SMS Body</label>
                            <textarea class="form-control" id="sms_body" name="body" rows="4"
                                      placeholder="Use [[placeholder_name]] for dynamic values, e.g. [[customer_name]], [[invoice_link]]"><?php echo e(old('body', $template->body)); ?></textarea>
                            <small class="text-muted">Use double square brackets for placeholders, e.g. [[customer_name]], [[otp]], [[invoice_link]]</small>
                            <?php $__errorArgs = ['body'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <div class="text-danger small mt-1"><?php echo e($message); ?></div>
                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>

                        <div class="mb-4">
                            <label for="sms_template_id" class="form-label fw-semibold"><span class="text-danger">*</span> Template ID</label>
                            <input type="text" class="form-control" id="sms_template_id" name="template_id"
                                   value="<?php echo e(old('template_id', $template->template_id)); ?>"
                                   placeholder="DLT Template ID (e.g. 1707172352407012545)">
                            <small class="text-muted">Your DLT template ID from the SMS provider (required when using DLT)</small>
                            <?php $__errorArgs = ['template_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <div class="text-danger small mt-1"><?php echo e($message); ?></div>
                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>

                        <?php if($template->identifier === 'pos_order_placement'): ?>
                            <hr class="my-4">
                            <h6 class="mb-2">POS Owner Copy</h6>
                            <div class="d-flex align-items-start justify-content-between gap-3 flex-wrap mb-4">
                                <div>
                                    <div class="fw-semibold">Send `pos_order_placement` SMS copy to Site Owner</div>
                                    <small class="text-muted">
                                        Applies only for wholesale customers. Site owner number is taken from General Settings (`site_phone`).
                                    </small>
                                </div>
                                <div class="form-check form-switch mb-0">
                                    <input class="form-check-input" type="checkbox" name="sms_pos_owner_copy_enabled" value="1"
                                           id="sms_pos_owner_copy_enabled" <?php echo e(old('sms_pos_owner_copy_enabled', $smsPosOwnerCopyEnabled ?? false) ? 'checked' : ''); ?>

                                           style="width: 3rem; height: 1.5rem;">
                                    <label class="form-check-label visually-hidden" for="sms_pos_owner_copy_enabled">Enable POS owner SMS copy</label>
                                </div>
                            </div>
                        <?php endif; ?>

                        <div class="pt-2">
                            <button type="submit" class="btn text-white" style="background: var(--admin-primary);">
                                <i class="bi bi-save"></i> Update
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        <?php else: ?>
            <div class="admin-card">
                <div class="card-body text-center py-5">
                    <p class="text-muted mb-4">No SMS templates yet.</p>
                    <a href="<?php echo e(route('admin.sms-templates.create')); ?>" class="btn text-white" style="background: var(--admin-primary);">
                        <i class="bi bi-plus-lg"></i> Create SMS Template
                    </a>
                </div>
            </div>
        <?php endif; ?>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /var/www/html/sudheerkt_uat/resources/views/admin/sms-templates/index.blade.php ENDPATH**/ ?>