From c98bae12bb2bf26df9b0df4c077c38dc3d45ae03 Mon Sep 17 00:00:00 2001 From: alaurin Date: Fri, 19 May 2006 17:01:02 +0000 Subject: [PATCH] new dev : create 3 new program for circulation : branchreserves : to see reserves for one library (with the branchip selection or librarian preferences) currenttransfers : show all the transfers are waiting in the library waitingreservetransfers: show all the book the librarian have to transfer to an another library . "actions" are bugged, will be corrected . --- C4/Circulation/Circ2.pm | 153 +++++++++++++++-- C4/Reserves2.pm | 156 +++++++++++++++++- circ/branchreserves.pl | 137 +++++++++++++++ circ/currenttransfers.pl | 123 ++++++++++++++ circ/waitingreservestransfers.pl | 126 ++++++++++++++ .../prog/en/circ/branchreserves.tmpl | 82 +++++++++ .../prog/en/circ/currenttransfers.tmpl | 59 +++++++ .../en/circ/waitingreservestransfers.tmpl | 62 +++++++ .../prog/en/includes/menu-circ.inc | 8 + .../intranet-tmpl/prog/en/includes/menus.inc | 1 + .../intranet-tmpl/prog/en/intranet-main.tmpl | 13 +- 11 files changed, 896 insertions(+), 24 deletions(-) create mode 100755 circ/branchreserves.pl create mode 100755 circ/currenttransfers.pl create mode 100755 circ/waitingreservestransfers.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/circ/branchreserves.tmpl create mode 100755 koha-tmpl/intranet-tmpl/prog/en/circ/currenttransfers.tmpl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/circ/waitingreservestransfers.tmpl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/menu-circ.inc diff --git a/C4/Circulation/Circ2.pm b/C4/Circulation/Circ2.pm index e47e6e51b2..128af70f46 100755 --- a/C4/Circulation/Circ2.pm +++ b/C4/Circulation/Circ2.pm @@ -83,8 +83,13 @@ Also deals with stocktaking. &fixdate get_return_date_of get_transfert_infos + &checktransferts + &GetReservesForBranch + &GetReservesToBranch + &GetTransfersFromBib + &getBranchIp + &dotranfer ); - # &getbranches &getprinters &getbranch &getprinter => moved to C4::Koha.pm =head2 itemseen @@ -503,11 +508,11 @@ sub transferbook { my ($resfound, $resrec) = CheckReserves($iteminformation->{'itemnumber'}); if ($resfound and not $ignoreRs) { $resrec->{'ResFound'} = $resfound; - $messages->{'ResFound'} = $resrec; - $dotransfer = 0; +# $messages->{'ResFound'} = $resrec; + $dotransfer = 1; } - #actually do the transfer.... - if ($dotransfer) { + + if ($dotransfer and not $resfound) { dotransfer($iteminformation->{'itemnumber'}, $fbr, $tbr); $messages->{'WasTransfered'} = 1; } @@ -524,10 +529,10 @@ sub dotransfer { $fbr = $dbh->quote($fbr); $tbr = $dbh->quote($tbr); #new entry in branchtransfers.... - $dbh->do("INSERT INTO branchtransfers (itemnumber, frombranch, datearrived, tobranch) + $dbh->do("INSERT INTO branchtransfers (itemnumber, frombranch, datesent, tobranch) VALUES ($itm, $fbr, now(), $tbr)"); #update holdingbranch in items ..... - $dbh->do("UPDATE items set holdingbranch = $tbr WHERE items.itemnumber = $itm"); + $dbh->do("UPDATE items set holdingbranch = $tbr WHERE items.itemnumber = $itm"); &itemseen($itm); &domarctransfer($dbh,$itm); return; @@ -897,7 +902,7 @@ sub issuebook { CancelReserve(0, $res->{'itemnumber'}, $res->{'borrowernumber'}); } } elsif ($restype eq "Reserved") { - warn "Reserved"; +# warn "Reserved"; # The item is on reserve for someone else. my ($resborrower, $flags)=getpatroninformation($env, $resbor,0); my $branches = getbranches(); @@ -914,7 +919,7 @@ sub issuebook { } else { # my $tobrcd = ReserveWaiting($res->{'itemnumber'}, $res->{'borrowernumber'}); # transferbook($tobrcd,$barcode, 1); - warn "transferbook"; +# warn "transferbook"; } } } @@ -934,8 +939,8 @@ sub issuebook { $sth->execute($borrower->{'borrowernumber'}, $iteminformation->{'itemnumber'}, $dateduef, $env->{'branchcode'}); $sth->finish; $iteminformation->{'issues'}++; - $sth=$dbh->prepare("update items set issues=? where itemnumber=?"); - $sth->execute($iteminformation->{'issues'},$iteminformation->{'itemnumber'}); + $sth=$dbh->prepare("update items set issues=?, holdingbranch=? where itemnumber=?"); + $sth->execute($iteminformation->{'issues'},C4::Context->userenv->{'branch'},$iteminformation->{'itemnumber'}); $sth->finish; &itemseen($iteminformation->{'itemnumber'}); itemborrowed($iteminformation->{'itemnumber'}); @@ -1092,28 +1097,64 @@ sub returnbook { $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) = getpatroninformation(\%env, $currentborrower, 0); 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'}); + +# FIXME the holdingbranch is updated if the document is returned in an other location . + if ( $iteminformation->{'holdingbranch'} ne C4::Context->userenv->{'branch'}){ + my $sth_upd_location = $dbh->prepare("UPDATE items SET holdingbranch=? WHERE itemnumber=?"); + $sth_upd_location->execute(C4::Context->userenv->{'branch'},$iteminformation->{'itemnumber'}); + $sth_upd_location->finish; + $iteminformation->{'holdingbranch'} = C4::Context->userenv->{'branch'}; + } + $messages->{'WasReturned'} = 1; # FIXME is the "= 1" right? } itemseen($iteminformation->{'itemnumber'}); ($borrower) = getpatroninformation(\%env, $currentborrower, 0); # transfer book to the current branch - my ($transfered, $mess, $item) = transferbook($branch, $barcode, 1); - if ($transfered) { - $messages->{'WasTransfered'} = 1; # FIXME is the "= 1" right? - } + +# FIXME function transfered still always used ???? +# my ($transfered, $mess, $item) = transferbook($branch, $barcode, 1); +# if ($transfered) { +# $messages->{'WasTransfered'} = 1; # FIXME is the "= 1" right? +# } + # fix up the accounts..... if ($iteminformation->{'itemlost'}) { fixaccountforlostandreturned($iteminformation, $borrower); $messages->{'WasLost'} = 1; # FIXME is the "= 1" right? } +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# check if we have a transfer for this document + my $checktransfer = checktransferts($iteminformation->{'itemnumber'}); +# if we have a return, we update the line of transfers with the datearrived + if ($checktransfer){ + 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' + my $updateWaiting = SetWaitingStatus($iteminformation->{'itemnumber'}); + } +# if we don't have a transfer on run, we check if the document is not in his homebranch and there is not a reservation, we transfer this one to his home branch directly . + else { + # new op dev + my $checkreserves = CheckReserves($iteminformation->{'itemnumber'}); + if (($iteminformation->{'homebranch'} ne $iteminformation->{'holdingbranch'}) and (not $checkreserves)){ + my $automatictransfer = dotransfer($iteminformation->{'itemnumber'},$iteminformation->{'holdingbranch'},$iteminformation->{'homebranch'}); + $messages->{'WasTransfered'} = 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) { # my $tobrcd = ReserveWaiting($resrec->{'itemnumber'}, $resrec->{'borrowernumber'}); @@ -1967,6 +2008,87 @@ SELECT datesent, return @row; } + +sub DeleteTransfer { + my($itemnumber) = @_; + my $dbh = C4::Context->dbh; + my $sth=$dbh->prepare("DELETE FROM branchtransfers + where itemnumber=? + AND datearrived is null "); + $sth->execute($itemnumber); + $sth->finish; +} + +sub GetTransfersFromBib { + my($frombranch,$tobranch) = @_; + my $dbh = C4::Context->dbh; + my $sth=$dbh->prepare("SELECT itemnumber,datesent,frombranch FROM + branchtransfers + where frombranch=? + AND tobranch=? + AND datearrived is null "); + $sth->execute($frombranch,$tobranch); + my @gettransfers; + my $i=0; + while (my $data=$sth->fetchrow_hashref){ + $gettransfers[$i]=$data; + $i++; + } + $sth->finish; + return(@gettransfers); +} + +sub GetReservesToBranch { + my($frombranch,$default) = @_; + my $dbh = C4::Context->dbh; + my $sth=$dbh->prepare("SELECT borrowernumber,reservedate,itemnumber,timestamp FROM + reserves + where priority='0' AND cancellationdate is null + AND branchcode=? + AND branchcode!=? + AND found is null "); + $sth->execute($frombranch,$default); + my @transreserv; + my $i=0; + while (my $data=$sth->fetchrow_hashref){ + $transreserv[$i]=$data; + $i++; + } + $sth->finish; + return(@transreserv); +} + +sub GetReservesForBranch { + my($frombranch) = @_; + my $dbh = C4::Context->dbh; + my $sth=$dbh->prepare("SELECT borrowernumber,reservedate,itemnumber,waitingdate FROM + reserves + where priority='0' AND cancellationdate is null + AND found='W' + AND branchcode=? order by reservedate"); + $sth->execute($frombranch); + my @transreserv; + my $i=0; + while (my $data=$sth->fetchrow_hashref){ + $transreserv[$i]=$data; + $i++; + } + $sth->finish; + return(@transreserv); +} + +sub checktransferts{ + my($itemnumber) = @_; + my $dbh = C4::Context->dbh; + my $sth=$dbh->prepare("SELECT datesent,frombranch,tobranch FROM branchtransfers + WHERE itemnumber = ? AND datearrived IS NULL"); + $sth->execute($itemnumber); + my @tranferts = $sth->fetchrow_array; + $sth->finish; + + return (@tranferts); +} + 1; __END__ @@ -1977,3 +2099,4 @@ __END__ Koha Developement team =cut + diff --git a/C4/Reserves2.pm b/C4/Reserves2.pm index e5e519e09f..979519c801 100755 --- a/C4/Reserves2.pm +++ b/C4/Reserves2.pm @@ -66,11 +66,153 @@ FIXME &UpdateReserve &getreservetitle &Findgroupreserve + &FastFindReserves + &SetWaitingStatus + &GlobalCancel + &MinusPriority + &OtherReserves GetFirstReserveDateFromItem GetNumberReservesFromBorrower ); # make all your functions, whether exported or not; +=item GlobalCancel + New op dev for the circulation based on item, global is a function to cancel reserv,check other reserves, and transfer document if it's necessary +=cut +#' +sub GlobalCancel { + my $messages; + my $nextreservinfo; + my ($itemnumber,$borrowernumber)=@_; + +# step 1 : cancel the reservation + my $CancelReserve = CancelReserve(0,$itemnumber,$borrowernumber); + +# step 2 launch the subroutine of the others reserves + my ($messages,$nextreservinfo) = OtherReserves($itemnumber); + +return ($messages,$nextreservinfo); +} + +=item OtherReserves + New op dev: check queued list of this document and check if this document must be transfered +=cut +#' +sub OtherReserves { + my ($itemnumber)=@_; + my $messages; + my $nextreservinfo; + my ($restype,$checkreserves) = CheckReserves($itemnumber); + if ($checkreserves){ + my %env; + my $iteminfo = C4::Circulation::Circ2::getiteminformation(\%env,$itemnumber); + if ($iteminfo->{'holdingbranch'} ne $checkreserves->{'branchcode'}){ + $messages->{'transfert'} = $checkreserves->{'branchcode'}; + +# minus priorities of others reservs + MinusPriority($itemnumber,$checkreserves->{'borrowernumber'},$iteminfo->{'biblionumber'}); +# launch the subroutine dotransfer + C4::Circulation::Circ2::dotransfer($itemnumber,$iteminfo->{'holdingbranch'},$checkreserves->{'branchcode'}), + } + +# step 2b : case of a reservation on the same branch, set the waiting status + else{ + $messages->{'waiting'} = 1; + MinusPriority($itemnumber,$checkreserves->{'borrowernumber'},$iteminfo->{'biblionumber'}); + SetWaitingStatus($itemnumber); + } + + $nextreservinfo = $checkreserves->{'borrowernumber'}; + } + + return ($messages,$nextreservinfo); +} + +=item MinusPriority + Reduce the values of queuded list +=cut +#' +sub MinusPriority{ + my ($itemnumber,$borrowernumber,$biblionumber)=@_; +# first step update the value of the first person on reserv + my $dbh = C4::Context->dbh; + my $sth_upd=$dbh->prepare("UPDATE reserves SET priority = 0 , itemnumber = ? + WHERE cancellationdate is NULL + AND borrowernumber=? + AND biblionumber=?"); + $sth_upd->execute($itemnumber,$borrowernumber,$biblionumber); + $sth_upd->finish; + +# second step update all others reservs + my $sth_oth=$dbh->prepare("SELECT priority,borrowernumber,biblionumber,reservedate FROM reserves WHERE priority !='0' AND cancellationdate is NULL"); + $sth_oth->execute(); + while (my ($priority,$borrowernumber,$biblionumber,$reservedate)=$sth_oth->fetchrow_array){ + $priority--; + my $sth_upd_oth = $dbh->prepare("UPDATE reserves SET priority = ? + WHERE biblionumber = ? + AND borrowernumber = ? + AND reservedate = ?"); + $sth_upd_oth->execute($priority,$biblionumber,$borrowernumber,$reservedate); + $sth_upd_oth->finish; + } + $sth_oth->finish; + +} + + +=item GlobalCancel + New op dev for the circulation based on item, global is a function to cancel reserv,check other reserves, and transfer document if it's necessary +=cut +#' +# New op dev : +# we check if we have a reserves with itemnumber (New op system of reserves), if we found one, we update the status of the reservation when we have : 'priority' = 0, and we have an itemnumber +sub SetWaitingStatus{ +# first : check if we have a reservation for this item . + my ($itemnumber)=@_; + my $dbh = C4::Context->dbh; + my $sth_find=$dbh->prepare("SELECT priority,borrowernumber from reserves WHERE itemnumber=? and cancellationdate is NULL and found is NULL and priority='0'"); + $sth_find->execute($itemnumber); + my ($priority,$borrowernumber) = $sth_find->fetchrow_array; + $sth_find->finish; + if (not $borrowernumber){ + return(); + } + else{ +# step 2 : if we have a borrowernumber, we update the value found to 'W' for notify the borrower + my $sth_set=$dbh->prepare("UPDATE reserves SET found='W',waitingdate = now() where borrowernumber=? AND itemnumber=? AND found is null"); + $sth_set->execute($borrowernumber,$itemnumber); + $sth_set->finish; + } + +} + +sub FastFindReserves { + my ($itemnumber,$borrowernumber)=@_; + if ($itemnumber){ + my $dbh = C4::Context->dbh; + my $sth_res=$dbh->prepare("SELECT reservedate,borrowernumber from reserves WHERE itemnumber=? and cancellationdate is NULL AND (found != 'F' or found is null)"); + $sth_res->execute($itemnumber); + my ($reservedate,$borrowernumber)=$sth_res->fetchrow_array; + $sth_res->finish; + return($reservedate,$borrowernumber); + } + if ($borrowernumber){ + my $dbh = C4::Context->dbh; + my $sth_find=$dbh->prepare("SELECT * from reserves WHERE borrowernumber=? and cancellationdate is NULL and (found != 'F' or found is null) order by reservedate"); + $sth_find->execute($borrowernumber); + my @borrowerreserv; + my $i=0; + while (my $data=$sth_find->fetchrow_hashref){ + $borrowerreserv[$i]=$data; + $i++; + } + $sth_find->finish; + return (@borrowerreserv); + } + +} + + =item FindReserves @@ -551,13 +693,17 @@ sub Findgroupreserve { # C4::Reserves. Pick one and stick with it. # XXX - POD sub CreateReserve { - my -($env,$branch,$borrnum,$biblionumber,$constraint,$bibitems,$priority,$notes,$title)= @_; + my ($env,$branch,$borrnum,$biblionumber,$constraint,$bibitems,$priority,$notes,$title,$checkitem,$found)= @_; my $fee=CalcReserveFee($env,$borrnum,$biblionumber,$constraint,$bibitems); my $dbh = C4::Context->dbh; my $const = lc substr($constraint,0,1); my @datearr = localtime(time); my $resdate =(1900+$datearr[5])."-".($datearr[4]+1)."-".$datearr[3]; + my $waitingdate; +# If the reserv had the waiting status, we had the value of the resdate + if ($found eq 'W'){ + $waitingdate = $resdate; + } #eval { # updates take place here if ($fee > 0) { @@ -572,9 +718,9 @@ sub CreateReserve { } #if ($const eq 'a'){ my $sth = $dbh->prepare("insert into reserves - (borrowernumber,biblionumber,reservedate,branchcode,constrainttype,priority,reservenotes) - values (?,?,?,?,?,?,?)"); - $sth->execute($borrnum,$biblionumber,$resdate,$branch,$const,$priority,$notes); + (borrowernumber,biblionumber,reservedate,branchcode,constrainttype,priority,reservenotes,itemnumber,found,waitingdate) + values (?,?,?,?,?,?,?,?,?,?)"); + $sth->execute($borrnum,$biblionumber,$resdate,$branch,$const,$priority,$notes,$checkitem,$found,$waitingdate); $sth->finish; #} if (($const eq "o") || ($const eq "e")) { diff --git a/circ/branchreserves.pl b/circ/branchreserves.pl new file mode 100755 index 0000000000..cae4210837 --- /dev/null +++ b/circ/branchreserves.pl @@ -0,0 +1,137 @@ +#!/usr/bin/perl + +# $Id$ + +# Copyright 2000-2002 Katipo Communications +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA + +use strict; +use C4::Context; +use C4::Output; +use CGI; +use HTML::Template; +use C4::Auth; +use C4::Date; +use C4::Circulation::Circ2; +use Date::Manip; +use C4::Reserves2; +use C4::Search; + +my $input = new CGI; + +my $item=$input->param('itemnumber'); +my $borrowernumber=$input->param('borrowernumber'); +my $fbr=$input->param('fbr'); +my $tbr=$input->param('tbr'); + +my $cancel; + + +my $theme = $input->param('theme'); # only used if allowthemeoverride is set + +my ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "circ/branchreserves.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {borrowers => 1}, + debug => 1, + }); + +my $default = C4::Context->userenv->{'branch'}; + +my @datearr = localtime(time()); +my $todaysdate = (1900+$datearr[5]).'-'.sprintf ("%0.2d", ($datearr[4]+1)).'-'.sprintf ("%0.2d", $datearr[3]); + + +# if we have a return from the form we launch the subroutine CancelReserve + if ($item){ + my $messages; + my $nextreservinfo; + my %env; + my $waiting; + ($messages,$nextreservinfo) = GlobalCancel($item,$borrowernumber); +# if we have a result + if ($nextreservinfo){ + my $borrowerinfo = getpatroninformation(\%env,$nextreservinfo); + my $iteminfo = C4::Circulation::Circ2::getiteminformation(\%env,$item); + if ($messages->{'transfert'}){ + my $branchname = getbranchname($messages->{'transfert'}); + $template->param( + messagetransfert => $messages->{'transfert'}, + branchname => $branchname, + ); + } + if ($messages->{'waiting'}){ + $waiting = 1; + } + + $template->param( + message => 1, + nextreservnumber => $nextreservinfo, + nextreservsurname => $borrowerinfo->{'surname'}, + nextreservfirstname => $borrowerinfo->{'firstname'}, + nextreservitem => $item, + nextreservtitle => $iteminfo->{'title'}, + waiting => $waiting + ); + } +# if the document is not in his homebranch location and there is not reservation after, we transfer it + if (($fbr ne $tbr) and (not $nextreservinfo)){ + C4::Circulation::Circ2::dotransfer($item,$fbr,$tbr); + } + } + +my @reservloop; +my @getreserves = GetReservesForBranch($default); +foreach my $num (@getreserves) { + my %getreserv; + my %env; + my $gettitle = getiteminformation(\%env,$num->{'itemnumber'}); + my $getborrower = getpatroninformation (\%env,$num->{'borrowernumber'}); + $getreserv{'waitingdate'} = format_date($num->{'waitingdate'}); + my $calcDate=DateCalc($num->{'waitingdate'},"+".C4::Context->preference('ReservesMaxPickUpDelay')." days"); + my $warning=Date_Cmp(ParseDate("today"),$calcDate); + if ($warning>0){ + $getreserv{'messcompa'} = 1; + } + $getreserv{'title'} = $gettitle->{'title'}; + $getreserv{'itemnumber'} = $gettitle->{'itemnumber'}; + $getreserv{'biblionumber'} = $gettitle->{'biblionumber'}; + $getreserv{'barcode'} = $gettitle->{'barcode'}; +# $getreserv{'itemtype'} = ItemType($gettitle->{'itemtype'}); + $getreserv{'homebranch'} = $gettitle->{'homebranch'}; + $getreserv{'holdingbranch'} = $gettitle->{'holdingbranch'}; + if ($gettitle->{'homebranch'} ne $gettitle->{'holdingbranch'}){ + $getreserv{'dotransfer'} = 1; + } + $getreserv{'itemcallnumber'} = $gettitle->{'itemcallnumber'}; + $getreserv{'borrowernum'} = $getborrower->{'borrowernumber'}; + $getreserv{'borrowername'} = $getborrower->{'surname'}; + $getreserv{'borrowerfirstname'} = $getborrower->{'firstname'} ; + if ($getborrower->{'emailaddress'}){ + $getreserv{'borrowermail'} = $getborrower->{'emailaddress'} ; + } + $getreserv{'borrowerphone'} = $getborrower->{'phone'}; + push(@reservloop, \%getreserv); +} + + $template->param( reserveloop => \@reservloop, + show_date => format_date($todaysdate), + ); + + print "Content-Type: text/html\n\n", $template->output; \ No newline at end of file diff --git a/circ/currenttransfers.pl b/circ/currenttransfers.pl new file mode 100755 index 0000000000..043280e78a --- /dev/null +++ b/circ/currenttransfers.pl @@ -0,0 +1,123 @@ +#!/usr/bin/perl + +# $Id$ + +# Copyright 2000-2002 Katipo Communications +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA + +use strict; +use C4::Context; +use C4::Output; +use CGI; +use HTML::Template; +use C4::Auth; +use C4::Date; +use C4::Circulation::Circ2; +use Date::Manip; +use C4::Koha; +use C4::Search; +use C4::Reserves2; + +my $input = new CGI; + +my $theme = $input->param('theme'); # only used if allowthemeoverride is set +my $itemnumber = $input->param('itemnumber'); +# if we have a resturn of the form to delete the transfer, we launch the subrroutine +if ($itemnumber){ + C4::Circulation::Circ2::DeleteTransfer($itemnumber); +} + +my ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "circ/currenttransfers.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {borrowers => 1}, + debug => 1, + }); + + +# set the userenv branch +my $default = C4::Context->userenv->{'branch'}; + + +my @datearr = localtime(time()); +my $todaysdate = (1900+$datearr[5]).'-'.sprintf ("%0.2d", ($datearr[4]+1)).'-'.sprintf ("%0.2d", $datearr[3]); + +# get the all the branches for reference +my $branches = getbranches(); +my @branchesloop; +foreach my $br (keys %$branches) { + my @transferloop; + my %branchloop; + $branchloop{'branchname'} = $branches->{$br}->{'branchname'}; + $branchloop{'branchcode'} = $branches->{$br}->{'branchcode'}; + # # # # # # # # # # # # # # # # # # # # # # + my @gettransfers = GetTransfersFromBib($branches->{$br}->{'branchcode'},$default); + if (@gettransfers){ + foreach my $num (@gettransfers) { + my %getransf; + my %env; + my $calcDate=DateCalc($num->{'datesent'},"+".C4::Context->preference('TransfersMaxDaysWarning')." days"); + my $warning=Date_Cmp(ParseDate("today"),$calcDate); + if ($warning>0){ + $getransf{'messcompa'} = 1; + } + my $gettitle = getiteminformation(\%env,$num->{'itemnumber'}); + $getransf{'title'} = $gettitle->{'title'}; + $getransf{'datetransfer'} = format_date($num->{'datesent'}); + $getransf{'biblionumber'} = $gettitle->{'biblionumber'}; + $getransf{'itemnumber'} = $gettitle->{'itemnumber'}; + $getransf{'barcode'} = $gettitle->{'barcode'}; +# $getransf{'itemtype'} = ItemType($gettitle->{'itemtype'}); + $getransf{'homebranch'} = $gettitle->{'homebranch'}; + $getransf{'holdingbranch'} = $gettitle->{'holdingbranch'}; + $getransf{'itemcallnumber'} = $gettitle->{'itemcallnumber'}; + +# we check if we have a reserv for this transfer + my @checkreserv = FastFindReserves($num->{'itemnumber'}); + if (@checkreserv[0]){ + my $getborrower = getpatroninformation (\%env,$checkreserv[1]); + $getransf{'borrowernum'} = $getborrower->{'borrowernumber'}; + $getransf{'borrowername'} = $getborrower->{'surname'}; + $getransf{'borrowerfirstname'} = $getborrower->{'firstname'}; + if ($getborrower->{'emailaddress'}){ + $getransf{'borrowermail'} = $getborrower->{'emailaddress'} ; + } + $getransf{'borrowerphone'} = $getborrower->{'phone'}; + + } + push(@transferloop, \%getransf); + } +# If we have a return of reservloop we put it in the branchloop sequence + $branchloop{'reserv'} = \@transferloop ; + } + else { +# if we don't have a retrun from reservestobranch we unset branchname and branchcode + $branchloop{'branchname'} = 0; + $branchloop{'branchcode'} = 0; + } +push(@branchesloop, \%branchloop); +} + $template->param( branchesloop => \@branchesloop, + show_date => format_date($todaysdate) + ); + + print "Content-Type: text/html\n\n", $template->output; + + + diff --git a/circ/waitingreservestransfers.pl b/circ/waitingreservestransfers.pl new file mode 100755 index 0000000000..7a6fabae32 --- /dev/null +++ b/circ/waitingreservestransfers.pl @@ -0,0 +1,126 @@ +#!/usr/bin/perl + +# $Id$ + +# Copyright 2000-2002 Katipo Communications +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA + +use strict; +use C4::Context; +use C4::Output; +use CGI; +use HTML::Template; +use C4::Auth; +use C4::Date; +use C4::Circulation::Circ2; +use Date::Manip; +use C4::Koha; +use C4::Biblio; + +my $input = new CGI; + +my $theme = $input->param('theme'); # only used if allowthemeoverride is set + +my ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "circ/waitingreservestransfers.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {borrowers => 1}, + debug => 1, + }); + + +# set the userenv branch +my $default = C4::Context->userenv->{'branch'}; + + +my @datearr = localtime(time()); +my $todaysdate = (1900+$datearr[5]).'-'.sprintf ("%0.2d", ($datearr[4]+1)).'-'.sprintf ("%0.2d", $datearr[3]); + +my $item=$input->param('itemnumber'); +my $fbr=$input->param('fbr'); +my $tbr=$input->param('tbr'); +# If we have a return of the form dotransfer, we launch the subroutine dotransfer +if ($item){ + C4::Circulation::Circ2::dotransfer($item,$fbr,$tbr); +} + +# get the all the branches for reference +my $branches = getbranches(); +my @branchesloop; +foreach my $br (keys %$branches) { + my @reservloop; + my %branchloop; + $branchloop{'branchname'} = $branches->{$br}->{'branchname'}; + $branchloop{'branchcode'} = $branches->{$br}->{'branchcode'}; + my @getreserves = GetReservesToBranch($branches->{$br}->{'branchcode'},$default); + if (@getreserves){ + foreach my $num (@getreserves) { + my %getreserv; + my %env; + my $gettitle = getiteminformation(\%env,$num->{'itemnumber'}); + if ($gettitle->{'holdingbranch'} eq $default){ + my $getborrower = getpatroninformation (\%env,$num->{'borrowernumber'}); + $getreserv{'reservedate'} = format_date($num->{'reservedate'}); + my $calcDate=DateCalc($num->{'reservedate'},"+".C4::Context->preference('MaxDaysRecoveryReserves')." days"); + my $warning=Date_Cmp(ParseDate("today"),$calcDate); + if ($warning>0){ + $getreserv{'messcompa'} = 1; + } + $getreserv{'title'} = $gettitle->{'title'}; + $getreserv{'biblionumber'} = $gettitle->{'biblionumber'}; + $getreserv{'itemnumber'} = $gettitle->{'itemnumber'}; + $getreserv{'barcode'} = $gettitle->{'barcode'}; +# $getreserv{'itemtype'} = get_iteminfos_of($gettitle->{'itemtype'}->{'description'}); + $getreserv{'holdingbranch'} = $gettitle->{'holdingbranch'}; + $getreserv{'itemcallnumber'} = $gettitle->{'itemcallnumber'}; + $getreserv{'borrowernum'} = $getborrower->{'borrowernumber'}; + $getreserv{'borrowername'} = $getborrower->{'surname'}; + $getreserv{'borrowerfirstname'} = $getborrower->{'firstname'} ; + if ($getborrower->{'emailaddress'}){ + $getreserv{'borrowermail'} = $getborrower->{'emailaddress'} ; + } + $getreserv{'borrowerphone'} = $getborrower->{'phone'}; + push(@reservloop, \%getreserv); + } + } +# If we have a return of reservloop we put it in the branchloop sequence + if (@reservloop){ + $branchloop{'reserv'} = \@reservloop ; + } +# else, we unset the value of the branchcode . + else{ + $branchloop{'branchcode'} = 0; + } + } + else { +# if we don't have a retrun from reservestobranch we unset branchname and branchcode + $branchloop{'branchname'} = 0; + $branchloop{'branchcode'} = 0; + } + push(@branchesloop, \%branchloop); +} + + $template->param( branchesloop => \@branchesloop, + show_date => format_date($todaysdate) + ); + + print "Content-Type: text/html\n\n", $template->output; + + + diff --git a/koha-tmpl/intranet-tmpl/prog/en/circ/branchreserves.tmpl b/koha-tmpl/intranet-tmpl/prog/en/circ/branchreserves.tmpl new file mode 100644 index 0000000000..030d0435a2 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/circ/branchreserves.tmpl @@ -0,0 +1,82 @@ +Koha -- Circulation + + + + +

