use C4::Branch;
require C4::Reserves;
use C4::Charset;
+use C4::Acquisition;
use vars qw($VERSION @ISA @EXPORT);
$query .= 'WHERE ';
$query .= join ' AND ', @where_strings;
}
- $query .= ' ORDER BY itemcallnumber, title';
+ $query .= ' ORDER BY items.cn_sort, itemcallnumber, title';
my $sth = $dbh->prepare($query);
$sth->execute( @bind_params );
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;
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
# If we found an item (should always true, except in case of database-marcxml inconsistency)
if ($item) {
+ # Checking if the item we want to move is in an order
+ my $order = GetOrderFromItemnumber($itemnumber);
+ if ($order) {
+ # Replacing the biblionumber within the order if necessary
+ $order->{'biblionumber'} = $tobiblio;
+ ModOrder($order);
+ }
+
# Saving the modification
ModBiblioMarc($record, $frombiblio, $frameworkcode);