mirror of
https://github.com/itflow-org/itflow
synced 2026-12-05 18:49:01 +00:00
Merge pull request #1321 from itflow-org/develop
Develop to master for 26.12.6 release
This commit is contained in:
63
CHANGELOG.md
63
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 `<a>` or, with the module off, a `<span>`; `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 `<span>`; `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)` - ``, `<img src>`, `[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/<id>/` 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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -90,7 +90,7 @@ $csrf = $_SESSION['csrf_token'];
|
||||
<?php if (!$ready) { ?>
|
||||
<div class="alert alert-warning py-2 small"><i class="fas fa-exclamation-triangle me-2"></i>Banners come with the 3.7.2 database update - run it in <a href="update.php">Update</a>.</div>
|
||||
<?php } ?>
|
||||
<p class="text-secondary small mb-3">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 <strong>⋮</strong> menu. Clients don't see them; for a note on the client portal, use <a href="settings_client_portal.php">announcements</a>.</p>
|
||||
<p class="text-secondary small mb-3">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 <strong>⋮</strong> menu. Clients don't see them<?= moduleOn('portal') ? '; for a note on the client portal, use <a href="settings_client_portal.php">announcements</a>' : '' ?>.</p>
|
||||
<form autocomplete="off">
|
||||
<?php if ($show !== '') { ?><input type="hidden" name="show" value="<?= escapeHtml($show) ?>"><?php } ?>
|
||||
<div class="row g-2 align-items-center">
|
||||
|
||||
@@ -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']);
|
||||
|
||||
@@ -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 !== '' ? ' (<code>' . escapeHtml($file_owner) . '</code> 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 = [
|
||||
<thead class="table-light text-nowrap">
|
||||
<tr>
|
||||
<th class="ps-3" colspan="2"><?= $sort_link('job', 'Job') ?></th>
|
||||
<th class="d-none d-md-table-cell"><?= $sort_link('schedule', 'Schedule') ?></th>
|
||||
<th class="d-none d-md-table-cell"><?= $sort_link('when', 'Schedule') ?></th>
|
||||
<th class="d-none d-md-table-cell"><?= $sort_link('last_run', 'Last run') ?></th>
|
||||
<th><?= $sort_link('status', 'Status') ?></th>
|
||||
<th></th>
|
||||
|
||||
33
admin/database_updates/4.4.4.php
Normal file
33
admin/database_updates/4.4.4.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* ITFlow - Database update to version 4.4.4 (from 4.4.3)
|
||||
* Included by admin/database_updates.php - do not access directly
|
||||
*
|
||||
* Warranty lookup (functions/warranty.php) - an asset's warranty end and purchase date filled from
|
||||
* its serial number, by its manufacturer (Admin > 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");
|
||||
}
|
||||
}
|
||||
54
admin/database_updates/4.4.5.php
Normal file
54
admin/database_updates/4.4.5.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* ITFlow - Database update to version 4.4.5 (from 4.4.4)
|
||||
* Included by admin/database_updates.php - do not access directly
|
||||
*
|
||||
* Email (mailto:) and phone (tel:) links are let through now (purifierUriSchemes(), functions/
|
||||
* sanitize.php). A document or Knowledge Base article written in Markdown keeps the HTML made from
|
||||
* it when it was saved (markdownToHtml()), which had those links taken out - each one whose
|
||||
* Markdown has such a link has its HTML made again, so they work without saving it again. When it
|
||||
* was last updated stays as it was. Rich text is made safe as it is shown, so it needs nothing.
|
||||
*
|
||||
* Re-runnable: the same Markdown makes the same HTML.
|
||||
*/
|
||||
|
||||
defined('FROM_DB_UPDATER') || die("Direct file access is not allowed");
|
||||
|
||||
// Made by the code from before this release, the links would come out again - so stop, and the
|
||||
// next run, on the updated code, picks up here (scripts/update_cli.php runs it so when it can)
|
||||
if (!function_exists('purifierUriSchemes') || !function_exists('markdownToHtml')) {
|
||||
throw new Exception('this update needs the updated code loaded - run the update again');
|
||||
}
|
||||
|
||||
$itflow_column_there = function ($table, $column) use ($mysqli) {
|
||||
$result = mysqli_query($mysqli, "SELECT 1 FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = '$table' AND COLUMN_NAME = '$column' LIMIT 1");
|
||||
return $result && mysqli_num_rows($result) > 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']));
|
||||
}
|
||||
}
|
||||
36
admin/database_updates/4.4.6.php
Normal file
36
admin/database_updates/4.4.6.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* ITFlow - Database update to version 4.4.6 (from 4.4.5)
|
||||
* Included by admin/database_updates.php - do not access directly
|
||||
*
|
||||
* A Vendors permission for Admin > 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']))));
|
||||
}
|
||||
}
|
||||
25
admin/database_updates/4.4.7.php
Normal file
25
admin/database_updates/4.4.7.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* ITFlow - Database update to version 4.4.7 (from 4.4.6)
|
||||
* Included by admin/database_updates.php - do not access directly
|
||||
*
|
||||
* Assets linked to each other (functions/asset_link.php) - a label printer and the knife unit on
|
||||
* it, a server and its disk shelf: asset_links, one row from each side of a link, so either reads
|
||||
* it the same. A link goes when either asset is deleted.
|
||||
*
|
||||
* Re-runnable: the table is made only where it isn't there.
|
||||
*/
|
||||
|
||||
defined('FROM_DB_UPDATER') || die("Direct file access is not allowed");
|
||||
|
||||
mysqli_query($mysqli, "CREATE TABLE IF NOT EXISTS `asset_links` (
|
||||
`asset_id` int(11) NOT NULL,
|
||||
`linked_asset_id` int(11) NOT NULL,
|
||||
`asset_link_created_by` int(11) NOT NULL DEFAULT 0,
|
||||
`asset_link_created_at` datetime NOT NULL DEFAULT current_timestamp(),
|
||||
PRIMARY KEY (`asset_id`,`linked_asset_id`),
|
||||
KEY `asset_links_linked` (`linked_asset_id`),
|
||||
CONSTRAINT `asset_links_asset` FOREIGN KEY (`asset_id`) REFERENCES `assets` (`asset_id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `asset_links_linked_asset` FOREIGN KEY (`linked_asset_id`) REFERENCES `assets` (`asset_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;");
|
||||
@@ -157,6 +157,7 @@
|
||||
<p>RMM Providers</p>
|
||||
</a>
|
||||
</li>
|
||||
<?php if ($config_module_enable_itdoc) { // What a platform brings in are assets ?>
|
||||
<li class="nav-item">
|
||||
<a href="/admin/network_platforms.php"
|
||||
class="nav-link <?= ($nav_rmm_page === 'network_platforms.php' || ($nav_rmm_page === 'rmm_clients.php' && $nav_rmm_family === 'network') ? 'active' : '') ?>">
|
||||
@@ -164,6 +165,7 @@
|
||||
<p>Network Platforms</p>
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<li class="nav-item">
|
||||
<a href="/admin/phone_systems.php"
|
||||
class="nav-link <?= (in_array(basename($_SERVER['PHP_SELF']), ['phone_systems.php', 'phone_domains.php']) ? 'active' : '') ?>">
|
||||
@@ -171,6 +173,8 @@
|
||||
<p>Phone Systems</p>
|
||||
</a>
|
||||
</li>
|
||||
<?php // Asset warranties from Dell, HP and Lenovo (functions/warranty.php) - with IT documentation ?>
|
||||
<?= adminNavGroupItemHtml('warranty') ?>
|
||||
<li class="nav-item">
|
||||
<a href="/admin/identity_providers.php" class="nav-link <?= (basename($_SERVER['PHP_SELF']) == 'identity_providers.php' ? 'active' : '') ?>">
|
||||
<i class="nav-icon fas fa-id-badge"></i>
|
||||
|
||||
@@ -49,7 +49,7 @@ $c_max = $c_config['max'] ?? 200;
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-layer-group"></i></span>
|
||||
<select class="form-select select2" name="type" required>
|
||||
<option value="">- Select a type -</option>
|
||||
<?php foreach (categoryKinds() as $kind_key => $kind_config) { ?>
|
||||
<?php foreach (categoryKindsOn() as $kind_key => $kind_config) { ?>
|
||||
<option value="<?= escapeHtml($kind_key) ?>"><?= escapeHtml(ucfirst($kind_config['many'])) ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
|
||||
@@ -146,6 +146,12 @@ $tab = 'templateTab' . bin2hex(random_bytes(3));
|
||||
</div>
|
||||
</div>
|
||||
<small class="text-secondary d-block mb-3">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.</small>
|
||||
<?php if (!moduleOn('ticketing')) {
|
||||
// SLAs are ticketing's - kept as they are while it is switched off (Admin > Settings > Modules)
|
||||
foreach (CONTRACT_SLA_PRIORITIES as $priority => $part) { ?>
|
||||
<input type="hidden" name="sla_<?= $part ?>" value="<?= intval($t_value("sla_{$part}_id", 0)) ?>">
|
||||
<?php }
|
||||
} else { ?>
|
||||
<label class="form-label">SLA by ticket priority</label>
|
||||
<?php foreach (CONTRACT_SLA_PRIORITIES as $priority => $part) { ?>
|
||||
<div class="input-group mb-2">
|
||||
@@ -159,6 +165,7 @@ $tab = 'templateTab' . bin2hex(random_bytes(3));
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="form-text">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.</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="<?= $tab ?>Terms" role="tabpanel">
|
||||
|
||||
@@ -51,7 +51,7 @@ ob_start();
|
||||
<label class="form-label">Schedule</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-calendar"></i></span>
|
||||
<select class="form-select select2" name="schedule" id="cronJobSchedule">
|
||||
<select class="form-select select2" name="job_schedule" id="cronJobSchedule">
|
||||
<?php if ($cron_job_interval_safe) { ?>
|
||||
<option value="Interval" <?= $cron_job_schedule === 'Interval' ? 'selected' : '' ?>>Every so many minutes</option>
|
||||
<?php } ?>
|
||||
|
||||
@@ -49,7 +49,7 @@ if (!in_array($t_icon, $t_icons, true)) {
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-layer-group"></i></span>
|
||||
<select class="form-select select2" name="type"<?= $t_kind_locked ? ' disabled' : '' ?> required>
|
||||
<?php foreach (tagKinds() as $kind_type => $kind_entity) {
|
||||
<?php foreach (tagKindsOn() + (isset(tagKinds()[intval($type)]) ? [intval($type) => tagKinds()[intval($type)]] : []) as $kind_type => $kind_entity) {
|
||||
$kind_config = tagEntity($kind_entity); ?>
|
||||
<option value="<?= $kind_type ?>"<?= $kind_type === intval($type) ? ' selected' : '' ?>><?= $kind_config['title'] ?>s</option>
|
||||
<?php } ?>
|
||||
|
||||
@@ -18,8 +18,10 @@ $error_description = escapeSql($_GET['error_description'] ?? '');
|
||||
|
||||
$session_state = $_SESSION['mail_oauth_state'] ?? '';
|
||||
$session_state_expires = intval($_SESSION['mail_oauth_state_expires_at'] ?? 0);
|
||||
// Graph's permissions or Exchange's - what Connect asked Microsoft for (functions/mail_graph.php)
|
||||
$way = ($_SESSION['mail_oauth_way'] ?? '') === 'graph' ? 'graph' : 'exchange';
|
||||
|
||||
unset($_SESSION['mail_oauth_state'], $_SESSION['mail_oauth_state_expires_at']);
|
||||
unset($_SESSION['mail_oauth_state'], $_SESSION['mail_oauth_state_expires_at'], $_SESSION['mail_oauth_way']);
|
||||
|
||||
if (!empty($error)) {
|
||||
$msg = "Microsoft OAuth authorization failed: $error";
|
||||
@@ -48,56 +50,44 @@ if (defined('BASE_URL') && !empty(BASE_URL)) {
|
||||
}
|
||||
|
||||
$redirect_uri = $base_url . '/admin/oauth_microsoft_mail_callback.php';
|
||||
$token_url = 'https://login.microsoftonline.com/' . rawurlencode($config_mail_oauth_tenant_id) . '/oauth2/v2.0/token';
|
||||
$scope = 'offline_access openid profile https://outlook.office.com/IMAP.AccessAsUser.All https://outlook.office.com/SMTP.Send';
|
||||
|
||||
$ch = curl_init($token_url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
|
||||
// Redeemed for what was asked for - a sign-in to one API at a time
|
||||
$response = mailGraphHttp('POST', MAIL_MICROSOFT_LOGIN_URL . rawurlencode($config_mail_oauth_tenant_id) . '/oauth2/v2.0/token', [], [
|
||||
'client_id' => $config_mail_oauth_client_id,
|
||||
'client_secret' => $config_mail_oauth_client_secret,
|
||||
'grant_type' => 'authorization_code',
|
||||
'code' => $code,
|
||||
'redirect_uri' => $redirect_uri,
|
||||
'scope' => $scope,
|
||||
], '', '&'));
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
|
||||
'scope' => mailMicrosoftConnectScope($way),
|
||||
], 20);
|
||||
|
||||
$raw_body = curl_exec($ch);
|
||||
$curl_err = curl_error($ch);
|
||||
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
if ($raw_body === false || $http_code < 200 || $http_code >= 300) {
|
||||
$reason = !empty($curl_err) ? $curl_err : "HTTP $http_code";
|
||||
flashAlert("Microsoft OAuth token exchange failed: $reason", 'error');
|
||||
redirect($settings_mail_path);
|
||||
}
|
||||
|
||||
$json = json_decode($raw_body, true);
|
||||
if (!is_array($json) || empty($json['refresh_token']) || empty($json['access_token'])) {
|
||||
flashAlert("Microsoft OAuth token exchange failed: refresh token or access token missing.", 'error');
|
||||
$json = $response['json'];
|
||||
if (empty($json['refresh_token']) || empty($json['access_token'])) {
|
||||
flashAlert(escapeHtml($response['status'] >= 200 && $response['status'] < 300
|
||||
? 'Microsoft OAuth token exchange failed: refresh token or access token missing.'
|
||||
: mailGraphError($response, 'Microsoft OAuth token exchange')), 'error');
|
||||
redirect($settings_mail_path);
|
||||
}
|
||||
|
||||
$refresh_token = (string) $json['refresh_token'];
|
||||
$access_token = (string) $json['access_token'];
|
||||
$expires_at = date('Y-m-d H:i:s', time() + intval($json['expires_in'] ?? 3600));
|
||||
|
||||
$expires_at_esc = mysqli_real_escape_string($mysqli, $expires_at);
|
||||
// An SMTP and IMAP sign-in is kept as what they sign in with - a Graph one isn't theirs, so they get their own when needed
|
||||
$access_token = $way === 'exchange' ? (string) $json['access_token'] : '';
|
||||
$expires_at_sql = $way === 'exchange' ? "'" . date('Y-m-d H:i:s', time() + intval($json['expires_in'] ?? 3600)) . "'" : 'NULL';
|
||||
|
||||
// Only the token - Sending and Receiving stay as they were set; connecting for one doesn't turn on the other. Sealed (functions/mail_secret.php)
|
||||
mysqli_query($mysqli, "UPDATE settings SET
|
||||
" . mailSecretSql('config_mail_oauth_refresh_token', $refresh_token) . ",
|
||||
" . mailSecretSql('config_mail_oauth_access_token', $access_token) . ",
|
||||
config_mail_oauth_access_token_expires_at = '$expires_at_esc'
|
||||
config_mail_oauth_access_token_expires_at = $expires_at_sql
|
||||
WHERE company_id = 1
|
||||
");
|
||||
|
||||
// What Microsoft Graph can do is asked afresh with the new sign-in (functions/mail_graph.php)
|
||||
// What Microsoft Graph can do is asked afresh with the new sign-in, and SMTP and IMAP for the rest (functions/mail_graph.php)
|
||||
mailGraphForget();
|
||||
$check = mailMicrosoftCheck($config_smtp_provider === 'microsoft_oauth', $config_imap_provider === 'microsoft_oauth', false);
|
||||
|
||||
logAudit("Settings", "Edit", "$session_name connected Microsoft 365 for mail");
|
||||
flashAlert("Microsoft 365 connected - ITFlow can now use the mailbox");
|
||||
logAudit("Settings", "Edit", "$session_name connected Microsoft 365 for mail" . ($way === 'graph' ? ' through Microsoft Graph' : ' by SMTP and IMAP'));
|
||||
flashAlert($check['ok']
|
||||
? 'Microsoft 365 connected. ' . escapeHtml($check['message'])
|
||||
: '<strong>Microsoft 365 is connected, but email can\'t go yet:</strong> ' . escapeHtml($check['message']), $check['ok'] ? 'success' : 'warning');
|
||||
redirect($settings_mail_path);
|
||||
|
||||
@@ -186,7 +186,7 @@ $csrf = $_SESSION['csrf_token'];
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-url="<?= $edit_url ?>">
|
||||
<i class="fas fa-fw fa-edit text-secondary me-2"></i>Edit
|
||||
</a>
|
||||
<?php if ($used['total']) { ?>
|
||||
<?php if ($used['total'] && moduleOn('bookkeeping')) { ?>
|
||||
<a class="dropdown-item" href="<?= escapeHtml($records_url) ?>">
|
||||
<i class="fas fa-fw fa-exchange-alt text-secondary me-2"></i>See Its Transactions
|
||||
</a>
|
||||
|
||||
@@ -47,7 +47,8 @@ if (isset($_POST['edit_cron_job'])) {
|
||||
|
||||
$cron_job_name = escapeSql($row['cron_job_name']);
|
||||
$enabled = isset($_POST['enabled']) ? 1 : 0;
|
||||
$schedule = $_POST['schedule'] === 'Daily' ? 'Daily' : 'Interval';
|
||||
// (job_schedule - a web application firewall takes a field named sched... for the Unix command; schedule is from before)
|
||||
$schedule = ($_POST['job_schedule'] ?? $_POST['schedule'] ?? '') === 'Daily' ? 'Daily' : 'Interval';
|
||||
|
||||
// A job the registry marks interval-unsafe only accepts the daily schedule. The form
|
||||
// does not offer anything else, so anything else arriving here is a crafted request
|
||||
|
||||
@@ -62,7 +62,8 @@ if (isset($_POST['edit_mail_smtp_settings']) || isset($_POST['edit_mail_imap_set
|
||||
* while Microsoft isn't picked), and the refresh token. No ID forgets the app:
|
||||
* its secret and token go too. A changed app or token makes what ITFlow last
|
||||
* signed in with useless, so that is fetched afresh when next needed.
|
||||
* Connect Microsoft 365 saves the same way, then goes to Microsoft to sign in.
|
||||
* Connect Microsoft 365 saves the same way, then goes to Microsoft to sign in,
|
||||
* asking for the permissions The app has says it was given (functions/mail_graph.php).
|
||||
*/
|
||||
if (isset($_POST['edit_mail_oauth_settings']) || isset($_POST['oauth_connect_microsoft_mail'])) {
|
||||
|
||||
@@ -157,10 +158,14 @@ if (isset($_POST['edit_mail_oauth_settings']) || isset($_POST['oauth_connect_mic
|
||||
$state = sha1(uniqid((string) mt_rand(), true));
|
||||
}
|
||||
|
||||
// Graph's permissions or Exchange's, as the app was given - the callback redeems the sign-in for the same
|
||||
$way = ($_POST['oauth_connect_way'] ?? '') === 'exchange' ? 'exchange' : 'graph';
|
||||
|
||||
$_SESSION['mail_oauth_state'] = $state;
|
||||
$_SESSION['mail_oauth_state_expires_at'] = time() + 600;
|
||||
$_SESSION['mail_oauth_way'] = $way;
|
||||
|
||||
$scope = 'offline_access openid profile https://outlook.office.com/IMAP.AccessAsUser.All https://outlook.office.com/SMTP.Send';
|
||||
$scope = mailMicrosoftConnectScope($way);
|
||||
|
||||
$authorize_url = MICROSOFT_OAUTH_BASE_URL . rawurlencode($config_mail_oauth_tenant_id) . '/oauth2/v2.0/authorize?'
|
||||
. http_build_query([
|
||||
@@ -170,10 +175,11 @@ if (isset($_POST['edit_mail_oauth_settings']) || isset($_POST['oauth_connect_mic
|
||||
'response_mode' => 'query',
|
||||
'scope' => $scope,
|
||||
'state' => $state,
|
||||
'prompt' => 'consent',
|
||||
// Which account to sign in as - not the consent screen, which a mailbox that may not approve apps can't get past even when an admin has
|
||||
'prompt' => 'select_account',
|
||||
], '', '&', PHP_QUERY_RFC3986);
|
||||
|
||||
logAudit("Settings", "Edit", "$session_name started connecting Microsoft 365 for mail");
|
||||
logAudit("Settings", "Edit", "$session_name started connecting Microsoft 365 for mail" . ($way === 'graph' ? ' through Microsoft Graph' : ' by SMTP and IMAP'));
|
||||
|
||||
redirect($authorize_url);
|
||||
}
|
||||
@@ -473,17 +479,22 @@ if (isset($_POST['test_oauth_token_refresh'])) {
|
||||
redirect($mail_tab_redirect);
|
||||
}
|
||||
|
||||
$token_url = 'https://oauth2.googleapis.com/token';
|
||||
// Microsoft 365: through Graph for what the app has its permission for, SMTP and IMAP only for the rest (functions/mail_graph.php)
|
||||
if ($provider === 'microsoft_oauth') {
|
||||
$token_url = MICROSOFT_OAUTH_BASE_URL . rawurlencode($oauth_tenant_id) . "/oauth2/v2.0/token";
|
||||
$check = mailMicrosoftCheck($config_smtp_provider === 'microsoft_oauth', $config_imap_provider === 'microsoft_oauth');
|
||||
logAudit("Settings", "Edit", "$session_name tested OAuth token refresh for Microsoft 365 mail settings");
|
||||
flashAlert(($check['ok'] ? 'OAuth token refresh successful for Microsoft 365. ' : '<strong>OAuth token test failed:</strong> ') . escapeHtml($check['message']), $check['ok'] ? 'success' : 'error');
|
||||
redirect($mail_tab_redirect);
|
||||
}
|
||||
|
||||
$token_url = 'https://oauth2.googleapis.com/token';
|
||||
|
||||
$post_fields = http_build_query([
|
||||
'client_id' => $oauth_client_id,
|
||||
'client_secret' => $oauth_client_secret,
|
||||
'refresh_token' => $oauth_refresh_token,
|
||||
'grant_type' => 'refresh_token',
|
||||
] + ($provider === 'microsoft_oauth' ? ['scope' => MAIL_MICROSOFT_EXCHANGE_SCOPE] : []));
|
||||
]);
|
||||
|
||||
$ch = curl_init($token_url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
@@ -520,21 +531,8 @@ if (isset($_POST['test_oauth_token_refresh'])) {
|
||||
|
||||
mysqli_query($mysqli, "UPDATE settings SET " . mailSecretSql('config_mail_oauth_access_token', $new_access_token) . ", config_mail_oauth_access_token_expires_at = '$new_expires_at_esc'$refresh_sql WHERE company_id = 1");
|
||||
|
||||
$provider_label = $provider === 'microsoft_oauth' ? 'Microsoft 365' : 'Google Workspace';
|
||||
logAudit("Settings", "Edit", "$session_name tested OAuth token refresh for $provider_label mail settings");
|
||||
logAudit("Settings", "Edit", "$session_name tested OAuth token refresh for Google Workspace mail settings");
|
||||
|
||||
// And what Microsoft Graph can do for the mailbox now - asked afresh (functions/mail_graph.php)
|
||||
$graph_said = '';
|
||||
if ($provider === 'microsoft_oauth') {
|
||||
try {
|
||||
$graph_send = mailGraphToken('Mail.Send', true) !== null;
|
||||
$graph_read = mailGraphToken('Mail.ReadWrite') !== null;
|
||||
$graph_said = ' ' . mailGraphSays($config_smtp_provider === 'microsoft_oauth', $config_imap_provider === 'microsoft_oauth', $graph_send, $graph_read);
|
||||
} catch (\Throwable $e) {
|
||||
$graph_said = ' ' . escapeHtml($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
flashAlert("OAuth token refresh successful for $provider_label. Access token expires at $new_expires_at." . $graph_said);
|
||||
flashAlert("OAuth token refresh successful for Google Workspace. Access token expires at $new_expires_at.");
|
||||
redirect($mail_tab_redirect);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,10 @@ if (isset($_POST['edit_notification_settings'])) {
|
||||
$weekly_columns = weeklySummaryReady() ? ['config_weekly_summary', 'config_weekly_summary_day', 'config_weekly_summary_to'] : [];
|
||||
$before = settingsCurrent(array_merge(['config_enable_alert_domain_expire', 'config_ticket_client_general_notifications', 'config_recurring_auto_send_invoice'], $team_columns, $sms_columns, $weekly_columns));
|
||||
|
||||
$after = ['config_enable_alert_domain_expire' => empty($_POST['config_enable_alert_domain_expire']) ? 0 : 1];
|
||||
$after = [];
|
||||
if ($config_module_enable_itdoc) {
|
||||
$after['config_enable_alert_domain_expire'] = empty($_POST['config_enable_alert_domain_expire']) ? 0 : 1;
|
||||
}
|
||||
if ($config_module_enable_ticketing) {
|
||||
$after['config_ticket_client_general_notifications'] = empty($_POST['config_ticket_client_general_notifications']) ? 0 : 1;
|
||||
}
|
||||
|
||||
87
admin/post/settings_warranty.php
Normal file
87
admin/post/settings_warranty.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Admin > Warranty Lookup (admin/settings_warranty.php). edit_warranty_settings saves the keys: a
|
||||
* secret typed in is sealed (secretSeal(), 'warranty'), one left empty is kept, and an empty client
|
||||
* ID forgets its secret. test_warranty_lookup saves the same way, then looks the serial number typed
|
||||
* beside it up with that manufacturer (functions/warranty.php) and says what came back - HP is
|
||||
* waited on for up to half a minute.
|
||||
*/
|
||||
|
||||
defined('FROM_POST_HANDLER') || die("Direct file access is not allowed");
|
||||
|
||||
if (isset($_POST['edit_warranty_settings']) || isset($_POST['test_warranty_lookup'])) {
|
||||
|
||||
validateCSRFToken();
|
||||
|
||||
$before = settingsCurrent(['config_warranty_dell_client_id', 'config_warranty_dell_client_secret', 'config_warranty_hp_client_id',
|
||||
'config_warranty_hp_client_secret', 'config_warranty_lenovo']);
|
||||
$after = [];
|
||||
$errors = [];
|
||||
foreach (['dell', 'hp'] as $maker) {
|
||||
$id = trim((string) ($_POST["config_warranty_{$maker}_client_id"] ?? ''));
|
||||
$secret = trim((string) ($_POST["config_warranty_{$maker}_client_secret"] ?? ''));
|
||||
if (mb_strlen($id) > 200) {
|
||||
$errors["config_warranty_{$maker}_client_id"] = 'Up to 200 characters.';
|
||||
}
|
||||
if (mb_strlen($secret) > 500) {
|
||||
$errors["config_warranty_{$maker}_client_secret"] = 'Up to 500 characters.';
|
||||
}
|
||||
if ($id !== '' && $secret === '' && trim((string) $before["config_warranty_{$maker}_client_secret"]) === '') {
|
||||
$errors["config_warranty_{$maker}_client_secret"] = 'Its secret is needed too.';
|
||||
}
|
||||
// Sealed with this install's key - or as typed on an install without one, which reads either
|
||||
$sealed = $secret !== '' ? (secretSeal($secret, 'warranty') ?: $secret) : (string) $before["config_warranty_{$maker}_client_secret"];
|
||||
$after["config_warranty_{$maker}_client_id"] = $id;
|
||||
$after["config_warranty_{$maker}_client_secret"] = $id === '' ? '' : $sealed;
|
||||
}
|
||||
$after['config_warranty_lenovo'] = !empty($_POST['config_warranty_lenovo']) ? 1 : 0;
|
||||
if ($errors) {
|
||||
settingsRefuse('warranty', $errors);
|
||||
}
|
||||
|
||||
$changed = settingsSave('warranty', $before, $after);
|
||||
|
||||
if (isset($_POST['test_warranty_lookup'])) {
|
||||
$maker = (string) $_POST['test_warranty_lookup'];
|
||||
$makers = warrantyMakers();
|
||||
$serial = strtoupper(trim((string) ($_POST["warranty_test_$maker"] ?? '')));
|
||||
$saved = $changed ? 'Saved. ' : '';
|
||||
if (!isset($makers[$maker])) {
|
||||
redirect();
|
||||
}
|
||||
if (!warrantySettings()['ready'][$maker]) {
|
||||
flashAlert($saved . escapeHtml($maker === 'lenovo' ? 'Lenovo lookups are off - switch them on to test.' : "{$makers[$maker]} isn't set up - put in its key and secret first."), 'error');
|
||||
redirect();
|
||||
}
|
||||
if ($serial === '') {
|
||||
flashAlert($saved . 'Type a serial number beside <strong>Save and test</strong> to look one up.', 'warning');
|
||||
redirect();
|
||||
}
|
||||
|
||||
if ($maker === 'hp') {
|
||||
// HP works through a job - waited on for up to half a minute
|
||||
$job = warrantyHpStart([$serial]);
|
||||
$result = warrantyNotFound($job['error'], 'error');
|
||||
if ($job['job'] !== '') {
|
||||
$result = warrantyNotFound("HP took the lookup and is still working through it - try again in a minute.", 'skip');
|
||||
for ($waited = 0; $waited < 30; $waited += 3) {
|
||||
sleep(3);
|
||||
$check = warrantyHpCheck($job['job'], [$serial]);
|
||||
if ($check['done']) {
|
||||
$result = $check['error'] !== '' ? warrantyNotFound($check['error'], 'error') : ($check['results'][$serial] ?? warrantyNotFound("doesn't know serial number $serial"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$result = warrantyLookup(['test' => ['maker' => $maker, 'serial' => $serial]])['test'];
|
||||
}
|
||||
|
||||
$tone = $result['found'] ? 'success' : ($result['kind'] === 'error' ? 'error' : 'warning');
|
||||
flashAlert($saved . escapeHtml(warrantySays($maker, $result)) . ($result['found'] && $result['product'] !== '' ? ' - ' . escapeHtml($result['product']) : ''), $tone);
|
||||
}
|
||||
|
||||
redirect();
|
||||
|
||||
}
|
||||
@@ -208,7 +208,7 @@ $devices_in = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FRO
|
||||
<td class="d-none d-md-table-cell text-nowrap">
|
||||
<div><?= number_format(intval($row['rmm_client_devices'])) ?> in <?= escapeHtml($short) ?></div>
|
||||
<?php if ($linked) { ?>
|
||||
<div class="small"><a href="../agent/assets.php?client_id=<?= $client_id ?>&rmm=any"><?= number_format(intval($row['assets_in'])) ?> asset<?= intval($row['assets_in']) === 1 ? '' : 's' ?></a>
|
||||
<div class="small"><?= moduleLink('itdoc', "../agent/assets.php?client_id=$client_id&rmm=any", number_format(intval($row['assets_in'])) . ' asset' . (intval($row['assets_in']) === 1 ? '' : 's')) ?>
|
||||
<?php if ($overdue) { ?><span class="text-danger-emphasis ms-1" title="Not heard from for longer than <?= escapeHtml($short) ?>'s overdue time"><?= $overdue ?> overdue</span><?php } ?>
|
||||
<?php if ($deleted) { ?><span class="text-body-secondary ms-1" title="Their assets were deleted in ITFlow, so they aren't brought in again"><?= $deleted ?> deleted</span><?php } ?>
|
||||
</div>
|
||||
|
||||
@@ -140,7 +140,7 @@ $groups = settingsGroups();
|
||||
continue;
|
||||
}
|
||||
$available = settingsPageAvailable($page); ?>
|
||||
<a href="<?= escapeHtml($page['url']) ?>" class="itflow-settings-tile<?= $available ? '' : ' is-off' ?>" data-settings-tile="<?= $page_key ?>">
|
||||
<a href="<?= escapeHtml($available ? $page['url'] : 'settings_module.php') ?>" class="itflow-settings-tile<?= $available ? '' : ' is-off' ?>" data-settings-tile="<?= $page_key ?>"<?= $available ? '' : ' title="Switch it on in Modules"' ?>>
|
||||
<span class="itflow-settings-tile-icon"><i class="fas fa-fw <?= escapeHtml($page['icon']) ?>"></i></span>
|
||||
<span class="min-w-0">
|
||||
<span class="itflow-settings-tile-title"><?= escapeHtml($page['title']) ?></span>
|
||||
|
||||
@@ -60,7 +60,9 @@ echo settingsPageStart('default');
|
||||
<?= settingsSectionStart('opening', 'Opening ITFlow', 'Where everyone lands on signing in or clicking the logo, and the calendar a new event goes on.') ?>
|
||||
<?= settingsSelect('config_start_page', $config_start_page, $start_pages, ['icon' => 'fa-home', 'search' => true, 'required' => true, 'data' => ['tags' => 'true'],
|
||||
'help' => 'Or type another page, as it is after /agent/ in its address - tickets.php?status=Open.']) ?>
|
||||
<?= settingsSelect('config_default_calendar', intval($config_default_calendar), $calendars, ['icon' => 'fa-calendar']) ?>
|
||||
<?php if (moduleOn('calendar')) { ?>
|
||||
<?= settingsSelect('config_default_calendar', intval($config_default_calendar), $calendars, ['icon' => 'fa-calendar']) ?>
|
||||
<?php } ?>
|
||||
<?= settingsSectionEnd() ?>
|
||||
|
||||
<?= settingsSectionStart('clients', 'Rates and terms', 'What a client is billed on when no contract in force sets it - a client has no rates or terms of its own; its contract\'s apply. The SLAs are in Admin > SLAs.') ?>
|
||||
|
||||
@@ -165,6 +165,7 @@ echo settingsPageStart('invoice');
|
||||
</script>
|
||||
<?= settingsSectionEnd() ?>
|
||||
|
||||
<?php if ($config_module_enable_ticketing) { ?>
|
||||
<?= settingsSectionStart('time', 'Billing time', 'How the time logged on a billable ticket becomes hours on an invoice - in Unbilled Time, a ticket\'s Invoice window and Add Tickets. Each ticket\'s time is rounded once, as a whole, and billed at the client\'s hourly rate, or the one in <a href="settings_default.php#setting=config_default_hourly_rate">Defaults</a> when the client has none.', 'billing-time') ?>
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6"><?= settingsSelect('config_time_increment', $time_rules['increment'], billingTimeIncrements(), ['icon' => 'fa-stopwatch', 'label' => 'Round to']) ?></div>
|
||||
@@ -176,6 +177,7 @@ echo settingsPageStart('invoice');
|
||||
'placeholder' => 'Support [Hourly]', 'help' => 'The ticket number, subject and date go in its description.']) ?></div>
|
||||
</div>
|
||||
<?= settingsSectionEnd() ?>
|
||||
<?php } ?>
|
||||
|
||||
<?= settingsSectionStart('expenses', 'Billable expenses', 'An expense for a client can be billed on to them - it waits in Unbilled Time and goes on their invoice at what it cost, less any refund, plus a markup. A recurring expense can be billed on each time it records one.', 'billable-expenses') ?>
|
||||
<div class="row g-3">
|
||||
@@ -184,6 +186,7 @@ echo settingsPageStart('invoice');
|
||||
</div>
|
||||
<?= settingsSectionEnd() ?>
|
||||
|
||||
<?php if (moduleOn('trips')) { ?>
|
||||
<?= settingsSectionStart('mileage', 'Trips and mileage', 'An agent driving their own vehicle is paid back for the distance: Pay Mileage on the Trips page makes their trips a mileage expense they paid personally, to pay back with Reimburse. A trip for a client can be billed to them from Unbilled Time, beside their tickets and expenses.', 'mileage') ?>
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6"><?= settingsSelect('config_mileage_unit', $trip_rules['unit'], ['mi' => 'Miles', 'km' => 'Kilometers'], ['icon' => 'fa-ruler',
|
||||
@@ -209,6 +212,7 @@ echo settingsPageStart('invoice');
|
||||
</div>
|
||||
<div class="itflow-settings-note mt-3" data-trip-rule><?= tripBillingOn() ? 'A trip bills ' . escapeHtml(tripBillRuleText()) . '.' : 'With no charge and no rate, trips aren\'t billed.' ?> The price can be changed in Unbilled Time before it goes on.</div>
|
||||
<?= settingsSectionEnd() ?>
|
||||
<?php } ?>
|
||||
|
||||
<?= settingsSaveBar('edit_invoice_settings') ?>
|
||||
</div>
|
||||
|
||||
@@ -331,6 +331,13 @@ if (!$config_module_enable_ticketing) {
|
||||
<button type="button" class="btn btn-outline-secondary clipboardjs" data-clipboard-target="#mailOauthRedirect" title="Copy"><i class="far fa-fw fa-copy"></i></button>
|
||||
</div>
|
||||
<div class="form-text">Under Authentication in the app registration, as a Web platform.</div>
|
||||
<div class="mt-3">
|
||||
<?= settingsSelect('oauth_connect_way', mailMicrosoftConnectWay($oauth_connected), [
|
||||
'graph' => 'Microsoft Graph\'s Mail.Send and Mail.ReadWrite',
|
||||
'exchange' => 'Exchange\'s SMTP.Send and IMAP.AccessAsUser.All',
|
||||
], ['id' => 'oauthConnectWay', 'icon' => 'fa-shield-alt', 'label' => 'The app has', 'data' => ['settings-untracked' => '1'],
|
||||
'help' => 'The permissions you gave it in Microsoft Entra - Connect asks Microsoft for just those, so there\'s nothing new to approve.']) ?>
|
||||
</div>
|
||||
<button type="submit" name="oauth_connect_microsoft_mail" class="btn btn-outline-primary mt-3">
|
||||
<i class="fab fa-fw fa-microsoft me-2"></i>Connect Microsoft 365
|
||||
</button>
|
||||
@@ -355,9 +362,9 @@ if (!$config_module_enable_ticketing) {
|
||||
</div>
|
||||
|
||||
<?= $from_box('mail', 'System emails', 'Share links, password resets, alerts - anything without its own address below.', $config_mail_from_email, $config_mail_from_name, 'noreply@example.com', (string) ($session_company_name ?? 'Your company')) ?>
|
||||
<?= $from_box('invoice', 'Invoices', 'Invoices, receipts, statements and payment reminders.', $config_invoice_from_email, $config_invoice_from_name, 'billing@example.com', 'Billing') ?>
|
||||
<?= $from_box('quote', 'Quotes', 'Quotes sent to clients. Empty - they come from the invoices address.', $config_quote_from_email, $config_quote_from_name, 'sales@example.com', 'Sales') ?>
|
||||
<?= $from_box('ticket', 'Tickets', 'Ticket emails to clients. Make it the mailbox Receiving reads, so their replies go on the ticket. An agent\'s reply goes out with their name in front of this one - <em>' . escapeHtml(ticketEmailFromName(stripslashes((string) ($session_name ?? 'Tess Tech')), (string) $config_ticket_from_name !== '' ? (string) $config_ticket_from_name : 'Support')) . '</em> - from the same address.', $config_ticket_from_email, $config_ticket_from_name, 'support@example.com', 'Support') ?>
|
||||
<?= !$config_module_enable_accounting ? '' : $from_box('invoice', 'Invoices', 'Invoices, receipts, statements and payment reminders.', $config_invoice_from_email, $config_invoice_from_name, 'billing@example.com', 'Billing') ?>
|
||||
<?= !$config_module_enable_accounting ? '' : $from_box('quote', 'Quotes', 'Quotes sent to clients. Empty - they come from the invoices address.', $config_quote_from_email, $config_quote_from_name, 'sales@example.com', 'Sales') ?>
|
||||
<?= !$config_module_enable_ticketing ? '' : $from_box('ticket', 'Tickets', 'Ticket emails to clients. Make it the mailbox Receiving reads, so their replies go on the ticket. An agent\'s reply goes out with their name in front of this one - <em>' . escapeHtml(ticketEmailFromName(stripslashes((string) ($session_name ?? 'Tess Tech')), (string) $config_ticket_from_name !== '' ? (string) $config_ticket_from_name : 'Support')) . '</em> - from the same address.', $config_ticket_from_email, $config_ticket_from_name, 'support@example.com', 'Support') ?>
|
||||
|
||||
<?= settingsSaveBar('edit_mail_from_settings') ?>
|
||||
</form>
|
||||
@@ -435,7 +442,12 @@ if (!$config_module_enable_ticketing) {
|
||||
<!-- ============================ PREVIEWS ============================ -->
|
||||
<?php
|
||||
// Every email ITFlow sends, made on sample records that are thrown away again (functions/email_preview.php)
|
||||
$preview_catalog = emailPreviewCatalog();
|
||||
// Only the emails of the parts of ITFlow switched on (Admin > Settings > Modules)
|
||||
$preview_catalog = array_filter(emailPreviewCatalog(), function ($entry) {
|
||||
$module = ['Tickets - to clients' => 'ticketing', 'Tickets - to your team' => 'ticketing', 'Billing' => 'accounting', 'Contracts' => 'accounting',
|
||||
'Calendar' => 'calendar', 'Client portal' => 'portal', 'Shared links' => 'itdoc'][$entry['group']] ?? null;
|
||||
return $module === null || moduleOn($module);
|
||||
});
|
||||
$preview_groups = [];
|
||||
foreach ($preview_catalog as $preview_key => $preview_entry) {
|
||||
$preview_groups[$preview_entry['group']][$preview_key] = $preview_entry;
|
||||
|
||||
@@ -22,9 +22,11 @@ echo settingsPageStart('notification');
|
||||
<div class="card itflow-settings-card">
|
||||
<div class="card-body">
|
||||
|
||||
<?php if ($config_module_enable_itdoc) { ?>
|
||||
<?= settingsSectionStart('alerts', 'Alerts for your team', 'In the bell at the top of the page, for everyone who can see the client - raised by the nightly job.') ?>
|
||||
<?= settingsSwitch('config_enable_alert_domain_expire', $config_enable_alert_domain_expire, ['help' => '45, 7 and 1 days before a domain expires - saying when one is set to auto-renew, to check it goes through.']) ?>
|
||||
<?= settingsSectionEnd() ?>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($config_module_enable_ticketing && version_compare(CURRENT_DATABASE_VERSION, '3.9.1', '>=')) { ?>
|
||||
<?= settingsSectionStart('team', 'Emails and notices to your team', 'What ITFlow tells your agents about their tickets by itself. The new-ticket address is set in <a href="settings_ticket.php">Tickets</a>.') ?>
|
||||
|
||||
101
admin/settings_warranty.php
Normal file
101
admin/settings_warranty.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Admin > Warranty Lookup - the manufacturers an asset's warranty can be looked up with
|
||||
* (functions/warranty.php): Dell's and HP's keys, and whether Lenovo's support site is asked.
|
||||
* Each has Save and test, with a serial number to try. Saved by edit_warranty_settings, tested by
|
||||
* test_warranty_lookup (admin/post/settings_warranty.php).
|
||||
*/
|
||||
|
||||
require_once "includes/inc_all_admin.php";
|
||||
|
||||
$warranty_ready = true;
|
||||
try {
|
||||
mysqli_query($mysqli, "SELECT config_warranty_lenovo FROM settings LIMIT 1");
|
||||
} catch (\Throwable $e) {
|
||||
$warranty_ready = false;
|
||||
}
|
||||
if (!$warranty_ready) { ?>
|
||||
<div class="alert alert-warning"><i class="fas fa-fw fa-exclamation-triangle me-2"></i>Warranty lookup arrives with a database update - run it in <a href="update.php">Maintenance > Update</a> first.</div>
|
||||
<?php
|
||||
require_once "../includes/footer.php";
|
||||
exit;
|
||||
}
|
||||
|
||||
$warranty = settingsCurrent(['config_warranty_dell_client_id', 'config_warranty_dell_client_secret', 'config_warranty_hp_client_id', 'config_warranty_hp_client_secret', 'config_warranty_lenovo']);
|
||||
$saved_secret = function ($stored) {
|
||||
return trim((string) $stored) !== '' ? 'Saved - type a new one to replace it' : 'The secret\'s value';
|
||||
};
|
||||
$ready = warrantySettings()['ready'];
|
||||
|
||||
// Save and test, with a serial number to try - sent with the form, not saved with it
|
||||
$test_field = function ($maker, $placeholder) {
|
||||
return '<div class="input-group mt-3" style="max-width: 32rem;">'
|
||||
. '<span class="input-group-text"><i class="fas fa-fw fa-barcode"></i></span>'
|
||||
. '<input type="text" class="form-control" name="warranty_test_' . $maker . '" placeholder="' . escapeHtml($placeholder) . '" maxlength="40" data-settings-untracked aria-label="Serial number to try">'
|
||||
. '<button type="submit" class="btn btn-outline-primary" name="test_warranty_lookup" value="' . $maker . '"><i class="fas fa-fw fa-vial me-1"></i>Save and test</button>'
|
||||
. '</div>';
|
||||
};
|
||||
$state = function ($on, $off_text) {
|
||||
return ($on ? '<span class="badge text-bg-success me-1">On</span>' : '<span class="badge text-bg-secondary me-1">' . escapeHtml($off_text) . '</span>') . ' ';
|
||||
};
|
||||
|
||||
echo settingsPageStart('warranty');
|
||||
|
||||
?>
|
||||
|
||||
<form action="post.php" method="post" autocomplete="off" data-settings-form>
|
||||
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
|
||||
|
||||
<div class="card itflow-settings-card">
|
||||
<div class="card-body">
|
||||
|
||||
<?= settingsSectionStart('how', 'How it works', 'An asset is looked up by its make - Dell, HP or Lenovo - or, with no make, by its model: Latitude, ThinkPad, EliteBook. Only empty dates are filled in: a warranty or purchase date already on an asset is never changed.') ?>
|
||||
<div class="small">
|
||||
<p class="mb-2"><strong>On one asset</strong> - the <i class="fas fa-search"></i> button beside <strong>Warranty expires</strong> on its Purchase tab, before you save.</p>
|
||||
<p class="mb-2"><strong>On many</strong> - select them on Assets, then <strong>Bulk Action > Look Up Warranty</strong>.</p>
|
||||
<p class="mb-0 text-body-secondary">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.</p>
|
||||
</div>
|
||||
<?= settingsSectionEnd() ?>
|
||||
|
||||
<?= settingsSectionStart('dell', 'Dell', $state($ready['dell'], 'Not set up') . 'TechDirect\'s Warranty API, by service tag. Ask for a key at <a href="https://techdirect.dell.com" target="_blank" rel="noopener">techdirect.dell.com<i class="fas fa-external-link-alt small ms-1"></i></a> under Services > APIs - Dell approves it, usually within a few days.') ?>
|
||||
<div class="row g-3">
|
||||
<div class="col-lg-6">
|
||||
<?= settingsInput('config_warranty_dell_client_id', $warranty['config_warranty_dell_client_id'], ['icon' => 'fa-id-badge', 'label' => 'Client ID', 'maxlength' => 200,
|
||||
'help' => 'Empty switches Dell lookups off, and forgets its secret.']) ?>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<?= settingsInput('config_warranty_dell_client_secret', '', ['icon' => 'fa-key', 'type' => 'password', 'label' => 'Client secret', 'maxlength' => 500,
|
||||
'autocomplete' => 'new-password', 'placeholder' => $saved_secret($warranty['config_warranty_dell_client_secret'])]) ?>
|
||||
</div>
|
||||
</div>
|
||||
<?= $test_field('dell', 'A service tag to try') ?>
|
||||
<?= settingsSectionEnd() ?>
|
||||
|
||||
<?= settingsSectionStart('lenovo', 'Lenovo', $state($ready['lenovo'], 'Off') . 'Lenovo\'s support site, asked the way its own pages ask it - no key needed. It isn\'t an API Lenovo offers, so it can stop working when Lenovo changes the site.') ?>
|
||||
<?= settingsSwitch('config_warranty_lenovo', $warranty['config_warranty_lenovo'], ['label' => 'Look up Lenovo serial numbers on Lenovo\'s support site']) ?>
|
||||
<?= $test_field('lenovo', 'A serial number to try') ?>
|
||||
<?= settingsSectionEnd() ?>
|
||||
|
||||
<?= settingsSectionStart('hp', 'HP', $state($ready['hp'], 'Not set up') . 'HP Inc.\'s Warranty API, by serial number. Register at <a href="https://developers.hp.com" target="_blank" rel="noopener">developers.hp.com<i class="fas fa-external-link-alt small ms-1"></i></a>, 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.') ?>
|
||||
<div class="row g-3">
|
||||
<div class="col-lg-6">
|
||||
<?= settingsInput('config_warranty_hp_client_id', $warranty['config_warranty_hp_client_id'], ['icon' => 'fa-id-badge', 'label' => 'API key', 'maxlength' => 200,
|
||||
'help' => 'Empty switches HP lookups off, and forgets its secret.']) ?>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<?= settingsInput('config_warranty_hp_client_secret', '', ['icon' => '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.']) ?>
|
||||
</div>
|
||||
</div>
|
||||
<?= $test_field('hp', 'A serial number to try') ?>
|
||||
<?= settingsSectionEnd() ?>
|
||||
|
||||
<?= settingsSaveBar('edit_warranty_settings') ?>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
require_once "../includes/footer.php";
|
||||
@@ -17,12 +17,16 @@ $order = "ASC";
|
||||
|
||||
require_once "includes/inc_all_admin.php";
|
||||
|
||||
// The kinds of the parts of ITFlow switched on (Admin > 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']);
|
||||
|
||||
@@ -212,14 +212,23 @@ $used_text = function (array $u) {
|
||||
</div>
|
||||
|
||||
<label class="form-label">Also tax</label>
|
||||
<?php // Ticket time and trips switched off (Admin > Settings > Modules) keep what they are
|
||||
if (moduleOn('ticketing')) { ?>
|
||||
<div class="form-check form-switch">
|
||||
<input type="checkbox" class="form-check-input" name="tax_time" value="1" id="taxTime"<?= $tax_settings['time'] ? ' checked' : '' ?>>
|
||||
<label class="form-check-label" for="taxTime">Billed time</label>
|
||||
</div>
|
||||
<?php } elseif ($tax_settings['time']) { ?>
|
||||
<input type="hidden" name="tax_time" value="1">
|
||||
<?php } ?>
|
||||
<?php if (moduleOn('trips')) { ?>
|
||||
<div class="form-check form-switch">
|
||||
<input type="checkbox" class="form-check-input" name="tax_trips" value="1" id="taxTrips"<?= $tax_settings['trip'] ? ' checked' : '' ?>>
|
||||
<label class="form-check-label" for="taxTrips">Trips</label>
|
||||
</div>
|
||||
<?php } elseif ($tax_settings['trip']) { ?>
|
||||
<input type="hidden" name="tax_trips" value="1">
|
||||
<?php } ?>
|
||||
<div class="form-check form-switch">
|
||||
<input type="checkbox" class="form-check-input" name="tax_expenses" value="1" id="taxExpenses"<?= $tax_settings['expense'] ? ' checked' : '' ?>>
|
||||
<label class="form-check-label" for="taxExpenses">Expenses billed to clients</label>
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
@@ -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) {
|
||||
<div class="dropdown">
|
||||
<button type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown"><i class="fas fa-plus me-2"></i>New</button>
|
||||
<div class="dropdown-menu dropdown-menu-end">
|
||||
<?php if ($asset_ticketing) { ?>
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-url="modals/ticket/ticket_add.php?<?= $client_url ?>&asset_id=<?= $asset_id ?>" data-modal-size="lg">
|
||||
<i class="fas fa-fw fa-life-ring text-secondary me-2"></i>Ticket
|
||||
</a>
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-url="modals/recurring_ticket/recurring_ticket_add.php?<?= $client_url ?>&asset_id=<?= $asset_id ?>" data-modal-size="lg">
|
||||
<i class="fas fa-fw fa-redo-alt text-secondary me-2"></i>Recurring Ticket
|
||||
</a>
|
||||
<?php } ?>
|
||||
<?php if ($can_credentials_edit) { ?>
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-size="lg" data-modal-url="modals/credential/credential_add.php?<?= $client_url ?>asset_id=<?= $asset_id ?>">
|
||||
<i class="fas fa-fw fa-key text-secondary me-2"></i>Credential
|
||||
@@ -493,7 +502,7 @@ if (mysqli_num_rows($sql) == 0) {
|
||||
<ul class="list-unstyled small mt-3 mb-0" data-rmm-alerts="<?= count($rmm_alerts) ?>">
|
||||
<?php foreach ($rmm_alerts as $rmm_alert) { ?>
|
||||
<li class="text-<?= ['error' => 'danger', 'warning' => 'warning'][$rmm_alert['rmm_alert_severity']] ?? 'secondary' ?>-emphasis">
|
||||
<i class="fas fa-fw fa-bell me-1"></i><a class="fw-semibold" href="<?= escapeHtml(ticketUrl($rmm_alert['ticket_id'], $rmm_alert['ticket_client_id'])) ?>"><?= escapeHtml($rmm_alert['ticket_prefix'] . $rmm_alert['ticket_number']) ?></a>
|
||||
<i class="fas fa-fw fa-bell me-1"></i><?php if ($asset_ticketing) { ?><a class="fw-semibold" href="<?= escapeHtml(ticketUrl($rmm_alert['ticket_id'], $rmm_alert['ticket_client_id'])) ?>"><?= escapeHtml($rmm_alert['ticket_prefix'] . $rmm_alert['ticket_number']) ?></a><?php } else { ?><span class="fw-semibold"><?= escapeHtml($rmm_alert['ticket_prefix'] . $rmm_alert['ticket_number']) ?></span><?php } ?>
|
||||
<?= escapeHtml(mb_strimwidth((string) $rmm_alert['rmm_alert_message'], 0, 120, '...')) ?>
|
||||
</li>
|
||||
<?php } ?>
|
||||
@@ -797,6 +806,23 @@ if (mysqli_num_rows($sql) == 0) {
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (assetLinksReady() && ($asset_linked || ($can_edit && !$asset_archived_at))) { ?>
|
||||
<!-- Linked assets - a printer and the knife unit on it; each shows the other -->
|
||||
<div class="card mb-3">
|
||||
<div class="card-header d-flex align-items-center gap-2">
|
||||
<h3 class="card-title mb-0 me-auto"><i class="fas fa-fw fa-link text-secondary me-2"></i>Linked assets<?php if ($asset_linked) { ?> <span class="text-body-secondary fw-normal">(<?= count($asset_linked) ?>)</span><?php } ?></h3>
|
||||
<?php if ($can_edit && !$asset_archived_at) { ?>
|
||||
<?= linkPickerButton('asset', $asset_id, 'asset', 'Link', 'btn btn-sm btn-outline-secondary', 'fas fa-link me-2', 'Link it to another of this client\'s assets') ?>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php if ($asset_linked) { ?>
|
||||
<?= assetLinkedListHtml($asset_row, $asset_linked, $can_edit && !$asset_archived_at) ?>
|
||||
<?php } else { ?>
|
||||
<div class="card-body small text-body-secondary">An asset that goes with this one - a part on it, or what it's fitted to. Each shows the other, and swaps go in both histories.</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title mb-0"><i class="fas fa-fw fa-pen text-secondary me-2"></i>Quick notes</h3>
|
||||
@@ -1079,6 +1105,7 @@ if (mysqli_num_rows($sql) == 0) {
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (isset($asset_tabs['tickets'])) { ?>
|
||||
<!-- Tickets -->
|
||||
<div class="tab-pane fade" id="asset-pane-tickets" role="tabpanel">
|
||||
<div class="itflow-asset-pane-bar">
|
||||
@@ -1095,7 +1122,9 @@ if (mysqli_num_rows($sql) == 0) {
|
||||
<div class="itflow-asset-empty">No tickets have mentioned this asset.</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (isset($asset_tabs['recurring'])) { ?>
|
||||
<!-- Recurring tickets -->
|
||||
<div class="tab-pane fade" id="asset-pane-recurring" role="tabpanel">
|
||||
<div class="itflow-asset-pane-bar">
|
||||
@@ -1170,6 +1199,7 @@ if (mysqli_num_rows($sql) == 0) {
|
||||
<div class="itflow-asset-empty">Nothing scheduled for this asset.</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<!-- Licenses -->
|
||||
<div class="tab-pane fade" id="asset-pane-licenses" role="tabpanel">
|
||||
|
||||
@@ -209,6 +209,7 @@ $asset_list_specs = assetSpecsFor(array_keys($assets));
|
||||
|
||||
// Tags, rack positions and what its RMM says of each for the whole page in three queries, not three per row
|
||||
$assets_tags = tagsForRecords('asset', array_keys($assets));
|
||||
$assets_linked = assetLinkedNames(array_keys($assets)); // what each is linked to - a printer's knife unit
|
||||
$assets_rmm = $rmm_set_up ? rmmDevicesForAssets(array_keys($assets)) : [];
|
||||
$assets_racked = [];
|
||||
if ($assets) {
|
||||
@@ -437,16 +438,26 @@ $search_noun = $type_filter ? $asset_type_tabs[$type_filter]['label'] : 'assets'
|
||||
data-bulk="true">
|
||||
<i class="fas fa-fw fa-info-circle me-2"></i>Set Status
|
||||
</a>
|
||||
<?php if (warrantyAnyReady()) { // Their empty warranty and purchase dates from Dell, HP and Lenovo (functions/warranty.php) ?>
|
||||
<a class="dropdown-item ajax-modal" href="#"
|
||||
data-modal-url="modals/asset/asset_bulk_warranty.php"
|
||||
data-modal-size="lg"
|
||||
data-bulk="true">
|
||||
<i class="fas fa-fw fa-shield-alt me-2"></i>Look Up Warranty
|
||||
</a>
|
||||
<?php } ?>
|
||||
<a class="dropdown-item" href="#" data-tag-picker data-tag-entity="asset" data-tag-bulk data-csrf="<?= $_SESSION['csrf_token'] ?>">
|
||||
<i class="fas fa-fw fa-tags me-2"></i>Tags
|
||||
</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<?php if (moduleOn('ticketing')) { ?>
|
||||
<a class="dropdown-item ajax-modal" href="#"
|
||||
data-modal-url="modals/asset/asset_bulk_add_ticket.php"
|
||||
data-modal-size="lg"
|
||||
data-bulk="true">
|
||||
<i class="fas fa-fw fa-life-ring me-2"></i>Create Tickets
|
||||
</a>
|
||||
<?php } ?>
|
||||
<a class="dropdown-item ajax-modal" href="#"
|
||||
data-modal-url="modals/asset/asset_bulk_transfer_client.php?<?= $client_url ?>"
|
||||
data-bulk="true">
|
||||
@@ -613,6 +624,9 @@ $search_noun = $type_filter ? $asset_type_tabs[$type_filter]['label'] : 'assets'
|
||||
<?php if ($asset_description) { ?>
|
||||
<div class="small text-body-secondary text-truncate itflow-asset-desc" title="<?= $asset_description ?>"><?= $asset_description ?></div>
|
||||
<?php } ?>
|
||||
<?php if (!empty($assets_linked[$asset_id])) { $linked_names = $assets_linked[$asset_id]; ?>
|
||||
<div class="small text-body-secondary text-truncate" title="Linked to <?= escapeHtml(implode(', ', $linked_names)) ?>"><i class="fas fa-fw fa-link me-1"></i><?= escapeHtml(implode(', ', array_slice($linked_names, 0, 2))) ?><?= count($linked_names) > 2 ? ' +' . (count($linked_names) - 2) : '' ?></div>
|
||||
<?php } ?>
|
||||
<?php if ($asset_tags || lookupUserPermission('module_client') >= 2) { ?>
|
||||
<div class="itflow-tags-row mt-1 itflow-above-stretch"><?= tagPills('asset', $asset_id, $asset_tags, "assets.php?$client_url") ?></div>
|
||||
<?php } ?>
|
||||
|
||||
@@ -172,7 +172,9 @@ $view_empty = [
|
||||
<div class="col-lg-9 col-md-6 small" data-audit-entity="<?= $entity_filter ?>">
|
||||
<input type="hidden" name="entity" value="<?= $entity_filter ?>">
|
||||
<span class="text-body-secondary"><i class="fas fa-fw fa-filter me-1"></i>Just one record:</span>
|
||||
<?php if ($entity_record) { ?>
|
||||
<?php if ($entity_record && $entity_record['url'] === '') { ?>
|
||||
<span><?= escapeHtml($type_filter . ' ' . $entity_record['name']) ?></span>
|
||||
<?php } elseif ($entity_record) { ?>
|
||||
<a href="<?= escapeHtml($entity_record['url']) ?>"><?= escapeHtml($type_filter . ' ' . $entity_record['name']) ?></a>
|
||||
<?php } else { ?>
|
||||
<span class="text-body-secondary"><?= escapeHtml($type_filter !== '' ? $type_filter : 'record') ?> #<?= $entity_filter ?></span>
|
||||
|
||||
@@ -154,7 +154,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||
<th class="d-none d-xl-table-cell"><?= sortLink('phone_call_extension', 'Taken by') ?></th>
|
||||
<th><?= sortLink('phone_call_started_at', 'When') ?></th>
|
||||
<th class="d-none d-sm-table-cell text-end"><?= sortLink('phone_call_talk_seconds', 'Talked') ?></th>
|
||||
<th class="d-none d-lg-table-cell">Ticket</th>
|
||||
<?php if (moduleOn('ticketing')) { ?><th class="d-none d-lg-table-cell">Ticket</th><?php } ?>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -211,6 +211,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||
<div class="text-body-secondary"><?= escapeHtml(date('M j, g:i a', strtotime($row['phone_call_started_at']))) ?></div>
|
||||
</td>
|
||||
<td class="d-none d-sm-table-cell small text-end text-nowrap"><?= $answered ? escapeHtml(phoneSecondsText($row['phone_call_talk_seconds'])) : '<span class="text-body-secondary">-</span>' ?></td>
|
||||
<?php if (moduleOn('ticketing')) { ?>
|
||||
<td class="d-none d-lg-table-cell small text-nowrap">
|
||||
<?php if ($ticket_id && $row['ticket_number'] !== null) { ?>
|
||||
<a href="ticket.php?client_id=<?= $call_client_id ?>&ticket_id=<?= $ticket_id ?>" title="<?= escapeHtml((string) $row['ticket_subject']) ?>"><?= escapeHtml($row['ticket_prefix'] . $row['ticket_number']) ?></a>
|
||||
@@ -218,12 +219,13 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||
<span class="text-body-secondary">-</span>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<?php } ?>
|
||||
<td class="text-end pe-3">
|
||||
<?php if (($can_edit && $row['phone_call_direction'] !== 'local') || $call_web !== '') { ?>
|
||||
<?php if (($can_edit && $row['phone_call_direction'] !== 'local' && moduleOn('ticketing')) || $call_web !== '') { ?>
|
||||
<div class="dropdown dropstart">
|
||||
<button class="btn btn-sm btn-light" title="More actions" type="button" data-bs-toggle="dropdown"><i class="fas fa-fw fa-ellipsis-v"></i></button>
|
||||
<div class="dropdown-menu">
|
||||
<?php if ($can_edit && $row['phone_call_direction'] !== 'local') { ?>
|
||||
<?php if ($can_edit && $row['phone_call_direction'] !== 'local' && moduleOn('ticketing')) { ?>
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-url="modals/phone/phone_call_ticket.php?id=<?= $phone_call_id ?>"><i class="fas fa-fw fa-life-ring text-secondary me-2"></i>Add to Ticket</a>
|
||||
<?php } ?>
|
||||
<?php if ($call_web !== '') { ?>
|
||||
|
||||
@@ -31,7 +31,7 @@ $favorites = clientOverviewFavorites($client_id, $access);
|
||||
$upcoming = clientOverviewUpcoming($client_id, $access);
|
||||
$asset_summary = $access['docs'] ? clientOverviewAssets($client_id) : null;
|
||||
$rmm_summary = $access['docs'] ? rmmClientSummary($client_id) : null;
|
||||
$shared_items = clientOverviewSharedItems($client_id);
|
||||
$shared_items = $access['docs'] ? clientOverviewSharedItems($client_id) : [];
|
||||
$activity = clientOverviewActivity($client_id);
|
||||
$money = $access['financial'] ? clientOverviewMoney($client_id, $balance, $recurring_monthly) : null;
|
||||
$open_invoices = $access['sales'] ? clientOverviewOpenInvoices($client_id) : null;
|
||||
|
||||
@@ -206,6 +206,15 @@ if (!$can_support) {
|
||||
unset($contact_tabs['assets'], $contact_tabs['tickets'], $contact_tabs['recurring'], $contact_tabs['licenses'],
|
||||
$contact_tabs['documents'], $contact_tabs['files'], $contact_tabs['services']);
|
||||
}
|
||||
// The parts of ITFlow switched off (Admin > Settings > Modules) - their tabs and New items go
|
||||
$contact_itdoc = moduleOn('itdoc');
|
||||
$contact_ticketing = moduleOn('ticketing');
|
||||
if (!$contact_itdoc) {
|
||||
unset($contact_tabs['assets'], $contact_tabs['credentials'], $contact_tabs['licenses'], $contact_tabs['documents'], $contact_tabs['files'], $contact_tabs['services']);
|
||||
}
|
||||
if (!$contact_ticketing) {
|
||||
unset($contact_tabs['tickets'], $contact_tabs['recurring']);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -264,27 +273,31 @@ if (!$can_support) {
|
||||
<button type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown"><i class="fas fa-plus me-2"></i>New</button>
|
||||
<div class="dropdown-menu dropdown-menu-end">
|
||||
<?php if ($can_support_edit) { ?>
|
||||
<?php if ($contact_ticketing) { ?>
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-url="modals/ticket/ticket_add.php?<?= $client_url ?>&contact_id=<?= $contact_id ?>" data-modal-size="lg">
|
||||
<i class="fas fa-fw fa-life-ring text-secondary me-2"></i>Ticket
|
||||
</a>
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-url="modals/recurring_ticket/recurring_ticket_add.php?<?= $client_url ?>&contact_id=<?= $contact_id ?>" data-modal-size="lg">
|
||||
<i class="fas fa-fw fa-redo-alt text-secondary me-2"></i>Recurring Ticket
|
||||
</a>
|
||||
<?php } ?>
|
||||
<?php if (moduleOn('calendar')) { ?>
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-url="modals/calendar/calendar_event_add.php?<?= $client_url ?>&contact_id=<?= $contact_id ?>&lock_client=1" data-modal-size="lg">
|
||||
<i class="far fa-fw fa-calendar-plus text-secondary me-2"></i>Meeting
|
||||
</a>
|
||||
<?php } ?>
|
||||
<?php if ($contact_itdoc) { ?>
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-size="lg" data-modal-url="modals/asset/asset_add.php?<?= $client_url ?>&contact_id=<?= $contact_id ?>">
|
||||
<i class="fas fa-fw fa-desktop text-secondary me-2"></i>Asset
|
||||
</a>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
<?php if ($can_credentials_edit) { ?>
|
||||
<?php if ($can_credentials_edit && $contact_itdoc) { ?>
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-size="lg" data-modal-url="modals/credential/credential_add.php?<?= $client_url ?>&contact_id=<?= $contact_id ?>">
|
||||
<i class="fas fa-fw fa-key text-secondary me-2"></i>Credential
|
||||
</a>
|
||||
<?php } ?>
|
||||
<?php if ($can_support_edit) { ?>
|
||||
<?php if ($can_support_edit && $contact_itdoc) { ?>
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-url="modals/document/document_add.php?<?= $client_url ?>&contact_id=<?= $contact_id ?>" data-modal-size="xl">
|
||||
<i class="fas fa-fw fa-file-alt text-secondary me-2"></i>Document
|
||||
</a>
|
||||
@@ -300,6 +313,7 @@ if (!$can_support) {
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($contact_itdoc) { ?>
|
||||
<div class="dropdown">
|
||||
<button type="button" class="btn btn-outline-secondary dropdown-toggle" data-bs-toggle="dropdown"><i class="fas fa-link me-2"></i>Link</button>
|
||||
<div class="dropdown-menu dropdown-menu-end">
|
||||
@@ -317,6 +331,7 @@ if (!$can_support) {
|
||||
<?= linkPickerButton('contact', $contact_id, 'file', 'File', 'dropdown-item', 'fas fa-fw fa-paperclip text-secondary me-2') ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<button type="button" class="btn btn-outline-secondary ajax-modal" data-modal-size="lg" data-modal-url="modals/contact/contact_edit.php?id=<?= $contact_id ?>">
|
||||
<i class="fas fa-user-edit me-2"></i>Edit
|
||||
</button>
|
||||
@@ -527,6 +542,7 @@ if (!$can_support) {
|
||||
<div class="tab-content">
|
||||
|
||||
<?php if ($can_support) { ?>
|
||||
<?php if (isset($contact_tabs['assets'])) { ?>
|
||||
<!-- Assets -->
|
||||
<div class="tab-pane fade" id="contact-pane-assets" role="tabpanel">
|
||||
<div class="itflow-asset-pane-bar">
|
||||
@@ -604,8 +620,10 @@ if (!$can_support) {
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($can_credentials) { ?>
|
||||
<?php if (isset($contact_tabs['credentials'])) { ?>
|
||||
<!-- Credentials -->
|
||||
<div class="tab-pane fade" id="contact-pane-credentials" role="tabpanel">
|
||||
<div class="itflow-asset-pane-bar">
|
||||
@@ -630,8 +648,10 @@ if (!$can_support) {
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($can_support) { ?>
|
||||
<?php if (isset($contact_tabs['tickets'])) { ?>
|
||||
<!-- Tickets -->
|
||||
<div class="tab-pane fade" id="contact-pane-tickets" role="tabpanel">
|
||||
<div class="itflow-asset-pane-bar">
|
||||
@@ -648,6 +668,7 @@ if (!$can_support) {
|
||||
<div class="itflow-asset-empty">No tickets yet.</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($contact_calls !== null) { ?>
|
||||
<!-- Calls from the phone systems -->
|
||||
@@ -666,6 +687,7 @@ if (!$can_support) {
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (isset($contact_tabs['recurring'])) { ?>
|
||||
<!-- Recurring tickets -->
|
||||
<div class="tab-pane fade" id="contact-pane-recurring" role="tabpanel">
|
||||
<div class="itflow-asset-pane-bar">
|
||||
@@ -728,8 +750,10 @@ if (!$can_support) {
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($can_support) { ?>
|
||||
<?php if (isset($contact_tabs['licenses'])) { ?>
|
||||
<!-- Licenses -->
|
||||
<div class="tab-pane fade" id="contact-pane-licenses" role="tabpanel">
|
||||
<div class="itflow-asset-pane-bar">
|
||||
@@ -750,8 +774,10 @@ if (!$can_support) {
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($can_support) { ?>
|
||||
<?php if (isset($contact_tabs['documents'])) { ?>
|
||||
<!-- Documents -->
|
||||
<div class="tab-pane fade" id="contact-pane-documents" role="tabpanel">
|
||||
<div class="itflow-asset-pane-bar">
|
||||
@@ -790,7 +816,9 @@ if (!$can_support) {
|
||||
<div class="itflow-asset-empty">No documents.</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (isset($contact_tabs['files'])) { ?>
|
||||
<!-- Files -->
|
||||
<div class="tab-pane fade" id="contact-pane-files" role="tabpanel">
|
||||
<div class="itflow-asset-pane-bar">
|
||||
@@ -827,7 +855,9 @@ if (!$can_support) {
|
||||
<div class="itflow-asset-empty">No files.</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (isset($contact_tabs['services'])) { ?>
|
||||
<!-- Services -->
|
||||
<div class="tab-pane fade" id="contact-pane-services" role="tabpanel">
|
||||
<div class="itflow-asset-pane-bar">
|
||||
@@ -845,6 +875,7 @@ if (!$can_support) {
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
<!-- History, from the audit log -->
|
||||
<div class="tab-pane fade" id="contact-pane-history" role="tabpanel">
|
||||
|
||||
@@ -404,6 +404,7 @@ if (!$contract || ($client_url && intval($contract['contract_client_id']) !== in
|
||||
?></div>
|
||||
</div>
|
||||
</div>
|
||||
<?php if (moduleOn('ticketing')) { // SLAs are ticketing's ?>
|
||||
<div class="small text-body-secondary text-uppercase fw-semibold mt-3 mb-1">SLA by priority</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-sm table-borderless mb-0" data-contract-slas>
|
||||
@@ -430,6 +431,7 @@ if (!$contract || ($client_url && intval($contract['contract_client_id']) !== in
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<div class="card-footer small text-body-secondary" data-contract-in-force>
|
||||
<i class="fas fa-fw <?= $in_force ? 'fa-check-circle text-success' : 'fa-info-circle' ?> me-1"></i>
|
||||
@@ -556,7 +558,7 @@ if (!$contract || ($client_url && intval($contract['contract_client_id']) !== in
|
||||
$reference = $use['ticket_prefix'] . $use['ticket_number']; ?>
|
||||
<li class="list-group-item px-0 d-flex align-items-center gap-2">
|
||||
<div class="flex-grow-1 min-w-0">
|
||||
<a class="d-block text-truncate" href="ticket.php?client_id=<?= $client_id ?>&ticket_id=<?= intval($use['ticket_id']) ?>"><span class="font-monospace small me-1"><?= escapeHtml($reference) ?></span><?= escapeHtml($use['ticket_subject']) ?></a>
|
||||
<?= moduleLink('ticketing', "ticket.php?client_id=$client_id&ticket_id=" . intval($use['ticket_id']), '<span class="font-monospace small me-1">' . escapeHtml($reference) . '</span>' . escapeHtml($use['ticket_subject']), 'class="d-block text-truncate"') ?>
|
||||
<div class="small text-body-secondary">
|
||||
Drawn <?= escapeHtml(date('M j, Y', strtotime($use['drawn_at']))) ?>
|
||||
<?= intval($use['covered']) ? '' : ' · <span class="text-warning-emphasis">part - the rest is billed</span>' ?>
|
||||
|
||||
@@ -24,7 +24,7 @@ if (!isset($period_options[$period_key])) {
|
||||
}
|
||||
$period = dashboardPeriod($period_key);
|
||||
|
||||
$attention = ($access['tickets'] || $access['sales'] || $access['support']) ? dashboardAttention($access) : null;
|
||||
$attention = ($access['tickets'] || $access['sales'] || $access['itdoc']) ? dashboardAttention($access) : null;
|
||||
$my_tickets = $access['tickets'] ? dashboardMyTickets(8) : null;
|
||||
$money_cards = $show_money ? dashboardMoneyCards($access, $period) : [];
|
||||
$schedule = $access['tickets'] ? dashboardSchedule() : null;
|
||||
|
||||
@@ -245,6 +245,10 @@ function filesItemMenu($item) {
|
||||
$html .= "<a class=\"dropdown-item ajax-modal\" href=\"#\" data-modal-url=\"modals/file/file_rename.php?id=$id\"><i class=\"fas fa-fw fa-pen me-2\"></i>Rename</a>";
|
||||
$html .= "<a class=\"dropdown-item ajax-modal\" href=\"#\" data-modal-url=\"modals/file/file_move.php?id=$id\"><i class=\"fas fa-fw fa-folder-open me-2\"></i>Move</a>";
|
||||
$html .= linkPickerButton('file', $id, '', 'Link', 'dropdown-item', 'fas fa-fw fa-link me-2');
|
||||
// An uploaded .md can't be edited as a file - it can as a document
|
||||
if (documentMarkdownReady() && in_array(strtolower((string) ($item['row']['file_ext'] ?? '')), markdownUploadExtensions(), true)) {
|
||||
$html .= "<a class=\"dropdown-item ajax-modal\" href=\"#\" data-modal-url=\"modals/file/file_make_document.php?id=$id\"><i class=\"fab fa-fw fa-markdown me-2\"></i>Make it a document</a>";
|
||||
}
|
||||
}
|
||||
$archive_name = 'file';
|
||||
} else {
|
||||
@@ -357,11 +361,6 @@ $preview = []; // the grid's previewer payload
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-size="lg" data-modal-url="modals/document/document_add_from_template.php?client_id=<?= $client_id ?>&folder_id=<?= $folder_id ?>">
|
||||
<i class="fas fa-fw fa-puzzle-piece me-2"></i>Document from Template
|
||||
</a>
|
||||
<?php if (documentMarkdownReady()) { ?>
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-url="modals/document/document_import_markdown.php?client_id=<?= $client_id ?>&folder_id=<?= $folder_id ?>">
|
||||
<i class="fab fa-fw fa-markdown me-2"></i>Import Markdown Files
|
||||
</a>
|
||||
<?php } ?>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-url="modals/folder/folder_add.php?client_id=<?= $client_id ?>¤t_folder_id=<?= $folder_id ?>">
|
||||
<i class="fas fa-fw fa-folder-plus me-2"></i>New Folder
|
||||
@@ -596,7 +595,11 @@ $preview = []; // the grid's previewer payload
|
||||
} else {
|
||||
$mime = $row['file_mime_type'];
|
||||
$excerpt = '';
|
||||
if (!in_array($mime, getInlineViewableMimeTypes(), true)) {
|
||||
if (in_array(strtolower($row['file_ext']), markdownUploadExtensions(), true) && strpos((string) $mime, 'text/') === 0) {
|
||||
// Shown as the Markdown reads (agent/ajax.php get_file_markdown)
|
||||
$kind = 'markdown';
|
||||
$excerpt = getFileTextExcerpt($client_id, $row['file_reference_name']);
|
||||
} elseif (!in_array($mime, getInlineViewableMimeTypes(), true)) {
|
||||
$kind = 'none';
|
||||
} elseif ($mime === 'application/pdf') {
|
||||
$kind = 'pdf';
|
||||
@@ -606,7 +609,7 @@ $preview = []; // the grid's previewer payload
|
||||
} else {
|
||||
$kind = 'image';
|
||||
}
|
||||
$preview_url = "file.php?file_id=$id&action=view";
|
||||
$preview_url = $kind === 'markdown' ? "ajax.php?get_file_markdown=$id" : "file.php?file_id=$id&action=view";
|
||||
$action_url = "file.php?file_id=$id";
|
||||
$meta = strtoupper($row['file_ext']) . ' · ' . formatBytes($item['size']);
|
||||
}
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
*/
|
||||
?>
|
||||
<div class="dropdown-menu">
|
||||
<?php if (lookupUserPermission("module_support") >= 2) { ?>
|
||||
<?php if (lookupUserPermission("module_support") >= 2 && moduleOn('ticketing')) { ?>
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-url="modals/ticket/ticket_add.php?client_id=<?= $client_id ?>" data-modal-size="lg">
|
||||
<i class="fas fa-fw fa-life-ring me-2"></i>New Ticket
|
||||
</a>
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-url="modals/project/project_add.php?client_id=<?= $client_id ?>" data-modal-size="lg">
|
||||
<i class="fas fa-fw fa-project-diagram me-2"></i>New Project
|
||||
</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<?php } ?>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item ajax-modal" href="#"
|
||||
data-modal-url="modals/client/client_edit.php?id=<?= $client_id ?>">
|
||||
<i class="fas fa-fw fa-edit me-2"></i>Edit Client
|
||||
@@ -39,7 +39,7 @@
|
||||
</a>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
<?php if (lookupUserPermission("module_sales") >= 2) { ?>
|
||||
<?php if (lookupUserPermission("module_sales") >= 2 && moduleOn('accounting')) { ?>
|
||||
<?php if ($show_add_credit) { ?>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="#" data-bs-toggle="modal" data-bs-target="#addCreditModal">
|
||||
|
||||
@@ -25,15 +25,15 @@ if (recurringAheadReady()) {
|
||||
<label class="form-label">Book the work for</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-clock"></i></span>
|
||||
<input type="time" class="form-control" name="schedule_time" step="900" value="<?= escapeHtml($ahead_time) ?>">
|
||||
<input type="time" class="form-control" name="book_time" step="900" value="<?= escapeHtml($ahead_time) ?>">
|
||||
<?php if (ticketScheduleEndReady()) { ?>
|
||||
<select class="form-select select2" name="schedule_minutes" aria-label="How long">
|
||||
<select class="form-select select2" name="book_minutes" aria-label="How long">
|
||||
<?php foreach (ticketScheduleLengths($ahead_minutes) as $minutes => $label) { ?>
|
||||
<option value="<?= intval($minutes) ?>" <?= intval($minutes) === $ahead_minutes ? 'selected' : '' ?>><?= escapeHtml($label) ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<?php } ?>
|
||||
<select class="form-select select2" name="schedule_onsite" aria-label="Visit">
|
||||
<select class="form-select select2" name="book_onsite" aria-label="Visit">
|
||||
<option value="0" <?= $ahead_onsite ? '' : 'selected' ?>>Remote</option>
|
||||
<option value="1" <?= $ahead_onsite ? 'selected' : '' ?>>Onsite</option>
|
||||
</select>
|
||||
|
||||
@@ -66,12 +66,16 @@
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
||||
<li class="nav-item">
|
||||
<a href="/agent/vendors.php" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "vendors.php" || basename($_SERVER["PHP_SELF"]) == "vendor.php") { echo "active"; } ?>">
|
||||
<i class="nav-icon fas fa-building"></i>
|
||||
<p>Vendors</p>
|
||||
</a>
|
||||
</li>
|
||||
<?php // Our vendors with the Vendors permission; without it, every client's when the agent sees clients ?>
|
||||
<?php $nav_vendors = vendorCan(0, 1) ? '/agent/vendors.php' : (lookupUserPermission('module_client') >= 1 ? '/agent/vendors.php?view=clients' : ''); ?>
|
||||
<?php if ($nav_vendors !== '') { ?>
|
||||
<li class="nav-item">
|
||||
<a href="<?= $nav_vendors ?>" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "vendors.php" || basename($_SERVER["PHP_SELF"]) == "vendor.php") { echo "active"; } ?>">
|
||||
<i class="nav-icon fas fa-building"></i>
|
||||
<p>Vendors</p>
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (moduleOn('calendar')) { ?>
|
||||
<li class="nav-item">
|
||||
|
||||
@@ -78,7 +78,7 @@ $guest_url = billingGuestUrl('invoice', $invoice);
|
||||
// Done long enough ago, its link no longer opens it - emailing it again does (functions/guest_link.php)
|
||||
$guest_expired = guestLinkExpired('invoice', $invoice['invoice_id']);
|
||||
// Hardware sold on it, and how much of it is on the client's assets (functions/products.php)
|
||||
$can_see_assets = lookupUserPermission('module_support') >= 1;
|
||||
$can_see_assets = lookupUserPermission('module_support') >= 1 && moduleOn('itdoc');
|
||||
$hardware = $can_see_assets ? productInvoiceHardware($invoice_id) : [];
|
||||
$hardware_units = array_sum(array_column($hardware, 'units'));
|
||||
$hardware_to_add = $status === 'Cancelled' ? 0 : array_sum(array_column($hardware, 'to_add'));
|
||||
@@ -467,7 +467,7 @@ echo agentBannersHtml($client_id);
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($tickets || $unbilled_tickets) { ?>
|
||||
<?php if (($tickets || $unbilled_tickets) && moduleOn('ticketing')) { ?>
|
||||
<div class="card mb-3">
|
||||
<div class="card-header d-flex align-items-center">
|
||||
<h3 class="card-title mb-0 me-auto"><i class="fas fa-fw fa-life-ring text-secondary me-2"></i>Tickets <span class="badge rounded-pill bg-secondary-subtle text-secondary-emphasis fw-normal ms-1"><?= count($tickets) ?></span></h3>
|
||||
|
||||
@@ -54,7 +54,7 @@ $recurring_query = $recurring_filter ? "AND invoice_recurring_invoice_id = $recu
|
||||
$recurring_filter_row = $recurring_filter ? billingRow('recurring', $recurring_filter) : null;
|
||||
|
||||
// Hardware sold on them that isn't on the client's assets yet (functions/products.php)
|
||||
$hardware_filter = !empty($_GET['hardware']);
|
||||
$hardware_filter = !empty($_GET['hardware']) && moduleOn('itdoc');
|
||||
$hardware_query = $hardware_filter ? "AND " . productHardwareInvoiceSql() . " AND invoices.invoice_id IN (SELECT invoice_items.item_invoice_id FROM invoice_items
|
||||
JOIN products ON products.product_id = invoice_items.item_product_id " . productHardwareMadeJoinSql() . " WHERE " . productHardwareShortSql() . ")" : '';
|
||||
|
||||
|
||||
@@ -660,8 +660,9 @@
|
||||
cal.unselect();
|
||||
const params = new URLSearchParams({
|
||||
assigned_to: String(agentId),
|
||||
schedule: ymd(info.start) + 'T' + hm(info.start),
|
||||
schedule_minutes: String(Math.round((info.end - info.start) / 60000)),
|
||||
// Not schedule... - a web application firewall takes a name starting sched for the Unix command
|
||||
book_at: ymd(info.start) + 'T' + hm(info.start),
|
||||
book_minutes: String(Math.round((info.end - info.start) / 60000)),
|
||||
return_to: 'dispatch'
|
||||
});
|
||||
openModal('modals/ticket/ticket_add.php?' + params.toString());
|
||||
|
||||
@@ -140,7 +140,8 @@
|
||||
});
|
||||
doc.innerHTML = '';
|
||||
|
||||
if (item.kind === 'document') {
|
||||
if (item.kind === 'document' || item.kind === 'markdown') {
|
||||
// A document, or an uploaded .md shown as the Markdown reads
|
||||
var requested = current;
|
||||
doc.innerHTML = '<p class="text-secondary mb-0">Loading...</p>';
|
||||
doc.classList.remove('d-none');
|
||||
@@ -151,14 +152,14 @@
|
||||
return;
|
||||
}
|
||||
// HTMLPurifier output - the same the document page renders
|
||||
doc.innerHTML = data.content || '<p class="text-secondary mb-0">This document is empty.</p>';
|
||||
doc.innerHTML = data.content || '<p class="text-secondary mb-0">' + (item.kind === 'markdown' ? 'There is nothing in this file.' : 'This document is empty.') + '</p>';
|
||||
if (typeof prettyContent === 'function') {
|
||||
prettyContent();
|
||||
}
|
||||
})
|
||||
.catch(function () {
|
||||
if (requested === current) {
|
||||
doc.innerHTML = '<p class="text-danger mb-0">Could not load this document.</p>';
|
||||
doc.innerHTML = '<p class="text-danger mb-0">Could not load this ' + (item.kind === 'markdown' ? 'file' : 'document') + '.</p>';
|
||||
}
|
||||
});
|
||||
} else if (item.kind === 'image') {
|
||||
|
||||
@@ -38,9 +38,43 @@
|
||||
}
|
||||
}
|
||||
|
||||
// The ticket's main asset, out of the ones picked in Assets (one field for one or many): the one
|
||||
// it was opened for, or else the first one picked, while it is still picked - kept in assetMain,
|
||||
// which the server goes by (ticketAssetsPosted() in functions/ticket.php)
|
||||
let pickedBefore = [];
|
||||
|
||||
function pickedAssets() {
|
||||
const assets = field("assetSelect");
|
||||
if (!assets) {
|
||||
return [];
|
||||
}
|
||||
return Array.prototype.map.call(assets.selectedOptions, function (option) { return option.value; })
|
||||
.filter(function (value) { return value && value !== '0'; });
|
||||
}
|
||||
|
||||
function mainAsset() {
|
||||
const picked = pickedAssets();
|
||||
const main = field("assetMain");
|
||||
if (main && picked.indexOf(main.value) !== -1) {
|
||||
return main.value;
|
||||
}
|
||||
return picked.length ? picked[0] : '';
|
||||
}
|
||||
|
||||
// After a pick: the main one stays while it is picked; else it is the first of those just
|
||||
// picked - not one that happens to come first in the list
|
||||
function keepMainAsset() {
|
||||
const picked = pickedAssets();
|
||||
const main = field("assetMain");
|
||||
if (main && picked.indexOf(main.value) === -1) {
|
||||
const added = picked.filter(function (value) { return pickedBefore.indexOf(value) === -1; });
|
||||
main.value = added.length ? added[0] : (picked.length ? picked[0] : '');
|
||||
}
|
||||
pickedBefore = picked;
|
||||
}
|
||||
|
||||
function fillFromAsset() {
|
||||
const asset = field("assetSelect");
|
||||
const links = asset ? assetLinks[asset.value] : null;
|
||||
const links = assetLinks[mainAsset()] || null;
|
||||
if (!links) {
|
||||
return;
|
||||
}
|
||||
@@ -71,9 +105,9 @@
|
||||
return;
|
||||
}
|
||||
const contact = field("contactSelect");
|
||||
const asset = field("assetSelect");
|
||||
const asset = mainAsset();
|
||||
const client_id = currentClientId();
|
||||
if (!client_id || ((!contact || contact.value === '0') && (!asset || !asset.value || asset.value === '0'))) {
|
||||
if (!client_id || ((!contact || contact.value === '0') && !asset)) {
|
||||
box.innerHTML = '';
|
||||
return;
|
||||
}
|
||||
@@ -81,7 +115,7 @@
|
||||
ticket_also_open: 1,
|
||||
client_id: client_id,
|
||||
contact_id: contact ? contact.value : 0,
|
||||
asset_id: asset ? asset.value : 0
|
||||
asset_id: asset || 0
|
||||
}, function (data) {
|
||||
try {
|
||||
box.innerHTML = JSON.parse(data).html || '';
|
||||
@@ -100,6 +134,7 @@
|
||||
dropdown.addEventListener('change', function () {
|
||||
touched[id] = true;
|
||||
if (id === "assetSelect") {
|
||||
keepMainAsset();
|
||||
fillFromAsset();
|
||||
} else if (id === "contactSelect") {
|
||||
fillFromContact();
|
||||
@@ -204,7 +239,15 @@
|
||||
return;
|
||||
}
|
||||
|
||||
dropdown.value = dropdown.dataset.selected;
|
||||
// A multi-select (Assets) takes a list - "12,15"
|
||||
if (dropdown.multiple) {
|
||||
const wanted = dropdown.dataset.selected.split(',');
|
||||
Array.prototype.forEach.call(dropdown.options, function (option) {
|
||||
option.selected = wanted.indexOf(option.value) !== -1;
|
||||
});
|
||||
} else {
|
||||
dropdown.value = dropdown.dataset.selected;
|
||||
}
|
||||
|
||||
// What the modal was opened for counts as picked
|
||||
touched[dropdown.id] = true;
|
||||
@@ -343,11 +386,10 @@
|
||||
);
|
||||
}
|
||||
|
||||
// Populate client assets - feeds both the single asset picker and the additional assets
|
||||
// multi-select from one request, as both need the same list
|
||||
// Populate client assets - Assets, one field for one or many
|
||||
function populateAssetsDropdowns(client_id) {
|
||||
|
||||
if (!document.getElementById("assetSelect") && !document.getElementById("additionalAssetsSelect")) {
|
||||
if (!document.getElementById("assetSelect")) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -364,13 +406,11 @@
|
||||
// Access the data for assets (multiple)
|
||||
const assets = response.assets || [];
|
||||
|
||||
const assetSelectDropdown = resetDropdown("assetSelect", '- None -', '0');
|
||||
const additionalAssetsDropdown = resetDropdown("additionalAssetsSelect", null, null);
|
||||
const assetSelectDropdown = resetDropdown("assetSelect", null, null);
|
||||
|
||||
// Assets arrive ordered by type, so a change of type starts a new group
|
||||
let currentType = null;
|
||||
let assetGroup = null;
|
||||
let additionalAssetGroup = null;
|
||||
|
||||
assets.forEach(asset => {
|
||||
const assetType = asset.asset_type || 'Uncategorized';
|
||||
@@ -378,7 +418,6 @@
|
||||
if (assetType !== currentType) {
|
||||
currentType = assetType;
|
||||
assetGroup = appendOptionGroup(assetSelectDropdown, assetType);
|
||||
additionalAssetGroup = appendOptionGroup(additionalAssetsDropdown, assetType);
|
||||
}
|
||||
|
||||
assetLinks[asset.asset_id] = {contact: asset.asset_contact_id, location: asset.asset_location_id};
|
||||
@@ -386,10 +425,10 @@
|
||||
const assetLabel = buildAssetLabel(asset);
|
||||
|
||||
appendGroupedOption(assetGroup, assetLabel, asset.asset_id, asset.asset_icon);
|
||||
appendGroupedOption(additionalAssetGroup, assetLabel, asset.asset_id, asset.asset_icon);
|
||||
});
|
||||
|
||||
applyPreselection(assetSelectDropdown);
|
||||
pickedBefore = pickedAssets();
|
||||
|
||||
loaded();
|
||||
|
||||
|
||||
12
agent/kb.php
12
agent/kb.php
@@ -327,11 +327,17 @@ $csrf = $_SESSION['csrf_token'];
|
||||
</td>
|
||||
<?php } ?>
|
||||
<td class="text-end">
|
||||
<?php if ($can_edit) { ?>
|
||||
<?php $copy_links = kbCopyLinks($row); ?>
|
||||
<?php if ($can_edit || $copy_links) { ?>
|
||||
<div class="dropdown dropstart">
|
||||
<button class="btn btn-sm btn-light" title="More actions" type="button" data-bs-toggle="dropdown"><i class="fas fa-fw fa-ellipsis-v"></i></button>
|
||||
<div class="dropdown-menu">
|
||||
<?php if (!$row['kb_article_archived_at']) { ?>
|
||||
<?php // Its links, for whoever reads it - to send, or to link to it from another article ?>
|
||||
<?= kbCopyLinksMenuHtml($copy_links, 'text-secondary') ?>
|
||||
<?php if ($copy_links && $can_edit) { ?>
|
||||
<div class="dropdown-divider"></div>
|
||||
<?php } ?>
|
||||
<?php if ($can_edit && !$row['kb_article_archived_at']) { ?>
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-size="xl" data-modal-url="modals/kb/kb_article_edit.php?id=<?= $kb_article_id ?>">
|
||||
<i class="fas fa-fw fa-edit text-secondary me-2"></i>Edit
|
||||
</a>
|
||||
@@ -354,7 +360,7 @@ $csrf = $_SESSION['csrf_token'];
|
||||
<a class="dropdown-item text-danger" href="post.php?archive_kb_article=<?= $kb_article_id ?>&csrf_token=<?= $csrf ?>">
|
||||
<i class="fas fa-fw fa-archive me-2"></i>Archive
|
||||
</a>
|
||||
<?php } else { ?>
|
||||
<?php } elseif ($can_edit) { ?>
|
||||
<a class="dropdown-item" href="post.php?restore_kb_article=<?= $kb_article_id ?>&csrf_token=<?= $csrf ?>">
|
||||
<i class="fas fa-fw fa-redo text-secondary me-2"></i>Restore
|
||||
</a>
|
||||
|
||||
@@ -42,6 +42,7 @@ $review = kbReviewState($row);
|
||||
$audience = kbAudiencesFor([$kb_article_id])[$kb_article_id];
|
||||
$visibility = isset(KB_VISIBILITY[$row['kb_article_visibility']]) ? $row['kb_article_visibility'] : 'agents';
|
||||
$public_url = kbPublicUrl($kb_article_id, $row['kb_article_title']);
|
||||
$copy_links = kbCopyLinks($row);
|
||||
|
||||
$versions = [];
|
||||
$sql_versions = mysqli_query($mysqli, "SELECT kb_article_version_id, kb_article_version_title, kb_article_version_created_at, user_name
|
||||
@@ -128,11 +129,16 @@ $page_title = $row['kb_article_title'];
|
||||
<button type="button" class="dropdown-item" onclick="window.print();"><i class="fas fa-fw fa-print me-2"></i>Print</button>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($can_edit) { ?>
|
||||
<?php if ($can_edit || $copy_links) { ?>
|
||||
<div class="dropdown">
|
||||
<button type="button" class="btn btn-outline-secondary" data-bs-toggle="dropdown" title="More actions"><i class="fas fa-ellipsis-v"></i></button>
|
||||
<div class="dropdown-menu dropdown-menu-end">
|
||||
<?php if (!$archived) { ?>
|
||||
<?php // Its links, for whoever reads it - one that won't open yet says why ?>
|
||||
<?= kbCopyLinksMenuHtml($copy_links) ?>
|
||||
<?php if ($copy_links && $can_edit) { ?>
|
||||
<div class="dropdown-divider"></div>
|
||||
<?php } ?>
|
||||
<?php if ($can_edit && !$archived) { ?>
|
||||
<?php if ($published) { ?>
|
||||
<a class="dropdown-item" href="post.php?draft_kb_article=<?= $kb_article_id ?>&csrf_token=<?= $csrf ?>" title="Back to a draft - not finished"><i class="fas fa-fw fa-pencil-alt me-2"></i>Make Draft</a>
|
||||
<?php } ?>
|
||||
@@ -142,7 +148,7 @@ $page_title = $row['kb_article_title'];
|
||||
<a class="dropdown-item" href="post.php?copy_kb_article=<?= $kb_article_id ?>&csrf_token=<?= $csrf ?>" title="A new draft starting from this one"><i class="far fa-fw fa-copy me-2"></i>Copy</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item text-danger" href="post.php?archive_kb_article=<?= $kb_article_id ?>&csrf_token=<?= $csrf ?>"><i class="fas fa-fw fa-archive me-2"></i>Archive</a>
|
||||
<?php } else { ?>
|
||||
<?php } elseif ($can_edit) { ?>
|
||||
<a class="dropdown-item" href="post.php?restore_kb_article=<?= $kb_article_id ?>&csrf_token=<?= $csrf ?>"><i class="fas fa-fw fa-redo me-2"></i>Restore</a>
|
||||
<?php } ?>
|
||||
<?php if ($can_delete) { ?>
|
||||
|
||||
@@ -26,6 +26,7 @@ enforceUserPermission('module_support');
|
||||
|
||||
$software_id = intval($_GET['software_id'] ?? 0);
|
||||
$license = softwareRow($software_id);
|
||||
$license = $license ? vendorRedact($license, $license['vendor_id']) : $license;
|
||||
|
||||
if (!$license || ($client_url && intval($license['software_client_id']) !== intval($client_id))) {
|
||||
|
||||
@@ -151,9 +152,11 @@ if (!$license || ($client_url && intval($license['software_client_id']) !== intv
|
||||
<div class="dropdown">
|
||||
<button type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown"><i class="fas fa-plus me-2"></i>New</button>
|
||||
<div class="dropdown-menu dropdown-menu-end">
|
||||
<?php if (moduleOn('ticketing')) { ?>
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-size="lg" data-modal-url="<?= escapeHtml($renewal_ticket_url) ?>">
|
||||
<i class="fas fa-fw fa-life-ring text-secondary me-2"></i>Renewal Ticket
|
||||
</a>
|
||||
<?php } ?>
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-url="modals/software/software_key_add.php?software_id=<?= $software_id ?>">
|
||||
<i class="fas fa-fw fa-key text-secondary me-2"></i>Keys
|
||||
</a>
|
||||
|
||||
@@ -130,6 +130,15 @@ if (!$location || ($client_url && intval($location['location_client_id']) !== in
|
||||
if (!$can_support) {
|
||||
unset($location_tabs['assets'], $location_tabs['networks'], $location_tabs['racks'], $location_tabs['tickets'], $location_tabs['documents'], $location_tabs['files']);
|
||||
}
|
||||
// The parts of ITFlow switched off (Admin > Settings > Modules) - their tabs and New items go
|
||||
$location_itdoc = moduleOn('itdoc');
|
||||
$location_ticketing = moduleOn('ticketing');
|
||||
if (!$location_itdoc) {
|
||||
unset($location_tabs['assets'], $location_tabs['networks'], $location_tabs['racks'], $location_tabs['documents'], $location_tabs['files']);
|
||||
}
|
||||
if (!$location_ticketing) {
|
||||
unset($location_tabs['tickets']);
|
||||
}
|
||||
|
||||
$move_url = "modals/location/location_assign.php?id=$location_id&kind=";
|
||||
$unset_url = function ($kind, $id) use ($location_id) {
|
||||
@@ -186,7 +195,7 @@ if (!$location || ($client_url && intval($location['location_client_id']) !== in
|
||||
<div class="dropdown">
|
||||
<button type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown"><i class="fas fa-plus me-2"></i>New</button>
|
||||
<div class="dropdown-menu dropdown-menu-end">
|
||||
<?php if ($can_support_edit) { ?>
|
||||
<?php if ($can_support_edit && $location_ticketing) { ?>
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-size="lg" data-modal-url="modals/ticket/ticket_add.php?client_id=<?= $client_id ?>&location_id=<?= $location_id ?>">
|
||||
<i class="fas fa-fw fa-life-ring text-secondary me-2"></i>Ticket Here
|
||||
</a>
|
||||
@@ -201,7 +210,7 @@ if (!$location || ($client_url && intval($location['location_client_id']) !== in
|
||||
<i class="fas fa-fw fa-user text-secondary me-2"></i>Contact
|
||||
</a>
|
||||
<?php } ?>
|
||||
<?php if ($can_support_edit) { ?>
|
||||
<?php if ($can_support_edit && $location_itdoc) { ?>
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-size="lg" data-modal-url="modals/asset/asset_add.php?client_id=<?= $client_id ?>&location_id=<?= $location_id ?>">
|
||||
<i class="fas fa-fw fa-desktop text-secondary me-2"></i>Asset
|
||||
</a>
|
||||
@@ -233,12 +242,12 @@ if (!$location || ($client_url && intval($location['location_client_id']) !== in
|
||||
<button type="button" class="btn btn-outline-secondary dropdown-toggle" data-bs-toggle="dropdown"><i class="fas fa-dolly me-2"></i>Move Here</button>
|
||||
<div class="dropdown-menu dropdown-menu-end">
|
||||
<?php foreach (LOCATION_KINDS as $kind => $k) {
|
||||
if (lookupUserPermission($k['module']) < 2) {
|
||||
if (lookupUserPermission($k['module']) < 2 || ($kind !== 'contact' && !$location_itdoc)) {
|
||||
continue;
|
||||
} ?>
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-url="<?= $move_url . $kind ?>"><i class="fas fa-fw <?= $k['icon'] ?> text-secondary me-2"></i><?= $k['plural'] ?></a>
|
||||
<?php } ?>
|
||||
<?php if ($can_support_edit) { ?>
|
||||
<?php if ($can_support_edit && $location_itdoc) { ?>
|
||||
<div class="dropdown-divider"></div>
|
||||
<?= linkPickerButton('location', $location_id, '', 'Link a document or file', 'dropdown-item', 'fas fa-fw fa-link text-secondary me-2') ?>
|
||||
<?php } ?>
|
||||
@@ -431,6 +440,7 @@ if (!$location || ($client_url && intval($location['location_client_id']) !== in
|
||||
</div>
|
||||
|
||||
<?php if ($can_support) { ?>
|
||||
<?php if (isset($location_tabs['assets'])) { ?>
|
||||
<!-- Assets on site -->
|
||||
<div class="tab-pane fade" id="location-pane-assets" role="tabpanel">
|
||||
<div class="itflow-asset-pane-bar">
|
||||
@@ -477,7 +487,9 @@ if (!$location || ($client_url && intval($location['location_client_id']) !== in
|
||||
<div class="itflow-asset-empty">No assets here.</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (isset($location_tabs['networks'])) { ?>
|
||||
<!-- Networks -->
|
||||
<div class="tab-pane fade" id="location-pane-networks" role="tabpanel">
|
||||
<div class="itflow-asset-pane-bar">
|
||||
@@ -525,7 +537,9 @@ if (!$location || ($client_url && intval($location['location_client_id']) !== in
|
||||
<div class="itflow-asset-empty">No networks here.</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (isset($location_tabs['racks'])) { ?>
|
||||
<!-- Racks -->
|
||||
<div class="tab-pane fade" id="location-pane-racks" role="tabpanel">
|
||||
<div class="itflow-asset-pane-bar">
|
||||
@@ -557,7 +571,9 @@ if (!$location || ($client_url && intval($location['location_client_id']) !== in
|
||||
<div class="itflow-asset-empty">No racks here.</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (isset($location_tabs['tickets'])) { ?>
|
||||
<!-- Tickets for this site -->
|
||||
<div class="tab-pane fade" id="location-pane-tickets" role="tabpanel">
|
||||
<div class="itflow-asset-pane-bar">
|
||||
@@ -575,10 +591,14 @@ if (!$location || ($client_url && intval($location['location_client_id']) !== in
|
||||
<div class="itflow-asset-empty">No tickets for this site.</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<!-- Documents and files -->
|
||||
<?php foreach (['documents' => ['document', $documents, 'Floor plans, site runbooks, cabling and access guides.', 'No documents linked.'],
|
||||
'files' => ['file', $files, 'Photos of the cupboard and the patch panel, plans, leases.', 'No files linked.']] as $pane => [$to, $linked, $hint, $empty]) { ?>
|
||||
'files' => ['file', $files, 'Photos of the cupboard and the patch panel, plans, leases.', 'No files linked.']] as $pane => [$to, $linked, $hint, $empty]) {
|
||||
if (!isset($location_tabs[$pane])) {
|
||||
continue;
|
||||
} ?>
|
||||
<div class="tab-pane fade" id="location-pane-<?= $pane ?>" role="tabpanel">
|
||||
<div class="itflow-asset-pane-bar">
|
||||
<span class="text-body-secondary small"><?= $hint ?></span>
|
||||
|
||||
@@ -167,7 +167,9 @@ $asset_spec_rows = assetSpecRows($asset_row['asset_type'], assetSpecs($asset_id)
|
||||
$asset_has_contact = assetTypeHasField($asset_row['asset_type'], 'contact') || $asset_row['contact_name'];
|
||||
|
||||
$has_left = $asset_ip || $asset_mac || $asset_serial || $asset_warranty || $asset_spec_rows;
|
||||
$has_right = $can_edit || $asset_row['location_name'] || $asset_row['contact_name'] || $asset_rack;
|
||||
// The assets it's linked to - a part on it, or what it's fitted to (functions/asset_link.php)
|
||||
$asset_linked = assetLinked($asset_id);
|
||||
$has_right = $can_edit || $asset_row['location_name'] || $asset_row['contact_name'] || $asset_rack || $asset_linked;
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -302,6 +304,17 @@ ob_start();
|
||||
<span><a href="rack.php?client_id=<?= $client_id ?>&rack_id=<?= intval($asset_rack['rack_id']) ?>"><?= escapeHtml($asset_rack['rack_name']) ?></a> <span class="text-body-secondary">· <?= rackPositionLabel($asset_rack['unit_start_number'], $asset_rack['unit_end_number']) ?>, <?= $asset_rack['unit_face'] === 'rear' ? 'rear' : 'front' ?><?= rackSlotHtml($asset_rack, $client_id) ?><?= intval($asset_rack['unit_slots']) && !$asset_rack['holder_id'] ? ' · holds ' . rackDeviceCount(rackChildCount($asset_rack['unit_id'])) : '' ?></span></span>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if ($asset_linked || ($can_edit && assetLinksReady() && empty($asset_row['asset_archived_at']))) { ?>
|
||||
<div class="itflow-glance-item" title="Linked assets">
|
||||
<i class="fas fa-fw fa-link"></i>
|
||||
<div class="flex-grow-1 min-w-0">
|
||||
<?php foreach ($asset_linked as $n => $linked_asset) { ?><?= $n ? ', ' : '' ?><a href="asset.php?client_id=<?= $client_id ?>&asset_id=<?= intval($linked_asset['asset_id']) ?>"><?= escapeHtml($linked_asset['asset_name']) ?></a><?php } ?>
|
||||
<?php if ($can_edit && empty($asset_row['asset_archived_at'])) { ?>
|
||||
<?= linkPickerButton('asset', $asset_id, 'asset', $asset_linked ? 'Change' : 'Link an asset', 'small' . ($asset_linked ? ' ms-1' : ''), '', 'Link it to another of this client\'s assets') ?>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
72
agent/modals/asset/asset_bulk_warranty.php
Normal file
72
agent/modals/asset/asset_bulk_warranty.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Assets > Bulk Action > Look Up Warranty - the selected assets looked up with their manufacturers
|
||||
* by serial number, a few at a time, each one's empty warranty and purchase dates filled in
|
||||
* (js/warranty_lookup.js warrantyLookupBulk(), agent/ajax.php warranty_lookup, functions/warranty.php).
|
||||
* Up to 500 at once. Each row says what was found; dates already there aren't changed.
|
||||
*/
|
||||
|
||||
require_once '../../../includes/modal_header.php';
|
||||
|
||||
$assets = warrantyAssets(array_slice(array_map('intval', $_GET['asset_ids'] ?? []), 0, 500));
|
||||
$count = count($assets);
|
||||
$can = moduleOn('itdoc') && lookupUserPermission('module_support') >= 2;
|
||||
$makers = warrantyMakers();
|
||||
$ready = warrantySettings()['ready'];
|
||||
|
||||
ob_start();
|
||||
|
||||
?>
|
||||
|
||||
<div class="modal-header bg-dark">
|
||||
<h5 class="modal-title"><i class="fas fa-fw fa-shield-alt me-2"></i>Look Up Warranty for <strong><?= $count ?></strong> asset<?= $count === 1 ? '' : 's' ?></h5>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
|
||||
<div class="modal-body" id="warrantyBulk" data-csrf="<?= $_SESSION['csrf_token'] ?>">
|
||||
<?php if (!$can) { ?>
|
||||
<div class="alert alert-warning mb-0"><i class="fas fa-fw fa-lock me-2"></i>Looking up warranties takes Support at Modify in your role.</div>
|
||||
<?php } elseif (!warrantyAnyReady()) { ?>
|
||||
<div class="alert alert-warning mb-0"><i class="fas fa-fw fa-exclamation-triangle me-2"></i>Warranty lookup isn't set up - an admin sets it up in Admin > Warranty Lookup.</div>
|
||||
<?php } elseif (!$count) { ?>
|
||||
<div class="alert alert-secondary mb-0">None of these assets can be looked up.</div>
|
||||
<?php } else { ?>
|
||||
<p class="text-body-secondary small">Each one's empty warranty and purchase dates are filled in from its manufacturer, by its serial number. Dates already there aren't changed. Keep this open until it's done - closing it stops the lookup.</p>
|
||||
<div class="mb-2 small fw-semibold" data-warranty-progress></div>
|
||||
<div class="table-responsive" style="max-height: 55vh;">
|
||||
<table class="table table-sm table-borderless align-middle mb-0">
|
||||
<thead class="text-nowrap small text-body-secondary">
|
||||
<tr><th>Asset</th><th>Serial</th><th>Result</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($assets as $asset) {
|
||||
$maker = warrantyMaker($asset['asset_make'], $asset['asset_model']); ?>
|
||||
<tr data-warranty-asset="<?= intval($asset['asset_id']) ?>">
|
||||
<td>
|
||||
<div class="fw-semibold text-nowrap"><?= escapeHtml($asset['asset_name']) ?></div>
|
||||
<div class="small text-body-secondary"><?= escapeHtml(trim($asset['asset_make'] . ' ' . $asset['asset_model'])) ?: '-' ?></div>
|
||||
</td>
|
||||
<td class="font-monospace small text-nowrap"><?= escapeHtml($asset['asset_serial']) ?: '-' ?></td>
|
||||
<td class="small" data-warranty-result>
|
||||
<span class="text-body-secondary"><?= $maker !== '' ? escapeHtml($makers[$maker]) . ($ready[$maker] ? ' - waiting' : ' - not set up') : 'Not a Dell, HP or Lenovo' ?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<script>
|
||||
itflowReady(function () {
|
||||
window.warrantyLookupBulk(document.getElementById('warrantyBulk'));
|
||||
});
|
||||
</script>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-light" data-bs-dismiss="modal"><i class="fas fa-times me-2"></i>Close</button>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
require_once '../../../includes/modal_footer.php';
|
||||
@@ -509,8 +509,14 @@ $asset_form_icons = [
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-shield-alt fa-fw"></i></span>
|
||||
<input type="date" class="form-control" name="warranty_expire" max="2999-12-31" value="<?= $asset_warranty_expire ?>">
|
||||
<?php if (warrantyAnyReady()) { // From its manufacturer, by its serial number (js/warranty_lookup.js) ?>
|
||||
<button type="button" class="btn btn-outline-secondary" data-warranty-lookup title="Look up its warranty with its manufacturer - Dell, HP or Lenovo - by its serial number" aria-label="Look up its warranty"><i class="fas fa-fw fa-search"></i></button>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if (warrantyAnyReady()) { ?>
|
||||
<div class="col-12 small" data-warranty-note></div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ ob_start();
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<?php if ($counts['open_tickets']) { ?>
|
||||
<?php if ($counts['open_tickets'] && moduleOn('ticketing')) { ?>
|
||||
<div class="small text-body-secondary"><i class="fas fa-exclamation-triangle text-warning me-1"></i><?= $plural($counts['open_tickets'], 'ticket is', 'tickets are') ?> still open - <a href="tickets.php?client_id=<?= $client_id ?>">resolve or close them</a> as you finish the work.</div>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
@@ -115,6 +115,14 @@ while ($row = mysqli_fetch_assoc($sql_note_type_icons)) {
|
||||
$note_type_icons[$row['category_name']] = escapeHtml($row['category_icon']);
|
||||
}
|
||||
|
||||
// The parts of ITFlow switched off (Admin > Settings > Modules) - none of their tabs
|
||||
if (!moduleOn('itdoc')) {
|
||||
$asset_count = $credential_count = $software_count = $document_count = $file_count = 0;
|
||||
}
|
||||
if (!moduleOn('ticketing')) {
|
||||
$ticket_count = $ticket_open_count = $recurring_ticket_count = 0;
|
||||
}
|
||||
|
||||
// Only the tabs with something in them - same order as the contact page
|
||||
$quick_tabs = array_filter([
|
||||
'assets' => ['label' => 'Assets', 'count' => $asset_count],
|
||||
|
||||
@@ -310,6 +310,12 @@ $tab = 'contractTab' . bin2hex(random_bytes(3));
|
||||
</div>
|
||||
<small class="text-secondary d-block mb-3">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.</small>
|
||||
|
||||
<?php if (!moduleOn('ticketing')) {
|
||||
// SLAs are ticketing's - kept as they are while it is switched off (Admin > Settings > Modules)
|
||||
foreach (CONTRACT_SLA_PRIORITIES as $priority => $part) { ?>
|
||||
<input type="hidden" name="sla_<?= $part ?>" value="<?= intval($c_value("sla_{$part}_id", 0)) ?>" data-contract-field="sla_<?= $part ?>">
|
||||
<?php }
|
||||
} else { ?>
|
||||
<label class="form-label">SLA by ticket priority</label>
|
||||
<?php foreach (CONTRACT_SLA_PRIORITIES as $priority => $part) { ?>
|
||||
<div class="input-group mb-2">
|
||||
@@ -323,6 +329,7 @@ $tab = 'contractTab' . bin2hex(random_bytes(3));
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="form-text">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.</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="<?= $tab ?>Terms" role="tabpanel">
|
||||
|
||||
@@ -133,7 +133,7 @@ ob_start();
|
||||
<li class="itflow-link-row">
|
||||
<?php if ($type === 'vendor') { ?>
|
||||
<?= vendorTile($name, 'sm') ?>
|
||||
<div class="min-w-0 flex-grow-1"><div class="d-flex"><a class="ajax-modal text-truncate" href="#" data-modal-size="lg" data-modal-url="modals/vendor/vendor.php?id=<?= $id ?>"><?= escapeHtml($name) ?></a></div><div class="small text-body-secondary">Vendor</div></div>
|
||||
<div class="min-w-0 flex-grow-1"><div class="d-flex"><?= vendorCanOpen($id) ? '<a class="ajax-modal text-truncate" href="#" data-modal-size="lg" data-modal-url="modals/vendor/vendor.php?id=' . intval($id) . '">' . escapeHtml($name) . '</a>' : '<span class="text-truncate">' . escapeHtml($name) . '</span>' ?></div><div class="small text-body-secondary">Vendor</div></div>
|
||||
<?php } elseif ($type === 'software') { ?>
|
||||
<span class="itflow-link-icon" aria-hidden="true"><i class="fas fa-fw fa-cube"></i></span>
|
||||
<div class="min-w-0 flex-grow-1"><div class="d-flex"><a class="ajax-modal text-truncate" href="#" data-modal-size="lg" data-modal-url="modals/software/software.php?id=<?= $id ?>"><?= escapeHtml($name) ?></a></div><div class="small text-body-secondary">License</div></div>
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Import Markdown files - each .md file picked becomes a document written in Markdown, in the
|
||||
* folder picked (import_markdown_documents, agent/post/document.php).
|
||||
*/
|
||||
|
||||
require_once '../../../includes/modal_header.php';
|
||||
|
||||
enforceUserPermission('module_support', 2);
|
||||
|
||||
$client_id = intval($_GET['client_id'] ?? 0);
|
||||
enforceClientAccess();
|
||||
|
||||
$folder_id = folderOwnedId($_GET['folder_id'] ?? 0, $client_id);
|
||||
|
||||
ob_start();
|
||||
|
||||
?>
|
||||
|
||||
<div class="modal-header bg-dark">
|
||||
<h5 class="modal-title"><i class="fab fa-fw fa-markdown me-2"></i>Import Markdown Files</h5>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<form action="post.php" method="post" enctype="multipart/form-data" autocomplete="off">
|
||||
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
|
||||
<input type="hidden" name="client_id" value="<?= $client_id ?>">
|
||||
<div class="modal-body">
|
||||
<?php if (!documentMarkdownReady()) { ?>
|
||||
<div class="alert alert-warning mb-0">Markdown documents arrive with the next database update - run it from Maintenance > Update first.</div>
|
||||
<?php } else { ?>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Markdown files <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-file-import"></i></span>
|
||||
<input type="file" class="form-control" name="files[]" multiple required accept=".md,.markdown,.mdown,.mkd,text/markdown">
|
||||
</div>
|
||||
<div class="form-text">Each becomes a document written in Markdown, named by the heading it starts with or its file name - up to 50 at a time. Pictures a file points to on your computer aren't brought in.</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Folder</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-folder"></i></span>
|
||||
<select class="form-select select2" name="folder">
|
||||
<?= folderOptionsHtml($client_id, $folder_id) ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($config_client_portal_enable)) { ?>
|
||||
<div class="form-check form-switch">
|
||||
<input type="hidden" name="client_visible" value="0">
|
||||
<input class="form-check-input" type="checkbox" role="switch" name="client_visible" value="1" id="importMarkdownVisible">
|
||||
<label class="form-check-label" for="importMarkdownVisible">
|
||||
<i class="fas fa-fw fa-eye text-body-secondary me-1"></i>Show them in the client portal <span class="text-body-secondary small">- to their technical contacts</span>
|
||||
</label>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<?php if (documentMarkdownReady()) { ?>
|
||||
<button type="submit" name="import_markdown_documents" class="btn btn-primary fw-bold"><i class="fas fa-file-import me-2"></i>Import</button>
|
||||
<?php } ?>
|
||||
<button type="button" class="btn btn-light" data-bs-dismiss="modal"><i class="fas fa-times me-2"></i>Cancel</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
require_once '../../../includes/modal_footer.php';
|
||||
@@ -126,7 +126,7 @@ ob_start();
|
||||
<?php if (!$is_transfer && intval($row['expense_vendor_id'])) { ?>
|
||||
<div class="itflow-glance-item" title="Vendor">
|
||||
<i class="fas fa-fw fa-building"></i>
|
||||
<a class="text-truncate" href="vendor.php?vendor_id=<?= intval($row['expense_vendor_id']) ?>"><?= escapeHtml($row['vendor_name']) ?></a>
|
||||
<?= vendorNameHtml($row['expense_vendor_id'], $row['vendor_name'], 'text-truncate') ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="itflow-glance-item" title="Category">
|
||||
|
||||
@@ -34,8 +34,12 @@ $file_archived = !empty($row['file_archived_at']);
|
||||
$file_info = fileTypeInfo($row['file_ext']);
|
||||
$file_mime = $row['file_mime_type'];
|
||||
|
||||
// What the preview can show - the same rule agent/file.php serves inline by
|
||||
if (!in_array($file_mime, getInlineViewableMimeTypes(), true)) {
|
||||
$file_is_markdown = in_array(strtolower((string) $row['file_ext']), markdownUploadExtensions(), true);
|
||||
|
||||
// What the preview can show - the same rule agent/file.php serves inline by; a .md as it reads
|
||||
if ($file_is_markdown && strpos((string) $file_mime, 'text/') === 0) {
|
||||
$preview_kind = 'markdown';
|
||||
} elseif (!in_array($file_mime, getInlineViewableMimeTypes(), true)) {
|
||||
$preview_kind = '';
|
||||
} elseif ($file_mime === 'application/pdf') {
|
||||
$preview_kind = 'pdf';
|
||||
@@ -79,6 +83,9 @@ ob_start();
|
||||
<a href="file.php?file_id=<?= $file_id ?>&action=view" target="_blank" rel="noopener" title="Open full size"><img src="file.php?file_id=<?= $file_id ?>&thumb=1" alt="<?= $file_name ?>"></a>
|
||||
<?php } elseif ($preview_kind === 'pdf') { ?>
|
||||
<iframe src="file.php?file_id=<?= $file_id ?>&action=view#view=FitH" title="<?= $file_name ?>"></iframe>
|
||||
<?php } elseif ($preview_kind === 'markdown') { ?>
|
||||
<?php /* markdownToHtml() output - purified, as the document page renders */ ?>
|
||||
<div class="itflow-file-preview-markdown prettyContent"><?= fileMarkdownPreviewHtml($file_id) ?: '<p class="text-body-secondary mb-0">There is nothing in this file.</p>' ?></div>
|
||||
<?php } elseif ($preview_kind === 'text') { ?>
|
||||
<pre><?= escapeHtml(getFileTextExcerpt($client_id, $row['file_reference_name'], 2000)) ?></pre>
|
||||
<?php } else { ?>
|
||||
@@ -136,6 +143,9 @@ ob_start();
|
||||
<?php if ($can_edit && !$file_archived) { ?>
|
||||
<button type="button" class="btn btn-outline-secondary ajax-modal" data-modal-url="modals/file/file_rename.php?id=<?= $file_id ?>"><i class="fas fa-pen me-2"></i>Rename</button>
|
||||
<button type="button" class="btn btn-outline-secondary ajax-modal" data-modal-url="modals/file/file_move.php?id=<?= $file_id ?>"><i class="fas fa-folder-open me-2"></i>Move</button>
|
||||
<?php if ($file_is_markdown && documentMarkdownReady()) { ?>
|
||||
<button type="button" class="btn btn-outline-secondary ajax-modal" data-modal-url="modals/file/file_make_document.php?id=<?= $file_id ?>"><i class="fab fa-markdown me-2"></i>Make it a document</button>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
<button type="button" class="btn btn-light" data-bs-dismiss="modal"><i class="fas fa-times me-2"></i>Close</button>
|
||||
</div>
|
||||
|
||||
58
agent/modals/file/file_make_document.php
Normal file
58
agent/modals/file/file_make_document.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Make it a document - an uploaded .md file becomes a document written in Markdown, in the same
|
||||
* folder, that can be edited (make_file_document, agent/post/file.php; functions/markdown_upload.php).
|
||||
*/
|
||||
|
||||
require_once '../../../includes/modal_header.php';
|
||||
|
||||
enforceUserPermission('module_support', 2);
|
||||
|
||||
$file_id = intval($_GET['id'] ?? 0);
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT file_client_id, file_ext, file_name, file_folder_id, file_archived_at FROM files WHERE file_id = $file_id LIMIT 1"));
|
||||
if (!$row) {
|
||||
echo json_encode(['error' => 'That file no longer exists.']);
|
||||
exit;
|
||||
}
|
||||
$client_id = intval($row['file_client_id']);
|
||||
enforceClientAccess();
|
||||
|
||||
$is_markdown = in_array(strtolower((string) $row['file_ext']), markdownUploadExtensions(), true);
|
||||
$file_name = escapeHtml($row['file_name']);
|
||||
$folder_name = escapeHtml(folderDisplayName(folderOwnedId($row['file_folder_id'], $client_id)));
|
||||
|
||||
ob_start();
|
||||
|
||||
?>
|
||||
<div class="modal-header bg-dark">
|
||||
<h5 class="modal-title text-truncate"><i class="fab fa-fw fa-markdown me-2"></i>Make <strong><?= $file_name ?></strong> a document</h5>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
|
||||
<input type="hidden" name="file_id" value="<?= $file_id ?>">
|
||||
<div class="modal-body">
|
||||
<?php if (!$is_markdown || $row['file_archived_at']) { ?>
|
||||
<div class="alert alert-warning mb-0">Only a .md file in Files can be made a document.</div>
|
||||
<?php } elseif (!documentMarkdownReady()) { ?>
|
||||
<div class="alert alert-warning mb-0">Markdown documents arrive with the next database update - run it from Maintenance > Update first.</div>
|
||||
<?php } else { ?>
|
||||
<p>It becomes a document written in Markdown, in <strong><?= $folder_name ?></strong>, that you can edit - named by the heading it starts with.</p>
|
||||
<ul class="mb-0 ps-3">
|
||||
<li>The pictures it uses that are in this client's Files are copied into it. Any that aren't are listed after, to add in the editor.</li>
|
||||
<li>The uploaded file is replaced by the document, with what it was linked to. Its <strong>Export</strong> menu gives you a .md again.</li>
|
||||
</ul>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<?php if ($is_markdown && !$row['file_archived_at'] && documentMarkdownReady()) { ?>
|
||||
<button type="submit" name="make_file_document" class="btn btn-primary fw-bold"><i class="fas fa-file-alt me-2"></i>Make it a document</button>
|
||||
<?php } ?>
|
||||
<button type="button" class="btn btn-light" data-bs-dismiss="modal"><i class="fas fa-times me-2"></i>Cancel</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
require_once '../../../includes/modal_footer.php';
|
||||
@@ -10,6 +10,12 @@
|
||||
* folders: each file goes with its path under it (file_paths[]), and the
|
||||
* folders are made as needed. It goes up twenty files at a time (upload_json),
|
||||
* and upload_folder_done says how it went before the page reloads.
|
||||
*
|
||||
* .md files become documents, with the pictures uploaded with them, unless
|
||||
* Keep them as files is on (functions/markdown_upload.php) - upload_batch ties
|
||||
* the parts of one upload together for that. A zip with Markdown pages in it -
|
||||
* a Notion, Obsidian or wiki export - is opened here (js/zip_reader.js) and
|
||||
* goes up as the folder it holds.
|
||||
*/
|
||||
|
||||
require_once '../../../includes/modal_header.php';
|
||||
@@ -30,7 +36,7 @@ $vendor_id = assetClientOwnedId('vendor', $_GET['vendor_id'] ?? 0, $client_id);
|
||||
$link_name = $asset_id ? $asset['name'] : ($contact_id ? getFieldById('contacts', $contact_id, 'contact_name') : ($software_id ? $software['name'] : ($location_id ? getFieldById('locations', $location_id, 'location_name') : ($vendor_id ? getFieldById('vendors', $vendor_id, 'vendor_name') : ''))));
|
||||
|
||||
// The extensions agent/post/file.php accepts - offered to the picker so the wrong kind is never chosen
|
||||
$upload_extensions = ['jpg', 'jpeg', 'gif', 'png', 'webp', 'pdf', 'txt', 'md', 'doc', 'docx', 'odt', 'csv', 'xls', 'xlsx', 'ods',
|
||||
$upload_extensions = ['jpg', 'jpeg', 'gif', 'png', 'webp', 'pdf', 'txt', 'md', 'markdown', 'doc', 'docx', 'odt', 'csv', 'xls', 'xlsx', 'ods',
|
||||
'pptx', 'odp', 'zip', 'tar', 'gz', 'msg', 'json', 'wav', 'mp3', 'ogg', 'mov', 'mp4', 'av1', 'ovpn', 'cfg', 'ps1', 'vsdx',
|
||||
'drawio', 'pfx', 'pages', 'numbers', 'unf', 'unifi', 'key', 'stk', 'bat', 'swb'];
|
||||
|
||||
@@ -67,6 +73,24 @@ ob_start();
|
||||
<ul class="list-unstyled mb-0 mt-2 itflow-upload-list" data-upload-list></ul>
|
||||
<div class="text-danger small mt-1" data-upload-error hidden></div>
|
||||
|
||||
<input type="hidden" name="upload_batch" value="<?= bin2hex(random_bytes(12)) ?>">
|
||||
<?php if (documentMarkdownReady()) { ?>
|
||||
<div class="itflow-upload-markdown mt-3" data-upload-markdown hidden>
|
||||
<div class="d-flex gap-2">
|
||||
<i class="fab fa-fw fa-markdown fa-lg mt-1"></i>
|
||||
<div class="small min-w-0 flex-grow-1">
|
||||
<div class="fw-semibold" data-upload-markdown-title></div>
|
||||
<ul class="list-unstyled mb-1" data-upload-markdown-list></ul>
|
||||
<div class="text-body-secondary" data-upload-markdown-note>The pictures they use go into them, from what you upload with them. Everything else uploads as it is.</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-check form-switch small mt-2 mb-0">
|
||||
<input class="form-check-input" type="checkbox" role="switch" name="markdown_keep" value="1" id="uploadMarkdownKeep" data-upload-markdown-keep>
|
||||
<label class="form-check-label" for="uploadMarkdownKeep">Keep them as files <span class="text-body-secondary">- each .md uploaded as it is, and a zip as a zip</span></label>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="mt-3 mb-3">
|
||||
<label class="form-label">Folder</label>
|
||||
<div class="input-group">
|
||||
@@ -120,6 +144,102 @@ ob_start();
|
||||
var list = form.querySelector('[data-upload-list]');
|
||||
var error = form.querySelector('[data-upload-error]');
|
||||
var submit = form.querySelector('[data-upload-submit]');
|
||||
var markdown = form.querySelector('[data-upload-markdown]'); // none until the database has Markdown documents
|
||||
var keep = form.querySelector('[data-upload-markdown-keep]');
|
||||
var zips = new Map(); // a zip picked -> what's in it: {state: reading, pages, none or error, ...}
|
||||
|
||||
function isMarkdown(name) {
|
||||
return /\.(md|markdown)$/i.test(name);
|
||||
}
|
||||
|
||||
function plural(count, one, many) {
|
||||
return count + ' ' + (count === 1 ? one : many);
|
||||
}
|
||||
|
||||
// What a zip holds - its Markdown pages, and the folder they'd go in
|
||||
function zipLook(file) {
|
||||
if (zips.has(file)) {
|
||||
return;
|
||||
}
|
||||
if (!window.itflowZip || !window.itflowZip.canUnpack) {
|
||||
zips.set(file, { state: 'error', why: 'this browser can\'t open zips' });
|
||||
return;
|
||||
}
|
||||
zips.set(file, { state: 'reading' });
|
||||
window.itflowZip.list(file).then(function (entries) {
|
||||
// Leave out what computers keep beside files - __MACOSX, .DS_Store, hidden folders
|
||||
entries = entries.filter(function (entry) {
|
||||
return !/(^|\/)(__MACOSX\/|\.)/.test(entry.path) && !/(^|\/)(Thumbs\.db|desktop\.ini)$/i.test(entry.path);
|
||||
});
|
||||
var pages = entries.filter(function (entry) { return isMarkdown(entry.path); }).length;
|
||||
var tops = {};
|
||||
entries.forEach(function (entry) {
|
||||
tops[entry.path.indexOf('/') > 0 ? entry.path.split('/')[0] : ''] = true;
|
||||
});
|
||||
var top = Object.keys(tops);
|
||||
// All in one folder - that folder; otherwise a folder named after the zip
|
||||
var prefix = top.length === 1 && top[0] !== '' ? '' : file.name.replace(/\.zip$/i, '') + '/';
|
||||
zips.set(file, {
|
||||
state: pages ? 'pages' : 'none',
|
||||
pages: pages,
|
||||
entries: entries,
|
||||
prefix: prefix,
|
||||
folder: (prefix ? prefix.slice(0, -1) : top[0]).replace(/\s+[0-9a-f]{32}$/i, ''),
|
||||
bytes: entries.reduce(function (sum, entry) { return sum + entry.size; }, 0)
|
||||
});
|
||||
show();
|
||||
}, function (problem) {
|
||||
zips.set(file, { state: 'error', why: problem.message });
|
||||
show();
|
||||
});
|
||||
}
|
||||
|
||||
// The zips that will be opened and sent up as folders
|
||||
function zipsToOpen(files) {
|
||||
if (picked || !markdown || keep.checked) {
|
||||
return [];
|
||||
}
|
||||
return files.filter(function (file) {
|
||||
return (zips.get(file) || {}).state === 'pages';
|
||||
});
|
||||
}
|
||||
|
||||
// What becomes a document - the panel, when there's Markdown
|
||||
function showMarkdown(items, files) {
|
||||
if (!markdown) {
|
||||
return;
|
||||
}
|
||||
var list = markdown.querySelector('[data-upload-markdown-list]');
|
||||
list.innerHTML = '';
|
||||
function line(text, muted) {
|
||||
var li = document.createElement('li');
|
||||
li.className = 'text-break' + (muted ? ' text-body-secondary' : '');
|
||||
li.textContent = text;
|
||||
list.appendChild(li);
|
||||
}
|
||||
var pages = items.filter(function (item) { return isMarkdown(item.path || item.file.name); });
|
||||
if (pages.length) {
|
||||
line(plural(pages.length, '.md file', '.md files') + ' - ' + pages.slice(0, 3).map(function (item) { return item.file.name; }).join(', ') + (pages.length > 3 ? ' and more' : ''));
|
||||
}
|
||||
var zipped = 0;
|
||||
(picked ? [] : files.filter(function (file) { return /\.zip$/i.test(file.name); })).forEach(function (file) {
|
||||
zipLook(file);
|
||||
var look = zips.get(file);
|
||||
if (look.state === 'reading') {
|
||||
line('Looking in ' + file.name + '...', true);
|
||||
} else if (look.state === 'pages') {
|
||||
zipped++;
|
||||
line(file.name + ' - ' + plural(look.pages, 'Markdown page', 'Markdown pages') + (keep.checked ? ', uploaded as a zip' : ', into a folder ' + look.folder));
|
||||
} else if (look.state === 'error') {
|
||||
line(file.name + ' uploads as a zip - ' + look.why, true);
|
||||
}
|
||||
});
|
||||
var any = pages.length > 0 || zipped > 0;
|
||||
markdown.hidden = !list.children.length;
|
||||
markdown.querySelector('[data-upload-markdown-title]').textContent = keep.checked ? 'Uploaded as they are:' : 'These become documents you can edit:';
|
||||
markdown.querySelector('[data-upload-markdown-note]').hidden = keep.checked || !any;
|
||||
keep.closest('.form-check').hidden = !any;
|
||||
}
|
||||
|
||||
function size(bytes) {
|
||||
var units = ['B', 'KB', 'MB', 'GB'], i = 0;
|
||||
@@ -156,17 +276,57 @@ ob_start();
|
||||
more.textContent = 'and ' + (items.length - 20) + ' more';
|
||||
list.appendChild(more);
|
||||
}
|
||||
showMarkdown(items, files);
|
||||
// A zip that's opened goes up as a folder, by what's in it
|
||||
var opening = zipsToOpen(files);
|
||||
var opened = opening.reduce(function (sum, file) { return sum + zips.get(file).entries.length - 1; }, files.length);
|
||||
var openedBytes = opening.reduce(function (sum, file) { return sum + zips.get(file).bytes - file.size; }, total);
|
||||
var problem = picked
|
||||
? (files.length > FOLDER_MAX_FILES ? 'That is ' + files.length + ' files - upload a folder of up to ' + FOLDER_MAX_FILES + '.'
|
||||
: total > FOLDER_MAX_BYTES ? 'That is ' + size(total) + ' - keep a folder under 2 GB.' : '')
|
||||
: opening.length
|
||||
? (opened > FOLDER_MAX_FILES ? 'That is ' + opened + ' files once the zip is opened - upload up to ' + FOLDER_MAX_FILES + ' at a time.'
|
||||
: openedBytes > FOLDER_MAX_BYTES ? 'That is ' + size(openedBytes) + ' once the zip is opened - keep it under 2 GB.' : '')
|
||||
: files.length > MAX_FILES ? 'That is ' + files.length + ' files - upload up to ' + MAX_FILES + ' at a time, or choose a folder.'
|
||||
: total > MAX_BYTES ? 'That is ' + size(total) + ' - keep each upload under 500 MB.' : '';
|
||||
var reading = files.some(function (file) { return (zips.get(file) || {}).state === 'reading'; });
|
||||
error.textContent = problem;
|
||||
error.hidden = !problem;
|
||||
submit.disabled = !files.length || !!problem;
|
||||
submit.disabled = !files.length || !!problem || reading;
|
||||
drop.classList.toggle('has-files', files.length > 0);
|
||||
}
|
||||
|
||||
if (keep) {
|
||||
keep.addEventListener('change', show);
|
||||
}
|
||||
|
||||
// The zips opened, one file at a time - the picked files, with what's in each zip in its place
|
||||
function openZips(files, opening) {
|
||||
var items = [];
|
||||
var skipped = [];
|
||||
var chain = Promise.resolve();
|
||||
files.forEach(function (file) {
|
||||
if (opening.indexOf(file) === -1) {
|
||||
chain = chain.then(function () { items.push({ file: file, path: file.name }); });
|
||||
return;
|
||||
}
|
||||
var look = zips.get(file);
|
||||
look.entries.forEach(function (entry, index) {
|
||||
chain = chain.then(function () {
|
||||
submit.innerHTML = '<i class="fas fa-spinner fa-spin me-2"></i>Opening ' + (index + 1) + ' of ' + look.entries.length + '...';
|
||||
return window.itflowZip.unpack(file, entry).then(function (unpacked) {
|
||||
items.push({ file: unpacked, path: look.prefix + entry.path });
|
||||
}, function (problem) {
|
||||
skipped.push(look.prefix + entry.path + ' (' + problem.message + ')');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
return chain.then(function () {
|
||||
return { items: items, skipped: skipped };
|
||||
});
|
||||
}
|
||||
|
||||
// A folder's files, with where each sits under it
|
||||
function takeFolder(items) {
|
||||
picked = items.filter(function (item) {
|
||||
@@ -246,7 +406,7 @@ ob_start();
|
||||
});
|
||||
|
||||
// A folder goes up twenty files at a time, then the page reloads with how it went
|
||||
function sendFolder() {
|
||||
function sendFolder(skippedBefore) {
|
||||
var parts = [], part = [], bytes = 0;
|
||||
picked.forEach(function (item) {
|
||||
if (part.length && (part.length >= PART_FILES || bytes + item.file.size > PART_BYTES)) {
|
||||
@@ -260,7 +420,7 @@ ob_start();
|
||||
if (part.length) {
|
||||
parts.push(part);
|
||||
}
|
||||
var done = { uploaded: 0, folders: 0, skipped: [] };
|
||||
var done = { uploaded: 0, folders: 0, skipped: (skippedBefore || []).slice() };
|
||||
var sent = 0;
|
||||
submit.disabled = true;
|
||||
(function next(index) {
|
||||
@@ -268,12 +428,27 @@ ob_start();
|
||||
var finish = new FormData();
|
||||
finish.append('csrf_token', form.querySelector('[name="csrf_token"]').value);
|
||||
finish.append('upload_folder_done', '1');
|
||||
finish.append('upload_batch', form.querySelector('[name="upload_batch"]').value);
|
||||
if (keep && keep.checked) {
|
||||
finish.append('markdown_keep', '1');
|
||||
}
|
||||
finish.append('uploaded', done.uploaded);
|
||||
finish.append('folders', done.folders);
|
||||
done.skipped.forEach(function (name) { finish.append('skipped[]', name); });
|
||||
fetch(form.action, { method: 'POST', body: finish, credentials: 'same-origin' }).finally(function () {
|
||||
window.location.reload();
|
||||
});
|
||||
submit.innerHTML = '<i class="fas fa-spinner fa-spin me-2"></i>' + (markdown && !(keep && keep.checked) ? 'Making documents...' : 'Finishing...');
|
||||
// One document made, and nothing else - it opens; otherwise the list reloads with how it went
|
||||
fetch(form.action, { method: 'POST', body: finish, credentials: 'same-origin' })
|
||||
.then(function (r) { return r.json(); })
|
||||
.then(function (answer) {
|
||||
if (answer && answer.go) {
|
||||
window.location.href = answer.go;
|
||||
} else {
|
||||
window.location.reload();
|
||||
}
|
||||
})
|
||||
.catch(function () {
|
||||
window.location.reload();
|
||||
});
|
||||
return;
|
||||
}
|
||||
submit.innerHTML = '<i class="fas fa-spinner fa-spin me-2"></i>Uploading ' + (sent + 1) + ' of ' + picked.length + '...';
|
||||
@@ -312,6 +487,18 @@ ob_start();
|
||||
sendFolder();
|
||||
return;
|
||||
}
|
||||
// A zip of Markdown pages is opened here and goes up as the folder it holds
|
||||
var files = Array.prototype.slice.call(input.files || []);
|
||||
var opening = zipsToOpen(files);
|
||||
if (opening.length) {
|
||||
e.preventDefault();
|
||||
submit.disabled = true;
|
||||
openZips(files, opening).then(function (opened) {
|
||||
picked = opened.items;
|
||||
sendFolder(opened.skipped);
|
||||
});
|
||||
return;
|
||||
}
|
||||
// Disabled after the browser has read the submitter, so upload_files still posts
|
||||
setTimeout(function () {
|
||||
submit.disabled = true;
|
||||
|
||||
@@ -53,6 +53,13 @@ if ($can_support) {
|
||||
}
|
||||
$open_tickets = ticketRows("tickets.ticket_location_id = $location_id AND " . TICKET_OPEN_SQL);
|
||||
}
|
||||
// The parts of ITFlow switched off (Admin > Settings > Modules) - none of their tabs
|
||||
if (!moduleOn('itdoc')) {
|
||||
$assets = $networks = [];
|
||||
}
|
||||
if (!moduleOn('ticketing')) {
|
||||
$open_tickets = [];
|
||||
}
|
||||
|
||||
$quick_tabs = array_filter([
|
||||
'people' => ['label' => 'People', 'count' => count($people)],
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
require_once '../../../includes/modal_header.php';
|
||||
|
||||
$network = networkForModal($_GET['id'] ?? 0, 1);
|
||||
$network = vendorRedact($network, $network['network_vendor_id']);
|
||||
$network_id = intval($network['network_id']);
|
||||
$client_id = intval($network['network_client_id']);
|
||||
$type = networkType($network);
|
||||
|
||||
@@ -108,7 +108,7 @@ ob_start();
|
||||
<?php if (intval($row['recurring_expense_vendor_id'])) { ?>
|
||||
<div class="itflow-glance-item" title="Vendor">
|
||||
<i class="fas fa-fw fa-building"></i>
|
||||
<a class="text-truncate" href="vendor.php?vendor_id=<?= intval($row['recurring_expense_vendor_id']) ?>"><?= escapeHtml($row['vendor_name']) ?></a>
|
||||
<?= vendorNameHtml($row['recurring_expense_vendor_id'], $row['vendor_name'], 'text-truncate') ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="itflow-glance-item" title="Paid from">
|
||||
|
||||
@@ -6,8 +6,8 @@ require_once '../../../includes/modal_header.php';
|
||||
* New Recurring Ticket - what the tickets it raises will say (Details), how
|
||||
* often and from when, with their priority, category and billing (Planning),
|
||||
* what they are about and their tasks. Opened from a client, contact or
|
||||
* asset, it starts with that filled in; picking an asset fills in the person
|
||||
* it is assigned to.
|
||||
* asset, it starts with that filled in. Assets is one field for one or many;
|
||||
* the first asset picked fills in the person it is assigned to.
|
||||
*/
|
||||
|
||||
enforceUserPermission('module_support', 2);
|
||||
@@ -226,21 +226,14 @@ ob_start();
|
||||
<div class="tab-pane fade" id="pills-add-assets">
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Asset</label>
|
||||
<label class="form-label">Assets</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-desktop"></i></span>
|
||||
<select class="form-select select2" name="asset_id" id="assetSelect" data-selected="<?= $asset_id ?>">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Other assets</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-desktop"></i></span>
|
||||
<select class="form-select select2" name="additional_assets[]" id="additionalAssetsSelect" data-placeholder="- Any other assets involved -" multiple>
|
||||
<select class="form-select select2" name="assets[]" id="assetSelect" data-selected="<?= $asset_id ?: '' ?>" data-placeholder="- Select assets -" multiple>
|
||||
</select>
|
||||
</div>
|
||||
<input type="hidden" name="assets_form" value="1">
|
||||
<input type="hidden" name="asset_main" id="assetMain" value="<?= $asset_id ?>">
|
||||
</div>
|
||||
|
||||
<?php if (!$client_id) { ?>
|
||||
|
||||
@@ -230,39 +230,7 @@ ob_start();
|
||||
<div class="tab-pane fade" id="pills-recurring-related">
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Asset</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-desktop"></i></span>
|
||||
<select class="form-select select2" name="asset_id">
|
||||
<option value="0">- None -</option>
|
||||
<?php
|
||||
$assets = [];
|
||||
$sql_assets = mysqli_query($mysqli, "SELECT asset_id, asset_name, asset_type, asset_make, asset_model, asset_archived_at, contact_name FROM assets
|
||||
LEFT JOIN contacts ON contact_id = asset_contact_id
|
||||
WHERE asset_client_id = $client_id AND (asset_archived_at IS NULL OR asset_id IN (" . implode(',', array_merge([0, $asset_id], $other_asset_ids)) . "))
|
||||
ORDER BY asset_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_assets)) {
|
||||
$assets[] = $row;
|
||||
}
|
||||
foreach ($assets as $row) {
|
||||
$asset_id_select = intval($row['asset_id']); ?>
|
||||
<option <?= $asset_id === $asset_id_select ? 'selected' : '' ?> value="<?= $asset_id_select ?>"<?= selectOptionAsset($row['asset_type'] ?? '', trim(($row['asset_make'] ?? '') . ' ' . ($row['asset_model'] ?? '') . ($row['contact_name'] ? ' - ' . $row['contact_name'] : ''))) ?>><?= escapeHtml($row['asset_name']) ?><?= $row['asset_archived_at'] ? ' (archived)' : '' ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Other assets</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-desktop"></i></span>
|
||||
<select class="form-select select2" name="additional_assets[]" data-placeholder="- Any other assets involved -" multiple>
|
||||
<?php foreach ($assets as $row) {
|
||||
$asset_id_select = intval($row['asset_id']); ?>
|
||||
<option value="<?= $asset_id_select ?>" <?= in_array($asset_id_select, $other_asset_ids, true) ? 'selected' : '' ?><?= selectOptionAsset($row['asset_type'] ?? '', trim(($row['asset_make'] ?? '') . ' ' . ($row['asset_model'] ?? ''))) ?>><?= escapeHtml($row['asset_name']) ?><?= $row['asset_archived_at'] ? ' (archived)' : '' ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<?= ticketAssetsFieldHtml($client_id, $asset_id, $other_asset_ids) ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -25,7 +25,7 @@ $active = function ($row) {
|
||||
};
|
||||
$assets = array_values(array_filter(serviceLinked($service_id, 'asset'), $active));
|
||||
$contacts = array_values(array_filter(serviceLinked($service_id, 'contact'), $active));
|
||||
$vendors = array_values(array_filter(serviceLinked($service_id, 'vendor'), $active));
|
||||
$vendors = array_map(function ($vendor) { return vendorRedact($vendor, $vendor['id']); }, array_values(array_filter(serviceLinked($service_id, 'vendor'), $active)));
|
||||
$urls = serviceUrls($service_id, $can_credentials);
|
||||
$page_url = escapeHtml(serviceUrl($service_id, $client_id));
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ enforceUserPermission('module_support');
|
||||
|
||||
$software_id = intval($_GET['id'] ?? 0);
|
||||
$license = softwareRow($software_id);
|
||||
$license = $license ? vendorRedact($license, $license['vendor_id']) : $license;
|
||||
if (!$license) {
|
||||
echo json_encode(['error' => 'That license no longer exists.']);
|
||||
exit;
|
||||
|
||||
@@ -46,7 +46,7 @@ ticketMarkRead($ticket_id, $session_user_id);
|
||||
|
||||
$purifier_config = HTMLPurifier_Config::createDefault();
|
||||
$purifier_config->set('Cache.DefinitionImpl', null);
|
||||
$purifier_config->set('URI.AllowedSchemes', ['data' => true, 'src' => true, 'http' => true, 'https' => true]);
|
||||
$purifier_config->set('URI.AllowedSchemes', purifierUriSchemes());
|
||||
// Classes our scripts act on (ajax-modal fetches a page and runs it) never come from stored HTML
|
||||
$purifier_config->set('Attr.ForbiddenClasses', ['ajax-modal']);
|
||||
$purifier = new HTMLPurifier($purifier_config);
|
||||
@@ -163,9 +163,26 @@ ob_start();
|
||||
<dt>Assigned</dt>
|
||||
<dd><?= formatAssignee($ticket['ticket_assigned_to'], $ticket['user_name'], $ticket['user_avatar'], $is_open) ?></dd>
|
||||
|
||||
<?php if (intval($ticket['ticket_asset_id']) && $ticket['asset_name'] !== null) { ?>
|
||||
<dt>Asset</dt>
|
||||
<dd><a class="ajax-modal" href="#" data-modal-size="lg" data-modal-url="modals/asset/asset.php?id=<?= intval($ticket['ticket_asset_id']) ?>"><i class="fas fa-desktop text-body-secondary me-1"></i><?= escapeHtml($ticket['asset_name']) ?></a></dd>
|
||||
<?php
|
||||
// Its assets - the main one first, then the others by name
|
||||
$quick_assets = [];
|
||||
if (moduleOn('itdoc')) {
|
||||
if (intval($ticket['ticket_asset_id']) && $ticket['asset_name'] !== null) {
|
||||
$quick_assets[] = [intval($ticket['ticket_asset_id']), $ticket['asset_name']];
|
||||
}
|
||||
$sql_quick_assets = mysqli_query($mysqli, "SELECT assets.asset_id, asset_name FROM ticket_assets JOIN assets ON assets.asset_id = ticket_assets.asset_id
|
||||
WHERE ticket_id = $ticket_id AND ticket_assets.asset_id != " . intval($ticket['ticket_asset_id']) . " ORDER BY asset_name ASC");
|
||||
while ($quick_asset = mysqli_fetch_row($sql_quick_assets)) {
|
||||
$quick_assets[] = [intval($quick_asset[0]), $quick_asset[1]];
|
||||
}
|
||||
}
|
||||
if ($quick_assets) { ?>
|
||||
<dt><?= count($quick_assets) === 1 ? 'Asset' : 'Assets' ?></dt>
|
||||
<dd>
|
||||
<?php foreach ($quick_assets as [$quick_asset_id, $quick_asset_name]) { ?>
|
||||
<div class="text-truncate"><a class="ajax-modal" href="#" data-modal-size="lg" data-modal-url="modals/asset/asset.php?id=<?= $quick_asset_id ?>"><i class="fas fa-desktop text-body-secondary me-1"></i><?= escapeHtml($quick_asset_name) ?></a></div>
|
||||
<?php } ?>
|
||||
</dd>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (intval($ticket['ticket_location_id']) && $ticket['location_name'] !== null) { ?>
|
||||
|
||||
@@ -7,13 +7,14 @@ require_once '../../../includes/modal_header.php';
|
||||
* due, the status it starts in, the work booked, its tags and billing
|
||||
* (Planning), what it is related to, and its tasks. Opened from a client,
|
||||
* contact, asset, site, vendor, project or service, it starts with that
|
||||
* filled in; picking an asset fills in the person it is assigned to and its
|
||||
* site. When the person or the asset already has open tickets, they show
|
||||
* filled in. Assets is one field for one or many; the first asset picked fills
|
||||
* in the person it is assigned to and its site. When the person or the asset
|
||||
* already has open tickets, they show
|
||||
* under the contact - so a second ticket for the same problem gets noticed
|
||||
* before it is raised.
|
||||
*
|
||||
* Copy of a ticket (copy_ticket_id - its More actions > Copy as a new ticket): it starts with
|
||||
* that ticket's subject, details, priority, category, billing, contact, asset, site, vendor and
|
||||
* that ticket's subject, details, priority, category, billing, contact, assets, site, vendor and
|
||||
* tasks, for the same client - which can be changed, and its lists follow.
|
||||
*/
|
||||
|
||||
@@ -24,8 +25,10 @@ $contact_id = intval($_GET['contact_id'] ?? 0);
|
||||
// From a drag over empty time on Dispatch: that agent, booked for that time on the viewer's own
|
||||
// clock, for that long - and back to Dispatch once it is saved
|
||||
$prefill_assigned_to = isset($_GET['assigned_to']) && preg_match('/^\d+$/', (string) $_GET['assigned_to']) ? intval($_GET['assigned_to']) : intval($session_user_id);
|
||||
$prefill_schedule = preg_match('/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/', (string) ($_GET['schedule'] ?? '')) ? (string) $_GET['schedule'] : '';
|
||||
$prefill_schedule_minutes = $prefill_schedule !== '' ? ticketScheduleMinutesValue($_GET['schedule_minutes'] ?? 0) : CALENDAR_TICKET_MINUTES;
|
||||
// (book_at and book_minutes - a web application firewall takes a name starting sched... for the Unix command)
|
||||
$prefill_book_at = (string) ($_GET['book_at'] ?? $_GET['schedule'] ?? '');
|
||||
$prefill_schedule = preg_match('/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/', $prefill_book_at) ? $prefill_book_at : '';
|
||||
$prefill_schedule_minutes = $prefill_schedule !== '' ? ticketScheduleMinutesValue($_GET['book_minutes'] ?? $_GET['schedule_minutes'] ?? 0) : CALENDAR_TICKET_MINUTES;
|
||||
$return_to = ($_GET['return_to'] ?? '') === 'dispatch' ? 'dispatch' : '';
|
||||
$project_id = intval($_GET['project_id'] ?? 0);
|
||||
$asset_id = intval($_GET['asset_id'] ?? 0);
|
||||
@@ -63,6 +66,7 @@ $prefill_priority = 'Medium';
|
||||
$prefill_category_id = 0;
|
||||
$prefill_billable = intval($config_ticket_default_billable) === 1;
|
||||
$existing_tasks = [];
|
||||
$copy_other_asset_ids = [];
|
||||
if ($copy) {
|
||||
$prefill_subject = (string) $copy['ticket_subject'];
|
||||
$prefill_details_html = (string) $copy['ticket_details'];
|
||||
@@ -75,6 +79,7 @@ if ($copy) {
|
||||
if ($client_id === intval($copy['ticket_client_id']) || $copy_client_id) {
|
||||
$contact_id = $contact_id ?: intval($copy['ticket_contact_id']);
|
||||
$asset_id = $asset_id ?: intval($copy['ticket_asset_id']);
|
||||
$copy_other_asset_ids = ticketOtherAssetIds($copy['ticket_id'], $asset_id);
|
||||
$location_id = $location_id ?: intval($copy['ticket_location_id']);
|
||||
$vendor_id = $vendor_id ?: intval($copy['ticket_vendor_id']);
|
||||
}
|
||||
@@ -319,8 +324,8 @@ ob_start();
|
||||
<label class="form-label">Schedule</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-calendar-day"></i></span>
|
||||
<input type="datetime-local" class="form-control" name="schedule" min="<?= date('Y-m-d\TH:i') ?>" value="<?= escapeHtml($prefill_schedule) ?>" aria-label="Date and time of the work">
|
||||
<select class="form-select select2 flex-grow-0 w-auto" name="schedule_minutes" aria-label="How long">
|
||||
<input type="datetime-local" class="form-control" name="book_at" min="<?= date('Y-m-d\TH:i') ?>" value="<?= escapeHtml($prefill_schedule) ?>" aria-label="Date and time of the work">
|
||||
<select class="form-select select2 flex-grow-0 w-auto" name="book_minutes" aria-label="How long">
|
||||
<?php foreach (ticketScheduleLengths($prefill_schedule_minutes) as $minutes => $label) { ?>
|
||||
<option value="<?= intval($minutes) ?>" <?= intval($minutes) === $prefill_schedule_minutes ? 'selected' : '' ?>><?= escapeHtml($label) ?></option>
|
||||
<?php } ?>
|
||||
@@ -366,21 +371,14 @@ ob_start();
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Asset</label>
|
||||
<label class="form-label">Assets</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-desktop"></i></span>
|
||||
<select class="form-select select2" name="asset_id" id="assetSelect" data-selected="<?= $asset_id ?>">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Other assets</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-desktop"></i></span>
|
||||
<select class="form-select select2" name="additional_assets[]" id="additionalAssetsSelect" data-placeholder="- Select additional assets -" multiple>
|
||||
<select class="form-select select2" name="assets[]" id="assetSelect" data-selected="<?= implode(',', array_merge(array_filter([$asset_id]), $copy_other_asset_ids)) ?>" data-placeholder="- Select assets -" multiple>
|
||||
</select>
|
||||
</div>
|
||||
<input type="hidden" name="assets_form" value="1">
|
||||
<input type="hidden" name="asset_main" id="assetMain" value="<?= $asset_id ?>">
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
|
||||
@@ -39,11 +39,7 @@ $ticket_billable = intval($ticket['ticket_billable']);
|
||||
$ticket_due_at = $ticket['ticket_due_at'] ? date('Y-m-d\TH:i', strtotime($ticket['ticket_due_at'])) : '';
|
||||
$edit_tab = ($_GET['tab'] ?? '') === 'planning' ? 'planning' : 'details';
|
||||
|
||||
$other_asset_ids = [];
|
||||
$sql_other_assets = mysqli_query($mysqli, "SELECT asset_id FROM ticket_assets WHERE ticket_id = $ticket_id");
|
||||
while ($row = mysqli_fetch_row($sql_other_assets)) {
|
||||
$other_asset_ids[] = intval($row[0]);
|
||||
}
|
||||
$other_asset_ids = ticketOtherAssetIds($ticket_id, $asset_id);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -205,39 +201,7 @@ ob_start();
|
||||
<?php if ($client_id) { ?>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Asset</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-desktop"></i></span>
|
||||
<select class="form-select select2" name="asset_id">
|
||||
<option value="0">- None -</option>
|
||||
<?php
|
||||
$assets = [];
|
||||
$sql_assets = mysqli_query($mysqli, "SELECT asset_id, asset_name, asset_type, asset_make, asset_model, asset_archived_at, contact_name FROM assets
|
||||
LEFT JOIN contacts ON contact_id = asset_contact_id
|
||||
WHERE asset_client_id = $client_id AND (asset_archived_at IS NULL OR asset_id = $asset_id OR asset_id IN (0" . ($other_asset_ids ? ',' . implode(',', $other_asset_ids) : '') . "))
|
||||
ORDER BY asset_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_assets)) {
|
||||
$assets[] = $row;
|
||||
}
|
||||
foreach ($assets as $row) {
|
||||
$asset_id_select = intval($row['asset_id']); ?>
|
||||
<option <?= $asset_id === $asset_id_select ? 'selected' : '' ?> value="<?= $asset_id_select ?>"<?= selectOptionAsset($row['asset_type'] ?? '', trim(($row['asset_make'] ?? '') . ' ' . ($row['asset_model'] ?? '') . ($row['contact_name'] ? ' - ' . $row['contact_name'] : ''))) ?>><?= escapeHtml($row['asset_name']) ?><?= $row['asset_archived_at'] ? ' (archived)' : '' ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Other assets</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-desktop"></i></span>
|
||||
<select class="form-select select2" name="additional_assets[]" data-placeholder="- Any other assets involved -" multiple>
|
||||
<?php foreach ($assets as $row) {
|
||||
$asset_id_select = intval($row['asset_id']); ?>
|
||||
<option value="<?= $asset_id_select ?>" <?= in_array($asset_id_select, $other_asset_ids, true) ? 'selected' : '' ?><?= selectOptionAsset($row['asset_type'] ?? '', trim(($row['asset_make'] ?? '') . ' ' . ($row['asset_model'] ?? ''))) ?>><?= escapeHtml($row['asset_name']) ?><?= $row['asset_archived_at'] ? ' (archived)' : '' ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<?= ticketAssetsFieldHtml($client_id, $asset_id, $other_asset_ids) ?>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
|
||||
@@ -20,15 +20,8 @@ if (!$client_id) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Additional Assets Selected
|
||||
$additional_assets_array = array();
|
||||
$sql_additional_assets = mysqli_query($mysqli, "SELECT asset_id FROM ticket_assets WHERE ticket_id = $ticket_id");
|
||||
while ($row = mysqli_fetch_assoc($sql_additional_assets)) {
|
||||
$additional_asset_id = intval($row['asset_id']);
|
||||
$additional_assets_array[] = $additional_asset_id;
|
||||
}
|
||||
// What it links to now stays on offer even once archived, so saving doesn't drop it
|
||||
$linked_asset_ids = implode(',', array_merge([0, $asset_id], $additional_assets_array));
|
||||
// Its assets in one field, for one or many - its main one, and the others
|
||||
$other_asset_ids = ticketOtherAssetIds($ticket_id, $asset_id);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -44,49 +37,7 @@ ob_start();
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Primary asset</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-desktop"></i></span>
|
||||
<select class="form-select select2" name="asset">
|
||||
<option value="0">- No asset -</option>
|
||||
<?php
|
||||
|
||||
$sql_assets = mysqli_query($mysqli, "SELECT asset_id, asset_name, asset_type, asset_make, asset_model, asset_archived_at, contact_name FROM assets LEFT JOIN contacts ON contact_id = asset_contact_id WHERE asset_client_id = $client_id AND (asset_archived_at IS NULL OR asset_id IN ($linked_asset_ids)) ORDER BY asset_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_assets)) {
|
||||
$asset_id_select = intval($row['asset_id']);
|
||||
$asset_name_select = escapeHtml($row['asset_name']) . ($row['asset_archived_at'] ? ' (archived)' : '');
|
||||
$asset_contact_name_select = escapeHtml($row['contact_name']);
|
||||
?>
|
||||
<option <?php if ($asset_id == $asset_id_select) { echo "selected"; } ?> value="<?= $asset_id_select ?>"<?= selectOptionAsset($row['asset_type'] ?? '', trim(($row['asset_make'] ?? '') . ' ' . ($row['asset_model'] ?? ''))) ?>><?= $asset_contact_name_select ? "$asset_name_select ($asset_contact_name_select)" : $asset_name_select ?></option>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Other assets</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-desktop"></i></span>
|
||||
<select class="form-select select2" name="additional_assets[]" data-placeholder="- Any other assets involved -" multiple>
|
||||
<option value=""></option>
|
||||
<?php
|
||||
|
||||
$sql_assets = mysqli_query($mysqli, "SELECT asset_id, asset_name, asset_type, asset_make, asset_model, asset_archived_at, contact_name FROM assets LEFT JOIN contacts ON contact_id = asset_contact_id WHERE asset_client_id = $client_id AND asset_id != $asset_id AND (asset_archived_at IS NULL OR asset_id IN ($linked_asset_ids)) ORDER BY asset_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_assets)) {
|
||||
$asset_id_select = intval($row['asset_id']);
|
||||
$asset_name_select = escapeHtml($row['asset_name']) . ($row['asset_archived_at'] ? ' (archived)' : '');
|
||||
$asset_contact_name_select = escapeHtml($row['contact_name']);
|
||||
?>
|
||||
<option value="<?= $asset_id_select ?>"
|
||||
<?php if (in_array($asset_id_select, $additional_assets_array)) { echo "selected"; } ?>
|
||||
<?= selectOptionAsset($row['asset_type'] ?? '', trim(($row['asset_make'] ?? '') . ' ' . ($row['asset_model'] ?? ''))) ?>><?= $asset_contact_name_select ? "$asset_name_select ($asset_contact_name_select)" : $asset_name_select ?></option>
|
||||
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<?= ticketAssetsFieldHtml($client_id, $asset_id, $other_asset_ids) ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -40,7 +40,7 @@ ob_start();
|
||||
<label class="form-label">Date and time</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-calendar-day"></i></span>
|
||||
<input type="datetime-local" class="form-control" name="scheduled_date_time" id="scheduleDateTime" placeholder="Scheduled Date & Time" min="<?= substr(timezoneNow(), 0, 16) ?>" <?php if ($ticket_scheduled_for) { echo "value='$ticket_scheduled_for'"; } ?>>
|
||||
<input type="datetime-local" class="form-control" name="book_at" id="scheduleDateTime" placeholder="Scheduled Date & Time" min="<?= substr(timezoneNow(), 0, 16) ?>" <?php if ($ticket_scheduled_for) { echo "value='$ticket_scheduled_for'"; } ?>>
|
||||
</div>
|
||||
<?= timezoneFormHint() ?>
|
||||
</div>
|
||||
@@ -50,7 +50,7 @@ ob_start();
|
||||
<label class="form-label">Agent</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-user-check"></i></span>
|
||||
<select class="form-select select2" name="schedule_tech" id="scheduleTech">
|
||||
<select class="form-select select2" name="book_agent" id="scheduleTech">
|
||||
<?php if (!$schedule_tech || !isset($schedule_agents[$schedule_tech])) { ?>
|
||||
<option value="<?= $schedule_tech ?>"><?= $schedule_tech ? escapeHtml($row['user_name']) : '- Unassigned -' ?></option>
|
||||
<?php } ?>
|
||||
@@ -64,7 +64,7 @@ ob_start();
|
||||
<label class="form-label">How long</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-hourglass-half"></i></span>
|
||||
<select class="form-select select2" name="schedule_minutes" id="scheduleMinutes">
|
||||
<select class="form-select select2" name="book_minutes" id="scheduleMinutes">
|
||||
<?php foreach (ticketScheduleLengths($schedule_minutes) as $minutes => $label) { ?>
|
||||
<option value="<?= intval($minutes) ?>" <?= intval($minutes) === $schedule_minutes ? 'selected' : '' ?>><?= escapeHtml($label) ?></option>
|
||||
<?php } ?>
|
||||
|
||||
@@ -100,14 +100,14 @@ ob_start();
|
||||
<label class="form-label">Date and time</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-calendar-day"></i></span>
|
||||
<input type="datetime-local" class="form-control" name="scheduled_date_time" id="scheduleDateTime" value="<?= $own_start ? date('Y-m-d\TH:i', strtotime(timezoneToView($own_start))) : '' ?>">
|
||||
<input type="datetime-local" class="form-control" name="book_at" id="scheduleDateTime" value="<?= $own_start ? date('Y-m-d\TH:i', strtotime(timezoneToView($own_start))) : '' ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-5">
|
||||
<label class="form-label">How long</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-hourglass-half"></i></span>
|
||||
<select class="form-select select2" name="schedule_minutes">
|
||||
<select class="form-select select2" name="book_minutes">
|
||||
<?php foreach (ticketScheduleLengths($own_minutes) as $minutes => $label) { ?>
|
||||
<option value="<?= intval($minutes) ?>" <?= intval($minutes) === $own_minutes ? 'selected' : '' ?>><?= escapeHtml($label) ?></option>
|
||||
<?php } ?>
|
||||
|
||||
17
agent/modals/vendor/vendor.php
vendored
17
agent/modals/vendor/vendor.php
vendored
@@ -17,7 +17,9 @@ if (!$vendor) {
|
||||
exit;
|
||||
}
|
||||
$client_id = intval($vendor['vendor_client_id']);
|
||||
if ($client_id) {
|
||||
if (!$client_id) {
|
||||
vendorEnforce(0, 1);
|
||||
} else {
|
||||
enforceUserPermission('module_client');
|
||||
enforceClientAccess();
|
||||
}
|
||||
@@ -64,7 +66,14 @@ if ($can_support) {
|
||||
if ($can_credentials && $client_id) {
|
||||
$logins = linkedRecords('vendor', $vendor_id, 'credential');
|
||||
}
|
||||
$spend = !$client_id && $can_financial ? vendorSpend($vendor_id) : null;
|
||||
$spend = !$client_id && $can_financial && moduleOn('accounting') ? vendorSpend($vendor_id) : null;
|
||||
// The parts of ITFlow switched off (Admin > Settings > Modules) - none of their tabs
|
||||
if (!moduleOn('itdoc')) {
|
||||
$licenses = $assets = $logins = [];
|
||||
}
|
||||
if (!moduleOn('ticketing')) {
|
||||
$cases = [];
|
||||
}
|
||||
|
||||
$quick_tabs = array_filter([
|
||||
'cases' => ['label' => 'Open cases', 'count' => count($cases)],
|
||||
@@ -170,7 +179,7 @@ ob_start();
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($vendor_dial || $vendor_email || $vendor_website_url || ($client_id && $can_support_edit && !$vendor_archived)) { ?>
|
||||
<?php if ($vendor_dial || $vendor_email || $vendor_website_url || ($client_id && $can_support_edit && !$vendor_archived && moduleOn('ticketing'))) { ?>
|
||||
<div class="d-flex flex-wrap gap-2 mt-3">
|
||||
<?php if ($vendor_dial) { ?>
|
||||
<a class="btn btn-sm btn-outline-primary" href="tel:<?= escapeHtml($vendor_dial) ?><?= $vendor['vendor_extension'] ? ',' . escapeHtml($vendor['vendor_extension']) : '' ?>"><i class="fas fa-phone me-1"></i>Call Support</a>
|
||||
@@ -181,7 +190,7 @@ ob_start();
|
||||
<?php if ($vendor_website_url) { ?>
|
||||
<a class="btn btn-sm btn-outline-primary" href="<?= escapeHtml($vendor_website_url) ?>" target="_blank" rel="noopener"><i class="fas fa-external-link-alt me-1"></i>Support Site</a>
|
||||
<?php } ?>
|
||||
<?php if ($client_id && $can_support_edit && !$vendor_archived) { ?>
|
||||
<?php if ($client_id && $can_support_edit && !$vendor_archived && moduleOn('ticketing')) { ?>
|
||||
<a class="btn btn-sm btn-outline-secondary ajax-modal" href="#" data-modal-size="lg" data-modal-url="modals/ticket/ticket_add.php?client_id=<?= $client_id ?>&vendor_id=<?= $vendor_id ?>"><i class="fas fa-life-ring me-1"></i>New Case</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
@@ -29,6 +29,7 @@ enforceUserPermission('module_support');
|
||||
|
||||
$network_id = intval($_GET['network_id'] ?? 0);
|
||||
$network = networkRow($network_id);
|
||||
$network = $network ? vendorRedact($network, $network['network_vendor_id']) : $network;
|
||||
|
||||
if (!$network || ($client_url && intval($network['network_client_id']) !== intval($client_id))) {
|
||||
|
||||
|
||||
@@ -655,6 +655,7 @@ if (isset($_POST['bulk_transfer_client_asset'])) {
|
||||
|
||||
// Get Count
|
||||
$asset_count = count($_POST['asset_ids']);
|
||||
$transferred = []; // old asset ID => new
|
||||
|
||||
foreach($_POST['asset_ids'] as $current_asset_id) {
|
||||
$current_asset_id = intval($current_asset_id);
|
||||
@@ -683,6 +684,7 @@ if (isset($_POST['bulk_transfer_client_asset'])) {
|
||||
WHERE asset_id = $current_asset_id
|
||||
");
|
||||
$new_asset_id = mysqli_insert_id($mysqli);
|
||||
$transferred[$current_asset_id] = $new_asset_id;
|
||||
|
||||
// Transfer all Interfaces over too - with their type, so a port stays a port and an SFP cage a cage
|
||||
$sql_interfaces = mysqli_query($mysqli, "SELECT interface_mac, interface_name, interface_type, interface_primary FROM asset_interfaces WHERE interface_asset_id = $current_asset_id");
|
||||
@@ -730,6 +732,17 @@ if (isset($_POST['bulk_transfer_client_asset'])) {
|
||||
|
||||
} // End Transfer to Client Loop
|
||||
|
||||
// Assets moved together stay linked to each other (functions/asset_link.php) - a link to one
|
||||
// left behind stays with the old, archived asset
|
||||
if (count($transferred) > 1 && assetLinksReady()) {
|
||||
$old_ids = implode(',', array_keys($transferred));
|
||||
$sql_links = mysqli_query($mysqli, "SELECT asset_id, linked_asset_id FROM asset_links WHERE asset_id IN ($old_ids) AND linked_asset_id IN ($old_ids)");
|
||||
while ($row = mysqli_fetch_row($sql_links)) {
|
||||
mysqli_query($mysqli, "INSERT IGNORE INTO asset_links (asset_id, linked_asset_id, asset_link_created_by)
|
||||
VALUES (" . $transferred[intval($row[0])] . ", " . $transferred[intval($row[1])] . ", " . intval($session_user_id) . ")");
|
||||
}
|
||||
}
|
||||
|
||||
logAudit("Asset", "Bulk Transfer", "$session_name transferred $asset_count assets to $new_client_name", $new_client_id);
|
||||
|
||||
flashAlert("Transferred <strong>$asset_count</strong> asset" . ($asset_count === 1 ? '' : 's') . " to <strong>" . stripslashes($new_client_name) . "</strong>");
|
||||
@@ -1042,6 +1055,60 @@ if (isset($_POST['bulk_delete_assets'])) {
|
||||
|
||||
// Licenses are linked in post/link.php (link_software_to_asset)
|
||||
|
||||
/*
|
||||
* Linked assets (functions/asset_link.php) - unlinking one from the asset's page, and moving one
|
||||
* of two linked assets to the other's site: what the Move menu beside it offers, never done on
|
||||
* its own.
|
||||
*/
|
||||
if (isset($_GET['unlink_asset_link'])) {
|
||||
|
||||
validateCSRFToken();
|
||||
|
||||
enforceUserPermission('module_support', 2);
|
||||
|
||||
$asset_id = intval($_GET['asset_id'] ?? 0);
|
||||
$other_id = intval($_GET['other'] ?? 0);
|
||||
$row = linkRecord('asset', $asset_id);
|
||||
if (!$row) {
|
||||
flashAlert('That asset no longer exists.', 'error');
|
||||
redirect();
|
||||
}
|
||||
$client_id = intval($row['client_id']);
|
||||
enforceClientAccess();
|
||||
|
||||
$name = assetLinkRemove($asset_id, $other_id);
|
||||
flashAlert($name !== '' ? 'Unlinked <strong>' . escapeHtml($name) . '</strong> from <strong>' . escapeHtml($row['name']) . '</strong>' : 'They weren\'t linked.', $name !== '' ? 'error' : 'info');
|
||||
redirect();
|
||||
|
||||
}
|
||||
|
||||
if (isset($_GET['move_linked_asset'])) {
|
||||
|
||||
validateCSRFToken();
|
||||
|
||||
enforceUserPermission('module_support', 2);
|
||||
|
||||
$move_id = intval($_GET['move'] ?? 0);
|
||||
$with_id = intval($_GET['with'] ?? 0);
|
||||
$move = assetQuickRow($move_id);
|
||||
$with = assetQuickRow($with_id);
|
||||
if (!$move || !$with) {
|
||||
flashAlert('That asset no longer exists.', 'error');
|
||||
redirect();
|
||||
}
|
||||
$client_id = intval($move['asset_client_id']);
|
||||
enforceClientAccess();
|
||||
if (intval($with['asset_client_id']) !== $client_id || !assetLinkedTo($move_id, $with_id)) {
|
||||
flashAlert('Those two aren\'t linked.', 'error');
|
||||
redirect();
|
||||
}
|
||||
|
||||
[$ok, $message] = assetQuickSet($move_id, 'asset_location', intval($with['asset_location_id']));
|
||||
flashAlert($ok ? '<strong>' . escapeHtml($move['asset_name']) . '</strong>: ' . escapeHtml($message ?: 'already there') : escapeHtml($message), $ok ? 'success' : 'error');
|
||||
redirect();
|
||||
|
||||
}
|
||||
|
||||
if (isset($_GET['unlink_credential_from_asset'])) {
|
||||
|
||||
validateCSRFToken();
|
||||
|
||||
@@ -351,7 +351,10 @@ if (isset($_POST['import_client_asset_interfaces_csv'])) {
|
||||
redirect();
|
||||
}
|
||||
|
||||
$file = fopen($_FILES['file']['tmp_name'], 'r');
|
||||
// As UTF-8 whatever the spreadsheet saved it as
|
||||
$file = fopen('php://temp', 'r+');
|
||||
fwrite($file, csvTextToUtf8((string) @file_get_contents($_FILES['file']['tmp_name'])));
|
||||
rewind($file);
|
||||
$header = fgetcsv($file, 1000, ',');
|
||||
if (!is_array($header) || !in_array(count($header), [8, 9], true)) {
|
||||
fclose($file);
|
||||
|
||||
@@ -478,81 +478,6 @@ if (isset($_GET['export_document_markdown'])) {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Markdown files made into documents (agent/modals/document/document_import_markdown.php) - one
|
||||
* each, written in Markdown, in the folder picked. Each is named by the title in its front
|
||||
* matter or the heading it starts with, else its file name (markdownImportSplit()).
|
||||
*/
|
||||
if (isset($_POST['import_markdown_documents'])) {
|
||||
|
||||
validateCSRFToken();
|
||||
|
||||
enforceUserPermission('module_support', 2);
|
||||
|
||||
$client_id = intval($_POST['client_id'] ?? 0);
|
||||
enforceClientAccess();
|
||||
if (!documentMarkdownReady() || !mysqli_num_rows(mysqli_query($mysqli, "SELECT 1 FROM clients WHERE client_id = $client_id"))) {
|
||||
flashAlert('Markdown files can\'t be imported here yet.', 'error');
|
||||
redirect();
|
||||
}
|
||||
$folder_id = folderOwnedId($_POST['folder'] ?? 0, $client_id);
|
||||
$client_visible = !empty($config_client_portal_enable) && intval($_POST['client_visible'] ?? 0) ? 1 : 0;
|
||||
|
||||
$files = $_FILES['files'] ?? null;
|
||||
$count = is_array($files['name'] ?? null) ? count($files['name']) : 0;
|
||||
$imported = [];
|
||||
$skipped = [];
|
||||
for ($i = 0; $i < $count && count($imported) < 50; $i++) {
|
||||
$original = basename((string) $files['name'][$i]);
|
||||
if ($files['error'][$i] === UPLOAD_ERR_NO_FILE) {
|
||||
continue;
|
||||
}
|
||||
if ($files['error'][$i] !== UPLOAD_ERR_OK || !is_uploaded_file($files['tmp_name'][$i])) {
|
||||
$skipped[] = "$original (it didn't upload)";
|
||||
continue;
|
||||
}
|
||||
if (!preg_match('/\.(md|markdown|mdown|mkd)$/i', $original)) {
|
||||
$skipped[] = "$original (not a .md file)";
|
||||
continue;
|
||||
}
|
||||
if ($files['size'][$i] > 5 * 1024 * 1024) {
|
||||
$skipped[] = "$original (over 5 MB)";
|
||||
continue;
|
||||
}
|
||||
$text = (string) file_get_contents($files['tmp_name'][$i]);
|
||||
if (!mb_check_encoding($text, 'UTF-8')) {
|
||||
$skipped[] = "$original (not UTF-8 text)";
|
||||
continue;
|
||||
}
|
||||
|
||||
[$name, $markdown] = markdownImportSplit($text, preg_replace('/\.(md|markdown|mdown|mkd)$/i', '', $original));
|
||||
$name_sql = escapeSql($name);
|
||||
mysqli_query($mysqli, "INSERT INTO documents SET document_name = '$name_sql', document_description = '', document_content = '', document_content_raw = '',
|
||||
document_client_visible = $client_visible, document_folder_id = $folder_id, document_created_by = $session_user_id, document_client_id = $client_id");
|
||||
$document_id = mysqli_insert_id($mysqli);
|
||||
|
||||
$markdown = markdownSaveImages($markdown, $document_id);
|
||||
$html = markdownToHtml($markdown);
|
||||
mysqli_query($mysqli, "UPDATE documents SET document_content = '" . mysqli_real_escape_string($mysqli, $html) . "',
|
||||
document_content_raw = '" . escapeSql(documentContentRaw($name, $html)) . "'" . documentMarkdownSet($markdown) . " WHERE document_id = $document_id");
|
||||
|
||||
logAudit("Document", "Create", "$session_name imported document $name_sql from " . escapeSql($original), $client_id, $document_id);
|
||||
$imported[] = [$document_id, $name];
|
||||
}
|
||||
|
||||
if (!$imported) {
|
||||
flashAlert('Nothing was imported' . ($skipped ? ': ' . escapeHtml(implode(', ', $skipped)) : ' - pick the .md files to import.'), 'error');
|
||||
redirect();
|
||||
}
|
||||
|
||||
$what = count($imported) === 1 ? 'Document <strong>' . escapeHtml($imported[0][1]) . '</strong> imported' : count($imported) . ' documents imported';
|
||||
flashAlert($what . ($skipped ? ' - left out ' . escapeHtml(implode(', ', $skipped)) : ''), $skipped ? 'warning' : 'success');
|
||||
|
||||
// One goes straight to it; several, to the folder they are in
|
||||
redirect(count($imported) === 1 ? "document.php?client_id=$client_id&document_id={$imported[0][0]}" : "files.php?client_id=$client_id&folder_id=$folder_id&type=document");
|
||||
|
||||
}
|
||||
|
||||
if (isset($_GET['archive_document'])) {
|
||||
|
||||
validateCSRFToken();
|
||||
|
||||
@@ -52,6 +52,11 @@ if (isset($_POST['upload_files'])) {
|
||||
$upload_paths = (array) ($_POST['file_paths'] ?? []);
|
||||
$upload_folders = [];
|
||||
$folders_made = 0;
|
||||
$folders_made_ids = [];
|
||||
|
||||
// .md files become documents, with the pictures uploaded with them (functions/markdown_upload.php) - unless kept as files
|
||||
$markdown_on = empty($_POST['markdown_keep']) && documentMarkdownReady();
|
||||
$markdown_ids = []; // the .md files and pictures of this upload
|
||||
|
||||
foreach ((array) $names as $index => $original_name) {
|
||||
|
||||
@@ -82,7 +87,7 @@ if (isset($_POST['upload_files'])) {
|
||||
$file_mime_type = escapeSql($detected_mime !== '' && $detected_mime !== 'application/octet-stream' ? $detected_mime : $single_file['type']);
|
||||
$file_size = intval($single_file['size']);
|
||||
|
||||
$file_folder_id = isset($upload_paths[$index]) ? folderForUploadPath($client_id, $folder_id, $upload_paths[$index], $upload_folders, $folders_made) : $folder_id;
|
||||
$file_folder_id = isset($upload_paths[$index]) ? folderForUploadPath($client_id, $folder_id, $upload_paths[$index], $upload_folders, $folders_made, $folders_made_ids) : $folder_id;
|
||||
|
||||
mysqli_query($mysqli, "INSERT INTO files SET
|
||||
file_reference_name = '$file_reference_name',
|
||||
@@ -115,19 +120,45 @@ if (isset($_POST['upload_files'])) {
|
||||
logAudit("File", "Upload", "$session_name uploaded file $file_name", $client_id, $file_id);
|
||||
|
||||
$uploaded[] = basename($original_name);
|
||||
if ($markdown_on && in_array(strtolower(pathinfo($original_name, PATHINFO_EXTENSION)), array_merge(markdownUploadExtensions(), markdownPictureExtensions()), true)) {
|
||||
$markdown_ids[] = $file_id;
|
||||
}
|
||||
}
|
||||
|
||||
// A folder goes up in parts from the upload window, which adds up what each part says
|
||||
// A folder goes up in parts from the upload window, which adds up what each part says - its
|
||||
// Markdown waits for the last part, as a picture may come after the .md that uses it
|
||||
if (!empty($_POST['upload_json'])) {
|
||||
$batch = preg_replace('/[^A-Za-z0-9]/', '', (string) ($_POST['upload_batch'] ?? ''));
|
||||
if ($markdown_on && strlen($batch) >= 16 && ($markdown_ids || $folders_made_ids)) {
|
||||
$batches = array_slice((array) ($_SESSION['upload_batches'] ?? []), -4, null, true);
|
||||
$batches[$batch] = $batches[$batch] ?? ['client_id' => $client_id, 'file_ids' => [], 'folder_ids' => []];
|
||||
if (intval($batches[$batch]['client_id']) === $client_id) {
|
||||
$batches[$batch]['file_ids'] = array_slice(array_merge($batches[$batch]['file_ids'], $markdown_ids), 0, 5000);
|
||||
$batches[$batch]['folder_ids'] = array_slice(array_merge($batches[$batch]['folder_ids'], $folders_made_ids), 0, 5000);
|
||||
}
|
||||
$_SESSION['upload_batches'] = $batches;
|
||||
}
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode(['uploaded' => count($uploaded), 'skipped' => array_values(array_map('strval', $skipped)), 'folders' => $folders_made]);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($uploaded && !$skipped) {
|
||||
flashAlert(count($uploaded) === 1 ? "Uploaded <strong>{$uploaded[0]}</strong>" : "Uploaded <strong>" . count($uploaded) . "</strong> files");
|
||||
$markdown = markdownUploadConvert($client_id, $markdown_ids, $folders_made_ids);
|
||||
$files_left = count($uploaded) - count($markdown['documents']) - $markdown['pictures'];
|
||||
[$markdown_said, $markdown_notes, $markdown_tone] = markdownUploadSays($markdown);
|
||||
|
||||
if ($uploaded && $markdown['documents']) {
|
||||
$said = ucfirst(trim(($files_left ? "uploaded <strong>$files_left</strong> file" . ($files_left === 1 ? '' : 's') . ' and ' : '') . $markdown_said));
|
||||
$notes = array_filter([$skipped ? 'skipped <strong>' . count($skipped) . '</strong> (not an allowed type, empty or too big): ' . implode(', ', $skipped) : '', $markdown_notes]);
|
||||
flashAlert($said . ($notes ? ' - ' . implode('. ', $notes) : ''), $skipped ? 'warning' : $markdown_tone);
|
||||
// One document and nothing else - straight to it
|
||||
if (count($markdown['documents']) === 1 && !$files_left && !$notes) {
|
||||
redirect("document.php?client_id=$client_id&document_id={$markdown['documents'][0][0]}");
|
||||
}
|
||||
} elseif ($uploaded && !$skipped) {
|
||||
flashAlert((count($uploaded) === 1 ? "Uploaded <strong>{$uploaded[0]}</strong>" : "Uploaded <strong>" . count($uploaded) . "</strong> files") . ($markdown_notes ? " - $markdown_notes" : ''), $markdown_notes ? 'warning' : 'success');
|
||||
} elseif ($uploaded) {
|
||||
flashAlert("Uploaded <strong>" . count($uploaded) . "</strong>, skipped <strong>" . count($skipped) . "</strong> (not an allowed type, empty or too big): " . implode(', ', $skipped), 'warning');
|
||||
flashAlert("Uploaded <strong>" . count($uploaded) . "</strong>, skipped <strong>" . count($skipped) . "</strong> (not an allowed type, empty or too big): " . implode(', ', $skipped) . ($markdown_notes ? ". $markdown_notes" : ''), 'warning');
|
||||
} else {
|
||||
flashAlert($skipped ? "Nothing uploaded - not an allowed type, empty or too big: " . implode(', ', $skipped) : 'Choose a file to upload.', 'error');
|
||||
}
|
||||
@@ -149,18 +180,41 @@ if (isset($_POST['upload_folder_done'])) {
|
||||
$uploaded = intval($_POST['uploaded'] ?? 0);
|
||||
$folders = intval($_POST['folders'] ?? 0);
|
||||
$skipped = array_slice(array_map(function ($name) { return escapeHtml(mb_substr((string) $name, 0, 200)); }, (array) ($_POST['skipped'] ?? [])), 0, 50);
|
||||
$made = $folders ? " and made <strong>$folders</strong> folder" . ($folders === 1 ? '' : 's') : '';
|
||||
|
||||
if ($uploaded && !$skipped) {
|
||||
flashAlert("Uploaded <strong>$uploaded</strong> file" . ($uploaded === 1 ? '' : 's') . $made);
|
||||
} elseif ($uploaded) {
|
||||
flashAlert("Uploaded <strong>$uploaded</strong>$made, skipped <strong>" . count($skipped) . "</strong> (not an allowed type, empty or too big): " . implode(', ', $skipped), 'warning');
|
||||
// Its .md files made documents, now every picture is in
|
||||
$batch = preg_replace('/[^A-Za-z0-9]/', '', (string) ($_POST['upload_batch'] ?? ''));
|
||||
$batches = (array) ($_SESSION['upload_batches'] ?? []);
|
||||
$markdown = ['documents' => [], 'missing' => [], 'kept' => [], 'pictures' => 0, 'folders_removed' => 0];
|
||||
$client_id = 0;
|
||||
if ($batch !== '' && isset($batches[$batch])) {
|
||||
$upload = $batches[$batch];
|
||||
unset($batches[$batch]);
|
||||
$_SESSION['upload_batches'] = $batches;
|
||||
$client_id = intval($upload['client_id']);
|
||||
enforceClientAccess();
|
||||
if (empty($_POST['markdown_keep'])) {
|
||||
$markdown = markdownUploadConvert($client_id, (array) $upload['file_ids'], (array) $upload['folder_ids']);
|
||||
}
|
||||
}
|
||||
|
||||
$uploaded -= count($markdown['documents']) + $markdown['pictures'];
|
||||
$folders -= $markdown['folders_removed'];
|
||||
[$markdown_said, $markdown_notes, $markdown_tone] = markdownUploadSays($markdown);
|
||||
$what = implode(' and ', array_filter([$uploaded > 0 ? "uploaded <strong>$uploaded</strong> file" . ($uploaded === 1 ? '' : 's') : '', $markdown_said]));
|
||||
if ($what !== '' && $folders > 0) {
|
||||
$what .= $markdown_said !== '' ? ", in <strong>$folders</strong> new folder" . ($folders === 1 ? '' : 's') : " and made <strong>$folders</strong> folder" . ($folders === 1 ? '' : 's');
|
||||
}
|
||||
$what = ucfirst($what);
|
||||
$notes = array_filter([$skipped ? 'skipped <strong>' . count($skipped) . '</strong> (not an allowed type, empty or too big): ' . implode(', ', $skipped) : '', $markdown_notes]);
|
||||
|
||||
if ($what !== '') {
|
||||
flashAlert($what . ($notes ? ' - ' . implode('. ', $notes) : ''), $skipped ? 'warning' : $markdown_tone);
|
||||
} else {
|
||||
flashAlert('Nothing uploaded - not an allowed type, empty or too big' . ($skipped ? ': ' . implode(', ', $skipped) : ''), 'error');
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode(['ok' => true]);
|
||||
echo json_encode(['ok' => true, 'go' => count($markdown['documents']) === 1 && $uploaded <= 0 && !$notes ? "document.php?client_id=$client_id&document_id={$markdown['documents'][0][0]}" : '']);
|
||||
exit;
|
||||
|
||||
}
|
||||
@@ -207,6 +261,38 @@ if (isset($_GET['download_folder_zip']) || isset($_POST['bulk_download_files']))
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Make it a document (agent/modals/file/file_make_document.php) - an uploaded .md file becomes a
|
||||
* Markdown document in its folder, with the pictures it uses that are in the client's Files
|
||||
* (functions/markdown_upload.php). The file goes; the document opens.
|
||||
*/
|
||||
if (isset($_POST['make_file_document'])) {
|
||||
|
||||
validateCSRFToken();
|
||||
|
||||
enforceUserPermission('module_support', 2);
|
||||
|
||||
$file_id = intval($_POST['file_id'] ?? 0);
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT file_name, file_client_id FROM files WHERE file_id = $file_id"));
|
||||
if (!$row) {
|
||||
flashAlert('That file no longer exists.', 'error');
|
||||
redirect();
|
||||
}
|
||||
$client_id = intval($row['file_client_id']);
|
||||
enforceClientAccess();
|
||||
|
||||
$made = markdownFileMakeDocument($file_id);
|
||||
if (!$made['document_id']) {
|
||||
flashAlert('<strong>' . escapeHtml($row['file_name']) . '</strong> couldn\'t be made a document - ' . escapeHtml($made['why']) . '.', 'error');
|
||||
redirect();
|
||||
}
|
||||
|
||||
[$said, $notes, $tone] = markdownUploadSays(['documents' => [[$made['document_id'], $made['name']]], 'missing' => $made['missing'] ? [$made['name'] => $made['missing']] : [], 'kept' => [], 'pictures' => 0, 'folders_removed' => 0]);
|
||||
flashAlert(ucfirst($said) . ($notes ? " - $notes" : ''), $tone);
|
||||
redirect("document.php?client_id=$client_id&document_id={$made['document_id']}");
|
||||
|
||||
}
|
||||
|
||||
if (isset($_POST['rename_file'])) {
|
||||
|
||||
validateCSRFToken();
|
||||
|
||||
@@ -17,7 +17,7 @@ if (isset($_POST['import_check']) || isset($_POST['import_run'])) {
|
||||
|
||||
$answer = function (array $answer) {
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
echo json_encode($answer);
|
||||
echo json_encode($answer, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
exit;
|
||||
};
|
||||
|
||||
|
||||
@@ -266,7 +266,10 @@ if (isset($_POST['import_network_ips_csv'])) {
|
||||
redirect();
|
||||
}
|
||||
|
||||
$file = fopen($_FILES['file']['tmp_name'], 'r');
|
||||
// As UTF-8 whatever the spreadsheet saved it as
|
||||
$file = fopen('php://temp', 'r+');
|
||||
fwrite($file, csvTextToUtf8((string) @file_get_contents($_FILES['file']['tmp_name'])));
|
||||
rewind($file);
|
||||
$header = fgetcsv($file, 1000, ',');
|
||||
if (!is_array($header) || !in_array(count($header), [3, 5], true)) {
|
||||
fclose($file);
|
||||
|
||||
@@ -55,15 +55,21 @@ function recurringTicketFromPost($client_id, $current = null) {
|
||||
// Booked at a time, and made ahead (functions/ticket.php) - before the 1st of the month for month-based repeats only
|
||||
$ahead = '';
|
||||
if (recurringAheadReady() && isset($_POST['lead_days'])) {
|
||||
$time = trim((string) ($_POST['schedule_time'] ?? ''));
|
||||
// (book_* - a web application firewall takes a field named sched... for the Unix command; schedule_* is from before)
|
||||
$time = trim((string) ($_POST['book_time'] ?? $_POST['schedule_time'] ?? ''));
|
||||
$book_minutes = $_POST['book_minutes'] ?? $_POST['schedule_minutes'] ?? null;
|
||||
$mode = ($_POST['lead_mode'] ?? '') === 'month' && recurringTicketMonthBased($frequency) ? 'month' : 'days';
|
||||
$ahead = ", recurring_ticket_schedule_time = " . (preg_match('/^([01]\d|2[0-3]):[0-5]\d$/', $time) ? "'$time:00'" : 'NULL')
|
||||
. ", recurring_ticket_schedule_onsite = " . (intval($_POST['schedule_onsite'] ?? 0) ? 1 : 0)
|
||||
. (ticketScheduleEndReady() && isset($_POST['schedule_minutes']) ? ", recurring_ticket_schedule_minutes = " . ticketScheduleMinutesValue($_POST['schedule_minutes']) : '')
|
||||
. ", recurring_ticket_schedule_onsite = " . (intval($_POST['book_onsite'] ?? $_POST['schedule_onsite'] ?? 0) ? 1 : 0)
|
||||
. (ticketScheduleEndReady() && $book_minutes !== null ? ", recurring_ticket_schedule_minutes = " . ticketScheduleMinutesValue($book_minutes) : '')
|
||||
. ", recurring_ticket_lead_days = " . recurringTicketLeadDays($_POST['lead_days'], $frequency, $mode)
|
||||
. ", recurring_ticket_lead_mode = '$mode'";
|
||||
}
|
||||
|
||||
// Its assets, one field for one or many - the main one on the schedule, the others beside it.
|
||||
// A form without the field keeps what it has.
|
||||
$assets = ticketAssetsPosted($client_id);
|
||||
|
||||
return [
|
||||
'subject' => escapeSql(mb_substr($subject, 0, 500)),
|
||||
'details' => mysqli_real_escape_string($mysqli, (string) ($_POST['details'] ?? '')),
|
||||
@@ -72,7 +78,8 @@ function recurringTicketFromPost($client_id, $current = null) {
|
||||
'billable' => $billable,
|
||||
'assigned_to' => ticketAgentId($_POST['assigned_to'] ?? 0),
|
||||
'contact_id' => ticketClientOwnedId('contact', $_POST['contact_id'] ?? 0, $client_id),
|
||||
'asset_id' => ticketClientOwnedId('asset', $_POST['asset_id'] ?? 0, $client_id),
|
||||
'asset_id' => $assets ? $assets[0] : intval($current['recurring_ticket_asset_id'] ?? 0),
|
||||
'other_asset_ids' => $assets ? $assets[1] : null,
|
||||
'category_id' => ticketCategoryId($_POST['category_id'] ?? 0),
|
||||
'template_id' => $template_id,
|
||||
'fill_ins' => $fill_ins,
|
||||
@@ -146,7 +153,7 @@ if (isset($_POST['add_recurring_ticket'])) {
|
||||
|
||||
$recurring_ticket_id = mysqli_insert_id($mysqli);
|
||||
|
||||
recurringTicketSetOtherAssets($recurring_ticket_id, ticketClientOwnedAssetIds($_POST['additional_assets'] ?? [], $client_id, $f['asset_id']));
|
||||
recurringTicketSetOtherAssets($recurring_ticket_id, $f['other_asset_ids'] ?? []);
|
||||
recurringTicketSetTasks($recurring_ticket_id);
|
||||
if ($f['fill_ins'] !== null) {
|
||||
ticketFillInsStore('recurring_ticket', $recurring_ticket_id, $f['fill_ins']);
|
||||
@@ -193,9 +200,8 @@ if (isset($_POST['edit_recurring_ticket'])) {
|
||||
recurring_ticket_contact_id = {$f['contact_id']}, recurring_ticket_category = {$f['category_id']}, recurring_ticket_ticket_template_id = {$f['template_id']} {$f['ahead']} $by_day_sql
|
||||
WHERE recurring_ticket_id = $recurring_ticket_id");
|
||||
|
||||
// The other assets go with the asset field - an empty multi-select posts nothing
|
||||
if (isset($_POST['asset_id'])) {
|
||||
recurringTicketSetOtherAssets($recurring_ticket_id, ticketClientOwnedAssetIds($_POST['additional_assets'] ?? [], $client_id, $f['asset_id']));
|
||||
if ($f['other_asset_ids'] !== null) {
|
||||
recurringTicketSetOtherAssets($recurring_ticket_id, $f['other_asset_ids']);
|
||||
}
|
||||
if (isset($_POST['tasks_submitted'])) {
|
||||
recurringTicketSetTasks($recurring_ticket_id);
|
||||
|
||||
@@ -67,7 +67,8 @@ if (isset($_POST['add_ticket'])) {
|
||||
$billable = intval($_POST['billable'] ?? 0) ? 1 : 0;
|
||||
$due = ticketDueSql($_POST['due'] ?? '');
|
||||
// The work booked as it is made - checked before anything is saved
|
||||
$schedule_input = trim((string) ($_POST['schedule'] ?? ''));
|
||||
// (book_* - a web application firewall takes a field named sched... for the Unix command; schedule is from before)
|
||||
$schedule_input = trim((string) ($_POST['book_at'] ?? $_POST['schedule'] ?? ''));
|
||||
// Typed on the agent's own clock - kept in the company's (functions/user_timezone.php)
|
||||
$schedule = ticketScheduleValue(timezoneFromView(str_replace('T', ' ', $schedule_input)));
|
||||
if ($schedule_input !== '' && $schedule === '') {
|
||||
@@ -93,11 +94,11 @@ if (isset($_POST['add_ticket'])) {
|
||||
$primary = mysqli_fetch_row(mysqli_query($mysqli, "SELECT contact_id FROM contacts WHERE contact_client_id = $client_id AND contact_primary = 1 AND contact_archived_at IS NULL LIMIT 1"));
|
||||
$contact_id = $primary ? intval($primary[0]) : $contact_id;
|
||||
}
|
||||
$asset_id = ticketClientOwnedId('asset', $_POST['asset_id'] ?? 0, $client_id);
|
||||
// Its assets, one field for one or many - the main one is kept on the ticket, the others beside it
|
||||
[$asset_id, $other_asset_ids] = ticketAssetsPosted($client_id) ?? [0, []];
|
||||
$location_id = ticketClientOwnedId('location', $_POST['location_id'] ?? 0, $client_id);
|
||||
$vendor_id = ticketClientOwnedId('vendor', $_POST['vendor_id'] ?? 0, $client_id);
|
||||
$project_id = ticketClientOwnedId('project', $_POST['project_id'] ?? 0, $client_id);
|
||||
$other_asset_ids = ticketClientOwnedAssetIds($_POST['additional_assets'] ?? [], $client_id, $asset_id);
|
||||
|
||||
// Atomically increment and get the new ticket number
|
||||
mysqli_query($mysqli, "UPDATE settings SET config_ticket_next_number = LAST_INSERT_ID(config_ticket_next_number), config_ticket_next_number = config_ticket_next_number + 1 WHERE company_id = 1");
|
||||
@@ -195,7 +196,7 @@ if (isset($_POST['add_ticket'])) {
|
||||
$created_alert = "Ticket <strong>" . escapeHtml($config_ticket_prefix . $ticket_number) . "</strong> created";
|
||||
if ($schedule !== '') {
|
||||
$booked = ticketSetSchedule(ticketRow($ticket_id), $schedule, intval($_POST['onsite'] ?? 0) ? 1 : 0,
|
||||
date('Y-m-d H:i:s', strtotime($schedule) + ticketScheduleMinutesValue($_POST['schedule_minutes'] ?? 0) * 60));
|
||||
date('Y-m-d H:i:s', strtotime($schedule) + ticketScheduleMinutesValue($_POST['book_minutes'] ?? $_POST['schedule_minutes'] ?? 0) * 60));
|
||||
$created_alert .= " and scheduled for " . escapeHtml($booked['when_text']);
|
||||
if ($booked['conflicts']) {
|
||||
$created_alert .= ".<br>The same agent already has work at that time: <br>" . implode(", <br>", array_map('escapeHtml', $booked['conflicts']));
|
||||
@@ -312,11 +313,8 @@ if (isset($_POST['edit_ticket'])) {
|
||||
$contact_id = ticketClientOwnedId('contact', $_POST['contact_id'], $client_id);
|
||||
$set .= ", ticket_contact_id = $contact_id";
|
||||
}
|
||||
$asset_posted = isset($_POST['asset_id']);
|
||||
if ($asset_posted) {
|
||||
$asset_id = ticketClientOwnedId('asset', $_POST['asset_id'], $client_id);
|
||||
$set .= ", ticket_asset_id = $asset_id";
|
||||
}
|
||||
// Its assets - saved, with what changed noted, once the rest is
|
||||
$assets = ticketAssetsPosted($client_id);
|
||||
if (isset($_POST['location_id'])) {
|
||||
$set .= ", ticket_location_id = " . ticketClientOwnedId('location', $_POST['location_id'], $client_id);
|
||||
}
|
||||
@@ -340,9 +338,9 @@ if (isset($_POST['edit_ticket'])) {
|
||||
syncTicketSlaClock($ticket_id);
|
||||
}
|
||||
|
||||
// An empty multi-select posts nothing, so the other assets go with the asset field
|
||||
if ($asset_posted) {
|
||||
ticketSetOtherAssets($ticket_id, ticketClientOwnedAssetIds($_POST['additional_assets'] ?? [], $client_id, $asset_id));
|
||||
if ($assets !== null) {
|
||||
$assets_before = [intval($row['ticket_asset_id']), ticketOtherAssetIds($ticket_id, $row['ticket_asset_id'])];
|
||||
ticketAssetsSave($ticket_id, $assets[0], $assets[1], $assets_before);
|
||||
}
|
||||
|
||||
// ...and the tags with their marker
|
||||
@@ -539,20 +537,24 @@ if (isset($_GET['delete_ticket_cc'])) {
|
||||
|
||||
}
|
||||
|
||||
if (isset($_GET['delete_ticket_additional_asset'])) {
|
||||
// Takes one asset off a ticket (the x beside it on the ticket page) - its main one too, the first
|
||||
// of the others by name taking its place. delete_ticket_additional_asset is the name from before.
|
||||
if (isset($_GET['remove_ticket_asset']) || isset($_GET['delete_ticket_additional_asset'])) {
|
||||
|
||||
validateCSRFToken();
|
||||
|
||||
$row = ticketForRequest($_GET['ticket_id'] ?? 0, 2);
|
||||
$ticket_id = intval($row['ticket_id']);
|
||||
$asset_id = intval($_GET['delete_ticket_additional_asset']);
|
||||
$asset_name = (string) getFieldById('assets', $asset_id, 'asset_name');
|
||||
|
||||
mysqli_query($mysqli, "DELETE FROM ticket_assets WHERE ticket_id = $ticket_id AND asset_id = $asset_id");
|
||||
$asset_id = intval($_GET['remove_ticket_asset'] ?? $_GET['delete_ticket_additional_asset']);
|
||||
$main_asset_id = intval($row['ticket_asset_id']);
|
||||
$other_asset_ids = ticketOtherAssetIds($ticket_id, $main_asset_id);
|
||||
|
||||
// Named only when it was on this ticket - any other id would say another client's asset name back
|
||||
if (mysqli_affected_rows($mysqli)) {
|
||||
logTicketHistory($ticket_id, "$session_name removed additional asset " . escapeSql($asset_name));
|
||||
if ($asset_id && ($asset_id === $main_asset_id || in_array($asset_id, $other_asset_ids, true))) {
|
||||
$asset_name = (string) getFieldById('assets', $asset_id, 'asset_name');
|
||||
$left = array_values(array_diff($other_asset_ids, [$asset_id]));
|
||||
$new_main = $asset_id === $main_asset_id ? intval(array_shift($left)) : $main_asset_id;
|
||||
ticketAssetsSave($ticket_id, $new_main, $left, [$main_asset_id, $other_asset_ids]);
|
||||
logAudit("Ticket", "Edit", "$session_name removed asset " . escapeSql($asset_name) . " from ticket " . escapeSql(ticketReference($row)), $client_id, $ticket_id);
|
||||
flashAlert("Removed asset <strong>" . escapeHtml($asset_name) . "</strong> from the ticket", 'error');
|
||||
} else {
|
||||
@@ -569,26 +571,21 @@ if (isset($_POST['edit_ticket_asset'])) {
|
||||
|
||||
$row = ticketForRequest($_POST['ticket_id'] ?? 0, 2);
|
||||
$ticket_id = intval($row['ticket_id']);
|
||||
$asset_id = ticketClientOwnedId('asset', $_POST['asset'] ?? 0, $client_id);
|
||||
$reference = escapeSql(ticketReference($row));
|
||||
$main_asset_id = intval($row['ticket_asset_id']);
|
||||
$before = [$main_asset_id, ticketOtherAssetIds($ticket_id, $main_asset_id)];
|
||||
|
||||
mysqli_query($mysqli, "UPDATE tickets SET ticket_asset_id = $asset_id WHERE ticket_id = $ticket_id");
|
||||
// One field for one or many (a form from before has the main one as asset, and additional_assets[])
|
||||
[$asset_id, $other_asset_ids] = ticketAssetsPosted($client_id, 'asset') ?? $before;
|
||||
$all_ids = array_merge(array_filter([$asset_id]), $other_asset_ids);
|
||||
$names = $all_ids ? array_column(mysqli_fetch_all(mysqli_query($mysqli, "SELECT asset_name FROM assets WHERE asset_id IN (" . implode(',', $all_ids) . ") ORDER BY asset_id = $asset_id DESC, asset_name ASC")), 0) : [];
|
||||
|
||||
// The others, when the form carried them
|
||||
if (isset($_POST['additional_assets']) || isset($_POST['additional_assets_form'])) {
|
||||
ticketSetOtherAssets($ticket_id, ticketClientOwnedAssetIds($_POST['additional_assets'] ?? [], $client_id, $asset_id));
|
||||
} else {
|
||||
// The primary asset is never also one of the others
|
||||
mysqli_query($mysqli, "DELETE FROM ticket_assets WHERE ticket_id = $ticket_id AND asset_id = $asset_id");
|
||||
}
|
||||
ticketAssetsSave($ticket_id, $asset_id, $other_asset_ids, $before);
|
||||
|
||||
$asset_name = $asset_id ? (string) getFieldById('assets', $asset_id, 'asset_name') : '';
|
||||
if ($asset_id !== intval($row['ticket_asset_id'])) {
|
||||
logTicketHistory($ticket_id, $asset_id ? "$session_name set the asset to " . escapeSql($asset_name) : "$session_name removed the asset");
|
||||
}
|
||||
logAudit("Ticket", "Edit", "$session_name " . ($asset_id ? "changed asset to " . escapeSql($asset_name) : "removed the asset") . " for ticket $reference", $client_id, $ticket_id);
|
||||
$names_text = implode(', ', $names);
|
||||
logAudit("Ticket", "Edit", "$session_name " . ($names ? "set the assets to " . escapeSql($names_text) : "removed the assets") . " for ticket $reference", $client_id, $ticket_id);
|
||||
|
||||
flashAlert($asset_id ? "Ticket <strong>" . escapeHtml(ticketReference($row)) . "</strong> asset set to <strong>" . escapeHtml($asset_name) . "</strong>" : "Removed the asset from ticket <strong>" . escapeHtml(ticketReference($row)) . "</strong>");
|
||||
flashAlert($names ? "Ticket <strong>" . escapeHtml(ticketReference($row)) . "</strong> assets: <strong>" . escapeHtml($names_text) . "</strong>" : "Removed the assets from ticket <strong>" . escapeHtml(ticketReference($row)) . "</strong>");
|
||||
|
||||
redirect();
|
||||
|
||||
@@ -2267,7 +2264,7 @@ if (isset($_POST['edit_ticket_schedule'])) {
|
||||
|
||||
$row = ticketForRequest($_POST['ticket_id'] ?? 0, 2);
|
||||
// Typed on the agent's own clock - kept in the company's (functions/user_timezone.php)
|
||||
$schedule = ticketScheduleValue(timezoneFromView(str_replace('T', ' ', trim((string) ($_POST['scheduled_date_time'] ?? '')))));
|
||||
$schedule = ticketScheduleValue(timezoneFromView(str_replace('T', ' ', trim((string) ($_POST['book_at'] ?? $_POST['scheduled_date_time'] ?? '')))));
|
||||
|
||||
if ($schedule === '') {
|
||||
flashAlert('Pick the date and time for the work.', 'error');
|
||||
@@ -2279,7 +2276,7 @@ if (isset($_POST['edit_ticket_schedule'])) {
|
||||
}
|
||||
|
||||
// Who does it - given to them first when it's someone new, one who can open the client's tickets - and for how long
|
||||
$schedule_tech = intval($_POST['schedule_tech'] ?? $row['ticket_assigned_to']);
|
||||
$schedule_tech = intval($_POST['book_agent'] ?? $_POST['schedule_tech'] ?? $row['ticket_assigned_to']);
|
||||
if ($schedule_tech && $schedule_tech !== intval($row['ticket_assigned_to'])) {
|
||||
if (!isset(ticketMentionAgents($row['ticket_client_id'])[$schedule_tech])) {
|
||||
flashAlert('That agent can\'t open this client\'s tickets.', 'error');
|
||||
@@ -2294,7 +2291,7 @@ if (isset($_POST['edit_ticket_schedule'])) {
|
||||
ticketMailScheduleAgentCancelled($row);
|
||||
$row = ticketForRequest($row['ticket_id'], 2);
|
||||
}
|
||||
$schedule_end = date('Y-m-d H:i:s', strtotime($schedule) + ticketScheduleMinutesValue($_POST['schedule_minutes'] ?? 0) * 60);
|
||||
$schedule_end = date('Y-m-d H:i:s', strtotime($schedule) + ticketScheduleMinutesValue($_POST['book_minutes'] ?? $_POST['schedule_minutes'] ?? 0) * 60);
|
||||
|
||||
$result = ticketSetSchedule($row, $schedule, intval($_POST['onsite'] ?? 0) ? 1 : 0, $schedule_end);
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ if (isset($_POST['save_ticket_helper'])) {
|
||||
$start = $end = '';
|
||||
if ($mode === 'own') {
|
||||
// Typed on the agent's own clock - kept in the company's (functions/user_timezone.php)
|
||||
$start = ticketScheduleValue(timezoneFromView(str_replace('T', ' ', trim((string) ($_POST['scheduled_date_time'] ?? '')))));
|
||||
$end = $start !== '' ? date('Y-m-d H:i:s', strtotime($start) + ticketScheduleMinutesValue($_POST['schedule_minutes'] ?? 0) * 60) : '';
|
||||
$start = ticketScheduleValue(timezoneFromView(str_replace('T', ' ', trim((string) ($_POST['book_at'] ?? $_POST['scheduled_date_time'] ?? '')))));
|
||||
$end = $start !== '' ? date('Y-m-d H:i:s', strtotime($start) + ticketScheduleMinutesValue($_POST['book_minutes'] ?? $_POST['schedule_minutes'] ?? 0) * 60) : '';
|
||||
}
|
||||
|
||||
[$ok, $message, $conflicts] = ticketHelperSave($row, intval($_POST['user_id'] ?? 0), $mode, $start, $end);
|
||||
|
||||
@@ -456,6 +456,7 @@ if (isExportRequest('export_vendors')) {
|
||||
$archive_query = $archived ? "(client_archived_at IS NOT NULL OR vendor_archived_at IS NOT NULL)" : "(client_archived_at IS NULL AND vendor_archived_at IS NULL)";
|
||||
} else {
|
||||
// Ours, same as the vendors page
|
||||
vendorEnforce(0, 1);
|
||||
$client_id = 0; // for Logging
|
||||
$client_query = "AND vendor_client_id = 0";
|
||||
$file_name_prepend = "$session_company_name-";
|
||||
|
||||
@@ -124,7 +124,7 @@ if (!$product) {
|
||||
<?php if ($product['product_code']) { ?><span title="Your code"><i class="fas fa-fw fa-barcode me-1"></i><span class="font-monospace"><?= escapeHtml($product['product_code']) ?></span></span><?php } ?>
|
||||
<?php if ($product['category_name']) { ?><span title="Income category"><i class="fas fa-fw fa-list me-1"></i><?= escapeHtml($product['category_name']) ?></span><?php } ?>
|
||||
<span><i class="fas fa-fw fa-redo-alt me-1"></i><?= escapeHtml($billed) ?></span>
|
||||
<?php if ($product['vendor_name']) { ?><span><i class="fas fa-fw fa-building me-1"></i><a class="text-reset" href="vendor.php?vendor_id=<?= intval($product['product_vendor_id']) ?>"><?= escapeHtml($product['vendor_name']) ?></a></span><?php } ?>
|
||||
<?php if ($product['vendor_name']) { ?><span><i class="fas fa-fw fa-building me-1"></i><?= vendorNameHtml($product['product_vendor_id'], $product['vendor_name'], 'text-reset') ?></span><?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -282,7 +282,7 @@ if (!$product) {
|
||||
<div class="card-body">
|
||||
<dl class="itflow-asset-dl mb-0">
|
||||
<dt>Vendor</dt>
|
||||
<dd><?= $product['vendor_name'] ? '<a href="vendor.php?vendor_id=' . intval($product['product_vendor_id']) . '">' . escapeHtml($product['vendor_name']) . '</a>' : '<span class="text-body-secondary">Not set</span>' ?></dd>
|
||||
<dd><?= $product['vendor_name'] ? vendorNameHtml($product['product_vendor_id'], $product['vendor_name']) : '<span class="text-body-secondary">Not set</span>' ?></dd>
|
||||
<dt>Part #</dt>
|
||||
<dd>
|
||||
<?php if ($product['product_vendor_part']) { ?>
|
||||
|
||||
@@ -388,7 +388,7 @@ $add_type = in_array($view, ['product', 'hardware', 'stocked', 'reorder'], true)
|
||||
</td>
|
||||
<td class="d-none d-xl-table-cell">
|
||||
<?php if ($row['vendor_name']) { ?>
|
||||
<a class="text-reset" href="vendor.php?vendor_id=<?= intval($row['product_vendor_id']) ?>"><?= escapeHtml($row['vendor_name']) ?></a>
|
||||
<?= vendorNameHtml($row['product_vendor_id'], $row['vendor_name'], 'text-reset') ?>
|
||||
<?php if ($row['product_vendor_part']) { ?><div class="small text-body-secondary font-monospace"><?= escapeHtml($row['product_vendor_part']) ?></div><?php } ?>
|
||||
<?php } else { ?>
|
||||
<span class="text-body-secondary">-</span>
|
||||
|
||||
@@ -85,7 +85,7 @@ if (!$po || !poAccessible($po['po_id'])) {
|
||||
<span class="fs-6"><?= poStatusBadge($status) ?></span>
|
||||
</h1>
|
||||
<div class="text-body-secondary small d-flex flex-wrap column-gap-3 row-gap-1">
|
||||
<span><i class="fas fa-fw fa-building me-1"></i><a class="text-reset" href="vendor.php?vendor_id=<?= intval($po['po_vendor_id']) ?>"><?= escapeHtml((string) $po['vendor_name']) ?></a></span>
|
||||
<span><i class="fas fa-fw fa-building me-1"></i><?= vendorNameHtml($po['po_vendor_id'], (string) $po['vendor_name'], 'text-reset') ?></span>
|
||||
<span title="<?= formatDateTime($po['po_created_at']) ?>"><i class="fas fa-fw fa-pencil-alt me-1"></i>Made <?= escapeHtml(date('M j, Y', strtotime($po['po_created_at']))) ?><?= $po['created_by_name'] ? ' by ' . escapeHtml($po['created_by_name']) : '' ?></span>
|
||||
<?php if ($po['po_approved_at'] && $po['approved_by_name'] && in_array($status, ['approved', 'ordered', 'partial', 'received'], true)) { ?>
|
||||
<span title="<?= escapeHtml((string) $po['po_approval_note']) ?>"><i class="fas fa-fw fa-thumbs-up me-1"></i>Approved by <?= escapeHtml($po['approved_by_name']) ?></span>
|
||||
|
||||
@@ -114,7 +114,7 @@ echo agentBannersHtml($client_id);
|
||||
<?php if (trim((string) $quote['quote_scope']) !== '') { ?><span><i class="fas fa-fw fa-comment me-1"></i><?= escapeHtml($quote['quote_scope']) ?></span><?php } ?>
|
||||
<?php if ($quote['category_name']) { ?><span><i class="fas fa-fw fa-tag me-1"></i><?= escapeHtml($quote['category_name']) ?></span><?php } ?>
|
||||
<?php if ($ticket) { ?>
|
||||
<span><i class="fas fa-fw fa-life-ring me-1"></i>For <a class="text-reset" href="ticket.php?ticket_id=<?= intval($ticket['ticket_id']) ?>"><?= escapeHtml($ticket['ticket_prefix'] . $ticket['ticket_number']) ?></a></span>
|
||||
<span><i class="fas fa-fw fa-life-ring me-1"></i>For <?= moduleLink('ticketing', 'ticket.php?ticket_id=' . intval($ticket['ticket_id']), escapeHtml($ticket['ticket_prefix'] . $ticket['ticket_number']), 'class="text-reset"') ?></span>
|
||||
<?php } ?>
|
||||
<span title="<?= formatDateTime($quote['quote_created_at']) ?>"><i class="far fa-fw fa-clock me-1"></i>Created <?= escapeHtml(timeAgo($quote['quote_created_at'])) ?></span>
|
||||
</div>
|
||||
@@ -318,7 +318,11 @@ echo agentBannersHtml($client_id);
|
||||
<div class="list-group-item d-flex align-items-center gap-2">
|
||||
<?= fileTypeTile($file['file_ext'], 'sm') ?>
|
||||
<div class="flex-grow-1 min-w-0">
|
||||
<a class="ajax-modal text-break" href="#" data-modal-size="lg" data-modal-url="modals/file/file.php?id=<?= $file_id ?>"><?= escapeHtml($file['file_name']) ?></a>
|
||||
<?php if (moduleOn('itdoc')) { ?>
|
||||
<a class="ajax-modal text-break" href="#" data-modal-size="lg" data-modal-url="modals/file/file.php?id=<?= $file_id ?>"><?= escapeHtml($file['file_name']) ?></a>
|
||||
<?php } else { // The quick look is IT documentation's; the download stays ?>
|
||||
<span class="text-break"><?= escapeHtml($file['file_name']) ?></span>
|
||||
<?php } ?>
|
||||
<div class="small text-body-secondary"><?= formatBytes(intval($file['file_size'])) ?> · <span title="<?= formatDateTime($file['file_created_at']) ?>"><?= escapeHtml(timeAgo($file['file_created_at'])) ?></span></div>
|
||||
</div>
|
||||
<a class="btn btn-sm btn-link text-body-secondary" href="file.php?file_id=<?= $file_id ?>" title="Download"><i class="fas fa-fw fa-download"></i></a>
|
||||
|
||||
@@ -240,7 +240,7 @@ if ($client) {
|
||||
$advice[] = ['info', 'fa-tags', '<strong>' . escapeHtml($top['label']) . ' was ' . reportPercent(reportShare($top['value'], $t['opened'], 0)) . ' of tickets</strong> (' . reportCount($top['value']) . ').
|
||||
Fixing the cause, or some training, could cut that down.', ''];
|
||||
}
|
||||
if ($t && $t['assets'] && intval($t['assets'][0]['n']) >= 3) {
|
||||
if ($t && $itdoc && $t['assets'] && intval($t['assets'][0]['n']) >= 3) {
|
||||
$asset = $t['assets'][0];
|
||||
$advice[] = ['info', 'fa-redo', '<strong>' . escapeHtml($asset['asset_name']) . ' was on ' . reportCount(intval($asset['n'])) . ' tickets.</strong> Worth repairing properly or replacing.',
|
||||
'/agent/asset.php?client_id=' . $client_id . '&asset_id=' . intval($asset['asset_id'])];
|
||||
@@ -573,8 +573,8 @@ $header = [
|
||||
<?php } ?>
|
||||
|
||||
<p class="small text-body-secondary">
|
||||
Times run on the clock from when a ticket was raised; "typical" is the middle ticket, so a few long ones do not skew it. The SLA counts business hours.
|
||||
Hardware age runs from the purchase date, else the install date.
|
||||
<?php if ($ticketing) { ?>Times run on the clock from when a ticket was raised; "typical" is the middle ticket, so a few long ones do not skew it. The SLA counts business hours.<?php } ?>
|
||||
<?php if ($itdoc) { ?>Hardware age runs from the purchase date, else the install date.<?php } ?>
|
||||
</p>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
@@ -92,7 +92,7 @@ unset($vendor);
|
||||
$columns = [
|
||||
'vendor' => ['label' => 'Vendor', 'html' => function ($row) {
|
||||
$name = escapeHtml($row['vendor']);
|
||||
return $row['exists'] ? '<a class="fw-semibold text-body" href="/agent/vendor.php?vendor_id=' . $row['vendor_id'] . '">' . $name . '</a>' : '<span class="text-body-secondary fst-italic">' . $name . '</span>';
|
||||
return $row['exists'] ? vendorNameHtml($row['vendor_id'], $row['vendor'], 'fw-semibold text-body', '/agent/') : '<span class="text-body-secondary fst-italic">' . $name . '</span>';
|
||||
}],
|
||||
'category' => ['label' => 'Mostly', 'class' => 'small text-body-secondary'],
|
||||
'count' => ['label' => 'Expenses', 'type' => 'count'],
|
||||
|
||||
@@ -91,7 +91,7 @@ if (!$service || ($client_url && intval($service['service_client_id']) !== intva
|
||||
$certificates = serviceLinked($service_id, 'certificate');
|
||||
$documents = serviceLinked($service_id, 'document');
|
||||
$contacts = serviceLinked($service_id, 'contact');
|
||||
$vendors = serviceLinked($service_id, 'vendor');
|
||||
$vendors = array_map(function ($vendor) { return vendorRedact($vendor, $vendor['id']); }, serviceLinked($service_id, 'vendor'));
|
||||
$archived_credentials = $can_credentials ? array_values(array_filter(serviceLinked($service_id, 'credential'), function ($row) { return $row['archived_at']; })) : [];
|
||||
|
||||
// Who to call - the vendors' and people's details for the call
|
||||
@@ -100,7 +100,7 @@ if (!$service || ($client_url && intval($service['service_client_id']) !== intva
|
||||
$sql = mysqli_query($mysqli, "SELECT vendor_id, vendor_account_number, vendor_code, vendor_email, vendor_website, vendor_hours, vendor_sla FROM vendors
|
||||
WHERE vendor_id IN (" . implode(',', array_map('intval', array_column($vendors, 'id'))) . ")");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$vendor_details[intval($row['vendor_id'])] = $row;
|
||||
$vendor_details[intval($row['vendor_id'])] = vendorRedact($row, $row['vendor_id']);
|
||||
}
|
||||
}
|
||||
$contact_details = [];
|
||||
@@ -132,6 +132,10 @@ if (!$service || ($client_url && intval($service['service_client_id']) !== intva
|
||||
if (!$can_credentials) {
|
||||
unset($service_tabs['logins']);
|
||||
}
|
||||
// Ticketing switched off (Admin > Settings > Modules) - no tickets about it
|
||||
if (!moduleOn('ticketing')) {
|
||||
unset($service_tabs['tickets']);
|
||||
}
|
||||
$unlink_url = function ($to, $other_id) use ($service_id) {
|
||||
return "post.php?unlink_item&from=service&id=$service_id&to=$to&other=" . intval($other_id) . "&csrf_token=" . $_SESSION['csrf_token'];
|
||||
};
|
||||
@@ -184,9 +188,11 @@ if (!$service || ($client_url && intval($service['service_client_id']) !== intva
|
||||
|
||||
<div class="d-flex flex-wrap gap-2 d-print-none">
|
||||
<?php if ($can_edit) { ?>
|
||||
<?php if (isset($service_tabs['tickets'])) { ?>
|
||||
<button type="button" class="btn btn-outline-danger ajax-modal" data-modal-size="lg" data-modal-url="<?= escapeHtml($report_url) ?>">
|
||||
<i class="fas fa-life-ring me-2"></i>Report a Problem
|
||||
</button>
|
||||
<?php } ?>
|
||||
<div class="dropdown">
|
||||
<button type="button" class="btn btn-outline-secondary dropdown-toggle" data-bs-toggle="dropdown"><i class="fas fa-link me-2"></i>Link</button>
|
||||
<div class="dropdown-menu dropdown-menu-end">
|
||||
@@ -592,6 +598,7 @@ if (!$service || ($client_url && intval($service['service_client_id']) !== intva
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<?php if (isset($service_tabs['tickets'])) { ?>
|
||||
<!-- Tickets about it, or about what it runs on -->
|
||||
<div class="tab-pane fade" id="service-pane-tickets" role="tabpanel">
|
||||
<div class="itflow-asset-pane-bar">
|
||||
@@ -623,6 +630,7 @@ if (!$service || ($client_url && intval($service['service_client_id']) !== intva
|
||||
<div class="itflow-asset-empty">No tickets about it or what it runs on.</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<!-- History, from the audit log -->
|
||||
<div class="tab-pane fade" id="service-pane-history" role="tabpanel">
|
||||
|
||||
@@ -387,9 +387,11 @@ $link_icons = ['asset' => ['fa-desktop', 'asset', 'assets'], 'credential' => ['f
|
||||
<i class="fas fa-fw fa-external-link-alt text-secondary me-2"></i>Open in a New Tab
|
||||
</a>
|
||||
<?php if ($can_edit && !$is_archived) { ?>
|
||||
<?php if (moduleOn('ticketing')) { ?>
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-size="lg" data-modal-url="<?= escapeHtml('modals/ticket/ticket_add.php?' . http_build_query(['client_id' => $row_client_id, 'service_id' => $service_id])) ?>">
|
||||
<i class="fas fa-fw fa-life-ring text-secondary me-2"></i>Report a Problem
|
||||
</a>
|
||||
<?php } ?>
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-size="lg" data-modal-url="modals/service/service_edit.php?id=<?= $service_id ?>">
|
||||
<i class="fas fa-fw fa-edit text-secondary me-2"></i>Edit
|
||||
</a>
|
||||
|
||||
@@ -245,7 +245,7 @@ $provider = smsProvider();
|
||||
<div class="text-body-secondary"><?= escapeHtml(date('M j, g:i A', strtotime($row['sms_message_created_at']))) ?></div>
|
||||
</td>
|
||||
<td class="text-end pe-3 text-nowrap">
|
||||
<?php if ($show === 'unmatched' && $can_work) { ?>
|
||||
<?php if ($show === 'unmatched' && $can_work && moduleOn('ticketing')) { ?>
|
||||
<button type="button" class="btn btn-sm btn-primary ajax-modal" data-modal-url="modals/sms/sms_ticket_open.php?id=<?= $message_id ?>"><i class="fas fa-fw fa-life-ring me-1"></i><span class="d-none d-sm-inline">Open Ticket</span></button>
|
||||
<?php } ?>
|
||||
<?php if (($show !== 'codes' && $can_work) || ($codes && $can_codes)) { ?>
|
||||
|
||||
@@ -21,11 +21,18 @@ require_once "../libs/htmlpurifier/HTMLPurifier.standalone.php";
|
||||
|
||||
$purifier_config = HTMLPurifier_Config::createDefault();
|
||||
$purifier_config->set('Cache.DefinitionImpl', null); // Disable cache by setting a non-existent directory or an invalid one
|
||||
$purifier_config->set('URI.AllowedSchemes', ['data' => true, 'src' => true, 'http' => true, 'https' => true]);
|
||||
$purifier_config->set('URI.AllowedSchemes', purifierUriSchemes());
|
||||
// Classes our scripts act on (ajax-modal fetches a page and runs it) never come from stored HTML
|
||||
$purifier_config->set('Attr.ForbiddenClasses', ['ajax-modal']);
|
||||
$purifier = new HTMLPurifier($purifier_config);
|
||||
|
||||
// No ticket asked for: as for one that isn't there - the page's scripts below need a ticket
|
||||
if (!isset($_GET['ticket_id'])) {
|
||||
echo "<center><h1 class='text-secondary mt-5'>Nothing to see here</h1><a class='btn btn-lg btn-secondary mt-3' href='tickets.php'><i class='fas fa-fw fa-arrow-left'></i> Go Back</a></center>";
|
||||
require_once "../includes/footer.php";
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_GET['ticket_id'])) {
|
||||
$ticket_id = intval($_GET['ticket_id']);
|
||||
|
||||
@@ -56,6 +63,8 @@ if (isset($_GET['ticket_id'])) {
|
||||
} else {
|
||||
|
||||
$ticket = mysqli_fetch_assoc($sql);
|
||||
// A case with one of our vendors, to an agent the Vendors permission keeps out - its name only
|
||||
$ticket = $ticket ? vendorRedact($ticket, $ticket['ticket_vendor_id']) : $ticket;
|
||||
|
||||
// Seen - no longer in bold on this agent's tickets list (functions/ticket_read.php)
|
||||
ticketMarkRead($ticket_id, $session_user_id);
|
||||
@@ -316,11 +325,12 @@ if (isset($_GET['ticket_id'])) {
|
||||
$sql_ticket_ccs = mysqli_query($mysqli, "SELECT ticket_cc_email, ticket_cc_id FROM ticket_ccs WHERE ticket_cc_ticket_id = $ticket_id ORDER BY ticket_cc_email DESC");
|
||||
$cc_count = mysqli_num_rows($sql_ticket_ccs);
|
||||
|
||||
// Get Additional Assets
|
||||
// Its assets besides its main one, by name
|
||||
$sql_additional_assets = mysqli_query($mysqli, "SELECT assets.asset_id, asset_name, asset_type FROM assets, ticket_assets
|
||||
WHERE assets.asset_id = ticket_assets.asset_id
|
||||
AND ticket_id = $ticket_id
|
||||
AND assets.asset_id != $asset_id"
|
||||
AND assets.asset_id != $asset_id
|
||||
ORDER BY asset_name ASC"
|
||||
);
|
||||
|
||||
// Get Tasks
|
||||
@@ -1883,9 +1893,13 @@ if (isset($_GET['ticket_id'])) {
|
||||
-->
|
||||
<?php
|
||||
$can_link = $can_edit_ticket && !$ticket_is_closed;
|
||||
// Its assets and services are IT documentation - not shown while that is switched off (Admin > Settings > Modules)
|
||||
$ticket_itdoc = moduleOn('itdoc');
|
||||
// Its main asset first, then the others - all one list, each can be taken off
|
||||
$ticket_asset_shown = $ticket_itdoc && ($asset_id || mysqli_num_rows($sql_additional_assets));
|
||||
// The services it is about - raised for them, or through its assets
|
||||
$ticket_services = $client_id ? ticketServices($ticket_id) : [];
|
||||
$has_links = $asset_id || $vendor_id || $project_id || $cc_count || $ticket_services;
|
||||
$ticket_services = $client_id && $ticket_itdoc ? ticketServices($ticket_id) : [];
|
||||
$has_links = $ticket_asset_shown || $vendor_id || $project_id || $cc_count || $ticket_services;
|
||||
if ($has_links || $can_link) { ?>
|
||||
<div class="card mb-3">
|
||||
<div class="card-header px-3 py-2">
|
||||
@@ -1898,16 +1912,18 @@ if (isset($_GET['ticket_id'])) {
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
<?php if ($client_id) { ?>
|
||||
<?php if ($ticket_itdoc) { ?>
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-url="modals/ticket/ticket_edit_asset.php?id=<?= $ticket_id ?>">
|
||||
<i class="fas fa-fw fa-desktop me-2"></i><?= $asset_id ? 'Change assets' : 'Add asset' ?>
|
||||
<i class="fas fa-fw fa-desktop me-2"></i><?= $ticket_asset_shown ? 'Change assets' : 'Add assets' ?>
|
||||
</a>
|
||||
<?php } ?>
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-url="modals/ticket/ticket_edit_vendor.php?ticket_id=<?= $ticket_id ?>">
|
||||
<i class="fas fa-fw fa-building me-2"></i><?= $vendor_id ? 'Change vendor' : 'Add vendor' ?>
|
||||
</a>
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-url="modals/ticket/ticket_edit_project.php?id=<?= $ticket_id ?>">
|
||||
<i class="fas fa-fw fa-project-diagram me-2"></i><?= $project_id ? 'Change project' : 'Add to a project' ?>
|
||||
</a>
|
||||
<?= linkPickerButton('ticket', $ticket_id, 'service', 'Link a service', 'dropdown-item', 'fas fa-fw fa-stream me-2') ?>
|
||||
<?php if ($ticket_itdoc) { ?><?= linkPickerButton('ticket', $ticket_id, 'service', 'Link a service', 'dropdown-item', 'fas fa-fw fa-stream me-2') ?><?php } ?>
|
||||
<div class="dropdown-divider"></div>
|
||||
<?php } ?>
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-url="modals/ticket/ticket_add_cc.php?ticket_id=<?= $ticket_id ?>">
|
||||
@@ -1924,16 +1940,23 @@ if (isset($_GET['ticket_id'])) {
|
||||
<div class="card-body p-3">
|
||||
|
||||
<?php if (!$has_links) { ?>
|
||||
<div class="text-body-secondary small">Nothing linked yet. Use <i class="fas fa-fw fa-plus"></i> to add an asset, vendor, project, service or CC.</div>
|
||||
<div class="text-body-secondary small">Nothing linked yet. Use <i class="fas fa-fw fa-plus"></i> to add <?= $ticket_itdoc ? 'an asset, vendor, project, service or CC' : 'a vendor, project or CC' ?>.</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($asset_id) { ?>
|
||||
<?php if ($ticket_asset_shown) { ?>
|
||||
<div class="ticket-link-heading">Assets</div>
|
||||
<div class="mt-1 text-truncate">
|
||||
<a class="ajax-modal" href="#" data-modal-size="lg" data-modal-url="modals/asset/asset.php?<?= $client_url ?>&id=<?= $asset_id ?>" title="<?= $asset_name ?>">
|
||||
<i class="fas fa-fw fa-<?= $asset_icon ?> text-secondary me-2"></i><?= $asset_name ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php if ($asset_id) { ?>
|
||||
<div class="mt-1 d-flex align-items-center">
|
||||
<a class="ajax-modal text-truncate flex-grow-1" href="#" data-modal-size="lg" data-modal-url="modals/asset/asset.php?<?= $client_url ?>&id=<?= $asset_id ?>" title="<?= $asset_name ?>">
|
||||
<i class="fas fa-fw fa-<?= $asset_icon ?> text-secondary me-2"></i><?= $asset_name ?>
|
||||
</a>
|
||||
<?php if ($can_link) { ?>
|
||||
<a class="confirm-link ms-2" href="post.php?remove_ticket_asset=<?= $asset_id ?>&ticket_id=<?= $ticket_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>" title="Remove from this ticket">
|
||||
<i class="fas fa-fw fa-times text-secondary"></i>
|
||||
</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php while ($additional_asset_row = mysqli_fetch_assoc($sql_additional_assets)) {
|
||||
$additional_asset_id = intval($additional_asset_row['asset_id']);
|
||||
$additional_asset_name = escapeHtml($additional_asset_row['asset_name']);
|
||||
@@ -1944,7 +1967,7 @@ if (isset($_GET['ticket_id'])) {
|
||||
<i class="fas fa-fw fa-<?= $additional_asset_icon ?> text-secondary me-2"></i><?= $additional_asset_name ?>
|
||||
</a>
|
||||
<?php if ($can_link) { ?>
|
||||
<a class="confirm-link ms-2" href="post.php?delete_ticket_additional_asset=<?= $additional_asset_id ?>&ticket_id=<?= $ticket_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>" title="Remove from this ticket">
|
||||
<a class="confirm-link ms-2" href="post.php?remove_ticket_asset=<?= $additional_asset_id ?>&ticket_id=<?= $ticket_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>" title="Remove from this ticket">
|
||||
<i class="fas fa-fw fa-times text-secondary"></i>
|
||||
</a>
|
||||
<?php } ?>
|
||||
@@ -1960,7 +1983,7 @@ if (isset($_GET['ticket_id'])) {
|
||||
$vendor_website_url = vendorWebsiteUrl($ticket['vendor_website']);
|
||||
$vendor_when = escapeHtml(implode(' · ', array_filter([$ticket['vendor_hours'], $ticket['vendor_sla']])));
|
||||
?>
|
||||
<div class="ticket-link-heading <?= $asset_id ? 'mt-3 pt-2 border-top' : '' ?>">Vendor</div>
|
||||
<div class="ticket-link-heading <?= $ticket_asset_shown ? 'mt-3 pt-2 border-top' : '' ?>">Vendor</div>
|
||||
<div class="mt-1 d-flex min-w-0">
|
||||
<?= vendorLink($vendor_id, $ticket['vendor_name'], ['archived' => !empty($ticket['vendor_archived_at'])]) ?>
|
||||
</div>
|
||||
@@ -1994,7 +2017,7 @@ if (isset($_GET['ticket_id'])) {
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($project_id) { ?>
|
||||
<div class="ticket-link-heading <?= ($asset_id || $vendor_id) ? 'mt-3 pt-2 border-top' : '' ?>">Project</div>
|
||||
<div class="ticket-link-heading <?= ($ticket_asset_shown || $vendor_id) ? 'mt-3 pt-2 border-top' : '' ?>">Project</div>
|
||||
<div class="mt-1 d-flex align-items-center gap-1 min-w-0">
|
||||
<a class="text-truncate" href="<?= $project_url ?>" title="<?= $project_name ?>"><i class="fas fa-fw fa-project-diagram text-secondary me-2"></i><?= $project_name ?></a>
|
||||
<a class="ajax-modal ms-auto text-body-secondary" href="#" data-modal-size="lg" data-modal-url="modals/project/project.php?id=<?= $project_id ?>" title="Quick look"><i class="fas fa-fw fa-eye"></i></a>
|
||||
@@ -2008,7 +2031,7 @@ if (isset($_GET['ticket_id'])) {
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($ticket_services) { ?>
|
||||
<div class="ticket-link-heading <?= ($asset_id || $vendor_id || $project_id) ? 'mt-3 pt-2 border-top' : '' ?>">Services</div>
|
||||
<div class="ticket-link-heading <?= ($ticket_asset_shown || $vendor_id || $project_id) ? 'mt-3 pt-2 border-top' : '' ?>">Services</div>
|
||||
<?php foreach ($ticket_services as $ticket_service) {
|
||||
$ticket_service_id = intval($ticket_service['service_id']); ?>
|
||||
<div class="mt-1 d-flex align-items-center gap-1 min-w-0">
|
||||
@@ -2026,7 +2049,7 @@ if (isset($_GET['ticket_id'])) {
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($cc_count) { ?>
|
||||
<div class="ticket-link-heading <?= ($asset_id || $vendor_id || $project_id || $ticket_services) ? 'mt-3 pt-2 border-top' : '' ?>">
|
||||
<div class="ticket-link-heading <?= ($ticket_asset_shown || $vendor_id || $project_id || $ticket_services) ? 'mt-3 pt-2 border-top' : '' ?>">
|
||||
CC <span class="text-body-secondary text-lowercase fw-normal">· copied in on its emails</span>
|
||||
</div>
|
||||
<?php while ($cc_row = mysqli_fetch_assoc($sql_ticket_ccs)) {
|
||||
|
||||
@@ -188,6 +188,7 @@ if ($q !== '') {
|
||||
$filter_sql[] = "AND (CONCAT(ticket_prefix, ticket_number) LIKE '%$q%' OR ticket_subject LIKE '%$q%' OR client_name LIKE '%$q%'
|
||||
OR contact_name LIKE '%$q%' OR contact_email LIKE '%$q%'" . contactEmailAltLikeSql($q) . " OR ticket_status_name LIKE '%$q%' OR ticket_priority LIKE '%$q%'
|
||||
OR user_name LIKE '%$q%' OR asset_name LIKE '%$q%' OR vendor_name LIKE '%$q%' OR ticket_vendor_ticket_number LIKE '%$q%' OR category_name LIKE '%$q%'
|
||||
OR tickets.ticket_id IN (SELECT ticket_assets.ticket_id FROM ticket_assets JOIN assets AS searched_assets ON searched_assets.asset_id = ticket_assets.asset_id WHERE searched_assets.asset_name LIKE '%$q%')
|
||||
" . tagSearchSql('ticket', $q, 'tickets.ticket_id') . ")";
|
||||
}
|
||||
|
||||
@@ -210,7 +211,8 @@ $shows = [
|
||||
'title' => 'We replied last and it is with the client - or it is parked in a status that pauses the clock, like On Hold'],
|
||||
'overdue' => ['label' => 'Overdue', 'icon' => 'fa-stopwatch', 'where' => ticketOverdueSql(), 'alarm' => 'danger',
|
||||
'title' => 'Past its due date, or its SLA is breached'],
|
||||
'scheduled' => ['label' => 'Scheduled', 'icon' => 'fa-calendar-check', 'where' => "$open_sql AND ticket_schedule IS NOT NULL",
|
||||
// booked, not scheduled - a web application firewall takes a value starting sched for the Unix command
|
||||
'booked' => ['label' => 'Scheduled', 'icon' => 'fa-calendar-check', 'where' => "$open_sql AND ticket_schedule IS NOT NULL",
|
||||
'title' => 'A visit or call is booked'],
|
||||
];
|
||||
// Mentioned me - open tickets with an internal note that @mentions you (functions/ticket_mention.php), after Mine
|
||||
@@ -230,6 +232,9 @@ $shows = projectTicketsShows($shows, $base_sql, $project_filter);
|
||||
|
||||
// A status or billing filter asked for on its own looks at every ticket - unbilled work is nearly all done already
|
||||
$show = $_GET['show'] ?? '';
|
||||
if ($show === 'scheduled') {
|
||||
$show = 'booked'; // its name from before
|
||||
}
|
||||
if (!isset($shows[$show])) {
|
||||
$show = ($view === 'list' && !isset($_GET['show']) && ($status_filter || $billing_filter)) ? 'all' : 'open';
|
||||
}
|
||||
|
||||
@@ -348,7 +348,7 @@ $add_url = 'modals/trip/trip_add.php' . ($client_page ? "?client_id=$client_id"
|
||||
</div>
|
||||
<div class="small text-body-secondary text-truncate" title="<?= escapeHtml($row['trip_purpose']) ?>">
|
||||
<?php if (intval($row['trip_ticket_id']) && $row['ticket_number'] !== null) { ?>
|
||||
<a class="font-monospace" href="<?= escapeHtml(ticketUrl($row['trip_ticket_id'], $row['trip_client_id'])) ?>" title="<?= escapeHtml($row['ticket_subject']) ?>"><?= escapeHtml(ticketReference($row)) ?></a> ·
|
||||
<?= moduleLink('ticketing', escapeHtml(ticketUrl($row['trip_ticket_id'], $row['trip_client_id'])), escapeHtml(ticketReference($row)), 'class="font-monospace" title="' . escapeHtml($row['ticket_subject']) . '"') ?> ·
|
||||
<?php } ?>
|
||||
<?= escapeHtml($row['trip_purpose']) ?>
|
||||
</div>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user