Compare commits

..

No commits in common. "2c3665650caeab4b3ee4d70edf36ac65b84c9005" and "283ae06a5ce7293a18754a01bfbdca2dd5426dc5" have entirely different histories.

27 changed files with 581 additions and 279 deletions

View File

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

View File

@ -4,11 +4,10 @@ namespace App\Http\Controllers;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use App\Http\Requests\{SupplierAddEdit,SupplierProductAddEdit};
use App\Jobs\ImportCosts;
use App\Models\{Cost,Supplier,SupplierDetail};
use App\Jobs\ImportCosts;
class SupplierController extends Controller
{
@ -21,7 +20,9 @@ class SupplierController extends Controller
*/
public function addedit(SupplierAddEdit $request,Supplier $o)
{
foreach (Arr::except($request->validated(),['supplier_details','api_key','api_secret','submit']) as $key => $item)
$this->middleware(['auth','wholesaler']);
foreach ($request->except(['_token','supplier_details','api_key','api_secret','submit']) as $key => $item)
$o->{$key} = $item;
$o->active = (bool)$request->active;
@ -50,6 +51,19 @@ 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
*
@ -85,9 +99,19 @@ class SupplierController extends Controller
$filename,
)->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)
@ -103,7 +127,7 @@ class SupplierController extends Controller
$oo = Supplier\Broadband::findOrNew($id);
// @todo these are broadband requirements - get them from the broadband class.
foreach (Arr::only($request->validated(),[
foreach ($request->only([
'supplier_detail_id',
'product_id'.
'product_desc',
@ -127,8 +151,8 @@ class SupplierController extends Controller
$oo->$key = $value;
// Our boolean values
foreach (Arr::only($request->validated(),['active','extra_shaped','extra_charged']) as $key => $value)
$oo->{$key} = ($value == 'on' ? 1 : 0);
foreach ($request->only(['active','extra_shaped','extra_charged']) as $key => $value)
$oo->$key = ($value == 'on' ? 1 : 0);
break;
@ -138,11 +162,28 @@ 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
*
@ -159,10 +200,24 @@ class SupplierController extends Controller
$request->session()->flashInput($request->old);
if ($o)
$o->load(['products.products.services']);
$o->load(['products.product.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);
}
}

View File

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

View File

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

View File

@ -21,7 +21,7 @@ abstract class Type extends Model
*/
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'))
$result->map(function($item) use ($config,$ceil) {
$result->transform(function($item) use ($config,$ceil) {
return $ceil
? (int)ceil($item/$config->get('metric'))
: $item/$config->get('metric');

View File

@ -7,8 +7,6 @@ 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;
@ -35,10 +33,9 @@ class AppServiceProvider extends ServiceProvider
$this->bootIntuitSocialite();
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);
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);
}
}

View File

@ -27,7 +27,7 @@
@endforeach
</tbody>
@if(($x=Supplier::active()->whereNotIn('id',$o->suppliers->pluck('id'))->orderBy(DB::raw('UPPER(name)'))->get())->count())
@if(($x=Supplier::active()->whereNotIn('id',$o->suppliers->pluck('id'))->orderBy('name')->get())->count())
<tfoot>
<tr>
<td colspan="3">
@ -36,7 +36,7 @@
<div class="row">
<div class="col-6">
<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])"/>
<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()"/>
</div>
<div class="col-4">

View File

@ -31,7 +31,7 @@
<input type="hidden" name="type" value="invoice">
<!-- @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(fn($item)=>['id'=>$item->id,'value'=>$item->name])"/>
<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; })"/>
<table id="invoices" class="table table-sm w-100">
<tr>

View File

@ -26,7 +26,7 @@
<div class="card-body">
<div class="row">
<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(fn($item)=>['id'=>$item->id,'value'=>$item->name])"/>
<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; })"/>
</div>
</div>
</div>

View File

@ -42,7 +42,7 @@
<div class="row">
<!-- Product Type -->
<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()->map(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()->transform(fn($item)=>['id'=>$item,'value'=>$item])"/>
</div>
</div>

View File

@ -12,7 +12,7 @@
<div class="row">
<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)->map(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)->transform(fn($item)=>['id'=>$item->id,'value'=>$item->name,'active'=>$item->active])"/>
</div>
</div>
</form>

