From 36503ca7682684a5c0a9b05f3426280b90eccc1e Mon Sep 17 00:00:00 2001 From: johnnyq Date: Fri, 4 Dec 2026 21:53:24 -0500 Subject: [PATCH] Warranty lookup by serial number: Admin > Warranty Lookup sets up Dell with a TechDirect key, HP with a Warranty API key and Lenovo through its support site with no key, each with Save and test; the search button beside Warranty expires on the asset form fills the empty warranty and purchase dates and offers the maker's date beside one already set, and Bulk Action > Look Up Warranty on Assets fills many at once with each answer listed and noted in the asset's history; database 4.4.4; 26.12.6 changelog --- CHANGELOG.md | 7 +- admin/database_updates/4.4.4.php | 33 ++ admin/includes/side_nav.php | 2 + admin/post/settings_warranty.php | 87 ++++ admin/settings_warranty.php | 101 ++++ agent/ajax.php | 45 ++ agent/assets.php | 8 + agent/modals/asset/asset_bulk_warranty.php | 72 +++ agent/modals/asset/asset_form.php | 6 + db.sql | 5 + functions.php | 1 + functions/settings.php | 13 +- functions/warranty.php | 557 +++++++++++++++++++++ includes/footer.php | 1 + js/warranty_lookup.js | 276 ++++++++++ 15 files changed, 1212 insertions(+), 2 deletions(-) create mode 100644 admin/database_updates/4.4.4.php create mode 100644 admin/post/settings_warranty.php create mode 100644 admin/settings_warranty.php create mode 100644 agent/modals/asset/asset_bulk_warranty.php create mode 100644 functions/warranty.php create mode 100644 js/warranty_lookup.js diff --git a/CHANGELOG.md b/CHANGELOG.md index f78719101..70c48a9b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,11 +6,12 @@ This file documents all notable changes made to ITFlow. ### Upgrading to 26.12.6 -Update from Maintenance > Update as usual. There is no database change. +Update from Maintenance > Update as usual. This release has one database change: 4.4.4 adds the settings for Warranty Lookup. - 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. ### New Features & Updates @@ -19,6 +20,8 @@ Update from Maintenance > Update as usual. There is no database change. - 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. ### Bug Fixes @@ -37,6 +40,8 @@ Update from Maintenance > Update as usual. There is no database change. - 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`. ## [26.12.5] 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/includes/side_nav.php b/admin/includes/side_nav.php index d1a21c7ac..adcf5563e 100644 --- a/admin/includes/side_nav.php +++ b/admin/includes/side_nav.php @@ -173,6 +173,8 @@

Phone Systems

+ +