diff --git a/app/Http/Controllers/ProductController.php b/app/Http/Controllers/ProductController.php index faebccf..7e3c825 100644 --- a/app/Http/Controllers/ProductController.php +++ b/app/Http/Controllers/ProductController.php @@ -43,6 +43,14 @@ class ProductController extends Controller ->sortBy('name') ->values(); + case 'App\Models\Product\Phone': + return Product\Phone::select(['id','supplier_item_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); } @@ -91,7 +99,8 @@ class ProductController extends Controller if (! $o->exists && $request->name) $o = Product::where('name',$request->name)->firstOrNew(); - return view('a.product.details') + return view('product.details') + ->with('breadcrumb',collect(['Products'=>url('a/product')])) ->with('o',$o); } @@ -103,6 +112,6 @@ class ProductController extends Controller */ public function home() { - return view('a.product.home'); + return view('product.home'); } } \ No newline at end of file diff --git a/app/Models/Service.php b/app/Models/Service.php index d9d9308..fe0ae9b 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -775,7 +775,7 @@ class Service extends Model implements IDs */ public function getNameShortAttribute() { - return $this->type->getServiceNameAttribute() ?: 'SID:'.$this->sid; + return ($this->type && $this->type->getServiceNameAttribute()) ? $this->type->getServiceNameAttribute() : 'SID:'.$this->sid; } /** @@ -790,7 +790,7 @@ class Service extends Model implements IDs */ public function getNameDetailAttribute() { - return $this->type->getServiceDescriptionAttribute(); + return ($this->type && $this->type->getServiceDescriptionAttribute()) ? $this->type->getServiceDescriptionAttribute() : 'No Description'; } /** diff --git a/app/Models/SupplierDetail.php b/app/Models/SupplierDetail.php index 19887a7..1661ed1 100644 --- a/app/Models/SupplierDetail.php +++ b/app/Models/SupplierDetail.php @@ -53,6 +53,10 @@ class SupplierDetail extends Model $item = $this->broadbands->where('id',$id); break; + case 'phone': + $item = $this->phones->where('id',$id); + break; + default: throw new \Exception('Unknown type: '.$type); } diff --git a/resources/views/theme/backend/adminlte/a/product/home.blade.php b/resources/views/theme/backend/adminlte/a/product/home.blade.php deleted file mode 100644 index 9538acc..0000000 --- a/resources/views/theme/backend/adminlte/a/product/home.blade.php +++ /dev/null @@ -1,70 +0,0 @@ -@extends('adminlte::layouts.app') - -@section('htmlheader_title') - Product -@endsection -@section('page_title') - Product -@endsection - -@section('contentheader_title') - Product -@endsection -@section('contentheader_description') -@endsection - -@section('main-content') -
-
- -
-
-

Product Configuration

-
- -
-
- @csrf - -
-
-
- - - - @error('name') - {{ $message }} - @else - Product Name is required. - @enderror - - Product Name -
-
-
-
-
-
-
-
-@endsection - -@section('page-scripts') - @css(select2) - @js(select2,autofocus) - - -@endsection \ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/a/product/widgets/detail.blade.php b/resources/views/theme/backend/adminlte/a/product/widgets/detail.blade.php deleted file mode 100644 index d379322..0000000 --- a/resources/views/theme/backend/adminlte/a/product/widgets/detail.blade.php +++ /dev/null @@ -1,155 +0,0 @@ - -
-
-

Product Details

-
- @if(session()->has('success')) - {{ session()->get('success') }} - @endif - -
- @csrf - -
-
-
- -
-
- - - - @error('description.name') - {{ $message }} - @else - Product Name required. - @enderror - -
-
- - -
-
-
- active) ? 'checked' : '' }}> - -
-
-
-
-
-
- -
- -
-
- - - - @error('model') - {{ $message }} - @else - Product Type required. - @enderror - -
-
-
- -
- -
-
- - - - @error('model_id') - {{ $message }} - @else - Supplied Product required. - @enderror - -
-
-
- -
- -
- Cancel - @can('wholesaler') - - @endcan -
-
-
-
-
- -@section('page-scripts') - @css(select2) - @js(select2,autofocus) - - -@endsection \ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/a/product/details.blade.php b/resources/views/theme/backend/adminlte/product/details.blade.php similarity index 92% rename from resources/views/theme/backend/adminlte/a/product/details.blade.php rename to resources/views/theme/backend/adminlte/product/details.blade.php index 5771cc8..bf8c89e 100644 --- a/resources/views/theme/backend/adminlte/a/product/details.blade.php +++ b/resources/views/theme/backend/adminlte/product/details.blade.php @@ -33,11 +33,11 @@
- @include('a.product.widgets.detail') + @include('product.widget.detail')
- @include('a.product.widgets.services') + @include('product.widget.services')
diff --git a/resources/views/theme/backend/adminlte/product/home.blade.php b/resources/views/theme/backend/adminlte/product/home.blade.php new file mode 100644 index 0000000..7d8f325 --- /dev/null +++ b/resources/views/theme/backend/adminlte/product/home.blade.php @@ -0,0 +1,61 @@ +@extends('adminlte::layouts.app') + +@section('htmlheader_title') + Product +@endsection +@section('page_title') + Product +@endsection + +@section('contentheader_title') + Product +@endsection +@section('contentheader_description') +@endsection + +@section('main-content') +
+
+ +
+
+

