If data is global then domain_uuid set to null

This means transaction is global. If there is a domain_uuid use the domain ID from the data.
This commit is contained in:
FusionPBX
2024-08-01 18:02:15 -06:00
committed by GitHub
parent d86217247e
commit b3f31af5a8
2 changed files with 28 additions and 15 deletions

View File

@@ -67,7 +67,7 @@
$sql .= "from v_database_transactions as t ";
$sql .= "left outer join v_domains as d using (domain_uuid) ";
$sql .= "left outer join v_users as u using (user_uuid) ";
$sql .= "where t.domain_uuid = :domain_uuid ";
$sql .= "where (t.domain_uuid = :domain_uuid or t.domain_uuid is null) ";
if (!empty($user_uuid)) {
$sql .= "and t.user_uuid = :user_uuid ";
$parameters['user_uuid'] = $user_uuid;
@@ -99,13 +99,13 @@
$offset = $rows_per_page * $page;
//get the list
$sql = "select t.database_transaction_uuid, d.domain_name, u.username, ";
$sql = "select t.database_transaction_uuid, t.domain_uuid, d.domain_name, u.username, ";
$sql .= "t.user_uuid, t.app_name, t.app_uuid, t.transaction_code, ";
$sql .= "t.transaction_address, t.transaction_type, t.transaction_date ";
$sql .= "from v_database_transactions as t ";
$sql .= "left outer join v_domains as d using (domain_uuid) ";
$sql .= "left outer join v_users as u using (user_uuid) ";
$sql .= "where t.domain_uuid = :domain_uuid ";
$sql .= "where (t.domain_uuid = :domain_uuid or t.domain_uuid is null) ";
if (!empty($user_uuid)) {
$sql .= "and t.user_uuid = :user_uuid ";
$parameters['user_uuid'] = $user_uuid;
@@ -127,7 +127,7 @@
$sql .= order_by($order_by, $order, 't.transaction_date', 'desc');
$sql .= limit_offset($rows_per_page, $offset);
$database = new database;
$result = $database->select($sql, $parameters, 'all');
$transactions = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//get users
@@ -190,10 +190,10 @@
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
if (!empty($result)) {
if (!empty($transactions)) {
$x = 0;
foreach($result as $row) {
foreach($transactions as $row) {
if (empty($row['domain_name'])) { $row['domain_name'] = $text['label-global']; }
if (permission_exists('database_transaction_edit')) {
$list_row_url = "database_transaction_edit.php?id=".urlencode($row['database_transaction_uuid']).(!empty($page) ? "&page=".urlencode($page) : null).(!empty($search) ? "&search=".urlencode($search) : null);
}
@@ -213,7 +213,6 @@
echo "</tr>\n";
$x++;
}
unset($result);
}
echo "</table>\n";

View File

@@ -2792,10 +2792,24 @@
//log the transaction results
if ($transaction_save && file_exists($_SERVER["PROJECT_ROOT"]."/app/database_transactions/app_config.php")) {
try {
//get the domain_uuid
$domain_uuid = '';
foreach($old_array as &$data_array) {
foreach ($data_array as $row) {
if (!empty($row['domain_uuid'])) {
$domain_uuid = $row['domain_uuid'];
}
}
}
//insert the transaction into the database
$sql = "insert into ".self::TABLE_PREFIX."database_transactions ";
$sql .= "(";
$sql .= "database_transaction_uuid, ";
$sql .= "domain_uuid, ";
if (isset($domain_uuid) && is_uuid($domain_uuid)) {
$sql .= "domain_uuid, ";
}
if (isset($this->user_uuid) && is_uuid($this->user_uuid)) {
$sql .= "user_uuid, ";
}
@@ -2816,11 +2830,8 @@
$sql .= "values ";
$sql .= "(";
$sql .= "'".uuid()."', ";
if (is_null($this->domain_uuid)) {
$sql .= "null, ";
}
else {
$sql .= "'".$this->domain_uuid."', ";
if (isset($domain_uuid) && is_uuid($domain_uuid)) {
$sql .= ":domain_uuid, ";
}
if (isset($this->user_uuid) && is_uuid($this->user_uuid)) {
$sql .= ":user_uuid, ";
@@ -2850,6 +2861,9 @@
$sql .= ":transaction_result ";
$sql .= ")";
$statement = $this->db->prepare($sql);
if (isset($domain_uuid) && is_uuid($domain_uuid)) {
$statement->bindParam(':domain_uuid', $domain_uuid);
}
if (isset($this->user_uuid) && is_uuid($this->user_uuid)) {
$statement->bindParam(':user_uuid', $this->user_uuid);
}
@@ -3171,4 +3185,4 @@
echo $database->count();
*/
?>
?>