diff --git a/app/Http/Controllers/SupplierController.php b/app/Http/Controllers/SupplierController.php index 718483f..27f1cd7 100644 --- a/app/Http/Controllers/SupplierController.php +++ b/app/Http/Controllers/SupplierController.php @@ -4,10 +4,11 @@ namespace App\Http\Controllers; use Carbon\Carbon; use Illuminate\Http\Request; +use Illuminate\Support\Arr; use App\Http\Requests\{SupplierAddEdit,SupplierProductAddEdit}; -use App\Models\{Cost,Supplier,SupplierDetail}; use App\Jobs\ImportCosts; +use App\Models\{Cost,Supplier,SupplierDetail}; class SupplierController extends Controller { @@ -20,9 +21,7 @@ class SupplierController extends Controller */ public function addedit(SupplierAddEdit $request,Supplier $o) { - $this->middleware(['auth','wholesaler']); - - foreach ($request->except(['_token','supplier_details','api_key','api_secret','submit']) as $key => $item) + foreach (Arr::except($request->validated(),['supplier_details','api_key','api_secret','submit']) as $key => $item) $o->{$key} = $item; $o->active = (bool)$request->active; @@ -51,19 +50,6 @@ class SupplierController extends Controller ->with('success','Supplier Saved'); } - /** - * Site up site wide suppliers, or a site's supplier details - * - * @note This method is protected by the routes - * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View - */ - public function admin_home() - { - $this->middleware(['auth','wholesaler']); - - return view('theme.backend.adminlte.supplier.home'); - } - /** * Show the suppliers invoice * @@ -99,19 +85,9 @@ class SupplierController extends Controller $filename, )->onQueue('low'); - return redirect()->back()->with('success','File uploaded'); - } - - /** - * New Product from a supplier - * - * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View - */ - public function product_add() - { - return view('theme.backend.adminlte.supplier.product.addedit') - ->with('o',new Supplier) - ->with('oo',NULL); + return redirect() + ->back() + ->with('success','File uploaded'); } public function product_addedit(SupplierProductAddEdit $request,Supplier $o,int $id,string $type) @@ -127,7 +103,7 @@ class SupplierController extends Controller $oo = Supplier\Broadband::findOrNew($id); // @todo these are broadband requirements - get them from the broadband class. - foreach ($request->only([ + foreach (Arr::only($request->validated(),[ 'supplier_detail_id', 'product_id'. 'product_desc', @@ -151,8 +127,8 @@ class SupplierController extends Controller $oo->$key = $value; // Our boolean values - foreach ($request->only(['active','extra_shaped','extra_charged']) as $key => $value) - $oo->$key = ($value == 'on' ? 1 : 0); + foreach (Arr::only($request->validated(),['active','extra_shaped','extra_charged']) as $key => $value) + $oo->{$key} = ($value == 'on' ? 1 : 0); break; @@ -162,28 +138,11 @@ class SupplierController extends Controller $oo->save(); - return redirect()->back() + return redirect() + ->back() ->with('success','Saved'); } - /** - * Edit a supplier product - * - * @param Supplier $o - * @param int $id - * @param string $type - * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View - */ - public function product_view(Supplier $o,int $id,string $type) - { - $oo = $o->detail->find($type,$id); - $oo->load(['products.product.services.product.type']); - - return view('theme.backend.adminlte.supplier.product.addedit') - ->with('o',$o) - ->with('oo',$oo); - } - /** * Return the form for a specific product type * @@ -200,24 +159,10 @@ class SupplierController extends Controller $request->session()->flashInput($request->old); if ($o) - $o->load(['products.product.services']); + $o->load(['products.products.services']); return view('theme.backend.adminlte.supplier.product.widget.'.$type) ->with('o',$id ? $o : NULL) ->withErrors($request->errors); } - - /** - * View a supplier. - * - * @param Supplier|null $o - * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View - */ - public function view(?Supplier $o) - { - $this->middleware(['auth','wholesaler']); - - return view('theme.backend.adminlte.supplier.details') - ->with('o',$o); - } } \ No newline at end of file diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 0d8005f..40a4cbf 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -7,6 +7,8 @@ use Illuminate\Support\Facades\Route; use Illuminate\Support\ServiceProvider; use Intuit\Traits\IntuitSocialite; +use App\Models\{Checkout,Payment,Product,Service,Supplier}; + class AppServiceProvider extends ServiceProvider { use IntuitSocialite; @@ -33,9 +35,10 @@ class AppServiceProvider extends ServiceProvider $this->bootIntuitSocialite(); - Route::model('co',\App\Models\Checkout::class); - Route::model('po',\App\Models\Payment::class); - Route::model('pdo',\App\Models\Product::class); - Route::model('so',\App\Models\Service::class); + Route::model('co',Checkout::class); + Route::model('po',Payment::class); + Route::model('pdo',Product::class); + Route::model('so',Service::class); + Route::model('spo',Supplier::class); } } \ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/supplier/details.blade.php b/resources/views/theme/backend/adminlte/supplier/details.blade.php index 461ba85..986668c 100644 --- a/resources/views/theme/backend/adminlte/supplier/details.blade.php +++ b/resources/views/theme/backend/adminlte/supplier/details.blade.php @@ -1,14 +1,14 @@ @extends('adminlte::layouts.app') @section('htmlheader_title') - {{ $o->name ?: 'New Supplier' }} + {{ $spo->name ?: 'New Supplier' }} @endsection @section('page_title') - {{ $o->name ?: 'New Supplier' }} + {{ $spo->name ?: 'New Supplier' }} @endsection @section('contentheader_title') - {{ $o->name ?: 'New Supplier' }} + {{ $spo->name ?: 'New Supplier' }} @endsection @section('contentheader_description') @endsection @@ -20,7 +20,7 @@
- @if($o->exists) + @if($spo->exists)
@include('theme.backend.adminlte.supplier.widget.products')
diff --git a/resources/views/theme/backend/adminlte/supplier/home.blade.php b/resources/views/theme/backend/adminlte/supplier/home.blade.php index 633c181..7b879c9 100644 --- a/resources/views/theme/backend/adminlte/supplier/home.blade.php +++ b/resources/views/theme/backend/adminlte/supplier/home.blade.php @@ -1,3 +1,5 @@ +@use(App\Models\Supplier) + @extends('adminlte::layouts.app') @section('htmlheader_title') @@ -27,16 +29,7 @@
- @include('adminlte::widget.form_select',[ - 'label'=>'Supplier', - 'icon'=>'fas fa-handshake', - 'id'=>'supplier_id', - 'old'=>'supplier_id', - 'name'=>'supplier_id', - 'groupby'=>'active', - 'options'=>\App\Models\Supplier::orderBy('active','DESC')->orderBy('name')->get()->transform(function($item) { return ['id'=>$item->id,'value'=>$item->name,'active'=>$item->active]; }), - 'value'=>'', - ]) +
@@ -47,9 +40,6 @@ @endsection @section('page-scripts') - @css(select2) - @js(select2,autofocus) - -@endsection \ No newline at end of file +@append \ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/supplier/product/widget/broadband.blade.php b/resources/views/theme/backend/adminlte/supplier/product/widget/broadband.blade.php index 9db24e4..cbf1e77 100644 --- a/resources/views/theme/backend/adminlte/supplier/product/widget/broadband.blade.php +++ b/resources/views/theme/backend/adminlte/supplier/product/widget/broadband.blade.php @@ -1,308 +1,148 @@
-
-
- - - - @error('product_id') - {{ $message }} - @else - Supplier's Product ID - @enderror - - Supplier's Product ID -
+
+
-
-
- - - - @error('product_desc') - {{ $message }} - @else - Product Description is required - @enderror - - Supplier's Product Description as it appears on Invoices -
+
+
-
-
- active) ? 'checked' : '' }}> - + +
+ +
+
+ +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
-
- -
-
- - - - @error('base_cost') - {{ $message }} - @enderror - - Monthly Cost -
-
+
+
+ +
- -
-
- - - - @error('setup_cost') - {{ $message }} - @enderror - - Setup Cost -
-
- - -
-
- - - - @error('contract_term') - {{ $message }} - @enderror - - Term (mths) -
-
- - -
-
- - - - @error('speed') - {{ $message }} - @enderror - - Speed -
-
- - -
-
- - - - @error('technology') - {{ $message }} - @enderror - - Technology -
-
-
- -
- - -
-
-
- extra_charged) ? 'checked' : '' }}> - +
+
- -
-
- - - - @error('offpeak_start') - {{ $message }} - @enderror - - Offpeak Start -
-
- -
-
- - - - @error('offpeak_end') - {{ $message }} - @enderror - - Offpeak Ends -
-
-
- -
- -
-
-
- extra_shaped) ? 'checked' : '' }}> - -
-
-
- -
-

