X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=C4%2FItems.pm;h=ccf8b0563bb4cf05d8d7e01da143ef790361004e;hb=64720c381f2628e6a71b78a492f67cd0e53fd913;hp=61126d9588981d299a54034d25bf6499d1e16cf8;hpb=079b5e0efdb002261a081906c9de46660fa4ecb3;p=koha.git diff --git a/C4/Items.pm b/C4/Items.pm index 61126d9588..ccf8b0563b 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -1267,11 +1267,12 @@ sub GetItemsInfo { items.notforloan as itemnotforloan, itemtypes.description FROM items + LEFT JOIN branches ON items.homebranch = branches.branchcode LEFT JOIN biblio ON biblio.biblionumber = items.biblionumber 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 items.dateaccessioned desc" ; + $query .= " WHERE items.biblionumber = ? ORDER BY branches.branchname,items.dateaccessioned desc" ; my $sth = $dbh->prepare($query); $sth->execute($biblionumber); my $i = 0; @@ -2031,8 +2032,11 @@ Returns undef if the move failed or the biblionumber of the destination record o sub MoveItemFromBiblio { my ($itemnumber, $frombiblio, $tobiblio) = @_; my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare("UPDATE items SET biblioitemnumber = ?, biblionumber = ? WHERE itemnumber = ? AND biblionumber = ?"); - my $return = $sth->execute($tobiblio, $tobiblio, $itemnumber, $frombiblio); + my $sth = $dbh->prepare("SELECT biblioitemnumber FROM biblioitems WHERE biblionumber = ?"); + $sth->execute( $tobiblio ); + my ( $tobiblioitem ) = $sth->fetchrow(); + $sth = $dbh->prepare("UPDATE items SET biblioitemnumber = ?, biblionumber = ? WHERE itemnumber = ? AND biblionumber = ?"); + my $return = $sth->execute($tobiblioitem, $tobiblio, $itemnumber, $frombiblio); if ($return == 1) { # Getting framework