<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('app-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(App\View\Components\AppLayout::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
     <?php $__env->slot('header', null, []); ?> 
        <h2 class="text-xl font-semibold text-slate-800">Create Order for <?php echo e($patient->full_name); ?></h2>
     <?php $__env->endSlot(); ?>

    <div class="py-6">
        <div class="mx-auto max-w-5xl sm:px-6 lg:px-8">
            <div class="rounded-xl border border-slate-200 bg-white p-5 shadow-sm">
                <form method="POST" action="<?php echo e(route('frontdesk.patients.orders.store', $patient)); ?>" class="space-y-4" x-data="{ rows: [{ id: '', qty: 1 }] }">
                    <?php echo csrf_field(); ?>

                    <div class="grid gap-4 md:grid-cols-3">
                        <div>
                            <label class="block text-sm font-medium text-slate-700">Patient</label>
                            <input type="text" value="<?php echo e($patient->full_name); ?>" disabled class="mt-1 w-full rounded-lg border-slate-300 bg-slate-100">
                        </div>
                        <div>
                            <label class="block text-sm font-medium text-slate-700">Lab</label>
                            <input type="text" value="<?php echo e($lab->name); ?> <?php echo e($lab->branch_name); ?>" disabled class="mt-1 w-full rounded-lg border-slate-300 bg-slate-100">
                        </div>
                        <div>
                            <label class="block text-sm font-medium text-slate-700">Discount</label>
                            <input type="number" step="0.01" min="0" name="discount" value="<?php echo e(old('discount', 0)); ?>" class="mt-1 w-full rounded-lg border-slate-300">
                            <?php $__errorArgs = ['discount'];
$__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>

                    <div class="rounded-lg border border-slate-200">
                        <div class="border-b border-slate-200 px-4 py-3 flex items-center justify-between">
                            <h3 class="font-semibold text-slate-800">Select tests</h3>
                            <button type="button" class="rounded-lg border border-slate-300 px-3 py-1 text-xs font-semibold" @click="rows.push({ id: '', qty: 1 })">Add row</button>
                        </div>

                        <div class="p-4 space-y-3">
                            <template x-for="(row, index) in rows" :key="index">
                                <div class="grid gap-3 md:grid-cols-12">
                                    <div class="md:col-span-8">
                                        <select :name="'tests['+index+'][test_id]'" x-model="row.id" class="w-full rounded-lg border-slate-300" required>
                                            <option value="">Select a test</option>
                                            <?php $__currentLoopData = $tests; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $test): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option value="<?php echo e($test->id); ?>"><?php echo e($test->code); ?> - <?php echo e($test->name); ?> (<?php echo e(number_format((float) ($overrides[$test->id]->price ?? $test->default_price), 2)); ?>)</option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </select>
                                    </div>
                                    <div class="md:col-span-3">
                                        <input type="number" min="1" :name="'tests['+index+'][qty]'" x-model="row.qty" class="w-full rounded-lg border-slate-300" required>
                                    </div>
                                    <div class="md:col-span-1">
                                        <button type="button" class="w-full rounded-lg border border-red-200 bg-red-50 px-2 py-2 text-xs font-semibold text-red-700" @click="rows.splice(index, 1)" x-show="rows.length > 1">x</button>
                                    </div>
                                </div>
                            </template>
                        </div>
                    </div>

                    <?php if($errors->any()): ?>
                        <div class="rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700">
                            <ul class="list-disc pl-5">
                                <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <li><?php echo e($error); ?></li>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </ul>
                        </div>
                    <?php endif; ?>

                    <div class="flex items-center justify-end gap-2">
                        <a href="<?php echo e(route('frontdesk.patients.show', $patient)); ?>" class="rounded-lg border border-slate-300 px-4 py-2 text-sm font-medium text-slate-700">Cancel</a>
                        <button type="submit" class="rounded-lg bg-sky-600 px-4 py-2 text-sm font-semibold text-white hover:bg-sky-700">Create order</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php /**PATH C:\wamp64\www\lab-result-portal\resources\views\frontdesk\orders\create.blade.php ENDPATH**/ ?>