From bf89a86ab1f0740cc4d3c2dd47f66e0458c9074d Mon Sep 17 00:00:00 2001 From: johnnyq Date: Sat, 17 Oct 2026 20:42:29 -0400 Subject: [PATCH] Categories stage 3: list category filters offer only the categories their records have through categoryFilterOptionsHtml, archived ones marked (archived) and referrals that aren't categories marked (not set up), on expenses, recurring expenses, income, invoices, products, tickets, recurring tickets, client referrals and their export windows; new filters for quotes and recurring invoices by category, assets by status, licenses by software type and racks by type, each also in its export window and filter summary; asset type tabs count within the chosen status, and license tabs within software type and license type, fixing license counts that ignored the license type filter; Category export column for invoices, quotes and recurring invoices and Status column for assets, off until ticked; lists and quick looks show a category as its icon in its color through categoryMarkHtml, or its dot without one, on expenses, recurring expenses, income, transactions, tickets, recurring tickets and the ticket page; Admin > Categories usage counts link to the new filtered lists; read-only categories API at api/v1/categories/read.php with kind, id, name, archived and paging, checked per kind against the module that uses it, with usage counts for keys whose user sees every client; racks Archived button kept on one line; changelog updated --- CHANGELOG.md | 15 ++- agent/assets.php | 33 +++++-- agent/clients.php | 7 +- agent/expenses.php | 12 +-- agent/income.php | 6 +- agent/invoices.php | 8 +- agent/modals/asset/asset_export.php | 14 +++ agent/modals/expense/expense.php | 2 +- agent/modals/expense/expense_export.php | 7 +- agent/modals/income/income_export.php | 4 +- agent/modals/invoice/invoice_export.php | 11 +-- agent/modals/payment/payment.php | 2 +- agent/modals/product/product_export.php | 11 +-- agent/modals/quote/quote_export.php | 14 +++ .../recurring_expense/recurring_expense.php | 2 +- .../recurring_invoice_export.php | 14 +++ agent/modals/revenue/revenue.php | 2 +- agent/modals/software/software_export.php | 12 +++ agent/modals/ticket/ticket.php | 4 +- agent/modals/ticket/ticket_export.php | 11 +-- agent/post/asset.php | 11 +++ agent/post/quote.php | 11 ++- agent/post/recurring_invoice.php | 11 ++- agent/post/software.php | 9 ++ agent/products.php | 8 +- agent/quotes.php | 14 ++- agent/racks.php | 29 ++++-- agent/recurring_expenses.php | 12 +-- agent/recurring_invoices.php | 16 +++- agent/recurring_tickets.php | 13 +-- agent/software.php | 34 +++++-- agent/ticket.php | 2 +- agent/ticket_list.php | 3 +- agent/tickets.php | 9 +- agent/transactions.php | 2 +- api/v1/categories/categories_model.php | 83 ++++++++++++++++ api/v1/categories/read.php | 86 +++++++++++++++++ api/v1/enforce_api_rbac.php | 2 + css/itflow_custom.css | 6 ++ functions/accounts.php | 4 +- functions/categories.php | 95 ++++++++++++++++--- functions/expenses.php | 12 +-- functions/export.php | 4 + functions/income.php | 10 +- 44 files changed, 506 insertions(+), 171 deletions(-) create mode 100644 api/v1/categories/categories_model.php create mode 100644 api/v1/categories/read.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fa2a09bc..4bec38562 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -799,6 +799,12 @@ If you are coming from 26.08 or earlier, the database update still has to be run - The + beside a category picker opens the category window over the form. What you make there is picked in the picker and the window closes, leaving the form as it was - nothing reloads and nothing typed is lost. A name that is taken is said in the window. It is on every form that picks one: expenses, recurring expenses, other income, invoices, quotes and recurring invoices (and a ticket's quote and invoice, and Unbilled Time), products, tickets and recurring tickets, a client's referral, an asset's status, an interface's type, a license's and a license template's type, a rack's type, a contact or asset note's type, payment providers, canned responses and the mileage setting - and their Bulk Action windows. - A referral typed into a client's form that matches one in another case takes its spelling. - A window opened over another shades the one underneath, rather than drawing its shade behind it. + - Lists show a category the way the category window does - its icon in its color, or a dot of its color: expenses, recurring expenses, other income, transactions, tickets, recurring tickets, a ticket and its quick look, and the expense, recurring expense, payment and other income quick looks. + - A list's category filter offers the categories its records have, rather than every one, in the kind's order with their colors and icons. One its records have that has since been archived is still there, marked (archived), and a referral clients have that isn't one, marked (not set up). This is on expenses, recurring expenses, income, invoices, products, tickets, recurring tickets, clients by referral, and their export windows. + - New filters, each in the export window too: quotes and recurring invoices by category, assets by status, licenses by software type and racks by type. The assets tabs count within the status picked, and the licenses tabs within the software and license type. + - The invoice, quote and recurring invoice exports have a Category column, and the asset export a Status column, to tick. + - Admin > Categories links what uses a category to these lists filtered by it too: quotes, recurring invoices, assets, licenses and racks. + - API: read the categories - every kind the key can see, one kind, one by id or by name, archived ones too - with how many records have each. ### Bug Fixes @@ -891,6 +897,8 @@ If you are coming from 26.08 or earlier, the database update still has to be run - Categories: the icons of contact and asset note types didn't show in the type pickers, and making a category from the + beside a category picker left out its description. - Categories: the + beside a category picker reloaded the page once the category was made, losing the form that was being filled in. On the quote made from a ticket it made an expense category, for a picker of income categories. - Clients: saving a client with no referral made a referral with no name, and typing one that matched an archived referral made a second of it. +- Licenses: the tab counts ignored the license type filter, so a tab could say more than it showed. +- Racks: the Archived button broke onto two lines on a laptop-sized screen. - License templates: the type picker showed a stray "<" at the top. - Admin > Settings > Defaults: Payment Method and Expense Payment Method listed the payment method categories that moved to Admin > Payment Methods in 2.3.1, so a new install had nothing to pick. They list Admin > Payment Methods now. - Messages, hints and window titles were reworded where they were unclear, and bulk windows say "1 asset" or "3 assets" correctly. @@ -1277,8 +1285,13 @@ If you are coming from 26.08 or earlier, the database update still has to be run - New `functions/categories.php`, loaded by `functions.php`: `categoryKinds()` - each `category_type` with `label`, `one`, `many`, `icon`, `about`, `by` (`id` or `name`), `ordered`, `max` (name length), and `uses` (`table`, `column`, `one`, `many`, `url` with `{id}` or `{name}`, `archived` and `updated` columns, and `text` for an id kept as text, `tickets.ticket_category` and `recurring_tickets.recurring_ticket_category`). Also `categoryKind()` (adds `kind`), `categoryKindPhrase()`, `categoryUseText()`, `CATEGORY_COLORS`, `CATEGORY_ICONS`, `categoryColor()` (`#rrggbb` or `''`), `categoryIcon()` (the bare name or `''`), `categoryNextColor()`, `categoryChip($row)`, `categoryRow()`, `categoryRows($kind)` (in picker order), `categoryNameKey()`, `categoryUsage($kind)` (id => `all`, `archived`, `uses`), `categoryLooseNames($kind)`, `categoryUsageFor()`, `categoryUsageHtml()`, `categoryUsageText()`, `categoryFromInput($in, $existing)` (`[$fields, $error]`: `type`, `name`, `description`, `color`, `icon`), `categorySetSql()`, `categoryCreate()` (last in the order), `categoryUpdate($row, $fields)` (renames a by-name kind on its records; returns how many), `categoryMoveRecords($config, $where_sql, $to_sql)` (keeps each record's `*_updated_at`), `categoryArchive()`, `categoryRestore()`, `categoryDeleteBlocker($row, $used)`, `categoryDelete($id, &$error)`, `categoryMerge($from_ids, $into_id)` (same kind; returns records moved), `categoryFoldBudget()` and `categoryReorder($kind, $ids)`. - Admin: `admin/categories.php` is rebuilt (`category`, `q`, `sort` - `order`, `name` or `use` - and `archived`; no paging), with `admin/modals/category/category_form.php` shared by `category_add.php` (`category`, or none to pick the kind) and `category_edit.php` (`id`), the new `category_merge.php` (`category_ids[]`), and `js/category_form.js`. `admin/post/category.php`: `add_category` and `edit_category` (`category_id`, `type`, `name`, `description`, `color`, `icon`), GET `archive_category`, `restore_category`, `delete_category` and `move_category` (`direction` `up` or `down`), POST `merge_categories` (`category_ids[]`, `into_category_id`), `reorder_categories` (`category`, `category_ids[]`; answers JSON), and `bulk_archive_categories`, `bulk_restore_categories` and `bulk_delete_categories` (`category_ids[]`). Audit entries are Category Create, Edit, Archive, Restore, Delete and Merge, naming the kind. - Removed: `agent/post/category.php` (the + window posts to `admin/post.php` from any page), and `admin/post/category_model.php` and `agent/post/category_model.php`. - - Pickers: `categoryPicker($kind, $keep, $opts)` - the current ones in the kind's order plus `$keep` (ids, or names for a kind held by name) even when archived, a kept name that is no category as a row with `loose` and no id, keyed by the value posted; `$opts` `since` (also those archived after then) and `exclude` (names). `categoryOptionHtml($row, $selected)` (`data-color` - an asset status's badge color, `data-icon` - a software type's icon from its name when it has none, `data-description`, and "(archived)" or "(not set up)"), `categoryOptionsHtml($kind, $selected, $opts)`. `expenseCategories()`, `incomeCategories()` and `billingCategories($since, $keep_id)` return `categoryPicker()`. Every record form and Bulk Action window that picks a category writes its options with `categoryOptionsHtml()`; the list filters and exports are unchanged. + - Pickers: `categoryPicker($kind, $keep, $opts)` - the current ones in the kind's order plus `$keep` (ids, or names for a kind held by name) even when archived, a kept name that is no category as a row with `loose` and no id, keyed by the value posted; `$opts` `since` (also those archived after then) and `exclude` (names). `categoryOptionHtml($row, $selected)` (`data-color` - an asset status's badge color, `data-icon` - a software type's icon from its name when it has none, `data-description`, and "(archived)" or "(not set up)"), `categoryOptionsHtml($kind, $selected, $opts)`. `expenseCategories()`, `incomeCategories()` and `billingCategories($since, $keep_id)` return `categoryPicker()`. Every record form and Bulk Action window that picks a category writes its options with `categoryOptionsHtml()`. - The +: `categoryAddButtonHtml($kind, $class)` - admins only, opening `admin/modals/category/category_add.php?category=&inline=1`, marked `data-category-add`. `js/app.js` notes the picker beside it in `window.itflowCategoryTarget`; `js/category_form.js` posts the inline window with fetch, and `add_category` with `inline` answers JSON - `ok`, `value`, `option` (the picker's `