mirror of https://github.com/itflow-org/itflow
Added Tag Type to allow expansion of tagging support for other entities in the future
This commit is contained in:
parent
d23d455cd9
commit
484d4fff82
|
|
@ -256,7 +256,7 @@
|
|||
<ul class="list-group">
|
||||
|
||||
<?php
|
||||
$sql_tags_select = mysqli_query($mysqli,"SELECT * FROM tags WHERE company_id = $session_company_id ORDER BY tag_name ASC");
|
||||
$sql_tags_select = mysqli_query($mysqli,"SELECT * FROM tags WHERE tag_type = 1 AND company_id = $session_company_id ORDER BY tag_name ASC");
|
||||
|
||||
while($row = mysqli_fetch_array($sql_tags_select)){
|
||||
$tag_id_select = $row['tag_id'];
|
||||
|
|
|
|||
|
|
@ -16,6 +16,19 @@
|
|||
<input type="text" class="form-control" name="name" placeholder="Tag name" required autofocus>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Type <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-th"></i></span>
|
||||
</div>
|
||||
<select class="form-control select2" name="type" required>
|
||||
<option value="">- Type -</option>
|
||||
<option value="1">Client Tag</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label>Color</label>
|
||||
<div class="form-row">
|
||||
|
||||
|
|
|
|||
3
db.sql
3
db.sql
|
|
@ -903,6 +903,7 @@ DROP TABLE IF EXISTS `tags`;
|
|||
CREATE TABLE `tags` (
|
||||
`tag_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`tag_name` varchar(200) NOT NULL,
|
||||
`tag_type` int(11) NOT NULL,
|
||||
`tag_color` varchar(200) DEFAULT NULL,
|
||||
`tag_icon` varchar(200) DEFAULT NULL,
|
||||
`tag_created_at` datetime NOT NULL,
|
||||
|
|
@ -1152,4 +1153,4 @@ CREATE TABLE `vendors` (
|
|||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2021-12-27 11:38:55
|
||||
-- Dump completed on 2021-12-27 12:04:12
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@
|
|||
|
||||
<?php
|
||||
|
||||
$sql_tags_select = mysqli_query($mysqli,"SELECT * FROM tags WHERE company_id = $session_company_id ORDER BY tag_name ASC");
|
||||
$sql_tags_select = mysqli_query($mysqli,"SELECT * FROM tags WHERE tag_type = 1 AND company_id = $session_company_id ORDER BY tag_name ASC");
|
||||
|
||||
while($row = mysqli_fetch_array($sql_tags_select)){
|
||||
$tag_id_select = $row['tag_id'];
|
||||
|
|
|
|||
|
|
@ -15,6 +15,19 @@
|
|||
<label>Name <strong class="text-danger">*</strong></label>
|
||||
<input type="text" class="form-control" name="name" value="<?php echo $tag_name; ?>" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Type <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-th"></i></span>
|
||||
</div>
|
||||
<select class="form-control select2" name="type" required>
|
||||
<option value="">- Type -</option>
|
||||
<option value="1" <?php if($tag_type == 1){ echo "selected"; } ?>>Client Tag</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label>Color</label>
|
||||
<div class="mb-3">
|
||||
|
|
|
|||
9
post.php
9
post.php
|
|
@ -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");
|
||||
|
|
|
|||
3
tags.php
3
tags.php
|
|
@ -96,6 +96,7 @@ $colors_diff = array_diff($colors_array,$colors_used_array);
|
|||
<thead class="text-dark <?php if($num_rows[0] == 0){ echo "d-none"; } ?>">
|
||||
<tr>
|
||||
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=tag_name&o=<?php echo $disp; ?>">Name</a></th>
|
||||
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=tag_type&o=<?php echo $disp; ?>">Type</a></th>
|
||||
<th>Color</th>
|
||||
<th class="text-center">Action</th>
|
||||
</tr>
|
||||
|
|
@ -106,12 +107,14 @@ $colors_diff = array_diff($colors_array,$colors_used_array);
|
|||
while($row = mysqli_fetch_array($sql)){
|
||||
$tag_id = $row['tag_id'];
|
||||
$tag_name = $row['tag_name'];
|
||||
$tag_type = $row['tag_type'];
|
||||
$tag_color = $row['tag_color'];
|
||||
$tag_icon = $row['tag_icon'];
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo "<i class='fa fa-fw fa-$tag_icon'></i>"; ?> <a class="text-dark" href="#" data-toggle="modal" data-target="#editTagModal<?php echo $tag_id; ?>"><?php echo "$tag_name"; ?></a></td>
|
||||
<td><?php echo $tag_type; ?></td>
|
||||
<td><i class="fa fa-3x fa-circle" style="color:<?php echo $tag_color; ?>;"></i></td>
|
||||
<td>
|
||||
<div class="dropdown dropleft text-center">
|
||||
|
|
|
|||
Loading…
Reference in New Issue