From 7d2cf8ce89676221884702800ee1906ad5b81c44 Mon Sep 17 00:00:00 2001 From: "johnny@pittpc.com" Date: Sat, 6 Feb 2021 01:52:38 -0500 Subject: [PATCH] Added Tax to products section Updated DB structure --- add_product_modal.php | 26 ++++++++++++++++++++++++++ db.sql | 3 ++- edit_product_modal.php | 26 ++++++++++++++++++++++++++ guest_view_invoice.php | 2 +- post.php | 6 ++++-- products.php | 1 + 6 files changed, 60 insertions(+), 4 deletions(-) diff --git a/add_product_modal.php b/add_product_modal.php index 66de867c..889d4d9b 100644 --- a/add_product_modal.php +++ b/add_product_modal.php @@ -47,6 +47,32 @@ + +
+ +
+
+ +
+ + +
+
diff --git a/db.sql b/db.sql index ab2bb9c7..6513d3f7 100644 --- a/db.sql +++ b/db.sql @@ -571,6 +571,7 @@ CREATE TABLE `products` ( `product_cost` decimal(15,2) NOT NULL, `product_created_at` datetime NOT NULL, `product_updated_at` datetime DEFAULT NULL, + `tax_id` int(11) DEFAULT NULL, `category_id` int(11) NOT NULL, `company_id` int(11) NOT NULL, PRIMARY KEY (`product_id`) @@ -929,4 +930,4 @@ CREATE TABLE `vendors` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-02-06 0:17:15 +-- Dump completed on 2021-02-06 1:52:10 diff --git a/edit_product_modal.php b/edit_product_modal.php index 206dab8f..9a69f856 100644 --- a/edit_product_modal.php +++ b/edit_product_modal.php @@ -47,6 +47,32 @@ + +
+ +
+
+ +
+ + +
+
diff --git a/guest_view_invoice.php b/guest_view_invoice.php index 2297b9c1..899144d2 100644 --- a/guest_view_invoice.php +++ b/guest_view_invoice.php @@ -122,7 +122,7 @@ if(isset($_GET['invoice_id'], $_GET['url_key'])){ - Pay Online (Coming Soon) + Pay Online (Coming Soon) diff --git a/post.php b/post.php index 96753485..60888b3e 100644 --- a/post.php +++ b/post.php @@ -952,8 +952,9 @@ if(isset($_POST['add_product'])){ $description = strip_tags(mysqli_real_escape_string($mysqli,$_POST['description'])); $cost = floatval($_POST['cost']); $category = intval($_POST['category']); + $tax = intval($_POST['tax']); - mysqli_query($mysqli,"INSERT INTO products SET product_name = '$name', product_description = '$description', product_cost = '$cost', product_created_at = NOW(), category_id = $category, company_id = $session_company_id"); + mysqli_query($mysqli,"INSERT INTO products SET product_name = '$name', product_description = '$description', product_cost = '$cost', product_created_at = NOW(), tax_id = $tax, category_id = $category, company_id = $session_company_id"); //Logging mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Product', log_action = 'Created', log_description = '$name', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id"); @@ -971,8 +972,9 @@ if(isset($_POST['edit_product'])){ $description = strip_tags(mysqli_real_escape_string($mysqli,$_POST['description'])); $cost = floatval($_POST['cost']); $category = intval($_POST['category']); + $tax = intval($_POST['tax']); - mysqli_query($mysqli,"UPDATE products SET product_name = '$name', product_description = '$description', product_cost = '$cost', product_updated_at = NOW(), category_id = $category WHERE product_id = $product_id AND company_id = $session_company_id"); + mysqli_query($mysqli,"UPDATE products SET product_name = '$name', product_description = '$description', product_cost = '$cost', product_updated_at = NOW(), tax_id = $tax, category_id = $category WHERE product_id = $product_id AND company_id = $session_company_id"); //Logging mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Product', log_action = 'Modified', log_description = '$name', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id"); diff --git a/products.php b/products.php index 9d2d1588..257aace2 100644 --- a/products.php +++ b/products.php @@ -92,6 +92,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); $product_cost = $row['product_cost']; $category_id = $row['category_id']; $category_name = $row['category_name']; + $tax_id = $row['tax_id']; ?>