34 lines
1.2 KiB
PHP
34 lines
1.2 KiB
PHP
<?php
|
|
// WorkorderTenantConfigModel.php
|
|
|
|
class WorkorderTenantConfigModel extends TTCrudBaseModel {
|
|
public int $id;
|
|
public int $addressId;
|
|
public string $name;
|
|
public string $documentationTypes; // JSON
|
|
public string $workorderCreationFilters; // JSON
|
|
public ?string $interventionTypes; // JSON
|
|
public int $civilEngineeringDocsRequired;
|
|
public int $create;
|
|
public int $createBy;
|
|
|
|
public static function findForWorkorder(WorkorderModel $workorder): ?WorkorderTenantConfigModel {
|
|
if (empty($workorder->preorderId)) return null;
|
|
|
|
$db = self::getDB();
|
|
$dbName = FRONKDB_DBNAME;
|
|
$tableWTC = self::getFullyQualifiedTable();
|
|
$preorderId = $db->real_escape_string($workorder->preorderId);
|
|
|
|
$sql = "SELECT wtc.* FROM $tableWTC wtc
|
|
JOIN `$dbName`.`Network` n ON wtc.addressId = n.owner_id
|
|
JOIN `$dbName`.`Preordercampaign` pc ON n.id = pc.network_id
|
|
JOIN `$dbName`.`Preorder` p ON pc.id = p.preordercampaign_id
|
|
WHERE p.id = '$preorderId' LIMIT 1";
|
|
|
|
$result = $db->query($sql);
|
|
$row = $result ? $result->fetch_assoc() : null;
|
|
|
|
return $row ? new self($row) : null;
|
|
}}
|