Product Configuration

+
+ +
+
+ @csrf + +
+
+ @include('adminlte::widget.form_select',[ + 'label'=>'Product', + 'icon'=>'fas fa-list', + 'id'=>'product_id', + 'old'=>'product_id', + 'name'=>'product_id', + 'groupby'=>'active', + 'options'=>\App\Models\Product::get()->sortBy(function($item) { return ($item->active ? '0' : '1').$item->name; })->transform(function($item) { return ['id'=>$item->id,'value'=>$item->name,'active'=>$item->active]; }), + 'value'=>'', + ]) +
+
+
+
+
+
+
+@endsection + +@section('page-scripts') + @css(select2) + @js(select2,autofocus) + + +@append \ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/product/widget/detail.blade.php b/resources/views/theme/backend/adminlte/product/widget/detail.blade.php new file mode 100644 index 0000000..3c29ab5 --- /dev/null +++ b/resources/views/theme/backend/adminlte/product/widget/detail.blade.php @@ -0,0 +1,140 @@ + +
+
+

Product Details

+
+ @if(session()->has('success')) + {{ session()->get('success') }} + @endif + +
+ @csrf + +
+ +
+ @include('adminlte::widget.form_text',[ + 'label'=>'Product Name', + 'icon'=>'fas fa-atom', + 'id'=>'name', + 'old'=>'description.name', + 'name'=>'description[name]', + 'value'=>$o->name ?? '', + ]) +
+ + +
+ @include('adminlte::widget.form_toggle',[ + 'label'=>'Active', + 'id'=>'active', + 'old'=>'active', + 'name'=>'active', + 'value'=>$o->active ?? '', + ]) +
+
+ +
+ +
+ @include('adminlte::widget.form_select',[ + 'label'=>'Product Type', + 'icon'=>'fas fa-list', + 'id'=>'model', + 'old'=>'model', + 'name'=>'model', + 'options'=>$o->availableTypes()->transform(function($item) { return ['id'=>$item,'value'=>$item]; }), + 'value'=>get_class($o->type) ?? '', + ]) +
+
+ +
+ +
+
+ +
+
+ +
+ + + @error('model_id') + {{ $message }} + @enderror + +
+
+
+
+ +
+ +
+ Cancel + @can('wholesaler') + + @endcan +
+
+
+
+
+ +@section('page-scripts') + @css(select2) + @js(select2,autofocus) + + +@append \ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/product/widget/services.blade.php b/resources/views/theme/backend/adminlte/product/widget/services.blade.php new file mode 100644 index 0000000..7adb7c7 --- /dev/null +++ b/resources/views/theme/backend/adminlte/product/widget/services.blade.php @@ -0,0 +1,35 @@ + +
+ @if(count($o->services)) +
+ + + + + + + + + + + + + + @foreach ($o->services as $so) + + + + + + + + + @endforeach + +
IDDate StartDate StopData InvoicedActiveCharge
{{ $so->sid }}{{ $so->start_at ? $so->start_at->format('Y-m-d') : '-' }}{{ $so->stop_at ? $so->stop_at->format('Y-m-d') : '-' }}{{ $so->invoice_to ? $so->invoice_to->format('Y-m-d') : '-' }}{{ $so->active ? 'YES' : 'NO' }}{{ number_format($so->billing_charge,2) }}
+
+ + @else +

No services use this product.

+ @endif +
\ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/service/widget/domain/update.blade.php b/resources/views/theme/backend/adminlte/service/widget/domain/update.blade.php index 57a4b1f..917c2f4 100644 --- a/resources/views/theme/backend/adminlte/service/widget/domain/update.blade.php +++ b/resources/views/theme/backend/adminlte/service/widget/domain/update.blade.php @@ -62,7 +62,7 @@ 'label'=>'Registrar Account', 'icon'=>'fas fa-user-circle', 'id'=>'registrar_account', - 'old'=>'domain.registrar_account', + 'old'=>'domain.registrar_account', 'name'=>'domain[registrar_account]', 'value'=>$o->registrar_account ?? '', ])