
<?php $__env->startSection('title', 'Service Book — ' . $ticket->ticket_code); ?>

<?php $__env->startSection('content'); ?>
<?php
$statusConfig = [
    'Pending'   => ['bg-yellow-100 text-yellow-800 border-yellow-200',  'Menunggu'],
    'Checking'  => ['bg-sky-100 text-sky-800 border-sky-200',           'Sedang Diperiksa'],
    'Repairing' => ['bg-blue-100 text-blue-800 border-blue-200',        'Sedang Dalam Perbaikan'],
    'Ready'     => ['bg-green-100 text-green-800 border-green-200',     'Siap Diambil'],
    'Picked Up' => ['bg-gray-100 text-gray-700 border-gray-200',        'Sudah Diambil'],
    'Cancelled' => ['bg-red-100 text-red-700 border-red-200',           'Dibatalkan'],
];
$sc = $statusConfig[$ticket->status] ?? ['bg-gray-100 text-gray-700 border-gray-200', $ticket->status];

$isFinal  = in_array($ticket->status, ['Picked Up', 'Cancelled']);
$canCheck  = $ticket->status === 'Pending';
$canRepair = $ticket->status === 'Checking' && $ticket->repair_approved_at;
$canReady  = $ticket->status === 'Repairing' && $ticket->final_check_passed_at;
$selectedFinalCheckItems = array_values(old('final_check_items', $ticket->final_check_items ?? []));
?>


<div class="mt-4 rounded-2xl bg-white border border-gray-200 shadow-sm overflow-hidden">

    
    <div class="h-1.5 <?php if($ticket->status === 'Pending'): ?> bg-yellow-400
                       <?php elseif($ticket->status === 'Checking'): ?> bg-sky-500
                       <?php elseif($ticket->status === 'Repairing'): ?> bg-blue-500
                       <?php elseif($ticket->status === 'Ready'): ?> bg-green-500
                       <?php elseif($ticket->status === 'Picked Up'): ?> bg-gray-400
                       <?php else: ?> bg-red-400 <?php endif; ?>"></div>

    <div class="p-4">
        <div class="flex items-start justify-between gap-3 flex-wrap">
            <div>
                <p class="text-xs text-gray-400 font-medium tracking-wide uppercase">Nomor Tiket</p>
                <h2 class="text-lg font-bold text-gray-900 tracking-tight mt-0.5"><?php echo e($ticket->ticket_code); ?></h2>
                <p class="text-[11px] text-gray-400 mt-0.5"><?php echo e($ticket->created_at->format('d M Y, H:i')); ?></p>
            </div>
            <span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-semibold border <?php echo e($sc[0]); ?>">
                <?php echo e($sc[1]); ?>

            </span>
        </div>

        <div class="mt-4 grid grid-cols-2 gap-3 text-sm">
            
            <div class="bg-gray-50 rounded-xl p-3">
                <p class="text-xs text-gray-400 font-medium mb-1">Pelanggan</p>
                <p class="font-semibold text-gray-800 leading-tight"><?php echo e($ticket->customer->name); ?></p>
            </div>
            
            <div class="bg-gray-50 rounded-xl p-3">
                <p class="text-xs text-gray-400 font-medium mb-1">Perangkat</p>
                <p class="font-semibold text-gray-800 leading-tight"><?php echo e($ticket->brand); ?> <?php echo e($ticket->model); ?></p>
                <p class="text-xs text-gray-500 mt-0.5"><?php echo e($ticket->device_type); ?></p>
            </div>
        </div>

        
        <div class="mt-3 bg-amber-50 border border-amber-100 rounded-xl p-3">
            <p class="text-xs text-amber-700 font-medium mb-1">Keluhan</p>
            <p class="text-sm text-gray-700"><?php echo e($ticket->problem_desc); ?></p>
        </div>

        <?php if($ticket->serial_number): ?>
        <div class="mt-2 text-xs text-gray-400">
            S/N: <span class="font-mono text-gray-600"><?php echo e($ticket->serial_number); ?></span>
        </div>
        <?php endif; ?>
    </div>
