Bug 13881: DBRev 19.12.00.054
[koha-ffzg.git] / installer / data / mysql / updatedatabase.pl
index 453d425..0f51b28 100755 (executable)
@@ -21211,6 +21211,82 @@ if( CheckVersion( $DBversion ) ) {
     NewVersion( $DBversion, 24854, "Remove IDreamBooks* system preferences");
 }
 
+$DBversion = '19.12.00.051';
+if( CheckVersion( $DBversion ) ) {
+    $dbh->do(q{
+        UPDATE systempreferences SET options = 'itemhomebranch|patronhomebranch|checkoutbranch|none' WHERE variable='OpacRenewalBranch'
+    });
+    $dbh->do(q{
+        UPDATE systempreferences SET value = "none" WHERE variable='OpacRenewalBranch'
+        AND value = 'NULL'
+    });
+    $dbh->do(q{
+        UPDATE systempreferences SET value = 'opacrenew' WHERE variable='OpacRenewalBranch'
+        AND value NOT IN ('checkoutbranch','itemhomebranch','opacrenew','patronhomebranch','none')
+    });
+
+    NewVersion( $DBversion, 24759, "Cleanup OpacRenewalBranch");
+}
+
+$DBversion = '19.12.00.052';
+if( CheckVersion( $DBversion ) ) {
+    if( !column_exists( 'itemtypes', 'rentalcharge_daily_calendar' ) ) {
+        $dbh->do(q{
+            ALTER TABLE itemtypes ADD COLUMN
+            rentalcharge_daily_calendar tinyint(1) NOT NULL DEFAULT 1
+            AFTER rentalcharge_daily;
+        });
+    }
+
+    if( !column_exists( 'itemtypes', 'rentalcharge_hourly_calendar' ) ) {
+        $dbh->do(q{
+            ALTER TABLE itemtypes ADD COLUMN
+            rentalcharge_hourly_calendar tinyint(1) NOT NULL DEFAULT 1
+            AFTER rentalcharge_hourly;
+        });
+    }
+
+    my $finesCalendar = C4::Context->preference('finesCalendar');
+    my $value = $finesCalendar eq 'noFinesWhenClosed' ? 1 : 0;
+    $dbh->do("UPDATE itemtypes SET rentalcharge_hourly_calendar = $value, rentalcharge_daily_calendar = $value");
+
+    NewVersion( $DBversion, 21443, "Add ability to exclude holidays when calculating rentals fees by time period");
+}
+
+$DBversion = '19.12.00.053';
+if( CheckVersion( $DBversion ) ) {
+    unless( column_exists('borrowers','autorenew_checkouts') ){
+        $dbh->do( "ALTER TABLE borrowers ADD COLUMN autorenew_checkouts TINYINT(1) NOT NULL DEFAULT 1 AFTER anonymized" );
+    }
+    unless( column_exists('deletedborrowers','autorenew_checkouts') ){
+        $dbh->do( "ALTER TABLE deletedborrowers ADD COLUMN autorenew_checkouts TINYINT(1) NOT NULL DEFAULT 1 AFTER anonymized" );
+    }
+    $dbh->do(q{
+        INSERT IGNORE INTO systempreferences
+        ( `variable`, `value`, `options`, `explanation`, `type` )
+        VALUES
+        ('AllowPatronToControlAutorenewal','0',NULL,'If enabled, patrons will have a field in their account to choose whether their checkouts are auto renewed or not','YesNo')
+    });
+
+    NewVersion( $DBversion, 24476, "Allow patrons to opt-out of autorenewal");
+}
+
+$DBversion = '19.12.00.054';
+if( CheckVersion( $DBversion ) ) {
+    $dbh->do(qq{
+             CREATE TABLE desks ( -- desks available in a library
+             desk_id int(11) NOT NULL auto_increment, -- unique identifier added by Koha
+             desk_name varchar(100) NOT NULL default '', -- name of the desk
+             branchcode varchar(10) NOT NULL,       -- library the desk is located at
+             PRIMARY KEY  (desk_id),
+             KEY `fk_desks_branchcode` (branchcode),
+             CONSTRAINT `fk_desks_branchcode` FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE
+             ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+    });
+
+    NewVersion( $DBversion, 13881, "Add desk management");
+}
+
 # SEE bug 13068
 # if there is anything in the atomicupdate, read and execute it.
 my $update_dir = C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate/';
@@ -21306,8 +21382,7 @@ sub NewVersion {
         $descriptions = [ $descriptions ];
     }
     my $first = 1;
-    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
-    my $time = sprintf ( "%02d:%02d:%02d", $hour,$min,$sec);
+    my $time = POSIX::strftime("%H:%M:%S",localtime);
     for my $description ( @$descriptions ) {
         if ( @$descriptions > 1 ) {
             if ( $first ) {
@@ -21317,7 +21392,7 @@ sub NewVersion {
                     say sprintf "Upgrade to %s done [%s]: Bug %5s - %s", $DBversion, $time, $bug_number, $description;
                 }
             }
-            say sprintf "\t\t\t\t\t- %s", $description;
+            say sprintf "\t\t\t\t\t\t   - %s", $description;
         } else {
             unless ( $bug_number ) {
                 say sprintf "Upgrade to %s done [%s]: %s", $DBversion, $time, $description;