diff --git a/CHANGELOG.md b/CHANGELOG.md index 536b5bf9c..d7c8f52f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,69 @@ This file documents all notable changes made to ITFlow. +## [26.12.6] + +### Upgrading to 26.12.6 + +Update from Maintenance > Update as usual. This release has four database changes: 4.4.4 adds the settings for Warranty Lookup, 4.4.5 puts the email and phone links back in Knowledge Base articles and documents written in Markdown, 4.4.6 adds the Vendors permission to roles, and 4.4.7 adds linked assets. + +- If you have switched a module off in Admin > Settings > Modules - IT documentation, ticketing, invoicing and accounting or any of the others - check that you meant it before updating. Its pages, bookmarks to them and links in old emails stop opening, and the nightly run stops doing its work: with ticketing off, no recurring tickets are raised and resolved tickets aren't closed; with invoicing and accounting off, no recurring invoices or expenses are made, no autopay is charged and no payment reminders go out; with IT documentation off, no domain, certificate, warranty or service review notifications, and shared links - logins, files, documents and IT documentation exports sent to clients - don't open. Switch it back on and the next run picks up what is due, and shared links that haven't run out open again. +- API keys get a 403 saying which module is off for anything of a module that is switched off - tickets with ticketing off, assets and credentials with IT documentation off, invoices with invoicing off. +- Contacts imported before with a ? in place of an accented letter keep it. Import the same file again with **A contact already here** set to **Update it** and their names are put right - contacts are matched by email. Anything else imported that way, such as a location or vendor, is matched by its name, so correct those by hand. +- The warranty lookup button shows beside **Warranty expires** on the asset form straight after the update, as Lenovo needs no key and is switched on. It only asks Lenovo when someone clicks it. Switch Lenovo off in Admin > Warranty Lookup if you'd rather ITFlow didn't ask Lenovo's support site at all. +- Roles have a new **Vendors** permission, for your own vendors. The update gives each role what it had - **Read**, or its **Financial** level where that is higher - so nobody gains or loses anything until you change it in Admin > Roles. +- A `.md` file uploaded to a client's Files now becomes a document you can edit. To upload one as a file, as before, turn on **Keep them as files** in the Upload window. **Import Markdown Files** has gone from the Upload menu - Upload does it. +- If CrowdSec blocked new tickets and you switched its rule 932260 off for ITFlow, switch it back on once you've updated: the fields it took for a Linux command have new names. Bookmarks to the tickets list's **Scheduled** tab, and scripts that post ITFlow's forms with the old names, keep working. + +### New Features & Updates + +- Switching a module off in Admin > Settings > Modules now takes it out of ITFlow completely, not just out of the side menu. Every other page leaves out its tabs, buttons, New items and links: with ticketing off, a contact, location, asset, vendor, service or license has no Tickets tab or New Ticket, the client menu has no New Ticket or New Project, and the calendar has no scheduled tickets, projects or recurring tickets; with IT documentation off, a contact, location, vendor or ticket has no assets, credentials, licenses, documents, files or services, the dashboard has no expiring domains, certificates or warranties, Network Platforms leaves the admin menu, and global search doesn't look through them; with invoicing and accounting off, one of your vendors has no expenses or products, and the calendar has no invoices due. Tags, Categories, email previews, From addresses, tax switches, the default calendar, start pages and the cron jobs follow suit, and settings saved while a module is off keep what that module had. +- A page or window of a module that is switched off says so and goes back where you came from - or to the dashboard, or for an admin page to Modules - instead of opening as if nothing were off. Whatever leads there: a bookmark, a link in an old email or notification, an address typed in. The settings overview's faded tiles take you to Modules, to switch it on. +- The client portal leaves out what is switched off too. With ticketing off, a contact sees no Tickets, New Ticket, open tickets, approvals or request forms, and portal search doesn't look through tickets; with IT documentation off, their home lists no devices. A link someone was sent - to a ticket, invoice, quote or contract, or a shared login or file - for a module that is now off says it isn't available, without mentioning settings. +- Maintenance > Cron shows the jobs of a module that is off as **Not in use**, saying which module: the Ticket Email Parser, Ticket SLA Monitor, Ticket Pictures and AI Triage with ticketing off, the Domain and Certificate Refreshers with IT documentation off, and Payment Provider Fees with invoicing off. +- Audit logs and notifications still name a ticket, invoice or asset of a module that is off, without linking it. The quick looks - a contact, location, vendor or ticket at a glance - leave out what is off too, and a quote's files from the client can still be downloaded with IT documentation off. +- Look up an asset's warranty by its serial number. On an asset's Purchase tab, the search button beside **Warranty expires** asks its maker - Dell, HP or Lenovo - and fills in when its warranty runs out and, as **Purchased**, when it began: for a Dell, the day it shipped. To do many at once, tick them on Assets and choose **Bulk Action > Look Up Warranty** - each one's answer is listed as it comes in. Only empty dates are filled in: a date already on an asset is never changed, and on the form the maker's is offered beside it to use instead. Each date filled in is noted in the asset's History. An asset is matched by its make, or with no make by its model - Latitude, OptiPlex, ThinkPad, EliteBook and the like. HP Enterprise servers aren't looked up. +- Admin > Warranty Lookup, under Integrations, sets up each maker. Dell needs a TechDirect Warranty API key and HP an HP Warranty API key, which each approve by hand - HP doesn't give its to every IT company. Lenovo needs none: ITFlow asks Lenovo's support site as its own pages do, which can stop working when Lenovo changes the site. **Save and test** beside each one tries a serial number with what you've entered. HP works through each lookup as a job, so its answers can take a few minutes. It's part of IT documentation, and goes with it when that module is off. +- Upload a `.md` file and it becomes a document written in Markdown, that you can edit, in the folder it goes into - with **Upload** or by dropping it on the list, no import step. Upload the pictures it uses with it - pick them together, or upload the folder they're in - and they go into the document, found where its links say or by their name; a picture no file uses uploads as a file. A zip of Markdown pages, such as an export from Notion, Obsidian or Confluence, is opened in the Upload window and brought in as the folder it holds: each page a document in its folder with its pictures, its other files uploaded beside them, and Notion's IDs taken off the names. Afterwards ITFlow says which pictures a file uses that weren't uploaded with it, to add in the editor. The Upload window says what will become a document, and **Keep them as files** uploads the `.md` files as they are and a zip as a zip. +- A `.md` already in Files shows as it reads in its preview and quick look, with its pictures that are in the client's files, and **Make it a document**, in its menu and quick look, makes it a document: the pictures it uses are copied in, and the document takes the file's place and its links. +- Copy a Knowledge Base article's link from its **⋮** menu, on its page or beside it in the list - to send it to someone, or to link to it from another article. It offers the links that suit who can read it: **Copy Public Link** for an article for anyone, **Copy Portal Link** for one in the client portal, and **Copy Link** to its page here for one for agents only. A link that won't open yet is greyed out with the reason under it, such as **Publish it first** or **The public help center is off**. Agents who can read articles but not edit them get the menu with these links too. +- A **Vendors** permission in Admin > Roles, for your own vendors - the ones with no client: suppliers, distributors, the colo - at **None**, **Read**, **Modify** or **Full**. Set a role to **None** to keep its agents out of your suppliers' numbers, accounts and contacts: **Vendors** in the menu opens your clients' vendors instead, your own vendors' pages and their export are refused, search leaves them out, and where a client's license, network, ticket or service names one of yours, they see only its name. A client's vendors stay with the **Clients** permission. Adding, editing and deleting your own vendors moves from **Financial** to **Vendors** too. +- Link assets to each other - a label printer and its cutter, a server and its disk shelf, a desk phone and its sidecar - so a part that is swapped or sent off for repair on its own can be its own asset, with its own serial number and warranty, and still be found with what it goes on. **Link**, on the asset's new **Linked assets** card, picks from the client's other assets, of any type. A link goes both ways, each asset showing the other, and an asset can be linked to as many as it needs. Linking and unlinking are noted in both assets' History, so you can see which part was on which device and when it was swapped. A linked asset at another site says where it is, and its **⋮** menu moves either one to the other's site - nothing moves on its own. The assets list and the asset's quick look show what each asset is linked to, the client export lists the links, and assets transferred to another client together stay linked. +- A ticket's assets are one field, **Assets**, for one or several, in place of **Asset** and **Other assets** - in New Ticket, Edit, the ticket's **Change assets** window and New and Edit Recurring Ticket. The first asset picked fills in the person it's assigned to and its site, as before, and a ticket raised from an asset's page starts with that asset. On the ticket, every asset on the **Linked** card has a **×** to take it off, the first one too, the history says which assets were added and taken off, and its quick look lists them all. **Copy as a New Ticket** copies all its assets, and searching tickets finds a ticket by any of them. + +### Bug Fixes + +- Importing a CSV file with accented letters - ü, é, ñ, ø and the like - keeps them. A file saved from Excel as plain **CSV (Comma delimited)**, exported from Outlook, or saved from Excel for Mac as **Comma Separated Values** imported with a ? in place of each accented letter, and one with an accented letter in a heading didn't import at all. Every import - clients, contacts, locations, assets and the rest - now reads the file in whatever it was saved as, and a file whose columns are separated by tabs imports too. Bank statements imported on Expenses and Income read the same way, so one saved on a Mac or in Unicode now imports too. +- UniFi gateways come in as **Firewall/Router**. The Cloud Gateway Fiber, the Enterprise Fortress Gateway and other newer gateways came in as a switch or as Other, because UniFi doesn't always say a device is a gateway - ITFlow now knows them by their model too: the Dream Machines, Dream Routers and Dream Wall, the Cloud Gateways, the UXG Gateways, the Enterprise Fortress Gateway and the older Security Gateways. One already brought in as a switch or Other is put right by the next sync, unless you changed its type yourself, and when one goes offline its alert is the site's gateway alert. In-wall access points, which came in as switches, come in as access points. +- Connecting Microsoft 365 for mail works with an app that has only Microsoft Graph's permissions, and where your users can't approve apps. Connect asked Microsoft for Exchange's SMTP and IMAP permissions every time and forced the consent screen, so an app with only Graph's Mail.Send and Mail.ReadWrite couldn't connect, and a mailbox account that isn't allowed to approve apps was stopped at "Need admin approval" even after an admin had granted consent. On the OAuth tab, **The app has**, above **Connect Microsoft 365**, says which permissions you gave the app, and Connect asks for just those - Microsoft asks which account to sign in as instead. Coming back, ITFlow says how email now goes, or what the app is missing. **Test OAuth Token Refresh** no longer fails an app with only Graph's permissions: it checks Graph first, and SMTP and IMAP only for what Graph can't do. +- A card is saved once per client, however often it's entered. A client who set up autopay on two recurring invoices with the same card - or added it again in the portal - ended up with the card saved twice, once for each, as Stripe gives the card a new reference each time it's entered. ITFlow now knows the same card when it comes back: the one saved card is kept, with the details just entered, and every recurring invoice it pays carries on with it. A card that is already saved twice is merged into one overnight - the copy that runs out last is kept and the autopay on the others moves to it - so you don't need to do anything, and its client isn't sent two expiry reminders for it. +- Email and phone links work in Knowledge Base articles and documents - a `mailto:` or `tel:` link showed as plain text on the published article, in the client portal and on the document, while the editor still had it. Those in an article or document written in Markdown were taken out when it was saved; the database update puts them back in the ones already saved, so they don't need saving again. Email and phone links in ticket replies, such as those in an email signature, work too. +- Opening one of your own vendors from a client's license or service works - it said there was nothing to see. +- A ticket's other assets show on it when its main asset was taken off - they were still on the ticket but not listed. +- A ticket's page opened without a ticket - from a link cut short, say - says there's nothing to see, as for a ticket that isn't there, instead of an empty page. +- Behind CrowdSec's web application firewall, creating a ticket or a recurring ticket got you blocked, and soon banned, whatever you wrote in it. CrowdSec took the names of the fields that book the work - when, for how long, remote or onsite - for a Linux command, as they began with "sched", and so blocked the post. The same stopped the ticket's Schedule window, adding an agent to help at their own time, the **Scheduled** tab of the tickets list, sorting Maintenance > Cron by **Schedule** and saving a cron job. Those fields have new names, so nothing needs excluding in CrowdSec: any exclusion you added for this can come out. Stripe's return to ITFlow after a client saves a card or sets up autopay is renamed too, as the same firewall can take it for an attack when the browser doesn't say where it came from. + +### Developer Updates + +- `functions/settings.php`: `modulePaths()` lists each module's pages, windows (`agent/modals/`, `admin/modals/`, a trailing `/` for a whole folder), portal pages and guest pages; `moduleForPath()` gives the modules a path belongs to, a report's from its `'feature'`s in `reportCatalog()`; `modulePathOff()`; `moduleRequestGuard()` turns a request away with `moduleRefuse()` - a window's JSON `content` "Switched off", a portal page's flash and `/client/index.php`, a guest page's plain 404, and an agent page's flash with the `HTTP_REFERER` when that is on this host and not off too, else `/agent/dashboard.php` or `/admin/settings_module.php`. It runs from `includes/check_login.php`, `client/includes/check_login.php`, `guest/includes/inc_all_guest.php` and `guest/guest_ticket_attachment.php`; `guest/share_ajax.php` answers `state: gone` with IT documentation off. `agent/file.php` isn't mapped - a quote's files from the client download through it. `moduleOffText()` now names `itdoc`, `ticketing`, `accounting` and `portal`. `moduleLink($module, $href, $inner_html, $attrs)` gives an `` or, with the module off, a ``; `ticketLink()` and `reportAssetCell()` use it. `settingsStartPages()` leaves out pages that are off, and `includes/load_global_settings.php` and `login.php` open the dashboard instead of a start page that is off (`moduleSwitchesLoad()` reads the switches where the settings aren't loaded). CONTRIBUTING.md has the rule. +- `api/v1/enforce_api_rbac.php` maps each resource to its module in `$resource_feature` and `apiDeny(moduleOffText())`s one that is off, reading the switches from `settings` itself. `categoryKindModule()`, `categoryKindsOn()` (`functions/categories.php`), `tagKindModule()` and `tagKindsOn()` (`functions/tags.php`) give the kinds of the modules on - Admin > Categories and Tags, their windows, global search and the API use them, and the API refuses a kind that is off. `calendarSources()` takes a `'part'` per source. `dashboardAccess()` adds `itdoc`. `globalSearchGroups()` gives the documentation groups `'enabled' => $itdoc`. `auditLogRecords()` leaves `url` empty for a record whose page is off and `auditLogRecordLink()` gives a ``; `notificationActionUrl()` returns null for one. +- Cron: `cronJobModuleOff()` (`includes/cron_jobs.php`) and `not_in_use` checks on `ticket_email_parser`, `ticket_sla`, `ai_triage`, `ticket_pictures`, `domain_refresher`, `certificate_refresher` and `payment_provider_fees`; `cronJobSettings()` reads the whole settings row. `cron/nightly_tasks.php` skips contracts, recurring invoices, expenses and payments, reminders, quote and draft notices and card checks with accounting off, recurring tickets, auto-close and the pending-tickets notice with ticketing off, and the domain, certificate, warranty, asset date and service review notices with IT documentation off. +- Pages: `agent/contact.php`, `location.php`, `asset.php`, `vendor.php`, `service.php`, `ticket.php`, `license.php`, `services.php`, `assets.php`, `calls.php`, `texts.php`, `invoice.php`, `invoices.php`, `quote.php`, `contract.php`, `trips.php`, `unbilled_time.php`, `client_overview.php`, `includes/client_actions_menu.php`, `reports/client_review.php`, `admin/includes/side_nav.php`, `rmm_clients.php`, `payment_methods.php`, `agent_banners.php`, `settings.php`, `settings_mail.php`, `settings_notification.php`, `settings_invoice.php`, `settings_default.php`, `tax_rates.php`, the contract and contract template windows (SLAs kept as hidden fields), the contact, location, vendor and ticket quick looks (`agent/modals/*/`), the offboarding window's open tickets note, `client/index.php`, `search.php`, `functions.php` (`portalNav()`) and `includes/header.php`. A switch or field hidden for a module that is off is kept as saved: `admin/post/settings_notification.php` only writes `config_enable_alert_domain_expire` with IT documentation on, and `tax_rates.php` posts `tax_time` and `tax_trips` hidden. +- Imports: `csvTextToUtf8($text)` (`functions/import.php`) gives a CSV's text as UTF-8 - UTF-8 as it is with its BOM dropped, UTF-16 LE or BE by its BOM, and otherwise Windows-1252 or Mac Roman, whichever `csvTextMisreads()` finds fewer signs of a wrong reading in (C1 control characters, a capital or symbols in the middle of a word, an opening quote or `š`/`ˆ`/`fl` after a letter), Windows-1252 on a tie. `importFile()` reads the whole upload through it into `php://temp`, turns lone `\r` line ends into `\n`, and takes comma, semicolon or tab, whichever the heading line has most of; `expenseImportRead()` uses it in place of its own BOM strip and Windows-1252 fallback, which also let a UTF-16 statement fail its NUL check, and so do the network IP and interface imports in `agent/post/network_ip.php` and `agent/post/asset_interface.php`. Before, `importFile()` passed the bytes through: `importSqlText()`'s `mb_substr()` turned each invalid byte into `?` before `escapeSql()`'s Windows-1252 fallback could see it, and an invalid byte in a heading made `json_encode()` return false, so `import_check` answered with an empty body. `agent/post/import.php` now encodes its answer with `JSON_INVALID_UTF8_SUBSTITUTE`. CONTRIBUTING.md has the rule. +- UniFi: `rmmUnifiGatewayModel($model)` (`functions/rmm_unifi.php`) knows a gateway by its model code or name - UDM, UDR, UDW, UCG, UXG, EFG, USG, UGW, or a name starting Dream, Cloud Gateway or Gateway - but not the Express (UX, UX7), which is a site's gateway or an access point in someone else's network. The official Network API's `features` say `gateway` for some gateways only - a UCG Fiber comes as `switching`, an EFG with none - so `rmmUnifiNetworkDeviceType($features, $model)` takes `gateway` or the model, then `accessPoint` before `switching`, as an in-wall access point has both. `rmmUnifiControllerDevice()` takes a gateway by its `type` (`ugw`, `udm`, `uxg`), its model, or a `wan1` with an `ifname` or `ip`. Assets already brought in follow `rmmAssetFollow()`'s usual rule: a type the sync wrote is updated, one changed in ITFlow is left. +- Microsoft 365 mail: `mailMicrosoftConnectScope($way)` (`functions/mail_graph.php`) - `graph` asks for `openid profile offline_access https://graph.microsoft.com/.default`, `exchange` for the IMAP and SMTP scopes as before. The OAuth tab's `oauth_connect_way` picker sets it - `mailMicrosoftConnectWay()`: Graph before a first connect, then Graph when `mailGraphState()` has a mail permission - and `$_SESSION['mail_oauth_way']` carries it to `admin/oauth_microsoft_mail_callback.php`, which redeems the code for the same. `prompt=consent` is now `prompt=select_account`. The callback keeps the access token as `config_mail_oauth_access_token` only for an Exchange sign-in, as a Graph one isn't XOAUTH2's, goes through `mailGraphHttp()` and `MAIL_MICROSOFT_LOGIN_URL`, and ends with `mailMicrosoftCheck($send_ms, $read_ms, $fresh_exchange)`, which Test OAuth Token Refresh now uses for Microsoft too: Graph's Mail.Send and Mail.ReadWrite first, then `mailMicrosoftExchangeToken()` only for a side Graph doesn't cover. `js/settings.js` leaves a `[data-settings-untracked]` field out of a settings form's unsaved changes. +- Saved cards: `billingStripeCardSave($stripe, $client_id, $customer, $pm)` (`functions/billing_pay.php`) is how every client-added card is saved - `autopayCheckoutFinish()`, `cardUpdateFinish()` and the client portal's `stripe_save_card` in `client/post.php`, which matched only Stripe's payment method ID, a new one each time a card is entered. It matches `card.fingerprint` among the cards on the client's Stripe customer (`billingStripeCardTwins()`, one `allPaymentMethods` call), points the oldest saved row at the new payment method and its description, clearing `saved_payment_update_key` when the expiry changed as `cardRefresh()` does, detaches the one it replaced (`billingStripeCardDetach()`) and merges any other copies in (`billingStripeCardMerge()`: `recurring_payments` moved, payment method detached, row deleted), under a per-client `GET_LOCK`. Stripe not answering falls back to saving a new row, as before. `billingStripeCardTwinsNightly()` in `cron/nightly_tasks.php`, before `cardExpiryNightly()`, merges cards already saved twice - only for clients with two saved cards of the same brand and last four digits, keeping the one that runs out last. +- Warranty lookup: `functions/warranty.php`. `warrantyMaker($make, $model)` gives `dell`, `hp`, `lenovo` or `''` (HPE and Hewlett Packard Enterprise `''`); `warrantySettings()` opens the keys, sealed with `secretSeal(..., 'warranty')`, and `warrantyAnyReady()` says whether any maker is set up. `warrantyLookup($items)` takes `key => ['maker', 'serial']` and answers each with `warrantyFound()` or `warrantyNotFound($why, $kind)` - `kind` `found`, `missing`, `skip`, `error` or `pending`, `end` the latest coverage end, `start` Dell's `shipDate` or the earliest start, `coverage` the name of the one ending last. Dell: an OAuth client-credentials token from `auth/oauth/v2/token` (form fields, then Basic), then `PROD/sbil/eapi/v5/asset-entitlements`, 100 tags a call. Lenovo: `us/en/api/v4/mse/getproducts?productId=` for its product ID, then `ds_warranties` from its `products/{id}/warranty` page - active contracts and every base warranty. HP: one `productwarranty/v2/jobs` job a batch (`warrantyHpStart()`), answered `pending` with the job ID, which `warrantyHpCheck()` polls. `warrantyApply()` writes only an empty `asset_warranty_expire` or `asset_purchase_date`, with an `asset_history` row and `logAudit()`. The hosts are `WARRANTY_DELL_URL`, `WARRANTY_HP_URL` and `WARRANTY_LENOVO_URL`, which config.php can define first. +- `agent/ajax.php` answers `warranty_lookup` - an asset form's `make`, `model` and `serial` (`{answer}`), or up to 25 `asset_ids` (`{results}`, written) - and `warranty_hp_check`, an HP job ID asked after with the same `asset_ids` or `serial` (`{done: false}` until HP has finished) - with IT documentation on (`moduleOffText('itdoc')` otherwise), Support at Modify, and `hasClientAccess()` for each asset. `js/warranty_lookup.js` drives the form's `[data-warranty-lookup]` button and `agent/modals/asset/asset_bulk_warranty.php` (up to 500 assets, 5 a request, HP polled every 10 seconds for up to 15 minutes). `admin/settings_warranty.php` and `admin/post/settings_warranty.php` are the `warranty` page in `settingsPages()`, its own group in `adminNavGroups()`, mapped to `itdoc` in `modulePaths()`. Database 4.4.4 adds `config_warranty_dell_client_id`, `config_warranty_dell_client_secret`, `config_warranty_hp_client_id`, `config_warranty_hp_client_secret` and `config_warranty_lenovo` (default 1) to `settings`. +- Markdown uploads: `functions/markdown_upload.php`. `upload_files` (`agent/post/file.php`) collects an upload's .md files and pictures (`markdownUploadExtensions()`, `markdownPictureExtensions()`) and hands them to `markdownUploadConvert($client_id, $file_ids, $folders_made)` at its end; a folder sent in parts keeps them in `$_SESSION['upload_batches'][upload_batch]` until `upload_folder_done`, which now answers `go` - the document's address when one document is all it made. `markdown_keep` turns it off. `markdownFileToDocument()` makes each document with `markdownImportSplit()`, `markdownSaveImages()` and `markdownRewritePictures($markdown, $find)` - `![alt](target)`, ``, `[id]: target` for a picture and Obsidian's `![[name]]`, code blocks left alone - finding each with `markdownFindPicture()`: through the folder tree from the .md's folder (`markdownPathFolder()`, `..` included, folder names with or without Notion's ID), then by a name only one picture has. `markdownCopyPicture()` checks it with `getimagesizefromstring()` and stores it under `uploads/documents//` by its real type. The file's links move to the document through `linkAdd()`; the .md and the pictures used go (`markdownUploadRemoveFile()`), and so do folders the upload made that are left empty (`markdownUploadRemoveEmptyFolders()`). `folderForUploadPath()` takes `&$made_ids` and drops Notion's 32-character ID from a folder's name (`markdownNotionName()`). +- `js/zip_reader.js` - `window.itflowZip.list(file)` reads a zip's central directory, `.unpack(file, entry)` takes a file out, inflating with `DecompressionStream('deflate-raw')`; no zip64 or encrypted entries. The upload window sends a zip with Markdown pages as the folder it holds, through the folder upload, so PHP's zip extension isn't needed. Make it a document: `agent/modals/file/file_make_document.php`, `make_file_document`, `markdownFileMakeDocument()`. `get_file_markdown` (`agent/ajax.php`) and `fileMarkdownPreviewHtml()` render an uploaded .md - its pictures in Files as `file.php` links - for the grid previewer (`kind: 'markdown'`) and the file quick look. `agent/modals/document/document_import_markdown.php` and `import_markdown_documents` are removed. `fileUploadExtensions()` takes `.markdown`, and `fileTypeInfo()` calls `.md` Markdown. +- `purifierUriSchemes()` (`functions/sanitize.php`) is the one list of address schemes HTMLPurifier lets through - `http`, `https`, `mailto`, `tel` and `data` - for `documentHtmlPurify()` and the ticket views (`agent/ticket.php`, `agent/modals/ticket/ticket.php`, `client/ticket.php`, `guest/guest_view_ticket.php`, `guest/guest_approve_ticket_task.php`), each of which set `http`/`https`/`data` only. HTMLPurifier still checks each: a `mailto:` must be an address, a `tel:` is cut down to its digits, and `javascript:`, `vbscript:`, `file:` and the rest go. Database 4.4.5 makes `document_content` and `kb_article_content` (with their `_raw` search text) again from the Markdown of those with `mailto:` or `tel:` in it, keeping `_updated_at`; it stops, to be run again, if the process still has the functions from before it. +- `kbCopyLinks($row)` (`functions/kb.php`) gives an article's links for its readers - `[label, icon, url, why not, what it is]`, from `kbPublicUrl()`, `kbPortalArticleUrl()` and the new `kbAgentArticleUrl()` - with why one won't open yet (a draft, `kbPublicOn()` or `moduleOn('portal')` off); `kbCopyLinksMenuHtml()` makes them `.clipboardjs` dropdown items, or disabled ones with the reason in `.itflow-dropdown-why`. `agent/kb_article.php` and the rows of `agent/kb.php` show their ⋮ menu for `kbCan(1)` as well as `kbCan(2)` - with only these items for those who can't edit. +- Vendors permission: `module_vendor` (database 4.4.6, module 9 on a fresh install, `setup/seed_data.php` - Technician Read, Accountant Full); 4.4.6 gives every role `max(1, its module_financial level)`. In `functions/vendor.php`, `vendorPermissionReady()` (4.4.6) switches `vendorModule(0)` from `module_financial` to `module_vendor`, and `vendorCan(0, 1)` from always-yes to the permission; `vendorEnforce(0, $level)` enforces it at every level. `vendorIsOurs($vendor_id)` (one query a page) and `vendorCanOpen($vendor_id)` decide whether a mention of a vendor opens: `vendorLink()` and the new `vendorNameHtml()` show the name without a link, and `vendorRedact($row, $vendor_id)` blanks a row's `vendor_phone`, `vendor_account_number`, `vendor_code`, `vendor_email`, contacts and hours - used by `agent/network.php`, `agent/license.php`, `agent/ticket.php`, `agent/service.php` and the network, license and service quick looks. `vendorLink()` no longer puts a client's id on a page link to one of ours. The ours list (`agent/vendors.php`), its export, the vendor quick look and global search's Vendors group check it; the side nav's Vendors goes to `vendors.php?view=clients` without it. `roleModules()` lists modules in `roleModuleInfo()`'s order, then by id. +- Linked assets: `asset_links` (database 4.4.7) keeps each link as two rows, (`asset_id`, `linked_asset_id`) and the reverse, both `ON DELETE CASCADE`. `functions/asset_link.php` has `assetLinksReady()` (4.4.7), `assetLinked($asset_id)` (the client's assets, not archived), `assetLinkedNames($asset_ids)` for a list in one query, `assetLinkedTo()`, `assetLinkAdd($asset_id, $ids)` and `assetLinkRemove($asset_id, $other_id)` - each writes an `asset_history` row on both sides and `logAudit('Asset', 'Link')` or `'Unlink'` - and `assetLinkedListHtml()` for the card. The link picker (`functions/link_picker.php`) takes `asset|asset` in `LINK_PICKER_OWN`, with Support at Modify; it is kept out of `LINK_RELATIONS`, whose code assumes two different kinds. `agent/post/asset.php` adds `unlink_asset_link` and `move_linked_asset`, which sets one asset's location to the other's through `assetQuickSet()`, and `bulk_transfer_client_asset` copies the links between the assets it moves to their new copies. `clientExportLinks()` lists each pair once. +- Ticket assets: New Ticket, Edit Ticket, `agent/modals/ticket/ticket_edit_asset.php` and both recurring ticket windows post one `assets[]` multi-select, an `assets_form` marker and `asset_main`, in place of `asset_id` (`asset` in the Assets window) and `additional_assets[]`. The tables are unchanged. `ticketAssetsPosted($client_id, $main_field)` (`functions/ticket.php`) reads it - the client's own in the order posted, `asset_main` kept as `ticket_asset_id` while it is picked, else the first, the rest to `ticket_assets` - and still reads the old fields. `ticketAssetsSave()` writes both and notes the assets added and removed in `ticket_history`; `ticketOtherAssetIds()` lists the others by name; `ticketAssetsFieldHtml()` draws the field for the edit windows. `agent/js/tickets_add_modal.js` fills one `#assetSelect` and keeps the first asset picked in `#assetMain`. `remove_ticket_asset` (`delete_ticket_additional_asset` still works) takes the main asset off too, the first of the others by name taking its place. The tickets list search also looks through `ticket_assets`, and the ticket quick look (`agent/modals/ticket/ticket.php`) lists them. +- Field and parameter names CrowdSec's copy of the OWASP Core Rule Set blocks: the `appsec-crs` collections install CRS 4.0.0-rc1 from crowdsecurity/sec-lists, whose rule 932260 matches `sched` at the start of any argument's name or value (upstream CRS has dropped it as a false positive). Renamed: New Ticket's `schedule` and `schedule_minutes` to `book_at` and `book_minutes`, which Dispatch's link to it uses too; the Schedule window's `scheduled_date_time`, `schedule_tech` and `schedule_minutes` to `book_at`, `book_agent` and `book_minutes`; the helper window's to `book_at` and `book_minutes`; recurring tickets' `schedule_time`, `schedule_minutes` and `schedule_onsite` to `book_time`, `book_minutes` and `book_onsite` (`agent/includes/inc_recurring_ticket_ahead.php`); the cron job window's `schedule` to `job_schedule`; the tickets list's `show=scheduled` to `show=booked`; and Maintenance > Cron's `sort=schedule` to `sort=when`. Stripe Checkout's return URLs carry `checkout={CHECKOUT_SESSION_ID}` in place of `session_id`, which rule 943120 blocks when there is no Referer (`guestCheckoutSessionId()` in `guest/guest_post.php`). Each handler and page still reads the old name. Every field name, URL parameter and link value in the code was put through CrowdSec's Coraza fork (v3.8.1-crowdsec.20261110) with its CRS 4.0.0-rc1 and 4.31.0 at paranoia level 1, and nothing else matches. CONTRIBUTING.md has the rule. + ## [26.12.5] ### Upgrading to 26.12.5 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 92036aa27..ec95daa5d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -184,6 +184,8 @@ Two portals are gated differently, which is why their handlers look like they ar - **Client portal.** `client/post.php` is a single file of action blocks rather than a dispatcher, and gates on the contact's own capabilities with `enforceContactCan('accounting'|'contacts'|'itdoc')`. Everywhere else — anything under `agent/post/` — the call belongs in the block. + +**Switched-off modules.** The parts of ITFlow an admin can switch off in Admin > Settings > Modules (`moduleOn()` in `functions/settings.php`) are a separate gate from roles. A new page, window, portal page or guest page of one goes in `modulePaths()` - a folder with a trailing `/` covers every window in it - and `moduleRequestGuard()` turns it away while the module is off; a new report says its module in `'feature'`, and a new API resource goes in `$resource_feature` in `api/v1/enforce_api_rbac.php`. Anything on another page that leads into a module - a tab, a New item, a button, a link - checks `moduleOn()` itself; `moduleLink()` names a record without linking it. A setting or field left off a form while its module is off must keep its saved value when the form is saved. ### 4. Client scoping is enforced, not assumed. @@ -268,6 +270,10 @@ The prefix is the entity name, which is usually but not always the singular of t Two standing exceptions: junction tables (`client_tags`, `service_assets`, …) carry the two parent FK names unprefixed, and `settings` / `user_settings` use `config_*` / `user_config_*`. +**Read an uploaded CSV through `csvTextToUtf8()`.** Excel's plain CSV is Windows-1252 on Windows and Mac Roman on a Mac, and its Unicode Text is UTF-16. Read raw, an accented letter turns into `?` at the first `mb_substr()`, or breaks `json_encode()` outright. `importFile()` does it for the Import window. Anything reading `$_FILES` itself puts the text through `csvTextToUtf8()` and `fgetcsv()`s it from `php://temp`, as `expenseImportRead()`, `agent/post/network_ip.php` and `agent/post/asset_interface.php` do. `escapeSql()`'s Windows-1252 fallback works on one value at a time, so it can't tell a Mac file from a Windows one. + +**Don't start a field name, or a value in an address, with a Unix command's name.** CrowdSec's web application firewall runs its own copy of the OWASP Core Rule Set - the `appsec-crs` collections install CRS 4.0.0-rc1 from crowdsecurity/sec-lists - whose rule 932260 blocks a request when any field or URL parameter's name or value starts with a command on its list, and bans whoever sends a few. `sched` is on it, so a field named `schedule_minutes` blocked every new ticket. The booking fields are `book_at`, `book_minutes`, `book_onsite`, `book_time` and `book_agent`, the tickets list's tab is `show=booked` and Maintenance > Cron sorts by `when`. Before using a name that starts with a word like that, check it against `appsec/crs/4.0.0-rc1/REQUEST-932-APPLICATION-ATTACK-RCE.conf` in that repo. What an editor holds is a separate case - it goes as a file beside the form (`itflowFields` in `js/http.js`). + **Schema changes require two edits in one PR:** 1. `db.sql` — so fresh installs get the new schema. diff --git a/admin/agent_banners.php b/admin/agent_banners.php index 9ca549f07..aa08fb8bc 100644 --- a/admin/agent_banners.php +++ b/admin/agent_banners.php @@ -90,7 +90,7 @@ $csrf = $_SESSION['csrf_token'];
Banners come with the 3.7.2 database update - run it in Update.
-

