From 9659621ba0d2788bab4ad9c053853233a1ef05a1 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sat, 2 Apr 2022 20:26:59 +1100 Subject: [PATCH] Added hosting report and enabled updating hosting details --- app/Http/Controllers/ProductController.php | 8 + app/Http/Controllers/ServiceController.php | 14 ++ app/Models/Product.php | 12 +- app/Models/Service/Host.php | 7 +- .../a/service/widgets/email/update.blade.php | 7 +- .../a/service/widgets/host/update.blade.php | 139 ++++++++++++++++++ .../adminlte/r/service/domain/list.blade.php | 2 +- .../adminlte/r/service/email/list.blade.php | 6 +- .../adminlte/r/service/host/list.blade.php | 88 +++++++++++ .../layouts/partials/sidebarmenu.blade.php | 10 +- routes/web.php | 1 + 11 files changed, 275 insertions(+), 19 deletions(-) create mode 100644 resources/views/theme/backend/adminlte/a/service/widgets/host/update.blade.php create mode 100644 resources/views/theme/backend/adminlte/r/service/host/list.blade.php diff --git a/app/Http/Controllers/ProductController.php b/app/Http/Controllers/ProductController.php index 8eb09c2..929bf57 100644 --- a/app/Http/Controllers/ProductController.php +++ b/app/Http/Controllers/ProductController.php @@ -35,6 +35,14 @@ class ProductController extends Controller ->sortBy('name') ->values(); + case 'App\Models\Product\Host': + return Product\Host::select(['id','supplier_host_id']) + ->with(['supplied.supplier_detail.supplier']) + ->get() + ->map(function($item) { return ['id'=>$item->id,'name'=>sprintf('%s: %s',$item->supplied->supplier_detail->supplier->name,$item->supplied->name)]; }) + ->sortBy('name') + ->values(); + default: throw new \Exception('Unknown type: '.$request->type); } diff --git a/app/Http/Controllers/ServiceController.php b/app/Http/Controllers/ServiceController.php index 7d44e40..60f6426 100644 --- a/app/Http/Controllers/ServiceController.php +++ b/app/Http/Controllers/ServiceController.php @@ -269,6 +269,20 @@ class ServiceController extends Controller ->with('o',$o); } + public function hosting_list(): View + { + // @todo Need to add the with path when calculating next_billed and price + $o = Service\Host::serviceActive() + ->serviceUserAuthorised(Auth::user()) + ->select('ab_service__hosting.*') + ->join('ab_service',['ab_service.id'=>'ab_service__hosting.service_id']) + ->with(['service.account','service.product.type.supplied.supplier_detail.supplier','tld']) + ->get(); + + return view('r.service.host.list') + ->with('o',$o); + } + /** * Update details about a service * diff --git a/app/Models/Product.php b/app/Models/Product.php index 11d6bea..f14f900 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -245,7 +245,7 @@ class Product extends Model implements IDs * Get our product type * * @return string - * @todo is the test of type and type->supplied necessary? + * @todo is the test of type and type->supplied necessary? (It seems some hosting entries have no type, are they old?) */ public function getProductTypeAttribute(): string { @@ -257,9 +257,9 @@ class Product extends Model implements IDs * * @return Model */ - public function getSupplierAttribute(): Model + public function getSupplierAttribute(): ?Model { - return $this->getSuppliedAttribute()->supplier_detail->supplier; + return $this->getSuppliedAttribute() ? $this->getSuppliedAttribute()->supplier_detail->supplier : NULL; } /** @@ -267,9 +267,9 @@ class Product extends Model implements IDs * * @return Model */ - public function getSuppliedAttribute(): Model + public function getSuppliedAttribute(): ?Model { - return $this->type->supplied; + return $this->type && $this->type->supplied ? $this->type->supplied : NULL; } /** @@ -401,7 +401,7 @@ class Product extends Model implements IDs */ public function hasUsage(): bool { - return $this->type->hasUsage(); + return $this->type && $this->type->hasUsage(); } /** diff --git a/app/Models/Service/Host.php b/app/Models/Service/Host.php index 0aacb5e..45f4c3b 100644 --- a/app/Models/Service/Host.php +++ b/app/Models/Service/Host.php @@ -2,15 +2,18 @@ namespace App\Models\Service; +use Carbon\Carbon; + use App\Interfaces\ServiceItem; use App\Models\Base\ServiceType; use App\Models\DomainTld; use App\Models\HostServer; use App\Traits\NextKey; -use Carbon\Carbon; +use App\Traits\{ScopeServiceActive,ScopeServiceUserAuthorised}; class Host extends ServiceType implements ServiceItem { + use ScopeServiceActive,ScopeServiceUserAuthorised; use NextKey; const RECORD_ID = 'service__hosting'; @@ -38,7 +41,7 @@ class Host extends ServiceType implements ServiceItem public function getServiceExpireAttribute(): Carbon { - // TODO: Implement getServiceExpireAttribute() method. + return $this->host_expire; } public function getServiceNameAttribute(): string diff --git a/resources/views/theme/backend/adminlte/a/service/widgets/email/update.blade.php b/resources/views/theme/backend/adminlte/a/service/widgets/email/update.blade.php index 38629fc..26d275b 100644 --- a/resources/views/theme/backend/adminlte/a/service/widgets/email/update.blade.php +++ b/resources/views/theme/backend/adminlte/a/service/widgets/email/update.blade.php @@ -149,11 +149,8 @@ @append \ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/a/service/widgets/host/update.blade.php b/resources/views/theme/backend/adminlte/a/service/widgets/host/update.blade.php new file mode 100644 index 0000000..4f1a606 --- /dev/null +++ b/resources/views/theme/backend/adminlte/a/service/widgets/host/update.blade.php @@ -0,0 +1,139 @@ + +
+ +
+
+ +
+
+ +
+ +
+ . +
+ + + + @error('host.domain_name') + {{ $message }} + @else + Domain Name is required. + @enderror + +
+ Domain Name +
+
+ + +
+
+ +
+
+ +
+ + + @error('host.host_expire') + {{ $message }} + @enderror + +
+ Hosting Expires +
+
+
+ +
+ {{-- + +
+
+ +
+
+ +
+ + + @error('host.admin_url') + {{ $message }} + @enderror + +
+ Admin URL +
+
+ --}} +
+ +
+ +
+
+ +
+
+ +
+ + + @error('host.host_username') + {{ $message }} + @enderror + +
+ Admin USER +
+
+ + +
+
+ +
+
+ +
+ + + @error('host.host_password') + {{ $message }} + @enderror + +
+ Admin PASSWORD +
+
+
+ +@section('page-scripts') + @css(select2) + @js(select2,autofocus) + + + + +@append \ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/r/service/domain/list.blade.php b/resources/views/theme/backend/adminlte/r/service/domain/list.blade.php index 64bb547..0e5fb4e 100644 --- a/resources/views/theme/backend/adminlte/r/service/domain/list.blade.php +++ b/resources/views/theme/backend/adminlte/r/service/domain/list.blade.php @@ -80,7 +80,7 @@ ], }); - $('#invoices_due tbody').on('click','tr', function () { + $('tbody').on('click','tr', function () { $(this).toggleClass('selected'); }); }); diff --git a/resources/views/theme/backend/adminlte/r/service/email/list.blade.php b/resources/views/theme/backend/adminlte/r/service/email/list.blade.php index b13d914..475a724 100644 --- a/resources/views/theme/backend/adminlte/r/service/email/list.blade.php +++ b/resources/views/theme/backend/adminlte/r/service/email/list.blade.php @@ -19,7 +19,7 @@
- +
@@ -71,7 +71,7 @@ +@append \ No newline at end of file diff --git a/resources/views/vendor/adminlte/layouts/partials/sidebarmenu.blade.php b/resources/views/vendor/adminlte/layouts/partials/sidebarmenu.blade.php index 7dc56d8..e44a587 100644 --- a/resources/views/vendor/adminlte/layouts/partials/sidebarmenu.blade.php +++ b/resources/views/vendor/adminlte/layouts/partials/sidebarmenu.blade.php @@ -107,8 +107,8 @@ @can('reseller') - + + @endcan \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 27687b9..4df6a8b 100644 --- a/routes/web.php +++ b/routes/web.php @@ -81,6 +81,7 @@ Route::group(['middleware'=>['theme:adminlte-be','auth','role:reseller'],'prefix Route::group(['middleware'=>['theme:adminlte-be','auth','role:reseller'],'prefix'=>'report'],function() { Route::get('domain',[ServiceController::class,'domain_list']); Route::get('email',[ServiceController::class,'email_list']); + Route::get('hosting',[ServiceController::class,'hosting_list']); }); // Charges on an account
Service ID