api: Expose ports in API requests for bills (#6069)

* Expose ports in API requests for bills
This commit is contained in:
Mark Hughes
2017-03-04 07:40:15 +11:00
committed by Neil Lathwood
parent 680ef0645f
commit dc41c0eae1
2 changed files with 19 additions and 2 deletions

View File

@@ -1711,7 +1711,14 @@ Output:
"allowed": "10Mbps",
"used": "0bps",
"percent": 0,
"overuse": "-"
"overuse": "-",
"ports": [
{
"device_id": "168",
"port_id": "35146",
"ifName": "eth0"
}
]
}
]
}
@@ -1771,7 +1778,14 @@ Output:
"allowed": "10Mbps",
"used": "0bps",
"percent": 0,
"overuse": "-"
"overuse": "-",
"ports": [
{
"device_id": "168",
"port_id": "35146",
"ifName": "eth0"
}
]
}
]
}

View File

@@ -1272,6 +1272,9 @@ function list_bills()
$bill['used'] = $used;
$bill['percent'] = $percent;
$bill['overuse'] = $overuse;
$bill['ports'] = dbFetchRows("SELECT `D`.`device_id`,`P`.`port_id`,`P`.`ifName` FROM `bill_ports` AS `B`, `ports` AS `P`, `devices` AS `D` WHERE `B`.`bill_id` = ? AND `P`.`port_id` = `B`.`port_id` AND `D`.`device_id` = `P`.`device_id`", array($bill["bill_id"]));
$bills[] = $bill;
}
$count = count($bills);