Expiring Domains
diff --git a/database_updates.php b/database_updates.php
index 257b7c6b..0ca193ab 100644
--- a/database_updates.php
+++ b/database_updates.php
@@ -2131,10 +2131,88 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) {
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.4.5'");
}
- // if (CURRENT_DATABASE_VERSION == '1.4.5') {
- // // Insert queries here required to update to DB version 1.4.6
+ if (CURRENT_DATABASE_VERSION == '1.4.5') {
+ mysqli_query($mysqli, "ALTER TABLE `settings` ADD `config_whitelabel_enabled` INT(11) NOT NULL DEFAULT '0' AFTER `config_phone_mask`");
+ mysqli_query($mysqli, "ALTER TABLE `settings` ADD `config_whitelabel_key` TEXT NULL DEFAULT NULL AFTER `config_whitelabel_enabled`");
+
+ mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.4.6'");
+ }
+
+ if (CURRENT_DATABASE_VERSION == '1.4.6') {
+ mysqli_query($mysqli, "CREATE TABLE `custom_links` (
+ `custom_link_id` INT(11) NOT NULL AUTO_INCREMENT,
+ `custom_link_name` VARCHAR(200) NOT NULL,
+ `custom_link_description` TEXT DEFAULT NULL,
+ `custom_link_uri` VARCHAR(500) NOT NULL,
+ `custom_link_icon` VARCHAR(200) DEFAULT NULL,
+ `custom_link_created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ `custom_link_updated_at` DATETIME ON UPDATE CURRENT_TIMESTAMP NULL,
+ `custom_link_archived_at` DATETIME NULL,
+ PRIMARY KEY (`custom_link_id`)
+ )");
+ mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.4.7'");
+ }
+
+ if (CURRENT_DATABASE_VERSION == '1.4.7') {
+ mysqli_query($mysqli, "ALTER TABLE `documents` ADD `document_client_visible` INT(11) NOT NULL DEFAULT '1' AFTER `document_parent`");
+
+ mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.4.8'");
+ }
+
+ if (CURRENT_DATABASE_VERSION == '1.4.8') {
+ mysqli_query($mysqli, "ALTER TABLE `settings` DROP `config_stripe_client_pays_fees`");
+
+ mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.4.9'");
+ }
+
+ if (CURRENT_DATABASE_VERSION == '1.4.9') {
+
+ // Add new "is admin" identifier on user roles
+ mysqli_query($mysqli, "ALTER TABLE `user_roles` ADD `user_role_is_admin` INT(11) NOT NULL DEFAULT '0' AFTER `user_role_description`");
+ mysqli_query($mysqli, "UPDATE `user_roles` SET `user_role_is_admin` = '1' WHERE `user_role_id` = 3");
+
+ // Add modules
+ mysqli_query($mysqli, "CREATE TABLE `modules` (
+ `module_id` INT(11) NOT NULL AUTO_INCREMENT,
+ `module_name` VARCHAR(200) NOT NULL,
+ `module_description` VARCHAR(200) NULL,
+ PRIMARY KEY (`module_id`)
+ )");
+
+ mysqli_query($mysqli, "INSERT INTO modules SET module_name = 'module_client', module_description = 'General client & contact management'");
+ mysqli_query($mysqli, "INSERT INTO modules SET module_name = 'module_support', module_description = 'Access to ticketing, assets and documentation'");
+ mysqli_query($mysqli, "INSERT INTO modules SET module_name = 'module_credential', module_description = 'Access to client credentials - usernames, passwords and 2FA codes'");
+ mysqli_query($mysqli, "INSERT INTO modules SET module_name = 'module_sales', module_description = 'Access to quotes, invoices and products'");
+ mysqli_query($mysqli, "INSERT INTO modules SET module_name = 'module_financial', module_description = 'Access to payments, accounts, expenses and budgets'");
+ mysqli_query($mysqli, "INSERT INTO modules SET module_name = 'module_reporting', module_description = 'Access to all reports'");
+
+ // Add table for storing role<->module permissions
+ mysqli_query($mysqli, "CREATE TABLE `user_role_permissions` (
+ `user_role_id` INT(11) NOT NULL,
+ `module_id` INT(11) NOT NULL,
+ `user_role_permission_level` INT(11) NOT NULL
+ )");
+
+ // Add default permissions for accountant role
+ mysqli_query($mysqli, "INSERT INTO user_role_permissions SET user_role_id = 1, module_id = 1, user_role_permission_level = 1"); // Read clients
+ mysqli_query($mysqli, "INSERT INTO user_role_permissions SET user_role_id = 1, module_id = 2, user_role_permission_level = 1"); // Read support
+ mysqli_query($mysqli, "INSERT INTO user_role_permissions SET user_role_id = 1, module_id = 4, user_role_permission_level = 1"); // Read sales
+ mysqli_query($mysqli, "INSERT INTO user_role_permissions SET user_role_id = 1, module_id = 5, user_role_permission_level = 2"); // Modify financial
+ mysqli_query($mysqli, "INSERT INTO user_role_permissions SET user_role_id = 1, module_id = 6, user_role_permission_level = 1"); // Read reports
+
+ // Add default permissions for tech role
+ mysqli_query($mysqli, "INSERT INTO user_role_permissions SET user_role_id = 2, module_id = 1, user_role_permission_level = 2"); // Modify clients
+ mysqli_query($mysqli, "INSERT INTO user_role_permissions SET user_role_id = 2, module_id = 2, user_role_permission_level = 2"); // Modify support
+ mysqli_query($mysqli, "INSERT INTO user_role_permissions SET user_role_id = 2, module_id = 3, user_role_permission_level = 2"); // Modify credentials
+ mysqli_query($mysqli, "INSERT INTO user_role_permissions SET user_role_id = 2, module_id = 4, user_role_permission_level = 2"); // Modify sales
+
+ mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.5.0'");
+ }
+
+ // if (CURRENT_DATABASE_VERSION == '1.5.0') {
+ // // Insert queries here required to update to DB version 1.5.1
// // Then, update the database to the next sequential version
- // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.4.6'");
+ // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.5.1'");
// }
} else {
diff --git a/database_version.php b/database_version.php
index 02ae2a6a..f81f9fe0 100644
--- a/database_version.php
+++ b/database_version.php
@@ -5,4 +5,4 @@
* It is used in conjunction with database_updates.php
*/
-DEFINE("LATEST_DATABASE_VERSION", "1.4.5");
+DEFINE("LATEST_DATABASE_VERSION", "1.5.0");
diff --git a/db.sql b/db.sql
index 2b4ba70f..9d9d4b14 100644
--- a/db.sql
+++ b/db.sql
@@ -66,7 +66,7 @@ CREATE TABLE `api_keys` (
`api_key_id` int(11) NOT NULL AUTO_INCREMENT,
`api_key_name` varchar(255) NOT NULL,
`api_key_secret` varchar(255) NOT NULL,
- `api_key_decrypt_hash` varchar(255) NULL,
+ `api_key_decrypt_hash` varchar(200) NOT NULL,
`api_key_created_at` datetime NOT NULL DEFAULT current_timestamp(),
`api_key_expire` date NOT NULL,
`api_key_client_id` int(11) NOT NULL DEFAULT 0,
@@ -462,6 +462,26 @@ CREATE TABLE `custom_fields` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `custom_links`
+--
+
+DROP TABLE IF EXISTS `custom_links`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `custom_links` (
+ `custom_link_id` int(11) NOT NULL AUTO_INCREMENT,
+ `custom_link_name` varchar(200) NOT NULL,
+ `custom_link_description` text DEFAULT NULL,
+ `custom_link_uri` varchar(500) NOT NULL,
+ `custom_link_icon` varchar(200) DEFAULT NULL,
+ `custom_link_created_at` datetime NOT NULL DEFAULT current_timestamp(),
+ `custom_link_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(),
+ `custom_link_archived_at` datetime DEFAULT NULL,
+ PRIMARY KEY (`custom_link_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `custom_values`
--
@@ -506,6 +526,7 @@ CREATE TABLE `documents` (
`document_content_raw` longtext NOT NULL,
`document_important` tinyint(1) NOT NULL DEFAULT 0,
`document_parent` int(11) NOT NULL DEFAULT 0,
+ `document_client_visible` int(11) NOT NULL DEFAULT 1,
`document_created_at` datetime NOT NULL DEFAULT current_timestamp(),
`document_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(),
`document_archived_at` datetime DEFAULT NULL,
@@ -868,6 +889,18 @@ CREATE TABLE `logs` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `modules`
+--
+
+DROP TABLE IF EXISTS `modules`;
+CREATE TABLE IF NOT EXISTS `modules` (
+ `module_id` int(11) NOT NULL AUTO_INCREMENT,
+ `module_name` varchar(200) NOT NULL,
+ `module_description` varchar(200) DEFAULT NULL,
+ PRIMARY KEY (`module_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
+
--
-- Table structure for table `networks`
--
@@ -1468,7 +1501,7 @@ CREATE TABLE `settings` (
`config_ticket_from_name` varchar(200) DEFAULT NULL,
`config_ticket_from_email` varchar(200) DEFAULT NULL,
`config_ticket_email_parse` tinyint(1) NOT NULL DEFAULT 0,
- `config_ticket_email_parse_unknown_senders` tinyint(1) NOT NULL DEFAULT 0,
+ `config_ticket_email_parse_unknown_senders` int(1) NOT NULL DEFAULT 0,
`config_ticket_client_general_notifications` tinyint(1) NOT NULL DEFAULT 1,
`config_ticket_autoclose_hours` int(5) NOT NULL DEFAULT 72,
`config_ticket_new_ticket_notification_email` varchar(200) DEFAULT NULL,
@@ -1492,7 +1525,6 @@ CREATE TABLE `settings` (
`config_ai_url` varchar(250) DEFAULT NULL,
`config_ai_api_key` varchar(250) DEFAULT NULL,
`config_stripe_flat_fee` decimal(15,2) NOT NULL DEFAULT 0.30,
- `config_stripe_client_pays_fees` tinyint(1) NOT NULL DEFAULT 0,
`config_azure_client_id` varchar(200) DEFAULT NULL,
`config_azure_client_secret` varchar(200) DEFAULT NULL,
`config_module_enable_itdoc` tinyint(1) NOT NULL DEFAULT 1,
@@ -1509,6 +1541,8 @@ CREATE TABLE `settings` (
`config_timezone` varchar(200) NOT NULL DEFAULT 'America/New_York',
`config_destructive_deletes_enable` tinyint(1) NOT NULL DEFAULT 0,
`config_phone_mask` tinyint(1) NOT NULL DEFAULT 1,
+ `config_whitelabel_enabled` int(11) NOT NULL DEFAULT 0,
+ `config_whitelabel_key` text DEFAULT NULL,
PRIMARY KEY (`company_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -1937,6 +1971,7 @@ CREATE TABLE `user_roles` (
`user_role_id` int(11) NOT NULL AUTO_INCREMENT,
`user_role_name` varchar(200) NOT NULL,
`user_role_description` varchar(200) DEFAULT NULL,
+ `user_role_is_admin` int(11) NOT NULL DEFAULT 0,
`user_role_created_at` datetime NOT NULL DEFAULT current_timestamp(),
`user_role_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(),
`user_role_archived_at` datetime DEFAULT NULL,
@@ -1944,6 +1979,17 @@ CREATE TABLE `user_roles` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `user_role_permissions`
+--
+
+DROP TABLE IF EXISTS `user_role_permissions`;
+CREATE TABLE IF NOT EXISTS `user_role_permissions` (
+ `user_role_id` int(11) NOT NULL,
+ `module_id` int(11) NOT NULL,
+ `user_role_permission_level` int(11) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
+
--
-- Table structure for table `user_settings`
--
@@ -2071,4 +2117,4 @@ CREATE TABLE `vendors` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2024-06-13 12:39:55
+-- Dump completed on 2024-09-05 16:21:24
diff --git a/document_edit_visibility_modal.php b/document_edit_visibility_modal.php
new file mode 100644
index 00000000..a06e0ccc
--- /dev/null
+++ b/document_edit_visibility_modal.php
@@ -0,0 +1,42 @@
+
diff --git a/expense_export_modal.php b/expense_export_modal.php
index ce84b56d..acc4befc 100644
--- a/expense_export_modal.php
+++ b/expense_export_modal.php
@@ -2,16 +2,86 @@
@@ -205,6 +212,8 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));