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} *
borrowernumber int(11) NOT NULL,
date_enrolled timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
date_canceled timestamp NULL DEFAULT NULL,
- date_created timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ date_created timestamp NULL DEFAULT NULL,
date_updated timestamp NULL DEFAULT NULL,
branchcode varchar(10) NULL DEFAULT NULL,
PRIMARY KEY (id),
if ( TableExists( 'branchcategories' ) and TableExists('branchrelations' )) {
$dbh->do(q{
- INSERT INTO library_groups ( title, description, created_on ) VALUES ( '__SEARCH_GROUPS__', 'Library search groups - Staff only', NOW() )
+ INSERT INTO library_groups ( title, description, created_on ) VALUES ( '__SEARCH_GROUPS__', 'Library search groups', NOW() )
});
- my $search_groups_staff_root_id = $dbh->last_insert_id(undef, undef, 'library_groups', undef);
-
- $dbh->do(q{
- INSERT INTO library_groups ( title, description, created_on ) VALUE ( '__SEARCH_GROUPS_OPAC__', 'Library search groups - Staff only', NOW() )
- });
- my $search_groups_opac_root_id = $dbh->last_insert_id(undef, undef, 'library_groups', undef);
+ my $search_groups_root_id = $dbh->last_insert_id(undef, undef, 'library_groups', undef);
my $sth = $dbh->prepare("SELECT * FROM branchcategories");
my $description = $lc->{categorycode};
$description .= " - " . $lc->{codedescription} if $lc->{codedescription};
- $sth2->execute(
- $lc->{show_in_pulldown} ? $search_groups_opac_root_id : $search_groups_staff_root_id,
- $lc->{categoryname},
- $description,
- );
+ $sth2->execute($search_groups_root_id, $lc->{categoryname}, $description);
my $subgroup_id = $dbh->last_insert_id(undef, undef, 'library_groups', undef);
print "Upgrade to $DBversion done (Bug 20133 - Add library_groups.ft_hide_patron_info)\n";
}
-# DEVELOPER PROCESS, search for anything to execute in the db_update directory
+$DBversion = '17.12.00.011';
+if( CheckVersion( $DBversion ) ) {
+
+ if( !column_exists( 'library_groups', 'ft_search_groups_opac' ) ) {
+ $dbh->do( "ALTER TABLE library_groups ADD COLUMN ft_search_groups_opac tinyint(1) NOT NULL DEFAULT 0 AFTER ft_hide_patron_info" );
+ $dbh->do( "ALTER TABLE library_groups ADD COLUMN ft_search_groups_staff tinyint(1) NOT NULL DEFAULT 0 AFTER ft_search_groups_opac" );
+ $dbh->do( "UPDATE library_groups SET ft_search_groups_staff = 1 AND ft_search_groups_opac = 1 WHERE title = '__SEARCH_GROUPS__'" );
+ }
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 20157 - Use group 'features' to decide which groups to use for group searching functionality)\n";
+}
+
+$DBversion = '17.12.00.012';
+if( CheckVersion( $DBversion ) ) {
+
+ $dbh->do( q|
+ INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
+ VALUES ('AutoSwitchPatron', '0', '', 'Auto switch to patron', 'YesNo');
+ |);
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 15752 - Add system preference AutoSwitchPatron)\n";
+}
+
+$DBversion = '17.12.00.013';
+if( CheckVersion( $DBversion ) ) {
+
+ $dbh->do(q|
+ ALTER TABLE club_enrollments MODIFY date_created timestamp NULL DEFAULT NULL;
+ |);
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 20175 - Set DEFAULT NULL value for club_enrollments.date_created)\n";
+}
+
+$DBversion = '17.12.00.014';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do( "UPDATE marc_subfield_structure SET kohafield=NULL where kohafield='additionalauthors.author'" );
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 19790 - Remove additionalauthors.author from installer files)\n";
+}
+
+$DBversion = '17.12.00.015';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q|
+ ALTER TABLE borrowers
+ MODIFY surname MEDIUMTEXT,
+ MODIFY address MEDIUMTEXT,
+ MODIFY city MEDIUMTEXT
+ |);
+ $dbh->do(q|
+ ALTER TABLE deletedborrowers
+ MODIFY surname MEDIUMTEXT,
+ MODIFY address MEDIUMTEXT,
+ MODIFY city MEDIUMTEXT
+ |);
+
+ $dbh->do(q|
+ ALTER TABLE export_format
+ MODIFY csv_separator VARCHAR(2) NOT NULL DEFAULT ',',
+ MODIFY field_separator VARCHAR(2),
+ MODIFY subfield_separator VARCHAR(2)
+ |);
+ $dbh->do(q|
+ ALTER TABLE export_format MODIFY encoding VARCHAR(255) NOT NULL DEFAULT 'utf8'
+ |);
+
+ $dbh->do(q|
+ ALTER TABLE reserves MODIFY lowestPriority tinyint(1) NOT NULL DEFAULT 0
+ |);
+ $dbh->do(q|
+ ALTER TABLE old_reserves MODIFY lowestPriority tinyint(1) NOT NULL DEFAULT 0
+ |);
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 20144 - Adapt DB structure to work with new SQL modes)\n";
+}
+
+$DBversion = '17.12.00.016';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q|SET foreign_key_checks = 0|);
+ my $sth = $dbh->table_info( '','','','TABLE' );
+
+ while ( my ( $cat, $schema, $name, $type, $remarks ) = $sth->fetchrow_array ) {
+ my $table_sth = $dbh->prepare(qq|SHOW CREATE TABLE $name|);
+ $table_sth->execute;
+ my @table = $table_sth->fetchrow_array;
+ unless ( $table[1] =~ /COLLATE=utf8mb4_unicode_ci/ ) {
+ # Some users might have done the upgrade to utf8mb4 on their own
+ # to support supplemental chars (japanese, chinese, etc)
+ if ( $name eq 'additional_fields' ) {
+ $dbh->do(qq|
+ ALTER TABLE $name
+ DROP KEY `fields_uniq`,
+ ADD UNIQUE KEY `fields_uniq` (`tablename` (191), `name` (191))
+ |);
+ $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
+ }
+ elsif ( $name eq 'authorised_values' ) {
+ $dbh->do(qq|
+ ALTER TABLE $name
+ DROP KEY `lib`,
+ ADD KEY `lib` (`lib` (191))
+ |);
+ $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
+ }
+ elsif ( $name eq 'borrower_modifications' ) {
+ $dbh->do(qq|
+ ALTER TABLE $name
+ DROP PRIMARY KEY,
+ DROP KEY `verification_token`,
+ ADD PRIMARY KEY (`verification_token` (191),`borrowernumber`),
+ ADD KEY `verification_token` (`verification_token` (191))
+ |);
+ $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
+ }
+ elsif ( $name eq 'columns_settings' ) {
+ $dbh->do(qq|
+ ALTER TABLE $name
+ DROP PRIMARY KEY,
+ ADD PRIMARY KEY (`module` (191), `page` (191), `tablename` (191), `columnname` (191))
+ |);
+ $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
+ }
+ elsif ( $name eq 'illrequestattributes' ) {
+ $dbh->do(qq|
+ ALTER TABLE $name
+ DROP PRIMARY KEY,
+ ADD PRIMARY KEY (`illrequest_id`, `type` (191))
+ |);
+ $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
+ }
+ elsif ( $name eq 'items_search_fields' ) {
+ $dbh->do(qq|
+ ALTER TABLE $name
+ DROP PRIMARY KEY,
+ ADD PRIMARY KEY (`name` (191))
+ |);
+ $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
+ }
+ elsif ( $name eq 'marc_subfield_structure' ) {
+ # In this case we convert each column explicitly
+ # to preserve 'tagsubield' collation (utf8mb4_bin)
+ $dbh->do(qq|
+ ALTER TABLE $name
+ MODIFY COLUMN tagfield
+ VARCHAR(3) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
+ MODIFY COLUMN tagsubfield
+ VARCHAR(1) COLLATE utf8mb4_bin NOT NULL DEFAULT '',
+ MODIFY COLUMN liblibrarian
+ VARCHAR(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
+ MODIFY COLUMN libopac
+ VARCHAR(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
+ MODIFY COLUMN kohafield
+ VARCHAR(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
+ MODIFY COLUMN authorised_value
+ VARCHAR(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
+ MODIFY COLUMN authtypecode
+ VARCHAR(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
+ MODIFY COLUMN value_builder
+ VARCHAR(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
+ MODIFY COLUMN frameworkcode
+ VARCHAR(4) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
+ MODIFY COLUMN seealso
+ VARCHAR(1100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
+ MODIFY COLUMN link
+ VARCHAR(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
+ MODIFY COLUMN defaultvalue
+ MEDIUMTEXT COLLATE utf8mb4_unicode_ci default NULL
+ |);
+ $dbh->do(qq|ALTER TABLE $name CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
+ }
+ elsif ( $name eq 'plugin_data' ) {
+ $dbh->do(qq|
+ ALTER TABLE $name
+ DROP PRIMARY KEY,
+ ADD PRIMARY KEY (`plugin_class` (191), `plugin_key` (191))
+ |);
+ $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
+ }
+ elsif ( $name eq 'search_field' ) {
+ $dbh->do(qq|
+ ALTER TABLE $name
+ DROP KEY `name`,
+ ADD UNIQUE KEY `name` (`name` (191))
+ |);
+ $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
+ }
+ elsif ( $name eq 'search_marc_map' ) {
+ $dbh->do(qq|
+ ALTER TABLE $name
+ DROP KEY `index_name`,
+ ADD UNIQUE KEY `index_name` (`index_name`, `marc_field` (191), `marc_type`)
+ |);
+ $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
+ }
+ elsif ( $name eq 'sms_providers' ) {
+ $dbh->do(qq|
+ ALTER TABLE $name
+ DROP KEY `name`,
+ ADD UNIQUE KEY `name` (`name` (191))
+ |);
+ $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
+ }
+ elsif ( $name eq 'tags' ) {
+ $dbh->do(qq|
+ ALTER TABLE $name
+ DROP PRIMARY KEY,
+ ADD PRIMARY KEY (`entry` (191))
+ |);
+ $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
+ }
+ elsif ( $name eq 'tags_approval' ) {
+ $dbh->do(qq|
+ ALTER TABLE $name
+ MODIFY COLUMN `term` VARCHAR(191) NOT NULL
+ |);
+ $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
+ }
+ elsif ( $name eq 'tags_index' ) {
+ $dbh->do(qq|
+ ALTER TABLE $name
+ MODIFY COLUMN `term` VARCHAR(191) NOT NULL
+ |);
+ $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
+ }
+ else {
+ $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
+ }
+ }
+ }
+ $dbh->do(q|SET foreign_key_checks = 1|);
+
+ print "Upgrade to $DBversion done (Bug 18336 - Convert DB tables to utf8mb4 🎁)\n";
+ SetVersion($DBversion);
+}
+
+
+$DBversion = '17.12.00.017';
+if( CheckVersion( $DBversion ) ) {
+
+ if( !column_exists( 'items', 'damaged_on' ) ) {
+ $dbh->do( "ALTER TABLE items ADD COLUMN damaged_on DATETIME NULL AFTER damaged");
+ }
+ if( !column_exists( 'deleteditems', 'damaged_on' ) ) {
+ $dbh->do( "ALTER TABLE deleteditems ADD COLUMN damaged_on DATETIME NULL AFTER damaged");
+ }
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 17672 - Add damaged_on to items and deleteditems tables)\n";
+}
+
+$DBversion = '17.12.00.018';
+if( CheckVersion( $DBversion ) ) {
+
+ $dbh->do( q|
+ INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('BrowseResultSelection','0',NULL,'Enable/Disable browsing search results fromt the bibliographic record detail page in staff client','YesNo')
+ |);
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 19290 - Add system preference BrowseResultSelection)\n";
+}
+
+$DBversion = '17.12.00.019';
+if( CheckVersion( $DBversion ) ) {
+
+ $dbh->do(q|UPDATE auth_subfield_structure SET hidden=1 WHERE hidden<>0|);
+
+ 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";
+}
+
# SEE bug 13068
# if there is anything in the atomicupdate, read and execute it.