Add Asset Tags Display in Contact Details, asset details, along with their detail modals
This commit is contained in:
@@ -118,6 +118,28 @@ if (isset($_GET['asset_id'])) {
|
|||||||
);
|
);
|
||||||
$document_count = mysqli_num_rows($sql_related_documents);
|
$document_count = mysqli_num_rows($sql_related_documents);
|
||||||
|
|
||||||
|
// Tags - many to many relationship
|
||||||
|
$asset_tag_name_display_array = array();
|
||||||
|
$asset_tag_id_array = array();
|
||||||
|
$sql_asset_tags = mysqli_query($mysqli, "SELECT * FROM asset_tags LEFT JOIN tags ON asset_tag_tag_id = tag_id WHERE asset_tag_asset_id = $asset_id ORDER BY tag_name ASC");
|
||||||
|
while ($row = mysqli_fetch_array($sql_asset_tags)) {
|
||||||
|
|
||||||
|
$asset_tag_id = intval($row['tag_id']);
|
||||||
|
$asset_tag_name = nullable_htmlentities($row['tag_name']);
|
||||||
|
$asset_tag_color = nullable_htmlentities($row['tag_color']);
|
||||||
|
if (empty($asset_tag_color)) {
|
||||||
|
$asset_tag_color = "dark";
|
||||||
|
}
|
||||||
|
$asset_tag_icon = nullable_htmlentities($row['tag_icon']);
|
||||||
|
if (empty($asset_tag_icon)) {
|
||||||
|
$asset_tag_icon = "tag";
|
||||||
|
}
|
||||||
|
|
||||||
|
$asset_tag_id_array[] = $asset_tag_id;
|
||||||
|
$asset_tag_name_display_array[] = "<a href='client_assets.php?client_id=$client_id&q=$asset_tag_name'><span class='badge text-light p-1 mr-1' style='background-color: $asset_tag_color;'><i class='fa fa-fw fa-$asset_tag_icon mr-2'></i>$asset_tag_name</span></a>";
|
||||||
|
}
|
||||||
|
$asset_tags_display = implode('', $asset_tag_name_display_array);
|
||||||
|
|
||||||
// Network Interfaces
|
// Network Interfaces
|
||||||
$sql_related_interfaces = mysqli_query($mysqli, "
|
$sql_related_interfaces = mysqli_query($mysqli, "
|
||||||
SELECT
|
SELECT
|
||||||
@@ -257,8 +279,13 @@ if (isset($_GET['asset_id'])) {
|
|||||||
<?php } ?>
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
<?php if ($asset_tags_display) { ?>
|
||||||
|
<div>
|
||||||
|
<?= $asset_tags_display ?>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
<?php if ($asset_type) { ?>
|
<?php if ($asset_type) { ?>
|
||||||
<div><i class="fa fa-fw fa-tag text-secondary mr-3"></i><?= $asset_type; ?></div>
|
<div class="mt-1"><i class="fa fa-fw fa-tag text-secondary mr-3"></i><?= $asset_type; ?></div>
|
||||||
<?php }
|
<?php }
|
||||||
if ($asset_make) { ?>
|
if ($asset_make) { ?>
|
||||||
<div class="mt-2"><i class="fa fa-fw fa-circle text-secondary mr-3"></i><?= "$asset_make $asset_model"; ?></div>
|
<div class="mt-2"><i class="fa fa-fw fa-circle text-secondary mr-3"></i><?= "$asset_make $asset_model"; ?></div>
|
||||||
|
|||||||
@@ -358,6 +358,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||||||
data-bulk="true">
|
data-bulk="true">
|
||||||
<i class="fas fa-fw fa-map-marker-alt mr-2"></i>Assign Location
|
<i class="fas fa-fw fa-map-marker-alt mr-2"></i>Assign Location
|
||||||
</a>
|
</a>
|
||||||
|
<div class="dropdown-divider"></div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<a class="dropdown-item ajax-modal" href="#"
|
<a class="dropdown-item ajax-modal" href="#"
|
||||||
data-modal-url="modals/asset/asset_bulk_assign_tags.php"
|
data-modal-url="modals/asset/asset_bulk_assign_tags.php"
|
||||||
|
|||||||
@@ -64,7 +64,14 @@ if (isset($_GET['contact_id'])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Related Assets Query - 1 to 1 relationship
|
// Related Assets Query - 1 to 1 relationship
|
||||||
$sql_related_assets = mysqli_query($mysqli, "SELECT * FROM assets LEFT JOIN asset_interfaces ON interface_asset_id = asset_id AND interface_primary = 1 WHERE asset_contact_id = $contact_id ORDER BY asset_name DESC");
|
$sql_related_assets = mysqli_query($mysqli, "SELECT * FROM assets
|
||||||
|
LEFT JOIN asset_interfaces ON interface_asset_id = asset_id AND interface_primary = 1
|
||||||
|
LEFT JOIN asset_tags ON asset_tag_asset_id = asset_id
|
||||||
|
LEFT JOIN tags ON tag_id = asset_tag_tag_id
|
||||||
|
WHERE asset_contact_id = $contact_id
|
||||||
|
GROUP BY asset_id
|
||||||
|
ORDER BY asset_name ASC"
|
||||||
|
);
|
||||||
$asset_count = mysqli_num_rows($sql_related_assets);
|
$asset_count = mysqli_num_rows($sql_related_assets);
|
||||||
|
|
||||||
// Linked Software Licenses
|
// Linked Software Licenses
|
||||||
@@ -90,7 +97,7 @@ if (isset($_GET['contact_id'])) {
|
|||||||
LEFT JOIN tags ON tags.tag_id = credential_tags.tag_id
|
LEFT JOIN tags ON tags.tag_id = credential_tags.tag_id
|
||||||
WHERE credential_contact_id = $contact_id
|
WHERE credential_contact_id = $contact_id
|
||||||
GROUP BY credentials.credential_id
|
GROUP BY credentials.credential_id
|
||||||
ORDER BY credential_name DESC
|
ORDER BY credential_name ASC
|
||||||
");
|
");
|
||||||
$credential_count = mysqli_num_rows($sql_related_credentials);
|
$credential_count = mysqli_num_rows($sql_related_credentials);
|
||||||
|
|
||||||
@@ -401,6 +408,28 @@ if (isset($_GET['contact_id'])) {
|
|||||||
$asset_created_at = nullable_htmlentities($row['asset_created_at']);
|
$asset_created_at = nullable_htmlentities($row['asset_created_at']);
|
||||||
$device_icon = getAssetIcon($asset_type);
|
$device_icon = getAssetIcon($asset_type);
|
||||||
|
|
||||||
|
// Tags
|
||||||
|
$asset_tag_name_display_array = array();
|
||||||
|
$asset_tag_id_array = array();
|
||||||
|
$sql_asset_tags = mysqli_query($mysqli, "SELECT * FROM asset_tags LEFT JOIN tags ON asset_tag_tag_id = tag_id WHERE asset_tag_asset_id = $asset_id ORDER BY tag_name ASC");
|
||||||
|
while ($row = mysqli_fetch_array($sql_asset_tags)) {
|
||||||
|
|
||||||
|
$asset_tag_id = intval($row['tag_id']);
|
||||||
|
$asset_tag_name = nullable_htmlentities($row['tag_name']);
|
||||||
|
$asset_tag_color = nullable_htmlentities($row['tag_color']);
|
||||||
|
if (empty($asset_tag_color)) {
|
||||||
|
$asset_tag_color = "dark";
|
||||||
|
}
|
||||||
|
$asset_tag_icon = nullable_htmlentities($row['tag_icon']);
|
||||||
|
if (empty($asset_tag_icon)) {
|
||||||
|
$asset_tag_icon = "tag";
|
||||||
|
}
|
||||||
|
|
||||||
|
$asset_tag_id_array[] = $asset_tag_id;
|
||||||
|
$asset_tag_name_display_array[] = "<a href='assets.php?$client_url tags[]=$asset_tag_id'><span class='badge text-light p-1 mr-1' style='background-color: $asset_tag_color;'><i class='fa fa-fw fa-$asset_tag_icon mr-2'></i>$asset_tag_name</span></a>";
|
||||||
|
}
|
||||||
|
$asset_tags_display = implode('', $asset_tag_name_display_array);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th>
|
||||||
@@ -413,6 +442,12 @@ if (isset($_GET['contact_id'])) {
|
|||||||
<div class="mt-0">
|
<div class="mt-0">
|
||||||
<small class="text-muted"><?php echo $asset_description; ?></small>
|
<small class="text-muted"><?php echo $asset_description; ?></small>
|
||||||
</div>
|
</div>
|
||||||
|
<?php
|
||||||
|
if ($asset_tags_display) { ?>
|
||||||
|
<div class="mt-1">
|
||||||
|
<?= $asset_tags_display ?>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
</th>
|
</th>
|
||||||
<td><?php echo $asset_type; ?></td>
|
<td><?php echo $asset_type; ?></td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@@ -70,6 +70,28 @@ if ($location_archived_at) {
|
|||||||
$location_name_display = $location_name;
|
$location_name_display = $location_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tags - many to many relationship
|
||||||
|
$asset_tag_name_display_array = array();
|
||||||
|
$asset_tag_id_array = array();
|
||||||
|
$sql_asset_tags = mysqli_query($mysqli, "SELECT * FROM asset_tags LEFT JOIN tags ON asset_tag_tag_id = tag_id WHERE asset_tag_asset_id = $asset_id ORDER BY tag_name ASC");
|
||||||
|
while ($row = mysqli_fetch_array($sql_asset_tags)) {
|
||||||
|
|
||||||
|
$asset_tag_id = intval($row['tag_id']);
|
||||||
|
$asset_tag_name = nullable_htmlentities($row['tag_name']);
|
||||||
|
$asset_tag_color = nullable_htmlentities($row['tag_color']);
|
||||||
|
if (empty($asset_tag_color)) {
|
||||||
|
$asset_tag_color = "dark";
|
||||||
|
}
|
||||||
|
$asset_tag_icon = nullable_htmlentities($row['tag_icon']);
|
||||||
|
if (empty($asset_tag_icon)) {
|
||||||
|
$asset_tag_icon = "tag";
|
||||||
|
}
|
||||||
|
|
||||||
|
$asset_tag_id_array[] = $asset_tag_id;
|
||||||
|
$asset_tag_name_display_array[] = "<a href='client_assets.php?client_id=$client_id&q=$asset_tag_name'><span class='badge text-light p-1 mr-1' style='background-color: $asset_tag_color;'><i class='fa fa-fw fa-$asset_tag_icon mr-2'></i>$asset_tag_name</span></a>";
|
||||||
|
}
|
||||||
|
$asset_tags_display = implode('', $asset_tag_name_display_array);
|
||||||
|
|
||||||
// Network Interfaces
|
// Network Interfaces
|
||||||
$sql_related_interfaces = mysqli_query($mysqli, "
|
$sql_related_interfaces = mysqli_query($mysqli, "
|
||||||
SELECT
|
SELECT
|
||||||
@@ -262,8 +284,13 @@ ob_start();
|
|||||||
<?php } ?>
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
<?php if ($asset_tags_display) { ?>
|
||||||
|
<div>
|
||||||
|
<?= $asset_tags_display ?>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
<?php if ($asset_type) { ?>
|
<?php if ($asset_type) { ?>
|
||||||
<div><i class="fa fa-fw fa-tag text-secondary mr-2"></i><?php echo $asset_type; ?></div>
|
<div class="mt-1"><i class="fa fa-fw fa-tag text-secondary mr-2"></i><?php echo $asset_type; ?></div>
|
||||||
<?php }
|
<?php }
|
||||||
if ($asset_make) { ?>
|
if ($asset_make) { ?>
|
||||||
<div class="mt-2"><i class="fa fa-fw fa-circle text-secondary mr-2"></i><?php echo "$asset_make $asset_model"; ?></div>
|
<div class="mt-2"><i class="fa fa-fw fa-circle text-secondary mr-2"></i><?php echo "$asset_make $asset_model"; ?></div>
|
||||||
|
|||||||
@@ -51,7 +51,14 @@ $auth_method = nullable_htmlentities($row['user_auth_method']);
|
|||||||
$contact_client_id = intval($row['contact_client_id']);
|
$contact_client_id = intval($row['contact_client_id']);
|
||||||
|
|
||||||
// Related Assets Query - 1 to 1 relationship
|
// Related Assets Query - 1 to 1 relationship
|
||||||
$sql_related_assets = mysqli_query($mysqli, "SELECT * FROM assets LEFT JOIN asset_interfaces ON interface_asset_id = asset_id AND interface_primary = 1 WHERE asset_contact_id = $contact_id ORDER BY asset_name DESC");
|
$sql_related_assets = mysqli_query($mysqli, "SELECT * FROM assets
|
||||||
|
LEFT JOIN asset_interfaces ON interface_asset_id = asset_id AND interface_primary = 1
|
||||||
|
LEFT JOIN asset_tags ON asset_tag_asset_id = asset_id
|
||||||
|
LEFT JOIN tags ON tag_id = asset_tag_tag_id
|
||||||
|
WHERE asset_contact_id = $contact_id
|
||||||
|
GROUP BY asset_id
|
||||||
|
ORDER BY asset_name ASC"
|
||||||
|
);
|
||||||
$asset_count = mysqli_num_rows($sql_related_assets);
|
$asset_count = mysqli_num_rows($sql_related_assets);
|
||||||
|
|
||||||
// Linked Software Licenses
|
// Linked Software Licenses
|
||||||
@@ -77,7 +84,7 @@ $sql_related_credentials = mysqli_query($mysqli, "
|
|||||||
LEFT JOIN tags ON tags.tag_id = credential_tags.tag_id
|
LEFT JOIN tags ON tags.tag_id = credential_tags.tag_id
|
||||||
WHERE credential_contact_id = $contact_id
|
WHERE credential_contact_id = $contact_id
|
||||||
GROUP BY credentials.credential_id
|
GROUP BY credentials.credential_id
|
||||||
ORDER BY credential_name DESC
|
ORDER BY credential_name ASC
|
||||||
");
|
");
|
||||||
$credential_count = mysqli_num_rows($sql_related_credentials);
|
$credential_count = mysqli_num_rows($sql_related_credentials);
|
||||||
|
|
||||||
@@ -376,6 +383,27 @@ ob_start();
|
|||||||
$asset_notes = nullable_htmlentities($row['asset_notes']);
|
$asset_notes = nullable_htmlentities($row['asset_notes']);
|
||||||
$asset_created_at = nullable_htmlentities($row['asset_created_at']);
|
$asset_created_at = nullable_htmlentities($row['asset_created_at']);
|
||||||
$device_icon = getAssetIcon($asset_type);
|
$device_icon = getAssetIcon($asset_type);
|
||||||
|
// Tags
|
||||||
|
$asset_tag_name_display_array = array();
|
||||||
|
$asset_tag_id_array = array();
|
||||||
|
$sql_asset_tags = mysqli_query($mysqli, "SELECT * FROM asset_tags LEFT JOIN tags ON asset_tag_tag_id = tag_id WHERE asset_tag_asset_id = $asset_id ORDER BY tag_name ASC");
|
||||||
|
while ($row = mysqli_fetch_array($sql_asset_tags)) {
|
||||||
|
|
||||||
|
$asset_tag_id = intval($row['tag_id']);
|
||||||
|
$asset_tag_name = nullable_htmlentities($row['tag_name']);
|
||||||
|
$asset_tag_color = nullable_htmlentities($row['tag_color']);
|
||||||
|
if (empty($asset_tag_color)) {
|
||||||
|
$asset_tag_color = "dark";
|
||||||
|
}
|
||||||
|
$asset_tag_icon = nullable_htmlentities($row['tag_icon']);
|
||||||
|
if (empty($asset_tag_icon)) {
|
||||||
|
$asset_tag_icon = "tag";
|
||||||
|
}
|
||||||
|
|
||||||
|
$asset_tag_id_array[] = $asset_tag_id;
|
||||||
|
$asset_tag_name_display_array[] = "<a href='assets.php?$client_url tags[]=$asset_tag_id'><span class='badge text-light p-1 mr-1' style='background-color: $asset_tag_color;'><i class='fa fa-fw fa-$asset_tag_icon mr-2'></i>$asset_tag_name</span></a>";
|
||||||
|
}
|
||||||
|
$asset_tags_display = implode('', $asset_tag_name_display_array);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -389,6 +417,12 @@ ob_start();
|
|||||||
<div class="mt-0">
|
<div class="mt-0">
|
||||||
<small class="text-muted"><?= $asset_description ?></small>
|
<small class="text-muted"><?= $asset_description ?></small>
|
||||||
</div>
|
</div>
|
||||||
|
<?php
|
||||||
|
if ($asset_tags_display) { ?>
|
||||||
|
<div class="mt-1">
|
||||||
|
<?= $asset_tags_display ?>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
</th>
|
</th>
|
||||||
<td><?= $asset_type ?></td>
|
<td><?= $asset_type ?></td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
Reference in New Issue
Block a user