Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/Http/Controllers/VenueController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class VenueController extends Controller
{
//
}
4 changes: 2 additions & 2 deletions app/Livewire/Components/EventCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function getEventDetails($eventId)

$event = Event::select(['event_id', 'ticket_id', 'event__type_id', 'notes'])
->with([
'ticket' => fn($q) => $q->select(['ticket_id', 'ticket_number', 'title', 'description', 'venue_requested', 'user_id', 'status'])
'ticket' => fn($q) => $q->select(['ticket_id', 'ticket_number', 'title', 'description', 'venue_requested', 'venue_other', 'user_id', 'status'])
->with([
'user' => fn($q) => $q->select(['user_id', 'org_id'])
->with('studentOrganization:org_id,org_name,logo'),
Expand All @@ -99,7 +99,7 @@ public function getEventDetails($eventId)
'status' => $event->ticket->status ?? 'approved',
'ticketNumber' => $event->ticket->ticket_number ?? null,
'type' => $event->eventType?->type_name ?? 'N/A',
'venue' => $event->ticket->venue_requested ?? 'TBD',
'venue' => $event->ticket->venue_display_name ?? 'TBD',
'description' => $event->ticket->description ?? null,
'schedules' => $event->eventSchedules->map(function ($s) {
// Use getRawOriginal to get exact database time values
Expand Down
2 changes: 1 addition & 1 deletion app/Livewire/Gso/TicketReview.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ protected function formatTicket(Office_Approval $approval): array
?? 'N/A',
'request_type' => $ticket?->eventType?->type_name ?? 'N/A',
'event_date' => $eventDate?->format('M d, Y') ?? 'N/A',
'venue' => $ticket?->venue_requested ?? 'TBD',
'venue' => $ticket?->venue_display_name ?? 'TBD',
'priority' => $priority['key'],
'priority_label' => $priority['label'],
'priority_days_until' => $priority['days_until'],
Expand Down
4 changes: 2 additions & 2 deletions app/Livewire/Osa/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function pendingApprovals(): array
public function upcomingEvents(): array
{
return Cache::remember('osa_dashboard_upcoming_events', $this->cacheDuration, function () {
return Ticket::select(['ticket_id', 'title', 'date_from', 'venue_requested', 'user_id'])
return Ticket::select(['ticket_id', 'title', 'date_from', 'venue_requested', 'venue_other', 'user_id'])
->with([
'user' => fn($q) => $q->select(['user_id', 'org_id'])
->with('studentOrganization:org_id,org_name,logo')
Expand All @@ -132,7 +132,7 @@ public function upcomingEvents(): array
'date' => $ticket->date_from
? \Carbon\Carbon::parse($ticket->date_from)->format('M d, Y')
: 'TBD',
'venue' => $ticket->venue_requested ?? 'TBD',
'venue' => $ticket->venue_display_name ?? 'TBD',
];
})
->toArray();
Expand Down
4 changes: 3 additions & 1 deletion app/Livewire/Osa/TicketReview/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public function tickets()
'description',
'status',
'venue_requested',
'venue_other',
'date_from',
'user_id',
'event_type_id',
'created_at',
Expand All @@ -65,7 +67,7 @@ public function tickets()
'user' => fn ($q) => $q->select(['user_id', 'org_id'])
->with('studentOrganization:org_id,org_name'),
'events' => fn ($q) => $q->select(['event_id', 'ticket_id'])
->with('eventSchedules:schedule_id,event_id,start_date,start_time'),
->with('eventSchedules:schedule_id,event_id,start_date,start_time,venue'),
'attachments:attachment_id,ticket_id,file_path,file_name',
'eventType:event_type_id,type_name',
])
Expand Down
6 changes: 4 additions & 2 deletions app/Livewire/Osa/TicketReview/Show.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ public function mount($ticketNumber)
'time_from',
'time_to',
'venue_requested',
'venue_other',
'alternate_venue',
'alternate_venue_other',
'special_requirements',
'plv_participants',
'external_participants',
Expand Down Expand Up @@ -149,7 +151,7 @@ public function approveTicket()
'end_date' => $this->ticket->date_to,
'start_time' => $this->ticket->time_from,
'end_time' => $this->ticket->time_to,
'venue' => $this->ticket->venue_requested,
'venue' => $this->ticket->venue_display_name,
'status' => 'approved',
'remarks' => 'Schedule created from approved ticket',
]);
Expand Down Expand Up @@ -337,7 +339,7 @@ public function finalApproval()
'end_date' => $this->ticket->date_to,
'start_time' => $this->ticket->time_from,
'end_time' => $this->ticket->time_to,
'venue' => $this->ticket->venue_requested,
'venue' => $this->ticket->venue_display_name,
'status' => 'approved',
'remarks' => 'Schedule created from approved ticket after GSO review',
]);
Expand Down
87 changes: 33 additions & 54 deletions app/Livewire/StudentOrg/History.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,77 +188,56 @@ public function getMonthlyActivityProperty()

public function getTicketsProperty()
{
$userId = auth()->id();

$query = DB::table('tickets')
->leftJoin('events', 'tickets.ticket_id', '=', 'events.ticket_id')
->leftJoin('event__types', function($join) {
$join->on('events.event__type_id', '=', 'event__types.event_type_id')
->orOn('tickets.event_type_id', '=', 'event__types.event_type_id');
})
->leftJoin('event_schedules', function($join) {
$join->on('events.event_id', '=', 'event_schedules.event_id')
->where('event_schedules.status', 'active');
})
->leftJoin('o_s_a__approvals as latest_osa', function($join) {
$join->on('tickets.ticket_id', '=', 'latest_osa.ticket_id')
->whereRaw('latest_osa.updated_at = (
SELECT MAX(updated_at)
FROM o_s_a__approvals
WHERE ticket_id = tickets.ticket_id
)');
})
->where('tickets.user_id', $userId)
->whereIn('tickets.status', ['approved', 'for_revision', 'cancelled']);
$query = \App\Models\Ticket::query()
->with([
'events.eventType',
'events' => function($q) {
$q->with(['eventSchedules' => function($sq) {
$sq->where('status', 'active')
->select('event_id', 'venue', 'start_date', 'end_date', 'status');
}]);
},
'venue',
'latestOsaApproval',
'eventType'
])
->where('user_id', auth()->id())
->whereIn('status', ['approved', 'for_revision', 'cancelled']);

// Search filter
// Apply filters
if ($this->search) {
$query->where(function($q) {
$q->where('tickets.title', 'like', '%' . $this->search . '%')
->orWhere('tickets.description', 'like', '%' . $this->search . '%')
->orWhere('tickets.venue_requested', 'like', '%' . $this->search . '%')
->orWhere('event_schedules.venue', 'like', '%' . $this->search . '%');
$q->where('title', 'like', "%{$this->search}%")
->orWhere('description', 'like', "%{$this->search}%")
->orWhereHas('venue', function($vq) {
$vq->where('venue_name', 'like', "%{$this->search}%");
})
->orWhereHas('events.schedules', function($sq) {
$sq->where('venue', 'like', "%{$this->search}%");
});
});
}

// Status filter
if ($this->statusFilter) {
$query->where('tickets.status', $this->statusFilter);
$query->where('status', $this->statusFilter);
}

// Event type filter
if ($this->typeFilter) {
$query->where('event__types.type_name', $this->typeFilter);
$query->whereHas('eventType', function($q) {
$q->where('type_name', $this->typeFilter);
});
}

// Year filter
if ($this->yearFilter) {
$query->where(function($q) {
$q->whereYear('tickets.date_from', $this->yearFilter)
->orWhereYear('event_schedules.start_date', $this->yearFilter);
$q->whereYear('date_from', $this->yearFilter)
->orWhereHas('events.schedules', function($sq) {
$sq->whereYear('start_date', $this->yearFilter);
});
});
}

$tickets = $query->select(
'tickets.*',
'events.event_id',
'events.notes as event_notes',
'event__types.type_name as event_type_name',
'event_schedules.schedule_id',
'event_schedules.start_date',
'event_schedules.end_date',
'event_schedules.start_time',
'event_schedules.end_time',
'event_schedules.venue as schedule_venue',
'event_schedules.status as schedule_status',
'event_schedules.remarks as schedule_remarks',
'latest_osa.remarks as osa_remarks',
'latest_osa.decision as osa_decision'
)
->orderByDesc('tickets.created_at')
->paginate(10);

return $tickets;
return $query->latest('created_at')->paginate(10);
}

public function getEventTypesProperty()
Expand Down
4 changes: 2 additions & 2 deletions app/Livewire/StudentOrg/MyTicket.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ private function makeTemporaryUrl(string $path, string $filename, bool $forceDow

public function render()
{
$allTickets = auth()->user()->tickets()->with('eventType')->get();
$ticketsQuery = auth()->user()->tickets()->with('eventType')
$allTickets = auth()->user()->tickets()->with('eventType')->with('venue')->get();
$ticketsQuery = auth()->user()->tickets()->with('eventType')->with('venue')
->when($this->search, function ($query) {
$query->where(function ($q) {
$q->where('title', 'like', '%' . $this->search . '%')
Expand Down
47 changes: 37 additions & 10 deletions app/Livewire/StudentOrg/SubmitTicket.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ class SubmitTicket extends Component
#[Validate('required|date_format:H:i|after:eventStartTime')]
public $eventEndTime = '';

#[Validate('required|string|max:255|min:3')]
public $preferredVenue = '';

#[Validate('nullable|string|max:255|min:3')]
public $alternativeVenue = '';
public $venues = [];
public $preferredVenue;
public $preferredVenueOther;
public $alternativeVenue;
public $alternativeVenueOther;

#[Validate('nullable|string|max:2000')]
public $specialRequirements = '';
Expand Down Expand Up @@ -243,8 +243,10 @@ protected function getCurrentStepRules(): array
'eventEndDate' => 'required|date|after_or_equal:eventStartDate',
'eventStartTime' => ['required', 'date_format:H:i'],
'eventEndTime' => ['required', 'date_format:H:i', 'after:eventStartTime'],
'preferredVenue' => 'required|string|max:255|min:3',
'alternativeVenue' => 'nullable|string|max:255|min:3',
'preferredVenue' => 'required|integer|exists:venues,venue_id',
'preferredVenueOther' => $this->isOthersVenue($this->preferredVenue) ? 'required|string|max:255|min:3' : 'nullable',
'alternativeVenue' => 'nullable|integer|exists:venues,venue_id',
'alternativeVenueOther' => $this->isOthersVenue($this->alternativeVenue) ? 'required|string|max:255|min:3' : 'nullable',
'specialRequirements' => 'nullable|string|max:2000',
'is_oc' => 'required|boolean',
'oc_accommodation' => $this->is_oc ? 'nullable|string|max:2000' : 'nullable',
Expand Down Expand Up @@ -273,6 +275,16 @@ protected function getCurrentStepRules(): array
};
}

protected function isOthersVenue($venueId): bool
{
if (!$venueId) {
return false;
}

$venue = \App\Models\Venue::find($venueId);
return $venue && $venue->venue_name === 'Others (Please Specify)';
}

// Auto-save draft on property update
public function updated($property)
{
Expand Down Expand Up @@ -390,7 +402,9 @@ public function getPreviewTicketProperty()
$ticket->time_from = $this->eventStartTime;
$ticket->time_to = $this->eventEndTime;
$ticket->venue_requested = $this->preferredVenue;
$ticket->venue_other = $this->preferredVenueOther;
$ticket->alternate_venue = $this->alternativeVenue;
$ticket->alternate_venue_other = $this->alternativeVenueOther;
$ticket->special_requirements = $this->specialRequirements;
$ticket->estimated_budget = $this->totalBudget;
$ticket->budget_breakdown = $this->budgetBreakdown;
Expand Down Expand Up @@ -419,9 +433,18 @@ public function getPreviewTicketProperty()
$ticket->setRelation('fundSource', Fund_Sources::find($this->fundingSource));
$ticket->setRelation('attachments', $previewAttachments);

// Load venue relationships
if ($this->preferredVenue) {
$ticket->setRelation('preferredVenueRelation', \App\Models\Venue::find($this->preferredVenue));
}
if ($this->alternativeVenue) {
$ticket->setRelation('alternativeVenueRelation', \App\Models\Venue::find($this->alternativeVenue));
}

return $ticket;
}


public function mount()
{
$currentUser = auth()->user();
Expand All @@ -435,6 +458,7 @@ public function mount()
$this->organizationCourse = $currentUserinfo->course->course_name ?? '';
$this->proponentPosition = $currentUserPosition->position_name ?? '';
$this->proponent_contact = $currentUser->phone ?? '';
$this->venues = \App\Models\Venue::where('is_active', true)->get();

// Trigger validation for adviser_contact since it has a default value
try {
Expand Down Expand Up @@ -472,8 +496,8 @@ public function save()
position: 'toast-top toast-end',
icon: 'o-clock',
css: 'alert-warning',
timeout: 5000,
noProgress: true,
timeout: 5000,
);
return;
}
Expand Down Expand Up @@ -526,8 +550,10 @@ public function save()
'oc_driver_contact_number' => $nullIfEmpty($this->oc_driver_contact_number),
'estimated_budget' => $this->totalBudget ? (float) $this->totalBudget : null,
'budget_breakdown' => $nullIfEmpty($this->budgetBreakdown),
'venue_requested' => $this->preferredVenue,
'alternate_venue' => $nullIfEmpty($this->alternativeVenue),
'venue_requested' => $nullIfEmptyInt($this->preferredVenue),
'venue_other' => $nullIfEmpty($this->preferredVenueOther),
'alternate_venue' => $nullIfEmptyInt($this->alternativeVenue),
'alternate_venue_other' => $nullIfEmpty($this->alternativeVenueOther),
'special_requirements' => $nullIfEmpty($this->specialRequirements),
'total_participants' => (int) $this->expectedPLVParticipants + (int) ($this->expectedNonPLVParticipants ?: 0),
'fund_source_id' => (int) $this->fundingSource,
Expand Down Expand Up @@ -643,6 +669,7 @@ public function save()
}
}


public function loadDraft($draftData)
{
foreach ($draftData as $key => $value) {
Expand Down
Loading