WIP Contract/Billing 2024-07-04

This commit is contained in:
Frank Schubert
2024-07-05 10:45:22 +02:00
parent 0640babfa3
commit 92edb9c812
27 changed files with 8043 additions and 116 deletions

View File

@@ -2,6 +2,7 @@
class VoiceCallHistoryModel {
public $uid;
public $voice_account;
public $contract_id;
public $start;
public $source;
public $destination;
@@ -109,6 +110,7 @@ class VoiceCallHistoryModel {
$sql .= isset($filters['destination']) ? Helper::generateFilterCondition($filters['destination'], "destination") : "";
$sql .= isset($filters['billable']) ? Helper::generateFilterCondition($filters['billable'], "billable") : "";
$sql .= isset($filters['duration']) ? Helper::generateFilterCondition($filters['duration'], "duration") : "";
$sql .= array_key_exists("contract_id", $filters) ? Helper::generateFilterCondition($filters['contract_id'], "contract_id") : "";
return $sql;
}
@@ -119,6 +121,7 @@ class VoiceCallHistoryModel {
$sql .= $order === null || $order['key'] === null ? " ORDER BY `start` DESC" : " ORDER BY `" . $order['key'] . "` " . $order['order'];
$sql .= $limit === null ? "" : " LIMIT " . $limit . " OFFSET " . $offset;
//mfLoghandler::singleton()->debug($sql);exit;
// die($sql);
$result = $db->query($sql);
$rows = [];
@@ -129,6 +132,23 @@ class VoiceCallHistoryModel {
return $rows;
}
public static function getVoiceCallHistoryAsEntity($filters, $limit = null, $offset = 0, $order = null) {
$db = FronkDB::singleton();
$sql = "SELECT * FROM `VoiceCallHistory` WHERE 1 " . self::getSqlFilter($filters);
$sql .= $order === null || $order['key'] === null ? " ORDER BY `start` DESC" : " ORDER BY `" . $order['key'] . "` " . $order['order'];
$sql .= $limit === null ? "" : " LIMIT " . $limit . " OFFSET " . $offset;
//mfLoghandler::singleton()->debug($sql);exit;
// die($sql);
$result = $db->query($sql);
$rows = [];
while ($row = $db->fetch_object($result)) {
$rows[] = new VoiceCallHistory($row);
}
return $rows;
}
public static function countVoiceCallHistory($filters) {
$db = FronkDB::singleton();
$sql = "SELECT COUNT(*) as `total_rows` FROM `VoiceCallHistory` WHERE 1 " . self::getSqlFilter($filters);