Files
portal-api/resources/views/admin/invoice/edit.blade.php
T
2025-07-24 16:18:27 +07:00

301 lines
16 KiB
PHP

@extends('admin.main')
@section('styles')
<style>
.addon-list {
max-height: 120px;
overflow-y: auto;
}
.addon-item {
border-left: 3px solid #17a2b8;
padding-left: 8px;
margin-bottom: 4px;
}
.addon-item:last-child {
margin-bottom: 0;
}
.table-invoice td {
vertical-align: top;
}
.product-info {
max-width: 300px;
}
.product-specs {
margin-top: 4px;
line-height: 1.2;
}
.os-info {
margin-top: 4px;
}
.product-info strong {
color: #2c3e50;
font-size: 14px;
}
</style>
@endsection
@section('content')
@if (auth()->guard('admins')->user()->can('edit invoice'))
<div class="card card-outline card-primary">
<div class="card-body">
<div class="row form-group">
<div class="col-md-6">
<table class="form">
<tbody>
<tr>
<td class="fieldlabel">Client Name</td>
<td class="fieldarea">
<a href="{{ route('customer.info', ['userid' => $invoice->customer->id]) }}">
{{ $invoice->customer->firstname . ' ' . $invoice->customer->lastname }}
</a>
</td>
</tr>
<tr>
<td width="15%" class="fieldlabel">Invoice Date</td>
<td class="fieldarea">
{{ \Carbon\Carbon::parse($invoice->date)->format('d/m/Y H:i:s') }}
</td>
</tr>
<tr>
<td class="fieldlabel">Due Date</td>
<td class="fieldarea">
{{ \Carbon\Carbon::parse($invoice->due_date)->format('d/m/Y H:i:s') }}
</td>
</tr>
<tr>
<td class="fieldlabel">Total Due</td>
<td class="fieldarea">
{{ number_format($invoice->total, 0, ',', ',') }}đ
</td>
</tr>
@if ($invoice->vm_id)
<tr>
<td class="fieldlabel">VM ID</td>
<td class="fieldarea">
<span class="badge badge-success">{{ $invoice->vm_id }}</span>
</td>
</tr>
@endif
</tbody>
</table>
</div>
<div class="col-md-6 align-items-center text-center">
<h3>
{!! $invoice->getStatus() !!}
</h3>
<p>
<span>Payment Method: </span> <strong>{{ $invoice->payment->name ?? 'Free' }}</strong>
</p>
<div class="row form-group">
<div class="col-md-12 text-center">
<form class="d-lg-inline"
action="{{ route('admin.invoice.update', ['id' => $invoice->id]) }}" method="post">
@method('put')
@csrf
<input type="hidden" name="action" value="Paid">
<button
{{ $invoice->status === 1 ? 'type=button' : 'type=submit' }}
class="btn {{ $invoice->status === 1 ? 'disabled' : '' }} bg-gradient-success">
<i class="far fa-check-circle"></i>
Mark Paid
</button>
</form>
<form class="d-lg-inline"
action="{{ route('admin.invoice.update', ['id' => $invoice->id]) }}" method="post">
@method('put')
@csrf
<input type="hidden" name="action" value="Cancel">
<button type="submit" class="btn bg-gradient-secondary">Mark Cancel
</button>
</form>
<form class="d-lg-inline"
action="{{ route('admin.invoice.update', ['id' => $invoice->id]) }}" method="post">
@method('put')
@csrf
<input type="hidden" name="action" value="UnPaid">
<button {{ $invoice->status === 0 ? '' : 'type="submit"' }}
class="btn {{ $invoice->status === 0 ? 'disabled' : '' }} bg-gradient-danger">
Mark Unpaid
</button>
</form>
</div>
</div>
</div>
</div>
<div class="row form-group">
<div class="col-md-12">
<h3 class="mb-3">Invoice Items</h3>
<table class="table table-invoice table-bordered">
<thead>
<tr>
<th>Item</th>
<th>Product</th>
<th>Description</th>
<th>Addons</th>
<th>Amount</th>
<th style="width: 40px">Tax</th>
</tr>
</thead>
<tbody>
@if ($invoice->invoiceItem->count())
@foreach ($invoice->invoiceItem->all() as $item)
<tr>
<td class="text-center">
@if ($item->type)
<a
href="{{ route('customer.product', ['userid' => $item->customer_id, 'product' => $item->relid, 'type' => $item->type_id]) }}">
{{ $item->type->name }}
</a>
@endif
</td>
<td>
@php
$product = null;
if ($item->product_type == 3 && $item->hosting) {
$product = $item->hosting;
} elseif ($item->product_type == 4 && $item->vps) {
$product = $item->vps;
}
@endphp
@if ($product)
<div class="product-info">
<strong>{{ $product->name }}</strong>
@if ($item->product_type == 4)
<div class="product-specs">
<small class="text-muted">
CPU: {{ $product->cpu }} vCore |
RAM: {{ $product->ram }} GB |
Disk: {{ $product->disk }} GB
@if ($product->gpu)
| GPU: {{ $product->gpu }}
@endif
</small>
</div>
@elseif ($item->product_type == 3)
<div class="product-specs">
<small class="text-muted">
Disk: {{ $product->disk }} GB |
RAM: {{ $product->ram }} GB |
Bandwidth: {{ $product->bandwidth }} GB
@if ($product->cpu)
| CPU: {{ $product->cpu }}
@endif
</small>
</div>
@endif
@if ($item->os)
<div class="os-info">
<span class="badge badge-secondary">{{ $item->os->name }}</span>
</div>
@endif
</div>
@else
<span class="text-muted">No product info</span>
@endif
</td>
<td>
{{ $item->description }}
</td>
<td>
@if ($item->addons->count() > 0)
<div class="addon-list">
@foreach ($item->addons as $addon)
<div class="addon-item mb-1">
<span class="badge badge-info">
{{ $addon->addonItems->name ?? 'Unknown Addon' }}
@if ($addon->qty > 1)
(x{{ $addon->qty }})
@endif
</span>
<small class="text-muted d-block">
{{ number_format($addon->price, 0, ',', '.') }} đ
</small>
</div>
@endforeach
</div>
@else
<span class="text-muted">No addons</span>
@endif
</td>
<td class="text-center">
{{ number_format($item->amount, 0, ',', '.') }} đ
</td>
<td class="text-center">
<input type="checkbox" name="tax" checked onclick="return false"
id="">
</td>
</tr>
@endforeach
@endif
</tbody>
</table>
@php
$totalAddonCost = 0;
foreach ($invoice->invoiceItem as $item) {
foreach ($item->addons as $addon) {
$totalAddonCost += $addon->price;
}
}
@endphp
@if ($totalAddonCost > 0)
<div class="row mt-3">
<div class="col-md-12">
<div class="alert alert-info">
<strong>Addon Summary:</strong> Total addon cost: {{ number_format($totalAddonCost, 0, ',', '.') }} đ
</div>
</div>
</div>
@endif
@php
$productTypes = [];
foreach ($invoice->invoiceItem as $item) {
$product = null;
if ($item->product_type == 3 && $item->hosting) {
$product = $item->hosting;
} elseif ($item->product_type == 4 && $item->vps) {
$product = $item->vps;
}
if ($product) {
$typeName = $item->product_type == 3 ? 'Hosting' : ($item->product_type == 4 ? 'VPS' : 'Other');
if (!isset($productTypes[$typeName])) {
$productTypes[$typeName] = 0;
}
$productTypes[$typeName]++;
}
}
@endphp
@if (!empty($productTypes))
<div class="row mt-2">
<div class="col-md-12">
<div class="alert alert-success">
<strong>Product Summary:</strong>
@foreach ($productTypes as $type => $count)
<span class="badge badge-success mr-2">{{ $type }}: {{ $count }}</span>
@endforeach
</div>
</div>
</div>
@endif
</div>
</div>
</div>
</div>
@else
<div class="alert alert-danger alert-dismissible">
<h5 class="mb-0"><i class="icon fas fa-ban"></i> Access Denied - You are not assigned to any Invoice
management department</h5>
</div>
@endif
@endsection