Change supplier resources to use components

This commit is contained in:
2024-08-18 13:58:18 +10:00
parent 283ae06a5c
commit 5139b26a05
12 changed files with 255 additions and 558 deletions

View File

@@ -1,4 +1,7 @@
<!-- $o = Supplier::class -->
<!-- $spo=Supplier::class -->
@use(App\Models\Supplier)
@use(Carbon\Carbon)
<div class="row">
<div class="col-9">
<table class="table table-sm">
@@ -14,14 +17,14 @@
</thead>
<tbody>
@foreach (\App\Models\Supplier::offeringTypes($o) as $key => $offering)
@foreach (Supplier::offeringTypes($spo) as $key => $offering)
<tr>
<th>{{ $offering->type }}</th>
@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>
@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>
<td class="text-right">{{ number_format($offering->items->count()) }}</td>
@else
<td colspan="5">&nbsp;</td>

View File

@@ -1,10 +1,10 @@
<!-- $o = Supplier::class -->
<!-- $pdo=Supplier::class -->
<div class="row">
<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>
<form class="g-0 needs-validation" method="POST" enctype="multipart/form-data" role="form">
<form method="POST">
@csrf
<div class="row">
@@ -12,23 +12,12 @@
<div class="row">
<!-- Supplier Active -->
<div class="col-12 col-sm-3">
<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>
<x-leenooks::form.toggle name="active" label="Active" :value="$spo->active"/>
</div>
<!-- Supplier Name -->
<div class="col-12 col-sm-9">
@include('adminlte::widget.form_text',[
'label'=>'Supplier Name',
'id'=>'name',
'old'=>'name',
'name'=>'name',
'value'=>$o->name ?? '',
])
<x-leenooks::form.text name="name" icon="fa-tag" label="Supplier Name" :value="$spo->name ?? ''"/>
</div>
</div>
@@ -37,8 +26,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',$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) }}">
<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) }}">
<span class="invalid-feedback" role="alert">
@error('address1')
{{ $message }}
@@ -53,37 +42,19 @@
<div class="row">
<!-- City -->
<div class="col-12">
@include('adminlte::widget.form_text',[
'label'=>'City',
'id'=>'city',
'old'=>'city',
'name'=>'city',
'value'=>$o->city ?? '',
])
<x-leenooks::form.text name="city" label="City" :value="$spo->city ?? ''"/>
</div>
</div>
<div class="row">
<!-- State -->
<div class="col-12 col-sm-9">
@include('adminlte::widget.form_text',[
'label'=>'State',
'id'=>'state',
'old'=>'state',
'name'=>'state',
'value'=>$o->state ?? '',
])
<x-leenooks::form.text name="state" label="State" :value="$spo->state ?? ''"/>
</div>
<!-- Postal Code -->
<div class="col-12 col-sm-3">
@include('adminlte::widget.form_text',[
'label'=>'Post Code',
'id'=>'postcode',
'old'=>'postcode',
'name'=>'postcode',
'value'=>$o->postcode ?? '',
])
<x-leenooks::form.text name="postcode" label="Post Code" :value="$spo->postcode ?? ''"/>
</div>
</div>
</div>
@@ -92,69 +63,41 @@
<div class="row">
<!-- Accounts Email -->
<div class="col-12">
@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 : ''),
])
<x-leenooks::form.email name="supplier_details[accounts]" label="Accounts Email" old="supplier_details.accounts" :value="$spo?->detail->accounts ?? ''"/>
</div>
</div>
<div class="row">
<!-- Support Email -->
<div class="col-12">
@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 : ''),
])
<x-leenooks::form.email name="supplier_details[support]" label="Support Email" old="supplier_details.support" :value="$spo?->detail->support ?? ''"/>
</div>
</div>
<div class="row">
<!-- Payment Details -->
<div class="col-12">
@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 : ''),
])
<x-leenooks::form.email name="supplier_details[payments]" label="Payment Details" old="supplier_details.payments" :value="$spo?->detail->payments ?? ''"/>
</div>
</div>
@if($o->api_class())
@if($spo->api_class())
<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">
<!-- API Details -->
<div class="col-12">
@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') : ''),
])
<x-leenooks::form.text name="api_key" label="API Key" :value="($spo->detail ? Arr::get($spo->detail->connections,'api_key') : '')"/>
</div>
</div>
<div class="row">
<!-- API Details -->
<div class="col-12">
@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') : ''),
])
<x-leenooks::form.text name="api_secret" label="API Secret" :value="($spo->detail ? Arr::get($spo->detail->connections,'api_secret') : '')"/>
</div>
</div>
@endif
@@ -164,25 +107,15 @@
<div class="row">
<!-- Notes -->
<div class="col-12">
<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>
<x-leenooks::form.textarea name="supplier_details[notes]" label="Notes" :value="($spo->detail ? $spo->detail->notes : '')"/>
</div>
</div>
<div class="row">
<!-- Buttons -->
<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 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>
</div>
</form>

View File

@@ -1,8 +1,10 @@
<!-- $o = Supplier::class -->
<!-- $spo=Supplier::class -->
@use(App\Models\Supplier)
<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(\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>
@endforeach
</div>
@@ -10,7 +12,7 @@
<div class="col-7 col-sm-10">
<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">
<table class="table table-sm table-bordered w-100" id="offering-{{ $key }}-table">
<thead>
@@ -66,13 +68,12 @@
</div>
</div>
@section('page-scripts')
@css(datatables,bootstrap4)
@js(datatables,bootstrap4)
@pa(datatables)
@section('page-scripts')
<script type="text/javascript">
$(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 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="col-5 col-sm-2">
<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>
@endforeach
</div>
@@ -10,7 +12,7 @@
<div class="col-7 col-sm-10">
<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">
<table class="table table-sm table-bordered w-100" id="products-{{ $key }}-table">
<thead>
@@ -34,10 +36,10 @@
</thead>
<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)
<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->name }}</td>
<td class="text-right">{{ $po->active ? 'YES' : 'NO' }}</td>
@@ -69,13 +71,12 @@
</div>
</div>
@section('page-scripts')
@css(datatables,bootstrap4)
@js(datatables,bootstrap4)
@pa(datatables)
@section('page-scripts')
<script type="text/javascript">
$(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 tbody').on('click','tr', function () {