Files
thetool/application/WorkorderTenantConfig/WorkorderTenantConfigModel.php

40 lines
1.4 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 $workorderActiveFilters; // JSON
public ?string $interventionTypes; // JSON
public int $civilEngineeringDocsRequired;
public int $requireCableLength;
public int $requireCableType;
public int $showTechnicalData = 0;
public int $enableWorkorder;
public int $enableWorkorderMph;
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;
}
}