Tags stage 2: tags on five more record kinds (tickets, documents, [kind], [kind], [kind]) working like the other seven with tag pills and + picker on list, page and quick look, Tags field in New and Edit, list tag filter and tag-name search, Bulk Action Tags, export tag filter and Tags column; tickets list shows + only once a ticket has a tag, Tags under More filters with its own chip, board cards show tags, tag changes written to ticket history and merging moves non-archived tags; document tag filter in client Files and at top level across all folders excluding uploads, bulk Tags only tags ticked documents, cross-client document tags open a global search; global search matches tag names, shows the matching tag on each result and adds a Tags group; API tags read, update and create endpoints plus a tags list on every record read, per-kind permission checks and tag creation limited to admin keys; Tags starter pack and demo data cover the new kinds; changelog breaking change for tag-name matching in searches and upgrade note now 2.7.9 to 3.1.4; stage 1 tag test updated for twelve kinds

This commit is contained in:
johnnyq
2026-10-17 15:17:14 -04:00
parent b5dc8883f1
commit 95dd3ef9c5
63 changed files with 1236 additions and 84 deletions

View File

@@ -62,6 +62,10 @@ $status = isset($status_filters[$_GET['status'] ?? '']) ? $_GET['status'] : '';
$_GET['status'] = $status;
$status_query = $status ? "AND ({$status_filters[$status]['sql']})" : '';
// Tags - a license with any of them
$tag_filter_ids = tagFilterIds();
$tag_query = tagFilterSql('license', $tag_filter_ids, 'software.software_id');
// License type filter
$license_type_filter = (string) ($_GET['license_type'] ?? '');
$license_type_query = $license_type_filter !== '' ? "AND software_license_type = '" . escapeSql($license_type_filter) . "'" : '';
@@ -106,7 +110,7 @@ $order_by = $sort === 'software_expire' ? "software_expire IS NULL, software_exp
$seats_used_sql = softwareSeatsUsedSql('software.software_id');
// Tab counts - within the client and archive scope, before the search narrows it
// Tab counts - within the client, tag and archive scope, before the search narrows it
$count_columns = ["COUNT(*) AS all_count"];
foreach ($status_filters as $status_key => $status_filter) {
$count_columns[] = "COALESCE(SUM({$status_filter['sql']}), 0) AS {$status_key}_count";
@@ -118,6 +122,7 @@ $row = mysqli_fetch_assoc(mysqli_query($mysqli, "
WHERE $archive_query
" . clientScopeSql('software_client_id') . "
$client_query
$tag_query
"));
$tab_counts = ['' => intval($row['all_count'])];
foreach (array_keys($status_filters) as $status_key) {
@@ -136,10 +141,12 @@ $sql = mysqli_query(
LEFT JOIN vendors ON vendor_id = software_vendor_id
WHERE (software_name LIKE '%$q%' OR software_description LIKE '%$q%' OR software_type LIKE '%$q%' OR software_license_type LIKE '%$q%'
OR software_key LIKE '%$q%' OR software_purchase_reference LIKE '%$q%' OR vendor_name LIKE '%$q%' OR client_name LIKE '%$q%'
OR software.software_id IN (SELECT software_key_software_id FROM software_keys WHERE software_key LIKE '%$q%'))
OR software.software_id IN (SELECT software_key_software_id FROM software_keys WHERE software_key LIKE '%$q%')
" . tagSearchSql('license', $q, 'software.software_id') . ")
AND $archive_query
" . clientScopeSql('software_client_id') . "
$client_query
$tag_query
$status_query
$license_type_query
$expire_query
@@ -147,6 +154,13 @@ $sql = mysqli_query(
$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
$licenses = [];
while ($row = mysqli_fetch_assoc($sql)) {
$licenses[intval($row['software_id'])] = $row;
}
$licenses_tags = tagsForRecords('license', array_keys($licenses));
$can_tag = $can_edit;
// License types in use here, for the filter
$license_type_options = [];
$sql_license_types = mysqli_query($mysqli, "SELECT DISTINCT software_license_type FROM software
@@ -178,7 +192,7 @@ while ($license_type_row = mysqli_fetch_row($sql_license_types)) {
<?php if ($num_rows[0] > 0) { ?>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-dark ajax-modal" href="#"
data-modal-url="<?= buildExportModalUrl('modals/software/software_export.php', ['client_id', 'client', 'status', 'license_type', 'expire_days', 'archived', 'q']) ?>">
data-modal-url="<?= buildExportModalUrl('modals/software/software_export.php', ['client_id', 'client', 'status', 'license_type', 'tags', 'expire_days', 'archived', 'q']) ?>">
<i class="fa fa-fw fa-download me-2"></i>Export
</a>
<?php } ?>
@@ -216,14 +230,14 @@ while ($license_type_row = mysqli_fetch_row($sql_license_types)) {
<input type="hidden" name="status" value="<?= $status ?>">
<input type="hidden" name="archived" value="<?= $archived ?>">
<div class="row g-2 align-items-center">
<div class="col-lg-3 col-md-6">
<div class="<?= $client_url ? 'col-lg-3' : 'col-lg-4' ?> col-md-6">
<div class="input-group">
<input type="search" class="form-control" name="q" value="<?php if (isset($q)) { echo stripslashes(escapeHtml($q)); } ?>" placeholder="Search licenses, keys, vendors...">
<input type="search" class="form-control" name="q" value="<?php if (isset($q)) { echo stripslashes(escapeHtml($q)); } ?>" placeholder="Search licenses, keys, vendors, tags...">
<button class="btn btn-dark" title="Search"><i class="fa fa-search"></i></button>
</div>
</div>
<?php if (!$client_url) { ?>
<div class="col-lg-2 col-md-6">
<div class="col-lg-4 col-md-6">
<select class="form-select select2" name="client" onchange="this.form.submit()">
<option value="" <?php if ($client == "") { echo "selected"; } ?>>- All Clients -</option>
<?php
@@ -244,7 +258,7 @@ while ($license_type_row = mysqli_fetch_row($sql_license_types)) {
</select>
</div>
<?php } ?>
<div class="col-lg-2 col-md-4">
<div class="<?= $client_url ? 'col-lg-2' : 'col-lg-4' ?> col-md-4">
<select class="form-select select2" name="license_type" onchange="this.form.submit()">
<option value="">- License Type -</option>
<?php foreach ($license_type_options as $license_type_option) { ?>
@@ -252,7 +266,7 @@ while ($license_type_row = mysqli_fetch_row($sql_license_types)) {
<?php } ?>
</select>
</div>
<div class="col-lg-2 col-md-4">
<div class="<?= $client_url ? 'col-lg-2' : 'col-lg-3' ?> col-md-4">
<select class="form-select select2" name="expire_days" onchange="this.form.submit()">
<option value="" <?php if ($expire_days == "") { echo "selected"; } ?>>- Renewal -</option>
<option value="expired" <?php if ($expire_days === "expired") { echo "selected"; } ?>>Expired</option>
@@ -261,14 +275,19 @@ while ($license_type_row = mysqli_fetch_row($sql_license_types)) {
<?php } ?>
</select>
</div>
<div class="col-lg-2 col-md-4">
<div class="<?= $client_url ? 'col-lg-2' : 'col-lg-3' ?> col-md-4">
<select onchange="this.form.submit()" class="form-select select2" name="tags[]" data-placeholder="- Tags -" multiple>
<?= tagFilterOptionsHtml('license', $tag_filter_ids, "$archive_query " . clientScopeSql('software_client_id') . " $client_query") ?>
</select>
</div>
<div class="<?= $client_url ? 'col-lg-2' : 'col-lg-3' ?> col-md-4">
<select onchange="this.form.submit()" class="form-select select2" name="show_column[]" data-placeholder="- More columns -" multiple>
<?php foreach ($extra_column_options as $column_key => $column_label) { ?>
<option value="<?= $column_key ?>" <?php if (in_array($column_key, $extra_columns, true)) { echo 'selected'; } ?>><?= $column_label ?></option>
<?php } ?>
</select>
</div>
<div class="col-lg-1 col-md-12 <?= $client_url ? 'col-lg-3' : '' ?>">
<div class="<?= $client_url ? 'col-lg-1' : 'col-lg-3' ?> col-md-12">
<div class="d-flex justify-content-end gap-2">
<a href="?<?= $client_url ?>archived=<?= $archived ? 0 : 1 ?>"
class="btn <?= $archived ? 'btn-dark' : 'btn-outline-dark' ?>" title="<?= $archived ? 'Back to active licenses' : 'Show archived licenses' ?>">
@@ -284,6 +303,9 @@ while ($license_type_row = mysqli_fetch_row($sql_license_types)) {
<a class="dropdown-item ajax-modal" href="#" data-modal-url="modals/software/software_renew.php" data-modal-size="lg" data-bulk="true">
<i class="fas fa-fw fa-redo-alt me-2"></i>Renew
</a>
<a class="dropdown-item" href="#" data-tag-picker data-tag-entity="license" data-tag-bulk data-csrf="<?= $_SESSION['csrf_token'] ?>">
<i class="fas fa-fw fa-tags me-2"></i>Tags
</a>
<div class="dropdown-divider"></div>
<button class="dropdown-item text-danger confirm-link" type="submit" form="bulkActions" name="bulk_archive_software">
<i class="fas fa-fw fa-archive me-2"></i>Archive
@@ -376,7 +398,7 @@ while ($license_type_row = mysqli_fetch_row($sql_license_types)) {
<tbody>
<?php
while ($row = mysqli_fetch_assoc($sql)) {
foreach ($licenses as $row) {
$client_id = intval($row['client_id']);
$client_name = escapeHtml($row['client_name']);
$software_id = intval($row['software_id']);
@@ -395,6 +417,7 @@ while ($license_type_row = mysqli_fetch_row($sql_license_types)) {
$seats = softwareSeats($row['seats_used'], $row['software_seats']);
$renewal = softwareRenewal($row['software_expire']);
$license_url = "license.php?client_id=$client_id&software_id=$software_id";
$license_tags = $licenses_tags[$software_id] ?? [];
?>
<tr>
@@ -415,6 +438,9 @@ while ($license_type_row = mysqli_fetch_row($sql_license_types)) {
<?php if ($software_favorite) { ?><i class="fas fa-star text-warning ms-1" title="Favorite"></i><?php } ?>
<?php if ($software_archived_at) { ?><span class="badge rounded-pill text-bg-secondary fw-normal ms-1">Archived</span><?php } ?>
<div class="small text-body-secondary text-truncate itflow-asset-desc" title="<?= $software_description ?: $software_type ?>"><?= $software_description ?: $software_type ?></div>
<?php if ($license_tags || ($can_tag && !$software_archived_at)) { ?>
<div class="mt-1 itflow-above-stretch"><?= tagPills('license', $software_id, $license_tags, "software.php?$client_url", $can_tag && !$software_archived_at) ?></div>
<?php } ?>
</div>
</div>
</td>