Included Traffic in MB

-
-
- -
- -
-
- - - - @error('base_down_peak') - {{ $message }} - @enderror - -
-
- - -
-
- - - - @error('base_up_peak') - {{ $message }} - @enderror - -
-
- - -
-
- - - - @error('base_down_offpeak') - {{ $message }} - @enderror - -
-
- - -
-
- - - - @error('base_up_offpeak') - {{ $message }} - @enderror - -
-
- - -
-
- - - - @error('metric') - {{ $message }} - @enderror - - Metric -
-
-
- -
-
-

Values determine the included traffic. A value of 0 means no traffic is included and charged at the Extra Traffic rates. An empty value means the traffic is not counted in this category.

-

Any values charged at extra rates, the rate determines the value charged, and if the value is empty it will roll up to the Peak category or Down Peak if the Peak category is null.

-

-
-
-

Extra Traffic in $/mb

+
+
+ +
+ +
+
+
+

Included Traffic in MB

+
+
+ +
+ +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+ +
+
+

Values determine the included traffic. A value of 0 means no traffic is included and charged at the Extra Traffic rates. An empty value means the traffic is not counted in this category.

+

Any values charged at extra rates, the rate determines the value charged, and if the value is empty it will roll up to the Peak category or Down Peak if the Peak category is null.

