print "Upgrade to $DBversion done (Bug 21417 - EDI ordering fails when basket and EAN libraries do not match)\n";
}
+$DBversion = '18.06.00.039';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{
+ INSERT IGNORE INTO `permissions` (module_bit, code, description) VALUES(3, 'manage_circ_rules_from_any_libraries', 'Manage circ rules for any libraries');
+ });
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 15520 - Add more granular permission for only editing own library's circ rules)\n";
+}
+
+$DBversion = '18.06.00.040';
+if( CheckVersion( $DBversion ) ) {
+ # Stock Rotation Rotas
+ unless (TableExists('stockrotationrotas')){
+ $dbh->do(q{
+ CREATE TABLE `stockrotationrotas` (
+ `rota_id` int(11) auto_increment, -- Stockrotation rota ID
+ `title` varchar(100) NOT NULL, -- Title for this rota
+ `description` text NOT NULL default '', -- Description for this rota
+ `cyclical` tinyint(1) NOT NULL default 0, -- Should items on this rota keep cycling?
+ `active` tinyint(1) NOT NULL default 0, -- Is this rota currently active?
+ PRIMARY KEY (`rota_id`),
+ CONSTRAINT `stockrotationrotas_title`
+ UNIQUE (`title`)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+ });
+ }
+ # Stock Rotation Stages
+ unless (TableExists('stockrotationstages')){
+ $dbh->do(q{
+ CREATE TABLE `stockrotationstages` (
+ `stage_id` int(11) auto_increment, -- Unique stage ID
+ `position` int(11) NOT NULL, -- The position of this stage within its rota
+ `rota_id` int(11) NOT NULL, -- The rota this stage belongs to
+ `branchcode_id` varchar(10) NOT NULL, -- Branch this stage relates to
+ `duration` int(11) NOT NULL default 4, -- The number of days items shoud occupy this stage
+ PRIMARY KEY (`stage_id`),
+ CONSTRAINT `stockrotationstages_rifk`
+ FOREIGN KEY (`rota_id`)
+ REFERENCES `stockrotationrotas` (`rota_id`)
+ ON UPDATE CASCADE ON DELETE CASCADE,
+ CONSTRAINT `stockrotationstages_bifk`
+ FOREIGN KEY (`branchcode_id`)
+ REFERENCES `branches` (`branchcode`)
+ ON UPDATE CASCADE ON DELETE CASCADE
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+ });
+ }
+ # Stock Rotation Items
+ unless (TableExists('stockrotationitems')){
+ $dbh->do(q{
+ CREATE TABLE `stockrotationitems` (
+ `itemnumber_id` int(11) NOT NULL, -- Itemnumber to link to a stage & rota
+ `stage_id` int(11) NOT NULL, -- stage ID to link the item to
+ `indemand` tinyint(1) NOT NULL default 0, -- Should this item be skipped for rotation?
+ `fresh` tinyint(1) NOT NULL default 0, -- Flag showing item is only just added to rota
+ PRIMARY KEY (itemnumber_id),
+ CONSTRAINT `stockrotationitems_iifk`
+ FOREIGN KEY (`itemnumber_id`)
+ REFERENCES `items` (`itemnumber`)
+ ON UPDATE CASCADE ON DELETE CASCADE,
+ CONSTRAINT `stockrotationitems_sifk`
+ FOREIGN KEY (`stage_id`)
+ REFERENCES `stockrotationstages` (`stage_id`)
+ ON UPDATE CASCADE ON DELETE CASCADE
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+ });
+ }
+ # System preferences
+ $dbh->do(q{
+ INSERT IGNORE INTO `systempreferences` (`variable`,`value`,`explanation`,`options`,`type`)
+ VALUES ('StockRotation','0','If ON, enables the stock rotation module','','YesNo'),
+ ('RotationPreventTransfers','0','If ON, prevent any transfers for items on stock rotation rotas, except for stock rotation transfers','','YesNo');
+ });
+ # Permissions
+ $dbh->do(q{
+ INSERT IGNORE INTO `userflags` (`bit`, `flag`, `flagdesc`, `defaulton`)
+ VALUES (24, 'stockrotation', 'Manage stockrotation operations', 0);
+ });
+ $dbh->do(q{
+ INSERT IGNORE INTO `permissions` (`module_bit`, `code`, `description`)
+ VALUES (24, 'manage_rotas', 'Create, edit and delete rotas'),
+ (24, 'manage_rota_items', 'Add and remove items from rotas');
+ });
+ # Notices
+ $dbh->do(q{
+ INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`)
+ VALUES ('circulation', 'SR_SLIP', '', 'Stock Rotation Slip', 0, 'Stockrotation Report', 'Stockrotation report for [% branch.name %]:\r\n\r\n[% IF branch.items.size %][% branch.items.size %] items to be processed for this branch.\r\n[% ELSE %]No items to be processed for this branch\r\n[% END %][% FOREACH item IN branch.items %][% IF item.reason ne \'in-demand\' %]Title: [% item.title %]\r\nAuthor: [% item.author %]\r\nCallnumber: [% item.callnumber %]\r\nLocation: [% item.location %]\r\nBarcode: [% item.barcode %]\r\nOn loan?: [% item.onloan %]\r\nStatus: [% item.reason %]\r\nCurrent Library: [% item.branch.branchname %] [% item.branch.branchcode %]\r\n\r\n[% END %][% END %]', 'email');
+ });
+ print "Upgrade to $DBversion done (Bug 11897 - Add Stock Rotation Feature)\n";
+ SetVersion( $DBversion );
+}
+
+$DBversion = '18.06.00.041';
+if( CheckVersion( $DBversion ) ) {
+
+ if( !column_exists( 'illrequests', 'price_paid' ) ) {
+ $dbh->do(q{
+ ALTER TABLE illrequests
+ ADD COLUMN price_paid varchar(20) DEFAULT NULL
+ AFTER cost
+ });
+ }
+
+ if( !column_exists( 'illrequestattributes', 'readonly' ) ) {
+ $dbh->do(q{
+ ALTER TABLE illrequestattributes
+ ADD COLUMN readonly tinyint(1) NOT NULL DEFAULT 1
+ AFTER value
+ });
+ $dbh->do(q{
+ UPDATE illrequestattributes SET readonly = 1
+ });
+ }
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 20772 - Add illrequestattributes.readonly and illrequest.price_paid columns)\n";
+}
+
+$DBversion = '18.06.00.042';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do( "alter table statistics change column ccode ccode varchar(80) default NULL" );
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 21617: Make statistics.ccode longer)\n";
+}
+
# SEE bug 13068
# if there is anything in the atomicupdate, read and execute it.