47 lines
1.3 KiB
PHP
47 lines
1.3 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../helpers.php';
|
|
runAuth();
|
|
|
|
$data = readJsonBody();
|
|
$macAddress = trim($data['MACAddress'] ?? '');
|
|
|
|
if ($macAddress === '') {
|
|
apiAbort(['OK' => false, 'ERROR' => 'missing_mac', 'MESSAGE' => 'MACAddress is required']);
|
|
}
|
|
|
|
$q = queryOne("
|
|
SELECT
|
|
bh.ID AS BeaconHardwareID,
|
|
bh.HardwareId AS MACAddress,
|
|
bh.BusinessID,
|
|
bh.ServicePointID,
|
|
bh.ShardUUID AS UUID,
|
|
bh.Major,
|
|
bh.Minor,
|
|
bh.Status,
|
|
biz.Name AS BusinessName,
|
|
sp.Name AS ServicePointName
|
|
FROM BeaconHardware bh
|
|
LEFT JOIN Businesses biz ON biz.ID = bh.BusinessID
|
|
LEFT JOIN ServicePoints sp ON sp.ID = bh.ServicePointID
|
|
WHERE bh.HardwareId = ?
|
|
LIMIT 1
|
|
", [$macAddress]);
|
|
|
|
if (!$q || $q['Status'] !== 'assigned') {
|
|
jsonResponse(['OK' => false, 'ERROR' => 'not_found']);
|
|
}
|
|
|
|
jsonResponse([
|
|
'OK' => true,
|
|
'ERROR' => '',
|
|
'BEACON' => [
|
|
'BeaconID' => (int) $q['BeaconHardwareID'],
|
|
'BusinessID' => (int) $q['BusinessID'],
|
|
'BusinessName' => $q['BusinessName'] ?? '',
|
|
'BeaconName' => $q['ServicePointName'] ?? '',
|
|
'UUID' => $q['UUID'] ?? '',
|
|
'MACAddress' => $q['MACAddress'],
|
|
'ServicePointName' => $q['ServicePointName'] ?? '',
|
|
],
|
|
]);
|