From 2b087c8f460cf170506c9a423b18fc97f1fb873e Mon Sep 17 00:00:00 2001 From: johnnyq Date: Sat, 17 Oct 2026 20:41:26 -0400 Subject: [PATCH] Categories stage 2: every form and Bulk Action window picks a category the same way through categoryPicker and categoryOptionsHtml, in the kind's order with each category's color, icon and description, keeping a record's archived category marked (archived) and a status, type or referral that isn't a category marked (not set up) so saving changes neither; the + beside a category picker is admins only and opens the category window stacked over the form, saving in the background as JSON, picking the new category and leaving the form as it was, with a taken name shown in the window, on every form that picks one including a ticket's quote and invoice, Unbilled Time, payment providers, canned responses, the mileage setting and the Bulk Action windows; stacked windows shade the one underneath; agent/post/category.php removed so the window posts to admin/post.php from any page; typed referrals go through categoryEnsure, taking an existing referral's spelling in any case, matching archived ones and no longer making an empty referral on client add, edit and import; fixes the + reloading the page and losing the form, the quote made from a ticket creating an expense category, and a stray < in the license template type picker; changelog updated --- CHANGELOG.md | 14 +- .../canned_response/canned_response_add.php | 11 +- .../canned_response/canned_response_edit.php | 11 +- admin/modals/category/category_add.php | 11 +- admin/modals/category/category_edit.php | 2 +- admin/modals/category/category_merge.php | 2 +- .../payment_provider/payment_provider_add.php | 18 +-- .../payment_provider_edit.php | 18 +-- .../software_template_add.php | 14 +- .../software_template_edit.php | 16 +-- admin/post/category.php | 23 +++- admin/settings_invoice.php | 7 +- agent/modals/asset/asset_bulk_add_ticket.php | 12 +- agent/modals/asset/asset_bulk_edit_status.php | 14 +- agent/modals/asset/asset_form.php | 19 +-- .../asset/asset_interface_bulk_edit_type.php | 14 +- agent/modals/asset/asset_interface_form.php | 9 +- .../asset/asset_interface_multiple_add.php | 5 +- agent/modals/asset/asset_note_add.php | 14 +- agent/modals/billing/billing_form.php | 9 +- agent/modals/client/client_add.php | 16 +-- .../modals/client/client_bulk_add_ticket.php | 12 +- .../client/client_bulk_edit_referral.php | 13 +- agent/modals/client/client_edit.php | 22 +-- agent/modals/contact/contact_note_add.php | 14 +- agent/modals/expense/expense_bulk_edit.php | 5 +- agent/modals/expense/expense_form.php | 9 +- agent/modals/income/income_bulk_edit.php | 5 +- agent/modals/invoice/invoice_assets.php | 5 +- .../invoice/invoice_bulk_edit_category.php | 7 +- .../product/product_bulk_edit_category.php | 14 +- agent/modals/product/product_form.php | 14 +- agent/modals/rack/rack_form.php | 20 +-- .../recurring_expense_form.php | 9 +- .../recurring_ticket/recurring_ticket_add.php | 16 +-- .../recurring_ticket_bulk_category_edit.php | 12 +- .../recurring_ticket_edit.php | 12 +- agent/modals/revenue/revenue_form.php | 9 +- agent/modals/software/software_form.php | 16 +-- agent/modals/ticket/ticket_add.php | 15 +- .../ticket/ticket_bulk_edit_category.php | 12 +- agent/modals/ticket/ticket_edit.php | 12 +- agent/modals/ticket/ticket_invoice_add.php | 6 +- agent/modals/ticket/ticket_quote_add.php | 16 +-- agent/post/category.php | 36 ----- agent/post/client.php | 35 ++--- agent/post/client_model.php | 1 - agent/unbilled_time.php | 6 +- functions/billing.php | 14 +- functions/categories.php | 130 ++++++++++++++++++ functions/expenses.php | 13 +- functions/income.php | 13 +- js/app.js | 37 +++++ js/category_form.js | 74 ++++++++++ 54 files changed, 395 insertions(+), 498 deletions(-) delete mode 100644 agent/post/category.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 960448bd9..9fa2a09bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -144,6 +144,7 @@ If you are coming from 26.08 or earlier, the database update still has to be run - A category can only be deleted while nothing uses it - merge it into another, or archive it. Deleting one in use used to leave expenses, invoices and tickets with no category, and clients and assets with a name that could no longer be picked. Delete is now on current categories too, not only archived ones. - A category's name is now unique within its kind, in any case: a second expense category called Travel can't be made, though an income category can be. Categories already named alike keep their names. - Interface types and rack types are held to 50 characters, which is all an interface or a rack keeps. + - The + beside a category picker shows for admins only, on every form. It opened Admin's New Category window, which refused anyone else. Agents typing a referral that isn't one yet into a client's form still make it, as before. - Notifications now follow access too. An agent only sees notifications for clients and areas they can open, so someone without sales access no longer sees invoice and quote notifications. - Drop-downs: Tom Select is gone, replaced by ITFlow's own picker. It works the way you are used to: type to search, tick several in a multi-select, and type a new value in fields that allow it, such as ticket watchers. See Developer Updates if you have custom pages that used Tom Select. - Several small windows are gone because the change is now made where the value is shown: @@ -794,6 +795,10 @@ If you are coming from 26.08 or earlier, the database update still has to be run - Merge moves everything with the merged categories onto the one you keep, and the others are deleted: expenses, recurring expenses, budget months (a month budgeted under both becomes one line of their total), import rules, a payment provider's fees and the mileage setting, invoices, quotes, recurring invoices, other income, products, tickets, recurring tickets and canned responses - and for the kinds kept by name, the clients, assets, interfaces, licenses, license templates, racks and notes that have them. - Names that records have but aren't categories - notes typed General, referrals entered before there was a list - are listed under the kind's categories with how many have each, linked to them where there is a list, and Add makes one a category. To fold one into another, add it, then merge it. - Renaming or merging doesn't mark the records it changes as edited. + - Every form that picks a category picks it the same way, from the categories in the order they are offered in, each with its color, its icon and its description underneath. A record keeps a category archived since it was picked, marked (archived), and a status, type or referral it has that isn't a category, marked (not set up), so saving it changes neither. + - 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. ### Bug Fixes @@ -884,6 +889,9 @@ If you are coming from 26.08 or earlier, the database update still has to be run - Tags: the Archived button on Admin > Tags showed the same tags as without it, as nothing could be archived. - Categories: editing a category whose color was saved as a word, such as lightblue, turned it black, as the color picker can't show words. The ticket list, a ticket's quick look and the recurring tickets list left those colors out, and the reports drew them in a color of their own. - 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. +- 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. @@ -1268,7 +1276,11 @@ If you are coming from 26.08 or earlier, the database update still has to be run - The migration writes every `category_color` as `#rrggbb` - short hex grows, an eight-digit one loses its alpha, the 148 CSS color words become their own hex, anything else NULL - and every `category_icon` as `fa-` and the name (`fas fa-`, markup and anything but `a-z0-9-` taken off, NULL when empty), leaving `category_updated_at` alone. No column changes; `setup/seed_data.php` writes hex colors. - 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. - - `agent/post/category.php` (what the + window posts to from an agent page) takes the same fields through `categoryFromInput()` and is admins only, like the window. Removed: `admin/post/category_model.php` and `agent/post/category_model.php`. + - 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. + - 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 `