From f8453ae3919f9c6f3a654bd18f4af9efe8fd2895 Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 1 Aug 2024 17:34:31 +1000 Subject: [PATCH] More work on moving service updates to use components, move 'host' to 'hosting', move some redundant views --- app/Http/Controllers/ServiceController.php | 15 +- app/Models/Service/Type.php | 6 +- composer.lock | 6 +- .../views/components/form/domain.blade.php | 30 ++++ .../a/charge/widgets/pending.blade.php | 37 ----- .../backend/adminlte/auth/terms.blade.php | 19 --- .../common/invoice/widget/list.blade.php | 43 ------ .../adminlte/service/domain/list.blade.php | 16 +- .../adminlte/service/email/list.blade.php | 16 +- .../service/{host => hosting}/list.blade.php | 16 +- .../service/widget/admin/movement.blade.php | 4 - .../service/widget/broadband/change.blade.php | 1 + .../service/widget/broadband/update.blade.php | 2 +- .../service/widget/domain/update.blade.php | 103 ++----------- .../service/widget/email/update.blade.php | 140 ++---------------- .../service/widget/host/update.blade.php | 98 ------------ .../{host => hosting}/details.blade.php | 0 .../service/widget/hosting/update.blade.php | 44 ++++++ 18 files changed, 120 insertions(+), 476 deletions(-) create mode 100644 resources/views/components/form/domain.blade.php delete mode 100644 resources/views/theme/backend/adminlte/a/charge/widgets/pending.blade.php delete mode 100644 resources/views/theme/backend/adminlte/auth/terms.blade.php delete mode 100644 resources/views/theme/backend/adminlte/common/invoice/widget/list.blade.php rename resources/views/theme/backend/adminlte/service/{host => hosting}/list.blade.php (85%) delete mode 100644 resources/views/theme/backend/adminlte/service/widget/host/update.blade.php rename resources/views/theme/backend/adminlte/service/widget/{host => hosting}/details.blade.php (100%) create mode 100644 resources/views/theme/backend/adminlte/service/widget/hosting/update.blade.php diff --git a/app/Http/Controllers/ServiceController.php b/app/Http/Controllers/ServiceController.php index b00e19a..9f0744d 100644 --- a/app/Http/Controllers/ServiceController.php +++ b/app/Http/Controllers/ServiceController.php @@ -8,7 +8,6 @@ use Illuminate\Http\Request; use Illuminate\Support\Arr; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Auth; -use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Session; @@ -18,7 +17,7 @@ use Illuminate\Validation\ValidationException; use Illuminate\View\View; use Symfony\Component\HttpKernel\Exception\HttpException; -use App\Http\Requests\{ChargeAdd,ServiceChangeRequest}; +use App\Http\Requests\ServiceChangeRequest; use App\Mail\{CancelRequest,ChangeRequest}; use App\Models\{Charge,Invoice,Product,Service}; @@ -274,7 +273,7 @@ class ServiceController extends Controller */ public function domain_list(): View { - $o = Service\Domain::serviceActive() + $o = Service\Domain::ServiceActive() ->serviceUserAuthorised(Auth::user()) ->select('service_domain.*') ->join('services',['services.id'=>'service_domain.service_id']) @@ -287,8 +286,7 @@ class ServiceController extends Controller public function email_list(): View { - // @todo Need to add the with path when calculating next_billed and price - $o = Service\Email::serviceActive() + $o = Service\Email::ServiceActive() ->serviceUserAuthorised(Auth::user()) ->select('service_email.*') ->join('services',['services.id'=>'service_email.service_id']) @@ -314,15 +312,14 @@ class ServiceController extends Controller public function hosting_list(): View { - // @todo Need to add the with path when calculating next_billed and price - $o = Service\Host::serviceActive() + $o = Service\Host::ServiceActive() ->serviceUserAuthorised(Auth::user()) ->select('service_host.*') ->join('services',['services.id'=>'service_host.service_id']) ->with(['service.account','service.product.type.supplied.supplier_detail.supplier','tld']) ->get(); - return view('theme.backend.adminlte.service.host.list') + return view('theme.backend.adminlte.service.hosting.list') ->with('o',$o); } @@ -471,7 +468,7 @@ class ServiceController extends Controller $o->type->save(); if ($validated->has('invoice_next_at')) - $o->invoice_next_at = $validated->get('invoice_next_at'); + $o->invoice_next_at = $validated?->get('invoice_next_at'); if ($validated->has('recur_schedule')) $o->recur_schedule = $validated->get('recur_schedule'); diff --git a/app/Models/Service/Type.php b/app/Models/Service/Type.php index 45b0847..3aada86 100644 --- a/app/Models/Service/Type.php +++ b/app/Models/Service/Type.php @@ -64,12 +64,14 @@ abstract class Type extends Model implements ServiceItem public function hasExpired(): bool { - return (! $this->inContract()) && ($this->service->invoice_next_at && $this->service->invoice_next_at->isPast()); + return (! $this->inContract()) + && ($this->service->invoice_next && $this->service->invoice_next->isPast()); } public function inContract(): bool { - return $this->expire_at && $this->expire_at->isFuture(); + return $this->expire_at + && $this->expire_at->isFuture(); } /* ATTRIBUTES */ diff --git a/composer.lock b/composer.lock index 5d15a40..26b6308 100644 --- a/composer.lock +++ b/composer.lock @@ -3056,11 +3056,11 @@ }, { "name": "leenooks/laravel", - "version": "11.1.8", + "version": "11.1.9", "source": { "type": "git", "url": "https://gitea.dege.au/laravel/leenooks.git", - "reference": "8acc3a91af7e4ce622aec60934a2f942b4a19eda" + "reference": "293d9913c65143f00e3051bff32d15c97644bd15" }, "type": "library", "extra": { @@ -3093,7 +3093,7 @@ "laravel", "leenooks" ], - "time": "2024-07-31T12:40:35+00:00" + "time": "2024-08-01T07:32:20+00:00" }, { "name": "leenooks/passkey", diff --git a/resources/views/components/form/domain.blade.php b/resources/views/components/form/domain.blade.php new file mode 100644 index 0000000..1f91138 --- /dev/null +++ b/resources/views/components/form/domain.blade.php @@ -0,0 +1,30 @@ +@use(App\Models\TLD) + +
+ @if(isset($label)) + + @endif +
+
+ +
+ +
+ . +
+ + + + @error($name.'.domain_name') + {{ $message }} + @else + Domain Name is required. + @enderror + +
+ Domain Name +
\ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/a/charge/widgets/pending.blade.php b/resources/views/theme/backend/adminlte/a/charge/widgets/pending.blade.php deleted file mode 100644 index 106513e..0000000 --- a/resources/views/theme/backend/adminlte/a/charge/widgets/pending.blade.php +++ /dev/null @@ -1,37 +0,0 @@ -@if(($x=$list)->count()) -
-
-

Pending Charges

-
- -
- - - - - - - - - - - - - - - @foreach ($x as $co) - - - - - - - - - - @endforeach - -
IDDate CreatedDate ChargeServiceTypeDescriptionTotal
{{ $co->id }}{{ $co->created_at->format('Y-m-d') }}{{ $co->charge_at ? $co->charge_at->format('Y-m-d') : '-' }}{{ $co->service->sid }}{{ $co->type }}{{ $co->description }}{{ number_format($co->quantity*$co->amount,2) }}
-
-
-@endif \ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/auth/terms.blade.php b/resources/views/theme/backend/adminlte/auth/terms.blade.php deleted file mode 100644 index 06eb606..0000000 --- a/resources/views/theme/backend/adminlte/auth/terms.blade.php +++ /dev/null @@ -1,19 +0,0 @@ - - \ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/common/invoice/widget/list.blade.php b/resources/views/theme/backend/adminlte/common/invoice/widget/list.blade.php deleted file mode 100644 index a9f14d9..0000000 --- a/resources/views/theme/backend/adminlte/common/invoice/widget/list.blade.php +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - @foreach ($o->invoices as $io) - - - - - - - - - @endforeach - -
#IssuedDueTotalPaymentsOutstanding
{{ $io->id }}{{ $io->created_at->format('Y-m-d') }}{{ $io->due_at->format('Y-m-d') }}${{ number_format($io->total,2) }}${{ number_format($io->paid,2) }}${{ number_format($io->due,2) }}
- -@section('page-scripts') - @css(datatables,bootstrap4) - @js(datatables,bootstrap4|responsive) - - -@append \ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/service/domain/list.blade.php b/resources/views/theme/backend/adminlte/service/domain/list.blade.php index f9ff98f..7d1ea8d 100644 --- a/resources/views/theme/backend/adminlte/service/domain/list.blade.php +++ b/resources/views/theme/backend/adminlte/service/domain/list.blade.php @@ -46,7 +46,7 @@ {{ $oo->registrar->name }} {{ $oo->registrar_ns }} @if ($oo->service->isBilled()) {{ $oo->service->invoice_next->format('Y-m-d') }}@else - @endif - @if (! $oo->service->external_billing)${{ number_format($oo->service->next_invoice_items(TRUE)->sum('total'),2) }}@else - @endif + @if (! $oo->service->external_billing)${{ number_format($oo->service->next_invoice_items()->sum('total'),2) }}@else - @endif {{ $oo->service->billing_interval_string }} @endforeach @@ -58,15 +58,9 @@ @endsection -@section('page-scripts') - @css(datatables,bootstrap4|rowgroup) - @js(datatables,bootstrap4|rowgroup) +@pa(datatables,rowgroup) - +@section('page-scripts') @append \ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/service/email/list.blade.php b/resources/views/theme/backend/adminlte/service/email/list.blade.php index 312bbc2..15fdded 100644 --- a/resources/views/theme/backend/adminlte/service/email/list.blade.php +++ b/resources/views/theme/backend/adminlte/service/email/list.blade.php @@ -50,7 +50,7 @@ @if($oo->admin_user){{ $oo->admin_user }}/{{ $oo->admin_pass }}@else   @endif {{ number_format($oo->accounts ?: 0) }} @if ($oo->service->isBilled()) {{ $oo->service->invoice_next->format('Y-m-d') }} @else - @endif - @if (! $oo->service->external_billing)${{ number_format($oo->service->next_invoice_items(TRUE)->sum('total'),2) }}@else - @endif + @if (! $oo->service->external_billing)${{ number_format($oo->service->next_invoice_items()->sum('total'),2) }}@else - @endif {{ $oo->service->billing_interval_string }} @endforeach @@ -62,15 +62,9 @@ @endsection -@section('page-scripts') - @css(datatables,bootstrap4|rowgroup) - @js(datatables,bootstrap4|rowgroup) +@pa(datatables,rowgroup) - +@section('page-scripts') @append \ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/service/host/list.blade.php b/resources/views/theme/backend/adminlte/service/hosting/list.blade.php similarity index 85% rename from resources/views/theme/backend/adminlte/service/host/list.blade.php rename to resources/views/theme/backend/adminlte/service/hosting/list.blade.php index d8d9357..4cd237c 100644 --- a/resources/views/theme/backend/adminlte/service/host/list.blade.php +++ b/resources/views/theme/backend/adminlte/service/hosting/list.blade.php @@ -44,7 +44,7 @@ {{ $oo->service_expire ? $oo->service_expire->format('Y-m-d') : '-' }} {{ $oo->service->product->supplier->name }} @if ($oo->service->isBilled()) {{ $oo->service->invoice_next->format('Y-m-d') }}@else - @endif - @if (! $oo->service->external_billing)${{ number_format($oo->service->next_invoice_items(TRUE)->sum('total'),2) }}@else - @endif + @if (! $oo->service->external_billing)${{ number_format($oo->service->next_invoice_items()->sum('total'),2) }}@else - @endif {{ $oo->service->billing_interval_string }} @endforeach @@ -56,15 +56,9 @@ @endsection -@section('page-scripts') - @css(datatables,bootstrap4|rowgroup) - @js(datatables,bootstrap4|rowgroup) +@pa(datatables,rowgroup) - +@section('page-scripts') @append \ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/service/widget/admin/movement.blade.php b/resources/views/theme/backend/adminlte/service/widget/admin/movement.blade.php index 5405b7c..d91af5c 100644 --- a/resources/views/theme/backend/adminlte/service/widget/admin/movement.blade.php +++ b/resources/views/theme/backend/adminlte/service/widget/admin/movement.blade.php @@ -72,10 +72,6 @@ }, orderFixed: [1, 'asc'] }); - - $('#service_movements tbody').on('click','tr', function () { - $(this).toggleClass('selected'); - }); }); @append \ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/service/widget/broadband/change.blade.php b/resources/views/theme/backend/adminlte/service/widget/broadband/change.blade.php index 51f3b24..345dad1 100644 --- a/resources/views/theme/backend/adminlte/service/widget/broadband/change.blade.php +++ b/resources/views/theme/backend/adminlte/service/widget/broadband/change.blade.php @@ -26,6 +26,7 @@ NOTE: A plan setup fee is normally not applicable to Broadband changes, but a plan change fee normally is. + @section('page-scripts') -@append \ No newline at end of file + \ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/service/widget/host/update.blade.php b/resources/views/theme/backend/adminlte/service/widget/host/update.blade.php deleted file mode 100644 index 09f9071..0000000 --- a/resources/views/theme/backend/adminlte/service/widget/host/update.blade.php +++ /dev/null @@ -1,98 +0,0 @@ - -
-
-
- -
-
- -
- - -
- . -
- - - - - @error('domain_name') - {{ $message }} - @enderror - @error('tld_id') - {{ $message }} - @enderror - -
-
-
- -
- @include('adminlte::widget.form_date',[ - 'label'=>'Expiry', - 'id'=>'expire_at', - 'old'=>'host.expire_at', - 'name'=>'host[expire_at]', - 'value'=>$o->expire_at ? $o->expire_at->format('Y-m-d') : ($o->connect_at ? $o->connect_at->addMonths($o->contract_term)->format('Y-m-d') : ''), - ]) -
-
- -
-

