10.April 2026
This commit is contained in:
parent
a00c42e770
commit
f58c709945
208 changed files with 19280 additions and 2914 deletions
|
|
@ -1,18 +1,15 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Carbon;
|
||||
use Request;
|
||||
use App\Services\Payment;
|
||||
use App\Models\UserInvoice;
|
||||
use App\Services\HTMLHelper;
|
||||
use App\Services\Payment;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Request;
|
||||
|
||||
class PaymentInvoiceController extends Controller
|
||||
{
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('admin');
|
||||
|
|
@ -26,16 +23,17 @@ class PaymentInvoiceController extends Controller
|
|||
'filter_months' => HTMLHelper::getTransMonths(),
|
||||
'filter_years' => HTMLHelper::getYearRange(),
|
||||
];
|
||||
|
||||
return view('admin.payment.invoice', $data);
|
||||
}
|
||||
|
||||
private function setFilterVars()
|
||||
{
|
||||
|
||||
if (!session('invoice_filter_month')) {
|
||||
if (! session('invoice_filter_month')) {
|
||||
session(['invoice_filter_month' => intval(date('m'))]);
|
||||
}
|
||||
if (!session('invoice_filter_year')) {
|
||||
if (! session('invoice_filter_year')) {
|
||||
session(['invoice_filter_year' => intval(date('Y'))]);
|
||||
}
|
||||
if (Request::get('invoice_filter_name')) {
|
||||
|
|
@ -61,12 +59,44 @@ class PaymentInvoiceController extends Controller
|
|||
|
||||
if (Request::get('invoice_filter_name')) {
|
||||
$query->whereHas('shopping_order.shopping_user', function ($query) {
|
||||
return $query->where('billing_firstname', 'LIKE', '%' . Request::get('invoice_filter_name') . '%')->orWhere('billing_lastname', 'LIKE', '%' . Request::get('invoice_filter_name') . '%')->orWhere('billing_email', 'LIKE', '%' . Request::get('invoice_filter_name') . '%');
|
||||
return $query->where('billing_firstname', 'LIKE', '%'.Request::get('invoice_filter_name').'%')->orWhere('billing_lastname', 'LIKE', '%'.Request::get('invoice_filter_name').'%')->orWhere('billing_email', 'LIKE', '%'.Request::get('invoice_filter_name').'%');
|
||||
})->get();
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function stats(): JsonResponse
|
||||
{
|
||||
$this->setFilterVars();
|
||||
|
||||
$month = Request::get('invoice_filter_month', session('invoice_filter_month'));
|
||||
$year = Request::get('invoice_filter_year', session('invoice_filter_year'));
|
||||
$name = Request::get('invoice_filter_name', '');
|
||||
|
||||
$baseQuery = UserInvoice::query()
|
||||
->where('user_invoices.month', $month)
|
||||
->where('user_invoices.year', $year);
|
||||
|
||||
if ($name) {
|
||||
$baseQuery->whereHas('shopping_order.shopping_user', function ($query) use ($name) {
|
||||
$query->where('billing_firstname', 'LIKE', '%'.$name.'%')
|
||||
->orWhere('billing_lastname', 'LIKE', '%'.$name.'%')
|
||||
->orWhere('billing_email', 'LIKE', '%'.$name.'%');
|
||||
});
|
||||
}
|
||||
|
||||
$count = (clone $baseQuery)->count();
|
||||
$total = (clone $baseQuery)
|
||||
->join('shopping_orders', 'shopping_orders.id', '=', 'user_invoices.shopping_order_id')
|
||||
->sum('shopping_orders.total_shipping');
|
||||
|
||||
return response()->json([
|
||||
'count' => $count,
|
||||
'total' => number_format((float) $total, 2, ',', '.'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
|
||||
|
|
@ -75,32 +105,35 @@ class PaymentInvoiceController extends Controller
|
|||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (UserInvoice $UserInvoice) {
|
||||
if ($UserInvoice->shopping_order->auth_user_id) {
|
||||
return '<a href="' . route('admin_sales_users_detail', [$UserInvoice->shopping_order->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
return '<a href="'.route('admin_sales_users_detail', [$UserInvoice->shopping_order->id]).'" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
}
|
||||
return '<a href="' . route('admin_sales_customers_detail', [$UserInvoice->shopping_order->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
|
||||
return '<a href="'.route('admin_sales_customers_detail', [$UserInvoice->shopping_order->id]).'" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('total_shipping', function (UserInvoice $UserInvoice) {
|
||||
return '<span class="no-line-break">' . $UserInvoice->shopping_order->getFormattedTotalShipping() . " €</span>";
|
||||
return '<span class="no-line-break">'.$UserInvoice->shopping_order->getFormattedTotalShipping().' €</span>';
|
||||
})
|
||||
->addColumn('created_at', function (UserInvoice $UserInvoice) {
|
||||
return $UserInvoice->created_at->format("d.m.Y");
|
||||
return $UserInvoice->created_at->format('d.m.Y');
|
||||
})
|
||||
->addColumn('txaction', function (UserInvoice $UserInvoice) {
|
||||
if ($UserInvoice->shopping_order) {
|
||||
return Payment::getShoppingOrderBadge($UserInvoice->shopping_order);
|
||||
}
|
||||
return "-";
|
||||
|
||||
return '-';
|
||||
})
|
||||
->addColumn('status', function (UserInvoice $UserInvoice) {
|
||||
return '<a href="#" data-toggle="modal" data-target="#modals-load-content" data-modal="modal-lg"
|
||||
data-id="' . $UserInvoice->id . '" data-route="' . route('modal_load') . '" data-action="user-credit-status" data-view="">
|
||||
<span class="badge badge-pill badge-' . $UserInvoice->getStatusColor() . '">' . $UserInvoice->getStatusType() . '</span>
|
||||
data-id="'.$UserInvoice->id.'" data-route="'.route('modal_load').'" data-action="user-credit-status" data-view="">
|
||||
<span class="badge badge-pill badge-'.$UserInvoice->getStatusColor().'">'.$UserInvoice->getStatusType().'</span>
|
||||
</a>';
|
||||
})
|
||||
->addColumn('invoice', function (UserInvoice $UserInvoice) {
|
||||
$ret = "";
|
||||
$ret .= '<a href="' . route('storage_file', [$UserInvoice->shopping_order->id, 'invoice', 'download']) . '" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a> ';
|
||||
$ret .= '<a href="' . route('storage_file', [$UserInvoice->shopping_order->id, 'invoice', 'stream']) . '" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a>';
|
||||
$ret = '';
|
||||
$ret .= '<a href="'.route('storage_file', [$UserInvoice->shopping_order->id, 'invoice', 'download']).'" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a> ';
|
||||
$ret .= '<a href="'.route('storage_file', [$UserInvoice->shopping_order->id, 'invoice', 'stream']).'" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a>';
|
||||
|
||||
return $ret;
|
||||
})
|
||||
->orderColumn('id', 'id $1')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue