Asset management/fix last bugs

This commit is contained in:
Luca Haid
2025-06-29 10:43:06 +00:00
parent 4e18891afc
commit dffd2698bd
3 changed files with 30 additions and 6 deletions

View File

@@ -9,4 +9,22 @@ class AssetManagementReservationModel extends TTCrudBaseModel {
public ?string $notes;
public int $createBy;
public int $create;
public static function getConflictingReservations($assetId): array
{
$db = self::getDB();
$table = self::getFullyQualifiedTable();
$now = time();
$sql = "SELECT * FROM $table
WHERE assetId = $assetId AND startDate <= $now AND (endDate IS NULL OR endDate >= $now)
";
$result = $db->query($sql);
$reservations = [];
while ($row = $result->fetch_assoc()) {
$reservations[] = new self($row);
}
return $reservations;
}
}