Files
itflow/admin/database_updates/3.2.7.php
johnnyq 32b5288338 Document templates stage 3, the client standard and reviews: a template can be required of every client or of clients with chosen tags (leads and archived clients not counted, a template whose tags are all deleted applying to none rather than every client), with the template page showing how many clients have one with a bar and the clients missing it each with a Make button, and Admin > Document Templates showing the count on each template plus a new Required tab; documents can be made for several clients at once, one per client filled in from its own client, for a picked list or every missing client in one click, with fill-ins answered once for all and clients that already have one skipped unless unticked; a client's Files shows the documents it should have along the top opening Document from template with that template picked, the client overview shows a Documents missing count, and Document from template lists missing templates first; a template can ask for its documents to be reviewed every 3 or 6 months, yearly or every 2 years, a document falling due when not edited or marked reviewed for that long, with the document page showing Review due or the next review and who did the last one plus a Mark reviewed button, a Review due tab in Files listing due documents across every folder, and due counts on the client overview, the template page and the list, documents from archived templates not counted; an older document written before its template can be linked to it from its page so it counts and follows the template's review schedule; migration 3.2.7; fixed tag merges dropping merged tags from ticket templates (merges now carry over ticket template and required template tags) and deleting a document template marking all its documents as updated; changelog updated
2026-10-18 19:49:20 -04:00

30 lines
1.6 KiB
PHP

<?php
/*
* ITFlow - Database update to version 3.2.7 (from 3.2.6)
* Included by admin/database_updates.php - do not access directly
*/
defined('FROM_DB_UPDATER') || die("Direct file access is not allowed");
// Who should have a document from a template - 0 no one in particular, 1
// every client, 2 the clients with one of its tags - and how often the
// documents made from it are reviewed, in months (0 never)
mysqli_query($mysqli, "ALTER TABLE `document_templates`
ADD `document_template_required` tinyint(1) NOT NULL DEFAULT 0 AFTER `document_template_content`,
ADD `document_template_review_months` int(11) NOT NULL DEFAULT 0 AFTER `document_template_required`");
mysqli_query($mysqli, "CREATE TABLE `document_template_required_tags` (
`document_template_id` int(11) NOT NULL,
`tag_id` int(11) NOT NULL,
PRIMARY KEY (`document_template_id`,`tag_id`),
KEY `tag_id` (`tag_id`),
CONSTRAINT `document_template_required_tags_ibfk_1` FOREIGN KEY (`document_template_id`) REFERENCES `document_templates` (`document_template_id`) ON DELETE CASCADE,
CONSTRAINT `document_template_required_tags_ibfk_2` FOREIGN KEY (`tag_id`) REFERENCES `tags` (`tag_id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci");
// When a document was last marked as reviewed, and by whom - an edit counts as a review too
mysqli_query($mysqli, "ALTER TABLE `documents`
ADD `document_reviewed_at` datetime DEFAULT NULL AFTER `document_accessed_at`,
ADD `document_reviewed_by` int(11) NOT NULL DEFAULT 0 AFTER `document_updated_by`");