Hosting Details

- -
-
- @include('adminlte::widget.form_select',[ - 'label'=>'Hosting Server', - 'icon'=>'fas fa-handshake', - 'id'=>'supplier_host_server_id', - 'old'=>'host.supplier_host_server_id', - 'name'=>'host[supplier_host_server_id]', - 'options'=>\App\Models\SupplierHostServer::active()->orderBy('name')->get()->transform(function($item) { return ['id'=>$item->id,'value'=>$item->name]; }), - 'value'=>$o->supplier_host_server_id ?? '', - ]) -
-
- -
-
- @include('adminlte::widget.form_text',[ - 'label'=>'Admin User', - 'icon'=>'fas fa-user', - 'id'=>'host_username', - 'old'=>'host.host_username', - 'name'=>'host[host_username]', - 'value'=>$o->host_username ?? '', - ]) -
- -
- @include('adminlte::widget.form_text',[ - 'label'=>'Admin Password', - 'icon'=>'fas fa-lock', - 'id'=>'host_password', - 'old'=>'host.host_password', - 'name'=>'host[host_password]', - 'value'=>$o->host_password ?? '', - ]) -
-
- -@section('page-scripts') - @css(select2) - @js(select2,autofocus) - - -@append \ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/service/widget/host/details.blade.php b/resources/views/theme/backend/adminlte/service/widget/hosting/details.blade.php similarity index 100% rename from resources/views/theme/backend/adminlte/service/widget/host/details.blade.php rename to resources/views/theme/backend/adminlte/service/widget/hosting/details.blade.php diff --git a/resources/views/theme/backend/adminlte/service/widget/hosting/update.blade.php b/resources/views/theme/backend/adminlte/service/widget/hosting/update.blade.php new file mode 100644 index 0000000..803705b --- /dev/null +++ b/resources/views/theme/backend/adminlte/service/widget/hosting/update.blade.php @@ -0,0 +1,44 @@ +@use(App\Models\SupplierHostServer) + + +
+
+ +
+ +
+ +
+
+ +
+

Hosting Details

+ +
+
+ +
+
+ +
+
+ +
+ +
+ +
+
+ +@pa(select2,autofocus) + +@section('page-scripts') + +@append \ No newline at end of file