Fix for bug 1552, fix ordering of issued items
authorChris Cormack <crc@liblime.com>
Sun, 30 Dec 2007 21:36:42 +0000 (15:36 -0600)
committerJoshua Ferraro <jmf@liblime.com>
Sun, 30 Dec 2007 22:24:27 +0000 (16:24 -0600)
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
admin/systempreferences.pl
circ/circulation.pl
installer/data/mysql/en/mandatory/sysprefs.sql
installer/data/mysql/updatedatabase.pl
kohaversion.pl

index 5a42e76..f3986ad 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 
-#script to administer the systempref table
-#written 20/02/2002 by paul.poulain@free.fr
+# script to administer the systempref table
+# written 20/02/2002 by paul.poulain@free.fr
 # This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html)
 
 # Copyright 2000-2002 Katipo Communications
@@ -136,6 +136,9 @@ my %tabsysprefs;
     $tabsysprefs{WebBasedSelfCheck}="Circulation";
     $tabsysprefs{CircControl}="Circulation";
     $tabsysprefs{finesCalendar}="Circulation";
+    $tabsysprefs{previousIssuesDefaultSortOrder}="Circulation";
+    $tabsysprefs{todaysIssuesDefaultSortOrder}="Circulation";
+
 # Staff Client
     $tabsysprefs{TemplateEncoding}="StaffClient";
     $tabsysprefs{template}="StaffClient";
@@ -281,7 +284,7 @@ sub StringSearch  {
         $sth->finish;
 
     }  elsif ($type){
-        foreach my $syspref (sort keys %tabsysprefs){
+        foreach my $syspref (sort { lc $a cmp lc $b } keys %tabsysprefs){
             if ($tabsysprefs{$syspref} eq $type){
                 my $sth=$dbh->prepare("Select variable,value,explanation,type,options from systempreferences where (variable like ?) order by variable");
                 $sth->execute($syspref);
index e3f7965..adeeba7 100755 (executable)
@@ -439,11 +439,22 @@ if ($borrower) {
             push @previousissues, $it;
         }
     }
-    @todaysissues   = sort { $b->{'timestamp'} <=> $a->{'timestamp'} } @todaysissues;
-    @previousissues = sort { $b->{'date_due' } <=> $a->{'date_due' } } @previousissues;
+       if (C4::Context->preference("todaysIssuesDefaultSortOrder") eq 'asc'){
+               @todaysissues   = sort { $a->{'timestamp'} cmp $b->{'timestamp'} } @todaysissues;
+       }
+       else {
+               @todaysissues   = sort { $b->{'timestamp'} cmp $a->{'timestamp'} } @todaysissues;
+       }
+       if (C4::Context->preference("previousIssuesDefaultSortOrder") eq 'asc'){
+               @previousissues = sort { $a->{'date_due' } cmp $b->{'date_due' } } @previousissues;
+       }
+       else {
+               @previousissues = sort { $b->{'date_due' } cmp $a->{'date_due' } } @previousissues;
+       }
     my $i = 1;
        foreach my $book (@todaysissues) {
         $book->{'togglecolor'} = (++$i % 2) ? 0 : 1 ;
+               warn $book->{'timestamp'};
     }
     $i = 1;
        foreach my $book (@previousissues) {
index c050cec..d33b877 100644 (file)
@@ -164,6 +164,8 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('uppercasesurnames',0,'If ON, surnames are converted to upper case in patron entry form',NULL,'YesNo');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('CircControl',"ItemHomeLibrary",'Specify the agency that controls the circulation and fines policy',"PickupLibrary|PatronLibrary|ItemHomeLibrary",'Choice');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('finesCalendar',"noFinesWhenClosed",'Specify whether to use the Calendar in calculating duedates and fines',"ignoreCalendar|noFinesWhenClosed",'Choice');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('previousIssuesDefaultSortOrder',"asc",'Specify the sort order of Previous Issues on the circulation page',"asc|desc",'Choice');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('todaysIssuesDefaultSortOrder',"desc",'Specify the sort order of Todays Issues on the circulation page',"asc|desc",'Choice');
 
 
 
index 0a7393e..a994352 100755 (executable)
@@ -812,6 +812,14 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     SetVersion ($DBversion);
 }
 
+$DBversion = "3.00.00.040";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+       $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('previousIssuesDefaultSortOrder','asc','Specify the sort order of Previous Issues on the circulation page','asc|desc','Choice')");
+       $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('todaysIssuesDefaultSortOrder','desc','Specify the sort order of Todays Issues on the circulation page','asc|desc','Choice')");
+       print "Upgrade to $DBversion done ('add circ sysprefs todaysIssuesDefaultSortOrder and previousIssuesDefaultSortOrder.')\n";
+    SetVersion ($DBversion);
+}
+
 
 =item DropAllForeignKeys($table)
 
index 7eaa074..2a7fdd8 100644 (file)
@@ -10,7 +10,7 @@
 use strict;
 
 sub kohaversion {
-    our $VERSION = "3.00.00.039";
+    our $VERSION = "3.00.00.040";
     # version needs to be set this way
     # so that it can be picked up by Makefile.PL
     # during install