Update source into github

This commit is contained in:
pbao9
2025-07-24 16:18:27 +07:00
parent 41419358dd
commit 69851ac7bc
2642 changed files with 284095 additions and 0 deletions
@@ -0,0 +1,300 @@
@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
@@ -0,0 +1,190 @@
@extends("admin.main")
@section("content")
@if(auth()->guard('admins')->user()->can("manager invoice"))
<div class="card card-primary card-outline">
<div class="card-header">
<form action="{{ route('admin.invoice.index') }}" method="get">
<div class="row form-group mb-0">
<div class="col-md-3">
{{-- Customer --}}
<x-form.customer :model="request()->get('client') ?? null" />
</div>
<div class="col-md-3">
<div class="form-group">
<label for="invoice_id">
Invoice ID </label>
<input type="number" name="invoice_id" id="invoice_id" class="form-control"
value="{{ request()->invoice_id ?? "" }}">
</div>
</div>
<div class="col-md-3">
{{-- Payment --}}
<x-form.payment :model="request()->get('payment_method') ?? null" />
</div>
<div class="col-md-3">
<div class="form-group">
<label for="inputStatus">
Status</label>
<select name="status" class="form-control" id="inputStatus">
<option value="full"
@selected(request()->status === "full")>
Any
</option>
<option value="active"
@selected(request()->status === "active")>
Active
</option>
<option value="unpaid"
@selected(request()->status === "unpaid")>
Pending
</option>
<option value="cancel"
@selected(request()->status === "cancel")>
Cancel
</option>
</select>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="date">Invoice Date:</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<i class="far fa-calendar-alt"></i>
</span>
</div>
<input type="text" class="form-control reservation float-right"
name="date"
value="{{ request()->date ?? "" }}"
id="date">
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="due_date">Due Date:</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<i class="far fa-calendar-alt"></i>
</span>
</div>
<input type="text" class="form-control reservation float-right"
name="due_date"
value="{{ request()->due_date ?? "" }}"
id="due_date">
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="date_paid">Date Paid:</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<i class="far fa-calendar-alt"></i>
</span>
</div>
<input type="text" class="form-control reservation float-right"
name="date_paid"
value="{{ request()->date_paid ?? "" }}"
id="date_paid">
</div>
</div>
</div>
<div class="col-md-3">
<label class="clear-search hidden">
</label>
<button type="submit" class="form-control btn btn-block bg-gradient-primary">
<i class="fas fa-search"></i> Search
</button>
</div>
</div>
</form>
<span>{{ $invoices->count() }} Records Found</span>
</div>
<div class="card-body">
<table class="table table-invoice table-bordered">
<thead>
<tr>
<th style="width: 10px">
<label for=""></label><input type="checkbox" name="check" class="check-all" id="">
</th>
<th>Invoice #</th>
<th>Client Name</th>
<th>Date</th>
<th>Payment Method</th>
<th>Total</th>
<th>Status</th>
<th style="width: 40px"></th>
<th style="width: 40px"></th>
</tr>
</thead>
<tbody>
@if($invoices->count())
@foreach($invoices->all() as $item)
<tr>
<td class="text-center">
<input type="checkbox" name="id[]" id="" value="{{ $item->id }}">
</td>
<td class="text-center">
<a href="{{ route("admin.invoice.edit",['id' => $item->id]) }}"
title="View Order"> {{ $item->id }}</a>
</td>
<td class="text-center">
@isset($item->customer->firstname)
{{ $item->customer->firstname . ' ' . $item->customer->lastname }}
@endisset
</td>
<td class="text-center">
@time($item->date)
</td>
<td class="text-center">
{{ $item->payment->name ?? 'VN Pay' }}
</td>
<td class="text-center">
{{ number_format($item->total,0,',','.') }}đ
</td>
<td class="text-center">
{!! $item->getStatus() !!}
</td>
<td class="text-center">
<a class="btn btn-warning btn-sm"
href="{{ route('admin.invoice.edit',['id' => $item->id ]) }}">
<i class="fas fa-search"></i>
</a>
</td>
<td class="text-center">
@if(auth()->guard('admins')->user()->can("delete invoice"))
<form method="post" class="d-inline"
action="{{ route('admin.invoice.destroy',['id' => $item->id]) }}">
@csrf
@method('delete')
<button type="submit" data-toggle="tooltip" data-placement="top" title=""
class="btn btn-sm btn-danger" data-original-title="Xoá">
<i class="fas fa-trash"></i>
</button>
</form>
@endif
</td>
</tr>
@endforeach
@endif
</tbody>
</table>
</div>
<div class="card-footer">
{{ $invoices->withQueryString()->links() }}
</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