If invoicing is disabled, hide references to it

Closes #98
This commit is contained in:
Matt Young 2024-12-26 16:43:01 -06:00
parent cc5afc0635
commit 7540a7135f
4 changed files with 63 additions and 45 deletions

View File

@ -10,6 +10,7 @@ use App\Models\School;
use App\Services\Invoice\InvoiceDataService;
use Illuminate\Support\Facades\Auth;
use function auditionSetting;
use function redirect;
class DashboardController extends Controller
@ -76,6 +77,11 @@ class DashboardController extends Controller
if (! Auth::user()->school_id) {
return redirect()->route('dashboard')->with('error', 'You do not have a school to get an invoice for');
}
if (! auditionSetting('invoicing_enabled')) {
return redirect()->route('dashboard')->with('error', 'Invoicing is not enabled');
}
$invoiceData = $this->invoiceService->allData(Auth::user()->school_id);
$school = Auth::user()->school;

View File

@ -12,7 +12,9 @@
<thead>
<tr>
<x-table.th>Name</x-table.th>
@if(auditionSetting('invoicing_enabled'))
<x-table.th>Total Fees</x-table.th>
@endif
<x-table.th>Directors</x-table.th>
<x-table.th>Students</x-table.th>
<x-table.th>Entries</x-table.th>
@ -22,12 +24,15 @@
<x-table.body>
@foreach($schools as $school)
<tr>
<x-table.td><a href="{{ route('admin.schools.show',$school) }}">{{ $school->name }}</a></x-table.td>
<x-table.td><a href="{{ route('admin.schools.show',$school) }}">{{ $school->name }}</a>
</x-table.td>
@if(auditionSetting('invoicing_enabled'))
<x-table.td>
<a href="{{ route('admin.schools.invoice',$school) }}">
${{ number_format($schoolTotalFees[$school->id],2) }}
</a>
</x-table.td>
@endif
<x-table.td>{{ $school->users->count() }}</x-table.td>
<x-table.td>{{ $school->students->count() }}</x-table.td>
<x-table.td>{{ $school->entries->count() }}</x-table.td>

View File

@ -1,10 +1,14 @@
<div x-data="{ open: false }" class="relative">
{{-- <button type="button" class="inline-flex items-center gap-x-1 text-sm font-semibold leading-6 text-gray-900" aria-expanded="false" @on:click=" open = ! open">--}}
<button type="button" class="inline-flex items-center gap-x-1 text-white rounded-md px-3 py-2 text-sm font-medium hover:bg-indigo-500 hover:bg-opacity-75" aria-expanded="false" @click=" open = ! open" @click.outside=" open = false">
<button type="button"
class="inline-flex items-center gap-x-1 text-white rounded-md px-3 py-2 text-sm font-medium hover:bg-indigo-500 hover:bg-opacity-75"
aria-expanded="false" @click=" open = ! open" @click.outside=" open = false">
<span>My Auditions</span>
<svg class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd" d="M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z" clip-rule="evenodd" />
<path fill-rule="evenodd"
d="M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z"
clip-rule="evenodd"/>
</svg>
</button>
@ -19,15 +23,18 @@
To: "opacity-0 translate-y-1"
-->
<div class="absolute left-1/2 z-10 mt-5 flex w-screen max-w-min -translate-x-1/2 px-4" x-show="open" x-cloak>
<div class="w-56 shrink rounded-xl bg-white p-4 text-sm font-semibold leading-6 text-gray-900 shadow-lg ring-1 ring-gray-900/5">
<div
class="w-56 shrink rounded-xl bg-white p-4 text-sm font-semibold leading-6 text-gray-900 shadow-lg ring-1 ring-gray-900/5">
<a href="{{route('dashboard')}}" class="block p-2 hover:text-indigo-600">Dashboard</a>
@if(Auth::user()->school_id)
<a href="{{route('students.index')}}" class="block p-2 hover:text-indigo-600">My Students</a>
<a href="{{route('entries.index')}}" class="block p-2 hover:text-indigo-600">My Entries</a>
<a href="{{route('doubler_request.index')}}" class="block p-2 hover:text-indigo-600">My Doubler Requests</a>
<a href="{{route('my_school')}}" class="block p-2 hover:text-indigo-600">My School</a>
@if(auditionSetting('invoicing_enabled'))
<a href="{{route('my_invoice')}}" class="block p-2 hover:text-indigo-600">My Invoice</a>
@endif
@endif
<a href="{{route('my_profile')}}" class="block p-2 hover:text-indigo-600">My Profile</a>
<form method="POST" action="/logout">
@csrf

View File

@ -20,7 +20,7 @@
My School
</x-card.list.row>
</a>
@if(Auth::user()->school_id)
@if(Auth::user()->school_id && auditionSetting('invoicing_enabled'))
<a href="{{ route('my_invoice') }}">
<x-card.list.row class="hover:bg-gray-200">
My Invoice