Skip to content

Commit

Permalink
piccola revisione funzione filtraggio prenotazioni per cerchie
Browse files Browse the repository at this point in the history
  • Loading branch information
madbob committed Sep 14, 2024
1 parent 92f0ec0 commit 2c4f0a2
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions code/app/Helpers/CirclesFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,28 +113,25 @@ private function sortByCircle($bookings)

public function sortBookings($bookings)
{
$actual_circles = $this->circles;
$tmp_bookings = new Collection();
$filter_circles = (empty($this->circles) == false);

if (empty($this->circles)) {
$tmp_bookings = collect($bookings);
}
else {
$tmp_bookings = new Collection();
foreach($bookings as $booking) {
$valid = true;

foreach($bookings as $booking) {
if ($filter_circles) {
$mycircles = $booking->involvedCircles();
$valid = true;

foreach($this->circles as $required_circle) {
if (is_null($mycircles->firstWhere('id', $required_circle->id))) {
$valid = false;
break;
}
}
}

if ($valid) {
$tmp_bookings->push($booking);
}
if ($valid) {
$tmp_bookings->push($booking);
}
}

Expand Down

0 comments on commit 2c4f0a2

Please sign in to comment.