diff --git a/CHANGELOG.md b/CHANGELOG.md index 46e3501ec..e06b886de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ This file documents all notable changes made to ITFlow. ### Upgrading -Update from Maintenance > Update — Queue Update hands the job to cron, which updates the files and applies this release's thirteen database changes (3.6.6 to 3.7.9) in the same pass. They add four tables for RMM providers and their alerts, a setting for device actions and one for API keys in the address, a column marking the emails the mail queue clears once sent, a column and a table for agent banners, two columns for ticket statuses with a setting for the "ticket assigned" message, a column on tickets with a setting for the "no response" message, a table for who a ticket's email replies go to, the settings for Quick tickets, columns on recurring tickets and recurring invoices for booking and making them ahead, two columns on ticket replies for when their time was worked, and the settings for cron alerts, and change nothing that is there. Nothing else is required. This release has eleven security fixes - see Security. On Apache, ITFlow's own .htaccess now sends security headers: if you show ITFlow inside a frame on another website, it will now refuse to load there. On nginx, add the same headers to your server block if you want them - see Developer Updates. +Update from Maintenance > Update — Queue Update hands the job to cron, which updates the files and applies this release's fourteen database changes (3.6.6 to 3.8.0) in the same pass. They add four tables for RMM providers and their alerts, a setting for device actions and one for API keys in the address, a column marking the emails the mail queue clears once sent, a column and a table for agent banners, two columns for ticket statuses with a setting for the "ticket assigned" message, a column on tickets with a setting for the "no response" message, a table for who a ticket's email replies go to, the settings for Quick tickets, columns on recurring tickets and recurring invoices for booking and making them ahead, two columns on ticket replies for when their time was worked, the settings for cron alerts, and a table and a setting for labor costs, and change nothing that is there. Nothing else is required. This release has eleven security fixes - see Security. On Apache, ITFlow's own .htaccess now sends security headers: if you show ITFlow inside a frame on another website, it will now refuse to load there. On nginx, add the same headers to your server block if you want them - see Developer Updates. ### Security @@ -93,6 +93,8 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u - Maintenance > Cron: an email can't say cron has stopped, since cron sends it. The Alerts card has a private health address for an uptime monitor such as Uptime Kuma or UptimeRobot: it answers OK while all is well and an error when cron isn't running or a job is in trouble. Check it every 5 minutes. Make a new address if the old one gets out. From Mountaineer IT's build of ITFlow. - Development mode, for a test copy of your ITFlow: turn it on in Admin > Backup before you restore production's backup onto a test server, and nothing reaches your clients, your team or the systems production talks to. Every email goes to a test inbox you give, with who it was for at the front of its subject. Texts wait in the queue, the ticket mailbox isn't read, AI Triage doesn't run, Stripe charges nothing (autopay included), nothing is done to RMM devices, log entries aren't sent to your syslog server, a managed ITFlow doesn't check in with its manager, and telemetry isn't sent. A red DEVELOPMENT badge shows in the top bar for everyone. It's kept in config.php rather than the database, so a restore can't turn it off. Never turn it on in production. From Mountaineer IT's build of ITFlow. - Maintenance > Backup: restore a backup from the page - Restore in a backup's menu, or upload one under Restoring, from another ITFlow say, with its key. An upload of up to 5 GB goes up in pieces, joins the list as Uploaded and opens its Restore window. That window says what's in the backup and refuses one from a newer version, and you confirm with your password and by typing RESTORE. Cron does it within a minute: ITFlow backs itself up first, kept as Before restore so the restore can be undone, then restores the backup and brings its database up to this version. The top of the page shows it waiting (with Cancel), running, and how it went. The command line restore is still under Restoring, for a backup of any size. From Mountaineer IT's build of ITFlow. +- Admin > Labor Costs, under Lists: what an hour of each agent costs your company - wage, payroll taxes and benefits - with the date each rate counts from, so a raise doesn't change what last year cost, and a company default for agents with none. Only admins see it, and the audit log never records the amounts. From Mountaineer IT's build of ITFlow. +- Reports: Client Profitability, with labor costs set, shows each client's labor cost (their hours at the cost of the agent who worked them), parts cost (the products on their invoices, at cost), profit and margin, and for flat monthly fees the hours a month their fee pays for against the hours they take, marked Over when they take more. The totals along the top add labor, parts, profit, and how many clients lose money or go over. Paid and Invoiced switch income between money received, as before, and sales before tax on invoices dated in the period. Hours by agents with no cost and no default are flagged. From Mountaineer IT's build of ITFlow. ### Bug Fixes @@ -213,6 +215,7 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u - Database 3.7.9: `config_cron_alert_email` (default 1), `config_cron_alert_to`, `config_cron_health_key` and `config_cron_alert_state` (JSON: `sent`, each problem's key and when it was last emailed; `waiting`, each job that is on and has never run and since when) - `cronHealthReady()`. `functions/cron_health.php`: `cronHealthProblems()` reads the heartbeat, `config_enable_cron` and each enabled registry job's row (not those a manager has paused) into problems with a key, kind (`not_running`, `off`, `failed`, `stuck` after `CRON_HEALTH_STUCK_MINUTES`, `overdue` - past two intervals and at least ten minutes over, or two hours past a daily time; a job never run is late once `waiting` is older than that), text and error. `includes/top_nav.php` shows them to admins as `#itflowCronHealth`. `cron/cron_watch.php` is the `cron_watch` job, every 5 minutes: `cronHealthWatch()` records `waiting`, then emails the problems that are new, a day old or gone with `cronHealthAlert()` through `cronHealthMail()` (`emailQueue()`, to `config_cron_alert_to`, else active admins - `cronHealthRecipients()`), leaving out `not_running` and its own; Admin > Mail previews it as `cron_alert`. `health.php` answers 200 `OK` or 503 with a line per problem, given `config_cron_health_key` as `?key=` or an `X-Health-Key` header, and 403 otherwise. `admin/post/cron.php` has `edit_cron_alerts`, `test_cron_alert` (to the addresses typed) and `renew_cron_health_key`, locked in the demo. From Mountaineer IT's build of ITFlow. - Development mode (`functions/dev_mode.php`): `$config_dev_mode` and `$config_dev_mail_to` in config.php - `devModeOn()`, `devModeMailTo()`. `edit_dev_mode` (`admin/post/backup.php`, locked in the demo) writes both with `devModeConfigSet()`, which replaces each line or adds them at the end and invalidates opcache; when config.php can't be written, Admin > Backup shows the lines to add. `sendQueueEmail()` (`cron/mail_queue.php`) sends to `devModeMailTo()` with `[DEV to ]` in front of the subject, and with no test inbox the queue is cancelled as in the demo. `includes/stripe_init.php` calls `devModeBlockStripe()`, a `\Stripe\ApiRequestor::setHttpClient()` client that throws `ApiConnectionException`. `smsSendQueued()` leaves a text queued, `rmmDeviceAct()` refuses, `managedHttpJson()` answers not ok, and `logForwardQueue()` and `logForwardSend()` send nothing. `cron/ticket_email_parser.php`, `ai_triage.php`, `sms_queue.php`, `payment_provider_fees.php`, `manager_checkin.php` and `managed_instances.php` stop with `cronJobStop("Development mode - ...")`; `cron/nightly_tasks.php` skips autopay and telemetry. `includes/top_nav.php` shows `[data-dev-mode]`, a link to `admin/backup.php#dev-mode` for admins. From Mountaineer IT's build of ITFlow. - Restoring from Maintenance > Backup (`functions/backup_restore.php`): `restore_backup` (`admin/post/backup.php`) checks the password and RESTORE, then `backupRestoreQueue()` checks the archive with `backupRestoreCheck()` (`backupInspectArchive()`, refused when its database version is newer) and the disk (three times its size), writes `restore_queued.json` beside the backups - another install's key sealed with this one's (`backupRestoreSealKey()`, AES-256-GCM) - and `restore_status.json`, and sets the Backup job's `cron_job_run_now`. `cron/backup.php` calls `backupRestoreRunQueued()` after the queued backups: it deletes the request first, refuses one older than `BACKUP_RESTORE_WAIT_MINUTES`, makes a Full Backup with source `Before restore`, runs `backupRestoreArchive()`, puts that row and the restored one back in the restored `backups` (others found again by retention), marks `Running` and `Pending` rows `Failed`, runs `scripts/update_cli.php --update_db`, records the outcome and sets `$cron_dispatch_stop_cycle`. `cron/cron.php` exits before its heartbeat while `backupRestoreInProgress()`. `cancel_restore` removes a request. Uploads: `backup_upload` in one request, or `backup_upload_start`, `backup_upload_chunk` and `backup_upload_finish` from `js/backup_restore.js` (JSON, the upload in the session, pieces of `backupRestoreChunkBytes()` appended to `upload_.part`, retried smaller when a proxy refuses), then `backupRestoreAdopt()` lists it with source `Uploaded`. The Restore window is `admin/modals/backup/backup_restore.php`, opened from a row's menu or by `?restore=`; `backupMadeBy()` words a row's source. All locked in the demo. From Mountaineer IT's build of ITFlow. +- Database 3.8.0: `user_cost_rates` (`user_cost_rate_user_id`, `_from`, `_hourly`, `_created_by`, `_created_at`, one a day per agent) and `config_labor_cost_default` (NULL leaves time uncosted) - `laborCostReady()`. `functions/labor_cost.php`: `laborCostRates()`, `laborCostRateOn()` (the newest rate on or before the day, the first also before it, else the default), `laborCostRateSave()`, `laborCostRateDelete()`, `laborCostParse()`. `admin/labor_costs.php`, `admin/modals/labor_cost/labor_cost_rates.php` and `labor_cost_default.php`, handlers `add_labor_cost_rate`, `delete_labor_cost_rate` and `edit_labor_cost_default` (`admin/post/labor_cost.php`). `agent/reports/client_profitability.php` calls `laborProfitAdd()` before net - `?basis=invoiced` replaces income with `item_subtotal` less `invoice_discount_amount` on Sent, Viewed, Partial and Paid invoices by `invoice_date`, plus revenue; labor by `ticket_reply_by` and day; parts as `product_cost * item_quantity` - and `laborProfitFinish()` after it for profit, margin, `hours_month` and `break_even`; the columns, totals, basis switch (`laborProfitBasis()`, paid by default) and second stats row are there only with 3.8.0. From Mountaineer IT's build of ITFlow. ## [26.11.8] diff --git a/admin/database_updates/3.8.0.php b/admin/database_updates/3.8.0.php new file mode 100644 index 000000000..86ed3cb3b --- /dev/null +++ b/admin/database_updates/3.8.0.php @@ -0,0 +1,38 @@ + 0; + }; + + mysqli_query($mysqli, "CREATE TABLE IF NOT EXISTS `user_cost_rates` ( + `user_cost_rate_id` int(11) NOT NULL AUTO_INCREMENT, + `user_cost_rate_user_id` int(11) NOT NULL, + `user_cost_rate_from` date NOT NULL, + `user_cost_rate_hourly` decimal(15,2) NOT NULL DEFAULT 0.00, + `user_cost_rate_created_by` int(11) NOT NULL DEFAULT 0, + `user_cost_rate_created_at` datetime NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`user_cost_rate_id`), + UNIQUE KEY `user_cost_rate_user_from` (`user_cost_rate_user_id`, `user_cost_rate_from`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"); + + if (!$itflow_column('settings', 'config_labor_cost_default')) { + mysqli_query($mysqli, "ALTER TABLE `settings` ADD `config_labor_cost_default` decimal(15,2) DEFAULT NULL AFTER `config_default_hourly_rate`"); + } diff --git a/admin/includes/side_nav.php b/admin/includes/side_nav.php index f8e130818..e89bdbedf 100644 --- a/admin/includes/side_nav.php +++ b/admin/includes/side_nav.php @@ -86,6 +86,12 @@

Payment Methods

+