Skip to content

Commit 737a96b

Browse files
authored
Merge branch 'v4.4.0' into shift-163100
2 parents f796f53 + 9c1855e commit 737a96b

File tree

5 files changed

+543
-7
lines changed

5 files changed

+543
-7
lines changed

app/Livewire/ProjectOverview.php

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
<?php
2+
3+
namespace App\Livewire;
4+
5+
use App\Models\Legacy\Expense;
6+
use App\Models\Legacy\LegacyBudgetPlan;
7+
use App\Models\Legacy\Project;
8+
use App\Services\Auth\AuthService;
9+
use Illuminate\Database\Eloquent\Collection;
10+
use Illuminate\Support\Facades\Auth;
11+
use Livewire\Attributes\Computed;
12+
use Livewire\Attributes\Url;
13+
use Livewire\Component;
14+
15+
class ProjectOverview extends Component
16+
{
17+
#[Url]
18+
public ?int $hhpId = null;
19+
20+
#[Url]
21+
public string $tab = 'mygremium';
22+
23+
public function mount(): void
24+
{
25+
if ($this->hhpId === null) {
26+
$this->hhpId = LegacyBudgetPlan::latest()?->id;
27+
}
28+
}
29+
30+
#[Computed]
31+
public function budgetPlans(): Collection
32+
{
33+
return LegacyBudgetPlan::orderBy('id', 'desc')->get();
34+
}
35+
36+
#[Computed]
37+
public function currentBudgetPlan(): ?LegacyBudgetPlan
38+
{
39+
return LegacyBudgetPlan::find($this->hhpId);
40+
}
41+
42+
#[Computed]
43+
public function userCommittees(): array
44+
{
45+
return app(AuthService::class)->userCommittees()->toArray();
46+
}
47+
48+
#[Computed]
49+
public function projectsByCommittee(): Collection
50+
{
51+
$budgetPlan = $this->currentBudgetPlan();
52+
if (!$budgetPlan) {
53+
return [];
54+
}
55+
56+
$query = Project::query()
57+
->with(['posts', 'expenses.receipts.posts'])
58+
->withSum('posts as total_ausgaben', 'ausgaben')
59+
->withSum('posts as total_einnahmen', 'einnahmen')
60+
->where('createdat', '>=', $budgetPlan->von);
61+
62+
if ($budgetPlan->bis) {
63+
$query->where('createdat', '<=', $budgetPlan->bis);
64+
}
65+
66+
// Apply tab-specific filters
67+
switch ($this->tab) {
68+
case 'mygremium':
69+
$committees = $this->userCommittees;
70+
if (empty($committees)) {
71+
return [];
72+
}
73+
$query->where(function ($q) use ($committees) {
74+
$q->whereIn('org', $committees)
75+
->orWhereNull('org')
76+
->orWhere('org', '');
77+
});
78+
break;
79+
80+
case 'allgremium':
81+
// No additional filter, show all
82+
break;
83+
84+
case 'open-projects':
85+
$query->whereNotIn('state', ['terminated', 'revoked'])
86+
->where('state', 'not like', '%terminated%')
87+
->where('state', 'not like', '%revoked%');
88+
break;
89+
}
90+
91+
$projects = $query->orderBy('org')->orderBy('id', 'desc')->get();
92+
93+
// Group by committee
94+
return $projects->groupBy(fn($project) => $project->org ?: '');
95+
}
96+
97+
#[Computed]
98+
public function expensesByProjectId(): array
99+
{
100+
$projectIds = collect($this->projectsByCommittee)
101+
->flatten(1)
102+
->pluck('id')
103+
->toArray();
104+
105+
if (empty($projectIds)) {
106+
return [];
107+
}
108+
109+
return Expense::query()
110+
->with(['receipts.posts'])
111+
->whereIn('projekt_id', $projectIds)
112+
->get()
113+
->groupBy('projekt_id')
114+
->toArray();
115+
}
116+
117+
public function setTab(string $tab): void
118+
{
119+
$this->tab = $tab;
120+
}
121+
122+
public function setBudgetPlan(int $id): void
123+
{
124+
$this->hhpId = $id;
125+
}
126+
127+
public function render()
128+
{
129+
return view('livewire.project-overview');
130+
}
131+
}

