X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=circ%2Freturns.pl;h=0f227dd3a21f4d3a0751b0ed43e995275a2dc2e2;hb=df97814f3034a3d5015546c4eca21f08ae951e37;hp=fe8fb5028a25de760ce7e63d5f716833bf913657;hpb=d31145ffccaeed7158163953b86f5640e646d2b0;p=srvgit diff --git a/circ/returns.pl b/circ/returns.pl index fe8fb5028a..0f227dd3a2 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -44,7 +44,7 @@ use C4::Reserves; use C4::Biblio; use C4::Items; use C4::Members; -use C4::Branch; # GetBranches GetBranchName +use C4::Members::Messaging; use C4::Koha; # FIXME : is it still useful ? use C4::RotatingCollections; use Koha::DateUtils; @@ -82,7 +82,6 @@ if ( $query->param('print_slip') ) { ##################### #Global vars -my $branches = GetBranches(); my $printers = GetPrinters(); my $userenv = C4::Context->userenv; my $userenv_branch = $userenv->{'branch'} // ''; @@ -142,10 +141,10 @@ if ($query->param('WT-itemNumber')){ updateWrongTransfer ($query->param('WT-itemNumber'),$query->param('WT-waitingAt'),$query->param('WT-From')); } -if ( $query->param('resbarcode') ) { +if ( $query->param('reserve_id') ) { my $item = $query->param('itemnumber'); my $borrowernumber = $query->param('borrowernumber'); - my $resbarcode = $query->param('resbarcode'); + my $reserve_id = $query->param('reserve_id'); my $diffBranchReturned = $query->param('diffBranch'); my $iteminfo = GetBiblioFromItemNumber($item); my $cancel_reserve = $query->param('cancel_reserve'); @@ -153,12 +152,12 @@ if ( $query->param('resbarcode') ) { $iteminfo->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $iteminfo->{'itype'} : $iteminfo->{'itemtype'}; if ( $cancel_reserve ) { - CancelReserve({ borrowernumber => $borrowernumber, itemnumber => $item, charge_cancel_fee => !$forgivemanualholdsexpire }); + CancelReserve({ reserve_id => $reserve_id, charge_cancel_fee => !$forgivemanualholdsexpire }); } else { my $diffBranchSend = ($userenv_branch ne $diffBranchReturned) ? $diffBranchReturned : undef; # diffBranchSend tells ModReserveAffect whether document is expected in this library or not, # i.e., whether to apply waiting status - ModReserveAffect( $item, $borrowernumber, $diffBranchSend); + ModReserveAffect( $item, $borrowernumber, $diffBranchSend, $reserve_id ); } # check if we have other reserves for this document, if we have a return send the message of transfer my ( $messages, $nextreservinfo ) = GetOtherReserves($item); @@ -171,7 +170,6 @@ if ( $query->param('resbarcode') ) { itemnumber => $iteminfo->{'itemnumber'}, itembiblionumber => $iteminfo->{'biblionumber'}, iteminfo => $iteminfo->{'author'}, - tobranchname => GetBranchName($messages->{'transfert'}), name => $name, borrowernumber => $borrowernumber, borcnum => $borr->{'cardnumber'}, @@ -249,6 +247,7 @@ if ($canceltransfer){ } # actually return book and prepare item table..... +my $returnbranch; if ($barcode) { $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace $barcode = barcodedecode($barcode) if C4::Context->preference('itemBarcodeInputFilter'); @@ -275,7 +274,7 @@ if ($barcode) { # make sure return branch respects home branch circulation rules, default to homebranch my $hbr = GetBranchItemRule($biblio->{'homebranch'}, $itemtype ? $itemtype->itemtype : undef )->{'returnbranch'} || "homebranch"; - my $returnbranch = $biblio->{$hbr} ; + $returnbranch = $biblio->{$hbr}; my $materials = $biblio->{'materials'}; my $avcode = GetAuthValCode('items.materials'); @@ -400,7 +399,6 @@ if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) { ); my $reserve = $messages->{'ResFound'}; - my $branchname = $branches->{ $reserve->{'branchcode'} }->{'branchname'}; my $borr = C4::Members::GetMember( borrowernumber => $reserve->{'borrowernumber'} ); my $name = $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'}; $template->param( @@ -426,9 +424,8 @@ if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) { # if ( $messages->{'ResFound'}) { my $reserve = $messages->{'ResFound'}; - my $branchname = $branches->{ $reserve->{'branchcode'} }->{'branchname'}; my $borr = C4::Members::GetMember( borrowernumber => $reserve->{'borrowernumber'} ); - + my $holdmsgpreferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $reserve->{'borrowernumber'}, message_name => 'Hold_Filled' } ); if ( $reserve->{'ResFound'} eq "Waiting" or $reserve->{'ResFound'} eq "Reserved" ) { if ( $reserve->{'ResFound'} eq "Waiting" ) { $template->param( @@ -438,7 +435,7 @@ if ( $messages->{'ResFound'}) { $template->param( intransit => ($userenv_branch eq $reserve->{'branchcode'} ? 0 : 1 ), transfertodo => ($userenv_branch eq $reserve->{'branchcode'} ? 0 : 1 ), - resbarcode => $barcode, + reserve_id => $reserve->{reserve_id}, reserved => 1, ); } @@ -446,8 +443,6 @@ if ( $messages->{'ResFound'}) { # same params for Waiting or Reserved $template->param( found => 1, - currentbranch => $branches->{$userenv_branch}->{'branchname'}, - destbranchname => $branches->{ $reserve->{'branchcode'} }->{'branchname'}, name => $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'}, borfirstname => $borr->{'firstname'}, borsurname => $borr->{'surname'}, @@ -467,6 +462,7 @@ if ( $messages->{'ResFound'}) { borrowernumber => $reserve->{'borrowernumber'}, itemnumber => $reserve->{'itemnumber'}, reservenotes => $reserve->{'reservenotes'}, + bormessagepref => $holdmsgpreferences->{'transports'}, ); } # else { ; } # error? } @@ -483,7 +479,7 @@ foreach my $code ( keys %$messages ) { elsif ( $code eq 'NotIssued' ) { $err{notissued} = 1; $err{msg} = ''; - $err{msg} = $branches->{ $messages->{'IsPermanent'} }->{'branchname'} if $messages->{'IsPermanent'}; + $err{msg} = $messages->{'IsPermanent'} if $messages->{'IsPermanent'}; } elsif ( $code eq 'LocalUse' ) { $err{localuse} = 1; @@ -510,8 +506,7 @@ foreach my $code ( keys %$messages ) { elsif ( ( $code eq 'IsPermanent' ) && ( not $messages->{'ResFound'} ) ) { if ( $messages->{'IsPermanent'} ne $userenv_branch ) { $err{ispermanent} = 1; - $err{msg} = - $branches->{ $messages->{'IsPermanent'} }->{'branchname'}; + $err{msg} = $messages->{'IsPermanent'}; } } elsif ( $code eq 'WrongTransfer' ) { @@ -599,6 +594,7 @@ foreach ( sort { $a <=> $b } keys %returneditems ) { $ri{itemnote} = $biblio->{'itemnotes'}; $ri{itemnotes_nonpublic} = $item->{'itemnotes_nonpublic'}; $ri{ccode} = $biblio->{'ccode'}; + $ri{enumchron} = $biblio->{'enumchron'}; $ri{itemnumber} = $biblio->{'itemnumber'}; $ri{barcode} = $bar_code; $ri{homebranch} = $item->{'homebranch'}; @@ -614,18 +610,9 @@ foreach ( sort { $a <=> $b } keys %returneditems ) { } push @riloop, \%ri; } -my ($genbrname, $genprname); -if (my $b = $branches->{$userenv_branch}) { - $genbrname = $b->{'branchname'}; -} -if (my $p = $printers->{$printer}) { - $genprname = $p->{'printername'}; -} + $template->param( riloop => \@riloop, - genbrname => $genbrname, - genprname => $genprname, - branchname => $genbrname, printer => $printer, errmsgloop => \@errmsgloop, exemptfine => $exemptfine, @@ -639,15 +626,17 @@ $template->param( $itemnumber = GetItemnumberFromBarcode( $barcode ); if ( $itemnumber ) { - my ( $holdingBranch, $collectionBranch ) = GetCollectionItemBranches( $itemnumber ); - $holdingBranch //= ''; - $collectionBranch //= ''; - if ( ! ( $holdingBranch eq $collectionBranch ) ) { - $template->param( - collectionItemNeedsTransferred => 1, - collectionBranch => GetBranchName($collectionBranch), - itemnumber => $itemnumber, - ); + my ( $holdingBranch, $collectionBranch ) = GetCollectionItemBranches( $itemnumber ); + if ( $holdingBranch and $collectionBranch ) { + $holdingBranch //= ''; + $collectionBranch //= $returnbranch; + if ( ! ( $holdingBranch eq $collectionBranch ) ) { + $template->param( + collectionItemNeedsTransferred => 1, + collectionBranch => $collectionBranch, + itemnumber => $itemnumber, + ); + } } }