View | Details | Raw Unified | Return to bug 10827
Collapse All | Expand All

(-)a/C4/Reserves.pm (-4 / +22 lines)
Lines 1228-1234 sub ModReserveStatus { Link Here
1228
1228
1229
=head2 ModReserveAffect
1229
=head2 ModReserveAffect
1230
1230
1231
  &ModReserveAffect({ itemnumber => $itemnumber, borrowernumber => $borrowernumber, force_transfer => $diffBranchSend });
1231
  &ModReserveAffect({ item => $item, itemnumber => $itemnumber, borrowernumber => $borrowernumber, force_transfer => $diffBranchSend });
1232
1232
1233
This function affect an item and a status for a given reserve
1233
This function affect an item and a status for a given reserve
1234
The itemnumber parameter is used to find the biblionumber.
1234
The itemnumber parameter is used to find the biblionumber.
Lines 1243-1252 take care of the waiting status Link Here
1243
1243
1244
sub ModReserveAffect {
1244
sub ModReserveAffect {
1245
    my ( $params ) = @_;
1245
    my ( $params ) = @_;
1246
    my $item = $params->{item};
1246
    my $borrowernumber = $params->{borrowernumber};
1247
    my $borrowernumber = $params->{borrowernumber};
1247
    my $itemnumber = $params->{itemnumber};
1248
    my $itemnumber = $params->{itemnumber};
1248
    my $force_transfer = $params->{force_transfer};
1249
    my $force_transfer = $params->{force_transfer};
1249
1250
1251
    if ( $item ) {
1252
        $itemnumber = $item->{itemnumber};
1253
    } else {
1254
        $item = GetBiblioFromItemNumber( $itemnumber );
1255
    }
1256
1250
    my $dbh = C4::Context->dbh;
1257
    my $dbh = C4::Context->dbh;
1251
1258
1252
    # we want to attach $itemnumber to $borrowernumber, find the biblionumber
1259
    # we want to attach $itemnumber to $borrowernumber, find the biblionumber
Lines 1265-1273 sub ModReserveAffect { Link Here
1265
    my $request = GetReserveInfo($reserve_id);
1272
    my $request = GetReserveInfo($reserve_id);
1266
    my $already_on_shelf = ($request && $request->{found} eq 'W') ? 1 : 0;
1273
    my $already_on_shelf = ($request && $request->{found} eq 'W') ? 1 : 0;
1267
1274
1275
    my $transfer_to_do = 0;
1276
    if ( defined $force_transfer ) {
1277
        $transfer_to_do = $force_transfer;
1278
    } else {
1279
        my $userenv_branch = C4::Context->userenv->{'branch'} || '';
1280
        $transfer_to_do = 1
1281
            if $userenv_branch ne $request->{branchcode};
1282
    }
1283
1268
    # If we affect a reserve that has to be transfered, don't set to Waiting
1284
    # If we affect a reserve that has to be transfered, don't set to Waiting
1269
    my $query;
1285
    my $query;
1270
    if ( $force_transfer ) {
1286
    if ( $transfer_to_do ) {
1271
    $query = "
1287
    $query = "
1272
        UPDATE reserves
1288
        UPDATE reserves
1273
        SET    priority = 0,
1289
        SET    priority = 0,
Lines 1291-1297 sub ModReserveAffect { Link Here
1291
    }
1307
    }
1292
    $sth = $dbh->prepare($query);
1308
    $sth = $dbh->prepare($query);
1293
    $sth->execute( $itemnumber, $borrowernumber,$biblionumber);
1309
    $sth->execute( $itemnumber, $borrowernumber,$biblionumber);
1294
    _koha_notify_reserve( $itemnumber, $borrowernumber, $biblionumber ) if ( !$force_transfer && !$already_on_shelf );
1310
1311
    _koha_notify_reserve( $itemnumber, $borrowernumber, $biblionumber )
1312
        unless $transfer_to_do or $already_on_shelf;
1295
1313
1296
    if ( C4::Context->preference("ReturnToShelvingCart") ) {
1314
    if ( C4::Context->preference("ReturnToShelvingCart") ) {
1297
      CartToShelf( $itemnumber );
1315
      CartToShelf( $itemnumber );
Lines 1727-1733 sub _FixPriority { Link Here
1727
            $priority[$j]->{'reserve_id'}
1745
            $priority[$j]->{'reserve_id'}
1728
        );
1746
        );
1729
    }
1747
    }
1730
    
1748
1731
    $sth = $dbh->prepare( "SELECT reserve_id FROM reserves WHERE lowestPriority = 1 ORDER BY priority" );
1749
    $sth = $dbh->prepare( "SELECT reserve_id FROM reserves WHERE lowestPriority = 1 ORDER BY priority" );
1732
    $sth->execute();
1750
    $sth->execute();
1733
    
1751
    
(-)a/circ/returns.pl (-8 / +6 lines)
Lines 132-150 if ($query->param('WT-itemNumber')){ Link Here
132
}
132
}
133
133
134
if ( $query->param('resbarcode') ) {
134
if ( $query->param('resbarcode') ) {
135
    my $item           = $query->param('itemnumber');
135
    my $itemnumber     = $query->param('itemnumber');
136
    my $borrowernumber = $query->param('borrowernumber');
136
    my $borrowernumber = $query->param('borrowernumber');
137
    my $resbarcode     = $query->param('resbarcode');
137
    my $resbarcode     = $query->param('resbarcode');
138
    my $diffBranchReturned = $query->param('diffBranch');
138
    my $diffBranchReturned = $query->param('diffBranch');
139
    my $iteminfo   = GetBiblioFromItemNumber($item);
139
    my $iteminfo   = GetBiblioFromItemNumber($itemnumber);
140
    # fix up item type for display
140
    # fix up item type for display
141
    $iteminfo->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $iteminfo->{'itype'} : $iteminfo->{'itemtype'};
141
    $iteminfo->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $iteminfo->{'itype'} : $iteminfo->{'itemtype'};
142
    my $diffBranchSend = ($userenv_branch ne $diffBranchReturned) ? $diffBranchReturned : undef;
142
143
# diffBranchSend tells ModReserveAffect whether document is expected in this library or not,
143
    ModReserveAffect({ item => $iteminfo, borrowernumber => $borrowernumber });
144
# i.e., whether to apply waiting status
144
145
    ModReserveAffect({ itemnumber => $item, borrowernumber => $borrowernumber, force_transfer => $diffBranchSend });
146
#   check if we have other reserves for this document, if we have a return send the message of transfer
145
#   check if we have other reserves for this document, if we have a return send the message of transfer
147
    my ( $messages, $nextreservinfo ) = GetOtherReserves($item);
146
    my ( $messages, $nextreservinfo ) = GetOtherReserves($itemnumber);
148
147
149
    my ($borr) = GetMemberDetails( $nextreservinfo, 0 );
148
    my ($borr) = GetMemberDetails( $nextreservinfo, 0 );
150
    my $name   = $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'};
149
    my $name   = $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'};
151
- 

Return to bug 10827