30 lines
925 B
PHP
30 lines
925 B
PHP
<?php
|
|
// WorkorderCompanyModel.php
|
|
|
|
class WorkorderCompanyModel extends TTCrudBaseModel {
|
|
public int $id;
|
|
public int $addressId;
|
|
public string $name;
|
|
public ?string $visibleForAddressId;
|
|
public int $create;
|
|
public int $createBy;
|
|
|
|
public static function getCompanyWorkers(int $companyId): array {
|
|
if (!$company = self::get($companyId)) {
|
|
return [];
|
|
}
|
|
|
|
$db = self::getDB();
|
|
$addressId = $db->real_escape_string($company->addressId);
|
|
|
|
$sql = "SELECT w.id, w.name, w.email
|
|
FROM `" . FRONKDB_DBNAME . "`.`Worker` w
|
|
JOIN `" . FRONKDB_DBNAME . "`.`WorkerPermission` wp ON w.id = wp.worker_id
|
|
WHERE w.address_id = '$addressId' AND wp.canRMLCompany = 'true' AND w.active = 1
|
|
ORDER BY w.name ASC";
|
|
|
|
$result = $db->query($sql);
|
|
|
|
return $result ? $result->fetch_all(MYSQLI_ASSOC) : [];
|
|
}
|
|
} |