327 lines
15 KiB
PHP
327 lines
15 KiB
PHP
@extends('layouts.layout-2')
|
||
|
||
@section('content')
|
||
<style>
|
||
.td-entry-table-margin {
|
||
padding-bottom: 6px;
|
||
border-bottom: 1px solid rgb(221, 221, 221);
|
||
margin-bottom: 6px;
|
||
}
|
||
</style>
|
||
|
||
<div class="card">
|
||
<h5 class="card-header">
|
||
Guthaben offen
|
||
<div class="float-right">
|
||
<button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-load-content"
|
||
data-id="new" data-action="add-user-credit" data-back="{{ url()->current() }}"
|
||
data-route="{{ route('modal_load') }}"><span class="fa fa-plus-circle"></span> Guthaben hinzufügen
|
||
</button>
|
||
</div>
|
||
</h5>
|
||
|
||
@if (isset($add_credit_error) && $add_credit_error)
|
||
<div class="col-sm-12">
|
||
<div class="alert alert-danger p-2 mt-2">
|
||
<ul>
|
||
<li>{{ $add_credit_error }}</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
@endif
|
||
|
||
<div class="card-datatable table-responsive pt-0">
|
||
<table class="datatables-style table table-striped table-bordered">
|
||
<thead>
|
||
<tr>
|
||
<th>{{ __('Account ID') }}</th>
|
||
<th>{{ __('First name') }}</th>
|
||
<th>{{ __('Last name') }}</th>
|
||
<th>{{ __('E-Mail') }}</th>
|
||
<th>{{ __('Betrag') }}</th>
|
||
<th>{{ __('Guthaben') }}</th>
|
||
<th>{{ __('#') }}</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
@foreach ($user_credit_items as $user_credit_item)
|
||
<tr>
|
||
<td>{{ $user_credit_item['m_account'] }}</td>
|
||
<td>{{ $user_credit_item['first_name'] }}</td>
|
||
<td>{{ $user_credit_item['last_name'] }}</td>
|
||
<td>{{ $user_credit_item['email'] }}</td>
|
||
<td><span class="no-line-break">{!! formatNumber($user_credit_item['sum']) !!} €</span></td>
|
||
<td>
|
||
@foreach ($user_credit_item['entries'] as $key => $credit)
|
||
<div class="td-entry-table-margin">
|
||
<i class="fa fa-plus-circle text-secondary"></i>
|
||
{!! formatNumber($credit->credit) !!} € |
|
||
{{ formatTextWithLineBreaks($credit->message, true) }}
|
||
/ {{ $credit->created_at->format('d.m.Y') }}
|
||
@if ($deleteTime = $credit->deleteTime())
|
||
/ <span class="no-line-break">
|
||
<a class="btn btn-danger btn-xs"
|
||
href="{{ route('admin_payments_credit_delete', [$credit->id, 'user_credit_item']) }}"
|
||
onclick="return confirm('Wirklich löschen?');">
|
||
<i class="ion ion-ios-trash"></i>
|
||
</a> noch {{ $deleteTime }} min.
|
||
</span>
|
||
@endif
|
||
</div>
|
||
@endforeach
|
||
</td>
|
||
<td>
|
||
<button type="button" class="btn btn-sm btn-secondary" data-toggle="modal"
|
||
data-target="#modals-credit" data-userid="{{ $user_credit_item['user_id'] }}"
|
||
data-email="{{ $user_credit_item['email'] }}" data-back="{{ url()->current() }}"
|
||
data-action="create_credit">
|
||
<span class="fa fa-dollar-sign"></span> <strong>Guthaben auszahlen</strong>
|
||
</button>
|
||
</td>
|
||
</tr>
|
||
@endforeach
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
|
||
<div class="card mt-3 mb-3" id="credit-stats-card">
|
||
<div class="card-body py-3">
|
||
<div class="row align-items-center">
|
||
<div class="col-auto text-muted small">
|
||
<i class="fa fa-chart-bar mr-1"></i> Statistik:
|
||
<span class="font-weight-bold text-dark" id="stats-credit-period">
|
||
{{ $filter_months[session('credit_filter_month')] ?? '' }} {{ session('credit_filter_year') }}
|
||
</span>
|
||
</div>
|
||
<div class="col text-right d-flex justify-content-end">
|
||
<div class="mr-4 text-center">
|
||
<div class="text-muted" style="font-size:0.75rem;">Anzahl Gutschriften</div>
|
||
<div class="h5 mb-0 font-weight-bold text-primary" id="stats-credit-count">
|
||
<i class="fa fa-spinner fa-spin fa-sm"></i>
|
||
</div>
|
||
</div>
|
||
<div class="text-center">
|
||
<div class="text-muted" style="font-size:0.75rem;">Gesamtsumme</div>
|
||
<div class="h5 mb-0 font-weight-bold text-success" id="stats-credit-total">
|
||
<i class="fa fa-spinner fa-spin fa-sm"></i>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="card mt-0">
|
||
<h5 class="card-header">
|
||
Gutschriften / Auszahlungen
|
||
</h5>
|
||
<div class="card-body p-0">
|
||
{!! Form::open([
|
||
'action' => route('admin_payments_credit'),
|
||
'class' => 'form-horizontal',
|
||
'id' => 'form_filter_payment_credits',
|
||
]) !!}
|
||
|
||
<div class="form-row align-items-center px-4 pb-2 pt-3">
|
||
<div class="col-12 col-sm-4 col-md-4 col-lg-4 mb-1">
|
||
<input class="form-control on_keyup_credits" name="credit_filter_name" type="text"
|
||
value="{{ session('credit_filter_name') }}" placeholder="Name">
|
||
</div>
|
||
|
||
<div class="col-6 col-sm-4 col-md-4 col-lg-4 mb-1">
|
||
<select class="custom-select on_change_credits" name="credit_filter_month">
|
||
@foreach ($filter_months as $key => $value)
|
||
<option value="{{ $key }}" @if (session('credit_filter_month') == $key) selected @endif>
|
||
{{ $value }}</option>
|
||
@endforeach
|
||
</select>
|
||
</div>
|
||
<div class="col-6 col-sm-4 col-md-4 col-lg-4 mb-1">
|
||
<select class="custom-select on_change_credits" name="credit_filter_year">
|
||
@foreach ($filter_years as $key => $value)
|
||
<option value="{{ $value }}" @if (session('credit_filter_year') == $value) selected @endif>
|
||
{{ $value }}</option>
|
||
@endforeach
|
||
</select>
|
||
</div>
|
||
</div>
|
||
{!! Form::close() !!}
|
||
|
||
<div class="card-datatable table-responsive pt-0">
|
||
<table class="datatables-style table table-striped table-bordered" id="datatable-credit">
|
||
<thead>
|
||
<tr>
|
||
<th>ID</th>
|
||
<th>{{ __('G.Nr.') }}</th>
|
||
<th>{{ __('Gutschrift') }}</th>
|
||
<th>{{ __('First name') }}</th>
|
||
<th>{{ __('Last name') }}</th>
|
||
<th>{{ __('E-Mail') }}</th>
|
||
<th>{{ __('Betrag') }}</th>
|
||
<th>{{ __('Datum') }}</th>
|
||
<th>{{ __('Zahlung') }}</th>
|
||
<th>{{ __('aus Guthaben') }}</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="modal fade" id="modals-credit">
|
||
<div class="modal-dialog">
|
||
<form class="modal-content form-prevent-multiple-submits" action="{{ route('admin_payments_credit_create') }}"
|
||
method="post">
|
||
@csrf
|
||
<input type="hidden" name="userid" value="">
|
||
<input type="hidden" name="action" value="create_credit">
|
||
<input type="hidden" name="back" value="{{ url()->current() }}">
|
||
<div class="modal-header">
|
||
<h5 class="modal-title">{{ __('Gutschrift') }}</h5>
|
||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>
|
||
</div>
|
||
<div class="modal-body">
|
||
<div class="form-group col-sm-12">
|
||
{{ Form::select('credit_option', ['create' => 'Gutschrift erstellen'], false, ['data-live-search' => 'false', 'class' => 'selectpicker']) }}
|
||
</div>
|
||
<div class="form-group col-sm-12">
|
||
<label class="form-label" for="credit_date">{{ __('Gutschriftsdatum') }}</label>
|
||
{!! Form::text('credit_date', \Carbon::now()->format('d.m.Y'), ['class' => 'form-control datepicker-base']) !!}
|
||
</div>
|
||
<div class="form-group col-sm-12">
|
||
<label class="form-label" for="credit_number">{{ __('Gutschriftsnummer') }}</label>
|
||
{!! Form::text('credit_number', App\Services\Credit::getCreditNumber(), ['class' => 'form-control', 'disabled']) !!}
|
||
<em> nächste Gutschriftsnummer <a href="{{ route('admin_settings') }}"><i
|
||
class="fa fa-edit"></i></a></em>
|
||
</div>
|
||
<div class="form-group col-sm-12">
|
||
<label class="custom-control custom-checkbox">
|
||
{!! Form::checkbox('credit_send_mail', 1, true, ['class' => 'custom-control-input']) !!}
|
||
<span class="custom-control-label">Gutschrift an <span
|
||
id="set_credit_send_mail">mail</span></span>
|
||
</label>
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-default" data-dismiss="modal">{{ __('close') }}</button>
|
||
<button type="submit" class="btn btn-primary button-prevent-multiple-submits"><i
|
||
class="spinner fa fa-spinner fa-spin"></i> {{ __('save') }}</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
<script>
|
||
function loadCreditStats() {
|
||
var month = $('select[name=credit_filter_month]').val();
|
||
var year = $('select[name=credit_filter_year]').val();
|
||
var name = $('input[name=credit_filter_name]').val();
|
||
$.getJSON('{!! route('admin_payments_credit_stats') !!}', {
|
||
credit_filter_month: month,
|
||
credit_filter_year: year,
|
||
credit_filter_name: name
|
||
}, function(data) {
|
||
$('#stats-credit-count').text(data.count);
|
||
$('#stats-credit-total').text(data.total + ' €');
|
||
var monthName = $('select[name=credit_filter_month] option:selected').text();
|
||
$('#stats-credit-period').text(monthName + ' ' + year);
|
||
});
|
||
}
|
||
|
||
$(document).ready(function() {
|
||
loadCreditStats();
|
||
|
||
var oTable = $('#datatable-credit').DataTable({
|
||
"processing": true,
|
||
"serverSide": true,
|
||
ajax: {
|
||
url: '{!! route('admin_payments_credit_datatable') !!}',
|
||
data: function(d) {
|
||
d.credit_filter_name = $('input[name=credit_filter_name]').val();
|
||
d.credit_filter_month = $('select[name=credit_filter_month]').val();
|
||
d.credit_filter_year = $('select[name=credit_filter_year]').val();
|
||
}
|
||
},
|
||
"order": [
|
||
[0, "desc"]
|
||
],
|
||
"columns": [{
|
||
data: 'id',
|
||
searchable: false
|
||
},
|
||
{
|
||
data: 'full_number',
|
||
name: 'full_number'
|
||
},
|
||
{
|
||
data: 'view',
|
||
name: 'view'
|
||
},
|
||
{
|
||
data: 'user.account.first_name',
|
||
name: 'user.account.first_name',
|
||
orderable: false
|
||
},
|
||
{
|
||
data: 'user.account.last_name',
|
||
name: 'user.account.last_name',
|
||
orderable: false
|
||
},
|
||
{
|
||
data: 'user.email',
|
||
name: 'user.email',
|
||
orderable: false
|
||
},
|
||
{
|
||
data: 'total',
|
||
name: 'total'
|
||
},
|
||
{
|
||
data: 'date',
|
||
name: 'date'
|
||
},
|
||
{
|
||
data: 'status',
|
||
name: 'status',
|
||
searchable: false
|
||
},
|
||
{
|
||
data: 'credits',
|
||
name: 'credits',
|
||
orderable: false
|
||
},
|
||
],
|
||
"bLengthChange": false,
|
||
"iDisplayLength": 100,
|
||
"language": {
|
||
"url": "/js/datatables-{{ \App::getLocale() }}.json"
|
||
}
|
||
});
|
||
$('select.on_change_credits').on('change', function() {
|
||
oTable.draw();
|
||
loadCreditStats();
|
||
});
|
||
|
||
$('input.on_keyup_credits').on('keyup', function() {
|
||
oTable.draw();
|
||
loadCreditStats();
|
||
});
|
||
$(document).ready(function() {
|
||
$('#modals-credit').on('show.bs.modal', function(event) {
|
||
var button = $(event.relatedTarget);
|
||
if (event.relatedTarget) {
|
||
$(this).find(".modal-content input[name='userid']").val(button.data(
|
||
'userid'));
|
||
$(this).find(".modal-body #set_credit_send_mail").html(button.data(
|
||
'email'));
|
||
}
|
||
|
||
});
|
||
});
|
||
});
|
||
</script>
|
||
@endsection
|