mirror of
https://github.com/itflow-org/itflow
synced 2026-11-27 14:48:59 +00:00
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
This commit is contained in:
15
CHANGELOG.md
15
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 `<option>`, selected) and `message`, or `ok` false and `error`. Without `inline` it goes back to the page it came from, or to the kind in Admin > Categories. The category windows post to `/admin/post.php`.
|
||||
- List filters: `categoryFilterOptionsHtml($kind, $selected, $used_sql, $opts)` - the categories the list's records have (`$used_sql` selects their ids, or names for a kind held by name), archived ones and loose names included, plus `$selected`; without `$used_sql`, the current ones. The list writes its own "any" option. The category filters of expenses, recurring expenses, income (other income's categories and those of the invoices paid), invoices, products, tickets, recurring tickets and clients' referrals, and the expense, income, invoice, product and ticket export windows, use it.
|
||||
- New list parameters: `agent/quotes.php?category=`, `agent/recurring_invoices.php?category=`, `agent/assets.php?status=` (a name; the `type` tabs and `$tab_counts` take it in), `agent/software.php?software_type=` (`$tab_counts` take it and `license_type` in) and `agent/racks.php?type=` (a name). `buildExportModalUrl()` hands each to its export window, and `export_quotes` and `export_recurring_invoices` take `category`, `export_assets` `status` and `export_software` `software_type`, each in the filter summary. Export columns: `category_name` for `invoices`, `quotes` and `recurring_invoices`, and `asset_status` for `assets`, off until ticked; the quote and recurring invoice handlers select `category_name`.
|
||||
- `categoryKinds()`: `modules` - the modules whose records hold a kind, any one of which reads it (`Income` is `module_sales` or `module_financial`) - and `uses` URLs for quotes, recurring invoices, assets, licenses and racks.
|
||||
- `categoryMarkHtml($color, $icon, $dot)` - the icon in the color (`.itflow-category-icon`), else `$dot` (`sprintf` with a style attribute or `''`) or `.itflow-category-dot`. `expenseCategoryDot($color, $icon)` returns it, and the ticket lists, a ticket and its quick look pass their `.itflow-ticket-dot`. `category_icon` is now selected by `incomeUnionSql()` (both halves), `incomeRevenueRow()`, `incomePaymentRow()`, the account ledger in `functions/accounts.php`, and the expense, recurring expense, ticket, recurring ticket and ticket quick look queries.
|
||||
- API: `api/v1/categories/read.php` (GET; `kind` - a `category_type` or its label, any case - `category_id` (archived or not), `category_name` (any case), `archived`, `limit`, `offset`) answers `category_id`, `category_name`, `category_description`, `category_type`, `category_color` and `category_icon` (or null), `category_order`, `category_created_at`, `category_updated_at`, `category_archived_at`, `category_used` and `category_used_by` (by table; both null for a user limited to certain clients, as they count every client's records). `api/v1/categories/categories_model.php`: `categoryApiCanRead()`, `categoryApiReadableKinds()`, `categoryApiKind()` (refuses an unknown kind or one the user can't read) and `categoryApiRow()`. `enforce_api_rbac.php` maps `categories` to `''`.
|
||||
- `categoryEnsure($kind, $name)` - a name typed for a kind held by name as its category's own spelling, matched in any case, archived or not, or made (with the next color, logged); `''` for none. `add_client`, `edit_client` and the client import use it for the referral, in place of their own insert.
|
||||
- `js/app.js`: a modal shown over another (`show.bs.modal`) takes a z-index 20 above it, its backdrop just under it, and `modal-open` goes back on the body when the top one closes.
|
||||
- `selectOptionColor()` turns an icon kept as `fa-name` into `fas fa-name`.
|
||||
|
||||
@@ -77,6 +77,10 @@ if ($client_url && !empty($_GET['location'])) {
|
||||
$location_filter = 0;
|
||||
}
|
||||
|
||||
// Status Filter - the asset statuses (Admin > Categories), held by name
|
||||
$status_filter = trim(strip_tags((string) ($_GET['status'] ?? '')));
|
||||
$status_query = $status_filter !== '' ? "AND asset_status = '" . escapeSql($status_filter) . "'" : '';
|
||||
|
||||
// Tags Filter
|
||||
if (isset($_GET['tags']) && is_array($_GET['tags']) && !empty($_GET['tags'])) {
|
||||
$tag_filter = implode(",", array_map('intval', $_GET['tags']));
|
||||
@@ -131,7 +135,7 @@ if (!in_array($sort, $sortable_columns, true)) {
|
||||
// Addresses sort by value - .9 before .10 - and this works for IPv4 and IPv6 alike
|
||||
$order_by = $sort === 'interface_ip' ? "INET6_ATON(interface_ip) $order, interface_ip $order" : "$sort $order";
|
||||
|
||||
// Tab counts - within the client, tag and archive scope, before the search narrows it
|
||||
// Tab counts - within the client, status, tag and archive scope, before the search narrows it
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "
|
||||
SELECT
|
||||
COUNT(*) AS all_count,
|
||||
@@ -144,6 +148,7 @@ $row = mysqli_fetch_assoc(mysqli_query($mysqli, "
|
||||
FROM assets
|
||||
LEFT JOIN clients ON client_id = asset_client_id
|
||||
WHERE $archive_query
|
||||
$status_query
|
||||
$tag_query
|
||||
" . clientScopeSql('asset_client_id') . "
|
||||
$client_query
|
||||
@@ -176,6 +181,7 @@ $sql = mysqli_query(
|
||||
OR asset_id IN (SELECT asset_tag_asset_id FROM asset_tags JOIN tags ON tag_id = asset_tag_tag_id WHERE tag_name LIKE '%$q%'))
|
||||
AND ($type_query)
|
||||
" . clientScopeSql('asset_client_id') . "
|
||||
$status_query
|
||||
$location_query
|
||||
$expire_query
|
||||
$client_query
|
||||
@@ -228,7 +234,7 @@ $search_noun = $type_filter ? $asset_type_tabs[$type_filter]['label'] : 'assets'
|
||||
<div class="dropdown-divider"></div>
|
||||
<?php } ?>
|
||||
<a class="dropdown-item text-dark ajax-modal" href="#"
|
||||
data-modal-url="<?= buildExportModalUrl('modals/asset/asset_export.php', ['client_id', 'type', 'client', 'location', 'tags', 'expire_days', 'archived', 'q']) ?>">
|
||||
data-modal-url="<?= buildExportModalUrl('modals/asset/asset_export.php', ['client_id', 'type', 'client', 'location', 'status', 'tags', 'expire_days', 'archived', 'q']) ?>">
|
||||
<i class="fa fa-fw fa-download me-2"></i>Export
|
||||
</a>
|
||||
<?php } ?>
|
||||
@@ -265,14 +271,14 @@ $search_noun = $type_filter ? $asset_type_tabs[$type_filter]['label'] : 'assets'
|
||||
<input type="hidden" name="type" value="<?= $type_filter ?>">
|
||||
<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="col-xl-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 <?= strtolower($search_noun) ?>, IPs, serials...">
|
||||
<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-xl col-lg-4 col-md-6">
|
||||
<select class="form-select select2" name="location" onchange="this.form.submit()">
|
||||
<option value="">- All Locations -</option>
|
||||
<?php
|
||||
@@ -292,7 +298,7 @@ $search_noun = $type_filter ? $asset_type_tabs[$type_filter]['label'] : 'assets'
|
||||
</select>
|
||||
</div>
|
||||
<?php } else { ?>
|
||||
<div class="col-lg-2 col-md-6">
|
||||
<div class="col-xl 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
|
||||
@@ -313,7 +319,16 @@ $search_noun = $type_filter ? $asset_type_tabs[$type_filter]['label'] : 'assets'
|
||||
</select>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="col-lg-2 col-md-4">
|
||||
<div class="col-xl col-lg-4 col-md-6">
|
||||
<select class="form-select select2" name="status" onchange="this.form.submit()">
|
||||
<option value="">- Status -</option>
|
||||
<?= categoryFilterOptionsHtml('asset_status', $status_filter, "SELECT DISTINCT asset_status FROM assets
|
||||
LEFT JOIN clients ON client_id = asset_client_id
|
||||
WHERE $archive_query AND asset_status IS NOT NULL AND asset_status <> ''
|
||||
" . clientScopeSql('asset_client_id') . " $client_query") ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-xl col-lg-3 col-md-6">
|
||||
<select onchange="this.form.submit()" class="form-select select2" name="tags[]" data-placeholder="- Tags -" multiple>
|
||||
<?php
|
||||
// Tags in use on assets in this scope, plus any already picked
|
||||
@@ -335,7 +350,7 @@ $search_noun = $type_filter ? $asset_type_tabs[$type_filter]['label'] : 'assets'
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-4">
|
||||
<div class="col-xl col-lg-3 col-md-6">
|
||||
<select class="form-select select2" name="expire_days" onchange="this.form.submit()">
|
||||
<option value="" <?php if ($expire_days == "") { echo "selected"; } ?>>- Warranty -</option>
|
||||
<option value="expired" <?php if ($expire_days === "expired") { echo "selected"; } ?>>Expired</option>
|
||||
@@ -344,14 +359,14 @@ $search_noun = $type_filter ? $asset_type_tabs[$type_filter]['label'] : 'assets'
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-4">
|
||||
<div class="col-xl col-lg-3 col-md-6">
|
||||
<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">
|
||||
<div class="col-xl-auto 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 assets' : 'Show archived assets' ?>">
|
||||
|
||||
@@ -403,12 +403,7 @@ $total_leads = intval($row['leads']);
|
||||
<label class="form-label">Referral</label>
|
||||
<select class="form-select select2" name="referral" onchange="this.form.submit()">
|
||||
<option value="">Any referral</option>
|
||||
<?php
|
||||
$sql_referrals_filter = mysqli_query($mysqli, "SELECT DISTINCT client_referral FROM clients WHERE client_$archive_query AND client_referral != '' $leads_query ORDER BY client_referral ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_referrals_filter)) {
|
||||
$referral_name = escapeHtml($row['client_referral']); ?>
|
||||
<option <?php if ($referral_name == $referral_filter) { echo "selected"; } ?>><?= $referral_name ?></option>
|
||||
<?php } ?>
|
||||
<?= categoryFilterOptionsHtml('Referral', (string) ($_GET['referral'] ?? ''), "SELECT DISTINCT client_referral FROM clients WHERE client_$archive_query AND client_referral != '' $leads_query") ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
|
||||
@@ -53,7 +53,7 @@ $where = expenseFiltersSql($filter_src);
|
||||
$show_query = $shows[$show]['where'] ? "AND {$shows[$show]['where']}" : '';
|
||||
$joins = expenseJoinsSql();
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS expenses.*, vendor_name, vendor_archived_at, category_name, category_color, account_name, client_name, user_name,
|
||||
$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS expenses.*, vendor_name, vendor_archived_at, category_name, category_color, category_icon, account_name, client_name, user_name,
|
||||
invoice_prefix, invoice_number, (SELECT payer.user_name FROM users AS payer WHERE payer.user_id = expense_paid_by) AS paid_by_name
|
||||
FROM expenses $joins
|
||||
LEFT JOIN invoices ON invoice_id = expense_invoice_id
|
||||
@@ -209,13 +209,7 @@ $month_change = $stats['last_to_date'] > 0 ? round(($stats['month'] - $stats['la
|
||||
<div class="col-lg-2 col-md-4">
|
||||
<select class="form-select select2" name="category" onchange="this.form.submit()" aria-label="Category">
|
||||
<option value="">- Any category -</option>
|
||||
<?php
|
||||
$sql_filter = mysqli_query($mysqli, "SELECT category_id, category_name, category_color, category_icon FROM categories
|
||||
WHERE category_type = 'Expense' AND EXISTS (SELECT 1 FROM expenses WHERE expense_category_id = category_id AND expense_vendor_id > 0) ORDER BY category_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_filter)) {
|
||||
$option_id = intval($row['category_id']); ?>
|
||||
<option <?= $category_filter === $option_id ? 'selected' : '' ?> value="<?= $option_id ?>"<?= selectOptionColor($row['category_color'] ?? '', $row['category_icon'] ?? '') ?>><?= escapeHtml($row['category_name']) ?></option>
|
||||
<?php } ?>
|
||||
<?= categoryFilterOptionsHtml('Expense', $category_filter, "SELECT DISTINCT expense_category_id FROM expenses WHERE expense_vendor_id > 0") ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-4">
|
||||
@@ -376,7 +370,7 @@ $month_change = $stats['last_to_date'] > 0 ? round(($stats['month'] - $stats['la
|
||||
<?= escapeHtml(implode(' · ', array_filter([truncate((string) $row['expense_description'], 80), $row['expense_reference'] ? '#' . $row['expense_reference'] : '']))) ?: ' ' ?>
|
||||
</div>
|
||||
</td>
|
||||
<td><div class="text-truncate" style="max-width: 10rem;" title="<?= escapeHtml((string) $row['category_name']) ?>"><?= expenseCategoryDot($row['category_color']) ?><?= escapeHtml($row['category_name'] ?: '-') ?></div></td>
|
||||
<td><div class="text-truncate" style="max-width: 10rem;" title="<?= escapeHtml((string) $row['category_name']) ?>"><?= expenseCategoryDot($row['category_color'], $row['category_icon'] ?? '') ?><?= escapeHtml($row['category_name'] ?: '-') ?></div></td>
|
||||
<td>
|
||||
<?php if (intval($row['expense_client_id'])) { ?>
|
||||
<div class="text-truncate" style="max-width: 10rem;"><a class="text-reset" href="<?= escapeHtml($filter_url(['client' => intval($row['expense_client_id'])])) ?>" title="<?= escapeHtml((string) $row['client_name']) ?> - their expenses"><?= escapeHtml($row['client_name']) ?></a></div>
|
||||
|
||||
@@ -196,9 +196,7 @@ $invoices_url = 'invoices.php?' . ($client_page ? "client_id=$client_id&" : '')
|
||||
<div class="flex-grow-1 min-w-0">
|
||||
<select class="form-select select2" name="category" onchange="this.form.submit()" aria-label="Category">
|
||||
<option value="">- Any category -</option>
|
||||
<?php foreach (incomeCategories($category_filter) as $option_id => $category) { ?>
|
||||
<option <?= $category_filter === $option_id ? 'selected' : '' ?> value="<?= $option_id ?>"<?= selectOptionColor($category['category_color'] ?? '', $category['category_icon'] ?? '') ?>><?= escapeHtml($category['category_name']) ?></option>
|
||||
<?php } ?>
|
||||
<?= categoryFilterOptionsHtml('Income', $category_filter, "SELECT revenue_category_id FROM revenues UNION SELECT invoice_category_id FROM payments JOIN invoices ON invoice_id = payment_invoice_id", ['exclude' => ['Account Transfer']]) ?>
|
||||
</select>
|
||||
</div>
|
||||
<?php if ($client_page && $can_bulk) { ?>
|
||||
@@ -334,7 +332,7 @@ $invoices_url = 'invoices.php?' . ($client_page ? "client_id=$client_id&" : '')
|
||||
</td>
|
||||
<td>
|
||||
<?php if (intval($row['income_category_id']) && $row['category_name'] !== null) { ?>
|
||||
<div class="text-truncate" style="max-width: 10rem;" title="<?= escapeHtml($row['category_name']) ?>"><?= expenseCategoryDot($row['category_color']) ?><?= escapeHtml($row['category_name']) ?></div>
|
||||
<div class="text-truncate" style="max-width: 10rem;" title="<?= escapeHtml($row['category_name']) ?>"><?= expenseCategoryDot($row['category_color'], $row['category_icon'] ?? '') ?><?= escapeHtml($row['category_name']) ?></div>
|
||||
<?php } else { ?>
|
||||
<span class="text-warning-emphasis small" title="Not in a category - the reports show it as No category">No category</span>
|
||||
<?php } ?>
|
||||
|
||||
@@ -243,13 +243,7 @@ $stat_money = function ($amount) use ($session_company_currency) {
|
||||
<div class="col-lg-3 col-md-6">
|
||||
<select class="form-select select2" name="category" onchange="this.form.submit()">
|
||||
<option value="">- Any category -</option>
|
||||
<?php
|
||||
$sql_categories_filter = mysqli_query($mysqli, "SELECT category_id, category_name, category_color, category_icon FROM categories
|
||||
WHERE category_type = 'Income' AND EXISTS (SELECT 1 FROM invoices WHERE invoice_category_id = category_id) ORDER BY category_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_categories_filter)) {
|
||||
$category_option_id = intval($row['category_id']); ?>
|
||||
<option <?= $category_filter === $category_option_id ? 'selected' : '' ?> value="<?= $category_option_id ?>"<?= selectOptionColor($row['category_color'] ?? '', $row['category_icon'] ?? '') ?>><?= escapeHtml($row['category_name']) ?></option>
|
||||
<?php } ?>
|
||||
<?= categoryFilterOptionsHtml('Income', $category_filter, "SELECT DISTINCT invoice_category_id FROM invoices") ?>
|
||||
</select>
|
||||
</div>
|
||||
<?php if (!$client_url) { ?>
|
||||
|
||||
@@ -23,6 +23,9 @@ $client_filter = intval($_GET['client'] ?? 0);
|
||||
// Location Filter
|
||||
$location_filter = intval($_GET['location'] ?? 0);
|
||||
|
||||
// Status Filter
|
||||
$status_filter = trim(strip_tags((string) ($_GET['status'] ?? '')));
|
||||
|
||||
// Tags Filter
|
||||
$tag_filter = (isset($_GET['tags']) && is_array($_GET['tags'])) ? array_map('intval', $_GET['tags']) : [];
|
||||
|
||||
@@ -119,6 +122,17 @@ ob_start();
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="mb-3">
|
||||
<label>Status</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-circle"></i></span>
|
||||
<select class="form-select select2" name="status">
|
||||
<option value="">- All Statuses -</option>
|
||||
<?= categoryFilterOptionsHtml('asset_status', $status_filter, "SELECT DISTINCT asset_status FROM assets WHERE asset_status IS NOT NULL AND asset_status <> ''" . ($client_id ? " AND asset_client_id = $client_id" : '') . clientScopeSql('asset_client_id')) ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label>Tags</label>
|
||||
<div class="input-group">
|
||||
|
||||
@@ -131,7 +131,7 @@ ob_start();
|
||||
<?php } ?>
|
||||
<div class="itflow-glance-item" title="Category">
|
||||
<i class="fas fa-fw fa-list"></i>
|
||||
<span><?= expenseCategoryDot($row['category_color']) ?><?= escapeHtml($row['category_name'] ?: 'No category') ?></span>
|
||||
<span><?= expenseCategoryDot($row['category_color'], $row['category_icon'] ?? '') ?><?= escapeHtml($row['category_name'] ?: 'No category') ?></span>
|
||||
</div>
|
||||
<?php if (floatval($row['expense_tax_amount']) != 0) { ?>
|
||||
<div class="itflow-glance-item" title="Tax included">
|
||||
|
||||
@@ -80,12 +80,7 @@ ob_start();
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-list"></i></span>
|
||||
<select class="form-select select2" name="category">
|
||||
<option value="">- Any category -</option>
|
||||
<?php
|
||||
$sql = mysqli_query($mysqli, "SELECT category_id, category_name, category_color, category_icon FROM categories WHERE category_type = 'Expense' ORDER BY category_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$option_id = intval($row['category_id']); ?>
|
||||
<option <?= $category_filter === $option_id ? 'selected' : '' ?> value="<?= $option_id ?>"<?= selectOptionColor($row['category_color'] ?? '', $row['category_icon'] ?? '') ?>><?= escapeHtml($row['category_name']) ?></option>
|
||||
<?php } ?>
|
||||
<?= categoryFilterOptionsHtml('Expense', $category_filter, "SELECT DISTINCT expense_category_id FROM expenses") ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -90,9 +90,7 @@ ob_start();
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span>
|
||||
<select class="form-select select2" name="category">
|
||||
<option value="">- Any category -</option>
|
||||
<?php foreach (incomeCategories($category_filter) as $option_id => $category) { ?>
|
||||
<option <?= $category_filter === $option_id ? 'selected' : '' ?> value="<?= $option_id ?>"<?= selectOptionColor($category['category_color'] ?? '', $category['category_icon'] ?? '') ?>><?= escapeHtml($category['category_name']) ?></option>
|
||||
<?php } ?>
|
||||
<?= categoryFilterOptionsHtml('Income', $category_filter, "SELECT revenue_category_id FROM revenues UNION SELECT invoice_category_id FROM payments JOIN invoices ON invoice_id = payment_invoice_id", ['exclude' => ['Account Transfer']]) ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -72,16 +72,7 @@ ob_start();
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-list"></i></span>
|
||||
<select class="form-select select2" name="category">
|
||||
<option value="">- All Categories -</option>
|
||||
<?php
|
||||
$sql_category_filter = mysqli_query($mysqli, "SELECT category_id, category_name, category_color, category_icon FROM categories WHERE category_type = 'Income' ORDER BY category_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_category_filter)) {
|
||||
$filter_option_id = intval($row['category_id']);
|
||||
$filter_option_name = escapeHtml($row['category_name']);
|
||||
?>
|
||||
<option <?php if ($category_filter == $filter_option_id) { echo "selected"; } ?> value="<?= $filter_option_id ?>"<?= selectOptionColor($row['category_color'] ?? '', $row['category_icon'] ?? '') ?>><?= $filter_option_name ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<?= categoryFilterOptionsHtml('Income', $category_filter, "SELECT DISTINCT invoice_category_id FROM invoices") ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -118,7 +118,7 @@ ob_start();
|
||||
<div class="itflow-glance-item" title="Category - the invoice's">
|
||||
<i class="fas fa-fw fa-tag"></i>
|
||||
<?php if (intval($row['invoice_category_id']) && $row['category_name'] !== null) { ?>
|
||||
<span class="text-truncate"><?= expenseCategoryDot($row['category_color']) ?><?= escapeHtml($row['category_name']) ?></span>
|
||||
<span class="text-truncate"><?= expenseCategoryDot($row['category_color'], $row['category_icon'] ?? '') ?><?= escapeHtml($row['category_name']) ?></span>
|
||||
<?php } else { ?>
|
||||
<span class="text-warning-emphasis">No category<?= $has_invoice ? ' - set one on the invoice' : '' ?></span>
|
||||
<?php } ?>
|
||||
|
||||
@@ -74,16 +74,7 @@ ob_start();
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-list"></i></span>
|
||||
<select class="form-select select2" name="category">
|
||||
<option value="">- All Categories -</option>
|
||||
<?php
|
||||
$sql_category_filter = mysqli_query($mysqli, "SELECT category_id, category_name, category_color, category_icon FROM categories WHERE category_type = 'Income' ORDER BY category_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_category_filter)) {
|
||||
$filter_option_id = intval($row['category_id']);
|
||||
$filter_option_name = escapeHtml($row['category_name']);
|
||||
?>
|
||||
<option <?php if ($category_filter == $filter_option_id) { echo "selected"; } ?> value="<?= $filter_option_id ?>"<?= selectOptionColor($row['category_color'] ?? '', $row['category_icon'] ?? '') ?>><?= $filter_option_name ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<?= categoryFilterOptionsHtml('Income', $category_filter, "SELECT DISTINCT product_category_id FROM products") ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -14,6 +14,9 @@ if ($client_id) {
|
||||
// Search Filter
|
||||
$q_filter = $_GET['q'] ?? '';
|
||||
|
||||
// Category Filter
|
||||
$category_filter = intval($_GET['category'] ?? 0);
|
||||
|
||||
// Date Filter - the all-time sentinels from filter_header.php leave the fields blank
|
||||
$date_from_filter = (!empty($_GET['dtf']) && $_GET['dtf'] !== '1970-01-01') ? escapeHtml($_GET['dtf']) : '';
|
||||
$date_to_filter = (!empty($_GET['dtt']) && $_GET['dtt'] !== '2099-12-31') ? escapeHtml($_GET['dtt']) : '';
|
||||
@@ -45,6 +48,17 @@ ob_start();
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label>Category</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-list"></i></span>
|
||||
<select class="form-select select2" name="category">
|
||||
<option value="">- Any category -</option>
|
||||
<?= categoryFilterOptionsHtml('Income', $category_filter, "SELECT DISTINCT quote_category_id FROM quotes") ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label>Dated From</label>
|
||||
<div class="input-group">
|
||||
|
||||
@@ -95,7 +95,7 @@ ob_start();
|
||||
</div>
|
||||
<div class="itflow-glance-item" title="Category">
|
||||
<i class="fas fa-fw fa-list"></i>
|
||||
<span><?= expenseCategoryDot($row['category_color']) ?><?= escapeHtml($row['category_name'] ?: 'No category') ?></span>
|
||||
<span><?= expenseCategoryDot($row['category_color'], $row['category_icon'] ?? '') ?><?= escapeHtml($row['category_name'] ?: 'No category') ?></span>
|
||||
</div>
|
||||
<?php if ($row['recurring_expense_reference']) { ?>
|
||||
<div class="itflow-glance-item" title="Reference">
|
||||
|
||||
@@ -17,6 +17,9 @@ $q_filter = $_GET['q'] ?? '';
|
||||
// Status Filter
|
||||
$status_filter = $_GET['status'] ?? '';
|
||||
|
||||
// Category Filter
|
||||
$category_filter = intval($_GET['category'] ?? 0);
|
||||
|
||||
// Date Filter - the all-time sentinels from filter_header.php leave the fields blank
|
||||
$date_from_filter = (!empty($_GET['dtf']) && $_GET['dtf'] !== '1970-01-01') ? escapeHtml($_GET['dtf']) : '';
|
||||
$date_to_filter = (!empty($_GET['dtt']) && $_GET['dtt'] !== '2099-12-31') ? escapeHtml($_GET['dtt']) : '';
|
||||
@@ -60,6 +63,17 @@ ob_start();
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label>Category</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-list"></i></span>
|
||||
<select class="form-select select2" name="category">
|
||||
<option value="">- Any category -</option>
|
||||
<?= categoryFilterOptionsHtml('Income', $category_filter, "SELECT DISTINCT recurring_invoice_category_id FROM recurring_invoices WHERE recurring_invoice_archived_at IS NULL") ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label>Created From</label>
|
||||
<div class="input-group">
|
||||
|
||||
@@ -70,7 +70,7 @@ ob_start();
|
||||
<div class="itflow-glance-item" title="Category">
|
||||
<i class="fas fa-fw fa-tag"></i>
|
||||
<?php if (intval($row['revenue_category_id']) && $row['category_name'] !== null) { ?>
|
||||
<a class="text-reset text-truncate" href="income.php?category=<?= intval($row['revenue_category_id']) ?>"><?= expenseCategoryDot($row['category_color']) ?><?= escapeHtml($row['category_name']) ?></a>
|
||||
<a class="text-reset text-truncate" href="income.php?category=<?= intval($row['revenue_category_id']) ?>"><?= expenseCategoryDot($row['category_color'], $row['category_icon'] ?? '') ?><?= escapeHtml($row['category_name']) ?></a>
|
||||
<?php } else { ?>
|
||||
<span class="text-warning-emphasis">No category - the reports show it as No category</span>
|
||||
<?php } ?>
|
||||
|
||||
@@ -27,6 +27,7 @@ $archived_filter = (isset($_GET['archived']) && $_GET['archived'] == 1) ? 1 : 0;
|
||||
$status_filters = softwareStatusFilters();
|
||||
$status_filter = isset($status_filters[$_GET['status'] ?? '']) ? $_GET['status'] : '';
|
||||
$license_type_filter = (string) ($_GET['license_type'] ?? '');
|
||||
$software_type_filter = trim(strip_tags((string) ($_GET['software_type'] ?? '')));
|
||||
$tag_filter = tagFilterIds();
|
||||
|
||||
ob_start();
|
||||
@@ -105,6 +106,17 @@ ob_start();
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label>Software Type</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-layer-group"></i></span>
|
||||
<select class="form-select select2" name="software_type">
|
||||
<option value="">- Any -</option>
|
||||
<?= categoryFilterOptionsHtml('software_type', $software_type_filter, "SELECT DISTINCT software_type FROM software WHERE software_type IS NOT NULL AND software_type <> ''" . ($client_id ? " AND software_client_id = $client_id" : '') . clientScopeSql('software_client_id')) ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label>License Type</label>
|
||||
<div class="input-group">
|
||||
|
||||
@@ -18,7 +18,7 @@ $ticket_id = intval($_GET['id'] ?? 0);
|
||||
$ticket = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT tickets.*, client_name, contact_name, contact_email, contact_photo, contact_title,
|
||||
contact_phone, contact_phone_country_code, contact_extension, contact_mobile, contact_mobile_country_code,
|
||||
ticket_status_name, ticket_status_color, ticket_status_pauses_sla, user_name, user_avatar, asset_name, location_name,
|
||||
vendor_name, category_name, category_color, project_prefix, project_number, project_name, project_client_id, sla_name,
|
||||
vendor_name, category_name, category_color, category_icon, project_prefix, project_number, project_name, project_client_id, sla_name,
|
||||
" . ticketLastSpokeSql() . " AS ticket_last_spoke
|
||||
FROM tickets
|
||||
LEFT JOIN clients ON client_id = ticket_client_id
|
||||
@@ -167,7 +167,7 @@ ob_start();
|
||||
|
||||
<?php if ($ticket['category_name'] !== null && $ticket['category_name'] !== '') { ?>
|
||||
<dt>Category</dt>
|
||||
<dd><i class="fas fa-circle itflow-ticket-dot" <?= preg_match('/^#[0-9a-f]{3,8}$/i', (string) $ticket['category_color']) ? 'style="color: ' . $ticket['category_color'] . '"' : '' ?>></i><?= escapeHtml($ticket['category_name']) ?></dd>
|
||||
<dd><?= categoryMarkHtml($ticket['category_color'], $ticket['category_icon'] ?? '', '<i class="fas fa-circle itflow-ticket-dot"%s aria-hidden="true"></i>') ?><?= escapeHtml($ticket['category_name']) ?></dd>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (!empty($ticket['ticket_schedule'])) { ?>
|
||||
|
||||
@@ -144,16 +144,7 @@ ob_start();
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-list"></i></span>
|
||||
<select class="form-select select2" name="category">
|
||||
<option value="">- All Categories -</option>
|
||||
<?php
|
||||
$sql_category_filter = mysqli_query($mysqli, "SELECT category_id, category_name, category_color, category_icon FROM categories WHERE category_type = 'Ticket' ORDER BY category_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_category_filter)) {
|
||||
$filter_option_id = intval($row['category_id']);
|
||||
$filter_option_name = escapeHtml($row['category_name']);
|
||||
?>
|
||||
<option <?php if ($category_filter == $filter_option_id) { echo "selected"; } ?> value="<?= $filter_option_id ?>"<?= selectOptionColor($row['category_color'] ?? '', $row['category_icon'] ?? '') ?>><?= $filter_option_name ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<?= categoryFilterOptionsHtml('Ticket', $category_filter, "SELECT DISTINCT ticket_category FROM tickets WHERE ticket_category <> ''") ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1214,6 +1214,16 @@ if (isExportRequest('export_assets')) {
|
||||
$location_query = '';
|
||||
}
|
||||
|
||||
// Status Filter
|
||||
$status_filter = trim(strip_tags((string) ($_POST['status'] ?? '')));
|
||||
if ($status_filter !== '') {
|
||||
$status_query = "AND asset_status = '" . escapeSql($status_filter) . "'";
|
||||
$filter_summary['Status'] = $status_filter;
|
||||
} else {
|
||||
// Default - any
|
||||
$status_query = '';
|
||||
}
|
||||
|
||||
// Tags Filter
|
||||
if (isset($_POST['tags']) && is_array($_POST['tags']) && !empty($_POST['tags'])) {
|
||||
$tag_filter = implode(",", array_map('intval', $_POST['tags']));
|
||||
@@ -1266,6 +1276,7 @@ if (isExportRequest('export_assets')) {
|
||||
AND (asset_name LIKE '%$q%' OR asset_description LIKE '%$q%' OR asset_type LIKE '%$q%' OR interface_ip LIKE '%$q%' OR interface_ipv6 LIKE '%$q%' OR interface_mac LIKE '%$q%' OR asset_make LIKE '%$q%' OR asset_model LIKE '%$q%' OR asset_serial LIKE '%$q%' OR asset_os LIKE '%$q%' OR contact_name LIKE '%$q%' OR location_name LIKE '%$q%' OR client_name LIKE '%$q%' OR tag_name LIKE '%$q%')
|
||||
AND ($type_query)
|
||||
" . clientScopeSql('asset_client_id') . "
|
||||
$status_query
|
||||
$location_query
|
||||
$expire_query
|
||||
$client_query
|
||||
|
||||
@@ -487,16 +487,25 @@ if (isExportRequest('export_quotes')) {
|
||||
$filter_summary['Search'] = $_POST['q'];
|
||||
}
|
||||
|
||||
// Category Filter
|
||||
$category_query = '';
|
||||
if (!empty($_POST['category'])) {
|
||||
$filter_category_id = intval($_POST['category']);
|
||||
$category_query = "AND quote_category_id = $filter_category_id";
|
||||
$filter_summary['Category'] = getFieldById('categories', $filter_category_id, 'category_name');
|
||||
}
|
||||
|
||||
$sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT client_name, quote_id, quote_amount, quote_discount_amount, quote_monthly_amount, quote_date, quote_number, quote_prefix, quote_scope,
|
||||
quote_status FROM quotes
|
||||
quote_status, category_name FROM quotes
|
||||
LEFT JOIN clients ON quote_client_id = client_id
|
||||
LEFT JOIN categories ON quote_category_id = category_id
|
||||
WHERE (CONCAT(quote_prefix,quote_number) LIKE '%$q%' OR quote_scope LIKE '%$q%' OR category_name LIKE '%$q%' OR quote_status LIKE '%$q%' OR quote_amount LIKE '%$q%' OR client_name LIKE '%$q%')
|
||||
AND DATE(quote_date) BETWEEN '$dtf' AND '$dtt'
|
||||
" . clientScopeSql('quote_client_id') . "
|
||||
$client_query
|
||||
$category_query
|
||||
ORDER BY quote_number ASC"
|
||||
);
|
||||
|
||||
|
||||
@@ -358,17 +358,26 @@ if (isExportRequest('export_recurring_invoices')) {
|
||||
$filter_summary['Search'] = $_POST['q'];
|
||||
}
|
||||
|
||||
// Category Filter
|
||||
$category_query = '';
|
||||
if (!empty($_POST['category'])) {
|
||||
$filter_category_id = intval($_POST['category']);
|
||||
$category_query = "AND recurring_invoice_category_id = $filter_category_id";
|
||||
$filter_summary['Category'] = getFieldById('categories', $filter_category_id, 'category_name');
|
||||
}
|
||||
|
||||
$sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT client_name, recurring_invoice_id, recurring_invoice_amount, recurring_invoice_created_at,
|
||||
recurring_invoice_frequency, recurring_invoice_number, recurring_invoice_prefix,
|
||||
recurring_invoice_scope FROM recurring_invoices
|
||||
recurring_invoice_scope, category_name FROM recurring_invoices
|
||||
LEFT JOIN clients ON recurring_invoice_client_id = client_id
|
||||
LEFT JOIN categories ON recurring_invoice_category_id = category_id
|
||||
WHERE (CONCAT(recurring_invoice_prefix,recurring_invoice_number) LIKE '%$q%' OR recurring_invoice_frequency LIKE '%$q%' OR recurring_invoice_scope LIKE '%$q%' OR client_name LIKE '%$q%' OR category_name LIKE '%$q%')
|
||||
AND DATE(recurring_invoice_created_at) BETWEEN '$dtf' AND '$dtt'
|
||||
$status_query
|
||||
$client_query
|
||||
$category_query
|
||||
" . clientScopeSql('recurring_invoice_client_id') . "
|
||||
ORDER BY recurring_invoice_number ASC"
|
||||
);
|
||||
|
||||
@@ -505,6 +505,14 @@ if (isExportRequest('export_software')) {
|
||||
$filter_summary['Showing'] = $status_filters[$status]['label'];
|
||||
}
|
||||
|
||||
// Software type
|
||||
$software_type_filter = trim(strip_tags((string) ($_POST['software_type'] ?? '')));
|
||||
$software_type_query = '';
|
||||
if ($software_type_filter !== '') {
|
||||
$software_type_query = "AND software_type = '" . escapeSql($software_type_filter) . "'";
|
||||
$filter_summary['Software Type'] = $software_type_filter;
|
||||
}
|
||||
|
||||
// License type
|
||||
$license_type_query = '';
|
||||
if (!empty($_POST['license_type'])) {
|
||||
@@ -547,6 +555,7 @@ if (isExportRequest('export_software')) {
|
||||
$tag_query
|
||||
$expire_query
|
||||
$status_query
|
||||
$software_type_query
|
||||
$license_type_query
|
||||
ORDER BY software_name ASC"
|
||||
);
|
||||
|
||||
@@ -246,13 +246,7 @@ $add_type = in_array($view, ['product', 'hardware', 'stocked', 'reorder'], true)
|
||||
<div class="col-lg-3 col-md-6">
|
||||
<select class="form-select select2" name="category" onchange="this.form.submit()" aria-label="Category">
|
||||
<option value="">- All Categories -</option>
|
||||
<?php
|
||||
$sql_categories_filter = mysqli_query($mysqli, "SELECT category_id, category_name, category_color, category_icon FROM categories
|
||||
WHERE category_type = 'Income' AND EXISTS (SELECT 1 FROM products WHERE product_category_id = category_id AND product_$archive_query) ORDER BY category_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_categories_filter)) {
|
||||
$category_option_id = intval($row['category_id']); ?>
|
||||
<option <?= $category_filter === $category_option_id ? 'selected' : '' ?> value="<?= $category_option_id ?>"<?= selectOptionColor($row['category_color'] ?? '', $row['category_icon'] ?? '') ?>><?= escapeHtml($row['category_name']) ?></option>
|
||||
<?php } ?>
|
||||
<?= categoryFilterOptionsHtml('Income', $category_filter, "SELECT DISTINCT product_category_id FROM products WHERE product_$archive_query") ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-6">
|
||||
|
||||
@@ -41,6 +41,10 @@ if (!$client_url && !empty($_GET['client'])) {
|
||||
$client_query = "AND quote_client_id = $client";
|
||||
}
|
||||
|
||||
// Category Filter
|
||||
$category_filter = intval($_GET['category'] ?? 0);
|
||||
$category_query = $category_filter ? "AND quote_category_id = $category_filter" : '';
|
||||
|
||||
$unanswered_sql = "quote_status IN ('Draft', 'Sent', 'Viewed')";
|
||||
$statuses = [
|
||||
'' => ['label' => 'All', 'where' => ''],
|
||||
@@ -63,7 +67,7 @@ if (!isset($sortable_columns[$sort])) {
|
||||
$scope_query = clientScopeSql('quote_client_id');
|
||||
$search_query = "AND (CONCAT(quote_prefix, quote_number) LIKE '%$q%' OR quote_scope LIKE '%$q%' OR category_name LIKE '%$q%' OR quote_status LIKE '%$q%' OR quote_amount LIKE '%$q%' OR client_name LIKE '%$q%')";
|
||||
$date_query = "AND DATE(quote_date) BETWEEN '$dtf' AND '$dtt'";
|
||||
$filters = "$scope_query $client_query $date_query $search_query";
|
||||
$filters = "$scope_query $client_query $category_query $date_query $search_query";
|
||||
$joins = "LEFT JOIN clients ON quote_client_id = client_id LEFT JOIN categories ON quote_category_id = category_id";
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS quotes.*, client_name, category_name
|
||||
@@ -162,7 +166,7 @@ $stat_monthly = function ($amount) use ($stat_money) {
|
||||
<?php if ($num_rows[0] > 0) { ?>
|
||||
<button type="button" class="btn btn-primary dropdown-toggle <?= $can_edit ? 'dropdown-toggle-split' : '' ?>" data-bs-toggle="dropdown"><?= $can_edit ? '' : '<i class="fas fa-ellipsis-h"></i>' ?></button>
|
||||
<div class="dropdown-menu dropdown-menu-end">
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-url="<?= buildExportModalUrl('modals/quote/quote_export.php', ['client_id', 'q'], ['dtf' => $dtf, 'dtt' => $dtt, 'client_id' => $client ?: '']) ?>">
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-url="<?= buildExportModalUrl('modals/quote/quote_export.php', ['client_id', 'category', 'q'], ['dtf' => $dtf, 'dtt' => $dtt, 'client_id' => $client ?: '']) ?>">
|
||||
<i class="fa fa-fw fa-download text-secondary me-2"></i>Export
|
||||
</a>
|
||||
</div>
|
||||
@@ -190,6 +194,12 @@ $stat_monthly = function ($amount) use ($stat_money) {
|
||||
<input type="hidden" name="dtf" id="dtf" value="<?= escapeHtml($dtf ?? '') ?>">
|
||||
<input type="hidden" name="dtt" id="dtt" value="<?= escapeHtml($dtt ?? '') ?>">
|
||||
</div>
|
||||
<div class="<?= $client_url ? 'col-lg-4' : 'col-lg-2' ?> col-md-6">
|
||||
<select class="form-select select2" name="category" onchange="this.form.submit()" aria-label="Category">
|
||||
<option value="">- Any category -</option>
|
||||
<?= categoryFilterOptionsHtml('Income', $category_filter, "SELECT DISTINCT quote_category_id FROM quotes") ?>
|
||||
</select>
|
||||
</div>
|
||||
<?php if (!$client_url) { ?>
|
||||
<div class="col-lg-3 col-md-6">
|
||||
<select class="form-select select2" name="client" onchange="this.form.submit()">
|
||||
|
||||
@@ -52,6 +52,10 @@ if ($client_url && !empty($_GET['location'])) {
|
||||
$location_query = "AND rack_location_id = $location_filter";
|
||||
}
|
||||
|
||||
// Type filter - the rack types (Admin > Categories), held by name
|
||||
$type_filter = trim(strip_tags((string) ($_GET['type'] ?? '')));
|
||||
$type_query = $type_filter !== '' ? "AND rack_type = '" . escapeSql($type_filter) . "'" : '';
|
||||
|
||||
// Only these sort - filter_header.php will hand through any lowercase word
|
||||
if (!in_array($sort, ['rack_name', 'rack_units', 'client_name', 'location_name', 'rack_created_at'], true)) {
|
||||
$sort = 'rack_name';
|
||||
@@ -72,6 +76,7 @@ $sql = mysqli_query(
|
||||
" . clientScopeSql('rack_client_id') . "
|
||||
$client_query
|
||||
$location_query
|
||||
$type_query
|
||||
ORDER BY $sort $order LIMIT $record_from, $record_to"
|
||||
);
|
||||
|
||||
@@ -117,7 +122,7 @@ foreach ($racks as $rack_id => $row) {
|
||||
<input type="hidden" name="archived" value="<?= $archived ?>">
|
||||
<div class="row g-2 align-items-center">
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="col-lg-3 col-md-4">
|
||||
<div class="input-group">
|
||||
<input type="search" class="form-control" name="q" value="<?php if (isset($q)) { echo stripslashes(escapeHtml($q)); } ?>" placeholder="Search racks and what's in them">
|
||||
<button class="btn btn-dark" title="Search"><i class="fa fa-search"></i></button>
|
||||
@@ -125,7 +130,7 @@ foreach ($racks as $rack_id => $row) {
|
||||
</div>
|
||||
|
||||
<?php if ($client_url) { ?>
|
||||
<div class="col-md-3">
|
||||
<div class="col-lg-2 col-md-4">
|
||||
<select class="form-select select2" name="location" onchange="this.form.submit()">
|
||||
<option value="">- All Locations -</option>
|
||||
<?php
|
||||
@@ -141,7 +146,7 @@ foreach ($racks as $rack_id => $row) {
|
||||
</select>
|
||||
</div>
|
||||
<?php } else { ?>
|
||||
<div class="col-md-3">
|
||||
<div class="col-lg-2 col-md-4">
|
||||
<select class="form-select select2" name="client" onchange="this.form.submit()">
|
||||
<option value="">- All Clients -</option>
|
||||
<?php
|
||||
@@ -159,13 +164,23 @@ foreach ($racks as $rack_id => $row) {
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="col-md-5 d-flex align-items-center justify-content-md-end gap-3">
|
||||
<div class="col-lg-2 col-md-4">
|
||||
<select class="form-select select2" name="type" onchange="this.form.submit()">
|
||||
<option value="">- All Types -</option>
|
||||
<?= categoryFilterOptionsHtml('rack_type', $type_filter, "SELECT DISTINCT rack_type FROM racks
|
||||
LEFT JOIN clients ON client_id = rack_client_id
|
||||
WHERE rack_type IS NOT NULL AND rack_type <> '' AND $archive_query
|
||||
" . clientScopeSql('rack_client_id') . " $client_query") ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-5 col-md-12 d-flex align-items-center justify-content-md-end gap-3">
|
||||
<?php if ($racks) { ?>
|
||||
<span class="small text-body-secondary d-none d-lg-inline">
|
||||
<span class="small text-body-secondary d-none d-xl-inline">
|
||||
<?= number_format($total_used) ?> of <?= number_format($total_units) ?>U in use · <?= number_format($total_items) ?> items<?= intval($num_rows[0]) > count($racks) ? ' on this page' : '' ?>
|
||||
</span>
|
||||
<?php } ?>
|
||||
<a href="?<?= $client_url ?>archived=<?= $archived ? 0 : 1 ?>" class="btn btn-<?= $archived ? 'primary' : 'default' ?>">
|
||||
<a href="?<?= $client_url ?>archived=<?= $archived ? 0 : 1 ?>" class="btn btn-<?= $archived ? 'primary' : 'default' ?> text-nowrap">
|
||||
<i class="fa fa-fw fa-archive me-2"></i>Archived
|
||||
</a>
|
||||
</div>
|
||||
@@ -181,7 +196,7 @@ foreach ($racks as $rack_id => $row) {
|
||||
<?= emptyStateHtml([
|
||||
'thing' => 'racks',
|
||||
'icon' => 'fa-server',
|
||||
'filtered' => $q || $location_filter || $client_filter,
|
||||
'filtered' => $q || $location_filter || $client_filter || $type_filter !== '',
|
||||
'archived' => $archived,
|
||||
'text' => "Document the comms closet: what's racked where, front and rear, and how much room and power is left.",
|
||||
'actions' => $client_url && $can_edit ? [['label' => 'New Rack', 'modal' => "modals/rack/rack_add.php?client_id=$client_id", 'size' => 'lg']] : [],
|
||||
|
||||
@@ -45,7 +45,7 @@ $joins = "LEFT JOIN vendors ON recurring_expense_vendor_id = vendor_id
|
||||
$where = recurringExpenseFiltersSql($_GET);
|
||||
$monthly_sql = expenseRecurringMonthlySql();
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS recurring_expenses.*, vendor_name, vendor_archived_at, category_name, category_color, account_name, client_name,
|
||||
$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS recurring_expenses.*, vendor_name, vendor_archived_at, category_name, category_color, category_icon, account_name, client_name,
|
||||
$monthly_sql AS monthly, recurring_invoice_prefix, recurring_invoice_number
|
||||
FROM recurring_expenses $joins
|
||||
LEFT JOIN recurring_invoices ON recurring_invoice_id = recurring_expense_recurring_invoice_id
|
||||
@@ -174,13 +174,7 @@ $any_filter = $q || $vendor_filter || $category_filter || $client_filter;
|
||||
<div class="col-lg-3 col-md-6">
|
||||
<select class="form-select select2" name="category" onchange="this.form.submit()" aria-label="Category">
|
||||
<option value="">- Any category -</option>
|
||||
<?php
|
||||
$sql_filter = mysqli_query($mysqli, "SELECT category_id, category_name, category_color, category_icon FROM categories
|
||||
WHERE EXISTS (SELECT 1 FROM recurring_expenses WHERE recurring_expense_category_id = category_id AND recurring_expense_archived_at IS NULL) ORDER BY category_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_filter)) {
|
||||
$option_id = intval($row['category_id']); ?>
|
||||
<option <?= $category_filter === $option_id ? 'selected' : '' ?> value="<?= $option_id ?>"<?= selectOptionColor($row['category_color'] ?? '', $row['category_icon'] ?? '') ?>><?= escapeHtml($row['category_name']) ?></option>
|
||||
<?php } ?>
|
||||
<?= categoryFilterOptionsHtml('Expense', $category_filter, "SELECT DISTINCT recurring_expense_category_id FROM recurring_expenses WHERE recurring_expense_archived_at IS NULL") ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-6">
|
||||
@@ -241,7 +235,7 @@ $any_filter = $q || $vendor_filter || $category_filter || $client_filter;
|
||||
</div>
|
||||
<div class="small text-body-secondary text-truncate" style="max-width: 18rem;" title="<?= escapeHtml((string) $row['recurring_expense_description']) ?>"><?= escapeHtml((string) $row['recurring_expense_description']) ?: ' ' ?></div>
|
||||
</td>
|
||||
<td><div class="text-truncate" style="max-width: 11rem;" title="<?= escapeHtml((string) $row['category_name']) ?>"><?= expenseCategoryDot($row['category_color']) ?><?= escapeHtml($row['category_name'] ?: '-') ?></div></td>
|
||||
<td><div class="text-truncate" style="max-width: 11rem;" title="<?= escapeHtml((string) $row['category_name']) ?>"><?= expenseCategoryDot($row['category_color'], $row['category_icon'] ?? '') ?><?= escapeHtml($row['category_name'] ?: '-') ?></div></td>
|
||||
<td>
|
||||
<?php if (intval($row['recurring_expense_client_id'])) { ?>
|
||||
<div class="text-truncate" style="max-width: 10rem;"><a class="text-reset" href="<?= escapeHtml($filter_url(['client' => intval($row['recurring_expense_client_id'])])) ?>"><?= escapeHtml($row['client_name']) ?></a></div>
|
||||
|
||||
@@ -40,6 +40,10 @@ if (!$client_url && !empty($_GET['client'])) {
|
||||
$client_query = "AND recurring_invoice_client_id = $client";
|
||||
}
|
||||
|
||||
// Category Filter
|
||||
$category_filter = intval($_GET['category'] ?? 0);
|
||||
$category_query = $category_filter ? "AND recurring_invoice_category_id = $category_filter" : '';
|
||||
|
||||
$statuses = [
|
||||
'active' => ['label' => 'Active', 'icon' => 'fa-play', 'where' => 'recurring_invoice_status = 1'],
|
||||
'soon' => ['label' => 'Next 7 days', 'icon' => 'fa-calendar-day', 'where' => 'recurring_invoice_status = 1 AND recurring_invoice_next_date BETWEEN CURDATE() AND CURDATE() + INTERVAL 7 DAY',
|
||||
@@ -62,7 +66,7 @@ if (!isset($sortable_columns[$sort])) {
|
||||
$monthly_sql = recurringInvoiceMonthlySql();
|
||||
$scope_query = clientScopeSql('recurring_invoice_client_id');
|
||||
$search_query = "AND (CONCAT(recurring_invoice_prefix, recurring_invoice_number) LIKE '%$q%' OR recurring_invoice_frequency LIKE '%$q%' OR recurring_invoice_scope LIKE '%$q%' OR client_name LIKE '%$q%' OR category_name LIKE '%$q%')";
|
||||
$filters = "AND recurring_invoice_archived_at IS NULL $scope_query $client_query $search_query";
|
||||
$filters = "AND recurring_invoice_archived_at IS NULL $scope_query $client_query $category_query $search_query";
|
||||
$joins = "LEFT JOIN clients ON recurring_invoice_client_id = client_id LEFT JOIN categories ON recurring_invoice_category_id = category_id";
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS recurring_invoices.*, client_name, category_name, recurring_payment_id, $monthly_sql AS monthly
|
||||
@@ -153,7 +157,7 @@ $stat_money = function ($amount) use ($session_company_currency) {
|
||||
<?php if ($num_rows[0] > 0) { ?>
|
||||
<button type="button" class="btn btn-primary dropdown-toggle <?= $can_edit ? 'dropdown-toggle-split' : '' ?>" data-bs-toggle="dropdown"><?= $can_edit ? '' : '<i class="fas fa-ellipsis-h"></i>' ?></button>
|
||||
<div class="dropdown-menu dropdown-menu-end">
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-url="<?= buildExportModalUrl('modals/recurring_invoice/recurring_invoice_export.php', ['client_id', 'q'], ['status' => in_array($status, ['active', 'inactive'], true) ? $status : '', 'client_id' => $client ?: '']) ?>">
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-url="<?= buildExportModalUrl('modals/recurring_invoice/recurring_invoice_export.php', ['client_id', 'category', 'q'], ['status' => in_array($status, ['active', 'inactive'], true) ? $status : '', 'client_id' => $client ?: '']) ?>">
|
||||
<i class="fa fa-fw fa-download text-secondary me-2"></i>Export
|
||||
</a>
|
||||
</div>
|
||||
@@ -169,12 +173,18 @@ $stat_money = function ($amount) use ($session_company_currency) {
|
||||
<?php } ?>
|
||||
<input type="hidden" name="status" value="<?= escapeHtml($status) ?>">
|
||||
<div class="row g-2 align-items-center">
|
||||
<div class="<?= $client_url ? 'col-lg-6' : 'col-lg-5' ?> col-md-6">
|
||||
<div class="<?= $client_url ? 'col-lg-8' : 'col-lg-6' ?> 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 number, scope, client, category...">
|
||||
<button class="btn btn-dark" title="Search"><i class="fa fa-search"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="<?= $client_url ? 'col-lg-4' : 'col-lg-3' ?> col-md-6">
|
||||
<select class="form-select select2" name="category" onchange="this.form.submit()" aria-label="Category">
|
||||
<option value="">- Any category -</option>
|
||||
<?= categoryFilterOptionsHtml('Income', $category_filter, "SELECT DISTINCT recurring_invoice_category_id FROM recurring_invoices WHERE recurring_invoice_archived_at IS NULL") ?>
|
||||
</select>
|
||||
</div>
|
||||
<?php if (!$client_url) { ?>
|
||||
<div class="col-lg-3 col-md-6">
|
||||
<select class="form-select select2" name="client" onchange="this.form.submit()">
|
||||
|
||||
@@ -96,7 +96,7 @@ if (!isset($sortable_columns[$sort])) {
|
||||
}
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS recurring_tickets.*, client_name, contact_name, contact_photo, asset_name,
|
||||
category_name, category_color, user_name, user_avatar, ticket_template_name,
|
||||
category_name, category_color, category_icon, user_name, user_avatar, ticket_template_name,
|
||||
(SELECT COUNT(*) FROM recurring_ticket_tasks WHERE recurring_ticket_task_recurring_ticket_id = recurring_ticket_id) AS recurring_ticket_task_count
|
||||
FROM recurring_tickets $joins
|
||||
WHERE $filters $show_query
|
||||
@@ -183,13 +183,7 @@ $sort_link = function ($column, $label) use ($url_query_strings_sort, $sort, $di
|
||||
<div class="col-lg-2 col-md-6">
|
||||
<select class="form-select select2" name="category" onchange="this.form.submit()">
|
||||
<option value="">- Any category -</option>
|
||||
<?php
|
||||
$sql_categories_filter = mysqli_query($mysqli, "SELECT category_id, category_name, category_color, category_icon FROM categories
|
||||
WHERE category_type = 'Ticket' AND (EXISTS (SELECT 1 FROM recurring_tickets WHERE recurring_ticket_category = category_id) OR category_id = $category_filter) ORDER BY category_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_categories_filter)) {
|
||||
$category_id = intval($row['category_id']); ?>
|
||||
<option <?= $category_filter === $category_id ? 'selected' : '' ?> value="<?= $category_id ?>"<?= selectOptionColor($row['category_color'] ?? '', $row['category_icon'] ?? '') ?>><?= escapeHtml($row['category_name']) ?></option>
|
||||
<?php } ?>
|
||||
<?= categoryFilterOptionsHtml('Ticket', $category_filter, "SELECT DISTINCT recurring_ticket_category FROM recurring_tickets WHERE recurring_ticket_category <> ''") ?>
|
||||
</select>
|
||||
</div>
|
||||
<?php if (!$client_url) { ?>
|
||||
@@ -297,7 +291,6 @@ $sort_link = function ($column, $label) use ($url_query_strings_sort, $sort, $di
|
||||
$paused = recurringTicketPaused($row);
|
||||
$last = $last_tickets[$recurring_ticket_id] ?? null;
|
||||
$edit_url = "modals/recurring_ticket/recurring_ticket_edit.php?id=$recurring_ticket_id";
|
||||
$category_color = preg_match('/^#[0-9a-f]{3,8}$/i', (string) $row['category_color']) ? $row['category_color'] : '';
|
||||
$task_count = intval($row['recurring_ticket_task_count']);
|
||||
$next = recurringTicketNextRunText($row);
|
||||
$assignee = formatAssignee($row['recurring_ticket_assigned_to'], $row['user_name'], $row['user_avatar'], !$paused);
|
||||
@@ -319,7 +312,7 @@ $sort_link = function ($column, $label) use ($url_query_strings_sort, $sort, $di
|
||||
<div class="itflow-ticket-meta small text-body-secondary">
|
||||
<?= ticketPriorityHtml($row['recurring_ticket_priority'], 'detail') ?>
|
||||
<?php if ($row['category_name'] !== null && $row['category_name'] !== '') { ?>
|
||||
<span class="text-nowrap"><i class="fas fa-circle itflow-ticket-dot" <?= $category_color ? 'style="color: ' . $category_color . '"' : '' ?>></i><?= escapeHtml($row['category_name']) ?></span>
|
||||
<span class="text-nowrap"><?= categoryMarkHtml($row['category_color'], $row['category_icon'] ?? '', '<i class="fas fa-circle itflow-ticket-dot"%s aria-hidden="true"></i>') ?><?= escapeHtml($row['category_name']) ?></span>
|
||||
<?php } ?>
|
||||
<?php if (!empty($row['asset_name'])) { ?>
|
||||
<span class="text-nowrap text-truncate itflow-ticket-asset"><i class="fas fa-desktop me-1"></i><?= escapeHtml($row['asset_name']) ?></span>
|
||||
|
||||
@@ -70,6 +70,10 @@ $tag_query = tagFilterSql('license', $tag_filter_ids, 'software.software_id');
|
||||
$license_type_filter = (string) ($_GET['license_type'] ?? '');
|
||||
$license_type_query = $license_type_filter !== '' ? "AND software_license_type = '" . escapeSql($license_type_filter) . "'" : '';
|
||||
|
||||
// Software type filter - the software types (Admin > Categories), held by name
|
||||
$software_type_filter = trim(strip_tags((string) ($_GET['software_type'] ?? '')));
|
||||
$software_type_query = $software_type_filter !== '' ? "AND software_type = '" . escapeSql($software_type_filter) . "'" : '';
|
||||
|
||||
// Expiring In Filter - the dashboard links here with expire_days=30
|
||||
if (!empty($_GET['expire_days'])) {
|
||||
if ($_GET['expire_days'] == "expired") {
|
||||
@@ -110,7 +114,7 @@ $order_by = $sort === 'software_expire' ? "software_expire IS NULL, software_exp
|
||||
|
||||
$seats_used_sql = softwareSeatsUsedSql('software.software_id');
|
||||
|
||||
// Tab counts - within the client, tag and archive scope, before the search narrows it
|
||||
// Tab counts - within the client, type, 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";
|
||||
@@ -123,6 +127,8 @@ $row = mysqli_fetch_assoc(mysqli_query($mysqli, "
|
||||
" . clientScopeSql('software_client_id') . "
|
||||
$client_query
|
||||
$tag_query
|
||||
$software_type_query
|
||||
$license_type_query
|
||||
"));
|
||||
$tab_counts = ['' => intval($row['all_count'])];
|
||||
foreach (array_keys($status_filters) as $status_key) {
|
||||
@@ -148,6 +154,7 @@ $sql = mysqli_query(
|
||||
$client_query
|
||||
$tag_query
|
||||
$status_query
|
||||
$software_type_query
|
||||
$license_type_query
|
||||
$expire_query
|
||||
ORDER BY $order_by LIMIT $record_from, $record_to");
|
||||
@@ -192,7 +199,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', 'tags', 'expire_days', 'archived', 'q']) ?>">
|
||||
data-modal-url="<?= buildExportModalUrl('modals/software/software_export.php', ['client_id', 'client', 'status', 'software_type', 'license_type', 'tags', 'expire_days', 'archived', 'q']) ?>">
|
||||
<i class="fa fa-fw fa-download me-2"></i>Export
|
||||
</a>
|
||||
<?php } ?>
|
||||
@@ -230,14 +237,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="<?= $client_url ? 'col-lg-3' : 'col-lg-4' ?> col-md-6">
|
||||
<div class="<?= $client_url ? 'col-xl-3 col-lg-4' : 'col-lg-3' ?> 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, 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-4 col-md-6">
|
||||
<div class="col-lg-3 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
|
||||
@@ -258,7 +265,16 @@ while ($license_type_row = mysqli_fetch_row($sql_license_types)) {
|
||||
</select>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="<?= $client_url ? 'col-lg-2' : 'col-lg-4' ?> col-md-4">
|
||||
<div class="<?= $client_url ? 'col-xl col-lg-4' : 'col-lg-3' ?> col-md-6">
|
||||
<select class="form-select select2" name="software_type" onchange="this.form.submit()">
|
||||
<option value="">- Software Type -</option>
|
||||
<?= categoryFilterOptionsHtml('software_type', $software_type_filter, "SELECT DISTINCT software_type FROM software
|
||||
LEFT JOIN clients ON client_id = software_client_id
|
||||
WHERE software_type IS NOT NULL AND software_type <> '' AND $archive_query
|
||||
" . clientScopeSql('software_client_id') . " $client_query") ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="<?= $client_url ? 'col-xl col-lg-4' : 'col-lg-3' ?> col-md-6">
|
||||
<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) { ?>
|
||||
@@ -266,7 +282,7 @@ while ($license_type_row = mysqli_fetch_row($sql_license_types)) {
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="<?= $client_url ? 'col-lg-2' : 'col-lg-3' ?> col-md-4">
|
||||
<div class="<?= $client_url ? 'col-xl col-lg-3' : 'col-lg-3' ?> col-md-6">
|
||||
<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>
|
||||
@@ -275,19 +291,19 @@ while ($license_type_row = mysqli_fetch_row($sql_license_types)) {
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="<?= $client_url ? 'col-lg-2' : 'col-lg-3' ?> col-md-4">
|
||||
<div class="<?= $client_url ? 'col-xl col-lg-3' : 'col-lg-3' ?> col-md-6">
|
||||
<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">
|
||||
<div class="<?= $client_url ? 'col-xl col-lg-3' : 'col-lg-3' ?> col-md-6">
|
||||
<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="<?= $client_url ? 'col-lg-1' : 'col-lg-3' ?> col-md-12">
|
||||
<div class="<?= $client_url ? 'col-xl-auto col-lg-3' : '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' ?>">
|
||||
|
||||
@@ -1051,7 +1051,7 @@ if (isset($_GET['ticket_id'])) {
|
||||
<div class="ticket-prop">
|
||||
<dt>Category</dt>
|
||||
<dd>
|
||||
<?php $category_value = $ticket_category ? $ticket_category_display : "<span class='text-muted'>None</span>"; ?>
|
||||
<?php $category_value = $ticket_category ? categoryMarkHtml($ticket['category_color'] ?? '', $ticket['category_icon'] ?? '', '<i class="fas fa-circle itflow-ticket-dot"%s aria-hidden="true"></i>') . $ticket_category_display : "<span class='text-muted'>None</span>"; ?>
|
||||
<?php if ($can_change_fields) { ?>
|
||||
<a href="#" class="ticket-prop-edit ajax-modal" data-modal-url="modals/ticket/ticket_edit.php?id=<?= $ticket_id ?>" data-modal-size="lg" title="Change category">
|
||||
<span><?= $category_value ?></span>
|
||||
|
||||
@@ -123,7 +123,6 @@ $sort_link = function ($column, $label, $class = '') use ($url_query_strings_sor
|
||||
$attention = $is_open ? ticketAttention($sla, $due) : '';
|
||||
$schedule = $row['ticket_schedule'];
|
||||
$scheduled_today = $schedule && substr($schedule, 0, 10) === date('Y-m-d');
|
||||
$category_color = preg_match('/^#[0-9a-f]{3,8}$/i', (string) $row['category_color']) ? $row['category_color'] : '';
|
||||
$ticket_invoice_id = intval($row['ticket_invoice_id']);
|
||||
$ticket_quote_id = intval($row['ticket_quote_id']);
|
||||
|
||||
@@ -152,7 +151,7 @@ $sort_link = function ($column, $label, $class = '') use ($url_query_strings_sor
|
||||
<span title="Opened <?= escapeHtml($row['ticket_created_at']) ?>"><?= timeAgo($row['ticket_created_at']) ?></span>
|
||||
<?= ticketSourceIcon($row['ticket_source']) ?>
|
||||
<?php if ($row['category_name'] !== null && $row['category_name'] !== '') { ?>
|
||||
<span class="text-nowrap"><i class="fas fa-circle itflow-ticket-dot" <?= $category_color ? 'style="color: ' . $category_color . '"' : '' ?>></i><?= escapeHtml($row['category_name']) ?></span>
|
||||
<span class="text-nowrap"><?= categoryMarkHtml($row['category_color'], $row['category_icon'] ?? '', '<i class="fas fa-circle itflow-ticket-dot"%s aria-hidden="true"></i>') ?><?= escapeHtml($row['category_name']) ?></span>
|
||||
<?php } ?>
|
||||
<?php if (!empty($row['asset_name'])) { ?>
|
||||
<span class="text-nowrap text-truncate itflow-ticket-asset" title="Asset"><i class="fas fa-desktop me-1"></i><?= escapeHtml($row['asset_name']) ?></span>
|
||||
|
||||
@@ -248,7 +248,7 @@ $ticket_select_columns =
|
||||
ticket_response_sla_alert_stage, ticket_resolution_sla_alert_stage,
|
||||
ticket_status_id, ticket_status_name, ticket_status_color, ticket_status_pauses_sla,
|
||||
client_name, contact_id, contact_name, contact_email, contact_photo,
|
||||
user_name, user_avatar, asset_name, category_name, category_color, project_prefix, project_number, project_name,
|
||||
user_name, user_avatar, asset_name, category_name, category_color, category_icon, project_prefix, project_number, project_name,
|
||||
" . ticketLastSpokeSql() . " AS ticket_last_spoke";
|
||||
|
||||
$ticket_joins =
|
||||
@@ -444,12 +444,7 @@ $export_extra = [
|
||||
<label class="form-label small text-body-secondary mb-1">Category</label>
|
||||
<select onchange="this.form.submit()" class="form-select select2" name="category">
|
||||
<option value="">Any category</option>
|
||||
<?php
|
||||
$sql_categories_filter = mysqli_query($mysqli, "SELECT category_id, category_name, category_color, category_icon FROM categories WHERE category_type = 'Ticket' AND (category_archived_at IS NULL OR category_id = $category_filter) ORDER BY category_name");
|
||||
while ($row = mysqli_fetch_assoc($sql_categories_filter)) {
|
||||
$filter_category_id = intval($row['category_id']); ?>
|
||||
<option value="<?= $filter_category_id ?>" <?= $category_filter === $filter_category_id ? 'selected' : '' ?><?= selectOptionColor($row['category_color'] ?? '', $row['category_icon'] ?? '') ?>><?= escapeHtml($row['category_name']) ?></option>
|
||||
<?php } ?>
|
||||
<?= categoryFilterOptionsHtml('Ticket', $category_filter, "SELECT DISTINCT ticket_category FROM tickets WHERE ticket_category <> ''") ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-6">
|
||||
|
||||
@@ -397,7 +397,7 @@ if ($transfer_cards) {
|
||||
<?php if ($transfer) { ?>
|
||||
<span class="small text-body-secondary" title="Money moved between your accounts - not income or spending">Transfer</span>
|
||||
<?php } elseif (intval($row['txn_category_id']) && $row['category_name'] !== null) { ?>
|
||||
<div class="text-truncate" style="max-width: 11rem;" title="<?= escapeHtml($row['category_name']) ?>"><?= expenseCategoryDot($row['category_color']) ?><?= escapeHtml($row['category_name']) ?></div>
|
||||
<div class="text-truncate" style="max-width: 11rem;" title="<?= escapeHtml($row['category_name']) ?>"><?= expenseCategoryDot($row['category_color'], $row['category_icon'] ?? '') ?><?= escapeHtml($row['category_name']) ?></div>
|
||||
<?php } else { ?>
|
||||
<span class="text-body-secondary">-</span>
|
||||
<?php } ?>
|
||||
|
||||
83
api/v1/categories/categories_model.php
Normal file
83
api/v1/categories/categories_model.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* API - Categories - what read.php uses. A kind of category belongs to the
|
||||
* modules whose records hold it (categoryKinds() in functions/categories.php):
|
||||
* expense categories to Financial, ticket categories and asset statuses to
|
||||
* Support, referrals to Clients, and so on. A key's user with any one of a
|
||||
* kind's modules can read that kind.
|
||||
*/
|
||||
|
||||
isset($mysqli) || die("Direct file access is not allowed");
|
||||
|
||||
/* Whether the key's user can read a kind's categories. */
|
||||
function categoryApiCanRead($kind) {
|
||||
$config = categoryKind($kind);
|
||||
foreach ($config['modules'] ?? [] as $module) {
|
||||
if (lookupUserPermission($module) >= 1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* The kinds the key's user can read - category_type values, in Admin > Categories' order. */
|
||||
function categoryApiReadableKinds() {
|
||||
return array_values(array_filter(array_keys(categoryKinds()), 'categoryApiCanRead'));
|
||||
}
|
||||
|
||||
/*
|
||||
* The kind asked for - its category_type ("Expense", "asset_status") or what
|
||||
* Admin > Categories calls it ("Asset Status"), in any case - when the key's
|
||||
* user can read it. Refuses the call otherwise.
|
||||
*/
|
||||
function categoryApiKind($value) {
|
||||
$key = str_replace([' ', '-'], '_', strtolower(trim((string) $value)));
|
||||
foreach (categoryKinds() as $kind => $config) {
|
||||
if ($key === strtolower($kind) || $key === str_replace(' ', '_', strtolower($config['label']))) {
|
||||
if (!categoryApiCanRead($kind)) {
|
||||
apiDeny("The user linked to this API key does not have permission for " . $config['many'] . ".");
|
||||
}
|
||||
return $kind;
|
||||
}
|
||||
}
|
||||
apiDeny("Unknown kind - one of " . implode(', ', array_keys(categoryKinds())) . ".");
|
||||
}
|
||||
|
||||
/*
|
||||
* One category as the API gives it. $usage: categoryUsage() for its kind -
|
||||
* or null when the key's user can't see every client, as the counts take in
|
||||
* every client's records - for category_used (how many records have it,
|
||||
* archived ones too) and category_used_by (that, by table).
|
||||
*/
|
||||
function categoryApiRow(array $row, $usage) {
|
||||
$config = categoryKind($row['category_type']);
|
||||
$used = null;
|
||||
$used_by = null;
|
||||
if ($usage !== null) {
|
||||
$mine = $usage[intval($row['category_id'])] ?? ['all' => 0, 'uses' => []];
|
||||
$used = intval($mine['all']);
|
||||
$used_by = [];
|
||||
foreach ($config['uses'] ?? [] as $index => $use) {
|
||||
if (!empty($mine['uses'][$index]['all'])) {
|
||||
$used_by[$use['table']] = intval($mine['uses'][$index]['all']);
|
||||
}
|
||||
}
|
||||
// {} rather than [] when nothing has it
|
||||
$used_by = (object) $used_by;
|
||||
}
|
||||
return [
|
||||
'category_id' => intval($row['category_id']),
|
||||
'category_name' => $row['category_name'],
|
||||
'category_description' => $row['category_description'] ?? null,
|
||||
'category_type' => $row['category_type'],
|
||||
'category_color' => categoryColor($row['category_color'] ?? '') ?: null,
|
||||
'category_icon' => categoryIcon($row['category_icon'] ?? '') ?: null,
|
||||
'category_order' => intval($row['category_order']),
|
||||
'category_created_at' => $row['category_created_at'],
|
||||
'category_updated_at' => $row['category_updated_at'] ?? null,
|
||||
'category_archived_at' => $row['category_archived_at'] ?? null,
|
||||
'category_used' => $used,
|
||||
'category_used_by' => $used_by,
|
||||
];
|
||||
}
|
||||
86
api/v1/categories/read.php
Normal file
86
api/v1/categories/read.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* API - Categories - Read
|
||||
* GET /api/v1/categories/read.php
|
||||
*
|
||||
* The categories set up in Admin > Categories, or one of them. Read only -
|
||||
* categories are changed in Admin > Categories.
|
||||
*
|
||||
* Parameters (GET):
|
||||
* api_key required - Your API key
|
||||
* kind optional - Expense, Income, Referral, Ticket, network_interface,
|
||||
* asset_status, software_type, rack_type,
|
||||
* contact_note_type or asset_note_type (or what
|
||||
* Admin > Categories calls it - "Asset Status"),
|
||||
* in any case
|
||||
* category_id optional - One category, archived or not
|
||||
* category_name optional - Categories with this name, in any case
|
||||
* archived optional - 1 to include archived categories in the list
|
||||
* limit optional - Max rows to return (default 50)
|
||||
* offset optional - Offset for pagination (default 0)
|
||||
*
|
||||
* Each category: category_id, category_name, category_description,
|
||||
* category_type (its kind, as above), category_color (#rrggbb or null),
|
||||
* category_icon (a Font Awesome name, or null), category_order (the order
|
||||
* pickers list it in, for the kinds that are put in order), category_created_at,
|
||||
* category_updated_at, category_archived_at, and category_used - how many
|
||||
* records have it, archived ones too - with category_used_by, that by table
|
||||
* ({"expenses": 42, "budget": 2}). The counts take in every client's records,
|
||||
* so they are null for a key whose user can't see every client.
|
||||
*
|
||||
* Only the kinds whose records the key's user can read - expense categories
|
||||
* need Financial, income categories Sales or Financial, referrals and contact
|
||||
* note types Clients, the rest Support.
|
||||
*/
|
||||
|
||||
require_once '../validate_api_key.php';
|
||||
|
||||
require_once '../require_get_method.php';
|
||||
|
||||
require_once 'categories_model.php';
|
||||
|
||||
$category_columns = 'category_id, category_name, category_description, category_type, category_color, category_icon, category_order,
|
||||
category_created_at, category_updated_at, category_archived_at';
|
||||
|
||||
$kinds = isset($_GET['kind']) ? [categoryApiKind($_GET['kind'])] : categoryApiReadableKinds();
|
||||
$where = "category_type IN ('" . implode("', '", array_map('escapeSql', $kinds ?: ['-'])) . "')";
|
||||
|
||||
if (isset($_GET['category_id'])) {
|
||||
$where .= ' AND category_id = ' . intval($_GET['category_id']);
|
||||
} else {
|
||||
if (isset($_GET['category_name'])) {
|
||||
$where .= " AND LOWER(category_name) = LOWER('" . escapeSql(trim($_GET['category_name'])) . "')";
|
||||
}
|
||||
if (intval($_GET['archived'] ?? 0) !== 1) {
|
||||
$where .= ' AND category_archived_at IS NULL';
|
||||
}
|
||||
}
|
||||
|
||||
// Kinds in Admin > Categories' order; within one, the order pickers list them in
|
||||
$all_kinds = array_keys(categoryKinds());
|
||||
$ordered_kinds = array_keys(array_filter(categoryKinds(), function ($config) {
|
||||
return $config['ordered'];
|
||||
}));
|
||||
$sql = mysqli_query($mysqli, "SELECT $category_columns FROM categories WHERE $where
|
||||
ORDER BY FIELD(category_type, '" . implode("', '", array_map('escapeSql', $all_kinds)) . "'),
|
||||
IF(category_type IN ('" . implode("', '", array_map('escapeSql', $ordered_kinds)) . "'), category_order, 0), category_name ASC, category_id ASC
|
||||
LIMIT $limit OFFSET $offset");
|
||||
|
||||
if ($sql && mysqli_num_rows($sql) > 0) {
|
||||
// The counts take in every client's records - only for a user who sees them all
|
||||
$see_all = clientScopeSql('category_id') === '';
|
||||
$usage = [];
|
||||
$rows = [];
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
if ($see_all && !isset($usage[$row['category_type']])) {
|
||||
$usage[$row['category_type']] = categoryUsage($row['category_type']);
|
||||
}
|
||||
$rows[] = categoryApiRow($row, $see_all ? $usage[$row['category_type']] : null);
|
||||
}
|
||||
echo json_encode(['success' => 'True', 'count' => count($rows), 'data' => $rows]);
|
||||
exit();
|
||||
}
|
||||
|
||||
// Output
|
||||
require_once "../read_output.php";
|
||||
@@ -152,6 +152,8 @@ $resource_module = [
|
||||
// Each kind of tag is its record's module - api/v1/tags/ checks the kind
|
||||
// asked about (tagApiKind()), so there is no one module to check here
|
||||
'tags' => '',
|
||||
// Likewise each kind of category - api/v1/categories/ checks the kind (categoryApiKind())
|
||||
'categories' => '',
|
||||
];
|
||||
|
||||
// Operation -> required permission level (read = 1, create/update = 2, delete = 3).
|
||||
|
||||
@@ -3083,6 +3083,12 @@ a.itflow-dash-rail-item:focus-visible {
|
||||
.itflow-category .itflow-category-dot {
|
||||
margin-right: 0;
|
||||
}
|
||||
/* A category's icon beside its name in a list (categoryMarkHtml()) - in its
|
||||
colour, set as the dot it stands in for is */
|
||||
.itflow-category-icon {
|
||||
margin-right: .3rem;
|
||||
color: var(--bs-secondary-color);
|
||||
}
|
||||
.itflow-category-name {
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
|
||||
@@ -348,7 +348,7 @@ function accountLedgerKinds() {
|
||||
* expense or reimbursement), txn_transfer_id, txn_account_id, account_name,
|
||||
* txn_date, txn_created_at, txn_amount (in positive, out negative), txn_what
|
||||
* (who or what - the invoice, the vendor, the agent paid back, the other
|
||||
* account), txn_description, txn_category_id, category_name, category_color,
|
||||
* account), txn_description, txn_category_id, category_name, category_color, category_icon,
|
||||
* txn_client_id, client_name, txn_other_account_id, other_account_name,
|
||||
* other_account_type (a transfer's other account's kind), txn_line (the row
|
||||
* behind it - payment-12, revenue-5 or expense-9), txn_reconciliation_id (the
|
||||
@@ -405,7 +405,7 @@ function accountLedgerSql($account_id = 0) {
|
||||
LEFT JOIN reimbursements ON reimbursement_expense_id = expenses.expense_id
|
||||
LEFT JOIN users AS payee ON payee.user_id = reimbursement_user_id
|
||||
WHERE expenses.expense_archived_at IS NULL AND " . $on('expenses.expense_account_id');
|
||||
return "SELECT ledger_lines.*, accounts.account_name, accounts.account_type, accounts.account_currency_code, category_name, category_color, client_name,
|
||||
return "SELECT ledger_lines.*, accounts.account_name, accounts.account_type, accounts.account_currency_code, category_name, category_color, category_icon, client_name,
|
||||
ledger_lines.txn_other_name AS other_account_name, other_account.account_type AS other_account_type,
|
||||
cleared.reconciliation_id AS txn_cleared_id, cleared.reconciliation_statement_date AS txn_cleared_date, cleared.reconciliation_opening AS txn_cleared_opening,
|
||||
accounts.opening_balance + SUM(ledger_lines.txn_amount) OVER (PARTITION BY ledger_lines.txn_account_id ORDER BY ledger_lines.txn_date ASC, ledger_lines.txn_created_at ASC,
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
* by 'id' or 'name' - how records hold it
|
||||
* ordered whether pickers list them in the order set here (else by name)
|
||||
* max the longest name the records' columns hold
|
||||
* modules the modules whose records hold it - a user with any of them
|
||||
* can read the kind (the API's categories/read.php)
|
||||
* uses where records hold it - table, column, one/many (the record,
|
||||
* in a sentence), url (the list showing them, {id} or {name}
|
||||
* filled in; null when there is no such list), archived and
|
||||
@@ -39,7 +41,7 @@ function categoryKinds() {
|
||||
'Expense' => [
|
||||
'label' => 'Expense', 'one' => 'expense category', 'many' => 'expense categories', 'icon' => 'fa-shopping-cart',
|
||||
'about' => 'What money goes out on. Every expense, recurring expense and budget line has one, and the expense reports add up by them.',
|
||||
'by' => 'id', 'ordered' => false, 'max' => 200,
|
||||
'by' => 'id', 'ordered' => false, 'max' => 200, 'modules' => ['module_financial'],
|
||||
'uses' => [
|
||||
$use('expenses', 'expense_category_id', 'expense', 'expenses', '/agent/expenses.php?category={id}', 'expense_archived_at', 'expense_updated_at'),
|
||||
$use('recurring_expenses', 'recurring_expense_category_id', 'recurring expense', 'recurring expenses', '/agent/recurring_expenses.php?category={id}&status=all', 'recurring_expense_archived_at', 'recurring_expense_updated_at'),
|
||||
@@ -52,11 +54,11 @@ function categoryKinds() {
|
||||
'Income' => [
|
||||
'label' => 'Income', 'one' => 'income category', 'many' => 'income categories', 'icon' => 'fa-hand-holding-usd',
|
||||
'about' => 'What money comes in for. Invoices, quotes, recurring invoices, products and other income each have one, and the income reports add up by them.',
|
||||
'by' => 'id', 'ordered' => false, 'max' => 200,
|
||||
'by' => 'id', 'ordered' => false, 'max' => 200, 'modules' => ['module_sales', 'module_financial'],
|
||||
'uses' => [
|
||||
$use('invoices', 'invoice_category_id', 'invoice', 'invoices', '/agent/invoices.php?category={id}', 'invoice_archived_at', 'invoice_updated_at'),
|
||||
$use('quotes', 'quote_category_id', 'quote', 'quotes', null, 'quote_archived_at', 'quote_updated_at'),
|
||||
$use('recurring_invoices', 'recurring_invoice_category_id', 'recurring invoice', 'recurring invoices', null, 'recurring_invoice_archived_at', 'recurring_invoice_updated_at'),
|
||||
$use('quotes', 'quote_category_id', 'quote', 'quotes', '/agent/quotes.php?category={id}', 'quote_archived_at', 'quote_updated_at'),
|
||||
$use('recurring_invoices', 'recurring_invoice_category_id', 'recurring invoice', 'recurring invoices', '/agent/recurring_invoices.php?category={id}&status=all', 'recurring_invoice_archived_at', 'recurring_invoice_updated_at'),
|
||||
$use('revenues', 'revenue_category_id', 'other income entry', 'other income entries', '/agent/income.php?category={id}&show=other', 'revenue_archived_at', 'revenue_updated_at'),
|
||||
$use('products', 'product_category_id', 'product', 'products', '/agent/products.php?category={id}', 'product_archived_at', 'product_updated_at'),
|
||||
$use('income_import_rules', 'import_rule_category_id', 'import rule', 'import rules', null, null, 'import_rule_updated_at'),
|
||||
@@ -65,7 +67,7 @@ function categoryKinds() {
|
||||
'Referral' => [
|
||||
'label' => 'Referral', 'one' => 'referral', 'many' => 'referrals', 'icon' => 'fa-share-alt',
|
||||
'about' => 'How a client found you - picked on the client, and a filter on the clients list.',
|
||||
'by' => 'name', 'ordered' => false, 'max' => 200,
|
||||
'by' => 'name', 'ordered' => false, 'max' => 200, 'modules' => ['module_client'],
|
||||
'uses' => [
|
||||
$use('clients', 'client_referral', 'client', 'clients', '/agent/clients.php?referral={name}', 'client_archived_at', 'client_updated_at'),
|
||||
],
|
||||
@@ -73,7 +75,7 @@ function categoryKinds() {
|
||||
'Ticket' => [
|
||||
'label' => 'Ticket', 'one' => 'ticket category', 'many' => 'ticket categories', 'icon' => 'fa-life-ring',
|
||||
'about' => 'What a ticket is about. Tickets, recurring tickets and canned responses have one, and the ticket reports add up by them.',
|
||||
'by' => 'id', 'ordered' => false, 'max' => 200,
|
||||
'by' => 'id', 'ordered' => false, 'max' => 200, 'modules' => ['module_support'],
|
||||
'uses' => [
|
||||
$use('tickets', 'ticket_category', 'ticket', 'tickets', '/agent/tickets.php?category={id}&show=all', 'ticket_archived_at', 'ticket_updated_at', true),
|
||||
$use('recurring_tickets', 'recurring_ticket_category', 'recurring ticket', 'recurring tickets', '/agent/recurring_tickets.php?category={id}', null, 'recurring_ticket_updated_at', true),
|
||||
@@ -83,7 +85,7 @@ function categoryKinds() {
|
||||
'network_interface' => [
|
||||
'label' => 'Network Interface', 'one' => 'interface type', 'many' => 'interface types', 'icon' => 'fa-ethernet',
|
||||
'about' => 'The kinds of port on an asset - Ethernet, SFP+, WiFi - picked on each of its interfaces.',
|
||||
'by' => 'name', 'ordered' => true, 'max' => 50,
|
||||
'by' => 'name', 'ordered' => true, 'max' => 50, 'modules' => ['module_support'],
|
||||
'uses' => [
|
||||
$use('asset_interfaces', 'interface_type', 'interface', 'interfaces', null, 'interface_archived_at', 'interface_updated_at'),
|
||||
],
|
||||
@@ -91,32 +93,32 @@ function categoryKinds() {
|
||||
'asset_status' => [
|
||||
'label' => 'Asset Status', 'one' => 'asset status', 'many' => 'asset statuses', 'icon' => 'fa-heartbeat',
|
||||
'about' => 'Where an asset stands - deployed, out for repair, retired. Its colour is the status badge\'s; without one the built-in statuses keep theirs.',
|
||||
'by' => 'name', 'ordered' => true, 'max' => 200,
|
||||
'by' => 'name', 'ordered' => true, 'max' => 200, 'modules' => ['module_support'],
|
||||
'uses' => [
|
||||
$use('assets', 'asset_status', 'asset', 'assets', null, 'asset_archived_at', 'asset_updated_at'),
|
||||
$use('assets', 'asset_status', 'asset', 'assets', '/agent/assets.php?status={name}', 'asset_archived_at', 'asset_updated_at'),
|
||||
],
|
||||
],
|
||||
'software_type' => [
|
||||
'label' => 'Software Type', 'one' => 'software type', 'many' => 'software types', 'icon' => 'fa-cube',
|
||||
'about' => 'What kind of software a license is for - SaaS, security, operating system. Its icon is the license\'s.',
|
||||
'by' => 'name', 'ordered' => true, 'max' => 200,
|
||||
'by' => 'name', 'ordered' => true, 'max' => 200, 'modules' => ['module_support'],
|
||||
'uses' => [
|
||||
$use('software', 'software_type', 'license', 'licenses', null, 'software_archived_at', 'software_updated_at'),
|
||||
$use('software', 'software_type', 'license', 'licenses', '/agent/software.php?software_type={name}', 'software_archived_at', 'software_updated_at'),
|
||||
$use('software_templates', 'software_template_type', 'license template', 'license templates', '/admin/software_templates.php', 'software_template_archived_at', 'software_template_updated_at'),
|
||||
],
|
||||
],
|
||||
'rack_type' => [
|
||||
'label' => 'Rack Type', 'one' => 'rack type', 'many' => 'rack types', 'icon' => 'fa-server',
|
||||
'about' => 'The kinds of rack - open frame, enclosed cabinet, wall mount - picked on each rack.',
|
||||
'by' => 'name', 'ordered' => true, 'max' => 50,
|
||||
'by' => 'name', 'ordered' => true, 'max' => 50, 'modules' => ['module_support'],
|
||||
'uses' => [
|
||||
$use('racks', 'rack_type', 'rack', 'racks', null, 'rack_archived_at', 'rack_updated_at'),
|
||||
$use('racks', 'rack_type', 'rack', 'racks', '/agent/racks.php?type={name}', 'rack_archived_at', 'rack_updated_at'),
|
||||
],
|
||||
],
|
||||
'contact_note_type' => [
|
||||
'label' => 'Contact Note Type', 'one' => 'contact note type', 'many' => 'contact note types', 'icon' => 'fa-address-book',
|
||||
'about' => 'What a note on a contact records - a call, an email, a meeting. Its icon marks the note.',
|
||||
'by' => 'name', 'ordered' => true, 'max' => 200,
|
||||
'by' => 'name', 'ordered' => true, 'max' => 200, 'modules' => ['module_client'],
|
||||
'uses' => [
|
||||
$use('contact_notes', 'contact_note_type', 'contact note', 'contact notes', null, 'contact_note_archived_at', 'contact_note_updated_at'),
|
||||
],
|
||||
@@ -124,7 +126,7 @@ function categoryKinds() {
|
||||
'asset_note_type' => [
|
||||
'label' => 'Asset Note Type', 'one' => 'asset note type', 'many' => 'asset note types', 'icon' => 'fa-desktop',
|
||||
'about' => 'What a note on an asset records - maintenance, a repair, an upgrade. Its icon marks the note.',
|
||||
'by' => 'name', 'ordered' => true, 'max' => 200,
|
||||
'by' => 'name', 'ordered' => true, 'max' => 200, 'modules' => ['module_support'],
|
||||
'uses' => [
|
||||
$use('asset_notes', 'asset_note_type', 'asset note', 'asset notes', null, 'asset_note_archived_at', 'asset_note_updated_at'),
|
||||
],
|
||||
@@ -752,3 +754,66 @@ function categoryEnsure($kind, $name) {
|
||||
logAudit("Category", "Create", ($session_name ?? 'ITFlow') . " created " . $config['one'] . " " . escapeSql($name), 0, $category_id);
|
||||
return $name;
|
||||
}
|
||||
|
||||
/*
|
||||
* A list's category filter <option>s - the kind's categories its records
|
||||
* have ($used_sql: a query giving the ids, or the names for a kind held by
|
||||
* name, on the list's records), archived ones too as records keep them, and
|
||||
* a name that is no category marked so; plus $selected, chosen. In the
|
||||
* kind's order, each with its colour and icon. Without $used_sql, the
|
||||
* current ones. $opts as categoryPicker()'s - names in 'exclude' are left
|
||||
* out even when records have them, unless chosen. The list writes its own
|
||||
* "any" option first. HTML.
|
||||
*/
|
||||
function categoryFilterOptionsHtml($kind, $selected = null, $used_sql = '', array $opts = []) {
|
||||
global $mysqli;
|
||||
$config = categoryKind($kind);
|
||||
if (!$config) {
|
||||
return '';
|
||||
}
|
||||
$by_name = $config['by'] === 'name';
|
||||
$used = null;
|
||||
if ($used_sql !== '') {
|
||||
$used = [];
|
||||
$sql = mysqli_query($mysqli, $used_sql);
|
||||
while ($row = mysqli_fetch_row($sql)) {
|
||||
$value = $by_name ? trim((string) $row[0]) : intval($row[0]);
|
||||
if ($value !== '' && $value !== 0) {
|
||||
$used[$by_name ? categoryNameKey($value) : $value] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
$selected_key = $by_name ? categoryNameKey(trim((string) $selected)) : intval($selected);
|
||||
$keep = array_values($used ?? []);
|
||||
if ($selected_key !== '' && $selected_key !== 0) {
|
||||
$keep[] = $selected;
|
||||
}
|
||||
$exclude = array_map('categoryNameKey', (array) ($opts['exclude'] ?? []));
|
||||
$html = '';
|
||||
foreach (categoryPicker($kind, $keep, $opts) as $value => $row) {
|
||||
$key = $by_name ? categoryNameKey($value) : intval($value);
|
||||
if ($key !== $selected_key && (($used !== null && !isset($used[$key])) || in_array(categoryNameKey($row['category_name']), $exclude, true))) {
|
||||
continue;
|
||||
}
|
||||
$html .= categoryOptionHtml($row, $key === $selected_key && $selected_key !== '' && $selected_key !== 0) . "\n";
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
/*
|
||||
* A category's mark beside its name in a list or quick look - its icon in
|
||||
* its colour, or a dot of its colour (an empty one without). $dot: the
|
||||
* page's own dot to use instead when it has no icon - the ticket lists' -
|
||||
* written for a colour (%s: a style attribute, or ''). HTML.
|
||||
*/
|
||||
function categoryMarkHtml($color, $icon = '', $dot = '') {
|
||||
$color = categoryColor($color);
|
||||
$icon = categoryIcon($icon);
|
||||
if ($icon !== '') {
|
||||
return '<i class="fas fa-fw fa-' . $icon . ' itflow-category-icon"' . ($color ? ' style="color: ' . $color . '"' : '') . ' aria-hidden="true"></i>';
|
||||
}
|
||||
if ($dot !== '') {
|
||||
return sprintf($dot, $color ? ' style="color: ' . $color . '"' : '');
|
||||
}
|
||||
return '<span class="itflow-category-dot"' . ($color ? ' style="background-color: ' . $color . '"' : '') . ' aria-hidden="true"></span>';
|
||||
}
|
||||
|
||||
@@ -194,13 +194,9 @@ function expenseStats() {
|
||||
];
|
||||
}
|
||||
|
||||
/** A category's colour as a small dot - names like "lightblue" or a hex value; nothing for anything else. */
|
||||
function expenseCategoryDot($color) {
|
||||
$color = trim((string) $color);
|
||||
if (!preg_match('/^(#[0-9a-f]{3,8}|[a-z]{3,24})$/i', $color)) {
|
||||
return '<span class="itflow-category-dot" aria-hidden="true"></span>';
|
||||
}
|
||||
return '<span class="itflow-category-dot" style="background-color: ' . $color . '" aria-hidden="true"></span>';
|
||||
/** A category's mark beside its name - its icon in its colour, or a dot of it (categoryMarkHtml()). */
|
||||
function expenseCategoryDot($color, $icon = '') {
|
||||
return categoryMarkHtml($color, $icon);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1291,7 +1287,7 @@ function recurringExpensesCovering($recurring_invoice_id) {
|
||||
global $mysqli;
|
||||
$id = intval($recurring_invoice_id);
|
||||
$rows = [];
|
||||
$sql = mysqli_query($mysqli, "SELECT recurring_expenses.*, vendor_name, category_name, category_color, " . expenseRecurringMonthlySql() . " AS monthly
|
||||
$sql = mysqli_query($mysqli, "SELECT recurring_expenses.*, vendor_name, category_name, category_color, category_icon, " . expenseRecurringMonthlySql() . " AS monthly
|
||||
FROM recurring_expenses
|
||||
LEFT JOIN vendors ON vendor_id = recurring_expense_vendor_id
|
||||
LEFT JOIN categories ON category_id = recurring_expense_category_id
|
||||
|
||||
@@ -142,6 +142,7 @@ function getExportColumns($export_type) {
|
||||
'client_name' => ['label' => 'Client', 'default' => false],
|
||||
'interface_ip' => ['label' => 'Primary IP', 'default' => false],
|
||||
'interface_mac' => ['label' => 'Primary MAC', 'default' => false],
|
||||
'asset_status' => ['label' => 'Status', 'default' => false],
|
||||
],
|
||||
|
||||
'asset_interfaces' => [
|
||||
@@ -338,6 +339,7 @@ function getExportColumns($export_type) {
|
||||
'invoice_due' => ['label' => 'Due Date'],
|
||||
'invoice_status' => ['label' => 'Status'],
|
||||
'client_name' => ['label' => 'Client', 'weight' => 2],
|
||||
'category_name' => ['label' => 'Category', 'default' => false],
|
||||
'invoice_currency_code' => ['label' => 'Currency', 'default' => false],
|
||||
'amount_paid' => ['label' => 'Paid', 'format' => 'money', 'default' => false],
|
||||
'invoice_balance' => ['label' => 'Balance', 'format' => 'money', 'default' => false],
|
||||
@@ -352,6 +354,7 @@ function getExportColumns($export_type) {
|
||||
'quote_date' => ['label' => 'Date'],
|
||||
'quote_status' => ['label' => 'Status'],
|
||||
'client_name' => ['label' => 'Client', 'weight' => 2, 'default' => false],
|
||||
'category_name' => ['label' => 'Category', 'default' => false],
|
||||
],
|
||||
|
||||
'recurring_invoices' => [
|
||||
@@ -362,6 +365,7 @@ function getExportColumns($export_type) {
|
||||
'recurring_invoice_frequency_display' => ['label' => 'Frequency'],
|
||||
'recurring_invoice_created_at' => ['label' => 'Date Created'],
|
||||
'client_name' => ['label' => 'Client', 'weight' => 2, 'default' => false],
|
||||
'category_name' => ['label' => 'Category', 'default' => false],
|
||||
],
|
||||
|
||||
'products' => [
|
||||
|
||||
@@ -48,7 +48,7 @@ function incomeOnlineSql($reference = 'payment_reference') {
|
||||
* client scope - a row each with income_type (payment or revenue),
|
||||
* income_id, income_date, income_created_at, income_invoice_id,
|
||||
* invoice_prefix, invoice_number, invoice_status, income_description,
|
||||
* income_category_id, category_name, category_color, income_client_id,
|
||||
* income_category_id, category_name, category_color, category_icon, income_client_id,
|
||||
* client_name, income_amount, income_currency_code, income_method,
|
||||
* income_reference, income_account_id, account_name, account_archived_at
|
||||
* and income_online. Select from it as a derived table.
|
||||
@@ -56,7 +56,7 @@ function incomeOnlineSql($reference = 'payment_reference') {
|
||||
function incomeUnionSql() {
|
||||
return "SELECT 'payment' AS income_type, payment_id AS income_id, payment_date AS income_date, payment_created_at AS income_created_at,
|
||||
payment_invoice_id AS income_invoice_id, invoice_prefix, invoice_number, invoice_status, invoice_scope AS income_description,
|
||||
COALESCE(invoice_category_id, 0) AS income_category_id, category_name, category_color,
|
||||
COALESCE(invoice_category_id, 0) AS income_category_id, category_name, category_color, category_icon,
|
||||
COALESCE(invoice_client_id, 0) AS income_client_id, client_name, payment_amount AS income_amount, payment_currency_code AS income_currency_code,
|
||||
payment_method AS income_method, payment_reference AS income_reference, payment_account_id AS income_account_id, account_name, account_archived_at,
|
||||
IF(" . incomeOnlineSql() . ", 1, 0) AS income_online
|
||||
@@ -69,7 +69,7 @@ function incomeUnionSql() {
|
||||
UNION ALL
|
||||
SELECT 'revenue', revenue_id, revenue_date, revenue_created_at,
|
||||
0, NULL, NULL, NULL, revenue_description,
|
||||
revenue_category_id, category_name, category_color,
|
||||
revenue_category_id, category_name, category_color, category_icon,
|
||||
revenue_client_id, client_name, revenue_amount, revenue_currency_code,
|
||||
revenue_payment_method, revenue_reference, revenue_account_id, account_name, account_archived_at,
|
||||
0
|
||||
@@ -216,7 +216,7 @@ function incomeRevenueRow($revenue_id, $scoped = true) {
|
||||
if (!$revenue_id) {
|
||||
return null;
|
||||
}
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT revenues.*, client_name, client_abbreviation, category_name, category_color, account_name,
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT revenues.*, client_name, client_abbreviation, category_name, category_color, category_icon, account_name,
|
||||
account_archived_at, account_currency_code, creator.user_name AS created_by_name
|
||||
FROM revenues
|
||||
LEFT JOIN clients ON client_id = revenue_client_id
|
||||
@@ -336,7 +336,7 @@ function incomePaymentRow($payment_id) {
|
||||
return null;
|
||||
}
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT payments.*, invoice_id, invoice_prefix, invoice_number, invoice_status, invoice_amount, invoice_currency_code,
|
||||
invoice_date, invoice_due, invoice_scope, invoice_client_id, client_name, category_name, category_color, invoice_category_id, account_name, account_archived_at
|
||||
invoice_date, invoice_due, invoice_scope, invoice_client_id, client_name, category_name, category_color, category_icon, invoice_category_id, account_name, account_archived_at
|
||||
FROM payments
|
||||
LEFT JOIN invoices ON invoice_id = payment_invoice_id
|
||||
LEFT JOIN clients ON client_id = invoice_client_id
|
||||
|
||||
Reference in New Issue
Block a user