X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=circ%2Freturns.pl;h=5927759c3757fd4dff9e10be10f7352e320ba905;hb=a16a75018063477cf13fdbdad60152bbb27a7616;hp=8ff9350da7df394f1d8111e78a000dcac3e287ae;hpb=aafe73eefb5151454fa8957bf188768324d23955;p=srvgit diff --git a/circ/returns.pl b/circ/returns.pl index 8ff9350da7..5927759c37 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -44,9 +44,10 @@ 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::AuthorisedValues; use Koha::DateUtils; use Koha::Calendar; @@ -75,14 +76,13 @@ if ($session->param('branch') eq 'NO_LIBRARY_SET'){ if ( $query->param('print_slip') ) { $template->param( print_slip => 1, - borrowernumber => $query->param('borrowernumber'), - biblionumber => $query->param('biblionumber'), + borrowernumber => scalar $query->param('borrowernumber'), + biblionumber => scalar $query->param('biblionumber'), ); } ##################### #Global vars -my $branches = GetBranches(); my $printers = GetPrinters(); my $userenv = C4::Context->userenv; my $userenv_branch = $userenv->{'branch'} // ''; @@ -142,10 +142,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 +153,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,12 +171,12 @@ if ( $query->param('resbarcode') ) { itemnumber => $iteminfo->{'itemnumber'}, itembiblionumber => $iteminfo->{'biblionumber'}, iteminfo => $iteminfo->{'author'}, - tobranchname => GetBranchName($messages->{'transfert'}), name => $name, borrowernumber => $borrowernumber, borcnum => $borr->{'cardnumber'}, borfirstname => $borr->{'firstname'}, borsurname => $borr->{'surname'}, + borcategory => $borr->{'description'}, diffbranch => 1, ); } @@ -249,6 +249,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'); @@ -266,7 +267,7 @@ if ($barcode) { # Check if we should display a checkin message, based on the the item # type of the checked in item my $itemtype = Koha::ItemTypes->find( $biblio->{'itemtype'} ); - if ( $itemtype->checkinmsg ) { + if ( $itemtype && $itemtype->checkinmsg ) { $template->param( checkinmsg => $itemtype->checkinmsg, checkinmsgtype => $itemtype->checkinmsgtype, @@ -274,8 +275,12 @@ if ($barcode) { } # make sure return branch respects home branch circulation rules, default to homebranch - my $hbr = GetBranchItemRule($biblio->{'homebranch'}, $itemtype->itemtype)->{'returnbranch'} || "homebranch"; - my $returnbranch = $biblio->{$hbr} ; + my $hbr = GetBranchItemRule($biblio->{'homebranch'}, $itemtype ? $itemtype->itemtype : undef )->{'returnbranch'} || "homebranch"; + $returnbranch = $biblio->{$hbr}; + + my $materials = $biblio->{'materials'}; + my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => '', kohafield =>'items.materials', authorised_value => $materials }); + $materials = $descriptions->{lib} // ''; $template->param( title => $biblio->{'title'}, @@ -289,7 +294,7 @@ if ($barcode) { itembiblionumber => $biblio->{'biblionumber'}, biblionumber => $biblio->{'biblionumber'}, borrower => $borrower, - additional_materials => $biblio->{'materials'}, + additional_materials => $materials, ); my %input = ( @@ -343,6 +348,11 @@ if ($barcode) { ); } } + } elsif ( C4::Context->preference('ShowAllCheckins') and !$messages->{'BadBarcode'} ) { + $input{duedate} = 0; + $returneditems{0} = $barcode; + $riduedate{0} = 0; + push( @inputloop, \%input ); } $template->param( privacy => $borrower->{privacy} ); } @@ -389,13 +399,13 @@ 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( wname => $name, wborfirstname => $borr->{'firstname'}, wborsurname => $borr->{'surname'}, + wborcategory => $borr->{'description'}, wbortitle => $borr->{'title'}, wborphone => $borr->{'phone'}, wboremail => $borr->{'email'}, @@ -415,9 +425,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( @@ -427,7 +436,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, ); } @@ -435,11 +444,10 @@ 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'}, + borcategory => $borr->{'description'}, bortitle => $borr->{'title'}, borphone => $borr->{'phone'}, boremail => $borr->{'email'}, @@ -456,6 +464,7 @@ if ( $messages->{'ResFound'}) { borrowernumber => $reserve->{'borrowernumber'}, itemnumber => $reserve->{'itemnumber'}, reservenotes => $reserve->{'reservenotes'}, + bormessagepref => $holdmsgpreferences->{'transports'}, ); } # else { ; } # error? } @@ -472,7 +481,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; @@ -499,8 +508,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' ) { @@ -543,7 +551,8 @@ $template->param( errmsgloop => \@errmsgloop ); my $returned_counter = ( C4::Context->preference('numReturnedItemsToShow') ) ? C4::Context->preference('numReturnedItemsToShow') : 8; my $count = 0; my @riloop; -my $shelflocations = GetKohaAuthorisedValues('items.location',''); +my $shelflocations = + { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' } ) }; foreach ( sort { $a <=> $b } keys %returneditems ) { my %ri; if ( $count++ < $returned_counter ) { @@ -583,10 +592,12 @@ foreach ( sort { $a <=> $b } keys %returneditems ) { $ri{itemtitle} = $biblio->{'title'}; $ri{itemauthor} = $biblio->{'author'}; $ri{itemcallnumber} = $biblio->{'itemcallnumber'}; + $ri{dateaccessioned} = $item->{dateaccessioned}; $ri{itemtype} = $biblio->{'itemtype'}; $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'}; @@ -602,18 +613,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, @@ -627,14 +629,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), - ); + my ( $holdingBranch, $collectionBranch ) = GetCollectionItemBranches( $itemnumber ); + if ( $holdingBranch and $collectionBranch ) { + $holdingBranch //= ''; + $collectionBranch //= $returnbranch; + if ( ! ( $holdingBranch eq $collectionBranch ) ) { + $template->param( + collectionItemNeedsTransferred => 1, + collectionBranch => $collectionBranch, + itemnumber => $itemnumber, + ); + } } }