mirror of
https://github.com/itflow-org/itflow
synced 2026-11-17 01:47:25 +00:00
Vendor templates stage 2: keep client vendors in step with the template they were made from - saving a template updates the fields its vendors still shared, the template window gets the vendor window's tabs, a template page shows each client vendor as in step or the fields it differs in with Bring in line, Link and Unlink, lists hand-made vendors that look like it to link, and sets who should have it (no one, every client or clients with chosen tags) with coverage and Add to clients for those missing; the list gains Required and Out of step tabs, a client vendor shows its differences with Update from template, a client's Vendors list and overview show vendors missing, Add to clients no longer skips a client whose vendor from the template was archived, and database 3.3.5 adds vendor_template_required, vendor_template_required_tags and a vendor_template_id key on vendors
This commit is contained in:
37
admin/database_updates/3.3.5.php
Normal file
37
admin/database_updates/3.3.5.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* ITFlow - Database update to version 3.3.5 (from 3.3.4)
|
||||
* 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 vendor from a vendor template (functions/vendor_template.php).
|
||||
//
|
||||
// 1. No one in particular (0), every client (1), or the clients with one of
|
||||
// its client tags (2). Checked first, so the step can run again.
|
||||
$itflow_column = mysqli_query($mysqli, "SELECT 1 FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'vendor_templates' AND COLUMN_NAME = 'vendor_template_required' LIMIT 1");
|
||||
if (!$itflow_column || mysqli_num_rows($itflow_column) === 0) {
|
||||
mysqli_query($mysqli, "ALTER TABLE `vendor_templates` ADD `vendor_template_required` tinyint(1) NOT NULL DEFAULT 0 AFTER `vendor_template_notes`");
|
||||
}
|
||||
|
||||
// 2. ...and those tags.
|
||||
mysqli_query($mysqli, "CREATE TABLE IF NOT EXISTS `vendor_template_required_tags` (
|
||||
`vendor_template_id` int(11) NOT NULL,
|
||||
`tag_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`vendor_template_id`, `tag_id`),
|
||||
KEY `tag_id` (`tag_id`),
|
||||
CONSTRAINT `vendor_template_required_tags_ibfk_1` FOREIGN KEY (`vendor_template_id`) REFERENCES `vendor_templates` (`vendor_template_id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `vendor_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");
|
||||
|
||||
// 3. A client's vendors are looked up by the template they came from.
|
||||
$itflow_index = mysqli_query($mysqli, "SELECT 1 FROM information_schema.STATISTICS
|
||||
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'vendors' AND INDEX_NAME = 'vendor_template_id' LIMIT 1");
|
||||
if (!$itflow_index || mysqli_num_rows($itflow_index) === 0) {
|
||||
mysqli_query($mysqli, "ALTER TABLE `vendors` ADD KEY `vendor_template_id` (`vendor_template_id`, `vendor_client_id`)");
|
||||
}
|
||||
|
||||
unset($itflow_column, $itflow_index);
|
||||
Reference in New Issue
Block a user