</div>

<?php if(! $isFinal): ?>
<div class="mt-4 rounded-2xl bg-white border border-gray-200 shadow-sm p-4">
    <h3 class="text-sm font-semibold text-gray-700 mb-3">1. Diagnosa Awal & Rekomendasi</h3>
    <form method="POST" action="<?php echo e(route('technician.diagnosis.store', $ticket)); ?>" class="space-y-3">
        <?php echo csrf_field(); ?>

        <div>
            <label class="block text-xs font-semibold uppercase tracking-wide text-gray-500 mb-1">Hasil Diagnosa Awal</label>
            <textarea name="initial_diagnosis" rows="3" required
                      class="w-full rounded-xl border border-gray-300 px-4 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-sky-500 focus:border-transparent"><?php echo e(old('initial_diagnosis', $ticket->initial_diagnosis)); ?></textarea>
        </div>

        <div>
            <label class="block text-xs font-semibold uppercase tracking-wide text-gray-500 mb-1">Temuan Pengecekan</label>
            <textarea name="diagnosis_findings" rows="2"
                      class="w-full rounded-xl border border-gray-300 px-4 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-sky-500 focus:border-transparent"><?php echo e(old('diagnosis_findings', $ticket->diagnosis_findings)); ?></textarea>
        </div>

        <div>
            <label class="block text-xs font-semibold uppercase tracking-wide text-gray-500 mb-1">Penyebab Kemungkinan</label>
            <textarea name="probable_cause" rows="2" required
                      class="w-full rounded-xl border border-gray-300 px-4 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-sky-500 focus:border-transparent"><?php echo e(old('probable_cause', $ticket->probable_cause)); ?></textarea>
        </div>

        <div>
            <label class="block text-xs font-semibold uppercase tracking-wide text-gray-500 mb-1">Rekomendasi Perbaikan</label>
            <textarea name="recommended_action" rows="2" required
                      class="w-full rounded-xl border border-gray-300 px-4 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-sky-500 focus:border-transparent"><?php echo e(old('recommended_action', $ticket->recommended_action)); ?></textarea>
        </div>

        <div class="grid grid-cols-2 gap-2">
            <div>
                <label class="block text-xs font-semibold uppercase tracking-wide text-gray-500 mb-1">Estimasi Biaya</label>
                <input type="number" min="0" step="0.01" name="estimated_cost" value="<?php echo e(old('estimated_cost', $ticket->estimated_cost)); ?>"
                       class="w-full rounded-xl border border-gray-300 px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-sky-500 focus:border-transparent">
            </div>
            <div>
                <label class="block text-xs font-semibold uppercase tracking-wide text-gray-500 mb-1">Estimasi Durasi (menit)</label>
                <input type="number" min="1" max="10080" name="estimated_minutes" value="<?php echo e(old('estimated_minutes', $ticket->estimated_minutes)); ?>"
                       class="w-full rounded-xl border border-gray-300 px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-sky-500 focus:border-transparent">
            </div>
        </div>

        <?php if($ticket->diagnosis_completed_at): ?>
        <p class="text-xs text-emerald-700">Diagnosa terakhir tersimpan: <?php echo e($ticket->diagnosis_completed_at->format('d M Y H:i')); ?></p>
        <?php endif; ?>

        <button type="submit"
                class="w-full rounded-xl bg-sky-600 text-white text-sm font-semibold px-4 py-3 hover:bg-sky-700 transition">
            Simpan Diagnosa & Rekomendasi
        </button>
    </form>
</div>

