From af6207fd04040ce427549d36d4819a909724cf8d Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 29 Mar 2012 09:54:38 -0400 Subject: [PATCH] Bug 3521 - Items table in catalogue/detail.pl and cataloguing/additem.pl is sorted nonsensically Based on patch submitted by Ian Walls Items were sorted by branch, then date accessioned, in GetItemsInfo. While this can be helpful in some circumstances, more often it is useful for items to be sorted first by their enumchron (volume/issue, if applicable) then by their copy number. This patch changes the sort on GetItemsInfo to branch, enumcrhon, copynumber then date accessioned. As sorting on copynumber will be incorrect based on standard sorting ( e.g. 1, 10, 2, 20 ), the copynumber is now padded with leading zeros to correct the sorting ( e.g. 01, 02, 10 20 ). This function appears to be a standard SQL function and not a mysql-ism. I have verfified that is available in MySQL, Postgres, and Oracle. Signed-off-by: Liz Rea Passed t xt Item sorts appear to be correct to me based on the rubric of branch, enumchron, copynumber, then date accessioned. Signed-off-by: Paul Poulain Signed-off-by: Chris Cormack Signed-off-by: Jared Camins-Esakov --- C4/Items.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C4/Items.pm b/C4/Items.pm index 3a8b7207ff..9067f3b879 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -1193,7 +1193,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.dateaccessioned desc" ; + $query .= " WHERE items.biblionumber = ? ORDER BY home.branchname, items.enumchron, LPAD( items.copynumber, 8, '0' ), items.dateaccessioned DESC" ; my $sth = $dbh->prepare($query); $sth->execute($biblionumber); my $i = 0; -- 2.39.5