use MARC::File::XML ( BinaryEncoding => 'utf8' );
use File::Path qw[remove_tree]; # perl core module
-use File::Spec;
use File::Slurp;
# FIXME - The user might be installing a new database, so can't rely
WHERE COALESCE(permanent,0)=0 AND dir='koha_upload'
});
-my $tmp= File::Spec->tmpdir.'/koha_upload';
+my $tmp = C4::Context->temporary_directory . '/koha_upload';
remove_tree( $tmp ) if -d $tmp;
print "Upgrade to $DBversion done (Bug 14893 - Separate temporary storage per instance in Upload.pm)\n";
WHERE ordernumber = ?
|);
- require Koha::Number::Price;
+ require Number::Format;
+ my $format = Number::Format->new;
+ my $precision = 2;
for my $order ( @$orders ) {
$sth_get_bookseller->execute( $order->{ordernumber} );
my ( $bookseller ) = $sth_get_bookseller->fetchrow_hashref;
- $order->{rrp} = Koha::Number::Price->new( $order->{rrp} )->round;
- $order->{ecost} = Koha::Number::Price->new( $order->{ecost} )->round;
+ $order->{rrp} = $format->round( $order->{rrp}, $precision );
+ $order->{ecost} = $format->round( $order->{ecost}, $precision );
$order->{tax_rate} ||= 0 ; # tax_rate can be NULL in DB
# Ordering
if ( $bookseller->{listincgst} ) {
$order->{rrp_tax_included} = $order->{rrp};
- $order->{rrp_tax_excluded} = Koha::Number::Price->new(
- $order->{rrp_tax_included} / ( 1 + $order->{tax_rate} ) )->round;
+ $order->{rrp_tax_excluded} = $format->round(
+ $order->{rrp_tax_included} / ( 1 + $order->{tax_rate} ), $precision );
$order->{ecost_tax_included} = $order->{ecost};
- $order->{ecost_tax_excluded} = Koha::Number::Price->new(
- $order->{ecost} / ( 1 + $order->{tax_rate} ) )->round;
+ $order->{ecost_tax_excluded} = $format->round(
+ $order->{ecost} / ( 1 + $order->{tax_rate} ), $precision );
}
else {
$order->{rrp_tax_excluded} = $order->{rrp};
- $order->{rrp_tax_included} = Koha::Number::Price->new(
- $order->{rrp} * ( 1 + $order->{tax_rate} ) )->round;
+ $order->{rrp_tax_included} = $format->round(
+ $order->{rrp} * ( 1 + $order->{tax_rate} ), $precision );
$order->{ecost_tax_excluded} = $order->{ecost};
- $order->{ecost_tax_included} = Koha::Number::Price->new(
- $order->{ecost} * ( 1 + $order->{tax_rate} ) )->round;
+ $order->{ecost_tax_included} = $format->round(
+ $order->{ecost} * ( 1 + $order->{tax_rate} ), $precision );
}
#receiving
if ( $bookseller->{listincgst} ) {
- $order->{unitprice_tax_included} = Koha::Number::Price->new( $order->{unitprice} )->round;
- $order->{unitprice_tax_excluded} = Koha::Number::Price->new(
- $order->{unitprice_tax_included} / ( 1 + $order->{tax_rate} ) )->round;
+ $order->{unitprice_tax_included} = $format->round( $order->{unitprice}, $precision );
+ $order->{unitprice_tax_excluded} = $format->round(
+ $order->{unitprice_tax_included} / ( 1 + $order->{tax_rate} ), $precision );
}
else {
- $order->{unitprice_tax_excluded} = Koha::Number::Price->new( $order->{unitprice} )->round;
- $order->{unitprice_tax_included} = Koha::Number::Price->new(
- $order->{unitprice_tax_excluded} * ( 1 + $order->{tax_rate} ) )->round;
+ $order->{unitprice_tax_excluded} = $format->round( $order->{unitprice}, $precision );
+ $order->{unitprice_tax_included} = $format->round(
+ $order->{unitprice_tax_excluded} * ( 1 + $order->{tax_rate} ), $precision );
}
# If the order is received, the tax is calculated from the unit price
if ( $order->{orderstatus} eq 'complete' ) {
- $order->{tax_value} = Koha::Number::Price->new(
+ $order->{tax_value} = $format->round(
( $order->{unitprice_tax_included} - $order->{unitprice_tax_excluded} )
- * $order->{quantity} )->round;
+ * $order->{quantity}, $precision );
} else {
# otherwise the ecost is used
- $order->{tax_value} = Koha::Number::Price->new(
+ $order->{tax_value} = $format->round(
( $order->{ecost_tax_included} - $order->{ecost_tax_excluded} ) *
- $order->{quantity} )->round;
+ $order->{quantity}, $precision );
}
$sth_update_order->execute(
WHERE ordernumber = ?
|);
- require Koha::Number::Price;
for my $order (@$orders) {
my $tax_value_on_ordering =
$order->{quantity} *
}
$dbh->do(q|SET foreign_key_checks = 1|);
- print "Upgrade to $DBversion done (Bug 18336 - Convert DB tables to utf8mb4 ð\9f\92©)\n";
+ print "Upgrade to $DBversion done (Bug 18336 - Convert DB tables to utf8mb4 ð\9f\8e\81)\n";
SetVersion($DBversion);
}
print "Upgrade to $DBversion done (Bug 20074 - Auth_subfield_structure changes hidden attribute)\n";
}
+$DBversion = '17.12.00.020';
+if( CheckVersion( $DBversion ) ) {
+
+ $dbh->do(q|
+ INSERT IGNORE INTO language_descriptions(subtag, type, lang, description)
+ VALUES ('vi', 'language', 'de', 'Vietnamesisch')
+ |);
+
+ $dbh->do(q|
+ UPDATE language_descriptions SET description = 'Tiếng Việt'
+ WHERE subtag = 'vi' and type = 'language' and lang = 'vi'
+ |);
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 20082 - Update descriptions of Vietnamese language)\n";
+}
+
+$DBversion = '17.12.00.021';
+if( CheckVersion( $DBversion ) ) {
+
+ $dbh->do(q|
+ INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
+ ('PurgeSuggestionsOlderThan', '', NULL, 'Default value for cronjob purge_suggestions.pl', 'Integer');
+ |);
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 13287 - Add system preference PurgeSuggestionsOlderThan)\n";
+}
+
+$DBversion = '17.12.00.022';
+if( CheckVersion( $DBversion ) ) {
+
+ if( !column_exists( 'currency', 'p_sep_by_space' ) ) {
+ $dbh->do(q|
+ ALTER TABLE currency ADD COLUMN p_sep_by_space tinyint(1) default 0 after archived
+ |);
+ }
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 4078 - Add column currency.p_sep_by_space)\n";
+}
+
+$DBversion = '17.12.00.023';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{
+ DELETE FROM systempreferences
+ WHERE variable='checkdigit'
+ });
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 20264 - Remove system preference 'checkdigit')\n";
+}
+
+$DBversion = '17.12.00.024';
+if( CheckVersion( $DBversion ) ) {
+
+ $dbh->do(q{
+ INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
+ VALUES ('SelfCheckInMainUserBlock', '', '70|10', 'Add a block of HTML that will display on the self check-in screen.', 'Textarea');
+ });
+
+ $dbh->do(q{
+ INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
+ VALUES ('SelfCheckInModule', 0, NULL, 'Enable the standalone self-checkin module.', 'YesNo');
+ });
+
+ $dbh->do(q{
+ INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
+ VALUES ('SelfCheckInModuleUserID', NULL, NULL, 'Patron ID (borrowernumber) to be allowed on the self-checkin module.', 'Integer');
+ });
+
+ $dbh->do(q{
+ INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
+ VALUES ('SelfCheckInTimeout', 120, NULL, 'Define the number of seconds before the self check-in module times out.', 'Integer');
+ });
+
+ $dbh->do(q{
+ INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
+ VALUES ('SelfCheckInUserCSS', '', NULL, 'Add CSS to be included in the self check-in module in an embedded <style> tag.', 'free');
+ });
+
+ $dbh->do(q{
+ INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
+ VALUES ('SelfCheckInUserJS', '', NULL, 'Define custom javascript for inclusion in the self check-in module.', 'free');
+ });
+
+ # Add new userflag for self check
+ $dbh->do(q{
+ INSERT IGNORE INTO userflags (bit,flag,flagdesc,defaulton) VALUES
+ (23,'self_check','Self check modules',0);
+ });
+
+ # Add self check-in module subpermission
+ $dbh->do(q{
+ INSERT IGNORE INTO permissions (module_bit,code,description)
+ VALUES (23, 'self_checkin_module', 'Log into the self check-in module');
+ });
+
+ # Add self check-in module subpermission
+ $dbh->do(q{
+ INSERT IGNORE INTO permissions (module_bit,code,description)
+ VALUES (23, 'self_checkout_module', 'Perform self checkout at the OPAC. It should be used for the patron matching the AutoSelfCheckID');
+ });
+
+ # Update patrons with self_checkout permission
+ # IMPORTANT: Needs to happen before removing the old subpermission
+ $dbh->do(q{
+ UPDATE user_permissions
+ SET module_bit = 23,
+ code = 'self_checkout_module'
+ WHERE module_bit = 1 AND code = 'self_checkout';
+ });
+
+ # Remove old self_checkout permission
+ $dbh->do(q{
+ DELETE IGNORE FROM permissions
+ WHERE code='self_checkout';
+ });
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 15492 - Add a standalone self-checkin module)\n";
+}
+
+$DBversion = '17.12.00.025';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q|
+ INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
+ VALUES ('StaffLoginInstructions','','HTML to go into the login box for the staff client',NULL,'Free')
+ |);
+ $dbh->do(q|
+ UPDATE systempreferences
+ SET variable = 'OpacLoginInstructions'
+ WHERE variable = 'NoLoginInstructions'
+ |);
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 20291 - Add StaffLoginInstructions system preference and rename NoLoginInstructions with OpacLoginInstructions)\n";
+}
+
+$DBversion = '17.12.00.026';
+if( CheckVersion( $DBversion ) ) {
+ if( !column_exists( 'issuingrules', 'suspension_chargeperiod' ) ) {
+ $dbh->do(q|
+ ALTER TABLE issuingrules ADD COLUMN suspension_chargeperiod int(11) DEFAULT '1' AFTER maxsuspensiondays;
+ |);
+ }
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 19804 - Add issuingrules.suspension_chargeperiod)\n";
+}
+
+$DBversion = '17.12.00.027';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q|
+ INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`)
+ VALUES ('UseACQFrameworkForBiblioRecords','0','','Use the ACQ framework for the catalog details','YesNo')
+ |);
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 19289 - Add system preference UseACQFrameworkForBiblioRecords)\n";
+}
+
+$DBversion = '17.12.00.028';
+if( CheckVersion( $DBversion ) ) {
+ if( !column_exists( 'marc_tag_structure', 'ind1_defaultvalue' ) ) {
+ $dbh->do(q|
+ ALTER TABLE marc_tag_structure
+ ADD COLUMN ind2_defaultvalue VARCHAR(1) NOT NULL DEFAULT '' AFTER authorised_value,
+ ADD COLUMN ind1_defaultvalue VARCHAR(1) NOT NULL DEFAULT '' AFTER authorised_value;
+ |);
+ }
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 9701 - Add default indicators (marc_tag_structure.indX_defaultvalue))\n";
+}
+
+$DBversion = '17.12.00.029';
+if( CheckVersion( $DBversion ) ) {
+ my $pref =
+q|# PERSO_NAME 100 600 696 700 796 800 896
+marc21, 100, ind1:auth1
+marc21, 600, ind1:auth1, ind2:thesaurus
+marc21, 696, ind1:auth1
+marc21, 700, ind1:auth1
+marc21, 796, ind1:auth1
+marc21, 800, ind1:auth1
+marc21, 896, ind1:auth1
+# CORPO_NAME 110 610 697 710 797 810 897
+marc21, 110, ind1:auth1
+marc21, 610, ind1:auth1, ind2:thesaurus
+marc21, 697, ind1:auth1
+marc21, 710, ind1:auth1
+marc21, 797, ind1:auth1
+marc21, 810, ind1:auth1
+marc21, 897, ind1:auth1
+# MEETI_NAME 111 611 698 711 798 811 898
+marc21, 111, ind1:auth1
+marc21, 611, ind1:auth1, ind2:thesaurus
+marc21, 698, ind1:auth1
+marc21, 711, ind1:auth1
+marc21, 798, ind1:auth1
+marc21, 811, ind1:auth1
+marc21, 898, ind1:auth1
+# UNIF_TITLE 130 440 630 699 730 799 830 899 / 240
+marc21, 130, ind1:auth2
+marc21, 240, , ind2:auth2
+marc21, 440, , ind2:auth2
+marc21, 630, ind1:auth2, ind2:thesaurus
+marc21, 699, ind1:auth2
+marc21, 730, ind1:auth2
+marc21, 799, ind1:auth2
+marc21, 830, , ind2:auth2
+marc21, 899, ind1:auth2
+# CHRON_TERM 648
+marc21, 648, , ind2:thesaurus
+# TOPIC_TERM 650 654 656 657 658 690
+marc21, 650, , ind2:thesaurus
+# GEOGR_NAME 651 662 691 / 751
+marc21, 651, , ind2:thesaurus
+# GENRE/FORM 655
+marc21, 655, , ind2:thesaurus
+
+# UNIMARC: Always copy the indicators from the authority
+unimarc, *, ind1:auth1, ind2:auth2|;
+
+ $dbh->do( q|
+ INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
+ VALUES ( 'AuthorityControlledIndicators', ?, 'Authority controlled indicators per biblio field', NULL, 'Free' );
+ |, undef, $pref );
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 14769 - Authorities merge: Set correct indicators in biblio field (new system preference AuthorityControlledIndicators))\n";
+}
+
+$DBversion = '17.12.00.030';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q|
+ INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
+ VALUES ('NovelistSelectStaffProfile',NULL,'Novelist staff client user Profile',NULL,'free')
+ |);
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 19882 - Add system preference NovelistSelectStaffProfile)\n";
+}
+
+$DBversion = '17.12.00.031';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q|
+ INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`)
+ VALUES ('MarcFieldDocURL', NULL, NULL, 'URL used for MARC field documentation. Following substitutions are available: {MARC} = marc flavour, eg. \"MARC21\" or \"UNIMARC\". {FIELD} = field number, eg. \"000\" or \"048\". {LANG} = user language, eg. \"en\" or \"fi-FI\"', 'free')
+ |);
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 11674 - Add system preference MarcFieldDocURL)\n";
+}
+
+$DBversion = '17.12.00.032';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q|
+ UPDATE letter SET code = "SERIAL_ALERT" WHERE code = "RLIST";
+ |);
+ $dbh->do(q|
+ UPDATE letter SET name = "New serial issue" WHERE name = "Routing List";
+ |);
+ $dbh->do(q|
+ UPDATE subscription SET letter = "SERIAL_ALERT" WHERE letter = "RLIST";
+ |);
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 19794 - Rename RLIST notice to SERIAL_ALERT)\n";
+}
+
+$DBversion = '17.12.00.033';
+if( CheckVersion( $DBversion ) ) {
+ if ( !column_exists( 'accountlines', 'payment_type' ) ) {
+ $dbh->do(q{
+ ALTER TABLE accountlines ADD payment_type varchar(80) default NULL AFTER accounttype
+ });
+ }
+
+ $dbh->do(q{
+ INSERT IGNORE INTO authorised_value_categories( category_name ) VALUES ('PAYMENT_TYPE')
+ });
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 18786 - Add ability to create custom payment types)\n";
+}
+
+$DBversion = '17.12.00.034';
+if( CheckVersion( $DBversion ) ) {
+
+ $dbh->do( q{
+ INSERT IGNORE INTO account_offset_types ( type ) VALUES ('Void Payment')
+ } );
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 18790 - Add ability to void payment)\n";
+}
+
+$DBversion = '17.12.00.035';
+if( CheckVersion( $DBversion ) ) {
+ my ( $original_value ) = $dbh->selectrow_array(q|
+ SELECT value FROM systempreferences WHERE variable="MarkLostItemsAsReturned"
+ |);
+ if ( $original_value and $original_value eq '1' ) {
+ $dbh->do(q{
+ UPDATE systempreferences
+ SET type="multiple",
+ options="batchmod|moredetail|cronjob|additem",
+ value="batchmod,moredetail,cronjob,additem"
+ WHERE variable="MarkLostItemsAsReturned"
+ });
+ } else {
+ $dbh->do(q{
+ UPDATE systempreferences
+ SET type="multiple",
+ options="batchmod|moredetail|cronjob|additem",
+ value=""
+ WHERE variable="MarkLostItemsAsReturned"
+ });
+ }
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 19974 - Make MarkLostItemsAsReturned multiple)\n";
+}
+
+$DBversion = '17.12.00.036';
+if( CheckVersion( $DBversion ) ) {
+
+ $dbh->do( q{
+ INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('CanMarkHoldsToPullAsLost','do_not_allow','do_not_allow|allow|allow_and_notify','Add a button to the "Holds to pull" screen to mark an item as lost and notify the patron.','Choice');
+ } );
+ $dbh->do( q{
+ INSERT IGNORE INTO letter(module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES ('reserves', 'CANCEL_HOLD_ON_LOST', '', 'Hold has been cancelled', 0, "Hold has been cancelled", "Dear [% borrower.firstname %] [% borrower.surname %],\n\nWe regret to inform you, that the following item can not be provided due to it being missing. Your hold was cancelled.\n\nTitle: [% biblio.title %]\nAuthor: [% biblio.author %]\nCopy: [% item.copynumber %]\nLocation: [% branch.branchname %]", 'email', 'default');
+ } );
+ $dbh->do( q{
+ INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('UpdateItemWhenLostFromHoldList','',NULL,'This is a list of values to update an item when it is marked as lost from the holds to pull screen','Free');
+ } );
+ $dbh->do( q{
+ UPDATE systempreferences SET options="batchmod|moredetail|cronjob|additem|pendingreserves", value="batchmod|moredetail|cronjob|additem|pendingreserves" WHERE variable="MarkLostItemsAsReturned";
+ } );
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 19287 - Add ability to mark an item 'Lost' from 'Holds to pull' list (CanMarkHoldsToPullAsLost, UpdateItemWhenLostFromHoldList and CANCEL_HOLD_ON_LOST))\n";
+}
+
+$DBversion = '17.12.00.037';
+if( CheckVersion( $DBversion ) ) {
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (This change has been reverted, nothing done!)\n";
+}
+
+$DBversion = '17.12.00.038';
+if( CheckVersion( $DBversion ) ) {
+
+ $dbh->do( q{
+ UPDATE language_rfc4646_to_iso639 SET iso639_2_code = 'slo' WHERE iso639_2_code = 'slk' AND rfc4646_subtag = 'sk';
+ } );
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 20245 - Use Bibliographic code value for Slovak language)\n";
+}
+
+$DBversion = '17.12.00.039';
+if( CheckVersion( $DBversion ) ) {
+
+ $dbh->do( q{
+ UPDATE language_rfc4646_to_iso639 SET iso639_2_code = 'baq' WHERE iso639_2_code = 'eus' AND rfc4646_subtag = 'eu';
+ } );
+ $dbh->do( q{
+ UPDATE language_rfc4646_to_iso639 SET iso639_2_code = 'mao' WHERE iso639_2_code = 'mri' AND rfc4646_subtag = 'mi';
+ } );
+ $dbh->do( q{
+ UPDATE language_rfc4646_to_iso639 SET iso639_2_code = 'alb' WHERE iso639_2_code = 'sqi' AND rfc4646_subtag = 'sq';
+ } );
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 20482 - Use Bibliographic code value for Basque, Maori and Albanian languages)\n";
+}
+
+$DBversion = '17.12.00.040';
+if( CheckVersion( $DBversion ) ) {
+
+ $dbh->do( q{
+ INSERT IGNORE INTO systempreferences ( value, variable, options, explanation, type )
+ VALUES ( '0', 'ProtectSuperlibrarianPrivileges', NULL, 'If enabled, non-superlibrarians cannot set superlibrarian privileges', 'YesNo' )
+ } );
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 20100 - Add new system preference ProtectSuperlibrarianPrivileges)\n";
+}
+
+$DBversion = '17.12.00.041';
+if( CheckVersion( $DBversion ) ) {
+
+ $dbh->do( q{
+ INSERT IGNORE INTO permissions (module_bit, code, description) VALUES (13, 'access_files', 'Access to the files stored on the server');
+ } );
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 11317 - Add a new permission to access files stored on the server)\n";
+}
+
+$DBversion = '17.12.00.042';
+if( CheckVersion( $DBversion ) ) {
+
+ if (!TableExists('oauth_access_tokens')) {
+ $dbh->do(q{
+ CREATE TABLE oauth_access_tokens (
+ `access_token` VARCHAR(191) NOT NULL,
+ `client_id` VARCHAR(191) NOT NULL,
+ `expires` INT NOT NULL,
+ PRIMARY KEY (`access_token`)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
+ });
+ }
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 20402 - Implement OAuth2 authentication for REST API)\n";
+}
+
+$DBversion = '17.12.00.043';
+if(CheckVersion($DBversion)) {
+
+ if (!TableExists('api_keys')) {
+ $dbh->do(q{
+ CREATE TABLE `api_keys` (
+ `client_id` VARCHAR(191) NOT NULL,
+ `secret` VARCHAR(191) NOT NULL,
+ `description` VARCHAR(255) NOT NULL,
+ `patron_id` INT(11) NOT NULL,
+ `active` TINYINT(1) DEFAULT 1 NOT NULL,
+ PRIMARY KEY `client_id` (`client_id`),
+ UNIQUE KEY `secret` (`secret`),
+ KEY `patron_id` (`patron_id`),
+ CONSTRAINT `api_keys_fk_patron_id`
+ FOREIGN KEY (`patron_id`)
+ REFERENCES `borrowers` (`borrowernumber`)
+ ON DELETE CASCADE ON UPDATE CASCADE
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+ });
+ }
+
+ print "Upgrade to $DBversion done (Bug 20568 - Add API key management interface for patrons)\n";
+ SetVersion($DBversion);
+}
+
+$DBversion = '17.12.00.044';
+if(CheckVersion($DBversion)) {
+
+ $dbh->do(q{
+ INSERT IGNORE INTO systempreferences (`variable`,`value`,`options`,`explanation`,`type`)
+ VALUES
+ ('RESTOAuth2ClientCredentials','0',NULL,'If enabled, the OAuth2 client credentials flow is enabled for the REST API.','YesNo');
+ });
+
+ print "Upgrade to $DBversion done (Bug 20624 - Disable OAuth2 client credentials grant by default)\n";
+ SetVersion($DBversion);
+}
+
+$DBversion = '18.05.00.000';
+if( CheckVersion( $DBversion ) ) {
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Koha 18.05)\n";
+}
+
+$DBversion = '18.06.00.000';
+if( CheckVersion( $DBversion ) ) {
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Koha 18.06 - It's Adventure time!)\n";
+}
+
+$DBversion = '18.06.00.001';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{UPDATE permissions SET description = 'Manage budgets' WHERE code = 'period_manage';});
+ $dbh->do(q{UPDATE permissions SET description = 'Manage funds' WHERE code = 'budget_manage';});
+ $dbh->do(q{UPDATE permissions SET description = 'Modify funds (can''t create lines, but can modify existing ones)' WHERE code = 'budget_modify';});
+ $dbh->do(q{UPDATE permissions SET description = 'Manage baskets and order lines' WHERE code = 'order_manage';});
+ $dbh->do(q{UPDATE permissions SET description = 'Manage all baskets and order lines, regardless of restrictions on them' WHERE code = 'order_manage_all';});
+ $dbh->do(q{UPDATE permissions SET description = 'Manage basket groups' WHERE code = 'group_manage';});
+ $dbh->do(q{UPDATE permissions SET description = 'Receive orders and manage shipments' WHERE code = 'order_receive';});
+ $dbh->do(q{UPDATE permissions SET description = 'Add and delete funds (but can''t modify funds)' WHERE code = 'budget_add_del';});
+ $dbh->do(q{UPDATE permissions SET description = 'Manage all funds' WHERE code = 'budget_manage_all';});
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 3849- Improve descriptions of granular acquisition permissions)\n";
+}
+
+$DBversion = '18.06.00.002';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{DELETE FROM userflags WHERE bit = 12 AND flag = 'management';});
+ $dbh->do(q{UPDATE borrowers SET flags = flags - ( flags & (1<<12) ) WHERE flags & (1 << 12);});
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 2426 - Remove deprecated management permission)\n";
+}
+
+$DBversion = '18.06.00.003';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do( "ALTER TABLE search_field CHANGE COLUMN type type ENUM('', 'string', 'date', 'number', 'boolean', 'sum', 'isbn', 'stdno') NOT NULL COMMENT 'what type of data this holds, relevant when storing it in the search engine'" );
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 20073 - Add new types for Elasticsearch fields)\n";
+}
+
+$DBversion = '18.06.00.004';
+if( CheckVersion( $DBversion ) ) {
+
+ # Add 'Manual Credit' offset type
+ $dbh->do(q{
+ INSERT IGNORE INTO `account_offset_types` (`type`) VALUES ('Manual Credit');
+ });
+
+ # Fix wrong account offsets / Manual credits
+ $dbh->do(q{
+ UPDATE account_offsets
+ SET credit_id=debit_id,
+ debit_id=NULL,
+ type='Manual Credit'
+ WHERE amount < 0 AND
+ type='Manual Debit' AND
+ debit_id IN
+ (SELECT accountlines_id AS debit_id
+ FROM accountlines
+ WHERE accounttype='C');
+ });
+
+ # Fix wrong account offsets / Manually forgiven amounts
+ $dbh->do(q{
+ UPDATE account_offsets
+ SET credit_id=debit_id,
+ debit_id=NULL,
+ type='Writeoff'
+ WHERE amount < 0 AND
+ type='Manual Debit' AND
+ debit_id IN
+ (SELECT accountlines_id AS debit_id
+ FROM accountlines
+ WHERE accounttype='FOR');
+ });
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 20980 - Manual credit offsets are stored as debits)\n";
+}
+
+$DBversion = '18.06.00.005';
+if( CheckVersion( $DBversion ) ) {
+ unless ( column_exists('aqorders', 'created_by') ) {
+ $dbh->do( "ALTER TABLE aqorders ADD COLUMN created_by int(11) NULL DEFAULT NULL AFTER quantityreceived;" );
+ unless ( foreign_key_exists('aqorders', 'aqorders_created_by') ) {
+ $dbh->do( "ALTER TABLE aqorders ADD CONSTRAINT aqorders_created_by FOREIGN KEY (created_by) REFERENCES borrowers (borrowernumber) ON DELETE SET NULL ON UPDATE CASCADE;" );
+ }
+ $dbh->do( "UPDATE aqorders, aqbasket SET aqorders.created_by = aqbasket.authorisedby WHERE aqorders.basketno = aqbasket.basketno AND aqorders.created_by IS NULL;" );
+ }
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 12395 - Save order line's creator)\n";
+}
+
+$DBversion = '18.06.00.006';
+if( CheckVersion( $DBversion ) ) {
+ unless ( column_exists('patron_lists', 'shared') ) {
+ $dbh->do( "ALTER TABLE patron_lists ADD COLUMN shared tinyint(1) default 0 AFTER owner;" );
+ }
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 19524 - Share patron lists between staff)\n";
+}
+
+$DBversion = '18.06.00.007';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do( "INSERT IGNORE INTO permissions (module_bit, code, description) VALUES (11, 'currencies_manage', 'Manage currencies and exchange rates');" );
+ $dbh->do(q{
+ INSERT IGNORE INTO user_permissions (borrowernumber, module_bit, code)
+ SELECT borrowernumber, 11, 'currencies_manage' FROM borrowers WHERE flags & (1 << 3) OR borrowernumber IN
+ (SELECT borrowernumber FROM user_permissions WHERE code = 'parameters_remaining_permissions');
+ });
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 7651 - Add separate permission for managing currencies and exchange rates)\n";
+}
+
+$DBversion = '18.06.00.008';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do( "ALTER TABLE marc_modification_template_actions CHANGE action action ENUM('delete_field','add_field','update_field','move_field','copy_field','copy_and_replace_field')" );
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 13560 - need an add option in marc modification templates)\n";
+}
+
+$DBversion = '18.06.00.009';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do( "
+ CREATE TABLE IF NOT EXISTS aqinvoice_adjustments (
+ adjustment_id int(11) NOT NULL AUTO_INCREMENT,
+ invoiceid int(11) NOT NULL,
+ adjustment decimal(28,6),
+ reason varchar(80) default NULL,
+ note mediumtext default NULL,
+ budget_id int(11) default NULL,
+ encumber_open smallint(1) NOT NULL default 1,
+ timestamp timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+ PRIMARY KEY (adjustment_id),
+ CONSTRAINT aqinvoice_adjustments_fk_invoiceid FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT aqinvoice_adjustments_fk_budget_id FOREIGN KEY (budget_id) REFERENCES aqbudgets (budget_id) ON DELETE SET NULL ON UPDATE CASCADE
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
+ " );
+ $dbh->do("INSERT IGNORE INTO authorised_value_categories (category_name) VALUES ('ADJ_REASON')");
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 19166 - Add the ability to add adjustments to an invoice)\n";
+}
+
+$DBversion = '18.06.00.010';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{
+ INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`, `lang`)
+ VALUES
+ ('circulation', 'ACCOUNT_PAYMENT', '', 'Account payment', 0, 'Account payment', '[%- USE Price -%]\r\nA payment of [% credit.amount * -1 | $Price %] has been applied to your account.\r\n\r\nThis payment affected the following fees:\r\n[%- FOREACH o IN offsets %]\r\nDescription: [% o.debit.description %]\r\nAmount paid: [% o.amount * -1 | $Price %]\r\nAmount remaining: [% o.debit.amountoutstanding | $Price %]\r\n[% END %]', 'email', 'default'),
+ ('circulation', 'ACCOUNT_WRITEOFF', '', 'Account writeoff', 0, 'Account writeoff', '[%- USE Price -%]\r\nAn account writeoff of [% credit.amount * -1 | $Price %] has been applied to your account.\r\n\r\nThis writeoff affected the following fees:\r\n[%- FOREACH o IN offsets %]\r\nDescription: [% o.debit.description %]\r\nAmount paid: [% o.amount * -1 | $Price %]\r\nAmount remaining: [% o.debit.amountoutstanding | $Price %]\r\n[% END %]', 'email', 'default');
+ });
+ $dbh->do(q{
+ INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`)
+ VALUES ('UseEmailReceipts','0','','Send email receipts for payments and write-offs','YesNo')
+ });
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 19191 - Add ability to email receipts for account payments and write-offs)\n";
+}
+
+$DBversion = '18.06.00.011';
+if( CheckVersion( $DBversion ) ) {
+ unless( column_exists( 'issues', 'noteseen' ) ) {
+ $dbh->do(q|ALTER TABLE issues ADD COLUMN noteseen int(1) default NULL AFTER notedate|);
+ }
+
+ unless( column_exists( 'old_issues', 'noteseen' ) ) {
+ $dbh->do(q|ALTER TABLE old_issues ADD COLUMN noteseen int(1) default NULL AFTER notedate|);
+ }
+ $dbh->do(q|INSERT IGNORE INTO permissions (module_bit, code, description) VALUES ( 1, 'manage_checkout_notes', 'Mark checkout notes as seen/not seen');|);
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 17698: Add column issues.noteseen and old_issues.noteseen)\n";
+}
+
+$DBversion = '18.06.00.012';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q|INSERT IGNORE INTO permissions (module_bit, code, description) VALUES (11, 'suggestions_manage', 'Manage purchase suggestions');|);
+ $dbh->do(q|INSERT IGNORE INTO user_permissions (borrowernumber, module_bit, code) SELECT borrowernumber, 11, 'suggestions_manage' FROM borrowers WHERE flags & (1 << 2);|);
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 11911 - Add separate permission for managing suggestions)\n";
+}
+
+$DBversion = '18.06.00.013';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{
+ INSERT IGNORE INTO `account_offset_types` (`type`) VALUES ('Credit Applied');
+ });
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 20997 - Add Koha::Account::Line::apply)\n";
+}
+
+$DBversion = '18.06.00.014';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{
+ INSERT IGNORE INTO systempreferences (variable, value, options, explanation) VALUES ('HidePersonalPatronDetailOnCirculation', 0, 'YesNo', 'Hide patrons phone number, email address, street address and city in the circulation page');
+ });
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 21121 - New syspref to allow hiding of private patron data in circulation page)\n";
+}
+
+$DBversion = '18.06.00.015';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{DELETE FROM systempreferences where variable="OCLCAffiliateID";});
+ $dbh->do(q{DELETE FROM systempreferences where variable="XISBN";});
+ $dbh->do(q{DELETE FROM systempreferences where variable="XISBNDailyLimit";});
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 21226 - Remove prefs OCLCAffiliateID, XISBN and XISBNDailyLimit)\n";
+}
+
+$DBversion = '18.06.00.016';
+if( CheckVersion( $DBversion ) ) {
+ my $dtf = Koha::Database->new->schema->storage->datetime_parser;
+ my $days = C4::Context->preference('MaxPickupDelay') || 7;
+ my $date = DateTime->now()->add( days => $days );
+ my $sql = q|UPDATE reserves SET expirationdate = ? WHERE expirationdate IS NULL AND waitingdate IS NOT NULL|;
+ $dbh->do( $sql, undef, $dtf->format_datetime($date) );
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 20773 - expirationdate filled for waiting holds)\n";
+}
+
+$DBversion = '18.06.00.017';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q|INSERT IGNORE INTO authorised_value_categories (category_name) VALUES ('ROADTYPE');|);
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 21144: Add ROADTYPE to default authorised values categories)\n";
+}
+
+$DBversion = '18.06.00.018';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do( q|
+UPDATE items LEFT JOIN issues USING (itemnumber)
+SET items.onloan = NULL
+WHERE issues.itemnumber IS NULL
+ |);
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 20487: Clear items.onloan for unissued items)\n";
+}
+
+$DBversion = '18.06.00.019';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do( q|
+INSERT IGNORE INTO columns_settings (module, page, tablename, columnname, cannot_be_toggled, is_hidden) VALUES
+("circ", "circulation", "issues-table", "collection", 0, 1),
+("members", "moremember", "issues-table", "collection", 0, 1);
+ |);
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 19719: Default to hiding collection code column)\n";
+}
+
+$DBversion = '18.06.00.020';
+if( CheckVersion( $DBversion ) ) {
+ if( !column_exists( 'branch_borrower_circ_rules', 'max_holds' ) ) {
+ $dbh->do(q{
+ ALTER TABLE branch_borrower_circ_rules ADD COLUMN max_holds INT(4) NULL DEFAULT NULL AFTER maxonsiteissueqty
+ });
+ }
+ if( !column_exists( 'default_borrower_circ_rules', 'max_holds' ) ) {
+ $dbh->do(q{
+ ALTER TABLE default_borrower_circ_rules ADD COLUMN max_holds INT(4) NULL DEFAULT NULL AFTER maxonsiteissueqty
+ });
+ }
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 15524 - Set limit on maximum possible holds per patron by category)\n";
+}
+
+$DBversion = '18.06.00.021';
+if( CheckVersion( $DBversion ) ) {
+ my $dbh = C4::Context->dbh;
+ unless ( C4::Context->preference('NorwegianPatronDBEnable') ) {
+ $dbh->do(q|
+ DELETE FROM systempreferences
+ WHERE variable IN ('NorwegianPatronDBEnable', 'NorwegianPatronDBEndpoint', 'NorwegianPatronDBUsername', 'NorwegianPatronDBPassword', 'NorwegianPatronDBSearchNLAfterLocalHit')
+ |);
+ if ( TableExists('borrower_sync') ) {
+ $dbh->do(q|DROP TABLE borrower_sync|);
+ }
+ }
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 21068 - Remove system preferences NorwegianPatronDB*)\n";
+}
+
+$DBversion = '18.06.00.022';
+if( CheckVersion( $DBversion ) ) {
+ my $dbh = C4::Context->dbh;
+ $dbh->do(q|
+ INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
+ ('HoldsAutoFill','0',NULL,'If on, librarian will not be asked if hold should be filled, it will be filled automatically','YesNo'),
+ ('HoldsAutoFillPrintSlip','0',NULL,'If on, hold slip print dialog will be displayed automatically','YesNo')
+ |);
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 19383 - Add ability to print hold receipts automatically)\n";
+}
+
+$DBversion = '18.06.00.023';
+if( CheckVersion( $DBversion ) ) {
+ if( !column_exists( 'aqorders', 'replacementprice' ) ){
+ $dbh->do( "ALTER TABLE aqorders ADD COLUMN replacementprice DECIMAL(28,6)" );
+ $dbh->do( "UPDATE aqorders set replacementprice = rrp WHERE replacementprice IS NULL" );
+ }
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 18639 - Add replacementprice field to aqorders table)\n";
+}
+
+$DBversion = '18.06.00.024';
+if( CheckVersion( $DBversion ) ) {
+ if( !column_exists( 'branches', 'pickup_location' ) ){
+ $dbh->do( "ALTER TABLE branches ADD COLUMN pickup_location TINYINT(1) not null default 1" );
+ }
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 7534 - Let libraries have configuration for pickup locations)\n";
+}
+
+$DBversion = '18.06.00.025';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{
+ INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
+ ('KohaManualBaseURL','https://koha-community.org/manual/','','Where is the Koha manual/documentation located?','Free'),
+ ('KohaManualLanguage','en','en|ar|cs|es|de|fr|it|pt_BR|tr|zh_TW','What is the language of the online manual you want to use?','Choice')
+ });
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 19817: Add pref KohaManualLanguage and KohaManualBaseURL)\n";
+}
+
+$DBversion = '18.06.00.026';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q|
+INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('ArticleRequestsLinkControl', 'always', 'always\|calc', 'Control display of article request link on search results', 'Choice')
+ |);
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 17530 - Add pref ArticleRequestsLinkControl)\n";
+}
+
+$DBversion = '18.06.00.027';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do( "DROP TABLE IF EXISTS services_throttle" );
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 21235: Remove table services_throttle)\n";
+}
+
+$DBversion = '18.06.00.028';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{
+INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
+('HoldsSplitQueue','nothing','nothing|branch|itemtype|branch_itemtype','In the staff client, split the holds view by the given criteria','Choice'),
+('HoldsSplitQueueNumbering', 'actual', 'actual|virtual', 'If the holds queue is split, decide if the acual priorities should be displayed', 'Choice');
+});
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 19469 - Add ability to split view of holds view on record by pickup library and/or itemtype)\n";
+}
+
+$DBversion = '18.06.00.029';
+if( CheckVersion( $DBversion ) ) {
+ unless ( index_exists( 'subscription', 'by_biblionumber' ) ) {
+ $dbh->do(q{
+ CREATE INDEX `by_biblionumber` ON `subscription` (`biblionumber`)
+ });
+ }
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 21288: Slowness in acquisition caused by GetInvoices\n";
+}
+
+$DBversion = '18.06.00.030';
+if( CheckVersion( $DBversion ) ) {
+ if ( column_exists( 'accountlines', 'dispute' ) ) {
+ $dbh->do(q{
+ ALTER TABLE `accountlines`
+ DROP COLUMN `dispute`
+ });
+ }
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 20777 - Remove unused field accountlines.dispute)\n";
+}
+
+$DBversion = '18.06.00.031';
+if( CheckVersion( $DBversion ) ) {
+ # Add table and add column
+ unless (TableExists('patron_consent')) {
+ $dbh->do(q|
+ CREATE TABLE patron_consent (id int AUTO_INCREMENT, borrowernumber int NOT NULL, type enum('GDPR_PROCESSING' ), given_on datetime, refused_on datetime, PRIMARY KEY (id), FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE )
+ |);
+ }
+ unless ( column_exists( 'borrower_modifications', 'gdpr_proc_consent' ) ) {
+ $dbh->do(q|
+ ALTER TABLE borrower_modifications ADD COLUMN gdpr_proc_consent datetime
+ |);
+ }
+ # Add two sysprefs too
+ $dbh->do(q|
+INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type ) VALUES ('PrivacyPolicyURL','',NULL,'This URL is used in messages about GDPR consents.', 'Free')
+ |);
+ $dbh->do(q|
+INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type ) VALUES ('GDPR_Policy','','Enforced\|Permissive\|Disabled','General Data Protection Regulation - policy', 'Choice')
+ |);
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 20819: Add patron_consent)\n";
+}
+
+$DBversion = '18.06.00.032';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q|ALTER TABLE items CHANGE COLUMN ccode ccode varchar(80) default NULL|);
+ $dbh->do(q|ALTER TABLE deleteditems CHANGE COLUMN ccode ccode varchar(80) default NULL|);
+ $dbh->do(q|ALTER TABLE branch_transfer_limits CHANGE COLUMN ccode ccode varchar(80) default NULL|);
+ $dbh->do(q|ALTER TABLE course_items CHANGE COLUMN ccode ccode varchar(80) default NULL|);
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 5458: length of items.ccode disagrees with authorised_values.authorised_value)\n";
+}
+
+$DBversion = '18.06.00.033';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q|
+ INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('AdditionalFieldsInZ3950ResultSearch', '', 'NULL', 'Determines which MARC field/subfields are displayed in -Additional field- column in the result of a search Z3950', 'Free')
+ |);
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 12747 - Add AdditionalFieldsInZ3950ResultSearch system preference)\n";
+}
+
+$DBversion = '18.06.00.034';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q|
+ INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
+ VALUES ('RecordedBooksClientSecret','','30','Client key for RecordedBooks integration','YesNo'),
+ ('RecordedBooksLibraryID','','','Library ID for RecordedBooks integration','Integer'),
+ ('RecordedBooksDomain','','','RecordedBooks domain','Free');
+ |);
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 17602 - Integrate support for OneClickdigital/Recorded Books API)\n";
+}
+
+$DBversion = '18.06.00.035';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{
+ UPDATE `systempreferences` SET options = 'US|CA|DE|FR|IN|JP|UK' WHERE variable = 'AmazonLocale' AND options='US|CA|DE|FR|JP|UK';
+ });
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 21403 - Add Indian Amazon Affiliate option to AmazonLocale setting)\n";
+}
+
+
+$DBversion = '18.06.00.036';
+if( CheckVersion( $DBversion ) ) {
+ unless (TableExists('circulation_rules')){
+ $dbh->do(q{
+ CREATE TABLE `circulation_rules` (
+ `id` int(11) NOT NULL auto_increment,
+ `branchcode` varchar(10) NULL default NULL,
+ `categorycode` varchar(10) NULL default NULL,
+ `itemtype` varchar(10) NULL default NULL,
+ `rule_name` varchar(32) NOT NULL,
+ `rule_value` varchar(32) NOT NULL,
+ PRIMARY KEY (`id`),
+ CONSTRAINT `circ_rules_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `circ_rules_ibfk_2` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `circ_rules_ibfk_3` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE,
+ KEY `rule_name` (`rule_name`),
+ UNIQUE (`branchcode`,`categorycode`,`itemtype`,`rule_name`)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+ });
+ }
+ if (column_exists('branch_borrower_circ_rules', 'max_holds') ){
+ $dbh->do(q{
+ INSERT IGNORE INTO circulation_rules ( branchcode, categorycode, itemtype, rule_name, rule_value )
+ SELECT branchcode, categorycode, NULL, 'max_holds', COALESCE( max_holds, '' ) FROM branch_borrower_circ_rules
+ });
+ $dbh->do(q{
+ ALTER TABLE branch_borrower_circ_rules DROP COLUMN max_holds
+ });
+ }
+ if (column_exists('default_borrower_circ_rules', 'max_holds') ){
+ $dbh->do(q{
+ INSERT IGNORE INTO circulation_rules ( branchcode, categorycode, itemtype, rule_name, rule_value )
+ SELECT NULL, categorycode, NULL, 'max_holds', COALESCE( max_holds, '' ) FROM default_borrower_circ_rules
+ });
+ $dbh->do(q{
+ ALTER TABLE default_borrower_circ_rules DROP COLUMN max_holds
+ });
+ }
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 18887 - Introduce new table 'circulation_rules', use for 'max_holds' rules)\n";
+}
+
+$DBversion = '18.06.00.037';
+if( CheckVersion( $DBversion ) ) {
+ unless (TableExists('branches_overdrive')){
+ $dbh->do( q|
+ CREATE TABLE IF NOT EXISTS branches_overdrive (
+ `branchcode` VARCHAR( 10 ) NOT NULL ,
+ `authname` VARCHAR( 255 ) NOT NULL ,
+ PRIMARY KEY (`branchcode`) ,
+ CONSTRAINT `branches_overdrive_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
+ ) ENGINE = INNODB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci |
+ );
+ }
+ $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('OverDriveAuthname', '', 'Authname for OverDrive Patron Authentication, will be used as fallback if individual branch authname not set', NULL, 'Free');");
+ $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('OverDriveWebsiteID','', 'WebsiteID provided by OverDrive', NULL, 'Free');");
+ $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('OverDrivePasswordRequired','', 'Does the library require passwords for OverDrive SIP authentication', NULL, 'YesNo');");
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 21082 - Add overdrive patron auth method)\n";
+}
+
+$DBversion = '18.06.00.038';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do( "ALTER TABLE edifact_ean MODIFY branchcode VARCHAR(10) NULL DEFAULT NULL" );
+ SetVersion( $DBversion );
+ 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.