<div class="mt-4 rounded-2xl bg-white border border-gray-200 shadow-sm p-4">
    <h3 class="text-sm font-semibold text-gray-700 mb-3">2. Eksekusi Perbaikan</h3>
    <form method="POST" action="<?php echo e(route('technician.repair.store', $ticket)); ?>" class="space-y-3">
        <?php echo csrf_field(); ?>
        <div>
            <label class="block text-xs font-semibold uppercase tracking-wide text-gray-500 mb-1">Ringkasan Tindakan Perbaikan</label>
            <textarea name="repair_summary" rows="3" required
                      class="w-full rounded-xl border border-gray-300 px-4 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"><?php echo e(old('repair_summary', $ticket->repair_summary)); ?></textarea>
        </div>
        <div>
            <label class="block text-xs font-semibold uppercase tracking-wide text-gray-500 mb-1">Part/Material yang Digunakan</label>
            <textarea name="parts_used" rows="2"
                      class="w-full rounded-xl border border-gray-300 px-4 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"><?php echo e(old('parts_used', $ticket->parts_used)); ?></textarea>
        </div>
        <button type="submit"
                class="w-full rounded-xl bg-blue-600 text-white text-sm font-semibold px-4 py-3 hover:bg-blue-700 transition">
            Simpan Eksekusi Perbaikan
        </button>
    </form>
</div>

