From 57a7c297e694e90a66604d639cee28db04b9196e Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 11 Dec 2012 12:08:14 -0500 Subject: [PATCH] Bug 9264 - Make getitems default sort to set by a preference instead of hard coded to homebranch. The sort order in GetItemsInfo has been switched from home branch to holding branch and then back again at different points in time. Some libraries liked it when it was by holding branch, rather than home branch. This patch makes the choice of sorting by home or holding branch a system preference. Test Plan: 1) Apply patch 2) Run updatedatabase.pl 3) Test the sorting order for items with the preference set each way. NOTE: I only rebased to make it apply. I still think Owen's feedback in comment #4 still applys. Hence the move from 'Patch does not apply' to 'In Discussion'. --- C4/Items.pm | 4 +++- installer/data/mysql/atomicupdate/bug_9264.perl | 9 +++++++++ .../prog/en/modules/admin/preferences/searching.pref | 8 ++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug_9264.perl diff --git a/C4/Items.pm b/C4/Items.pm index 11c6c1d5c4..7192e9d79e 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -706,6 +706,7 @@ sub GetItemsInfo { my $dbh = C4::Context->dbh; require C4::Languages; my $language = C4::Languages::getlanguage(); + my $branch = C4::Context->preference("DefaultItemSortOrder") || 'home'; my $query = " SELECT items.*, biblio.*, @@ -757,7 +758,8 @@ sub GetItemsInfo { AND localization.lang = ? |; - $query .= " WHERE items.biblionumber = ? ORDER BY home.branchname, items.enumchron, LPAD( items.copynumber, 8, '0' ), items.dateaccessioned DESC" ; + $query .= " WHERE items.biblionumber = ? ORDER BY $branch.branchname, items.enumchron, LPAD( items.copynumber, 8, '0' ), items.dateaccessioned DESC" ; + my $sth = $dbh->prepare($query); $sth->execute($language, $biblionumber); my $i = 0; diff --git a/installer/data/mysql/atomicupdate/bug_9264.perl b/installer/data/mysql/atomicupdate/bug_9264.perl new file mode 100644 index 0000000000..fc861ee338 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_9264.perl @@ -0,0 +1,9 @@ +$DBversion = 'XXX'; +if( CheckVersion( $DBversion ) ) { + $dbh->do(q{ + INSERT IGNORE INTO systempreferences + ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES + ('DefaultItemSortOrder', 'home', 'home|holding', 'Define the default sort order for items.', 'Choice' ) + }); + NewVersion( $DBversion, 9264, "Add DefaultItemSortOrder preference"); +} diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref index 25b3878307..1d0af1ce9b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref @@ -283,3 +283,11 @@ Searching: - LIBRIS base URL - pref: LibrisURL - "Please only change this if you are sure it needs changing." + - + - The default sort order for items should be by the item's + - pref: DefaultItemSortOrder + type: choice + default: home + choices: + home: "home library" + holding: "holding library" -- 2.20.1