View File

@ -41,7 +41,7 @@
<!-- PRODUCT -->
<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"
: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/>
: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/>
</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"
:value="$o->service->product_id"
: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/>
: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/>
<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="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()->map(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()->transform(fn($item)=>['id'=>$item->id,'value'=>$item->name])"/>
</div>
<div class="col-12 col-sm-9 col-md-12 col-xl-6">
@ -28,7 +28,7 @@
<div class="row">
<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()->map(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()->transform(fn($item)=>['id'=>$item->registrar_ns,'value'=>$item->registrar_ns])"/>
</div>
<div class="col-12 col-sm-9 col-md-12 col-xl-6">

View File

@ -16,7 +16,7 @@
<div class="row">
<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()->map(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()->transform(fn($item)=>['id'=>$item->id,'value'=>$item->name])"/>
</div>
</div>

View File

@ -1,14 +1,14 @@
@extends('adminlte::layouts.app')
@section('htmlheader_title')
{{ $spo->name ?: 'New Supplier' }}
{{ $o->name ?: 'New Supplier' }}
@endsection
@section('page_title')
{{ $spo->name ?: 'New Supplier' }}
{{ $o->name ?: 'New Supplier' }}
@endsection
@section('contentheader_title')
{{ $spo->name ?: 'New Supplier' }}
{{ $o->name ?: 'New Supplier' }}
@endsection
@section('contentheader_description')
@endsection
@ -20,7 +20,7 @@
<div class="card-header bg-dark d-flex p-0">
<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>
@if($spo->exists)
@if($o->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="#offerings" data-toggle="tab">Offerings</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')
</div>
@if($spo->exists)
@if($o->exists)
<div class="tab-pane fade" id="products" role="tabpanel">
@include('theme.backend.adminlte.supplier.widget.products')
</div>

View File

@ -1,5 +1,3 @@
@use(App\Models\Supplier)
@extends('adminlte::layouts.app')
@section('htmlheader_title')
@ -29,7 +27,16 @@
<div class="row">
<div class="col-12 col-sm-9 col-md-6 col-xl-5">
<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])"/>
@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'=>'',
])
</div>
</div>
</form>
@ -40,6 +47,9 @@
@endsection
@section('page-scripts')
@css(select2)
@js(select2,autofocus)
<script type="text/javascript">
$(document).ready(function() {
$('#supplier_id')

View File

@ -1,24 +1,16 @@
<!-- $spo=Supplier::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
<!-- $o = Supplier::class -->
<!-- $oo = Supplier/{type}::class -->
@extends('adminlte::layouts.app')
@section('htmlheader_title')
Supplier Product - @if (isset($oo) && $oo->exists)Edit @else New @endif
Supplier - @if ($oo && $oo->exists)Edit @else New @endif Product
@endsection
@section('page_title')
@if (isset($oo) && $oo->exists){{ $oo->name }} @else New @endif Product
@if ($oo && $oo->exists)Edit @else New @endif Product
@endsection
@section('contentheader_title')
Supplier Product - @if (isset($oo) && $oo->exists){{ $oo->name }} @else New @endif
Supplier - @if ($oo && $oo->exists)Edit @else New @endif Product
@endsection
@section('contentheader_description')
@endsection
@ -27,39 +19,70 @@ if(isset($spo)) {
<div class="row">
<div class="col-8">
<div class="card card-dark">
<div class="card-header p-2">
<div class="card-header">
<h1 class="card-title">Supplier Product</h1>
<!-- @todo Should this be a x-leenooks::success component -->
@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>
@endif
</div>
<div class="card-body">
<form method="POST">
<form class="g-0 needs-validation" method="POST" enctype="multipart/form-data" role="form">
@csrf
<input type="hidden" name="id" value="{{ $oo?->id ?? '' }}">
<input type="hidden" name="id" value="{{ $oo?->id }}">
<div class="row">
<div class="col-4">
<!-- Supplier -->
<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])"/>
<div class="form-group has-validation">
<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 class="col-4">
<!-- Offering Type -->
<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])"/>
<div class="form-group has-validation">
<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 id="type"></div>
<div class="row">
<!-- Buttons -->
<div class="col">
<x-leenooks::button.cancel/>
<x-leenooks::button.submit class="float-right">@if(isset($spo) && $spo?->exists)Update @else Add @endif</x-leenooks::button.submit>
<div class="col-12">
<a href="{{ url('/home') }}" class="btn btn-danger">Cancel</a>
@can('wholesaler')
<button type="submit" name="submit" class="btn btn-success mr-0 float-right">@if ($oo && $oo->exists)Save @else Add @endif</button>
@endcan
</div>
</div>
</form>
@ -67,16 +90,16 @@ if(isset($spo)) {
</div>
</div>
@if(isset($oo) && $oo->exists)
@if($oo && $oo->exists)
<div class="col-4">
<div class="row">
<div class="col-12">
<div class="card card-info">
<div class="card-header p-2">
<div class="card-header">
<h1 class="card-title">Offering Products</h1>
</div>
<div class="card-body p-2">
<div class="card-body">
<table class="table table-sm">
<thead>
<tr>
@ -89,14 +112,12 @@ if(isset($spo)) {
<tbody>
@foreach ($oo->products as $pto)
@foreach ($pto->products as $po)
<tr>
<td>{{ $po->id }}</td>
<td>{{ $po->name }}</td>
<td class="text-right">{{ $po->services->where('active',true)->count() }}</td>
<td class="text-right">{{ $po->services->count() }}</td>
</tr>
@endforeach
<tr>
<td>{{ $pto->id }}</td>
<td>{{ $pto->product->name }}</td>
<td class="text-right">{{ $pto->product->services->where('active',true)->count() }}</td>
<td class="text-right">{{ $pto->product->services->count() }}</td>
</tr>
@endforeach
</tbody>
</table>
@ -108,12 +129,12 @@ if(isset($spo)) {
<div class="row">
<div class="col-12">
<div class="card card-info">
<div class="card-header p-2">
<div class="card-header">
<h1 class="card-title">Services Using this Supplier Product</h1>
</div>
<div class="card-body p-2">
<table class="table table-hover table-sm" id="services">
<div class="card-body">
<table class="table table-sm" id="services">
<thead>
<tr>
<th>ID</th>
@ -125,15 +146,13 @@ if(isset($spo)) {
<tbody>
@foreach ($oo->products as $pto)
@foreach ($pto->products as $po)
@foreach ($po->services as $so)
<tr>
<td><a href="{{ url('u/service',[$so->id]) }}">{{ $so->lid }}</a></td>
<td>{{ $po->name }}</td>
<td>{{ $so->name }}</td>
<td>{{ $so->active ? 'Active' : 'Not Active' }}</td>
</tr>
@endforeach
@foreach ($pto->product->services as $so)
<tr>
<td><a href="{{ url('u/service',[$so->id]) }}">{{ $so->lid }}</a></td>
<td>{{ $so->product->type->id }}</td>
<td>{{ $so->name }}</td>
<td>{{ $so->active ? 'Active' : 'Not Active' }}</td>
</tr>
@endforeach
@endforeach
</tbody>
@ -147,9 +166,10 @@ if(isset($spo)) {
</div>
@endsection
@pa(datatables,rowgroup|conditionalpaging)
@section('page-scripts')
@css(datatables,bootstrap4|rowgroup)
@js(datatables,bootstrap4|responsive|rowgroup)
<script type="text/javascript">
$(document).ready(function() {
function load_type(type,id) {
@ -161,7 +181,7 @@ if(isset($spo)) {
url: '{{ url('a/supplier/product/view') }}/'+type+(id ? '/'+id : ''),
timeout: 2000,
error: function(x) {
//spinner.toggleClass('d-none').toggleClass('fa-spin');
spinner.toggleClass('d-none').toggleClass('fa-spin');
alert('Failed to submit');
},
success: function(data) {
@ -170,7 +190,7 @@ if(isset($spo)) {
});
}
@if (isset($oo) && $oo->exists)
@if ($oo && $oo->exists)
$('#offering_type').attr('style','pointer-events: none;');
load_type('{{$oo->category}}',{{$oo->id}})
@endif
@ -183,18 +203,17 @@ if(isset($spo)) {
});
$('#services').DataTable({
conditionalPaging: true,
order: [[3,'asc'],[1,'asc'],[2,'asc']],
rowGroup: {
dataSrc: 1,
dataSrc: 3,
},
columnDefs: [
{
targets: [1],
targets: [3],
visible: false,
}
],
});
});
</script>
@append
@endsection

View File

@ -1,148 +1,308 @@
<!-- $o = Supplier{type}::class -->
<div class="row">
<!-- Supplier Name -->
<div class="col-4">
<x-leenooks::form.text name="product_id" label="Product ID" icon="fa-tag" helper="Supplier's Product ID" :value="$o?->product_id"/>
<div class="col-3">
<div class="form-group has-validation">
<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>
<!-- Suppliers Description -->
<div class="col-8">
<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"/>
<div class="offset-1 col-8">
<div class="form-group has-validation">
<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 class="row">
<!-- Supplier Active -->
<div class="col-1">
<x-leenooks::form.toggle name="active" label="Active" :value="$o?->active"/>
</div>
<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 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="active" name="active" {{ old('active',$o?->active) ? 'checked' : '' }}>
<label class="custom-control-label" for="active">Active</label>
</div>
</div>
</div>
<div class="row">
<div class="col-2">
<x-leenooks::form.time class="text-right" name="offpeak_start" label="OffPeak Start" :value="($o && $o->offpeak_start) ? $o->offpeak_start->format('H:i') : ''"/>
</div>
<!-- Base Cost -->
<div class="offset-1 col-2">
<div class="form-group has-validation">
<label for="base_cost">Base (ex)</label>
<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>
<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>
<!-- Setup Cost -->
<div class="col-2">
<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>
<hr>
<div class="row">
<div class="col-1">
<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>
<hr>
<div class="row">
<!-- @todo Add javascript so these toggles cannot both be on -->
<!-- Extra Charged -->
<div class="col-1">
<x-leenooks::form.toggle name="extra_charged" label="Extra Charged" :value="$o?->extra_charged"/>
</div>
<div class="offset-1 col-10">
<div class="row">
<div class="col-8">
<h3 class="text-md">Extra Traffic in $/mb</h3>
<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 class="row">
<!-- Extra Down Peak -->
<div class="col-2">
<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"/>
</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>
<!-- Extra Up Peak -->
<div class="col-2">
<x-leenooks::form.text class="text-right" name="extra_up_peak" label="Up Peak" helper="Extra Upload Peak ($/mb)" :value="$o?->extra_up_peak"/>
</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>
<!-- Extra Down Offpeak -->
<div class="col-2">
<x-leenooks::form.text class="text-right" name="extra_down_offpeak" label="Down OffPeak" helper="Extra Download OffPeak ($/mb)" :value="$o?->extra_down_offpeak"/>
<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>
<!-- 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 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>
<hr>
<div class="row mt-3">
<div class="offset-2 col-8">
<h3 class="text-md">Extra Traffic in $/mb</h3>
</div>
</div>
<div class="row">
<!-- Extra Down Peak -->
<div class="offset-2 col-2">
<div class="form-group has-validation">
<label for="extra_down_peak">Down Peak</label>
<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>
<!-- Extra Down Peak -->
<div class="col-2">
<div class="form-group has-validation">
<label for="extra_up_peak">Up Peak</label>
<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) }}">
<span class="invalid-feedback" role="alert">
@error('extra_up_peak')
{{ $message }}
@enderror
</span>
</div>
</div>
<!-- Extra Down Offpeak -->
<div class="col-2">
<div class="form-group has-validation">
<label for="extra_down_offpeak">Down Offpeak</label>
<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) }}">
<span class="invalid-feedback" role="alert">
@error('extra_down_offpeak')
{{ $message }}
@enderror
</span>
</div>
</div>
<!-- Extra Down Offpeak -->
<div class="col-2">
<div class="form-group has-validation">
<label for="extra_up_offpeak">Up Offpeak</label>
<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">
@error('extra_up_offpeak')
{{ $message }}
@enderror
</span>
</div>
</div>
</div>