Circulation: Branch Reserves

+ +
+

Reservs of your library the :

+ +
+

Reserv find for the document()must transfered

+

This documen is reserved by : at the library : , Please put this document in transfer . +

+
+ +
+
+ + +
+

This document is in Waiting status

+

This document () is reserved by : , + Please keep this document for the next reserv . +

+
+ +
+
+ + +
+ + + + + + + + + + + + + class="problem" > + + + + + + + +
Reservs of your library
Available sinceTitleBorrowerLocalisationAction

Reserv Over
+

+ "> +   () +
Barcode : +

+
+

">  

+ ?subject=Reservation: "> + +

+

+
+ "> + "> + "> + "> + + value="Cancel reserv and return this document" + + value="Cancel reserv" + + > +
+
+
+ +
+ diff --git a/koha-tmpl/intranet-tmpl/prog/en/circ/currenttransfers.tmpl b/koha-tmpl/intranet-tmpl/prog/en/circ/currenttransfers.tmpl new file mode 100755 index 0000000000..5894759e78 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/circ/currenttransfers.tmpl @@ -0,0 +1,59 @@ +Koha -- Circulation + + + + +
+

Transfers in wait for your library the :

+
+ + + + + + + + + + + + + + + class="problem" > + + + + + + + +
current transfers from the library :
Date of transferTitleBorrowerLocalisationAction

