diff --git a/blank.php b/blank.php index 6aeaa538..d390c4ea 100644 --- a/blank.php +++ b/blank.php @@ -15,7 +15,6 @@ - - + \ No newline at end of file diff --git a/client_vendors.php b/client_vendors.php index 5e8ef07f..cebdbbde 100644 --- a/client_vendors.php +++ b/client_vendors.php @@ -85,11 +85,6 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); $vendor_description_display = $vendor_description; } $vendor_account_number = $row['vendor_account_number']; - $vendor_country = $row['vendor_country']; - $vendor_address = $row['vendor_address']; - $vendor_city = $row['vendor_city']; - $vendor_state = $row['vendor_state']; - $vendor_zip = $row['vendor_zip']; $vendor_contact_name = $row['vendor_contact_name']; if(empty($vendor_contact_name)){ $vendor_contact_name_display = "-"; @@ -100,7 +95,11 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); $vendor_extension = $row['vendor_extension']; $vendor_email = $row['vendor_email']; $vendor_website = $row['vendor_website']; + $vendor_hours = $row['vendor_hours']; + $vendor_sla = $row['vendor_sla']; + $vendor_code = $row['vendor_code']; $vendor_notes = $row['vendor_notes']; + $vendor_template_id = $row['vendor_template_id']; ?> diff --git a/database_updates.php b/database_updates.php index 6c69dec6..e8431ed4 100644 --- a/database_updates.php +++ b/database_updates.php @@ -330,16 +330,52 @@ if(LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION){ // Then, update the database to the next sequential version mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.2.0'"); - } - - //if(CURRENT_DATABASE_VERSION == '0.2.0'){ - // Insert queries here required to update to DB version 0.2.1 - - // Then, update the database to the next sequential version - // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.2.1'"); - //} - } - else{ + + if(CURRENT_DATABASE_VERSION == '0.2.0'){ + //Insert queries here required to update to DB version 0.2.1 + + mysqli_query($mysqli, "ALTER TABLE `vendors` + ADD `vendor_hours` VARCHAR(200) NULL DEFAULT NULL AFTER `vendor_website`, + ADD `vendor_sla` VARCHAR(200) NULL DEFAULT NULL AFTER `vendor_hours`, + ADD `vendor_code` VARCHAR(200) NULL DEFAULT NULL AFTER `vendor_sla`, + ADD `vendor_template_id` INT(11) DEFAULT 0 AFTER `vendor_archived_at` + "); + + mysqli_query($mysqli, "ALTER TABLE `vendors` + DROP `vendor_country`, + DROP `vendor_address`, + DROP `vendor_city`, + DROP `vendor_state`, + DROP `vendor_zip`, + DROP `vendor_global` + "); + + //Create New Vendor Templates Table + mysqli_query($mysqli, "CREATE TABLE `vendor_templates` (`vendor_template_id` int(11) AUTO_INCREMENT PRIMARY KEY, + `vendor_template_name` varchar(200) NOT NULL, + `vendor_template_description` varchar(200) NULL DEFAULT NULL, + `vendor_template_phone` varchar(200) NULL DEFAULT NULL, + `vendor_template_email` varchar(200) NULL DEFAULT NULL, + `vendor_template_website` varchar(200) NULL DEFAULT NULL, + `vendor_template_hours` varchar(200) NULL DEFAULT NULL, + `vendor_template_created_at` datetime DEFAULT CURRENT_TIMESTAMP, + `vendor_template_updated_at` datetime NULL ON UPDATE CURRENT_TIMESTAMP, + `vendor_template_archived_at` datetime NULL DEFAULT NULL, + `company_id` int(11) NOT NULL + )"); + + //Then, update the database to the next sequential version + mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.2.1'"); + } + + //if(CURRENT_DATABASE_VERSION == '0.2.1'){ + // Insert queries here required to update to DB version 0.2.2 + + // Then, update the database to the next sequential version + // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.2.2'"); + //} + +}else{ // Up-to-date - } \ No newline at end of file +} \ No newline at end of file diff --git a/db.sql b/db.sql index 2f7417b5..925237d3 100644 --- a/db.sql +++ b/db.sql @@ -1431,6 +1431,29 @@ CREATE TABLE `vendor_logins` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!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; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `vendors` -- @@ -1442,22 +1465,20 @@ CREATE TABLE `vendors` ( `vendor_id` int(11) NOT NULL AUTO_INCREMENT, `vendor_name` varchar(200) NOT NULL, `vendor_description` varchar(200) DEFAULT NULL, - `vendor_country` varchar(200) DEFAULT NULL, - `vendor_address` varchar(200) DEFAULT NULL, - `vendor_city` varchar(200) DEFAULT NULL, - `vendor_state` varchar(200) DEFAULT NULL, - `vendor_zip` varchar(200) DEFAULT NULL, `vendor_contact_name` varchar(200) DEFAULT NULL, `vendor_phone` varchar(200) DEFAULT NULL, `vendor_extension` varchar(200) DEFAULT NULL, `vendor_email` varchar(200) DEFAULT NULL, `vendor_website` varchar(200) DEFAULT NULL, + `vendor_hours` varchar(200) DEFAULT NULL, + `vendor_sla` varchar(200) DEFAULT NULL, + `vendor_code` varchar(200) DEFAULT NULL, `vendor_account_number` varchar(200) DEFAULT NULL, `vendor_notes` text DEFAULT NULL, - `vendor_global` tinyint(1) DEFAULT NULL, `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`) @@ -1473,4 +1494,4 @@ CREATE TABLE `vendors` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-09-17 18:03:12 +-- Dump completed on 2022-10-14 21:46:21 diff --git a/post.php b/post.php index 9dcdb5b3..e69b16ca 100644 --- a/post.php +++ b/post.php @@ -762,6 +762,7 @@ if(isset($_GET['delete_company'])){ mysqli_query($mysqli,"DELETE FROM trips WHERE company_id = $company_id"); mysqli_query($mysqli,"DELETE FROM user_companies WHERE company_id = $company_id"); mysqli_query($mysqli,"DELETE FROM vendors WHERE company_id = $company_id"); + mysqli_query($mysqli,"DELETE FROM vendor_templates WHERE company_id = $company_id"); // Delete Company Files removeDirectory('uploads/clients/$company_id'); @@ -1733,19 +1734,18 @@ if(isset($_POST['add_vendor'])){ $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); $description = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['description']))); $account_number = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['account_number']))); - $country = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['country']))); - $address = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['address']))); - $city = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['city']))); - $state = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['state']))); - $zip = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['zip']))); $contact_name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['contact_name']))); $phone = preg_replace("/[^0-9]/", '',$_POST['phone']); - $extension = preg_replace("/[^0-9]/", '',$_POST['extension']); + $extension = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['extension']))); $email = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['email']))); $website = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['website']))); + $hours = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['hours']))); + $sla = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['sla']))); + $code = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['code']))); $notes = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes']))); + $template_id = intval($_POST['template_id']); - mysqli_query($mysqli,"INSERT INTO vendors SET vendor_name = '$name', vendor_description = '$description', vendor_country = '$country', vendor_address = '$address', vendor_city = '$city', vendor_state = '$state', vendor_zip = '$zip', vendor_contact_name = '$contact_name', vendor_phone = '$phone', vendor_extension = '$extension', vendor_email = '$email', vendor_website = '$website', vendor_account_number = '$account_number', vendor_notes = '$notes', vendor_client_id = $client_id, company_id = $session_company_id"); + mysqli_query($mysqli,"INSERT INTO vendors SET vendor_name = '$name', vendor_description = '$description', vendor_contact_name = '$contact_name', vendor_phone = '$phone', vendor_extension = '$extension', vendor_email = '$email', vendor_website = '$website', vendor_hours = '$hours', vendor_sla = '$sla', vendor_code = '$code', vendor_account_number = '$account_number', vendor_notes = '$notes', vendor_template_id = $template_id, vendor_client_id = $client_id, company_id = $session_company_id"); $vendor_id = mysqli_insert_id($mysqli); @@ -1763,19 +1763,18 @@ if(isset($_POST['edit_vendor'])){ $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); $description = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['description']))); $account_number = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['account_number']))); - $country = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['country']))); - $address = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['address']))); - $city = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['city']))); - $state = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['state']))); - $zip = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['zip']))); $contact_name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['contact_name']))); $phone = preg_replace("/[^0-9]/", '',$_POST['phone']); - $extension = preg_replace("/[^0-9]/", '',$_POST['extension']); + $extension = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['extension']))); $email = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['email']))); $website = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['website']))); + $hours = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['hours']))); + $sla = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['sla']))); + $code = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['code']))); $notes = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes']))); + $template_id = intval($_POST['template_id']); - mysqli_query($mysqli,"UPDATE vendors SET vendor_name = '$name', vendor_description = '$description', vendor_country = '$country', vendor_address = '$address', vendor_city = '$city', vendor_state = '$state', vendor_zip = '$zip', vendor_contact_name = '$contact_name', vendor_phone = '$phone', vendor_extension = '$extension', vendor_email = '$email', vendor_website = '$website', vendor_account_number = '$account_number', vendor_notes = '$notes' WHERE vendor_id = $vendor_id AND company_id = $session_company_id"); + mysqli_query($mysqli,"UPDATE vendors SET vendor_name = '$name', vendor_description = '$description', vendor_contact_name = '$contact_name', vendor_phone = '$phone', vendor_extension = '$extension', vendor_email = '$email', vendor_website = '$website', vendor_hours = '$hours', vendor_sla = '$sla', vendor_code = '$code',vendor_account_number = '$account_number', vendor_notes = '$notes', vendor_template_id = $template_id WHERE vendor_id = $vendor_id AND company_id = $session_company_id"); //Logging mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Vendor', log_action = 'Modify', log_description = '$session_name modified vendor $name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id, company_id = $session_company_id"); diff --git a/vendor_add_modal.php b/vendor_add_modal.php index ec9fd446..e219bf82 100644 --- a/vendor_add_modal.php +++ b/vendor_add_modal.php @@ -10,6 +10,7 @@
+ - - -
-
- +
- +
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- +
-
+
-
- -
-
- -
- -
-
- - +
@@ -150,27 +89,57 @@
- + +
+
+ +
+ +
+
+ +
+
- +
- +
- +
- + +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+
diff --git a/vendor_edit_modal.php b/vendor_edit_modal.php index 305ed1ba..f12143a4 100644 --- a/vendor_edit_modal.php +++ b/vendor_edit_modal.php @@ -9,6 +9,7 @@
+ -
- -
-
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
- -
- +
@@ -135,7 +70,11 @@
- +
+ +
+ +
@@ -148,27 +87,57 @@
- + +
+
+ +
+ +
+
+ +
+
- +
- +
- +
- + +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+
diff --git a/vendors.php b/vendors.php index f9f47214..a0aec2be 100644 --- a/vendors.php +++ b/vendors.php @@ -105,11 +105,6 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); $vendor_description_display = $vendor_description; } $vendor_account_number = $row['vendor_account_number']; - $vendor_country = $row['vendor_country']; - $vendor_address = $row['vendor_address']; - $vendor_city = $row['vendor_city']; - $vendor_state = $row['vendor_state']; - $vendor_zip = $row['vendor_zip']; $vendor_contact_name = $row['vendor_contact_name']; if(empty($vendor_contact_name)){ $vendor_contact_name_display = "-"; @@ -120,7 +115,11 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); $vendor_extension = $row['vendor_extension']; $vendor_email = $row['vendor_email']; $vendor_website = $row['vendor_website']; - $vendor_notes = $row['vendor_notes'] + $vendor_hours = $row['vendor_hours']; + $vendor_sla = $row['vendor_sla']; + $vendor_code = $row['vendor_code']; + $vendor_notes = $row['vendor_notes']; + $vendor_template_id = $row['vendor_template_id']; ?>