diff --git a/post/account_type.php b/post/account_type.php index 42a02106..7c3fb256 100644 --- a/post/account_type.php +++ b/post/account_type.php @@ -86,3 +86,17 @@ if (isset($_GET['archive_account_type'])) { header("Location: " . $_SERVER["HTTP_REFERER"]); } + +if (isset($_GET['unarchive_account_type'])) { + $account_type_id = intval($_GET['unarchive_account_type']); + + mysqli_query($mysqli,"UPDATE account_types SET account_type_archived_at = NULL WHERE account_type_id = $account_type_id"); + + //logging + mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Account Type', log_action = 'Unarchive', log_description = '$account_id', log_ip = '$session_ip', log_user_agent = '$session_user_agent'"); + + $_SESSION['alert_message'] = "Account Unarchived"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} \ No newline at end of file diff --git a/settings_account_types.php b/settings_account_types.php index 55134c03..69674c37 100644 --- a/settings_account_types.php +++ b/settings_account_types.php @@ -5,11 +5,39 @@ require_once("inc_all_settings.php"); $sort = "account_type_id"; $order = "ASC"; +if (isset($_GET['account_type'])) { + $account_type = sanitizeInput($_GET['account_type']); + switch ($account_type) { + case "Assets": + $account_type_id_min = "10"; + $account_type_id_max = "19"; + break; + case "Liabilities": + $account_type_id_min = "20"; + $account_type_id_max = "29"; + break; + case "Equity": + $account_type_id_min = "30"; + $account_type_id_max = "39"; + break; + default: + $account_type_id_min = "10"; + $account_type_id_max = "39"; + } +} else { + $account_type_id_min = "10"; + $account_type_id_max = "39"; +} + + $sql = mysqli_query( $mysqli, "SELECT * FROM account_types - WHERE account_type_archived_at IS NULL + WHERE account_type_$archive_query + AND account_type_id >= $account_type_id_min + AND account_type_id <= $account_type_id_max + AND (account_type_name LIKE '%$q%' OR account_type_description LIKE '%$q%' OR account_type_id LIKE '%$q%') ORDER BY $sort $order" ); @@ -21,17 +49,61 @@ $num_rows = mysqli_num_rows($sql);