From 43ad7fb4dfc1d7f57bac158049e51d4006ef7140 Mon Sep 17 00:00:00 2001 From: tipaul Date: Tue, 17 Apr 2007 16:24:59 +0000 Subject: [PATCH] circulation cleaning continued: working on branchtransfers.pl (unfinished, but at least it compiles... --- C4/Circulation.pm | 261 ++++++++-------- C4/Stats.pm | 202 +------------ circ/branchtransfers.pl | 165 +++-------- .../prog/en/circ/branchtransfers.tmpl | 278 ++++++++++-------- .../intranet-tmpl/prog/en/circ/returns.tmpl | 8 +- 5 files changed, 321 insertions(+), 593 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 66c98fc02c..ebe2e11d95 100755 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -200,39 +200,25 @@ The item was eligible to be transferred. Barring problems communicating with the =cut -#' -# FIXME - This function tries to do too much, and its API is clumsy. -# If it didn't also return books, it could be used to change the home -# branch of a book while the book is on loan. -# -# Is there any point in returning the item information? The caller can -# look that up elsewhere if ve cares. -# -# This leaves the ($dotransfer, $messages) tuple. This seems clumsy. -# If the transfer succeeds, that's all the caller should need to know. -# Thus, this function could simply return 1 or 0 to indicate success -# or failure, and set $C4::Circulation::Circ2::errmsg in case of -# failure. Or this function could return undef if successful, and an -# error message in case of failure (this would feel more like C than -# Perl, though). sub transferbook { my ( $tbr, $barcode, $ignoreRs ) = @_; my $messages; my %env; my $dotransfer = 1; my $branches = GetBranches(); - my $item = GetItemnumberFromBarcode( $barcode ); - my $issue = GetItemIssues($item->{itemnumber}); + my $itemnumber = GetItemnumberFromBarcode( $barcode ); + my $issue = GetItemIssue($itemnumber); + my $biblio = GetBiblioFromItemNumber($itemnumber); # bad barcode.. - if ( not $item ) { + if ( not $itemnumber ) { $messages->{'BadBarcode'} = $barcode; $dotransfer = 0; } # get branches of book... - my $hbr = $item->{'homebranch'}; - my $fbr = $item->{'holdingbranch'}; + my $hbr = $biblio->{'homebranch'}; + my $fbr = $biblio->{'holdingbranch'}; # if is permanent... if ( $hbr && $branches->{$hbr}->{'PE'} ) { @@ -240,7 +226,6 @@ sub transferbook { } # can't transfer book if is already there.... - # FIXME - Why not? Shouldn't it trivially succeed? if ( $fbr eq $tbr ) { $messages->{'DestinationEqualsHolding'} = 1; $dotransfer = 0; @@ -253,10 +238,9 @@ sub transferbook { } # find reserves..... - # FIXME - Don't call &CheckReserves unless $ignoreRs is true. # That'll save a database query. my ( $resfound, $resrec ) = - CheckReserves( $item->{'itemnumber'} ); + CheckReserves( $itemnumber ); if ( $resfound and not $ignoreRs ) { $resrec->{'ResFound'} = $resfound; @@ -266,12 +250,12 @@ sub transferbook { #actually do the transfer.... if ($dotransfer) { - dotransfer( $item->{'itemnumber'}, $fbr, $tbr ); + dotransfer( $itemnumber, $fbr, $tbr ); # don't need to update MARC anymore, we do it in batch now $messages->{'WasTransfered'} = 1; } - return ( $dotransfer, $messages, $item ); + return ( $dotransfer, $messages, $biblio ); } # Not exported @@ -1210,135 +1194,133 @@ patron who last borrowed the book. sub AddReturn { my ( $barcode, $branch ) = @_; - my %env; - my $messages; my $dbh = C4::Context->dbh; + my $messages; my $doreturn = 1; + my $borrower; my $validTransfert = 0; my $reserveDone = 0; - die '$branch not defined' unless defined $branch; # just in case (bug 170) # get information on item my $iteminformation = GetItemIssue( GetItemnumberFromBarcode($barcode)); - if ( not $iteminformation ) { + unless ($iteminformation->{'itemnumber'} ) { $messages->{'BadBarcode'} = $barcode; $doreturn = 0; - } - - # find the borrower - if ( ( not $iteminformation->{borrowernumber} ) && $doreturn ) { - $messages->{'NotIssued'} = $barcode; - $doreturn = 0; - } - - # check if the book is in a permanent collection.... - my $hbr = $iteminformation->{'homebranch'}; - my $branches = GetBranches(); - if ( $hbr && $branches->{$hbr}->{'PE'} ) { - $messages->{'IsPermanent'} = $hbr; - } - - # check that the book has been cancelled - if ( $iteminformation->{'wthdrawn'} ) { - $messages->{'wthdrawn'} = 1; - $doreturn = 0; - } - -# new op dev : if the book returned in an other branch update the holding branch - -# update issues, thereby returning book (should push this out into another subroutine - my ($borrower) = GetMemberDetails( $iteminformation->{borrowernumber}, 0 ); - -# case of a return of document (deal with issues and holdingbranch) - - if ($doreturn) { - my $sth = - $dbh->prepare( -"update issues set returndate = now() where (borrowernumber = ?) and (itemnumber = ?) and (returndate is null)" - ); - $sth->execute( $borrower->{'borrowernumber'}, - $iteminformation->{'itemnumber'} ); - $messages->{'WasReturned'} = 1; # FIXME is the "= 1" right? - } - -# continue to deal with returns cases, but not only if we have an issue - -# the holdingbranch is updated if the document is returned in an other location . -if ( $iteminformation->{'holdingbranch'} ne C4::Context->userenv->{'branch'} ) - { - UpdateHoldingbranch(C4::Context->userenv->{'branch'},$iteminformation->{'itemnumber'}); -# reload iteminformation holdingbranch with the userenv value - $iteminformation->{'holdingbranch'} = C4::Context->userenv->{'branch'}; + } else { + # find the borrower + if ( ( not $iteminformation->{borrowernumber} ) && $doreturn ) { + $messages->{'NotIssued'} = $barcode; + $doreturn = 0; } - ModDateLastSeen( $iteminformation->{'itemnumber'} ); - ($borrower) = GetMemberDetails( $iteminformation->{borrowernumber}, 0 ); - # fix up the accounts..... - if ( $iteminformation->{'itemlost'} ) { - $messages->{'WasLost'} = 1; - } - - # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # - # check if we have a transfer for this document - my ($datesent,$frombranch,$tobranch) = GetTransfers( $iteminformation->{'itemnumber'} ); - - # if we have a transfer to do, we update the line of transfers with the datearrived - if ($datesent) { - if ( $tobranch eq C4::Context->userenv->{'branch'} ) { - my $sth = - $dbh->prepare( - "update branchtransfers set datearrived = now() where itemnumber= ? AND datearrived IS NULL" - ); - $sth->execute( $iteminformation->{'itemnumber'} ); - $sth->finish; -# now we check if there is a reservation with the validate of transfer if we have one, we can set it with the status 'W' - SetWaitingStatus( $iteminformation->{'itemnumber'} ); + # check if the book is in a permanent collection.... + my $hbr = $iteminformation->{'homebranch'}; + my $branches = GetBranches(); + if ( $hbr && $branches->{$hbr}->{'PE'} ) { + $messages->{'IsPermanent'} = $hbr; } - else { - $messages->{'WrongTransfer'} = $tobranch; - $messages->{'WrongTransferItem'} = $iteminformation->{'itemnumber'}; - } - $validTransfert = 1; - } - -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# fix up the overdues in accounts... - fixoverduesonreturn( $borrower->{'borrowernumber'}, - $iteminformation->{'itemnumber'} ); - -# find reserves..... -# if we don't have a reserve with the status W, we launch the Checkreserves routine - my ( $resfound, $resrec ) = - CheckReserves( $iteminformation->{'itemnumber'} ); - if ($resfound) { - $resrec->{'ResFound'} = $resfound; - $messages->{'ResFound'} = $resrec; - $reserveDone = 1; - } - - # update stats? - # Record the fact that this book was returned. - UpdateStats( - \%env, $branch, 'return', '0', '', - $iteminformation->{'itemnumber'}, - $iteminformation->{'itemtype'}, - $borrower->{'borrowernumber'} - ); - &logaction(C4::Context->userenv->{'number'},"CIRCULATION","RETURN",$iteminformation->{borrowernumber},$iteminformation->{'biblionumber'}) - if C4::Context->preference("ReturnLog"); - - #adding message if holdingbranch is non equal a userenv branch to return the document to homebranch - #we check, if we don't have reserv or transfert for this document, if not, return it to homebranch . + # check that the book has been cancelled + if ( $iteminformation->{'wthdrawn'} ) { + $messages->{'wthdrawn'} = 1; + $doreturn = 0; + } - if ( ($iteminformation->{'holdingbranch'} ne $iteminformation->{'homebranch'}) and not $messages->{'WrongTransfer'} and ($validTransfert ne 1) and ($reserveDone ne 1) ){ - if (C4::Context->preference("AutomaticItemReturn") == 1) { - dotransfer($iteminformation->{'itemnumber'}, C4::Context->userenv->{'branch'}, $iteminformation->{'homebranch'}); - $messages->{'WasTransfered'} = 1; - warn "was transfered"; - } - } + # new op dev : if the book returned in an other branch update the holding branch + + # update issues, thereby returning book (should push this out into another subroutine + $borrower = GetMemberDetails( $iteminformation->{borrowernumber}, 0 ); + + # case of a return of document (deal with issues and holdingbranch) + + if ($doreturn) { + my $sth = + $dbh->prepare( + "update issues set returndate = now() where (borrowernumber = ?) and (itemnumber = ?) and (returndate is null)" + ); + $sth->execute( $borrower->{'borrowernumber'}, + $iteminformation->{'itemnumber'} ); + $messages->{'WasReturned'} = 1; # FIXME is the "= 1" right? + } + + # continue to deal with returns cases, but not only if we have an issue + + # the holdingbranch is updated if the document is returned in an other location . + if ( $iteminformation->{'holdingbranch'} ne C4::Context->userenv->{'branch'} ) + { + UpdateHoldingbranch(C4::Context->userenv->{'branch'},$iteminformation->{'itemnumber'}); + # reload iteminformation holdingbranch with the userenv value + $iteminformation->{'holdingbranch'} = C4::Context->userenv->{'branch'}; + } + ModDateLastSeen( $iteminformation->{'itemnumber'} ); + ($borrower) = GetMemberDetails( $iteminformation->{borrowernumber}, 0 ); + + # fix up the accounts..... + if ( $iteminformation->{'itemlost'} ) { + $messages->{'WasLost'} = 1; + } + + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + # check if we have a transfer for this document + my ($datesent,$frombranch,$tobranch) = GetTransfers( $iteminformation->{'itemnumber'} ); + + # if we have a transfer to do, we update the line of transfers with the datearrived + if ($datesent) { + if ( $tobranch eq C4::Context->userenv->{'branch'} ) { + my $sth = + $dbh->prepare( + "update branchtransfers set datearrived = now() where itemnumber= ? AND datearrived IS NULL" + ); + $sth->execute( $iteminformation->{'itemnumber'} ); + $sth->finish; + # now we check if there is a reservation with the validate of transfer if we have one, we can set it with the status 'W' + SetWaitingStatus( $iteminformation->{'itemnumber'} ); + } + else { + $messages->{'WrongTransfer'} = $tobranch; + $messages->{'WrongTransferItem'} = $iteminformation->{'itemnumber'}; + } + $validTransfert = 1; + } + + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + # fix up the overdues in accounts... + fixoverduesonreturn( $borrower->{'borrowernumber'}, + $iteminformation->{'itemnumber'} ); + + # find reserves..... + # if we don't have a reserve with the status W, we launch the Checkreserves routine + my ( $resfound, $resrec ) = + CheckReserves( $iteminformation->{'itemnumber'} ); + if ($resfound) { + $resrec->{'ResFound'} = $resfound; + $messages->{'ResFound'} = $resrec; + $reserveDone = 1; + } + + # update stats? + # Record the fact that this book was returned. + UpdateStats( + $branch, 'return', '0', '', + $iteminformation->{'itemnumber'}, + $iteminformation->{'itemtype'}, + $borrower->{'borrowernumber'} + ); + &logaction(C4::Context->userenv->{'number'},"CIRCULATION","RETURN",$iteminformation->{borrowernumber},$iteminformation->{'biblionumber'}) + if C4::Context->preference("ReturnLog"); + + #adding message if holdingbranch is non equal a userenv branch to return the document to homebranch + #we check, if we don't have reserv or transfert for this document, if not, return it to homebranch . + + if ( ($iteminformation->{'holdingbranch'} ne $iteminformation->{'homebranch'}) and not $messages->{'WrongTransfer'} and ($validTransfert ne 1) and ($reserveDone ne 1) ){ + if (C4::Context->preference("AutomaticItemReturn") == 1) { + dotransfer($iteminformation->{'itemnumber'}, C4::Context->userenv->{'branch'}, $iteminformation->{'homebranch'}); + $messages->{'WasTransfered'} = 1; + warn "was transfered"; + } + } + } return ( $doreturn, $messages, $iteminformation, $borrower ); } @@ -1389,6 +1371,7 @@ Returns an array of hashes sub GetItemIssue { my ( $itemnumber) = @_; + return unless $itemnumber; my $dbh = C4::Context->dbh; my @GetItemIssues; diff --git a/C4/Stats.pm b/C4/Stats.pm index 7190d20422..e4573fb8b2 100644 --- a/C4/Stats.pm +++ b/C4/Stats.pm @@ -50,9 +50,7 @@ the Koha database, which acts as an activity log. =cut @ISA = qw(Exporter); -@EXPORT = qw(&UpdateStats &statsreport &TotalOwing - &TotalPaid &getcharges &Getpaidbranch &unfilledreserves &getcredits - getrefunds); +@EXPORT = qw(&UpdateStats); =item UpdateStats @@ -78,210 +76,22 @@ sub UpdateStats { #module to insert stats data into stats table my ( - $env, $branch, $type, + $branch, $type, $amount, $other, $itemnum, - $itemtype, $borrowernumber, $accountno + $itemtype, $borrowernumber ) = @_; my $dbh = C4::Context->dbh; - if ( $branch eq '' ) { - $branch = $env->{'branchcode'}; - } - my $user = $env->{'usercode'}; - my $organisation = $env->{'organisation'}; - # FIXME - Use $dbh->do() instead my $sth = $dbh->prepare( - "Insert into statistics (datetime,branch,type,usercode,value, - other,itemnumber,itemtype,borrowernumber,proccode,associatedborrower) values (now(),?,?,?,?,?,?,?,?,?,?)" + "Insert into statistics (datetime,branch,type,value, + other,itemnumber,itemtype,borrowernumber) values (now(),?,?,?,?,?,?,?,?)" ); $sth->execute( - $branch, $type, $user, $amount, + $branch, $type, $amount, $other, $itemnum, $itemtype, $borrowernumber, - $accountno, $organisation - ); - $sth->finish; -} - -# Otherwise, it'd need a POD. -sub TotalPaid { - my ( $time, $time2, $spreadsheet ) = @_; - $time2 = $time unless $time2; - my $dbh = C4::Context->dbh; - my $query = "SELECT * FROM statistics,borrowers - WHERE statistics.borrowernumber= borrowers.borrowernumber - AND (statistics.type='payment' OR statistics.type='writeoff') "; - if ( $time eq 'today' ) { - $query = $query . " AND datetime = now()"; - } - else { - $query .= " AND datetime > '$time'"; - } - if ( $time2 ne '' ) { - $query .= " AND datetime < '$time2'"; - } - if ($spreadsheet) { - $query .= " ORDER BY branch, type"; - } - my $sth = $dbh->prepare($query); - $sth->execute(); - my @results; - while ( my $data = $sth->fetchrow_hashref ) { - push @results, $data; - } - $sth->finish; - return (@results); -} - -# Otherwise, it needs a POD. -sub getcharges { - my ( $borrowerno, $timestamp, $accountno ) = @_; - my $dbh = C4::Context->dbh; - my $timestamp2 = $timestamp - 1; - my $query = ""; - my $sth; - - # getcharges is now taking accountno. as an argument - if ($accountno) { - $sth = $dbh->prepare( - "Select * from accountlines where borrowernumber=? - and accountno = ?" - ); - $sth->execute( $borrowerno, $accountno ); - - # this bit left in for old 2 arg usage of getcharges - } - else { - $sth = $dbh->prepare( - "Select * from accountlines where borrowernumber=? - and timestamp = ? and accounttype <> 'Pay' and - accounttype <> 'W'" - ); - $sth->execute( $borrowerno, $timestamp ); - } - - # print $query,"
"; - my $i = 0; - my @results; - while ( my $data = $sth->fetchrow_hashref ) { - - # if ($data->{'timestamp'} == $timestamp){ - $results[$i] = $data; - $i++; - - # } - } - return (@results); -} - -# Otherwise, it needs a POD. -sub getcredits { - my ( $date, $date2 ) = @_; - my $dbh = C4::Context->dbh; - - #takes date converts to timestamps - my $padding = "000000"; - ( my $a, my $b, my $c ) = unpack( "A4 x1 A2 x1 A2", $date ); - ( my $x, my $y, my $z ) = unpack( "A4 x1 A2 x1 A2", $date2 ); - my $timestamp = $a . $b . $c . $padding; - my $timestamp2 = $x . $y . $z . $padding; - - my $sth = $dbh->prepare( -"Select * from accountlines,borrowers where (((accounttype = 'LR') or (accounttype <> 'Pay')) - and amount < 0 and accountlines.borrowernumber = borrowers.borrowernumber - and timestamp >=? and timestamp execute( $timestamp, $timestamp2 ); - - my $i = 0; - my @results; - while ( my $data = $sth->fetchrow_hashref ) { - $results[$i] = $data; - $i++; - } - return (@results); -} - -sub getrefunds { - my ( $date, $date2 ) = @_; - my $dbh = C4::Context->dbh; - - #takes date converts to timestamps - my $padding = "000000"; - ( my $a, my $b, my $c ) = unpack( "A4 x1 A2 x1 A2", $date ); - ( my $x, my $y, my $z ) = unpack( "A4 x1 A2 x1 A2", $date2 ); - my $timestamp = $a . $b . $c . $padding; - my $timestamp2 = $x . $y . $z . $padding; - - my $sth = $dbh->prepare( -"Select * from accountlines,borrowers where (accounttype = 'REF' - and accountlines.borrowernumber = borrowers.borrowernumber - and timestamp >=? and timestamp execute( $timestamp, $timestamp2 ); - - my @results; - while ( my $data = $sth->fetchrow_hashref ) { - push @results, $data; - } - return (@results); -} - -# Otherwise, this needs a POD. -sub Getpaidbranch { - my ( $date, $borrno ) = @_; - my $dbh = C4::Context->dbh; - my $sth = - $dbh->prepare( -"select * from statistics where type='payment' and datetime >? and borrowernumber=?" - ); - $sth->execute( $date, $borrno ); - - # print $query; - my $data = $sth->fetchrow_hashref; - $sth->finish; - return ( $data->{'branch'} ); -} - -# FIXME - This is only used in reservereport.pl and reservereport.xls, -# neither of which is used. -# Otherwise, it needs a POD. -sub unfilledreserves { - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare( -"select *,biblio.title from reserves,reserveconstraints,biblio,borrowers,biblioitems where (found <> 'F' or - found is NULL) and cancellationdate - is NULL and biblio.biblionumber=reserves.biblionumber and - reserves.constrainttype='o' - and (reserves.biblionumber=reserveconstraints.biblionumber - and reserves.borrowernumber=reserveconstraints.borrowernumber) - and - reserves.borrowernumber=borrowers.borrowernumber and - biblioitems.biblioitemnumber=reserveconstraints.biblioitemnumber order by - biblio.title,reserves.reservedate" - ); - $sth->execute; - my $i = 0; - my @results; - while ( my $data = $sth->fetchrow_hashref ) { - $results[$i] = $data; - $i++; - } - $sth->finish; - $sth = $dbh->prepare( -"select *,biblio.title from reserves,biblio,borrowers where (found <> 'F' or found is NULL) and cancellationdate - is NULL and biblio.biblionumber=reserves.biblionumber and reserves.constrainttype='a' and - reserves.borrowernumber=borrowers.borrowernumber - order by - biblio.title,reserves.reservedate" ); - $sth->execute; - while ( my $data = $sth->fetchrow_hashref ) { - $results[$i] = $data; - $i++; - } $sth->finish; - return ( $i, \@results ); } 1; diff --git a/circ/branchtransfers.pl b/circ/branchtransfers.pl index 4e22c1cf92..a92f54e59d 100755 --- a/circ/branchtransfers.pl +++ b/circ/branchtransfers.pl @@ -26,28 +26,33 @@ use CGI; use C4::Circulation; use C4::Output; use C4::Reserves2; +use C4::Biblio; use C4::Auth; use C4::Interface::CGI::Output; use C4::Branch; # GetBranches use C4::Koha; -############################################### -# constants - -my %env; -my $branches = GetBranches; -my $printers = GetPrinters( \%env ); - ############################################### # Getting state my $query = new CGI; -my $branch = GetBranch( $query, $branches ); -my $printer = GetPrinter( $query, $printers ); +####################################################################################### +# Make the page ..... +my ( $template, $cookie ); +my $user; +( $template, $user, $cookie ) = get_template_and_user( + { + template_name => "circ/branchtransfers.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => { circulate => 1 }, + } +); -my $genbrname = $branches->{$branch}->{'branchname'}; -my $genprname = $printers->{$printer}->{'printername'}; +my $branches = GetBranches; +my $branch = GetBranch( $query, $branches ); my $messages; my $found; @@ -56,14 +61,10 @@ my $waiting; my $reqmessage; my $cancelled; my $setwaiting; -my $reqbrchname; -my $allmessages; my $request = $query->param('request'); my $borrowernumber = $query->param('borrowernumber'); - -my $tobranchcd = $query->param('tobranchcd'); -my $frbranchcd = ''; +my $tobranchcd = $query->param('tobranchcd'); ############ # Deal with the requests.... @@ -73,32 +74,26 @@ if ( $request eq "KillWaiting" ) { CancelReserve( 0, $item, $borrowernumber ); $cancelled = 1; $reqmessage = 1; - $allmessages = 1; } my $ignoreRs = 0; if ( $request eq "SetWaiting" ) { my $item = $query->param('itemnumber'); $tobranchcd = ReserveWaiting( $item, $borrowernumber ); - $reqbrchname = $branches->{$tobranchcd}->{'branchname'}; $ignoreRs = 1; $setwaiting = 1; $reqmessage = 1; - $allmessages = 1; } if ( $request eq 'KillReserved' ) { my $biblio = $query->param('biblionumber'); CancelReserve( $biblio, 0, $borrowernumber ); $cancelled = 1; $reqmessage = 1; - $allmessages = 1; } # set up the branchselect options.... my @branchoptionloop; foreach my $br ( keys %$branches ) { - - #(next) unless $branches->{$br}->{'CU'}; #FIXME disabled to fix bug 202 my %branch; $branch{selected} = ( $br eq $tobranchcd ); $branch{code} = $br; @@ -109,39 +104,35 @@ foreach my $br ( keys %$branches ) { # collect the stack of books already transfered so they can printed... my @trsfitemloop; my %transfereditems; -my %frbranchcds; -my %tobranchcds; my $transfered; my $barcode = $query->param('barcode'); +# warn "barcode : $barcode"; if ($barcode) { my $iteminformation; ( $transfered, $messages, $iteminformation ) = transferbook( $tobranchcd, $barcode, $ignoreRs ); +# use Data::Dumper; +# warn "Transfered : $transfered / ".Dumper($messages); $found = $messages->{'ResFound'}; if ($transfered) { my %item; - my $frbranchcd = $iteminformation->{'frbranchcd'}; - if ( not($found) ) { - $item{'biblionumber'} = $iteminformation->{'biblionumber'}; - $item{'title'} = $iteminformation->{'title'}; - $item{'author'} = $iteminformation->{'author'}; - $item{'itemtype'} = $iteminformation->{'itemtype'}; - $item{'ccode'} = $iteminformation->{'ccode'}; - $item{'frbrname'} = $branches->{$frbranchcd}->{'branchname'}; - $item{'tobrname'} = $branches->{$tobranchcd}->{'branchname'}; - } + my $frbranchcd = C4::Context->userenv->{'branch'}; +# if ( not($found) ) { + $item{'biblionumber'} = $iteminformation->{'biblionumber'}; + $item{'title'} = $iteminformation->{'title'}; + $item{'author'} = $iteminformation->{'author'}; + $item{'itemtype'} = $iteminformation->{'itemtype'}; + $item{'ccode'} = $iteminformation->{'ccode'}; + $item{'frbrname'} = $branches->{$frbranchcd}->{'branchname'}; + $item{'tobrname'} = $branches->{$tobranchcd}->{'branchname'}; +# } $item{counter} = 0; $item{barcode} = $barcode; $item{frombrcd} = $frbranchcd; $item{tobrcd} = $tobranchcd; -########## - #Are these lines still useful ??? - $transfereditems{0} = $barcode; - $frbranchcds{0} = $frbranchcd; - $tobranchcds{0} = $tobranchcd; -########## push( @trsfitemloop, \%item ); +# warn Dumper(@trsfitemloop); } } @@ -157,7 +148,7 @@ foreach ( $query->param ) { $item{barcode} = $bc; $item{frombrcd} = $frbcd; $item{tobrcd} = $tobcd; - my ($iteminformation) = GetBiblioFromItemNumer( 0, $bc ); + my ($iteminformation) = GetBiblioFromItemNumber( GetItemnumberFromBarcode($bc) ); $item{'biblionumber'} = $iteminformation->{'biblionumber'}; $item{'title'} = $iteminformation->{'title'}; $item{'author'} = $iteminformation->{'author'}; @@ -165,47 +156,16 @@ foreach ( $query->param ) { $item{'ccode'} = $iteminformation->{'ccode'}; $item{'frbrname'} = $branches->{$frbcd}->{'branchname'}; $item{'tobrname'} = $branches->{$tobcd}->{'branchname'}; -########## - #Are these lines still useful ??? - $transfereditems{$counter} = $bc; - $frbranchcds{$counter} = $frbcd; - $tobranchcds{$counter} = $tobcd; -######### push( @trsfitemloop, \%item ); } -my $title; -my $surname; -my $firstname; -my $borphone; -my $borstraddress; -my $borcity; -my $borzip; -my $boremail; -my $borcnum; my $itemnumber; -my $biblionum; -my $branchname; -my $wastransferred; +my $biblionumber; ##################### if ($found) { my $res = $messages->{'ResFound'}; - $branchname = $branches->{ $res->{'branchcode'} }->{'branchname'}; - my ($borr) = GetMemberDetails( $res->{'borrowernumber'}, 0 ); - $title = $borr->{'title'}; - $surname = $borr->{'surname'}; - $firstname = $borr->{'firstname'}; - $borrowernumber = $borr->{'borrowernumber'}; - $borphone = $borr->{'phone'}; - $borstraddress = $borr->{'streetaddress'}; - $borcity = $borr->{'city'}; - $borzip = $borr->{'zipcode'}; - $boremail = $borr->{'emailadress'}; - - #Hopefully, borr->{borrowernumber}=res->{borrowernumber} - $borcnum = $borr->{'cardnumber'}; $itemnumber = $res->{'itemnumber'}; if ( $res->{'ResFound'} eq "Waiting" ) { @@ -213,7 +173,7 @@ if ($found) { } if ( $res->{'ResFound'} eq "Reserved" ) { $reserved = 1; - $biblionum = $res->{'biblionumber'}; + $biblionumber = $res->{'biblionumber'}; } } @@ -226,88 +186,37 @@ foreach my $code ( keys %$messages ) { if ( $code eq 'BadBarcode' ) { $err{msg} = $messages->{'BadBarcode'}; $err{errbadcode} = 1; - $allmessages = 1; } if ( $code eq 'IsPermanent' ) { $err{errispermanent} = 1; $err{msg} = $branches->{ $messages->{'IsPermanent'} }->{'branchname'}; - - # Here, msg contains the branchname - # Not so satisfied with this... But should work - $allmessages = 1; } $err{errdesteqholding} = ( $code eq 'DestinationEqualsHolding' ); if ( $code eq 'WasReturned' ) { $err{errwasreturned} = 1; - $allmessages = 1; - my ($borrowerinfo) = - GetMemberDetails( $messages->{'WasReturned'}, 0 ); - $title = $borrowerinfo->{'title'}; - $surname = $borrowerinfo->{'surname'}; - $firstname = $borrowerinfo->{'firstname'}; - $borrowernumber = $borrowerinfo->{'borrowernumber'}; - $borcnum = $borrowerinfo->{'cardnumber'}; } - - # if ($code eq 'WasTransfered'){ - # Put code here if you want to notify the user that item was transfered... - # $wastransferred = 1; - # } push( @errmsgloop, \%err ); } -####################################################################################### -# Make the page ..... -my ( $template, $cookie ); -( $template, $borrowernumber, $cookie ) = get_template_and_user( - { - template_name => "circ/branchtransfers.tmpl", - query => $query, - type => "intranet", - authnotrequired => 0, - flagsrequired => { circulate => 1 }, - } -); -if ($allmessages) { - $template->param( allmessages => 1 ); -} - +# use Data::Dumper; +# warn "FINAL ============= ".Dumper(@trsfitemloop); $template->param( - genbrname => $genbrname, - genprname => $genprname, - branch => $branch, - printer => $printer, found => $found, reserved => $reserved, waiting => $waiting, - title => $title, - surname => $surname, - firstname => $firstname, - borphone => $borphone, - borstraddress => $borstraddress, - borcity => $borcity, - borzip => $borzip, - boremail => $boremail, borrowernumber => $borrowernumber, - borcnum => $borcnum, - branchname => $branchname, itemnumber => $itemnumber, barcode => $barcode, - biblionumber => $biblionum, + biblionumber => $biblionumber, tobranchcd => $tobranchcd, reqmessage => $reqmessage, cancelled => $cancelled, setwaiting => $setwaiting, - wastransferred => $wastransferred, trsfitemloop => \@trsfitemloop, branchoptionloop => \@branchoptionloop, errmsgloop => \@errmsgloop, - intranetcolorstylesheet => - C4::Context->preference("intranetcolorstylesheet"), - intranetstylesheet => C4::Context->preference("intranetstylesheet"), - IntranetNav => C4::Context->preference("IntranetNav"), ); output_html_with_http_headers $query, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/circ/branchtransfers.tmpl b/koha-tmpl/intranet-tmpl/prog/en/circ/branchtransfers.tmpl index e8bb1416e6..c079aaede3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/circ/branchtransfers.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/circ/branchtransfers.tmpl @@ -8,135 +8,161 @@

Circulation › Transfers

-

Reserve Found

- - - - - - - - - -
Reserve found for (">). - - Item is marked waiting at for (">).
- Set reserve to waiting and transfer book to : - Cancel reservation and then attempt transfer: - -
- - " value="" /> - " value="" /> - " value="" /> - - " /> - " /> - " /> - - - - - -
-
Cancel reservation and then attempt transfer: -
- - - " value="" /> - " value="" /> - " value="" /> - - - " /> - " /> - " /> - /> - - -
- -
Ignore and return to transfers: -
- /> - - - " value="" /> - " value="" /> - " value="" /> - - -
-
+

Reserve Found

+ + + + + + + + + + + + + + + + +
+ + Reserve found for (">). + + + Item is marked waiting at for (">). + +
+ Set reserve to waiting and transfer book to : + Cancel reservation and then attempt transfer: + +
+ + " value="" /> + " value="" /> + " value="" /> + + " /> + " /> + + " /> + + + + + + + +
+
Cancel reservation and then attempt transfer: +
+ + " value="" /> + " value="" /> + " value="" /> + + " /> + " /> + " /> + /> + + +
+
Ignore and return to transfers: +
+ /> + + + " value="" /> + " value="" /> + " value="" /> + + +
+
- - - + +
Messages
- - - Reserve Cancelled
- - - Item should now be waiting at branch:
- - - No message. - - - - - No Item with barcode: - - - Please return item to home branch: - - - Item is already at destination branch. - - - Item was on loan to "> + + + +
Messages
+ + + Reserve Cancelled
+ + + Item should now be waiting at branch:
+ + + + + No Item with barcode: + + + Please return item to home branch: + + + Item is already at destination branch. + + + Item was on loan to "> and has been returned. - - - -
- -
- - - - -
Transfer
Destination branch:
Enter barcode
- " /> - - " value="" /> - " value="" /> - " value="" /> - - -
- - - - - - - - - - - - - - -
Transfered Items
Bar CodeTitleAuthorTypeFromTo
- &type=intra">
- + + +
+
+ + + + + + + + + + +
Transfer
Destination branch: + +
Enter barcode
+ " /> + + " value="" /> + " value="" /> + " value="" /> + + +
+ + + + + + + + + + + + + + + + +
Transfered Items
Bar CodeTitleTo
+ > + +

()

+

+
+ diff --git a/koha-tmpl/intranet-tmpl/prog/en/circ/returns.tmpl b/koha-tmpl/intranet-tmpl/prog/en/circ/returns.tmpl index 9fe7f7ce8b..0ab3508ab3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/circ/returns.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/circ/returns.tmpl @@ -7,7 +7,7 @@ -

This item was not transfered initialy to this library !

+

This item should not be in this library !

@@ -32,7 +32,7 @@
Title :
Action : - this document must be transfered to : + This item must be transfered to :
@@ -146,9 +146,9 @@ -

Reserve With necesary transfert Found

+

Reserve at an other library, transfer to do

-

Waiting Reserve Found in your library

+

Waiting reserve found in your library

-- 2.20.1
">