<?php ($plan = $plan ?? null); ?>

<?php $__env->startSection('title', __('nav.plans')); ?>
<?php $__env->startSection('content'); ?>
<h1 class="h4 mb-3"><?php echo e($plan ? __('messages.edit') : __('messages.create')); ?></h1>
<form method="post" action="<?php echo e($plan ? route('plans.update',$plan) : route('plans.store')); ?>" class="card card-body">
<?php echo csrf_field(); ?> <?php if($plan): ?><?php echo method_field('PUT'); ?><?php endif; ?>
<div class="row g-3">
<div class="col-md-6"><label class="form-label"><?php echo e(__('messages.name')); ?></label><input class="form-control" name="name" value="<?php echo e(old('name', $plan?->name)); ?>" required></div>
<div class="col-md-6"><label class="form-label"><?php echo e(__('messages.company')); ?></label><select class="form-select" name="telecom_company_id" required><?php $__currentLoopData = $companies; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $c): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($c->id); ?>" <?php if((string) old('telecom_company_id', $plan?->telecom_company_id) === (string) $c->id): echo 'selected'; endif; ?>><?php echo e($c->name); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select></div>
<div class="col-md-4"><label class="form-label"><?php echo e(__('messages.monthly_price')); ?></label><input class="form-control" name="price" value="<?php echo e(old('price', $plan?->price)); ?>" required></div>
<div class="col-md-4">
    <label class="form-label"><?php echo e(__('messages.plan_type')); ?></label>
    <select class="form-select" name="plan_type">
        <?php $__currentLoopData = ['postpaid','prepaid']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $t): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <option value="<?php echo e($t); ?>" <?php if(old('plan_type', $plan?->plan_type?->value ?? 'postpaid') === $t): echo 'selected'; endif; ?>><?php echo e(__('status.plan_'.$t)); ?></option>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </select>
    <div class="form-text"><?php echo e(__('messages.plan_type_help')); ?></div>
</div>
<div class="col-md-4"><label class="form-label"><?php echo e(__('messages.billing_cycle')); ?></label><select class="form-select" name="billing_cycle"><?php $__currentLoopData = ['monthly','quarterly','yearly']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $t): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($t); ?>" <?php if(old('billing_cycle', $plan?->billing_cycle?->value ?? 'monthly') === $t): echo 'selected'; endif; ?>><?php echo e(__('status.cycle_'.$t)); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select></div>
<?php if($plan): ?>
<div class="col-md-6"><label class="form-label"><?php echo e(__('messages.effective_date')); ?></label><input class="form-control" type="date" name="effective_date" value="<?php echo e(now()->toDateString()); ?>"></div>
<div class="col-md-6"><label class="form-label"><?php echo e(__('messages.reason')); ?></label><input class="form-control" name="price_reason" placeholder="<?php echo e(__('messages.price_change_reason')); ?>"></div>
<?php endif; ?>
<div class="col-md-6"><label class="form-label"><?php echo e(__('messages.status')); ?></label><select class="form-select" name="status"><option value="active"><?php echo e(__('status.active')); ?></option><option value="inactive" <?php if(old('status', $plan?->status?->value) === 'inactive'): echo 'selected'; endif; ?>><?php echo e(__('status.inactive')); ?></option></select></div>
<div class="col-12"><textarea class="form-control" name="description" placeholder="<?php echo e(__('messages.description')); ?>"><?php echo e(old('description', $plan?->description)); ?></textarea></div>
</div>
<input type="hidden" name="start_date" value="<?php echo e(old('start_date', $plan?->start_date?->toDateString())); ?>">
<input type="hidden" name="end_date" value="<?php echo e(old('end_date', $plan?->end_date?->toDateString())); ?>">
<button class="btn btn-success mt-3"><?php echo e(__('messages.save')); ?></button>
</form>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH D:\laragon\www\esim\resources\views/plans/_form.blade.php ENDPATH**/ ?>