From 04bf845e149c0c317ca20a3e4e92eddaef1dbc46 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. --- C4/Items.pm | 3 ++- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 9 +++++++++ .../en/modules/admin/preferences/searching.pref | 8 ++++++++ 4 files changed, 20 insertions(+), 1 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index dbd06b6..60258e9 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -1203,6 +1203,7 @@ sub GetItemsInfo { my ( $biblionumber ) = @_; my $dbh = C4::Context->dbh; # note biblioitems.* must be avoided to prevent large marc and marcxml fields from killing performance. + my $branch = C4::Context->preference("DefaultItemSortOrder") || 'home'; my $query = " SELECT items.*, biblio.*, @@ -1230,7 +1231,7 @@ sub GetItemsInfo { LEFT JOIN biblioitems ON biblioitems.biblioitemnumber = items.biblioitemnumber LEFT JOIN itemtypes ON itemtypes.itemtype = " . (C4::Context->preference('item-level_itypes') ? 'items.itype' : 'biblioitems.itemtype'); - $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($biblionumber); my $i = 0; diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 7e9f43d..8c2fad9 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -408,3 +408,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('NotesBlacklist','','List of notes fields that should not appear in the title notes/description separator of details',NULL,'free'); INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('SCOUserCSS', '', NULL, 'Add CSS to be included in the SCO module in an embedded