diff --git a/admin/categories.php b/admin/categories.php index d9bb8a01..ca549e0a 100644 --- a/admin/categories.php +++ b/admin/categories.php @@ -23,193 +23,195 @@ $sql = mysqli_query( ); $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); +// Category types shown in the left nav +$category_types = [ + 'Expense' => ['label' => 'Expense', 'icon' => 'fa-shopping-cart'], + 'Income' => ['label' => 'Income', 'icon' => 'fa-hand-holding-usd'], + 'Referral' => ['label' => 'Referral', 'icon' => 'fa-share-alt'], + 'Ticket' => ['label' => 'Ticket', 'icon' => 'fa-life-ring'], + 'network_interface' => ['label' => 'Network Interface', 'icon' => 'fa-ethernet'], + 'asset_status' => ['label' => 'Asset Status', 'icon' => 'fa-heartbeat'], + 'software_type' => ['label' => 'Software Type', 'icon' => 'fa-cube'], + 'rack_type' => ['label' => 'Rack Type', 'icon' => 'fa-server'], + 'contact_note_type' => ['label' => 'Contact Note Type', 'icon' => 'fa-address-book'], + 'asset_note_type' => ['label' => 'Asset Note Type', 'icon' => 'fa-desktop'], +]; + +// Label for the selected type, falling back for anything not in the map +$category_label = $category_types[$category]['label'] ?? ucwords(str_replace('_', ' ', $category)); + +// Row count per type for the nav badges, respecting the archived view +$category_type_counts = []; +$sql_category_type_counts = mysqli_query( + $mysqli, + "SELECT category_type, COUNT(category_id) AS category_type_count FROM categories + WHERE category_$archive_query + GROUP BY category_type" +); +while ($row = mysqli_fetch_assoc($sql_category_type_counts)) { + $category_type_counts[$row['category_type']] = intval($row['category_type_count']); +} + +// Archived nav item toggles the view while holding the selected type/search +$archive_toggle_query = $_GET; +unset($archive_toggle_query['page']); +$archive_toggle_query['category'] = $category; +if ($archived) { + unset($archive_toggle_query['archived']); +} else { + $archive_toggle_query['archived'] = 1; +} +$archive_toggle_url = '?' . http_build_query($archive_toggle_query); + ?>

- Categories + Categories

+ class="fas fa-plus mr-2">New Category
-
- -
-
-
- -
- +
+ + +
+ +
+ + +
+ + + + + +
+
+
+ +
+ +
+
+
+
+ +
+
+ + "> + + + + + + + + + + + + + + + + + +
+ + Name + + ColorAction
+ + +
+
+
+ +
- +
- -
-
- - "> - - - - - - - - - - - - - - - - - -
- - Name - - ColorAction
- - -
-
-
- -
-
diff --git a/admin/tags.php b/admin/tags.php index 0ff61201..33cfa9a6 100644 --- a/admin/tags.php +++ b/admin/tags.php @@ -12,19 +12,17 @@ if (isset($_GET['type'])) { $type_filter = 1; } -if ($type_filter == 1) { - $tag_type_display = "Client"; -} elseif ( $type_filter == 2) { - $tag_type_display = "Location"; -} elseif ( $type_filter == 3) { - $tag_type_display = "Contact"; -} elseif ( $type_filter == 4) { - $tag_type_display = "Credential"; - } elseif ( $type_filter == 5) { - $tag_type_display = "Asset"; -} else { - $tag_type_display = "Unknown"; -} +// Tag types shown in the left nav +$tag_types = [ + 1 => ['label' => 'Client', 'icon' => 'fa-users'], + 2 => ['label' => 'Location', 'icon' => 'fa-map-marker-alt'], + 3 => ['label' => 'Contact', 'icon' => 'fa-address-book'], + 4 => ['label' => 'Credential', 'icon' => 'fa-key'], + 5 => ['label' => 'Asset', 'icon' => 'fa-desktop'], +]; + +// Label for the selected type +$tag_type_display = $tag_types[$type_filter]['label'] ?? 'Unknown'; $sql = mysqli_query( $mysqli, @@ -36,6 +34,13 @@ $sql = mysqli_query( $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); +// Row count per type for the nav badges +$tag_type_counts = []; +$sql_tag_type_counts = mysqli_query($mysqli, "SELECT tag_type, COUNT(tag_id) AS tag_type_count FROM tags GROUP BY tag_type"); +while ($row = mysqli_fetch_assoc($sql_tag_type_counts)) { + $tag_type_counts[intval($row['tag_type'])] = intval($row['tag_type_count']); +} + ?>
@@ -48,118 +53,111 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
-
+ + +
+ +
+ + +
-
- -
- + + + + +
+
+
+ +
+ +
+
+
+
-
- -
+
+
+ + "> + + + + + + + -
-
+ + Name + + Action
- "> - - - - - - - - - - + - + + + - + ?> - -
- - Name - - Action
- - - - -
+ - Edit + - - - Delete - - - -
+ +
+ + +
+ +
-