check this transfer
+

+ "> +   ( ) +
Barcode : +

+
+ +

">  

+ ?subject=Reservation: "> + +

+ +

+ Transfer without reserv linked +

+ +

+
+ "> + +
+
+

+ + +
+
+ diff --git a/koha-tmpl/intranet-tmpl/prog/en/circ/waitingreservestransfers.tmpl b/koha-tmpl/intranet-tmpl/prog/en/circ/waitingreservestransfers.tmpl new file mode 100644 index 0000000000..0587fefba2 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/circ/waitingreservestransfers.tmpl @@ -0,0 +1,62 @@ +Koha -- Circulation + +: Issuing to , +() + + + + + + +

Circulation: Transfers in wait

+ +
+

Transfers to do

+
+ + + + + + + + + + + + + + + class="problem" > + + + + + + + +
Reservs in wait to the library :
Date of reservTitleBorrowerLocalisationAction

Reserv over
+

+ "> +   ( ) +
Barcode : +

+
+

">  

+ ?subject=Reservation: "> + +

+

+
+ "> + "> + "> + +
+
+

+ + +
+
+ diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/menu-circ.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/menu-circ.inc new file mode 100644 index 0000000000..96054493dc --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/menu-circ.inc @@ -0,0 +1,8 @@ +Circulation +Issues +Returns +Transfers +Set branch +Waiting reserves +Transfers to do +Transfers to recieve diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/menus.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/menus.inc index 8cf034d940..fb134296ce 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/menus.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/menus.inc @@ -1,4 +1,5 @@