<?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 ? $attributes->all() : [])); ?>
<?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): ?>
<?php $attributes = $attributes->except(\App\View\Components\AppLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
     <?php $__env->slot('heading', null, []); ?> Log Treatment <?php $__env->endSlot(); ?>

    <div class="max-w-xl">
        <div class="rounded-xl border border-gray-100 bg-white p-6 shadow-sm">
            <form method="POST" action="<?php echo e(route('health.treatment.store')); ?>" x-data="treatmentForm()" class="space-y-5">
                <?php echo csrf_field(); ?>

                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">Pond <span class="text-red-500">*</span></label>
                    <select name="pond_id" class="w-full rounded-lg border-gray-200 text-sm focus:border-primary-500 focus:ring-primary-500">
                        <option value="">Select pond…</option>
                        <?php $__currentLoopData = $ponds; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $pond): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($pond->id); ?>" <?php if($selectedPondId == $pond->id): echo 'selected'; endif; ?>><?php echo e($pond->name); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                    <?php $__errorArgs = ['pond_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-red-500"><?php echo e($message); ?></p> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                </div>

                <div class="grid grid-cols-2 gap-4">
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Treatment Date <span class="text-red-500">*</span></label>
                        <input type="date" name="treatment_date" x-model="treatmentDate"
                               @change="calcSafeDate()"
                               value="<?php echo e(old('treatment_date', today()->toDateString())); ?>"
                               max="<?php echo e(today()->toDateString()); ?>"
                               class="w-full rounded-lg border-gray-200 text-sm focus:border-primary-500 focus:ring-primary-500">
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Application Method <span class="text-red-500">*</span></label>
                        <select name="application_method" class="w-full rounded-lg border-gray-200 text-sm focus:border-primary-500 focus:ring-primary-500">
                            <?php $__currentLoopData = $applicationMethods; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $opt): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($opt->value); ?>" <?php if(old('application_method') === $opt->value): echo 'selected'; endif; ?>><?php echo e($opt->label); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                </div>

                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">Drug / Chemical Name <span class="text-red-500">*</span></label>
                    <input type="text" name="drug_chemical_name" value="<?php echo e(old('drug_chemical_name')); ?>"
                           class="w-full rounded-lg border-gray-200 text-sm focus:border-primary-500 focus:ring-primary-500">
                    <?php $__errorArgs = ['drug_chemical_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-red-500"><?php echo e($message); ?></p> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                </div>

                <div class="grid grid-cols-2 gap-4">
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Dosage <span class="text-red-500">*</span></label>
                        <input type="text" name="dosage" value="<?php echo e(old('dosage')); ?>"
                               placeholder="e.g. 2 ml/L"
                               class="w-full rounded-lg border-gray-200 text-sm focus:border-primary-500 focus:ring-primary-500">
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Duration (days)</label>
                        <input type="number" name="duration_days" value="<?php echo e(old('duration_days')); ?>" min="1"
                               class="w-full rounded-lg border-gray-200 text-sm focus:border-primary-500 focus:ring-primary-500">
                    </div>
                </div>

                <div class="grid grid-cols-2 gap-4">
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Withdrawal Period (days)</label>
                        <input type="number" name="withdrawal_period_days" x-model.number="withdrawalDays"
                               @input="calcSafeDate()"
                               value="<?php echo e(old('withdrawal_period_days')); ?>" min="0"
                               class="w-full rounded-lg border-gray-200 text-sm focus:border-primary-500 focus:ring-primary-500">
                        <p x-show="safeDate" class="mt-1 text-xs text-amber-600">
                            Harvest safe after: <strong x-text="safeDate"></strong>
                        </p>
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Cost (₦)</label>
                        <input type="number" name="cost_naira" value="<?php echo e(old('cost_naira')); ?>"
                               step="0.01" min="0"
                               class="w-full rounded-lg border-gray-200 text-sm focus:border-primary-500 focus:ring-primary-500">
                    </div>
                </div>

                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">Administered by</label>
                    <input type="text" name="administered_by" value="<?php echo e(old('administered_by')); ?>"
                           placeholder="Vet or farm staff name"
                           class="w-full rounded-lg border-gray-200 text-sm focus:border-primary-500 focus:ring-primary-500">
                </div>

                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">Notes</label>
                    <textarea name="notes" rows="2"
                              class="w-full rounded-lg border-gray-200 text-sm focus:border-primary-500 focus:ring-primary-500"><?php echo e(old('notes')); ?></textarea>
                </div>

                <div class="flex items-center gap-3 border-t border-gray-100 pt-4">
                    <button type="submit"
                            class="inline-flex items-center gap-2 rounded-lg bg-primary-600 px-5 py-2 text-sm font-semibold text-white hover:bg-primary-700">
                        Log Treatment
                    </button>
                    <a href="<?php echo e(route('health.index')); ?>" class="text-sm text-gray-500 hover:text-gray-700">Cancel</a>
                </div>
            </form>
        </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 $__env->startPush('scripts'); ?>
<script>
function treatmentForm() {
    return {
        treatmentDate: '<?php echo e(today()->toDateString()); ?>',
        withdrawalDays: null,
        safeDate: null,
        calcSafeDate() {
            if (this.treatmentDate && this.withdrawalDays > 0) {
                const d = new Date(this.treatmentDate);
                d.setDate(d.getDate() + parseInt(this.withdrawalDays));
                this.safeDate = d.toLocaleDateString('en-NG', {day:'2-digit', month:'short', year:'numeric'});
            } else {
                this.safeDate = null;
            }
        }
    }
}
</script>
<?php $__env->stopPush(); ?>
<?php /**PATH C:\laragon\www\farm\resources\views\health\treatment-create.blade.php ENDPATH**/ ?>