Admin-Abos: Filterleiste und Textsuche nach PayOne-ID
Neue serverseitige, pro Admin persistente Filter auf /admin/abos: - Status (echte Abo-Status aus UserAbo::$statusTypes, nur vorhandene Werte) - Aktiv / Inaktiv - Ist fuer (Berater/Kunde, is_for me/ot) - Zahlung (Kreditkarte/PayPal ueber clearingtype cc/wlt) - Startdatum (Monat + Jahr, optisch gruppiert; whereMonth/whereYear) - Naechste Ausfuehrung (feste Liefertage 5/10/20/25 ueber abo_interval) - Berater-Zuordnung (Member-Dropdown, Proportionen wie /admin/business/points) - Reset-Button (korrigiert: bleibt auf admin_abos, Label ausserhalb des Buttons) Layout in zwei Zeilen, damit nichts zusammengequetscht wird. Textsuche der Tabelle: payone_userid via filterColumn suchbar gemacht (addColumn-Spalten schliesst Yajra sonst von der globalen Suche aus). Lang-Keys tables.month/year/all/inactive (de/en) ergaenzt. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
4709dfde55
commit
6720d99e08
4 changed files with 167 additions and 39 deletions
|
|
@ -25,24 +25,64 @@ class AboController extends Controller
|
|||
public function index()
|
||||
{
|
||||
if (Request::get('reset') === 'filter') {
|
||||
set_user_attr('filter_user_shop_id', null);
|
||||
set_user_attr('filter_status', null);
|
||||
set_user_attr('filter_member_id', null);
|
||||
foreach (['filter_member_id', 'filter_status', 'filter_active', 'filter_is_for', 'filter_payment', 'filter_start_month', 'filter_start_year', 'filter_next_day'] as $attr) {
|
||||
set_user_attr($attr, null);
|
||||
}
|
||||
|
||||
return redirect(route('admin_sales_customers'));
|
||||
return redirect(route('admin_abos'));
|
||||
}
|
||||
|
||||
// $filter_user_shops = UserAbo::join('user_shops', 'user_shop_id', '=', 'user_shops.id')->orderBy('slug')->get()->pluck('slug', 'id')->unique()->toArray();
|
||||
$filter_members = UserAbo::join('users', 'user_id', '=', 'users.id')->groupBy('user_id')->join('user_accounts', 'account_id', '=', 'user_accounts.id')->select('users.id', 'users.email', 'user_accounts.first_name', 'user_accounts.last_name')->get();
|
||||
|
||||
$data = [
|
||||
// 'filter_user_shops' => $filter_user_shops,
|
||||
'filter_members' => $filter_members,
|
||||
'filter_statuses' => $this->getStatusFilterOptions(),
|
||||
'filter_months' => $this->getMonthFilterOptions(),
|
||||
'filter_years' => $this->getStartYearFilterOptions(),
|
||||
'filter_next_days' => UserAbo::$aboDeliveryDays,
|
||||
];
|
||||
|
||||
return view('admin.abo.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
private function getStatusFilterOptions(): array
|
||||
{
|
||||
return UserAbo::query()
|
||||
->select('status')
|
||||
->distinct()
|
||||
->orderBy('status')
|
||||
->pluck('status')
|
||||
->mapWithKeys(fn ($status) => [$status => __('abo.'.(UserAbo::$statusTypes[$status] ?? $status))])
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
private function getMonthFilterOptions(): array
|
||||
{
|
||||
$months = [];
|
||||
for ($month = 1; $month <= 12; $month++) {
|
||||
$months[$month] = \Carbon\Carbon::create(null, $month, 1)->locale(app()->getLocale())->translatedFormat('F');
|
||||
}
|
||||
|
||||
return $months;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, int>
|
||||
*/
|
||||
private function getStartYearFilterOptions(): array
|
||||
{
|
||||
$minStart = UserAbo::whereNotNull('start_date')->min('start_date');
|
||||
$fromYear = $minStart ? (int) substr($minStart, 0, 4) : (int) date('Y');
|
||||
|
||||
return range((int) date('Y'), $fromYear);
|
||||
}
|
||||
|
||||
public function detail($id)
|
||||
{
|
||||
$data = Request::all();
|
||||
|
|
@ -139,6 +179,36 @@ class AboController extends Controller
|
|||
$query->where('status', '=', Request::get('filter_status'));
|
||||
}
|
||||
|
||||
set_user_attr('filter_active', Request::get('filter_active'));
|
||||
if (Request::get('filter_active') != '') {
|
||||
$query->where('active', '=', (int) Request::get('filter_active'));
|
||||
}
|
||||
|
||||
set_user_attr('filter_is_for', Request::get('filter_is_for'));
|
||||
if (Request::get('filter_is_for') != '') {
|
||||
$query->where('is_for', '=', Request::get('filter_is_for'));
|
||||
}
|
||||
|
||||
set_user_attr('filter_payment', Request::get('filter_payment'));
|
||||
if (Request::get('filter_payment') != '') {
|
||||
$query->where('clearingtype', '=', Request::get('filter_payment'));
|
||||
}
|
||||
|
||||
set_user_attr('filter_start_month', Request::get('filter_start_month'));
|
||||
if (Request::get('filter_start_month') != '') {
|
||||
$query->whereMonth('start_date', (int) Request::get('filter_start_month'));
|
||||
}
|
||||
|
||||
set_user_attr('filter_start_year', Request::get('filter_start_year'));
|
||||
if (Request::get('filter_start_year') != '') {
|
||||
$query->whereYear('start_date', (int) Request::get('filter_start_year'));
|
||||
}
|
||||
|
||||
set_user_attr('filter_next_day', Request::get('filter_next_day'));
|
||||
if (Request::get('filter_next_day') != '') {
|
||||
$query->where('abo_interval', '=', (int) Request::get('filter_next_day'));
|
||||
}
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (UserAbo $user_abo) {
|
||||
return '<a href="'.route('admin_abos_detail', [$user_abo->id]).'" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
|
|
@ -179,6 +249,11 @@ class AboController extends Controller
|
|||
->addColumn('payone_userid', function (UserAbo $user_abo) {
|
||||
return $user_abo->payone_userid;
|
||||
})
|
||||
->filterColumn('payone_userid', function ($query, $keyword) {
|
||||
if ($keyword != '') {
|
||||
$query->whereRaw('user_abos.payone_userid LIKE ?', ['%'.$keyword.'%']);
|
||||
}
|
||||
})
|
||||
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('start_date', 'start_date $1')
|
||||
|
|
|
|||
|
|
@ -83,6 +83,10 @@ return [
|
|||
'abo_delivery_day' => 'Abo-Liefertag',
|
||||
'abo_delivery' => 'Abo-Lieferungen',
|
||||
'active' => 'Aktiv',
|
||||
'inactive' => 'Inaktiv',
|
||||
'all' => 'Alle',
|
||||
'month' => 'Monat',
|
||||
'year' => 'Jahr',
|
||||
'is_for' => 'Ist für',
|
||||
'count' => 'Anzahl',
|
||||
'member' => 'Mitglied',
|
||||
|
|
|
|||
|
|
@ -8,6 +8,10 @@ return [
|
|||
'account_to' => 'account until',
|
||||
'activ' => 'active',
|
||||
'active' => 'Active',
|
||||
'inactive' => 'Inactive',
|
||||
'all' => 'All',
|
||||
'month' => 'Month',
|
||||
'year' => 'Year',
|
||||
'addition' => 'additive',
|
||||
'address' => 'address',
|
||||
'adviser' => 'Advisor',
|
||||
|
|
|
|||
|
|
@ -7,40 +7,86 @@
|
|||
{{ __('Abos') }}
|
||||
</h4>
|
||||
<div class="card">
|
||||
{{--
|
||||
<div class="card-header">
|
||||
<div class="form-row align-items-center">
|
||||
<div class="col-sm-4 mb-2">
|
||||
<label class="form-label" for="filter_user_shop_id">Filter zugewiesener Berater</label>
|
||||
|
||||
<select class="selectpicker" data-style="btn-default" name="filter_member_id" id="filter_member_id" data-live-search="true">
|
||||
<option value="">Filter aus</option>
|
||||
@foreach($filter_members as $member)
|
||||
<option value="{{$member->id}}" @if(get_user_attr('filter_member_id') == $member->id) selected @endif>{{$member->first_name}} {{$member->last_name}} | {{$member->email}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="col-10 col-sm-3 mb-2">
|
||||
<label class="form-label" for="filter_status">Filter Status</label>
|
||||
<div class="form-row align-items-end">
|
||||
<div class="col-6 col-md-3 col-lg-2 mb-2">
|
||||
<label class="form-label" for="filter_status">{{ __('tables.status') }}</label>
|
||||
<select class="custom-select" name="filter_status" id="filter_status">
|
||||
<option value="">Filter aus</option>
|
||||
@foreach(\App\Services\AboHelper::getTransStatusFilterText() as $id=>$name)
|
||||
<option value="{{$id}}" @if(get_user_attr('filter_status') == $id) selected @endif>{{$name}}</option>
|
||||
<option value="">{{ __('tables.all') }}</option>
|
||||
@foreach ($filter_statuses as $id => $name)
|
||||
<option value="{{ $id }}" @if((string) get_user_attr('filter_status') === (string) $id) selected @endif>{{ $name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-2 col-sm-1 mb-2 mt-4">
|
||||
<a href="{{ route('admin_sales_customers') }}?reset=filter" data-toggle="tooltip" data-placement="top" title="Reset Filter" class="btn icon-btn btn-sm btn-outline-dark float-right">
|
||||
<div class="col-6 col-md-3 col-lg-2 mb-2">
|
||||
<label class="form-label" for="filter_active">{{ __('tables.active') }}</label>
|
||||
<select class="custom-select" name="filter_active" id="filter_active">
|
||||
<option value="">{{ __('tables.all') }}</option>
|
||||
<option value="1" @if((string) get_user_attr('filter_active') === '1') selected @endif>{{ __('tables.active') }}</option>
|
||||
<option value="0" @if((string) get_user_attr('filter_active') === '0') selected @endif>{{ __('tables.inactive') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-6 col-md-3 col-lg-2 mb-2">
|
||||
<label class="form-label" for="filter_is_for">{{ __('tables.is_for') }}</label>
|
||||
<select class="custom-select" name="filter_is_for" id="filter_is_for">
|
||||
<option value="">{{ __('tables.all') }}</option>
|
||||
<option value="me" @if(get_user_attr('filter_is_for') === 'me') selected @endif>{{ __('tables.adviser') }}</option>
|
||||
<option value="ot" @if(get_user_attr('filter_is_for') === 'ot') selected @endif>{{ __('tables.customer') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-6 col-md-3 col-lg-2 mb-2">
|
||||
<label class="form-label" for="filter_payment">{{ __('tables.payment') }}</label>
|
||||
<select class="custom-select" name="filter_payment" id="filter_payment">
|
||||
<option value="">{{ __('tables.all') }}</option>
|
||||
<option value="cc" @if(get_user_attr('filter_payment') === 'cc') selected @endif>{{ __('payment.credit_card') }}</option>
|
||||
<option value="wlt" @if(get_user_attr('filter_payment') === 'wlt') selected @endif>{{ __('payment.paypal') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row align-items-end">
|
||||
<div class="col-12 col-md-6 col-lg-4 mb-2">
|
||||
<label class="form-label">{{ __('tables.start_date') }}</label>
|
||||
<div class="d-flex border rounded p-1" style="gap: 6px;">
|
||||
<select class="custom-select" name="filter_start_month" id="filter_start_month" aria-label="{{ __('tables.month') }}">
|
||||
<option value="">{{ __('tables.month') }} ({{ __('tables.all') }})</option>
|
||||
@foreach ($filter_months as $num => $name)
|
||||
<option value="{{ $num }}" @if((string) get_user_attr('filter_start_month') === (string) $num) selected @endif>{{ $name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<select class="custom-select" name="filter_start_year" id="filter_start_year" aria-label="{{ __('tables.year') }}" style="max-width: 130px;">
|
||||
<option value="">{{ __('tables.year') }} ({{ __('tables.all') }})</option>
|
||||
@foreach ($filter_years as $year)
|
||||
<option value="{{ $year }}" @if((string) get_user_attr('filter_start_year') === (string) $year) selected @endif>{{ $year }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 col-md-3 col-lg-2 mb-2">
|
||||
<label class="form-label" for="filter_next_day">{{ __('tables.next_date') }}</label>
|
||||
<select class="custom-select" name="filter_next_day" id="filter_next_day">
|
||||
<option value="">{{ __('tables.all') }}</option>
|
||||
@foreach ($filter_next_days as $day)
|
||||
<option value="{{ $day }}" @if((string) get_user_attr('filter_next_day') === (string) $day) selected @endif>{{ \App\Services\HTMLHelper::getAboStrLang($day) }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-12 col-sm-6 col-md-3 col-lg-3 mb-2">
|
||||
<label class="form-label" for="filter_member_id">{{ __('tables.adviser') }}</label>
|
||||
<select class="selectpicker" data-style="btn-default" name="filter_member_id" id="filter_member_id" data-live-search="true" title="{{ __('tables.all') }}">
|
||||
<option value="">{{ __('tables.all') }}</option>
|
||||
@foreach ($filter_members as $member)
|
||||
<option value="{{ $member->id }}" @if(get_user_attr('filter_member_id') == $member->id) selected @endif>{{ $member->first_name }} {{ $member->last_name }} | {{ $member->email }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-12 col-lg-auto mb-2 d-flex align-items-end">
|
||||
<a href="{{ route('admin_abos') }}?reset=filter" title="{{ __('Reset Filter') }}" class="btn icon-btn btn-sm btn-outline-dark">
|
||||
<span class="fa fa-sync"></span>
|
||||
</a>
|
||||
<span class="ml-2">{{ __('Reset Filter') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
--}}
|
||||
<div class="card-datatable table-responsive">
|
||||
<table class="datatable-abos table table-striped table-bordered" id="datatable-abos">
|
||||
<thead>
|
||||
|
|
@ -73,10 +119,15 @@
|
|||
"serverSide": true,
|
||||
ajax: {
|
||||
url: '{!! route( 'admin_abos_datatable') !!}',
|
||||
data: function(d) {
|
||||
data: function(d) {
|
||||
d.filter_member_id = $('select[name=filter_member_id]').val();
|
||||
d.filter_user_shop_id = $('select[name=filter_user_shop_id]').val();
|
||||
d.filter_status = $('select[name=filter_status]').val();
|
||||
d.filter_active = $('select[name=filter_active]').val();
|
||||
d.filter_is_for = $('select[name=filter_is_for]').val();
|
||||
d.filter_payment = $('select[name=filter_payment]').val();
|
||||
d.filter_start_month = $('select[name=filter_start_month]').val();
|
||||
d.filter_start_year = $('select[name=filter_start_year]').val();
|
||||
d.filter_next_day = $('select[name=filter_next_day]').val();
|
||||
}
|
||||
},
|
||||
"order": [[0, "desc" ]],
|
||||
|
|
@ -104,13 +155,7 @@
|
|||
"url": "/js/datatables-{{ \App::getLocale() }}.json"
|
||||
}
|
||||
});
|
||||
$('#filter_member_id').on('change', function(){
|
||||
oTable.draw();
|
||||
});
|
||||
$('#filter_user_shop_id').on('change', function(){
|
||||
oTable.draw();
|
||||
});
|
||||
$('#filter_txaction').on('change', function(){
|
||||
$('#filter_start_month, #filter_start_year, #filter_next_day, #filter_status, #filter_active, #filter_is_for, #filter_payment, #filter_member_id').on('change', function(){
|
||||
oTable.draw();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue