<?php
    use App\Support\InventoryCatalog;
?>

<div class="space-y-5">
    <div class="grid gap-5 sm:grid-cols-2">
        <div>
            <label class="isp-form-label" for="name">Name</label>
            <input id="name" type="text" name="name" value="<?php echo e(old('name', $item->name ?? '')); ?>" class="isp-form-input" placeholder="Customer CPE — Tower A" required>
            <?php $__errorArgs = ['name'];
$__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-rose-600"><?php echo e($message); ?></p><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
        </div>
        <div>
            <label class="isp-form-label" for="serial_number">Serial number</label>
            <input id="serial_number" type="text" name="serial_number" value="<?php echo e(old('serial_number', $item->serial_number ?? '')); ?>" class="isp-form-input" required>
            <?php $__errorArgs = ['serial_number'];
$__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-rose-600"><?php echo e($message); ?></p><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
        </div>
    </div>

    <div class="grid gap-5 sm:grid-cols-3">
        <div>
            <label class="isp-form-label" for="category">Category</label>
            <select id="category" name="category" class="isp-form-select" required>
                <?php $__currentLoopData = InventoryCatalog::CATEGORIES; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $value => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($value); ?>" <?php if(old('category', $item->category ?? 'cpe') === $value): echo 'selected'; endif; ?>><?php echo e($label); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>
            <?php $__errorArgs = ['category'];
$__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-rose-600"><?php echo e($message); ?></p><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
        </div>
        <div>
            <label class="isp-form-label" for="brand">Brand</label>
            <select id="brand" name="brand" class="isp-form-select">
                <option value="">— Select —</option>
                <?php $__currentLoopData = InventoryCatalog::BRANDS; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $brand): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($brand); ?>" <?php if(old('brand', $item->brand ?? '') === $brand): echo 'selected'; endif; ?>><?php echo e($brand); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>
            <?php $__errorArgs = ['brand'];
$__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-rose-600"><?php echo e($message); ?></p><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
        </div>
        <div>
            <label class="isp-form-label" for="model">Model</label>
            <input id="model" type="text" name="model" value="<?php echo e(old('model', $item->model ?? '')); ?>" class="isp-form-input" placeholder="hAP ac²">
            <?php $__errorArgs = ['model'];
$__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-rose-600"><?php echo e($message); ?></p><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
        </div>
    </div>

    <div class="grid gap-5 sm:grid-cols-2">
        <div>
            <label class="isp-form-label" for="mac_address">MAC address (optional)</label>
            <input id="mac_address" type="text" name="mac_address" value="<?php echo e(old('mac_address', $item->mac_address ?? '')); ?>" class="isp-form-input" placeholder="AA:BB:CC:DD:EE:FF">
            <?php $__errorArgs = ['mac_address'];
$__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-rose-600"><?php echo e($message); ?></p><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
        </div>
        <div>
            <label class="isp-form-label" for="location">Location</label>
            <select id="location" name="location" class="isp-form-select">
                <?php $__currentLoopData = InventoryCatalog::LOCATIONS; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $value => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($value); ?>" <?php if(old('location', $item->location ?? 'warehouse') === $value): echo 'selected'; endif; ?>><?php echo e($label); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>
            <?php $__errorArgs = ['location'];
$__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-rose-600"><?php echo e($message); ?></p><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
        </div>
    </div>

    <div class="grid gap-5 sm:grid-cols-3">
        <div>
            <label class="isp-form-label" for="purchase_price">Purchase price</label>
            <input id="purchase_price" type="number" step="0.01" min="0" name="purchase_price" value="<?php echo e(old('purchase_price', $item->purchase_price ?? '')); ?>" class="isp-form-input">
            <?php $__errorArgs = ['purchase_price'];
$__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-rose-600"><?php echo e($message); ?></p><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
        </div>
        <div>
            <label class="isp-form-label" for="purchase_date">Purchase date</label>
            <input id="purchase_date" type="date" name="purchase_date" value="<?php echo e(old('purchase_date', isset($item) && $item->purchase_date ? $item->purchase_date->format('Y-m-d') : '')); ?>" class="isp-form-input">
            <?php $__errorArgs = ['purchase_date'];
$__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-rose-600"><?php echo e($message); ?></p><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
        </div>
        <div>
            <label class="isp-form-label" for="warranty_expiry">Warranty expiry</label>
            <input id="warranty_expiry" type="date" name="warranty_expiry" value="<?php echo e(old('warranty_expiry', isset($item) && $item->warranty_expiry ? $item->warranty_expiry->format('Y-m-d') : '')); ?>" class="isp-form-input">
            <?php $__errorArgs = ['warranty_expiry'];
$__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-rose-600"><?php echo e($message); ?></p><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
        </div>
    </div>

    <?php if(! empty($purchases)): ?>
        <div>
            <label class="isp-form-label" for="inventory_purchase_id">Link to purchase record (optional)</label>
            <select id="inventory_purchase_id" name="inventory_purchase_id" class="isp-form-select">
                <option value="">— None —</option>
                <?php $__currentLoopData = $purchases; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $purchase): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($purchase->id); ?>" <?php if(old('inventory_purchase_id', $item->inventory_purchase_id ?? '') == $purchase->id): echo 'selected'; endif; ?>>
                        <?php echo e($purchase->vendor_name); ?> — <?php echo e($purchase->purchase_date?->format('M d, Y')); ?>

                        <?php if($purchase->invoice_number): ?> (<?php echo e($purchase->invoice_number); ?>) <?php endif; ?>
                    </option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>
            <?php $__errorArgs = ['inventory_purchase_id'];
$__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-rose-600"><?php echo e($message); ?></p><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
        </div>
    <?php endif; ?>

    <div>
        <label class="isp-form-label" for="notes">Notes</label>
        <textarea id="notes" name="notes" rows="3" class="isp-form-textarea" placeholder="Condition, accessories, supplier remarks…"><?php echo e(old('notes', $item->notes ?? '')); ?></textarea>
        <?php $__errorArgs = ['notes'];
$__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-rose-600"><?php echo e($message); ?></p><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
    </div>
</div>
<?php /**PATH C:\xampp\htdocs\ispbilling\resources\views/isp/inventory/partials/form.blade.php ENDPATH**/ ?>