diff --git a/add_tag_modal.php b/add_tag_modal.php
new file mode 100644
index 00000000..d903f616
--- /dev/null
+++ b/add_tag_modal.php
@@ -0,0 +1,48 @@
+
\ No newline at end of file
diff --git a/edit_tag_modal.php b/edit_tag_modal.php
new file mode 100644
index 00000000..7018e835
--- /dev/null
+++ b/edit_tag_modal.php
@@ -0,0 +1,54 @@
+
\ No newline at end of file
diff --git a/post.php b/post.php
index 64acf21d..9fd6c84f 100644
--- a/post.php
+++ b/post.php
@@ -1744,6 +1744,71 @@ if(isset($_GET['delete_category'])){
}
+
+//Tags
+
+if(isset($_POST['add_tag'])){
+
+ $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])));
+ $color = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['color'])));
+
+ mysqli_query($mysqli,"INSERT INTO tags SET tag_name = '$name', tag_color = '$color', tag_created_at = NOW(), company_id = $session_company_id");
+
+ //Logging
+ mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Tag', log_action = 'Created', log_description = '$name', log_created_at = NOW(), company_id = $session_company_id, log_user_id = $session_user_id");
+
+ $_SESSION['alert_message'] = "Tag added";
+
+ header("Location: " . $_SERVER["HTTP_REFERER"]);
+
+}
+
+if(isset($_POST['edit_tag'])){
+
+ $tag_id = intval($_POST['tag_id']);
+ $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])));
+ $color = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['color'])));
+
+ mysqli_query($mysqli,"UPDATE tags SET tag_name = '$name', tag_color = '$color', tag_updated_at = NOW() WHERE tag_id = $tag_id AND company_id = $session_company_id");
+
+ //Logging
+ mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Tag', log_action = 'Modified', log_description = '$name', log_created_at = NOW(), company_id = $session_company_id, log_user_id = $session_user_id");
+
+ $_SESSION['alert_message'] = "Tag modified";
+
+ header("Location: " . $_SERVER["HTTP_REFERER"]);
+
+}
+
+if(isset($_GET['archive_tag'])){
+ $tag_id = intval($_GET['archive_tag']);
+
+ mysqli_query($mysqli,"UPDATE tags SET tag_archived_at = NOW() WHERE tag_id = $tag_id");
+
+ //logging
+ mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Tag', log_action = 'Archive', log_description = '$tag_id', log_created_at = NOW()");
+
+ $_SESSION['alert_message'] = "Tag Archived";
+
+ header("Location: " . $_SERVER["HTTP_REFERER"]);
+
+}
+
+if(isset($_GET['delete_tag'])){
+ $tag_id = intval($_GET['delete_tag']);
+
+ mysqli_query($mysqli,"DELETE FROM tags WHERE tag_id = $tag_id AND company_id = $session_company_id");
+
+ //Logging
+ mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Tag', log_action = 'Deleted', log_description = '$tag_id', log_created_at = NOW(), company_id = $session_company_id, log_user_id = $session_user_id");
+
+ $_SESSION['alert_message'] = "Tag deleted";
+ $_SESSION['alert_type'] = "danger";
+
+ header("Location: " . $_SERVER["HTTP_REFERER"]);
+
+}
+
//Tax
if(isset($_POST['add_tax'])){
diff --git a/side_nav.php b/side_nav.php
index 21eeba63..e11f48c2 100644
--- a/side_nav.php
+++ b/side_nav.php
@@ -227,6 +227,12 @@
Categories
+
+ ">
+
+ Tags
+
+
">
diff --git a/tags.php b/tags.php
new file mode 100644
index 00000000..29355cd4
--- /dev/null
+++ b/tags.php
@@ -0,0 +1,152 @@
+ $sb, 'o' => $o)));
+
+$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM tags
+ WHERE tag_name LIKE '%$q%'
+ AND tag_archived_at IS NULL
+ AND company_id = $session_company_id
+ ORDER BY $sb $o LIMIT $record_from, $record_to"
+);
+
+$num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
+
+if($num_row > 0){
+//Colors Used
+$sql_colors_used = mysqli_query($mysqli,"SELECT tag_color FROM tags
+ WHERE tag_archived_at IS NULL
+ AND company_id = $session_company_id"
+);
+
+while($color_used_row = mysqli_fetch_array($sql_colors_used)){
+ $colors_used_array[] = $color_used_row['tag_color'];
+}
+$colors_diff = array_diff($colors_array,$colors_used_array);
+
+}else{
+ $colors_diff = $colors_array;
+}
+
+?>
+
+
+
+
+
+
+
+
+
+
+
+ ">
+
+ Name
+ Color
+ Action
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file