<div class="mt-4 rounded-2xl bg-white border border-gray-200 shadow-sm p-4">
    <h3 class="text-sm font-semibold text-gray-700 mb-3">3. Final Quality Check</h3>
    <form method="POST" action="<?php echo e(route('technician.final-check.store', $ticket)); ?>" enctype="multipart/form-data" class="space-y-3"
          x-data="finalQcForm(<?php echo \Illuminate\Support\Js::from($selectedFinalCheckItems)->toHtml() ?>, <?php echo \Illuminate\Support\Js::from($finalCheckRequiredItems)->toHtml() ?>, <?php echo e($finalCheckMinimumPass); ?>)"
          @submit="if (!canSubmit) { $event.preventDefault(); return; } submitting = true;">
        <?php echo csrf_field(); ?>
        <div>
            <label class="block text-xs font-semibold uppercase tracking-wide text-gray-500 mb-1">Checklist Otomatis <?php echo e($ticket->device_type); ?></label>
            <div class="rounded-xl border border-gray-200 p-3 bg-gray-50 space-y-1.5">
                <?php $__currentLoopData = $finalCheckTemplate; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <label class="flex items-start gap-2 text-sm text-gray-700">
                    <input type="checkbox" name="final_check_items[]" value="<?php echo e($item); ?>"
                           <?php if(in_array($item, $selectedFinalCheckItems, true)): echo 'checked'; endif; ?>
                           x-model="selectedItems"
                           class="mt-0.5 rounded border-gray-300 text-emerald-600 focus:ring-emerald-500">
                    <span>
                        <?php echo e($item); ?>

                        <?php if(in_array($item, $finalCheckRequiredItems, true)): ?>
                        <span class="ml-1 inline-flex items-center rounded-full bg-amber-100 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-amber-700">Inti</span>
                        <?php endif; ?>
                    </span>
                </label>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
            <p class="text-[11px] mt-1"
               :class="canSubmit ? 'text-emerald-700' : 'text-amber-700'"
               x-text="`Lulus tercentang ${selectedItems.length} item.`"></p>
            <p class="text-[11px] text-gray-500 mt-1">Template ini otomatis mengikuti jenis barang dari data pendaftaran service. Wajib centang semua item bertanda Inti dan minimal <?php echo e($finalCheckMinimumPass); ?> item lulus.</p>
            <?php $__errorArgs = ['final_check_items'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
            <p class="mt-1 text-xs text-red-600"><?php echo e($message); ?></p>
            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
        </div>

        <div>
            <label class="block text-xs font-semibold uppercase tracking-wide text-gray-500 mb-1">Checklist/Uji Akhir</label>
            <textarea name="final_check_notes" rows="3" required
                      class="w-full rounded-xl border border-gray-300 px-4 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:border-transparent"><?php echo e(old('final_check_notes', $ticket->final_check_notes)); ?></textarea>
        </div>
        <div>
            <label class="block text-xs font-semibold uppercase tracking-wide text-gray-500 mb-1">Foto Kondisi Akhir (opsional)</label>
            <input type="file" name="final_check_photo" accept="image/*" capture="environment"
                   class="w-full rounded-xl border border-gray-300 px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:border-transparent">
        </div>

        <?php if($ticket->final_check_photo_path): ?>
        <a href="<?php echo e(asset('storage/' . $ticket->final_check_photo_path)); ?>" target="_blank" class="inline-flex text-xs text-emerald-700 underline">Lihat foto final check terakhir</a>
        <?php endif; ?>

        <?php if($ticket->final_check_passed_at): ?>
        <p class="text-xs text-emerald-700">Final QC terakhir lulus: <?php echo e($ticket->final_check_passed_at->format('d M Y H:i')); ?></p>
        <?php endif; ?>

        <button type="submit"
                :disabled="!canSubmit || submitting"
                :class="(!canSubmit || submitting) ? 'bg-gray-200 text-gray-400 cursor-not-allowed' : 'bg-emerald-600 text-white hover:bg-emerald-700'"
                class="w-full rounded-xl text-sm font-semibold px-4 py-3 transition">
            Simpan Final QC (PASS)
        </button>
    </form>
</div>
<?php endif; ?>


<?php if(! $isFinal): ?>
<div class="mt-4 rounded-2xl bg-white border border-gray-200 shadow-sm p-4">
    <h3 class="text-sm font-semibold text-gray-700 mb-3">Ubah Status</h3>

    <?php if($ticket->repair_approved_at): ?>
    <div class="mb-3 rounded-xl bg-emerald-50 border border-emerald-200 px-3 py-2 text-xs text-emerald-700">
        Perbaikan sudah disetujui admin pada <?php echo e($ticket->repair_approved_at->format('d M Y H:i')); ?>.
    </div>
    <?php elseif($ticket->status === 'Checking'): ?>
    <div class="mb-3 rounded-xl bg-amber-50 border border-amber-200 px-3 py-2 text-xs text-amber-700">
        Menunggu persetujuan admin sebelum status bisa diubah ke "Sedang Dalam Perbaikan".
    </div>
    <?php endif; ?>

    <?php if($ticket->status === 'Checking' && ! $ticket->diagnosis_completed_at): ?>
    <div class="mb-3 rounded-xl bg-sky-50 border border-sky-200 px-3 py-2 text-xs text-sky-700">
        Lengkapi Diagnosa Awal terlebih dahulu agar bisa naik ke status "Sedang Dalam Perbaikan".
    </div>
    <?php endif; ?>

    <?php if($ticket->status === 'Repairing' && ! $ticket->final_check_passed_at): ?>
    <div class="mb-3 rounded-xl bg-emerald-50 border border-emerald-200 px-3 py-2 text-xs text-emerald-700">
        Status "Ready" akan aktif setelah Final Quality Check dinyatakan lulus.
    </div>
    <?php endif; ?>

    <div class="flex flex-col gap-2">

        <?php if($canCheck): ?>
        <form method="POST" action="<?php echo e(route('technician.status', $ticket)); ?>">
            <?php echo csrf_field(); ?> <?php echo method_field('PATCH'); ?>
            <input type="hidden" name="status" value="Checking">
            <button type="submit"
                    class="w-full flex items-center justify-center gap-2 bg-sky-600 text-white
                           font-semibold text-sm rounded-xl px-4 py-3 hover:bg-sky-700
                           active:bg-sky-800 transition shadow-sm">
                <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                          d="M9 12h6m-3-3v6m10-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
                </svg>
                Mulai Pengecekan Unit
            </button>
        </form>
        <?php endif; ?>

        <?php if($ticket->status === 'Checking' && ! $ticket->repair_approved_at): ?>
        <button type="button"
                disabled
                class="w-full flex items-center justify-center gap-2 bg-gray-100 text-gray-400
                       font-semibold text-sm rounded-xl px-4 py-3 cursor-not-allowed">
            Menunggu Persetujuan Admin untuk Perbaikan
        </button>
        <?php endif; ?>

        <?php if($canRepair && $ticket->diagnosis_completed_at): ?>
        <form method="POST" action="<?php echo e(route('technician.status', $ticket)); ?>">
            <?php echo csrf_field(); ?> <?php echo method_field('PATCH'); ?>
            <input type="hidden" name="status" value="Repairing">
            <button type="submit"
                    class="w-full flex items-center justify-center gap-2 bg-blue-600 text-white
                           font-semibold text-sm rounded-xl px-4 py-3 hover:bg-blue-700
                           active:bg-blue-800 transition shadow-sm">
                <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                          d="M14.7 6.3a1 1 0 000 1.4l1.6 1.6a1 1 0 001.4 0l3.77-3.77a6 6 0 01-7.94 7.94
                             l-6.91 6.91a2.12 2.12 0 01-3-3l6.91-6.91a6 6 0 017.94-7.94l-3.76 3.76z"/>
                </svg>
                Ubah ke Sedang Dalam Perbaikan
            </button>
        </form>
        <?php endif; ?>

        <?php if($canRepair && ! $ticket->diagnosis_completed_at): ?>
        <button type="button"
            disabled
            class="w-full flex items-center justify-center gap-2 bg-gray-100 text-gray-400
                   font-semibold text-sm rounded-xl px-4 py-3 cursor-not-allowed">
            Lengkapi Diagnosa untuk Masuk Perbaikan
        </button>
        <?php endif; ?>

        <?php if($canReady): ?>
        <form method="POST" action="<?php echo e(route('technician.status', $ticket)); ?>">
            <?php echo csrf_field(); ?> <?php echo method_field('PATCH'); ?>
            <input type="hidden" name="status" value="Ready">
            <button type="submit"
                    class="w-full flex items-center justify-center gap-2 bg-green-600 text-white
                           font-semibold text-sm rounded-xl px-4 py-3 hover:bg-green-700
                           active:bg-green-800 transition shadow-sm">
                <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                          d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
                </svg>
                Tandai Siap Diambil
            </button>
        </form>
        <?php endif; ?>

        <?php if($ticket->status === 'Repairing' && ! $ticket->final_check_passed_at): ?>
        <button type="button"
            disabled
            class="w-full flex items-center justify-center gap-2 bg-gray-100 text-gray-400
                   font-semibold text-sm rounded-xl px-4 py-3 cursor-not-allowed">
            Final QC Belum Lulus
        </button>
        <?php endif; ?>

    </div>
</div>
<?php endif; ?>


<?php if(! $isFinal): ?>
<div class="mt-4 rounded-2xl bg-white border border-gray-200 shadow-sm p-4"
     x-data="{ note: '', submitting: false }">
    <h3 class="text-sm font-semibold text-gray-700 mb-3">Tambah Catatan Servis</h3>

    <form method="POST" action="<?php echo e(route('technician.log', $ticket)); ?>"
          @submit="submitting = true">
        <?php echo csrf_field(); ?>
        <div class="mb-3">
            <textarea name="note" rows="3" required minlength="3" maxlength="1000"
                      x-model="note"
                      placeholder="Contoh: Ganti Pasta Thermal, RAM dibersihkan, Layar retak diganti…"
                      class="w-full rounded-xl border border-gray-300 px-4 py-3 text-sm
                             focus:outline-none focus:ring-2 focus:ring-emerald-500
                             focus:border-transparent placeholder-gray-400 resize-none"></textarea>
            <div class="flex justify-between mt-1 text-xs text-gray-400">
                <span x-text="note.length < 3 ? 'Min. 3 karakter' : ''" class="text-red-400"></span>
                <span x-text="note.length + ' / 1000'"></span>
            </div>
        </div>

        <button type="submit"
                :disabled="note.trim().length < 3 || submitting"
                :class="note.trim().length < 3 || submitting
                    ? 'bg-gray-200 text-gray-400 cursor-not-allowed'
                    : 'bg-emerald-600 text-white hover:bg-emerald-700 active:bg-emerald-800'"
                class="w-full flex items-center justify-center gap-2 font-semibold text-sm
                       rounded-xl px-4 py-3 transition">
            <template x-if="!submitting">
                <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                          d="M12 4v16m8-8H4"/>
                </svg>
            </template>
            <template x-if="submitting">
                <svg class="w-4 h-4 animate-spin" fill="none" viewBox="0 0 24 24">
                    <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"/>
                    <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"/>
                </svg>
            </template>
            <span x-text="submitting ? 'Menyimpan…' : 'Simpan Catatan'"></span>
        </button>
    </form>
</div>
<?php endif; ?>


<div class="mt-4 rounded-2xl bg-white border border-gray-200 shadow-sm p-4 mb-6">
    <h3 class="text-sm font-semibold text-gray-700 mb-4">
        Riwayat Servis
        <?php if($ticket->logs->count()): ?>
            <span class="ml-1.5 bg-gray-100 text-gray-600 text-xs font-medium px-2 py-0.5 rounded-full">
                <?php echo e($ticket->logs->count()); ?>

            </span>
        <?php endif; ?>
    </h3>

    <?php if($ticket->logs->isEmpty()): ?>
        <div class="text-center py-8 text-gray-400">
            <svg class="w-10 h-10 mx-auto mb-2 opacity-40" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"
                      d="M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2
                         M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"/>
            </svg>
            <p class="text-sm">Belum ada catatan servis.</p>
        </div>
    <?php else: ?>
        <ol class="relative border-l-2 border-gray-100 ml-2 space-y-5">
            <?php $__currentLoopData = $ticket->logs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $log): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <li class="ml-5">
                <span class="absolute -left-[9px] flex items-center justify-center w-4 h-4
                             bg-emerald-500 rounded-full ring-4 ring-white">
                </span>
                <div class="bg-gray-50 rounded-xl p-3">
                    <p class="text-sm text-gray-800 leading-relaxed"><?php echo e($log->note); ?></p>
                    <p class="text-xs text-gray-400 mt-1.5">
                        <?php echo e($log->created_at->format('d M Y, H:i')); ?>

                    </p>
                    <p class="text-[11px] text-gray-500 mt-0.5">
                        Petugas: <?php echo e($log->user?->name ?? 'Sistem'); ?>

                        <?php if($log->user?->role): ?>
                        (<?php echo e(ucfirst($log->user->role)); ?>)
                        <?php endif; ?>
                    </p>
                </div>
            </li>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </ol>
    <?php endif; ?>
