36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
<?php
|
|
|
|
class WarehouseProjectModel extends TTCrudBaseModel {
|
|
public int $id;
|
|
public string $projectNumber;
|
|
public string $title;
|
|
public ?string $description;
|
|
public ?int $startDate;
|
|
public ?int $endDate;
|
|
public string $status;
|
|
public float $financials;
|
|
public ?string $storageLocation;
|
|
public ?string $externalTeam;
|
|
public ?int $createdFromOrderId;
|
|
public int $createBy;
|
|
public int $create;
|
|
|
|
public static function getNextProjectNumber(): string {
|
|
$year = date('Y');
|
|
$prefix = "XP-$year-";
|
|
|
|
$db = self::getDB();
|
|
$tableName = self::getFullyQualifiedTable();
|
|
|
|
$sql = "SELECT projectNumber FROM $tableName WHERE projectNumber LIKE '$prefix%' ORDER BY projectNumber DESC LIMIT 1";
|
|
$result = $db->query($sql);
|
|
|
|
$nextNum = 1;
|
|
if ($row = $result->fetch_assoc()) {
|
|
$lastNumStr = substr($row['projectNumber'], strrpos($row['projectNumber'], '-') + 1);
|
|
$nextNum = intval($lastNumStr) + 1;
|
|
}
|
|
|
|
return $prefix . str_pad((string)$nextNum, 4, '0', STR_PAD_LEFT);
|
|
}
|
|
} |