Merge branch 'master' into fork/boriswa/1849-1848-1920-1921-fix-bugs

# Conflicts:
#	src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location/NewLocation.vue
This commit is contained in:
2025-12-12 10:11:31 +01:00
22 changed files with 1037 additions and 955 deletions

View File

@@ -43,6 +43,7 @@ use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Collections\Order;
use Doctrine\Common\Collections\ReadableCollection;
use Doctrine\Common\Collections\Selectable;
use Doctrine\ORM\Mapping as ORM;
@@ -140,6 +141,12 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
#[ORM\ManyToMany(targetEntity: Calendar::class, mappedBy: 'persons')]
private Collection $calendars;
/**
* @var Collection<int, Calendar>&Selectable<int, Calendar>
*/
#[ORM\OneToMany(mappedBy: 'person', targetEntity: Calendar::class)]
private Collection $directCalendars;
/**
* The person's center.
*
@@ -409,6 +416,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
public function __construct()
{
$this->calendars = new ArrayCollection();
$this->directCalendars = new ArrayCollection();
$this->accompanyingPeriodParticipations = new ArrayCollection();
$this->spokenLanguages = new ArrayCollection();
$this->addresses = new ArrayCollection();
@@ -869,6 +877,30 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this->calendars;
}
/**
* Get next calendars for this person (calendars with start date after today).
* Only returns calendars that are directly linked to this person via the person property,
* not those linked through AccompanyingPeriods.
*
* @param int|null $limit Optional limit for the number of results
*
* @return array<Calendar>
*/
public function getNextCalendarsForPerson(?int $limit = null): array
{
$today = new \DateTimeImmutable('today');
$criteria = Criteria::create()
->where(Criteria::expr()->gte('startDate', $today))
->orderBy(['startDate' => Order::Ascending]);
if (null !== $limit) {
$criteria->setMaxResults($limit);
}
return $this->directCalendars->matching($criteria)->toArray();
}
public function getCenter(): ?Center
{
if (null !== $this->centerCurrent) {
@@ -1122,7 +1154,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
->where(
$expr->eq('shareHousehold', false)
)
->orderBy(['startDate' => \Doctrine\Common\Collections\Order::Descending]);
->orderBy(['startDate' => Order::Descending]);
return $this->getHouseholdParticipations()
->matching($criteria);
@@ -1144,7 +1176,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
->where(
$expr->eq('shareHousehold', true)
)
->orderBy(['startDate' => \Doctrine\Common\Collections\Order::Descending, 'id' => \Doctrine\Common\Collections\Order::Descending]);
->orderBy(['startDate' => Order::Descending, 'id' => Order::Descending]);
return $this->getHouseholdParticipations()
->matching($criteria);