From bcc60a1117824df604347b69db0e22d6851ee2c7 Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Sun, 30 Dec 2007 15:36:42 -0600 Subject: [PATCH] Fix for bug 1552, fix ordering of issued items Signed-off-by: Joshua Ferraro --- admin/systempreferences.pl | 9 ++++++--- circ/circulation.pl | 15 +++++++++++++-- installer/data/mysql/en/mandatory/sysprefs.sql | 2 ++ installer/data/mysql/updatedatabase.pl | 8 ++++++++ kohaversion.pl | 2 +- 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/admin/systempreferences.pl b/admin/systempreferences.pl index 5a42e768f4..f3986adf89 100755 --- a/admin/systempreferences.pl +++ b/admin/systempreferences.pl @@ -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); diff --git a/circ/circulation.pl b/circ/circulation.pl index e3f79652de..adeeba7a0e 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -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) { diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql b/installer/data/mysql/en/mandatory/sysprefs.sql index c050cec076..d33b8774e9 100644 --- a/installer/data/mysql/en/mandatory/sysprefs.sql +++ b/installer/data/mysql/en/mandatory/sysprefs.sql @@ -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'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 0a7393ecc5..a994352c78 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -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) diff --git a/kohaversion.pl b/kohaversion.pl index 7eaa074e47..2a7fdd8a74 100644 --- a/kohaversion.pl +++ b/kohaversion.pl @@ -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 -- 2.39.5