Added Tag Type to allow expansion of tagging support for other entities in the future

This commit is contained in:
johnnyq
2021-12-27 12:06:37 -05:00
parent d23d455cd9
commit 484d4fff82
7 changed files with 40 additions and 5 deletions

View File

@@ -893,6 +893,9 @@ if(isset($_GET['update_db'])){
mysqli_query($mysqli,"ALTER TABLE clients DROP client_support");
mysqli_query($mysqli,"ALTER TABLE tags DROP tag_archived_at");
//Update 2
mysqli_query($mysqli,"ALTER TABLE tags ADD tag_type INT(11) AFTER tag_name");
$_SESSION['alert_message'] = "Update Successful Database Structure Update Successful!";
header("Location: " . $_SERVER["HTTP_REFERER"]);
@@ -1800,10 +1803,11 @@ if(isset($_GET['delete_category'])){
if(isset($_POST['add_tag'])){
$name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])));
$type = intval($_POST['type']);
$color = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['color'])));
$icon = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['icon'])));
mysqli_query($mysqli,"INSERT INTO tags SET tag_name = '$name', tag_color = '$color', tag_icon = '$icon', tag_created_at = NOW(), company_id = $session_company_id");
mysqli_query($mysqli,"INSERT INTO tags SET tag_name = '$name', tag_type = $type, tag_color = '$color', tag_icon = '$icon', 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");
@@ -1818,10 +1822,11 @@ if(isset($_POST['edit_tag'])){
$tag_id = intval($_POST['tag_id']);
$name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])));
$type = intval($_POST['type']);
$color = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['color'])));
$icon = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['icon'])));
mysqli_query($mysqli,"UPDATE tags SET tag_name = '$name', tag_color = '$color', tag_icon = '$icon', tag_updated_at = NOW() WHERE tag_id = $tag_id AND company_id = $session_company_id");
mysqli_query($mysqli,"UPDATE tags SET tag_name = '$name', tag_type = $type, tag_color = '$color', tag_icon = '$icon', 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");