lang/de/dashboard.php

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?php
2+
3+
return [
4+
// Page titles
5+
'page_titles' => [
6+
'projects' => 'Projektübersicht',
7+
'stura' => 'StuRa-Sitzung',
8+
'hv' => 'Haushaltsverantwortliche*r',
9+
'kv' => 'Kassenverantwortliche*r',
10+
'belege' => 'Fehlende Belege',
11+
'export_bank' => 'Überweisungen',
12+
],
13+
14+
// Main tabs
15+
'tabs' => [
16+
'my_committees' => 'Meine Gremien',
17+
'all_committees' => 'Alle Gremien',
18+
'open_projects' => 'Offene Projekte',
19+
],
20+
21+
// Todo tabs
22+
'todo_tabs' => [
23+
'missing_receipts' => 'Belege fehlen',
24+
'hv' => 'Haushaltsverantwortliche*r',
25+
'kv' => 'Kassenverantwortliche*r',
26+
'transfers' => 'Überweisungen',
27+
],
28+
29+
// Table headers
30+
'table' => [
31+
'name' => 'Name',
32+
'recipient' => 'Zahlungsempfänger',
33+
'income' => 'Einnahmen',
34+
'expenses' => 'Ausgaben',
35+
'status' => 'Status',
36+
'project' => 'Projekt',
37+
'expense' => 'Abrechnung',
38+
'organization' => 'Organisation',
39+
'project_start' => 'Projektbeginn',
40+
'last_changed' => 'Zuletzt geändert',
41+
'iban' => 'IBAN',
42+
'reference' => 'Verwendungszweck',
43+
'amount' => 'Auszuzahlen',
44+
],
45+
46+
// Summary
47+
'summary' => [
48+
'submitted' => 'Eingereicht',
49+
'paid' => 'Ausgezahlt',
50+
],
51+
52+
// Alerts
53+
'alerts' => [
54+
'no_committee_title' => 'Schade!',
55+
'no_committee_message' => 'Leider scheinst du noch kein Gremium zu haben.',
56+
'no_projects_title' => 'Hinweis',
57+
'no_projects_message' => 'In deinen Gremien wurden in diesem Haushaltsjahr noch keine Projekte angelegt. Fange doch jetzt damit an!',
58+
'create_new_project' => 'Neues Projekt erstellen',
59+
'no_open_projects_title' => 'Super!',
60+
'no_open_projects_message' => 'Es gibt in diesem Haushaltsjahr keine offenen Projekte. Für den Haushaltsabschluss ist das wirklich eine gute Sache!',
61+
],
62+
63+
// Unassigned projects
64+
'unassigned_projects' => 'Nicht zugeordnete Projekte',
65+
66+
// StuRa section
67+
'stura' => [
68+
'title' => 'Projekte für die nächste Sitzung',
69+
'to_vote' => 'Vom Gremium abzustimmen',
70+
'for_announcement' => 'Zur Verkündung',
71+
'no_projects_to_vote' => 'Aktuell keine Projekte zur Abstimmung.',
72+
'no_projects_for_announcement' => 'Aktuell keine Projekte zur Verkündung.',
73+
],
74+
75+
// HV section
76+
'hv' => [
77+
'projects_to_review' => 'Zu prüfende Projekte',
78+
'expenses_to_review' => 'Sachliche Richtigkeit der Auslagen prüfen',
79+
'no_projects' => 'Aktuell keine Projekte zu prüfen.',
80+
'no_expenses' => 'Aktuell keine Auslagen zu prüfen.',
81+
],
82+
83+
// KV section
84+
'kv' => [
85+
'expenses_to_review' => 'Rechnerische Richtigkeit der Auslagen prüfen',
86+
'no_expenses' => 'Aktuell keine Auslagen zu prüfen.',
87+
],
88+
89+
// Belege section
90+
'belege' => [
91+
'missing_receipts' => 'Belege fehlen',
92+
'no_missing' => 'Alle Belege vollständig.',
93+
],
94+
95+
// Bank export section
96+
'bank' => [
97+
'pending_transfers' => 'Zu überweisen',
98+
'no_transfers_title' => 'Alles erledigt!',
99+
'no_transfers_message' => 'Aktuell liegen keine Überweisungen vor.',
100+
'total' => 'Gesamt',
101+
],
102+
103+
// Expense states
104+
'expense_states' => [
105+
'draft' => 'Entwurf',
106+
'wip' => 'In Bearbeitung',
107+
'ok' => 'Genehmigt',
108+
'instructed' => 'Angewiesen',
109+
'booked' => 'Gebucht',
110+
'revocation' => 'Widerrufen',
111+
'terminated' => 'Abgeschlossen',
112+
],
113+
];

0 commit comments

Comments
 (0)