From 297148bc632a2cb233d59f84cab73f7ea64440dc Mon Sep 17 00:00:00 2001 From: johnnyq Date: Thu, 21 Dec 2023 16:36:31 -0500 Subject: [PATCH] DB Update add User settings to enable / disable Dashboard Items Financial and Technical --- check_login.php | 2 ++ dashboard.php | 20 ++++++++++++-------- database_updates.php | 15 ++++++++++++--- database_version.php | 2 +- db.sql | 4 +++- 5 files changed, 30 insertions(+), 13 deletions(-) diff --git a/check_login.php b/check_login.php index 9e277e69..f6ca6b69 100644 --- a/check_login.php +++ b/check_login.php @@ -44,6 +44,8 @@ if ($session_user_role == 3) { } $session_user_config_force_mfa = intval($row['user_config_force_mfa']); $user_config_records_per_page = intval($row['user_config_records_per_page']); +$user_config_dashboard_financial_enable = intval($row['user_config_dashboard_financial_enable']); +$user_config_dashboard_technical_enable = intval($row['user_config_dashboard_technical_enable']); $sql = mysqli_query($mysqli, "SELECT * FROM companies, settings WHERE settings.company_id = companies.company_id AND companies.company_id = 1"); $row = mysqli_fetch_array($sql); diff --git a/dashboard.php b/dashboard.php index 7f4bd17e..09c2fda4 100644 --- a/dashboard.php +++ b/dashboard.php @@ -7,12 +7,16 @@ if (isset($_GET['year'])) { $year = date('Y'); } -if (isset($_GET['show_financial']) == 1) { - $show_financial = 1; +if (isset($_GET['enable_financial']) == 1) { + mysqli_query($mysqli, "UPDATE user_settings SET user_config_dashboard_financial_enable = 1 WHERE user_id = $session_user_id"); +} else { + mysqli_query($mysqli, "UPDATE user_settings SET user_config_dashboard_financial_enable = 0 WHERE user_id = $session_user_id"); } -if (isset($_GET['show_technical']) == 1) { - $show_technical = 1; +if (isset($_GET['enable_technical']) == 1) { + mysqli_query($mysqli, "UPDATE user_settings SET user_config_dashboard_technical_enable = 1 WHERE user_id = $session_user_id"); +} else { + mysqli_query($mysqli, "UPDATE user_settings SET user_config_dashboard_technical_enable = 0 WHERE user_id = $session_user_id"); } //GET unique years from expenses, payments invoices and revenues @@ -50,14 +54,14 @@ $sql_years_select = mysqli_query(
- > + >
= 2 && $config_module_enable_ticketing == 1) { ?>
- > + >
@@ -66,7 +70,7 @@ $sql_years_select = mysqli_query( CURRENT_DATABASE_VERSION) { mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.9.7'"); } + if (CURRENT_DATABASE_VERSION == '0.9.7') { + // Insert queries here required to update to DB version 0.9.8 + mysqli_query($mysqli, "ALTER TABLE `user_settings` ADD `user_config_dashboard_financial_enable` TINYINT(1) NOT NULL DEFAULT 0 AFTER `user_config_records_per_page`"); + mysqli_query($mysqli, "ALTER TABLE `user_settings` ADD `user_config_dashboard_technical_enable` TINYINT(1) NOT NULL DEFAULT 0 AFTER `user_config_dashboard_financial_enable`"); + //set all invoice id + // Then, update the database to the next sequential version + mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.9.8'"); + } + // Be sure to change database_version.php to reflect the version you are updating to here // Please add this same comment block to the bottom of this file, and update the version number. // Uncomment Below Lines, to add additional database updates // - // if (CURRENT_DATABASE_VERSION == '0.9.7') { - // // Insert queries here required to update to DB version 0.9.8 + // if (CURRENT_DATABASE_VERSION == '0.9.8') { + // // Insert queries here required to update to DB version 0.9.9 // // Then, update the database to the next sequential version - // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.9.8'"); + // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.9.9'"); // } } else { diff --git a/database_version.php b/database_version.php index 36265c6e..55f0278b 100644 --- a/database_version.php +++ b/database_version.php @@ -5,5 +5,5 @@ * It is used in conjunction with database_updates.php */ -DEFINE("LATEST_DATABASE_VERSION", "0.9.7"); +DEFINE("LATEST_DATABASE_VERSION", "0.9.8"); diff --git a/db.sql b/db.sql index 337efb88..b7590423 100644 --- a/db.sql +++ b/db.sql @@ -1637,6 +1637,8 @@ CREATE TABLE `user_settings` ( `user_config_remember_me_token` varchar(255) DEFAULT NULL, `user_config_force_mfa` tinyint(1) NOT NULL DEFAULT 0, `user_config_records_per_page` int(11) NOT NULL DEFAULT 10, + `user_config_dashboard_financial_enable` tinyint(1) NOT NULL DEFAULT 0, + `user_config_dashboard_technical_enable` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -1749,4 +1751,4 @@ CREATE TABLE `vendors` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2023-12-01 11:52:50 +-- Dump completed on 2023-12-21 16:35:50