</div>


<div class="pb-4">
    <a href="<?php echo e(route('technician.scanner')); ?>"
       class="flex items-center justify-center gap-2 text-sm font-medium text-emerald-700
              border border-emerald-200 bg-emerald-50 rounded-xl px-4 py-3 hover:bg-emerald-100 transition">
        <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                  d="M12 4v1m6 11h2m-6 0h-2v4m0-11v3m0 0h.01M12 12h4.01M16 20h4M4 12h4m12 0h.01
                     M5 8h2a1 1 0 001-1V5a1 1 0 00-1-1H5a1 1 0 00-1 1v2a1 1 0 001 1zm12 0h2a1 1 0 001-1V5
                     a1 1 0 00-1-1h-2a1 1 0 00-1 1v2a1 1 0 001 1zM5 20h2a1 1 0 001-1v-2a1 1 0 00-1-1H5
                     a1 1 0 00-1 1v2a1 1 0 001 1z"/>
        </svg>
        Scan Tiket Lain
    </a>
</div>

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

<?php $__env->startPush('scripts'); ?>
<script>
function finalQcForm(initialSelected, requiredItems, minimumPass) {
    return {
        selectedItems: Array.from(new Set(initialSelected || [])),
        requiredItems: requiredItems || [],
        minimumPass: Number(minimumPass || 1),
        submitting: false,

        get hasMinimum() {
            return this.selectedItems.length >= this.minimumPass;
        },

        get hasRequired() {
            return this.requiredItems.every((item) => this.selectedItems.includes(item));
        },

        get canSubmit() {
            return this.hasMinimum && this.hasRequired;
        },
    };
}
</script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layouts.technician', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\Service-sistem\resources\views/technician/servicebook.blade.php ENDPATH**/ ?>