From a959f588f3a7763afb93041cce978dbc9bd43393 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Sun, 27 Aug 2023 17:50:10 -0400 Subject: [PATCH] Updated hopefully everywhere for account so account_archived works properly also do not allow archiving of account if equals online payment account --- accounts.php | 3 ++- dashboard_financial.php | 2 +- expense_copy_modal.php | 4 ++-- expense_edit_modal.php | 10 ++++++++-- payments.php | 8 +++++++- recurring_expense_edit_modal.php | 10 ++++++++-- revenue_edit_modal.php | 11 ++++++++--- settings_defaults.php | 10 +++++----- settings_online_payment.php | 2 +- transfer_edit_modal.php | 20 ++++++++++++++++---- transfers.php | 16 ++++++++++++++-- 11 files changed, 72 insertions(+), 24 deletions(-) diff --git a/accounts.php b/accounts.php index 511f8693..25b4a4fd 100644 --- a/accounts.php +++ b/accounts.php @@ -13,6 +13,7 @@ $sql = mysqli_query( $mysqli, "SELECT SQL_CALC_FOUND_ROWS * FROM accounts WHERE account_name LIKE '%$q%' + AND account_archived_at IS NULL ORDER BY $sort $order LIMIT $record_from, $record_to" ); @@ -85,7 +86,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); Edit - + Archive diff --git a/dashboard_financial.php b/dashboard_financial.php index 50e4a902..e84ea52f 100644 --- a/dashboard_financial.php +++ b/dashboard_financial.php @@ -59,7 +59,7 @@ $receivables = $invoice_totals_all_years - $total_payments_to_invoices_all_years $profit = $total_income - $total_expenses; -$sql_accounts = mysqli_query($mysqli, "SELECT * FROM accounts"); +$sql_accounts = mysqli_query($mysqli, "SELECT * FROM accounts WHERE account_archived_at IS NULL ORDER BY account_name ASC"); $sql_latest_invoice_payments = mysqli_query( $mysqli, diff --git a/expense_copy_modal.php b/expense_copy_modal.php index ac82941b..3e1e2aef 100644 --- a/expense_copy_modal.php +++ b/expense_copy_modal.php @@ -44,7 +44,7 @@ '$expense_created_at' OR account_archived_at IS NULL) ORDER BY account_name ASC"); + $sql_accounts = mysqli_query($mysqli, "SELECT account_id, account_name, opening_balance, account_archived_at FROM accounts WHERE (account_archived_at > '$expense_created_at' OR account_archived_at IS NULL) ORDER BY account_archived_at ASC, account_name ASC"); while ($row = mysqli_fetch_array($sql_accounts)) { $account_id_select = intval($row['account_id']); $account_name_select = nullable_htmlentities($row['account_name']); $opening_balance = floatval($row['opening_balance']); + $account_archived_at = nullable_htmlentities($row['account_archived_at']); + if (empty($account_archived_at)) { + $account_archived_display = ""; + } else { + $account_archived_display = "Archived - "; + } $sql_payments = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS total_payments FROM payments WHERE payment_account_id = $account_id_select"); $row = mysqli_fetch_array($sql_payments); @@ -107,7 +113,7 @@ $balance = $opening_balance + $total_payments + $total_revenues - $total_expenses; ?> - + - Account - '$revenue_created_at' OR account_archived_at IS NULL) ORDER BY account_name ASC"); + $sql_accounts = mysqli_query($mysqli, "SELECT * FROM accounts WHERE (account_archived_at > '$revenue_created_at' OR account_archived_at IS NULL) ORDER BY account_archived_at ASC, account_name ASC"); while ($row = mysqli_fetch_array($sql_accounts)) { $account_id_select = intval($row['account_id']); $account_name_select = nullable_htmlentities($row['account_name']); $account_currency_code_select = nullable_htmlentities($row['account_currency_code']); $opening_balance = floatval($row['opening_balance']); - + $account_archived_at = nullable_htmlentities($row['account_archived_at']); + if (empty($account_archived_at)) { + $account_archived_display = ""; + } else { + $account_archived_display = "Archived - "; + } $sql_payments = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS total_payments FROM payments WHERE payment_account_id = $account_id_select"); $row = mysqli_fetch_array($sql_payments); $total_payments = floatval($row['total_payments']); @@ -84,7 +89,7 @@ $balance = $opening_balance + $total_payments + $total_revenues - $total_expenses; ?> - + @@ -71,7 +71,7 @@ require_once("inc_all_settings.php"); ?> @@ -92,7 +92,7 @@ require_once("inc_all_settings.php"); ?> @@ -113,7 +113,7 @@ require_once("inc_all_settings.php"); ?> @@ -180,7 +180,7 @@ require_once("inc_all_settings.php"); ?>
- + diff --git a/settings_online_payment.php b/settings_online_payment.php index ade93ff8..969b4768 100644 --- a/settings_online_payment.php +++ b/settings_online_payment.php @@ -49,7 +49,7 @@ require_once("inc_all_settings.php");