+
+
+
+
- -
-
- - - - @error('extra_down_peak') - {{ $message }} - @enderror - -
+ + +
+
- -
-
- - - - @error('extra_up_peak') - {{ $message }} - @enderror - +
+
+
+

Extra Traffic in $/mb

+
-
- -
-
- - - - @error('extra_down_offpeak') - {{ $message }} - @enderror - -
-
+
+ +
+ +
- -
-
- - - - @error('extra_up_offpeak') - {{ $message }} - @enderror - + +
+ +
+ + +
+ +
+ + +
+ +
\ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/supplier/widget/connections.blade.php b/resources/views/theme/backend/adminlte/supplier/widget/connections.blade.php index 9055813..ce7096c 100644 --- a/resources/views/theme/backend/adminlte/supplier/widget/connections.blade.php +++ b/resources/views/theme/backend/adminlte/supplier/widget/connections.blade.php @@ -1,4 +1,7 @@ - + +@use(App\Models\Supplier) +@use(Carbon\Carbon) +
@@ -14,14 +17,14 @@ - @foreach (\App\Models\Supplier::offeringTypes($o) as $key => $offering) + @foreach (Supplier::offeringTypes($spo) as $key => $offering) - @if(Arr::get($o->detail->connections,$key)) - - - - + @if(Arr::get($spo->detail->connections,$key)) + + + + @else diff --git a/resources/views/theme/backend/adminlte/supplier/widget/detail.blade.php b/resources/views/theme/backend/adminlte/supplier/widget/detail.blade.php index 956b4ca..19c1deb 100644 --- a/resources/views/theme/backend/adminlte/supplier/widget/detail.blade.php +++ b/resources/views/theme/backend/adminlte/supplier/widget/detail.blade.php @@ -1,10 +1,10 @@ - +
-

Supplier Details @include('adminlte::widget.success_button')

+

Supplier Details


