Asset management/fix last bugs
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user