Compare commits

...

2 Commits

Author SHA1 Message Date
2c3665650c Use map() instead of transform(), use fn() instead of function(), consistent coding for form.select
Some checks failed
Create Docker Image / Build Docker Image (x86_64) (push) Failing after 28s
Create Docker Image / Final Docker Image Manifest (push) Has been skipped
2024-08-18 14:11:35 +10:00
5139b26a05 Change supplier resources to use components 2024-08-18 14:11:35 +10:00
27 changed files with 278 additions and 580 deletions

View File

@ -399,11 +399,11 @@ class ServiceController extends Controller
// We dynamically create our validation // We dynamically create our validation
$validator = Validator::make( $validator = Validator::make(
$request->post(), $request->post(),
$x=collect($o->type->validation()) collect($o->type->validation())
->keys() ->keys()
->transform(fn($item)=>sprintf('%s.%s',$o->product->category,$item)) ->map(fn($item)=>sprintf('%s.%s',$o->product->category,$item))
->combine(array_values($o->type->validation())) ->combine(array_values($o->type->validation()))
->transform(fn($item)=>is_string($item) ->map(fn($item)=>is_string($item)
? preg_replace('/^exclude_without:/',sprintf('exclude_without:%s.',$o->product->category),$item) ? preg_replace('/^exclude_without:/',sprintf('exclude_without:%s.',$o->product->category),$item)
: $item) : $item)
->merge( ->merge(

View File

@ -4,10 +4,11 @@ namespace App\Http\Controllers;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use App\Http\Requests\{SupplierAddEdit,SupplierProductAddEdit}; use App\Http\Requests\{SupplierAddEdit,SupplierProductAddEdit};
use App\Models\{Cost,Supplier,SupplierDetail};
use App\Jobs\ImportCosts; use App\Jobs\ImportCosts;
use App\Models\{Cost,Supplier,SupplierDetail};
class SupplierController extends Controller class SupplierController extends Controller
{ {
@ -20,9 +21,7 @@ class SupplierController extends Controller
*/ */
public function addedit(SupplierAddEdit $request,Supplier $o) public function addedit(SupplierAddEdit $request,Supplier $o)
{ {
$this->middleware(['auth','wholesaler']); foreach (Arr::except($request->validated(),['supplier_details','api_key','api_secret','submit']) as $key => $item)
foreach ($request->except(['_token','supplier_details','api_key','api_secret','submit']) as $key => $item)
$o->{$key} = $item; $o->{$key} = $item;
$o->active = (bool)$request->active; $o->active = (bool)$request->active;
@ -51,19 +50,6 @@ class SupplierController extends Controller
->with('success','Supplier Saved'); ->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 * Show the suppliers invoice
* *
@ -99,19 +85,9 @@ class SupplierController extends Controller
$filename, $filename,
)->onQueue('low'); )->onQueue('low');
return redirect()->back()->with('success','File uploaded'); 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);
} }
public function product_addedit(SupplierProductAddEdit $request,Supplier $o,int $id,string $type) 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); $oo = Supplier\Broadband::findOrNew($id);
// @todo these are broadband requirements - get them from the broadband class. // @todo these are broadband requirements - get them from the broadband class.
foreach ($request->only([ foreach (Arr::only($request->validated(),[
'supplier_detail_id', 'supplier_detail_id',
'product_id'. 'product_id'.
'product_desc', 'product_desc',
@ -151,8 +127,8 @@ class SupplierController extends Controller
$oo->$key = $value; $oo->$key = $value;
// Our boolean values // Our boolean values
foreach ($request->only(['active','extra_shaped','extra_charged']) as $key => $value) foreach (Arr::only($request->validated(),['active','extra_shaped','extra_charged']) as $key => $value)
$oo->$key = ($value == 'on' ? 1 : 0); $oo->{$key} = ($value == 'on' ? 1 : 0);
break; break;
@ -162,28 +138,11 @@ class SupplierController extends Controller
$oo->save(); $oo->save();
return redirect()->back() return redirect()
->back()
->with('success','Saved'); ->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 * Return the form for a specific product type
* *
@ -200,24 +159,10 @@ class SupplierController extends Controller
$request->session()->flashInput($request->old); $request->session()->flashInput($request->old);
if ($o) if ($o)
$o->load(['products.product.services']); $o->load(['products.products.services']);
return view('theme.backend.adminlte.supplier.product.widget.'.$type) return view('theme.backend.adminlte.supplier.product.widget.'.$type)
->with('o',$id ? $o : NULL) ->with('o',$id ? $o : NULL)
->withErrors($request->errors); ->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);
}
} }

View File

@ -62,7 +62,7 @@ class ImportCosts implements ShouldQueue
'PRICETOTAL'=>'Total (inc-GST)' 'PRICETOTAL'=>'Total (inc-GST)'
]; ];
$this->columns = collect($headers)->transform(function($item) { return strtolower($item); }); $this->columns = collect($headers)->map(fn($item)=>strtolower($item));
} }
/** /**

View File

@ -367,7 +367,7 @@ class Product extends Model implements IDs
return round($price,2); return round($price,2);
} }
public function accounting(string $provider): Collection public function accounting(): Collection
{ {
$so = ProviderOauth::where('name',self::provider) $so = ProviderOauth::where('name',self::provider)
->sole(); ->sole();
@ -379,7 +379,7 @@ class Product extends Model implements IDs
->API() ->API()
->getItems() ->getItems()
->pluck('pid','Id') ->pluck('pid','Id')
->transform(fn($item,$value)=>['id'=>$value,'value'=>$item]) ->map(fn($item,$value)=>['id'=>$value,'value'=>$item])
->values(); ->values();
} }

View File

@ -21,7 +21,7 @@ abstract class Type extends Model
*/ */
final public function products() final public function products()
{ {
return $this->morphMany(Product::class, null,'model','model_id'); return $this->morphMany(Product::class,null,'model','model_id');
} }
/** /**

View File

@ -140,7 +140,7 @@ class Broadband extends Type
} }
if ($config->has('metric') AND $config->get('metric')) if ($config->has('metric') AND $config->get('metric'))
$result->transform(function($item) use ($config,$ceil) { $result->map(function($item) use ($config,$ceil) {
return $ceil return $ceil
? (int)ceil($item/$config->get('metric')) ? (int)ceil($item/$config->get('metric'))
: $item/$config->get('metric'); : $item/$config->get('metric');

View File

@ -7,6 +7,8 @@ use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use Intuit\Traits\IntuitSocialite; use Intuit\Traits\IntuitSocialite;
use App\Models\{Checkout,Payment,Product,Service,Supplier};
class AppServiceProvider extends ServiceProvider class AppServiceProvider extends ServiceProvider
{ {
use IntuitSocialite; use IntuitSocialite;
@ -33,9 +35,10 @@ class AppServiceProvider extends ServiceProvider
$this->bootIntuitSocialite(); $this->bootIntuitSocialite();
Route::model('co',\App\Models\Checkout::class); Route::model('co',Checkout::class);
Route::model('po',\App\Models\Payment::class); Route::model('po',Payment::class);
Route::model('pdo',\App\Models\Product::class); Route::model('pdo',Product::class);
Route::model('so',\App\Models\Service::class); Route::model('so',Service::class);
Route::model('spo',Supplier::class);
} }
} }

View File

@ -27,7 +27,7 @@
@endforeach @endforeach
</tbody> </tbody>
@if(($x=Supplier::active()->whereNotIn('id',$o->suppliers->pluck('id'))->orderBy('name')->get())->count()) @if(($x=Supplier::active()->whereNotIn('id',$o->suppliers->pluck('id'))->orderBy(DB::raw('UPPER(name)'))->get())->count())
<tfoot> <tfoot>
<tr> <tr>
<td colspan="3"> <td colspan="3">
@ -36,7 +36,7 @@
<div class="row"> <div class="row">
<div class="col-6"> <div class="col-6">
<x-leenooks::form.select id="supplier_id" name="supplier_id" icon="fa-handshake" label="Add Supplier" :options="$x->map(function($item) { $item->value = $item->name; return $item; })->toArray()"/> <x-leenooks::form.select id="supplier_id" name="supplier_id" icon="fa-handshake" label="Add Supplier" :options="$x->map(fn($item)=>['id'=>$item->id,'value'=>$item->name])"/>
</div> </div>
<div class="col-4"> <div class="col-4">

View File

@ -31,7 +31,7 @@
<input type="hidden" name="type" value="invoice"> <input type="hidden" name="type" value="invoice">
<!-- @todo This is currently forcing only paypal --> <!-- @todo This is currently forcing only paypal -->
<x-leenooks::form.select id="checkout_id" name="checkout_id" icon="fa-credit-card" label="Payment Method" feedback="Payment Method is required" choose="true" :options="Checkout::active()->where('name','ilike','paypal')->orderBy('name')->get()->map(function ($item) { $item->value = $item->name; return $item; })"/> <x-leenooks::form.select id="checkout_id" name="checkout_id" icon="fa-credit-card" label="Payment Method" feedback="Payment Method is required" choose="true" :options="Checkout::active()->where('name','ilike','paypal')->orderBy('name')->get()->map(fn($item)=>['id'=>$item->id,'value'=>$item->name])"/>
<table id="invoices" class="table table-sm w-100"> <table id="invoices" class="table table-sm w-100">
<tr> <tr>

View File

@ -26,7 +26,7 @@
<div class="card-body"> <div class="card-body">
<div class="row"> <div class="row">
<div class="col-12 col-lg-4"> <div class="col-12 col-lg-4">
<x-leenooks::form.select id="checkout_id" name="checkout_id" icon="fa-credit-card" label="Payment Name" feedback="Payment Name is required" addnew="New Payment" groupby="active" :options="Checkout::orderBy('active','DESC')->orderBy('name')->get()->map(function ($item) { $item->value = $item->name; return $item; })"/> <x-leenooks::form.select id="checkout_id" name="checkout_id" icon="fa-credit-card" label="Payment Name" feedback="Payment Name is required" addnew="New Payment" groupby="active" :options="Checkout::orderBy('active','DESC')->orderBy('name')->get()->map(fn($item)=>['id'=>$item->id,'value'=>$item->name])"/>
</div> </div>
</div> </div>
</div> </div>

View File

@ -42,7 +42,7 @@
<div class="row"> <div class="row">
<!-- Product Type --> <!-- Product Type -->
<div class="col-12"> <div class="col-12">
<x-leenooks::form.select name="model" icon="fa-list" label="Product" choose="true" groupby="active" :value="get_class($pdo->type)" :options="Product::availableTypes()->transform(fn($item)=>['id'=>$item,'value'=>$item])"/> <x-leenooks::form.select name="model" icon="fa-list" label="Product" choose="true" groupby="active" :value="get_class($pdo->type)" :options="Product::availableTypes()->map(fn($item)=>['id'=>$item,'value'=>$item])"/>
</div> </div>
</div> </div>

View File

@ -12,7 +12,7 @@
<div class="row"> <div class="row">
<div class="col-12 col-sm-9 col-md-6 col-xl-5"> <div class="col-12 col-sm-9 col-md-6 col-xl-5">
<x-leenooks::form.select name="product_id" icon="fa-list" label="Product" choose="true" groupby="active" :value="$po?->id ?? ''" :options="Product::get()->sortBy(fn($item)=>($item->active ? '0' : '1').$item->name)->transform(fn($item)=>['id'=>$item->id,'value'=>$item->name,'active'=>$item->active])"/> <x-leenooks::form.select name="product_id" icon="fa-list" label="Product" choose="true" groupby="active" :value="$po?->id ?? ''" :options="Product::get()->sortBy(fn($item)=>($item->active ? '0' : '1').$item->name)->map(fn($item)=>['id'=>$item->id,'value'=>$item->name,'active'=>$item->active])"/>
</div> </div>
</div> </div>
</form> </form>

View File

@ -41,7 +41,7 @@
<!-- PRODUCT --> <!-- PRODUCT -->
<x-leenooks::form.select id="product_id" name="broadband[product_id]" icon="fa-list" label="Product" :helper="$o->product->category_name" groupby="active" <x-leenooks::form.select id="product_id" name="broadband[product_id]" icon="fa-list" label="Product" :helper="$o->product->category_name" groupby="active"
:value="$np->id" :value="$np->id"
:options="Product::get()->filter(fn($item)=>$item->category === $np->category)->sortBy('name')->sortByDesc('active')->transform(fn($item)=>['id'=>$item->id,'active'=>$item->active,'value'=>$item->name])" required/> :options="Product::get()->filter(fn($item)=>$item->category === $np->category)->sortBy('name')->sortByDesc('active')->map(fn($item)=>['id'=>$item->id,'active'=>$item->active,'value'=>$item->name])" required/>
</div> </div>
</div> </div>

View File

@ -3,7 +3,7 @@
<x-leenooks::form.select id="product_id" name="product_id" icon="fa-list" label="Product" :helper="$o->category_name" :choose="true" <x-leenooks::form.select id="product_id" name="product_id" icon="fa-list" label="Product" :helper="$o->category_name" :choose="true"
:value="$o->service->product_id" :value="$o->service->product_id"
:options="Product::active()->get()->filter(fn($item)=>get_class($item->type) === Broadband::class)->sortBy('name')->sortByDesc('active')->transform(fn($item)=>['id'=>$item->id,'active'=>$item->active,'value'=>$item->name])" required/> :options="Product::active()->get()->filter(fn($item)=>get_class($item->type) === Broadband::class)->sortBy('name')->sortByDesc('active')->map(fn($item)=>['id'=>$item->id,'active'=>$item->active,'value'=>$item->name])" required/>
<strong>NOTE</strong>: A plan setup fee is normally not applicable to Broadband changes, but a plan change fee normally is. <strong>NOTE</strong>: A plan setup fee is normally not applicable to Broadband changes, but a plan change fee normally is.

View File

@ -18,7 +18,7 @@
<div class="row"> <div class="row">
<div class="col-12 col-sm-9 col-md-6 col-xl-5"> <div class="col-12 col-sm-9 col-md-6 col-xl-5">
<x-leenooks::form.select id="domain_registrar_id" name="domain[domain_registrar_id]" icon="fa-handshake" label="Registrar" :value="$o->domain_registrar_id" :options="DomainRegistrar::active()->orderBy('name')->get()->transform(fn($item)=>['id'=>$item->id,'value'=>$item->name])"/> <x-leenooks::form.select id="domain_registrar_id" name="domain[domain_registrar_id]" icon="fa-handshake" label="Registrar" :value="$o->domain_registrar_id" :options="DomainRegistrar::active()->orderBy('name')->get()->map(fn($item)=>['id'=>$item->id,'value'=>$item->name])"/>
</div> </div>
<div class="col-12 col-sm-9 col-md-12 col-xl-6"> <div class="col-12 col-sm-9 col-md-12 col-xl-6">
@ -28,7 +28,7 @@
<div class="row"> <div class="row">
<div class="col-12 col-sm-9 col-md-6 col-xl-5"> <div class="col-12 col-sm-9 col-md-6 col-xl-5">
<x-leenooks::form.select id="registrar_ns" name="domain[registrar_ns]" icon="fa-project-diagram" label="DNS Location" :value="$o->registrar_ns" :options="ServiceDomain::select('registrar_ns')->distinct()->orderBy('registrar_ns')->get()->transform(fn($item)=>['id'=>$item->registrar_ns,'value'=>$item->registrar_ns])"/> <x-leenooks::form.select id="registrar_ns" name="domain[registrar_ns]" icon="fa-project-diagram" label="DNS Location" :value="$o->registrar_ns" :options="ServiceDomain::select('registrar_ns')->distinct()->orderBy('registrar_ns')->get()->map(fn($item)=>['id'=>$item->registrar_ns,'value'=>$item->registrar_ns])"/>
</div> </div>
<div class="col-12 col-sm-9 col-md-12 col-xl-6"> <div class="col-12 col-sm-9 col-md-12 col-xl-6">

View File

@ -16,7 +16,7 @@
<div class="row"> <div class="row">
<div class="col-12 col-sm-9 col-md-6 col-xl-5"> <div class="col-12 col-sm-9 col-md-6 col-xl-5">
<x-leenooks::form.select id="supplier_host_server_id" name="hosting[supplier_host_server_id]" icon="fa-handshake" label="Registrar" :value="$o->supplier_host_server_id" :options="SupplierHostServer::active()->orderBy('name')->get()->transform(fn($item)=>['id'=>$item->id,'value'=>$item->name])"/> <x-leenooks::form.select id="supplier_host_server_id" name="hosting[supplier_host_server_id]" icon="fa-handshake" label="Registrar" :value="$o->supplier_host_server_id" :options="SupplierHostServer::active()->orderBy('name')->get()->map(fn($item)=>['id'=>$item->id,'value'=>$item->name])"/>
</div> </div>
</div> </div>

View File

@ -1,14 +1,14 @@
@extends('adminlte::layouts.app') @extends('adminlte::layouts.app')
@section('htmlheader_title') @section('htmlheader_title')
{{ $o->name ?: 'New Supplier' }} {{ $spo->name ?: 'New Supplier' }}
@endsection @endsection
@section('page_title') @section('page_title')
{{ $o->name ?: 'New Supplier' }} {{ $spo->name ?: 'New Supplier' }}
@endsection @endsection
@section('contentheader_title') @section('contentheader_title')
{{ $o->name ?: 'New Supplier' }} {{ $spo->name ?: 'New Supplier' }}
@endsection @endsection
@section('contentheader_description') @section('contentheader_description')
@endsection @endsection
@ -20,7 +20,7 @@
<div class="card-header bg-dark d-flex p-0"> <div class="card-header bg-dark d-flex p-0">
<ul class="nav nav-pills w-100 p-2"> <ul class="nav nav-pills w-100 p-2">
<li class="nav-item"><a class="nav-link active" href="#details" data-toggle="tab">Detail</a></li> <li class="nav-item"><a class="nav-link active" href="#details" data-toggle="tab">Detail</a></li>
@if($o->exists) @if($spo->exists)
<li class="nav-item"><a class="nav-link" href="#products" data-toggle="tab">Products</a></li> <li class="nav-item"><a class="nav-link" href="#products" data-toggle="tab">Products</a></li>
<li class="nav-item"><a class="nav-link" href="#offerings" data-toggle="tab">Offerings</a></li> <li class="nav-item"><a class="nav-link" href="#offerings" data-toggle="tab">Offerings</a></li>
<li class="nav-item"><a class="nav-link" href="#connections" data-toggle="tab">Connections</a></li> <li class="nav-item"><a class="nav-link" href="#connections" data-toggle="tab">Connections</a></li>
@ -35,7 +35,7 @@
@include('theme.backend.adminlte.supplier.widget.detail') @include('theme.backend.adminlte.supplier.widget.detail')
</div> </div>
@if($o->exists) @if($spo->exists)
<div class="tab-pane fade" id="products" role="tabpanel"> <div class="tab-pane fade" id="products" role="tabpanel">
@include('theme.backend.adminlte.supplier.widget.products') @include('theme.backend.adminlte.supplier.widget.products')
</div> </div>

View File

@ -1,3 +1,5 @@
@use(App\Models\Supplier)
@extends('adminlte::layouts.app') @extends('adminlte::layouts.app')
@section('htmlheader_title') @section('htmlheader_title')
@ -27,16 +29,7 @@
<div class="row"> <div class="row">
<div class="col-12 col-sm-9 col-md-6 col-xl-5"> <div class="col-12 col-sm-9 col-md-6 col-xl-5">
@include('adminlte::widget.form_select',[ <x-leenooks::form.select name="supplier_id" icon="fa-handshake" label="Supplier" choose="true" groupby="active" :options="$x=Supplier::orderBy('active','DESC')->orderBy(DB::Raw('UPPER(name)'))->get()->map(fn($item)=>['id'=>$item->id,'active'=>$item->active,'value'=>$item->name])"/>
'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'=>'',
])
</div> </div>
</div> </div>
</form> </form>
@ -47,9 +40,6 @@
@endsection @endsection
@section('page-scripts') @section('page-scripts')
@css(select2)
@js(select2,autofocus)
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
$('#supplier_id') $('#supplier_id')

View File

@ -1,16 +1,24 @@
<!-- $o = Supplier::class --> <!-- $spo=Supplier::class -->
<!-- $oo = Supplier/{type}::class --> <!-- $oo=Supplier/{type}::class -->
@use(App\Models\Supplier)
@php
if(isset($spo)) {
$oo = $spo->detail?->find(request()->route()->parameter('type'),request()->route()->parameter('id'));
$oo?->load(['products.products.services']);
}
@endphp
@extends('adminlte::layouts.app') @extends('adminlte::layouts.app')
@section('htmlheader_title') @section('htmlheader_title')
Supplier - @if ($oo && $oo->exists)Edit @else New @endif Product Supplier Product - @if (isset($oo) && $oo->exists)Edit @else New @endif
@endsection @endsection
@section('page_title') @section('page_title')
@if ($oo && $oo->exists)Edit @else New @endif Product @if (isset($oo) && $oo->exists){{ $oo->name }} @else New @endif Product
@endsection @endsection
@section('contentheader_title') @section('contentheader_title')
Supplier - @if ($oo && $oo->exists)Edit @else New @endif Product Supplier Product - @if (isset($oo) && $oo->exists){{ $oo->name }} @else New @endif
@endsection @endsection
@section('contentheader_description') @section('contentheader_description')
@endsection @endsection
@ -19,70 +27,39 @@
<div class="row"> <div class="row">
<div class="col-8"> <div class="col-8">
<div class="card card-dark"> <div class="card card-dark">
<div class="card-header"> <div class="card-header p-2">
<h1 class="card-title">Supplier Product</h1> <h1 class="card-title">Supplier Product</h1>
<!-- @todo Should this be a x-leenooks::success component -->
@if(session()->has('success')) @if(session()->has('success'))
<span class="ml-3 pt-0 pb-0 pr-1 pl-1 btn btn-outline-success"><small>{{ session()->get('success') }}</small></span> <span class="ml-3 pt-0 pb-0 pr-1 pl-1 btn btn-outline-success"><small>{{ session()->get('success') }}</small></span>
@endif @endif
</div> </div>
<div class="card-body"> <div class="card-body">
<form class="g-0 needs-validation" method="POST" enctype="multipart/form-data" role="form"> <form method="POST">
@csrf @csrf
<input type="hidden" name="id" value="{{ $oo?->id }}">
<input type="hidden" name="id" value="{{ $oo?->id ?? '' }}">
<div class="row"> <div class="row">
<div class="col-4"> <div class="col-4">
<!-- Supplier --> <!-- Supplier -->
<div class="form-group has-validation"> <x-leenooks::form.select name="supplier_detail_id" icon="fa-handshake" label="Supplier" :choose="true" :value="$spo->id ?? ''" :options="Supplier::active()->orderBy(DB::raw('UPPER(name)'))->get()->map(fn($item,$key)=>['id'=>$item->id,'value'=>$item->name])"/>
<label for="supplier_detail_id">Supplier</label>
<select class="form-control form-control-border @error('supplier_detail_id') is-invalid @enderror" id="supplier_detail_id" name="supplier_detail_id">
<option value=""></option>
@foreach(\App\Models\Supplier::active()->orderBy('name')->get() as $so)
<option value="{{ $so->id }}" {{ old('supplier_detail_id',$o->id) == $so->detail->id ? 'selected' : ''}}>{{ $so->name }}</option>
@endforeach
</select>
<span class="invalid-feedback" role="alert">
@error('supplier_detail_id')
{{ $message }}
@else
Date is required.
@enderror
</span>
<span class="input-helper">Suppliers Name</span>
</div>
</div> </div>
<div class="col-4"> <div class="col-4">
<!-- Offering Type --> <!-- Offering Type -->
<div class="form-group has-validation"> <x-leenooks::form.select name="offering_type" icon="fa-cogs" label="Type" helper="Offering Type" :choose="true" :value="$oo?->category ?? ''" :options="Supplier::offeringTypes()->sortBy(fn($item)=>$item->category_name)->map(fn($item)=>['id'=>$item->category,'value'=>$item->category_name])"/>
<label for="offering_type">Type</label>
<select class="form-control form-control-border @error('offering_type') is-invalid @enderror" id="offering_type" name="offering_type">
<option value=""></option>
@foreach(\App\Models\Supplier::offeringTypes()->sortBy(function($item) { return $item->category_name; }) as $to)
<option value="{{ $to->category }}" {{ old('offering_type',$oo?->category) == $to->category ? 'selected' : ''}}>{{ $to->category_name }}</option>
@endforeach
</select>
<span class="invalid-feedback" role="alert">
@error('offering_type')
{{ $message }}
@else
Offering Type is Required
@enderror
</span>
<span class="input-helper">Offering Type</span>
</div>
</div> </div>
</div> </div>
<div id="type"></div> <div id="type"></div>
<div class="row"> <div class="row">
<div class="col-12"> <!-- Buttons -->
<a href="{{ url('/home') }}" class="btn btn-danger">Cancel</a> <div class="col">
@can('wholesaler') <x-leenooks::button.cancel/>
<button type="submit" name="submit" class="btn btn-success mr-0 float-right">@if ($oo && $oo->exists)Save @else Add @endif</button> <x-leenooks::button.submit class="float-right">@if(isset($spo) && $spo?->exists)Update @else Add @endif</x-leenooks::button.submit>
@endcan
</div> </div>
</div> </div>
</form> </form>
@ -90,16 +67,16 @@
</div> </div>
</div> </div>
@if($oo && $oo->exists) @if(isset($oo) && $oo->exists)
<div class="col-4"> <div class="col-4">
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<div class="card card-info"> <div class="card card-info">
<div class="card-header"> <div class="card-header p-2">
<h1 class="card-title">Offering Products</h1> <h1 class="card-title">Offering Products</h1>
</div> </div>
<div class="card-body"> <div class="card-body p-2">
<table class="table table-sm"> <table class="table table-sm">
<thead> <thead>
<tr> <tr>
@ -112,12 +89,14 @@
<tbody> <tbody>
@foreach ($oo->products as $pto) @foreach ($oo->products as $pto)
<tr> @foreach ($pto->products as $po)
<td>{{ $pto->id }}</td> <tr>
<td>{{ $pto->product->name }}</td> <td>{{ $po->id }}</td>
<td class="text-right">{{ $pto->product->services->where('active',true)->count() }}</td> <td>{{ $po->name }}</td>
<td class="text-right">{{ $pto->product->services->count() }}</td> <td class="text-right">{{ $po->services->where('active',true)->count() }}</td>
</tr> <td class="text-right">{{ $po->services->count() }}</td>
</tr>
@endforeach
@endforeach @endforeach
</tbody> </tbody>
</table> </table>
@ -129,12 +108,12 @@
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<div class="card card-info"> <div class="card card-info">
<div class="card-header"> <div class="card-header p-2">
<h1 class="card-title">Services Using this Supplier Product</h1> <h1 class="card-title">Services Using this Supplier Product</h1>
</div> </div>
<div class="card-body"> <div class="card-body p-2">
<table class="table table-sm" id="services"> <table class="table table-hover table-sm" id="services">
<thead> <thead>
<tr> <tr>
<th>ID</th> <th>ID</th>
@ -146,13 +125,15 @@
<tbody> <tbody>
@foreach ($oo->products as $pto) @foreach ($oo->products as $pto)
@foreach ($pto->product->services as $so) @foreach ($pto->products as $po)
<tr> @foreach ($po->services as $so)
<td><a href="{{ url('u/service',[$so->id]) }}">{{ $so->lid }}</a></td> <tr>
<td>{{ $so->product->type->id }}</td> <td><a href="{{ url('u/service',[$so->id]) }}">{{ $so->lid }}</a></td>
<td>{{ $so->name }}</td> <td>{{ $po->name }}</td>
<td>{{ $so->active ? 'Active' : 'Not Active' }}</td> <td>{{ $so->name }}</td>
</tr> <td>{{ $so->active ? 'Active' : 'Not Active' }}</td>
</tr>
@endforeach
@endforeach @endforeach
@endforeach @endforeach
</tbody> </tbody>
@ -166,10 +147,9 @@
</div> </div>
@endsection @endsection
@section('page-scripts') @pa(datatables,rowgroup|conditionalpaging)
@css(datatables,bootstrap4|rowgroup)
@js(datatables,bootstrap4|responsive|rowgroup)
@section('page-scripts')
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
function load_type(type,id) { function load_type(type,id) {
@ -181,7 +161,7 @@
url: '{{ url('a/supplier/product/view') }}/'+type+(id ? '/'+id : ''), url: '{{ url('a/supplier/product/view') }}/'+type+(id ? '/'+id : ''),
timeout: 2000, timeout: 2000,
error: function(x) { error: function(x) {
spinner.toggleClass('d-none').toggleClass('fa-spin'); //spinner.toggleClass('d-none').toggleClass('fa-spin');
alert('Failed to submit'); alert('Failed to submit');
}, },
success: function(data) { success: function(data) {
@ -190,7 +170,7 @@
}); });
} }
@if ($oo && $oo->exists) @if (isset($oo) && $oo->exists)
$('#offering_type').attr('style','pointer-events: none;'); $('#offering_type').attr('style','pointer-events: none;');
load_type('{{$oo->category}}',{{$oo->id}}) load_type('{{$oo->category}}',{{$oo->id}})
@endif @endif
@ -203,17 +183,18 @@
}); });
$('#services').DataTable({ $('#services').DataTable({
conditionalPaging: true,
order: [[3,'asc'],[1,'asc'],[2,'asc']], order: [[3,'asc'],[1,'asc'],[2,'asc']],
rowGroup: { rowGroup: {
dataSrc: 3, dataSrc: 1,
}, },
columnDefs: [ columnDefs: [
{ {
targets: [3], targets: [1],
visible: false, visible: false,
} }
], ],
}); });
}); });
</script> </script>
@endsection @append

View File

@ -1,308 +1,148 @@
<!-- $o = Supplier{type}::class --> <!-- $o = Supplier{type}::class -->
<div class="row"> <div class="row">
<!-- Supplier Name --> <!-- Supplier Name -->
<div class="col-3"> <div class="col-4">
<div class="form-group has-validation"> <x-leenooks::form.text name="product_id" label="Product ID" icon="fa-tag" helper="Supplier's Product ID" :value="$o?->product_id"/>
<label for="product_id">Product ID</label>
<input type="text" class="form-control form-control-border @error('product_id') is-invalid @enderror" id="product_id" name="product_id" placeholder="Product ID" value="{{ old('product_id',$o?->product_id) }}" required>
<span class="invalid-feedback" role="alert">
@error('product_id')
{{ $message }}
@else
Supplier's Product ID
@enderror
</span>
<span class="input-helper">Supplier's Product ID</span>
</div>
</div> </div>
<!-- Suppliers Description --> <!-- Suppliers Description -->
<div class="offset-1 col-8"> <div class="col-8">
<div class="form-group has-validation"> <x-leenooks::form.text name="product_desc" label="Product Description" icon="fa-file-alt" helper="Supplier's Product Description as it appears on Invoices" :value="$o?->product_desc"/>
<label for="product_desc">Product Description</label>
<input type="text" class="form-control form-control-border @error('product_desc') is-invalid @enderror" id="product_desc" name="product_desc" placeholder="Product Description" value="{{ old('product_desc',$o?->product_desc) }}" required>
<span class="invalid-feedback" role="alert">
@error('product_desc')
{{ $message }}
@else
Product Description is required
@enderror
</span>
<span class="input-helper">Supplier's Product Description as it appears on Invoices</span>
</div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<!-- Supplier Active --> <!-- Supplier Active -->
<div class="col-1"> <div class="col-1">
<div class="form-group"> <x-leenooks::form.toggle name="active" label="Active" :value="$o?->active"/>
<div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success"> </div>
<input type="checkbox" class="custom-control-input" id="active" name="active" {{ old('active',$o?->active) ? 'checked' : '' }}>
<label class="custom-control-label" for="active">Active</label> <div class="offset-1 col-10">
<div class="row">
<!-- Base Cost -->
<div class="col-12 col-sm-2">
<x-leenooks::form.text class="text-right" name="base_cost" label="Base" helper="Monthly Cost (ex)" :value="$o?->base_cost"/>
</div>
<!-- Setup Cost -->
<div class="col-2">
<x-leenooks::form.text class="text-right" name="setup_cost" label="Setup" helper="Setup Cost (ex)" :value="$o?->setup_cost"/>
</div>
<!-- Contract Term -->
<div class="col-2">
<x-leenooks::form.number class="text-right" name="contract_term" label="Contract Term" helper="Term (mths)" :value="$o?->contract_term"/>
</div>
<!-- Speed -->
<div class="col-2">
<x-leenooks::form.text class="text-right" name="speed" label="Speed" :value="$o?->speed"/>
</div>
<!-- Technology -->
<div class="col-2">
<x-leenooks::form.text class="text-right" name="technology" label="Technology" :value="$o?->technology"/>
</div> </div>
</div> </div>
</div>
<!-- Base Cost --> <div class="row">
<div class="offset-1 col-2"> <div class="col-2">
<div class="form-group has-validation"> <x-leenooks::form.time class="text-right" name="offpeak_start" label="OffPeak Start" :value="($o && $o->offpeak_start) ? $o->offpeak_start->format('H:i') : ''"/>
<label for="base_cost">Base (ex)</label> </div>
<input type="number" class="form-control form-control-border @error('base_cost') is-invalid @enderror" id="base_cost" name="base_cost" placeholder="Cost" value="{{ old('base_cost',$o?->base_cost) }}">
<span class="invalid-feedback" role="alert">
@error('base_cost')
{{ $message }}
@enderror
</span>
<span class="input-helper">Monthly Cost</span>
</div>
</div>
<!-- Setup Cost --> <div class="col-2">
<div class="col-2"> <x-leenooks::form.time class="text-right" name="offpeak_end" label="OffPeak End" :value="($o && $o->offpeak_end) ? $o->offpeak_end->format('H:i') : ''"/>
<div class="form-group has-validation">
<label for="setup_cost">Setup (ex)</label>
<input type="number" class="form-control form-control-border @error('setup_cost') is-invalid @enderror" id="setup_cost" name="setup_cost" placeholder="Setup" value="{{ old('setup_cost',$o?->setup_cost) }}">
<span class="invalid-feedback" role="alert">
@error('setup_cost')
{{ $message }}
@enderror
</span>
<span class="input-helper">Setup Cost</span>
</div>
</div>
<!-- Contract Term -->
<div class="col-2">
<div class="form-group has-validation">
<label for="contract_term">Contract Term</label>
<input type="number" class="form-control form-control-border @error('contract_term') is-invalid @enderror" id="contract_term" name="contract_term" placeholder="Term" value="{{ old('contract_term',$o?->contract_term) }}">
<span class="invalid-feedback" role="alert">
@error('contract_term')
{{ $message }}
@enderror
</span>
<span class="input-helper">Term (mths)</span>
</div>
</div>
<!-- Speed -->
<div class="col-2">
<div class="form-group has-validation">
<label for="speed">Speed</label>
<input type="text" class="form-control form-control-border @error('speed') is-invalid @enderror" id="speed" name="speed" placeholder="Speed" value="{{ old('speed',$o?->speed) }}">
<span class="invalid-feedback" role="alert">
@error('speed')
{{ $message }}
@enderror
</span>
<span class="input-helper">Speed</span>
</div>
</div>
<!-- Technology -->
<div class="col-2">
<div class="form-group has-validation">
<label for="technology">Technology</label>
<input type="text" class="form-control form-control-border @error('technology') is-invalid @enderror" id="technology" name="technology" placeholder="Speed" value="{{ old('technology',$o?->technology) }}">
<span class="invalid-feedback" role="alert">
@error('technology')
{{ $message }}
@enderror
</span>
<span class="input-helper">Technology</span>
</div>
</div>
</div>
<div class="row">
<!-- @todo Add javascript so these toggles cannot both be on -->
<!-- Extra Charged -->
<div class="col-1">
<div class="form-group">
<div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
<input type="checkbox" class="custom-control-input" id="extra_charged" name="extra_charged" {{ old('extra_charged',$o?->extra_charged) ? 'checked' : '' }}>
<label class="custom-control-label" for="extra_charged">Extra Charge</label>
</div> </div>
</div> </div>
</div> </div>
<div class="offset-1 col-3">
<div class="form-group has-validation">
<label for="offpeak_start">OffPeak Start</label>
<input type="time" class="form-control form-control-border @error('offpeak_start') is-invalid @enderror" id="offpeak_start" name="offpeak_start" value="{{ old('offpeak_start',($o && $o->offpeak_start) ? $o->offpeak_start->format('H:i') : '') }}">
<span class="invalid-feedback" role="alert">
@error('offpeak_start')
{{ $message }}
@enderror
</span>
<span class="input-helper">Offpeak Start</span>
</div>
</div>
<div class="col-3">
<div class="form-group has-validation">
<label for="offpeak_end">OffPeak End</label>
<input type="time" class="form-control form-control-border @error('offpeak_end') is-invalid @enderror" id="offpeak_end" name="offpeak_end" value="{{ old('offpeak_end',($o && $o->offpeak_end) ? $o->offpeak_end->format('H:i') : '') }}">
<span class="invalid-feedback" role="alert">
@error('offpeak_end')
{{ $message }}
@enderror
</span>
<span class="input-helper">Offpeak Ends</span>
</div>
</div>
</div>
<div class="row mt-3">
<!-- Extra Shaped -->
<div class="col-1">
<div class="form-group">
<div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
<input type="checkbox" class="custom-control-input" id="extra_shaped" name="extra_shaped" {{ old('extra_shaped',$o?->extra_shaped) ? 'checked' : '' }}>
<label class="custom-control-label" for="extra_shaped">Extra Shaped</label>
</div>
</div>
</div>
<div class="offset-1 col-8">
<h3 class="text-md">Included Traffic in MB</h3>
</div>
</div>
<div class="row">
<!-- Base Down Peak -->
<div class="offset-2 col-2">
<div class="form-group has-validation">
<label for="base_down_peak">Down Peak</label>
<input type="number" class="form-control form-control-border @error('base_down_peak') is-invalid @enderror" id="base_down_peak" name="base_down_peak" value="{{ old('base_down_peak',$o?->base_down_peak) }}">
<span class="invalid-feedback" role="alert">
@error('base_down_peak')
{{ $message }}
@enderror
</span>
</div>
</div>
<!-- Base Down Peak -->
<div class="col-2">
<div class="form-group has-validation">
<label for="base_up_peak">Up Peak</label>
<input type="number" class="form-control form-control-border @error('base_up_peak') is-invalid @enderror" id="base_up_peak" name="base_up_peak" value="{{ old('base_up_peak',$o?->base_up_peak) }}">
<span class="invalid-feedback" role="alert">
@error('base_up_peak')
{{ $message }}
@enderror
</span>
</div>
</div>
<!-- Base Down Offpeak -->
<div class="col-2">
<div class="form-group has-validation">
<label for="base_down_offpeak">Down Offpeak</label>
<input type="number" class="form-control form-control-border @error('base_down_offpeak') is-invalid @enderror" id="base_down_offpeak" name="base_down_offpeak" value="{{ old('base_down_offpeak',$o?->base_down_offpeak) }}">
<span class="invalid-feedback" role="alert">
@error('base_down_offpeak')
{{ $message }}
@enderror
</span>
</div>
</div>
<!-- Base Down Offpeak -->
<div class="col-2">
<div class="form-group has-validation">
<label for="base_up_offpeak">Up Offpeak</label>
<input type="number" class="form-control form-control-border @error('base_up_offpeak') is-invalid @enderror" id="base_up_offpeak" name="base_up_offpeak" value="{{ old('base_up_offpeak',$o?->base_up_offpeak) }}">
<span class="invalid-feedback" role="alert">
@error('base_up_offpeak')
{{ $message }}
@enderror
</span>
</div>
</div>
<!-- Metric Divider -->
<div class="col-2">
<div class="form-group has-validation">
<label for="metric">Metric Divider</label>
<input type="number" class="form-control form-control-border @error('metric') is-invalid @enderror" id="metric" name="metric" placeholder="1000" value="{{ old('metric',$o?->metric) }}">
<span class="invalid-feedback" role="alert">
@error('metric')
{{ $message }}
@enderror
</span>
<span class="input-helper">Metric</span>
</div>
</div>
</div>
<div class="row mt-3">
<div class="offset-2 col-8">
<p class="text-small">Values determine the included traffic. A value of <strong>0</strong> means no traffic is included and charged at the Extra Traffic rates. An empty value means the traffic is not counted in this category.</p>
<p class="text-small">Any values charged at extra rates, the rate determines the value charged, and if the value is empty it will roll up to the <strong>Peak</strong> category or <strong>Down Peak</strong> if the Peak category is null.</p>
</div>
</div> </div>
<hr> <hr>
<div class="row mt-3"> <div class="row">
<div class="offset-2 col-8"> <div class="col-1">
<h3 class="text-md">Extra Traffic in $/mb</h3> <x-leenooks::form.toggle name="extra_shaped" label="Extra Shaped" :value="$o?->extra_shaped"/>
</div>
<div class="offset-1 col-10">
<div class="row">
<div class="col">
<h3 class="text-md">Included Traffic in MB</h3>
</div>
</div>
<div class="row">
<!-- Base Down Peak -->
<div class="col-2">
<x-leenooks::form.text class="text-right" name="base_down_peak" label="Down Peak" helper="Download Peak (mb)" :value="$o?->base_down_peak"/>
</div>
<!-- Base Up Peak -->
<div class="col-2">
<x-leenooks::form.text class="text-right" name="base_up_peak" label="Up Peak" helper="Upload Peak (mb)" :value="$o?->base_up_peak"/>
</div>
<!-- Base Down Offpeak -->
<div class="col-2">
<x-leenooks::form.text class="text-right" name="base_down_offpeak" label="Down OffPeak" helper="Download OffPeak (mb)" :value="$o?->base_down_offpeak"/>
</div>
<!-- Base Up Offpeak -->
<div class="col-2">
<x-leenooks::form.text class="text-right" name="base_up_offpeak" label="Up OffPeak" helper="Upload OffPeak (mb)" :value="$o?->base_up_offpeak"/>
</div>
<!-- Metric Divider -->
<div class="col-2">
<x-leenooks::form.text class="text-right" name="metric" label="Divider" helper="Traffic Divider to get MB" :value="$o?->metric"/>
</div>
</div>
<div class="row mt-3">
<div class="col">
<p class="text-small">Values determine the included traffic. A value of <strong>0</strong> means no traffic is included and charged at the Extra Traffic rates. An empty value means the traffic is not counted in this category.</p>
<p class="text-small">Any values charged at extra rates, the rate determines the value charged, and if the value is empty it will roll up to the <strong>Peak</strong> category or <strong>Down Peak</strong> if the Peak category is null.</p>
</div>
</div>
</div> </div>
</div> </div>
<hr>
<div class="row"> <div class="row">
<!-- Extra Down Peak --> <!-- @todo Add javascript so these toggles cannot both be on -->
<div class="offset-2 col-2"> <!-- Extra Charged -->
<div class="form-group has-validation"> <div class="col-1">
<label for="extra_down_peak">Down Peak</label> <x-leenooks::form.toggle name="extra_charged" label="Extra Charged" :value="$o?->extra_charged"/>
<input type="number" class="form-control form-control-border @error('extra_down_peak') is-invalid @enderror" id="extra_down_peak" name="extra_down_peak" value="{{ old('extra_down_peak',$o?->extra_down_peak) }}">
<span class="invalid-feedback" role="alert">
@error('extra_down_peak')
{{ $message }}
@enderror
</span>
</div>
</div> </div>
<!-- Extra Down Peak --> <div class="offset-1 col-10">
<div class="col-2"> <div class="row">
<div class="form-group has-validation"> <div class="col-8">
<label for="extra_up_peak">Up Peak</label> <h3 class="text-md">Extra Traffic in $/mb</h3>
<input type="number" class="form-control form-control-border @error('extra_up_peak') is-invalid @enderror" id="extra_up_peak" name="extra_up_peak" value="{{ old('extra_up_peak',$o?->extra_up_peak) }}"> </div>
<span class="invalid-feedback" role="alert">
@error('extra_up_peak')
{{ $message }}
@enderror
</span>
</div> </div>
</div>
<!-- Extra Down Offpeak --> <div class="row">
<div class="col-2"> <!-- Extra Down Peak -->
<div class="form-group has-validation"> <div class="col-2">
<label for="extra_down_offpeak">Down Offpeak</label> <x-leenooks::form.text class="text-right" name="extra_down_peak" label="Extra Down Peak" helper="Extra Download Peak ($/mb)" :value="$o?->extra_down_peak"/>
<input type="number" class="form-control form-control-border @error('extra_down_offpeak') is-invalid @enderror" id="extra_down_offpeak" name="extra_down_offpeak" value="{{ old('extra_down_offpeak',$o?->extra_down_offpeak) }}"> </div>
<span class="invalid-feedback" role="alert">
@error('extra_down_offpeak')
{{ $message }}
@enderror
</span>
</div>
</div>
<!-- Extra Down Offpeak --> <!-- Extra Up Peak -->
<div class="col-2"> <div class="col-2">
<div class="form-group has-validation"> <x-leenooks::form.text class="text-right" name="extra_up_peak" label="Up Peak" helper="Extra Upload Peak ($/mb)" :value="$o?->extra_up_peak"/>
<label for="extra_up_offpeak">Up Offpeak</label> </div>
<input type="number" class="form-control form-control-border @error('extra_up_offpeak') is-invalid @enderror" id="extra_up_offpeak" name="extra_up_offpeak" value="{{ old('extra_up_offpeak',$o?->extra_up_offpeak) }}">
<span class="invalid-feedback" role="alert"> <!-- Extra Down Offpeak -->
@error('extra_up_offpeak') <div class="col-2">
{{ $message }} <x-leenooks::form.text class="text-right" name="extra_down_offpeak" label="Down OffPeak" helper="Extra Download OffPeak ($/mb)" :value="$o?->extra_down_offpeak"/>
@enderror </div>
</span>
<!-- Extra Up Offpeak -->
<div class="col-2">
<x-leenooks::form.text class="text-right" name="extra_up_offpeak" label="Up OffPeak" helper="Extra Upload OffPeak ($/mb)" :value="$o?->extra_up_offpeak"/>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,4 +1,7 @@
<!-- $o = Supplier::class --> <!-- $spo=Supplier::class -->
@use(App\Models\Supplier)
@use(Carbon\Carbon)
<div class="row"> <div class="row">
<div class="col-9"> <div class="col-9">
<table class="table table-sm"> <table class="table table-sm">
@ -14,14 +17,14 @@
</thead> </thead>
<tbody> <tbody>
@foreach (\App\Models\Supplier::offeringTypes($o) as $key => $offering) @foreach (Supplier::offeringTypes($spo) as $key => $offering)
<tr> <tr>
<th>{{ $offering->type }}</th> <th>{{ $offering->type }}</th>
@if(Arr::get($o->detail->connections,$key)) @if(Arr::get($spo->detail->connections,$key))
<td>{{ Arr::get($o->detail->connections,$key.'.user') }}</td> <td>{{ Arr::get($spo->detail->connections,$key.'.user') }}</td>
<td>{{ Arr::get($o->detail->connections,$key.'.pass') }}</td> <td>{{ Arr::get($spo->detail->connections,$key.'.pass') }}</td>
<td>{{ Arr::get($o->detail->connections,$key.'.url') }}</td> <td>{{ Arr::get($spo->detail->connections,$key.'.url') }}</td>
<td>{{ \Carbon\Carbon::createFromFormat('Y-m-d',Arr::get($o->detail->connections,$key.'.last'))->format('Y-m-d') }}</td> <td>{{ Carbon::createFromFormat('Y-m-d',Arr::get($spo->detail->connections,$key.'.last'))->format('Y-m-d') }}</td>
<td class="text-right">{{ number_format($offering->items->count()) }}</td> <td class="text-right">{{ number_format($offering->items->count()) }}</td>
@else @else
<td colspan="5">&nbsp;</td> <td colspan="5">&nbsp;</td>

View File

@ -1,10 +1,10 @@
<!-- $o = Supplier::class --> <!-- $pdo=Supplier::class -->
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<h3>Supplier Details @include('adminlte::widget.success_button')</h3> <h3>Supplier Details <x-leenooks::button.success class="float-right"/></h3>
<hr> <hr>
<form class="g-0 needs-validation" method="POST" enctype="multipart/form-data" role="form"> <form method="POST">
@csrf @csrf
<div class="row"> <div class="row">
@ -12,23 +12,12 @@
<div class="row"> <div class="row">
<!-- Supplier Active --> <!-- Supplier Active -->
<div class="col-12 col-sm-3"> <div class="col-12 col-sm-3">
<div class="form-group left"> <x-leenooks::form.toggle name="active" label="Active" :value="$spo->active"/>
<div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
<input type="checkbox" class="custom-control-input" id="active" name="active" {{ old('active',$o->active) ? 'checked' : '' }}>
<label class="custom-control-label" for="active">Active</label>
</div>
</div>
</div> </div>
<!-- Supplier Name --> <!-- Supplier Name -->
<div class="col-12 col-sm-9"> <div class="col-12 col-sm-9">
@include('adminlte::widget.form_text',[ <x-leenooks::form.text name="name" icon="fa-tag" label="Supplier Name" :value="$spo->name ?? ''"/>
'label'=>'Supplier Name',
'id'=>'name',
'old'=>'name',
'name'=>'name',
'value'=>$o->name ?? '',
])
</div> </div>
</div> </div>
@ -37,8 +26,8 @@
<div class="col-12"> <div class="col-12">
<div class="form-group"> <div class="form-group">
<label for="address1">Address Lines</label> <label for="address1">Address Lines</label>
<input type="text" style="border-bottom-left-radius:0;border-bottom-right-radius:0;" class="form-control @error('address1') is-invalid @enderror" id="address1" name="address1" value="{{ old('address1',$o->address1) }}"> <input type="text" style="border-bottom-left-radius:0;border-bottom-right-radius:0;" class="form-control @error('address1') is-invalid @enderror" id="address1" name="address1" value="{{ old('address1',$spo->address1) }}">
<input type="text" style="border-top-left-radius:0;border-top-right-radius:0;" class="form-control" id="address2" name="address2" value="{{ old('address2',$o->address2) }}"> <input type="text" style="border-top-left-radius:0;border-top-right-radius:0;border-top:0;" class="form-control" id="address2" name="address2" value="{{ old('address2',$spo->address2) }}">
<span class="invalid-feedback" role="alert"> <span class="invalid-feedback" role="alert">
@error('address1') @error('address1')
{{ $message }} {{ $message }}
@ -53,37 +42,19 @@
<div class="row"> <div class="row">
<!-- City --> <!-- City -->
<div class="col-12"> <div class="col-12">
@include('adminlte::widget.form_text',[ <x-leenooks::form.text name="city" label="City" :value="$spo->city ?? ''"/>
'label'=>'City',
'id'=>'city',
'old'=>'city',
'name'=>'city',
'value'=>$o->city ?? '',
])
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<!-- State --> <!-- State -->
<div class="col-12 col-sm-9"> <div class="col-12 col-sm-9">
@include('adminlte::widget.form_text',[ <x-leenooks::form.text name="state" label="State" :value="$spo->state ?? ''"/>
'label'=>'State',
'id'=>'state',
'old'=>'state',
'name'=>'state',
'value'=>$o->state ?? '',
])
</div> </div>
<!-- Postal Code --> <!-- Postal Code -->
<div class="col-12 col-sm-3"> <div class="col-12 col-sm-3">
@include('adminlte::widget.form_text',[ <x-leenooks::form.text name="postcode" label="Post Code" :value="$spo->postcode ?? ''"/>
'label'=>'Post Code',
'id'=>'postcode',
'old'=>'postcode',
'name'=>'postcode',
'value'=>$o->postcode ?? '',
])
</div> </div>
</div> </div>
</div> </div>
@ -92,69 +63,41 @@
<div class="row"> <div class="row">
<!-- Accounts Email --> <!-- Accounts Email -->
<div class="col-12"> <div class="col-12">
@include('adminlte::widget.form_text',[ <x-leenooks::form.email name="supplier_details[accounts]" label="Accounts Email" old="supplier_details.accounts" :value="$spo?->detail->accounts ?? ''"/>
'label'=>'Accounts Email',
'id'=>'supplier_details.accounts',
'old'=>'supplier_details.accounts',
'name'=>'supplier_details[accounts]',
'value'=>($o->detail ? $o->detail->accounts : ''),
])
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<!-- Support Email --> <!-- Support Email -->
<div class="col-12"> <div class="col-12">
@include('adminlte::widget.form_text',[ <x-leenooks::form.email name="supplier_details[support]" label="Support Email" old="supplier_details.support" :value="$spo?->detail->support ?? ''"/>
'label'=>'Support Email',
'id'=>'supplier_details.support',
'old'=>'supplier_details.support',
'name'=>'supplier_details[support]',
'value'=>($o->detail ? $o->detail->support : ''),
])
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<!-- Payment Details --> <!-- Payment Details -->
<div class="col-12"> <div class="col-12">
@include('adminlte::widget.form_text',[ <x-leenooks::form.email name="supplier_details[payments]" label="Payment Details" old="supplier_details.payments" :value="$spo?->detail->payments ?? ''"/>
'label'=>'Payment Details',
'id'=>'supplier_details.payments',
'old'=>'supplier_details.payments',
'name'=>'supplier_details[payments]',
'value'=>($o->detail ? $o->detail->support : ''),
])
</div> </div>
</div> </div>
@if($o->api_class()) @if($spo->api_class())
<hr> <hr>
<p class="h6"><i class="fa-fw fas fa-sitemap"></i> <strong>{{ $o->api_class() }}</strong></p> <p class="h6">
<i class="fa-fw fas fa-sitemap"></i> <strong>{{ $spo->api_class() }}</strong>
</p>
<div class="row"> <div class="row">
<!-- API Details --> <!-- API Details -->
<div class="col-12"> <div class="col-12">
@include('adminlte::widget.form_text',[ <x-leenooks::form.text name="api_key" label="API Key" :value="($spo->detail ? Arr::get($spo->detail->connections,'api_key') : '')"/>
'label'=>'API Key',
'id'=>'api_key',
'old'=>'api_key',
'name'=>'api_key',
'value'=>($o->detail ? Arr::get($o->detail->connections,'api_key') : ''),
])
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<!-- API Details --> <!-- API Details -->
<div class="col-12"> <div class="col-12">
@include('adminlte::widget.form_text',[ <x-leenooks::form.text name="api_secret" label="API Secret" :value="($spo->detail ? Arr::get($spo->detail->connections,'api_secret') : '')"/>
'label'=>'API Secret',
'id'=>'api_secret',
'old'=>'api_secret',
'name'=>'api_secret',
'value'=>($o->detail ? Arr::get($o->detail->connections,'api_secret') : ''),
])
</div> </div>
</div> </div>
@endif @endif
@ -164,25 +107,15 @@
<div class="row"> <div class="row">
<!-- Notes --> <!-- Notes -->
<div class="col-12"> <div class="col-12">
<div class="form-group has-validation"> <x-leenooks::form.textarea name="supplier_details[notes]" label="Notes" :value="($spo->detail ? $spo->detail->notes : '')"/>
<label for="notes">Notes</label>
<textarea class="form-control @error('supplier_details.notes') is-invalid @enderror" id="notes" name="supplier_details[notes]" placeholder="Notes...">{{ old('supplier_details.notes',($o->detail ? $o->detail->notes : '')) }}</textarea>
<span class="invalid-feedback" role="alert">
@error('supplier_details.notes')
{{ $message }}
@enderror
</span>
</div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<!-- Buttons --> <!-- Buttons -->
<div class="col-12"> <div class="col">
<a href="{{ url('/home') }}" class="btn btn-danger">Cancel</a> <x-leenooks::button.cancel/>
@can('wholesaler') <x-leenooks::button.submit class="float-right">@if($spo?->exists)Update @else Add @endif</x-leenooks::button.submit>
<button type="submit" name="submit" class="btn btn-success mr-0 float-right">@if ($o->exists)Save @else Add @endif</button>
@endcan
</div> </div>
</div> </div>
</form> </form>

View File

@ -1,8 +1,10 @@
<!-- $o = Supplier::class --> <!-- $spo=Supplier::class -->
@use(App\Models\Supplier)
<div class="row"> <div class="row">
<div class="col-5 col-sm-2"> <div class="col-5 col-sm-2">
<div class="nav flex-column nav-tabs h-100" role="tablist" aria-orientation="vertical"> <div class="nav flex-column nav-tabs h-100" role="tablist" aria-orientation="vertical">
@foreach(\App\Models\Supplier::offeringTypes($o) as $key => $offering) @foreach(Supplier::offeringTypes($spo) as $key => $offering)
<a class="nav-link @if($loop->first)active @endif" id="offering-{{ $key }}-tab" data-toggle="pill" href="#offering-{{ $key }}-profile" role="tab" aria-controls="offering-{{ $key }}-tab" aria-selected="true">{{ $offering->type }}</a> <a class="nav-link @if($loop->first)active @endif" id="offering-{{ $key }}-tab" data-toggle="pill" href="#offering-{{ $key }}-profile" role="tab" aria-controls="offering-{{ $key }}-tab" aria-selected="true">{{ $offering->type }}</a>
@endforeach @endforeach
</div> </div>
@ -10,7 +12,7 @@
<div class="col-7 col-sm-10"> <div class="col-7 col-sm-10">
<div class="tab-content"> <div class="tab-content">
@foreach(\App\Models\Supplier::offeringTypes($o) as $key => $offering) @foreach(Supplier::offeringTypes($spo) as $key => $offering)
<div class="tab-pane text-left fade show @if($loop->first)active @endif" id="offering-{{ $key }}-profile" role="tabpanel" aria-labelledby="offering-{{ $key }}-tab"> <div class="tab-pane text-left fade show @if($loop->first)active @endif" id="offering-{{ $key }}-profile" role="tabpanel" aria-labelledby="offering-{{ $key }}-tab">
<table class="table table-sm table-bordered w-100" id="offering-{{ $key }}-table"> <table class="table table-sm table-bordered w-100" id="offering-{{ $key }}-table">
<thead> <thead>
@ -66,13 +68,12 @@
</div> </div>
</div> </div>
@section('page-scripts') @pa(datatables)
@css(datatables,bootstrap4)
@js(datatables,bootstrap4)
@section('page-scripts')
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
@foreach(\App\Models\Supplier::offeringTypes($o) as $key => $offering) @foreach(Supplier::offeringTypes($spo) as $key => $offering)
$('#offering-{{ $key }}-table').DataTable(); $('#offering-{{ $key }}-table').DataTable();
$('#offering-{{ $key }}-table tbody').on('click','tr', function () { $('#offering-{{ $key }}-table tbody').on('click','tr', function () {

View File

@ -1,8 +1,10 @@
<!-- $o = Supplier::class --> <!-- $spo=Supplier::class -->
@use(App\Models\Supplier)
<div class="row"> <div class="row">
<div class="col-5 col-sm-2"> <div class="col-5 col-sm-2">
<div class="nav flex-column nav-tabs h-100" role="tablist" aria-orientation="vertical"> <div class="nav flex-column nav-tabs h-100" role="tablist" aria-orientation="vertical">
@foreach(\App\Models\Supplier::offeringTypes($o) as $key => $offering) @foreach(Supplier::offeringTypes($spo) as $key => $offering)
<a class="nav-link @if($loop->first)active @endif" id="products-{{ $key }}-tab" data-toggle="pill" href="#products-{{ $key }}-profile" role="tab" aria-controls="products-{{ $key }}-tab" aria-selected="true">{{ $offering->type }}</a> <a class="nav-link @if($loop->first)active @endif" id="products-{{ $key }}-tab" data-toggle="pill" href="#products-{{ $key }}-profile" role="tab" aria-controls="products-{{ $key }}-tab" aria-selected="true">{{ $offering->type }}</a>
@endforeach @endforeach
</div> </div>
@ -10,7 +12,7 @@
<div class="col-7 col-sm-10"> <div class="col-7 col-sm-10">
<div class="tab-content"> <div class="tab-content">
@foreach(\App\Models\Supplier::offeringTypes($o) as $key => $offering) @foreach(Supplier::offeringTypes($spo) as $key => $offering)
<div class="tab-pane text-left fade show @if($loop->first)active @endif" id="products-{{ $key }}-profile" role="tabpanel" aria-labelledby="products-{{ $key }}-tab"> <div class="tab-pane text-left fade show @if($loop->first)active @endif" id="products-{{ $key }}-profile" role="tabpanel" aria-labelledby="products-{{ $key }}-tab">
<table class="table table-sm table-bordered w-100" id="products-{{ $key }}-table"> <table class="table table-sm table-bordered w-100" id="products-{{ $key }}-table">
<thead> <thead>
@ -34,10 +36,10 @@
</thead> </thead>
<tbody> <tbody>
@foreach($xx=$offering->items->with(['products.products.services','products.products.type.supplied','products.products.translate'])->get() as $oo) @foreach($xx=$offering->items->with(['products.products.services','products.products.type.supplied.supplier_detail','products.products.translate'])->get() as $oo)
@foreach($oo->products->pluck('products')->flatten()->filter() as $po) @foreach($oo->products->pluck('products')->flatten()->filter() as $po)
<tr> <tr>
<td><a href="{{ url('a/supplier/product/addedit',[$po->supplier->id,$po->supplied->id,$po->supplied->category]) }}">{{ $po->lid }}</a></td> <td><a href="{{ url('a/supplier/product',[$po->supplier->id,$po->supplied->id,$po->supplied->category]) }}">{{ $po->lid }}</a></td>
<td>{{ $po->pid }}</td> <td>{{ $po->pid }}</td>
<td>{{ $po->name }}</td> <td>{{ $po->name }}</td>
<td class="text-right">{{ $po->active ? 'YES' : 'NO' }}</td> <td class="text-right">{{ $po->active ? 'YES' : 'NO' }}</td>
@ -69,13 +71,12 @@
</div> </div>
</div> </div>
@section('page-scripts') @pa(datatables)
@css(datatables,bootstrap4)
@js(datatables,bootstrap4)
@section('page-scripts')
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
@foreach(\App\Models\Supplier::offeringTypes($o) as $key => $offering) @foreach(Supplier::offeringTypes($spo) as $key => $offering)
$('#products-{{ $key }}-table').DataTable(); $('#products-{{ $key }}-table').DataTable();
$('#products-{{ $key }}-table tbody').on('click','tr', function () { $('#products-{{ $key }}-table tbody').on('click','tr', function () {

View File

@ -1,3 +1,6 @@
<!-- ($o??$user)=User::class -->
@use(App\Models\Country)
@extends('adminlte::layouts.app') @extends('adminlte::layouts.app')
@section('htmlheader_title') @section('htmlheader_title')
@ -14,8 +17,6 @@
{{ ($o??$user)->role }} {{ ($o??$user)->role }}
@endsection @endsection
@use(App\Models\Country)
<!-- ($o??$user)=User::class -->
@section('main-content') @section('main-content')
<div class="row"> <div class="row">
<div class="col"> <div class="col">
@ -93,7 +94,7 @@
<div class="row"> <div class="row">
<div class="col-12 col-md-6"> <div class="col-12 col-md-6">
<x-leenooks::form.select id="country" name="country_id" icon="fa-globe" label="Country" :value="($o??$user)->country_id ?? ''" :options="Country::select(['id','name'])->active()->get()->map(function($item) { $item->value = $item->name; return $item; })->toArray()"/> <x-leenooks::form.select id="country" name="country_id" icon="fa-globe" label="Country" :value="($o??$user)->country_id ?? ''" :options="Country::select(['id','name'])->active()->get()->map(fn($item)=>['id'=>$item->id,'value'=>$item->name])"/>
</div> </div>
</div> </div>
</div> </div>

View File

@ -90,7 +90,7 @@
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a href="{{ url('a/supplier/product/add') }}" @class(['nav-link','active'=>preg_match('#^a/supplier/product/(add|edit)#',$path)])> <a href="{{ url('a/supplier/product/new') }}" @class(['nav-link','active'=>preg_match('#^a/supplier/product/(add|edit)#',$path)])>
<i class="nav-icon fas fa-barcode"></i> <p>New Product</p> <i class="nav-icon fas fa-barcode"></i> <p>New Product</p>
</a> </a>
</li> </li>

View File

@ -99,21 +99,21 @@ Route::group(['middleware'=>['auth','role:wholesaler'],'prefix'=>'a'],function()
Route::get('supplied_products',[ProductController::class,'api_supplied_products']); Route::get('supplied_products',[ProductController::class,'api_supplied_products']);
// Supplier Setup // Supplier Setup
Route::get('supplier',[SupplierController::class,'admin_home']); Route::view('supplier','theme.backend.adminlte.supplier.home');
Route::get('supplier/cost/new/{o}',[SupplierController::class,'cost_add']); Route::get('supplier/cost/new/{o}',[SupplierController::class,'cost_add']);
Route::post('supplier/cost/new/{o}',[SupplierController::class,'cost_submit']); Route::post('supplier/cost/new/{o}',[SupplierController::class,'cost_submit']);
Route::get('supplier/cost/{o}',[SupplierController::class,'cost']) Route::get('supplier/cost/{o}',[SupplierController::class,'cost'])
->where('o','[0-9]+'); ->where('o','[0-9]+');
Route::get('supplier/details/{o?}',[SupplierController::class,'view']) Route::view('supplier/details/{spo}','theme.backend.adminlte.supplier.details')
->where('o','[0-9]+'); ->where('spo','[0-9]+');
Route::post('supplier/details/{o?}',[SupplierController::class,'addedit']) Route::post('supplier/details/{o?}',[SupplierController::class,'addedit'])
->where('o','[0-9]+'); ->where('o','[0-9]+');
Route::get('supplier/product/add',[SupplierController::class,'product_add']); Route::view('supplier/product/new','theme.backend.adminlte.supplier.product.addedit');
Route::get('supplier/product/addedit/{o}/{oo}/{type}',[SupplierController::class,'product_view']) Route::view('supplier/product/{spo}/{id}/{type}','theme.backend.adminlte.supplier.product.addedit')
->where('o','[0-9]+') ->where('spo','[0-9]+')
->where('oo','[0-9]+') ->where('id','[0-9]+')
->whereIn('type',Supplier::offeringTypeKeys()->toArray()); ->whereIn('type',Supplier::offeringTypeKeys()->toArray());
Route::post('supplier/product/addedit/{o}/{oo}/{type}',[SupplierController::class,'product_addedit']) Route::post('supplier/product/{o}/{oo}/{type}',[SupplierController::class,'product_addedit'])
->where('o','[0-9]+') ->where('o','[0-9]+')
->where('oo','[0-9]+') ->where('oo','[0-9]+')
->whereIn('type',Supplier::offeringTypeKeys()->toArray()); ->whereIn('type',Supplier::offeringTypeKeys()->toArray());