-
+ @csrf
@@ -12,23 +12,12 @@
-
-
- active) ? 'checked' : '' }}> - -
-
+
- @include('adminlte::widget.form_text',[ - 'label'=>'Supplier Name', - 'id'=>'name', - 'old'=>'name', - 'name'=>'name', - 'value'=>$o->name ?? '', - ]) +
@@ -37,8 +26,8 @@
- - + + @error('address1') {{ $message }} @@ -53,37 +42,19 @@
- @include('adminlte::widget.form_text',[ - 'label'=>'City', - 'id'=>'city', - 'old'=>'city', - 'name'=>'city', - 'value'=>$o->city ?? '', - ]) +
- @include('adminlte::widget.form_text',[ - 'label'=>'State', - 'id'=>'state', - 'old'=>'state', - 'name'=>'state', - 'value'=>$o->state ?? '', - ]) +
- @include('adminlte::widget.form_text',[ - 'label'=>'Post Code', - 'id'=>'postcode', - 'old'=>'postcode', - 'name'=>'postcode', - 'value'=>$o->postcode ?? '', - ]) +
@@ -92,69 +63,41 @@
- @include('adminlte::widget.form_text',[ - 'label'=>'Accounts Email', - 'id'=>'supplier_details.accounts', - 'old'=>'supplier_details.accounts', - 'name'=>'supplier_details[accounts]', - 'value'=>($o->detail ? $o->detail->accounts : ''), - ]) +
- @include('adminlte::widget.form_text',[ - 'label'=>'Support Email', - 'id'=>'supplier_details.support', - 'old'=>'supplier_details.support', - 'name'=>'supplier_details[support]', - 'value'=>($o->detail ? $o->detail->support : ''), - ]) +
- @include('adminlte::widget.form_text',[ - 'label'=>'Payment Details', - 'id'=>'supplier_details.payments', - 'old'=>'supplier_details.payments', - 'name'=>'supplier_details[payments]', - 'value'=>($o->detail ? $o->detail->support : ''), - ]) +
- @if($o->api_class()) + @if($spo->api_class())
-

{{ $o->api_class() }}

+

+ {{ $spo->api_class() }} +

- @include('adminlte::widget.form_text',[ - 'label'=>'API Key', - 'id'=>'api_key', - 'old'=>'api_key', - 'name'=>'api_key', - 'value'=>($o->detail ? Arr::get($o->detail->connections,'api_key') : ''), - ]) +
- @include('adminlte::widget.form_text',[ - 'label'=>'API Secret', - 'id'=>'api_secret', - 'old'=>'api_secret', - 'name'=>'api_secret', - 'value'=>($o->detail ? Arr::get($o->detail->connections,'api_secret') : ''), - ]) +
@endif @@ -164,25 +107,15 @@
-
- - - - @error('supplier_details.notes') - {{ $message }} - @enderror - -
+
-
- Cancel - @can('wholesaler') - - @endcan +
+ + @if($spo?->exists)Update @else Add @endif
diff --git a/resources/views/theme/backend/adminlte/supplier/widget/offerings.blade.php b/resources/views/theme/backend/adminlte/supplier/widget/offerings.blade.php index c51306d..b9d9089 100644 --- a/resources/views/theme/backend/adminlte/supplier/widget/offerings.blade.php +++ b/resources/views/theme/backend/adminlte/supplier/widget/offerings.blade.php @@ -1,8 +1,10 @@ - + +@use(App\Models\Supplier) +
@@ -10,7 +12,7 @@
- @foreach(\App\Models\Supplier::offeringTypes($o) as $key => $offering) + @foreach(Supplier::offeringTypes($spo) as $key => $offering)
{{ $offering->type }}{{ Arr::get($o->detail->connections,$key.'.user') }}{{ Arr::get($o->detail->connections,$key.'.pass') }}{{ Arr::get($o->detail->connections,$key.'.url') }}{{ \Carbon\Carbon::createFromFormat('Y-m-d',Arr::get($o->detail->connections,$key.'.last'))->format('Y-m-d') }}{{ Arr::get($spo->detail->connections,$key.'.user') }}{{ Arr::get($spo->detail->connections,$key.'.pass') }}{{ Arr::get($spo->detail->connections,$key.'.url') }}{{ Carbon::createFromFormat('Y-m-d',Arr::get($spo->detail->connections,$key.'.last'))->format('Y-m-d') }} {{ number_format($offering->items->count()) }} 
@@ -66,13 +68,12 @@ -@section('page-scripts') - @css(datatables,bootstrap4) - @js(datatables,bootstrap4) +@pa(datatables) +@section('page-scripts')