5 description => "Item bundles support",
8 my ($dbh, $out) = @$args{qw(dbh out)};
10 if( !TableExists( 'item_bundles' ) ) {
12 CREATE TABLE `item_bundles` (
13 `item` int(11) NOT NULL,
14 `host` int(11) NOT NULL,
15 PRIMARY KEY (`host`, `item`),
16 UNIQUE KEY `item_bundles_uniq_1` (`item`),
17 CONSTRAINT `item_bundles_ibfk_1` FOREIGN KEY (`item`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
18 CONSTRAINT `item_bundles_ibfk_2` FOREIGN KEY (`host`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
19 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
22 say $out "item_bundles table added";
24 my ($lost_val) = $dbh->selectrow_array( "SELECT MAX(authorised_value) FROM authorised_values WHERE category = 'LOST'", {} );
28 INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('LOST',$lost_val,'Missing from bundle')
30 say $out "Missing from bundle LOST AV added";
32 my ($nfl_val) = $dbh->selectrow_array( "SELECT MAX(authorised_value) FROM authorised_values WHERE category = 'NOT_LOAN'", {} );
36 INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('NOT_LOAN',$nfl_val,'Added to bundle')
38 say $out "Added to bundle NOT_LOAN AV added";
41 INSERT IGNORE INTO systempreferences( `variable`, `value`, `options`, `explanation`, `type` )
43 ( 'BundleLostValue', $lost_val, '', 'Sets the LOST AV value that represents "Missing from bundle" as a lost value', 'Free' ),
44 ( 'BundleNotLoanValue', $nfl_val, '', 'Sets the NOT_LOAN AV value that represents "Added to bundle" as a not for loan value', 'Free')
46 say $out "System preferences added and set";