56 lines
3.1 KiB
PHP
56 lines
3.1 KiB
PHP
@props(['invoice'])
|
|
|
|
<flux:modal name="renewal-modal" class="md:w-[28rem]">
|
|
<div class="space-y-6" x-data="{ submitting: false, plan: '12', months: 12, unitPrice: 0, total: 0 }" x-init="
|
|
(() => {
|
|
const p = {{ (int) ($invoice->invoiceItem->first()?->getProductAttribute()?->price_sale ?? $invoice->invoiceItem->first()?->getProductAttribute()?->price ?? 0) }};
|
|
unitPrice = p; total = p * months;
|
|
$watch('plan', value => { months = (value === 'other') ? months : parseInt(value); total = unitPrice * months; });
|
|
$watch('months', value => { if (plan === 'other') { total = unitPrice * (parseInt(value) || 0); } });
|
|
})()
|
|
">
|
|
<div>
|
|
<flux:heading size="lg">{{ __('Gia hạn dịch vụ') }}</flux:heading>
|
|
<flux:text class="mt-2">{{ __('Chọn thời hạn gia hạn hoặc nhập số tháng mong muốn.') }}</flux:text>
|
|
</div>
|
|
|
|
<form x-on:submit.prevent="if (submitting) return; submitting = true; $el.submit()" method="POST" action="{{ route('service.renew') }}">
|
|
@csrf
|
|
<input type="hidden" name="product_id" value="{{ $invoice->vm_id }}">
|
|
|
|
<flux:field>
|
|
<flux:label>{{ __('Chọn thời hạn') }}</flux:label>
|
|
<flux:select x-model="plan" name="plan">
|
|
<flux:select.option value="3">{{ __('3 tháng') }}</flux:select.option>
|
|
<flux:select.option value="6">{{ __('6 tháng') }}</flux:select.option>
|
|
<flux:select.option value="12">{{ __('12 tháng') }}</flux:select.option>
|
|
<flux:select.option value="24">{{ __('24 tháng') }}</flux:select.option>
|
|
<flux:select.option value="other">{{ __('Khác...') }}</flux:select.option>
|
|
</flux:select>
|
|
</flux:field>
|
|
|
|
<div x-show="plan === 'other'" class="mt-2">
|
|
<flux:field>
|
|
<flux:label>{{ __('Số tháng') }}</flux:label>
|
|
<flux:input x-model.number="months" name="months" type="number" min="1" max="60" placeholder="{{ __('Nhập số tháng') }}" />
|
|
<flux:description>{{ __('Nhập số tháng muốn gia hạn (tối đa 60).') }}</flux:description>
|
|
</flux:field>
|
|
</div>
|
|
|
|
<div class="mt-4 text-sm text-gray-700">
|
|
<div class="flex justify-between"><span>{{ __('Đơn giá / tháng') }}</span><span x-text="new Intl.NumberFormat('vi-VN').format(unitPrice) + ' đ'"></span></div>
|
|
<div class="flex justify-between font-semibold"><span>{{ __('Tổng tiền') }}</span><span x-text="new Intl.NumberFormat('vi-VN').format(total) + ' đ'"></span></div>
|
|
</div>
|
|
|
|
<div class="flex gap-2 justify-end mt-6">
|
|
<flux:modal.close>
|
|
<flux:button variant="ghost">{{ __('Hủy') }}</flux:button>
|
|
</flux:modal.close>
|
|
<flux:button type="submit" variant="primary" color="orange" x-bind:disabled="submitting">{{ __('Đồng ý') }}</flux:button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</flux:modal>
|
|
|
|
|