Files
portal-api/resources/views/administrator/pages/order/edit.blade.php
T

202 lines
11 KiB
PHP

@php use Carbon\Carbon; @endphp
@extends('administrator.layout.master')
@section('breadcrumb')
@php
$breadcrumbItems = [
['label' => 'Order'],
['label' => 'Order Management', 'url' => route('administrator.pages.order.index')],
['label' => 'View Order', 'active' => true],
];
@endphp
<x-admin-breadcrumb :items="$breadcrumbItems" />
@endsection
@section('content')
@if(auth()->guard('admins')->user()->can("edit order"))
<form action="{{ route('administrator.pages.order.update', ['id' => $order->id]) }}" method="post">
@csrf
@method('PUT')
<input type="hidden" name="module" value="1">
<div class="row align-items-start">
<div class="col-md-8">
<div class="card card-outline card-primary">
<div class="card-header bg-white">
<h5 class="card-title m-0">Order Information</h5>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-borderless">
<tbody>
<tr>
<td class="text-muted" style="width: 150px;">Date</td>
<td>{{ Carbon::parse($order->date)->format("d/m/Y H:i:s") }}</td>
<td class="text-muted" style="width: 150px;">Payment Method</td>
<td>{{ $order->payment->name ?? 'VN Pay' }}</td>
</tr>
<tr>
<td class="text-muted">Order #</td>
<td>{{ $order->order_num }} (ID: {{ $order->id }})</td>
<td class="text-muted">Amount</td>
<td>@money($order->amount) đ</td>
</tr>
<tr>
<td class="text-muted">Client</td>
<td>
<a href="{{ route('customer.info', ['userid' => $order->customer->id]) }}">
{{ $order->customer->firstname . ' ' . $order->customer->lastname }}
</a>
<br>
<small class="text-muted">{{ $order->customer->address }}</small>
</td>
<td class="text-muted">Invoice #</td>
<td>{{ $order->invoice_id !== 0 ? $order->invoice_id : "No Invoice" }}</td>
</tr>
<tr>
<td class="text-muted">Status</td>
<td>{!! App\Http\Helpers\Helper::OrderStatus($order->status) !!}</td>
<td class="text-muted">IP Address</td>
<td>{{ $order->client_ip }}</td>
</tr>
<tr>
<td class="text-muted">Order Placed By</td>
<td>
@if($order->user)
{{ $order->user->username }} (#ID: {{ $order->user->id }})
<br>
<small class="text-muted">{{ $order->user->email }}</small>
@endif
</td>
<td class="text-muted">Promotion Code</td>
<td>{{ $order->discount?->code }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="card card-outline card-primary">
<div class="card-header bg-white">
<h5 class="card-title m-0">Order Item</h5>
</div>
<div class="card-body p-0">
<table class="table table-invoice table-bordered mb-0">
<thead>
<tr>
<th>Item</th>
<th>Description</th>
<th>Billing Cycle</th>
<th>Amount</th>
<th style="width: 100px">Status</th>
<th style="width: 120px">Payment Status</th>
</tr>
</thead>
<tbody>
@if($order->orderItem->isNotEmpty())
@foreach($order->orderItem->all() as $item)
<tr>
<td class="text-center">
@if($item->type && in_array($item->Type->id, [3, 4]))
<a href="{{ route('customer.product', ['userid' => $item->customer_id, 'product' => $item->relid, 'type' => $item->type_id]) }}">
{{ $item->type->name }}
</a>
@else
{{ $item->type->name }}
@endif
</td>
<td>{{ $item->description }}</td>
<td class="text-center">{{ Helper::billing_cycle($item->billing) }}</td>
<td class="text-center">@money($item->amount) đ</td>
<td class="text-center">
@if($item->status)
{!! $item->status->getStatus() !!}
@endif
</td>
<td class="text-center">
@if($order->invoice_id !== 0)
{!! $order->invoice->getStatus() !!}
@else
No Invoice Due
@endif
</td>
</tr>
@endforeach
@endif
</tbody>
</table>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card card-outline card-primary">
<div class="card-header bg-white">
<h5 class="card-title m-0">Order Actions</h5>
</div>
<div class="card-body">
@if($order->status !== 1)
<div class="form-group mb-3">
<label class="box-input__checker">
<span>Auto Create Product (Hosting/VPS)</span>
<input type="checkbox" name="module_checker" checked>
<span class="checkmark"></span>
</label>
</div>
@endif
<div class="d-flex flex-column gap-2">
@if($order->status !== 1)
<x-button-crm type="submit" name="action" value="accept" variant="success" icon="check-circle">
Accept Order
</x-button-crm>
@endif
<x-button-crm type="submit" name="action" value="cancel" variant="secondary" icon="x-circle">
Cancel Order
</x-button-crm>
@if(auth()->guard('admins')->user()->can("delete order"))
<form method="POST" action="{{ route('administrator.pages.order.destroy') }}" class="d-inline">
@csrf
@method('DELETE')
<input type="hidden" name="order" value="{{ $order->id }}">
<x-button-crm type="submit" variant="danger" icon="trash-2">
Delete Order
</x-button-crm>
</form>
@endif
</div>
</div>
</div>
</div>
</div>
<x-fixed-action-bar>
<x-button-crm type="button" variant="secondary" size="sm" icon="arrow-left"
route="administrator.pages.order.index">Back</x-button-crm>
</x-fixed-action-bar>
</form>
@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 Order
management department</h5>
</div>
@endif
@endsection
@push('custom-scripts')
<script>
document.addEventListener('DOMContentLoaded', function() {
const moduleChecker = document.querySelector('input[name="module_checker"]');
const moduleInput = document.querySelector('input[name="module"]');
if (moduleChecker && moduleInput) {
moduleChecker.addEventListener('change', function() {
moduleInput.value = this.checked ? '0' : '1';
});
}
});
</script>
@endpush