View File

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

View File

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

View File

@ -1,10 +1,8 @@
<!-- $spo=Supplier::class -->
@use(App\Models\Supplier)
<!-- $o = Supplier::class -->
<div class="row">
<div class="col-5 col-sm-2">
<div class="nav flex-column nav-tabs h-100" role="tablist" aria-orientation="vertical">
@foreach(Supplier::offeringTypes($spo) as $key => $offering)
@foreach(\App\Models\Supplier::offeringTypes($o) 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>
@endforeach
</div>
@ -12,7 +10,7 @@
<div class="col-7 col-sm-10">
<div class="tab-content">
@foreach(Supplier::offeringTypes($spo) as $key => $offering)
@foreach(\App\Models\Supplier::offeringTypes($o) 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">
<table class="table table-sm table-bordered w-100" id="offering-{{ $key }}-table">
<thead>
@ -68,12 +66,13 @@
</div>
</div>
@pa(datatables)
@section('page-scripts')
@css(datatables,bootstrap4)
@js(datatables,bootstrap4)
<script type="text/javascript">
$(document).ready(function() {
@foreach(Supplier::offeringTypes($spo) as $key => $offering)
@foreach(\App\Models\Supplier::offeringTypes($o) as $key => $offering)
$('#offering-{{ $key }}-table').DataTable();
$('#offering-{{ $key }}-table tbody').on('click','tr', function () {

View File

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

View File

@ -1,6 +1,3 @@
<!-- ($o??$user)=User::class -->
@use(App\Models\Country)
@extends('adminlte::layouts.app')
@section('htmlheader_title')
@ -17,6 +14,8 @@
{{ ($o??$user)->role }}
@endsection
@use(App\Models\Country)
<!-- ($o??$user)=User::class -->
@section('main-content')
<div class="row">
<div class="col">
@ -94,7 +93,7 @@
<div class="row">
<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(fn($item)=>['id'=>$item->id,'value'=>$item->name])"/>
<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()"/>
</div>
</div>
</div>

View File

@ -90,7 +90,7 @@
</li>
<li class="nav-item">
<a href="{{ url('a/supplier/product/new') }}" @class(['nav-link','active'=>preg_match('#^a/supplier/product/(add|edit)#',$path)])>
<a href="{{ url('a/supplier/product/add') }}" @class(['nav-link','active'=>preg_match('#^a/supplier/product/(add|edit)#',$path)])>
<i class="nav-icon fas fa-barcode"></i> <p>New Product</p>
</a>
</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']);
// Supplier Setup
Route::view('supplier','theme.backend.adminlte.supplier.home');
Route::get('supplier',[SupplierController::class,'admin_home']);
Route::get('supplier/cost/new/{o}',[SupplierController::class,'cost_add']);
Route::post('supplier/cost/new/{o}',[SupplierController::class,'cost_submit']);
Route::get('supplier/cost/{o}',[SupplierController::class,'cost'])
->where('o','[0-9]+');
Route::view('supplier/details/{spo}','theme.backend.adminlte.supplier.details')
->where('spo','[0-9]+');
Route::get('supplier/details/{o?}',[SupplierController::class,'view'])
->where('o','[0-9]+');
Route::post('supplier/details/{o?}',[SupplierController::class,'addedit'])
->where('o','[0-9]+');
Route::view('supplier/product/new','theme.backend.adminlte.supplier.product.addedit');
Route::view('supplier/product/{spo}/{id}/{type}','theme.backend.adminlte.supplier.product.addedit')
->where('spo','[0-9]+')
->where('id','[0-9]+')
Route::get('supplier/product/add',[SupplierController::class,'product_add']);
Route::get('supplier/product/addedit/{o}/{oo}/{type}',[SupplierController::class,'product_view'])
->where('o','[0-9]+')
->where('oo','[0-9]+')
->whereIn('type',Supplier::offeringTypeKeys()->toArray());
Route::post('supplier/product/{o}/{oo}/{type}',[SupplierController::class,'product_addedit'])
Route::post('supplier/product/addedit/{o}/{oo}/{type}',[SupplierController::class,'product_addedit'])
->where('o','[0-9]+')
->where('oo','[0-9]+')
->whereIn('type',Supplier::offeringTypeKeys()->toArray());