<?php $__env->startSection('title', 'Create Quotation'); ?>

<?php $__env->startSection('content'); ?>
    <?php if (isset($component)) { $__componentOriginal00a2e3c817942d1565d2933416f28c6a = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal00a2e3c817942d1565d2933416f28c6a = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.page-head','data' => ['title' => 'Create Quotation','subtitle' => 'Prepare quote before converting to invoice']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('page-head'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['title' => 'Create Quotation','subtitle' => 'Prepare quote before converting to invoice']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal00a2e3c817942d1565d2933416f28c6a)): ?>
<?php $attributes = $__attributesOriginal00a2e3c817942d1565d2933416f28c6a; ?>
<?php unset($__attributesOriginal00a2e3c817942d1565d2933416f28c6a); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal00a2e3c817942d1565d2933416f28c6a)): ?>
<?php $component = $__componentOriginal00a2e3c817942d1565d2933416f28c6a; ?>
<?php unset($__componentOriginal00a2e3c817942d1565d2933416f28c6a); ?>
<?php endif; ?>

    <?php if (isset($component)) { $__componentOriginal36665f0dc0e45320e21db1e20a989acf = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal36665f0dc0e45320e21db1e20a989acf = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.panel','data' => []] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('panel'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
        <form method="POST" action="<?php echo e(route('finance.quotations.store')); ?>" id="quotationForm">
            <?php echo csrf_field(); ?>
            <div style="display:grid; grid-template-columns: repeat(2, 1fr); gap:16px; margin-bottom:20px;">
                <div class="form-group">
                    <label class="form-label" for="student_id">Student (optional)</label>
                    <select class="input" id="student_id" name="student_id">
                        <option value="">—</option>
                        <?php $__currentLoopData = $students; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $student): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($student->id); ?>" <?php if(old('student_id') == $student->id): echo 'selected'; endif; ?>>
                                <?php echo e($student->admission_number); ?> — <?php echo e($student->full_name); ?>

                            </option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>
                <div class="form-group">
                    <label class="form-label" for="customer_name">Customer Name (if no student)</label>
                    <input class="input" type="text" id="customer_name" name="customer_name" value="<?php echo e(old('customer_name')); ?>">
                </div>
                <div class="form-group">
                    <label class="form-label" for="issue_date">Issue Date</label>
                    <input class="input" type="date" id="issue_date" name="issue_date" value="<?php echo e(old('issue_date', now()->toDateString())); ?>" required>
                </div>
                <div class="form-group">
                    <label class="form-label" for="valid_until">Valid Until</label>
                    <input class="input" type="date" id="valid_until" name="valid_until" value="<?php echo e(old('valid_until')); ?>">
                </div>
                <div class="form-group">
                    <label class="form-label" for="tax_amount">Tax Amount</label>
                    <input class="input" type="number" step="0.01" min="0" id="tax_amount" name="tax_amount" value="<?php echo e(old('tax_amount', '0.00')); ?>">
                </div>
            </div>

            <h4 style="margin-bottom:12px;">Line Items</h4>
            <table id="linesTable">
                <thead><tr><th>Description</th><th>Qty</th><th>Unit Price</th><th></th></tr></thead>
                <tbody>
                    <?php for($i = 0; $i < max(1, count(old('lines', []))); $i++): ?>
                        <?php ($line = old('lines.'.$i, [])); ?>
                        <tr>
                            <td><input class="input" type="text" name="lines[<?php echo e($i); ?>][description]" value="<?php echo e($line['description'] ?? ''); ?>" required></td>
                            <td><input class="input" type="number" step="0.01" min="0.01" name="lines[<?php echo e($i); ?>][quantity]" value="<?php echo e($line['quantity'] ?? '1'); ?>" required style="width:80px;"></td>
                            <td><input class="input" type="number" step="0.01" min="0" name="lines[<?php echo e($i); ?>][unit_price]" value="<?php echo e($line['unit_price'] ?? ''); ?>" required style="width:120px;"></td>
                            <td></td>
                        </tr>
                    <?php endfor; ?>
                </tbody>
            </table>

            <div style="display:flex; gap:10px; margin-top:16px;">
                <button type="button" class="btn btn-outline" onclick="addLine()">Add Line</button>
                <button type="submit" class="btn btn-primary">Save Quotation</button>
                <a href="<?php echo e(route('finance.invoices.index')); ?>" class="btn btn-ghost">Cancel</a>
            </div>
        </form>
     <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal36665f0dc0e45320e21db1e20a989acf)): ?>
<?php $attributes = $__attributesOriginal36665f0dc0e45320e21db1e20a989acf; ?>
<?php unset($__attributesOriginal36665f0dc0e45320e21db1e20a989acf); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal36665f0dc0e45320e21db1e20a989acf)): ?>
<?php $component = $__componentOriginal36665f0dc0e45320e21db1e20a989acf; ?>
<?php unset($__componentOriginal36665f0dc0e45320e21db1e20a989acf); ?>
<?php endif; ?>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
<script>
function addLine() {
    const tbody = document.querySelector('#linesTable tbody');
    const index = tbody.children.length;
    const row = document.createElement('tr');
    row.innerHTML = `
        <td><input class="input" type="text" name="lines[${index}][description]" required></td>
        <td><input class="input" type="number" step="0.01" min="0.01" name="lines[${index}][quantity]" value="1" required style="width:80px;"></td>
        <td><input class="input" type="number" step="0.01" min="0" name="lines[${index}][unit_price]" required style="width:120px;"></td>
        <td></td>`;
    tbody.appendChild(row);
}
</script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\southend\resources\views\admin\invoices\create-quotation.blade.php ENDPATH**/ ?>