Preorder/add new filter
This commit is contained in:
@@ -2,14 +2,35 @@
|
||||
|
||||
class WarehouseProjectModel extends TTCrudBaseModel {
|
||||
public int $id;
|
||||
public string $projectNumber;
|
||||
public string $title;
|
||||
public string $description;
|
||||
public string $startDate;
|
||||
public string $endDate;
|
||||
public ?string $description;
|
||||
public ?int $startDate;
|
||||
public ?int $endDate;
|
||||
public string $status;
|
||||
public string $priority;
|
||||
|
||||
public int $assignedTo;
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user