Along the top of agents' pages - for every client on every page, or for one client on its pages and its tickets, invoices, quotes and projects. Agents who can edit a client add its banners from its ⋮ menu. Clients don't see them; for a note on the client portal, use announcements.

+

Along the top of agents' pages - for every client on every page, or for one client on its pages and its tickets, invoices, quotes and projects. Agents who can edit a client add its banners from its ⋮ menu. Clients don't see themannouncements' : '' ?>.

diff --git a/admin/categories.php b/admin/categories.php index e50959df5..240405f8b 100644 --- a/admin/categories.php +++ b/admin/categories.php @@ -19,8 +19,12 @@ $order = "ASC"; require_once "includes/inc_all_admin.php"; -$kinds = categoryKinds(); -$kind = isset($kinds[$_GET['category'] ?? '']) ? (string) $_GET['category'] : 'Expense'; +// The kinds of the parts of ITFlow switched on (Admin > Settings > Modules) - the first when none is asked for +$kinds = categoryKindsOn(); +$kind = isset($kinds[$_GET['category'] ?? '']) ? (string) $_GET['category'] : (string) array_key_first($kinds); +// The sort and page links keep the kind shown, not one asked for that isn't there (includes/filter_header.php built the sort ones) +$_GET['category'] = $kind; +$url_query_strings_sort = http_build_query(['category' => $kind] + array_diff_key($_GET, ['sort' => 1, 'order' => 1])); $config = categoryKind($kind); // ?archived=1 is how older links asked for the archived ones $show_archived = ($_GET['show'] ?? '') === 'archived' || !empty($_GET['archived']); diff --git a/admin/cron.php b/admin/cron.php index 5b37ca537..7d22b1262 100644 --- a/admin/cron.php +++ b/admin/cron.php @@ -16,8 +16,9 @@ * there is nothing to change about it until cron has run once. */ -// The list: by schedule until a heading is clicked - the every-minute jobs, then the day's in the order they run -$sort = "schedule"; +// The list: by schedule until a heading is clicked - the every-minute jobs, then the day's in the order they run. +// Its key is when, not schedule: a web application firewall takes a value starting sched for the Unix command. +$sort = "when"; $order = "ASC"; require_once "includes/inc_all_admin.php"; @@ -233,23 +234,26 @@ $command_block = function () use ($cron_command) { }; $owner_note = $file_owner !== '' ? ' (' . escapeHtml($file_owner) . ' here)' : ''; -// The list - only these sort; anything else asked for falls back to the schedule +// The list - only these sort; anything else asked for falls back to the schedule (schedule is when's name from before) +if ($sort === 'schedule') { + $sort = 'when'; +} $sort_keys = [ 'job' => function ($job) { return strtolower($job['label']); }, - 'schedule' => function ($job) { return $job['schedule'] === 'Daily' ? 100000 + intval(substr($job['daily_at'], 0, 2)) * 60 + intval(substr($job['daily_at'], 3, 2)) : $job['interval_minutes']; }, + 'when' => function ($job) { return $job['schedule'] === 'Daily' ? 100000 + intval(substr($job['daily_at'], 0, 2)) * 60 + intval(substr($job['daily_at'], 3, 2)) : $job['interval_minutes']; }, 'last_run' => function ($job) { return $job['last_run_at'] ? strtotime($job['last_run_at']) : 0; }, // What needs a look first 'status' => function ($job) { return array_search($job['state'], ['failed', 'lost', 'queued', 'running', 'paused', 'skipped', 'never', 'completed', 'unused'], true); }, ]; if (!isset($sort_keys[$sort])) { - $sort = 'schedule'; + $sort = 'when'; } uasort($jobs, function ($a, $b) use ($sort_keys, $sort, $order) { $compared = $sort_keys[$sort]($a) <=> $sort_keys[$sort]($b); return ($order === 'DESC' ? -$compared : $compared) ?: $a['position'] <=> $b['position']; }); // A heading sorts its own way round first - names A to Z, the latest run and what needs a look at the top - then the other -$sort_first = ['job' => 'ASC', 'schedule' => 'ASC', 'last_run' => 'DESC', 'status' => 'ASC']; +$sort_first = ['job' => 'ASC', 'when' => 'ASC', 'last_run' => 'DESC', 'status' => 'ASC']; $sort_link = function ($column, $label) use ($sort_first) { return sortLink($column, $label, $sort_first[$column] ?? null); }; @@ -387,7 +391,7 @@ $status_looks = [ - + diff --git a/admin/database_updates/4.4.4.php b/admin/database_updates/4.4.4.php new file mode 100644 index 000000000..a53a4b9d5 --- /dev/null +++ b/admin/database_updates/4.4.4.php @@ -0,0 +1,33 @@ + Warranty Lookup): + * settings.config_warranty_dell_client_id / _secret - a Dell TechDirect Warranty API key; the + * secret sealed (secretSeal(), 'warranty') + * settings.config_warranty_hp_client_id / _secret - an HP Warranty API key, the same + * settings.config_warranty_lenovo - Lenovo serials looked up on Lenovo's support site, which needs + * no key; on by default + * + * Re-runnable: each column is added only where it isn't there. + */ + +defined('FROM_DB_UPDATER') || die("Direct file access is not allowed"); + + $itflow_warranty_columns = [ + ['config_warranty_dell_client_id', "varchar(200) DEFAULT NULL"], + ['config_warranty_dell_client_secret', "text DEFAULT NULL"], + ['config_warranty_hp_client_id', "varchar(200) DEFAULT NULL"], + ['config_warranty_hp_client_secret', "text DEFAULT NULL"], + ['config_warranty_lenovo', "tinyint(1) NOT NULL DEFAULT 1"], + ]; + foreach ($itflow_warranty_columns as [$itflow_column, $itflow_definition]) { + $itflow_column_exists = mysqli_query($mysqli, "SELECT 1 FROM information_schema.COLUMNS + WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'settings' AND COLUMN_NAME = '$itflow_column' LIMIT 1"); + if (!$itflow_column_exists || mysqli_num_rows($itflow_column_exists) === 0) { + mysqli_query($mysqli, "ALTER TABLE `settings` ADD `$itflow_column` $itflow_definition"); + } + } diff --git a/admin/database_updates/4.4.5.php b/admin/database_updates/4.4.5.php new file mode 100644 index 000000000..89c2d4742 --- /dev/null +++ b/admin/database_updates/4.4.5.php @@ -0,0 +1,54 @@ + 0; +}; + +if ($itflow_column_there('documents', 'document_markdown')) { + $itflow_rows = mysqli_query($mysqli, "SELECT document_id, document_name, document_markdown FROM documents + WHERE document_markdown IS NOT NULL AND (document_markdown LIKE '%mailto:%' OR document_markdown LIKE '%tel:%')"); + while ($itflow_rows && ($itflow_row = mysqli_fetch_assoc($itflow_rows))) { + $itflow_html = markdownToHtml($itflow_row['document_markdown']); + mysqli_query($mysqli, "UPDATE documents SET + document_content = '" . mysqli_real_escape_string($mysqli, $itflow_html) . "', + document_content_raw = '" . escapeSql(documentContentRaw($itflow_row['document_name'], $itflow_html)) . "', + document_updated_at = document_updated_at + WHERE document_id = " . intval($itflow_row['document_id'])); + } +} + +if ($itflow_column_there('kb_articles', 'kb_article_markdown')) { + $itflow_rows = mysqli_query($mysqli, "SELECT kb_article_id, kb_article_title, kb_article_summary, kb_article_markdown FROM kb_articles + WHERE kb_article_markdown IS NOT NULL AND (kb_article_markdown LIKE '%mailto:%' OR kb_article_markdown LIKE '%tel:%')"); + while ($itflow_rows && ($itflow_row = mysqli_fetch_assoc($itflow_rows))) { + $itflow_html = markdownToHtml($itflow_row['kb_article_markdown']); + mysqli_query($mysqli, "UPDATE kb_articles SET + kb_article_content = '" . mysqli_real_escape_string($mysqli, $itflow_html) . "', + kb_article_content_raw = '" . escapeSql(kbArticleContentRaw($itflow_row['kb_article_title'], (string) $itflow_row['kb_article_summary'], $itflow_html)) . "', + kb_article_updated_at = kb_article_updated_at + WHERE kb_article_id = " . intval($itflow_row['kb_article_id'])); + } +} diff --git a/admin/database_updates/4.4.6.php b/admin/database_updates/4.4.6.php new file mode 100644 index 000000000..f8e9b6292 --- /dev/null +++ b/admin/database_updates/4.4.6.php @@ -0,0 +1,36 @@ + Roles (module_vendor, functions/vendor.php): our own vendors - + * the ones with no client: suppliers, distributors, the colo - to see (Read), change (Modify) and + * delete (Full), so a role can keep technicians out of their numbers, accounts and contacts. A + * client's vendors stay with the Clients permission. + * + * Until now anyone could see ours and Financial changed them, so each role is given that here: + * Read, or its Financial level when that is higher. Nothing changes until an admin lowers it. + * Admins have every permission. + * + * Re-runnable: the permission, and each role's level for it, is added only where it isn't there. + */ + +defined('FROM_DB_UPDATER') || die("Direct file access is not allowed"); + +if (!mysqli_num_rows(mysqli_query($mysqli, "SELECT 1 FROM modules WHERE module_name = 'module_vendor'"))) { + mysqli_query($mysqli, "INSERT INTO modules SET module_name = 'module_vendor', module_description = 'Our own vendors - suppliers, distributors, the colo - with their numbers, accounts and contacts'"); +} +$itflow_vendor_module = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT module_id FROM modules WHERE module_name = 'module_vendor' LIMIT 1"))[0]); +$itflow_financial_module = intval((mysqli_fetch_row(mysqli_query($mysqli, "SELECT module_id FROM modules WHERE module_name = 'module_financial' LIMIT 1")) ?: [0])[0]); + +$itflow_roles = mysqli_query($mysqli, "SELECT role_id, + (SELECT MAX(user_role_permission_level) FROM user_role_permissions WHERE user_role_id = role_id AND module_id = $itflow_financial_module) AS financial, + (SELECT COUNT(*) FROM user_role_permissions WHERE user_role_id = role_id AND module_id = $itflow_vendor_module) AS has_vendor + FROM user_roles"); +while ($itflow_roles && ($itflow_role = mysqli_fetch_assoc($itflow_roles))) { + if (intval($itflow_role['has_vendor']) === 0) { + mysqli_query($mysqli, "INSERT INTO user_role_permissions SET user_role_id = " . intval($itflow_role['role_id']) . ", + module_id = $itflow_vendor_module, user_role_permission_level = " . max(1, min(3, intval($itflow_role['financial'])))); + } +} diff --git a/admin/database_updates/4.4.7.php b/admin/database_updates/4.4.7.php new file mode 100644 index 000000000..72b153adf --- /dev/null +++ b/admin/database_updates/4.4.7.php @@ -0,0 +1,25 @@ +RMM Providers

