diff --git a/app/Http/Controllers/Qr/QrCodeController.php b/app/Http/Controllers/Qr/QrCodeController.php index 2807454..b395a6a 100644 --- a/app/Http/Controllers/Qr/QrCodeController.php +++ b/app/Http/Controllers/Qr/QrCodeController.php @@ -20,8 +20,10 @@ use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; +use Illuminate\Support\Facades\Log; use Illuminate\View\View; use RuntimeException; +use Throwable; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\StreamedResponse; @@ -45,12 +47,22 @@ class QrCodeController extends Controller ->latest() ->get(); + $ladillWalletBalance = 0.0; + try { + $ladillWalletBalance = $this->platformBilling->balanceMinor($user->public_id) / 100; + } catch (Throwable $e) { + Log::warning('QR Plus index could not load Ladill wallet balance', [ + 'user' => $user->public_id, + 'error' => $e->getMessage(), + ]); + } + return view('qr-codes.index', [ 'wallet' => $wallet, 'qrCodes' => $qrCodes, 'pricePerQr' => QrWallet::pricePerQr(), 'minTopup' => QrWallet::minTopupGhs(), - 'ladillWalletBalance' => $this->platformBilling->balanceMinor($user->public_id) / 100, + 'ladillWalletBalance' => $ladillWalletBalance, 'topupUrl' => 'https://'.config('app.account_domain').'/wallet', ]); } diff --git a/resources/views/layouts/user.blade.php b/resources/views/layouts/user.blade.php index 982c204..17e0fb5 100644 --- a/resources/views/layouts/user.blade.php +++ b/resources/views/layouts/user.blade.php @@ -352,6 +352,7 @@ document.addEventListener('alpine:init', () => { balance: Number(config.balance ?? 0), price: Number(config.price ?? 0), modalId: config.modalId ?? null, + topupUrl: config.topupUrl ?? null, href: config.href ?? null, requiresPayment: Object.prototype.hasOwnProperty.call(config, 'requiresPayment') ? config.requiresPayment !== false @@ -367,6 +368,11 @@ document.addEventListener('alpine:init', () => { return this.needsTopupFor(this.requiresPayment); }, openTopup() { + if (this.topupUrl) { + window.location.href = this.topupUrl; + return; + } + if (! this.modalId) { return; } diff --git a/resources/views/qr-codes/attendees.blade.php b/resources/views/qr-codes/attendees.blade.php index 5933831..a246d23 100644 --- a/resources/views/qr-codes/attendees.blade.php +++ b/resources/views/qr-codes/attendees.blade.php @@ -7,8 +7,8 @@ selected: [], toggle(id) { const i = this.selected.indexOf(id); i === -1 ? this.selected.push(id) : this.selected.splice(i, 1); }, get qs() { return this.selected.map(id => 'ids[]=' + id).join('&'); }, - printSelected() { window.open(@js(route('qr-codes.badges', $qrCode)) + '?auto=1&' + this.qs, '_blank'); }, - zplSelected() { window.location = @js(route('qr-codes.badges.zpl', $qrCode)) + '?' + this.qs; } + printSelected() { window.open(@js(route('user.qr-codes.badges', $qrCode)) + '?auto=1&' + this.qs, '_blank'); }, + zplSelected() { window.location = @js(route('user.qr-codes.badges.zpl', $qrCode)) + '?' + this.qs; } }"> {{-- Flash --}} @@ -22,7 +22,7 @@ {{-- Header --}}
- + {{ $qrCode->label }} @@ -41,7 +41,7 @@

Email & text the {{ $programme->label }} programme link to all confirmed attendees.

-
@@ -90,9 +90,9 @@ class="rounded-xl bg-indigo-600 px-3.5 py-2 text-xs font-semibold text-white hover:bg-indigo-700 transition">Print selected - Print all badges - Download ZPL @endunless @@ -144,7 +144,7 @@ @unless($isContribution) - + @csrf @method('PATCH')