diff --git a/database_updates.php b/database_updates.php index a1f81630..0942e516 100644 --- a/database_updates.php +++ b/database_updates.php @@ -436,15 +436,24 @@ if(LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION){ mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.2.7'"); } - //if(CURRENT_DATABASE_VERSION == '0.2.7'){ - // Insert queries here required to update to DB version 0.2.8 + if(CURRENT_DATABASE_VERSION == '0.2.7'){ + + mysqli_query($mysqli, "ALTER TABLE `vendors` ADD `vendor_template` TINYINT(1) DEFAULT 0 AFTER `vendor_notes`"); + mysqli_query($mysqli, "ALTER TABLE `software` ADD `software_template` TINYINT(1) DEFAULT 0 AFTER `software_notes`"); + mysqli_query($mysqli, "ALTER TABLE `vendors` DROP `vendor_template_id`"); + mysqli_query($mysqli, "DROP TABLE vendor_templates"); + + mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.2.8'"); + } + + //if(CURRENT_DATABASE_VERSION == '0.2.8'){ + // Insert queries here required to update to DB version 0.2.9 // Then, update the database to the next sequential version - // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.2.8'"); + // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.2.9'"); //} - }else{ // Up-to-date } \ No newline at end of file diff --git a/database_version.php b/database_version.php index 8eb6e5bc..025e0bef 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", "0.2.7"); \ No newline at end of file +DEFINE("LATEST_DATABASE_VERSION", "0.2.8"); \ No newline at end of file diff --git a/db.sql b/db.sql index 9068590f..049f23b6 100644 --- a/db.sql +++ b/db.sql @@ -1125,6 +1125,7 @@ CREATE TABLE `software` ( `software_purchase` date DEFAULT NULL, `software_expire` date DEFAULT NULL, `software_notes` text DEFAULT NULL, + `software_template` tinyint(1) DEFAULT 0, `software_created_at` datetime NOT NULL DEFAULT current_timestamp(), `software_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), `software_archived_at` datetime DEFAULT NULL, @@ -1475,29 +1476,6 @@ CREATE TABLE `vendor_logins` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `vendor_templates` --- - -DROP TABLE IF EXISTS `vendor_templates`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `vendor_templates` ( - `vendor_template_id` int(11) NOT NULL AUTO_INCREMENT, - `vendor_template_name` varchar(200) NOT NULL, - `vendor_template_description` varchar(200) DEFAULT NULL, - `vendor_template_phone` varchar(200) DEFAULT NULL, - `vendor_template_email` varchar(200) DEFAULT NULL, - `vendor_template_website` varchar(200) DEFAULT NULL, - `vendor_template_hours` varchar(200) DEFAULT NULL, - `vendor_template_created_at` datetime DEFAULT current_timestamp(), - `vendor_template_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), - `vendor_template_archived_at` datetime DEFAULT NULL, - `company_id` int(11) NOT NULL, - PRIMARY KEY (`vendor_template_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `vendors` -- @@ -1519,10 +1497,10 @@ CREATE TABLE `vendors` ( `vendor_code` varchar(200) DEFAULT NULL, `vendor_account_number` varchar(200) DEFAULT NULL, `vendor_notes` text DEFAULT NULL, + `vendor_template` tinyint(1) DEFAULT 0, `vendor_created_at` datetime NOT NULL DEFAULT current_timestamp(), `vendor_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), `vendor_archived_at` datetime DEFAULT NULL, - `vendor_template_id` int(11) DEFAULT 0, `vendor_client_id` int(11) DEFAULT NULL, `company_id` int(11) NOT NULL, PRIMARY KEY (`vendor_id`) @@ -1538,4 +1516,4 @@ CREATE TABLE `vendors` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2023-01-13 21:42:57 +-- Dump completed on 2023-01-18 20:12:49 diff --git a/post.php b/post.php index 89e43245..0b499f25 100644 --- a/post.php +++ b/post.php @@ -6762,8 +6762,18 @@ if(isset($_POST['add_document'])){ $content = trim(mysqli_real_escape_string($mysqli,$purifier->purify(html_entity_decode($_POST['content'])))); $content_raw = trim(mysqli_real_escape_string($mysqli, strip_tags($_POST['name'] . " " . str_replace("<", " <", $_POST['content'])))); // Content Raw is used for FULL INDEX searching. Adding a space before HTML tags to allow spaces between newlines, bulletpoints, etc. for searching. + $template = intval($_POST['template']); - $folder = intval($_POST['folder']); + //Templates don't go into folders + if($template == 0){ + $folder = intval($_POST['folder']); + }else{ + $folder = 0; + } + //Templates don't have assigned client_ids + if($template == 1){ + $client_id = 0; + } // Document add query $add_document = mysqli_query($mysqli,"INSERT INTO documents SET document_name = '$name', document_content = '$content', document_content_raw = '$content_raw', document_template = $template, document_folder_id = $folder, document_client_id = $client_id, company_id = $session_company_id");