+ + + +
While the contract is in force, time bills at these rates - the after-hours one for tickets opened outside business hours - and new invoices are due on these terms. Leave one empty and the default in Admin > Settings > Defaults applies - a rate of 0 bills that time at nothing. + Settings > Modules) + foreach (CONTRACT_SLA_PRIORITIES as $priority => $part) { ?> + "> + $part) { ?>
@@ -159,6 +165,7 @@ $tab = 'templateTab' . bin2hex(random_bytes(3));
From Admin > SLAs. While the contract is in force, the client's new tickets get them, and the default for a priority left on the default.
+
diff --git a/admin/modals/cron/cron_edit.php b/admin/modals/cron/cron_edit.php index d99774e7d..100270089 100644 --- a/admin/modals/cron/cron_edit.php +++ b/admin/modals/cron/cron_edit.php @@ -51,7 +51,7 @@ ob_start();
- diff --git a/admin/modals/tag/tag_form.php b/admin/modals/tag/tag_form.php index aef2c54fd..c02a30ae2 100644 --- a/admin/modals/tag/tag_form.php +++ b/admin/modals/tag/tag_form.php @@ -49,7 +49,7 @@ if (!in_array($t_icon, $t_icons, true)) {
' + . '' + . '
'; +}; +$state = function ($on, $off_text) { + return ($on ? 'On' : '' . escapeHtml($off_text) . '') . ' '; +}; + +echo settingsPageStart('warranty'); + +?> + + + + +
+
+ + +
+

On one asset - the button beside Warranty expires on its Purchase tab, before you save.

+

On many - select them on Assets, then Bulk Action > Look Up Warranty.

+

The warranty date is when the last of the manufacturer's coverage for it ends; the purchase date, when its warranty began - for Dell, the day it shipped.

+
+ + + techdirect.dell.com
under Services > APIs - Dell approves it, usually within a few days.') ?> +
+
+ 'fa-id-badge', 'label' => 'Client ID', 'maxlength' => 200, + 'help' => 'Empty switches Dell lookups off, and forgets its secret.']) ?> +
+
+ 'fa-key', 'type' => 'password', 'label' => 'Client secret', 'maxlength' => 500, + 'autocomplete' => 'new-password', 'placeholder' => $saved_secret($warranty['config_warranty_dell_client_secret'])]) ?> +
+
+ + + + + 'Look up Lenovo serial numbers on Lenovo\'s support site']) ?> + + + + developers.hp.com, then email warrantyapi.customers@hp.com for access - HP approves each by hand and doesn\'t give every IT company one. Not for HP Enterprise (HPE) servers, which have no such API.') ?> +
+
+ 'fa-id-badge', 'label' => 'API key', 'maxlength' => 200, + 'help' => 'Empty switches HP lookups off, and forgets its secret.']) ?> +
+
+ 'fa-key', 'type' => 'password', 'label' => 'API secret', 'maxlength' => 500, + 'autocomplete' => 'new-password', 'placeholder' => $saved_secret($warranty['config_warranty_hp_client_secret']), + 'help' => 'HP works through each lookup as a job, so its answers can take a few minutes.']) ?> +
+
+ + + + +
+
+ + + Settings > Modules) $kinds = []; -foreach (tagKinds() as $kind_type => $kind_entity) { +foreach (tagKindsOn() as $kind_type => $kind_entity) { $kinds[$kind_type] = tagEntity($kind_entity); } $type = intval($_GET['type'] ?? 1); $type = isset($kinds[$type]) ? $type : 1; +// The sort and page links keep the kind shown, not one asked for that isn't there (includes/filter_header.php built the sort ones) +$_GET['type'] = $type; +$url_query_strings_sort = http_build_query(['type' => $type] + array_diff_key($_GET, ['sort' => 1, 'order' => 1])); $kind = $kinds[$type]; // ?archived=1 is how older links asked for the archived ones $show_archived = ($_GET['show'] ?? '') === 'archived' || !empty($_GET['archived']); diff --git a/admin/tax_rates.php b/admin/tax_rates.php index 226b39c4e..eb650ad29 100644 --- a/admin/tax_rates.php +++ b/admin/tax_rates.php @@ -212,14 +212,23 @@ $used_text = function (array $u) {
+ Settings > Modules) keep what they are + if (moduleOn('ticketing')) { ?>
>
+ + + +
>
+ + +
> diff --git a/agent/ajax.php b/agent/ajax.php index 69de205a4..434559d69 100644 --- a/agent/ajax.php +++ b/agent/ajax.php @@ -1687,6 +1687,21 @@ if (isset($_GET['get_document_content'])) { } +/* + * An uploaded .md file as its Markdown reads, for the files grid's previewer and the file's quick + * look - made safe by markdownToHtml(). The pictures it points to that are in the client's Files + * show from there (functions/markdown_upload.php). + */ +if (isset($_GET['get_file_markdown'])) { + header('Content-Type: application/json'); + + // Whoever can open the files list can preview its files + enforceUserPermission('module_client'); + + echo json_encode(['content' => fileMarkdownPreviewHtml(intval($_GET['get_file_markdown']))]); + exit; +} + /* * Returns ordered list of active contacts for a specified client */ @@ -2384,6 +2399,51 @@ if (isset($_GET['asset_duplicate_check'])) { exit; } +/* + * Warranty lookup (functions/warranty.php, js/warranty_lookup.js). warranty_lookup: asset_ids[] - + * up to 25 assets, looked up and their empty dates filled, for Assets' bulk window; or make, model + * and serial - what the asset form has typed, looked up for the form to fill in. warranty_hp_check: + * an HP job asked after, with the same asset_ids[] or serial. Answers {results} or {answer}, an HP + * job not finished {done: false}, and anything refused {error}. + */ +if (isset($_POST['warranty_lookup']) || isset($_POST['warranty_hp_check'])) { + validateCSRFToken(); + header('Content-Type: application/json'); + if (!moduleOn('itdoc')) { + exit(json_encode(['error' => moduleOffText('itdoc')])); + } + if (lookupUserPermission('module_support') < 2) { + exit(json_encode(['error' => 'Looking up warranties takes Support at Modify in your role.'])); + } + if (!warrantyAnyReady()) { + exit(json_encode(['error' => 'Warranty lookup isn\'t set up - Admin > Warranty Lookup.'])); + } + session_write_close(); // a lookup can take a while - other pages needn't wait on it + $asset_ids = array_slice(array_map('intval', (array) ($_POST['asset_ids'] ?? [])), 0, 25); + + if (isset($_POST['warranty_hp_check'])) { + $job = (string) $_POST['warranty_hp_check']; + if ($asset_ids) { + $check = warrantyAssetsHpCheck($job, $asset_ids); + exit(json_encode($check['done'] ? ['done' => true, 'results' => $check['results']] : ['done' => false])); + } + $serial = strtoupper(trim((string) ($_POST['serial'] ?? ''))); + $check = warrantyHpCheck($job, [$serial]); + if (!$check['done']) { + exit(json_encode(['done' => false])); + } + $result = $check['error'] !== '' ? warrantyNotFound($check['error'], 'error') : ($check['results'][$serial] ?? warrantyNotFound("doesn't know serial number $serial")); + exit(json_encode(['done' => true, 'answer' => warrantyFormAnswer('hp', $result)])); + } + + if ($asset_ids) { + exit(json_encode(['results' => warrantyAssetsLookup($asset_ids)])); + } + $maker = warrantyMaker($_POST['make'] ?? '', $_POST['model'] ?? ''); + $result = warrantyLookup(['form' => ['maker' => $maker, 'serial' => mb_substr((string) ($_POST['serial'] ?? ''), 0, 60)]])['form']; + exit(json_encode(['answer' => warrantyFormAnswer($maker, $result)])); +} + if (isset($_GET['client_duplicate_check'])) { header('Content-Type: application/json'); diff --git a/agent/asset.php b/agent/asset.php index b66cb31c8..be2dc22c4 100644 --- a/agent/asset.php +++ b/agent/asset.php @@ -120,6 +120,8 @@ if (mysqli_num_rows($sql) == 0) { $can_edit = lookupUserPermission('module_support') >= 2; $can_delete = lookupUserPermission('module_support') >= 3; + // The assets it's linked to - a part on it, or what it sits on (functions/asset_link.php) + $asset_linked = assetLinked($asset_id); $can_credentials = lookupUserPermission('module_credential') >= 1; $can_credentials_edit = lookupUserPermission('module_credential') >= 2; @@ -251,6 +253,11 @@ if (mysqli_num_rows($sql) == 0) { if (!$can_credentials) { unset($asset_tabs['credentials']); } + // Ticketing switched off (Admin > Settings > Modules) - its tabs and New items go + $asset_ticketing = moduleOn('ticketing'); + if (!$asset_ticketing) { + unset($asset_tabs['tickets'], $asset_tabs['recurring']); + } ?> @@ -339,12 +346,14 @@ if (mysqli_num_rows($sql) == 0) {