From 13e7c898dff603108d79380cc3bad38a2df0ba4d Mon Sep 17 00:00:00 2001 From: finlayt Date: Fri, 27 Sep 2002 05:21:44 +0000 Subject: [PATCH] Added the possiblity of deleting waiting reservesm or setting them back to not waiting. uses UpdateReserve now, instead of updatereserves from Reserves2.pm --- C4/Reserves2.pm | 30 ++++++++++++++++++++++++++++-- modrequest.pl | 14 +++++--------- request.pl | 42 ++++++++++++++++++++++++------------------ 3 files changed, 57 insertions(+), 29 deletions(-) diff --git a/C4/Reserves2.pm b/C4/Reserves2.pm index 9ac3c49384..a45dc75e4a 100755 --- a/C4/Reserves2.pm +++ b/C4/Reserves2.pm @@ -31,7 +31,7 @@ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); $VERSION = 0.01; @ISA = qw(Exporter); -@EXPORT = qw(&FindReserves &CheckReserves &CheckWaiting &CancelReserve &FillReserve &ReserveWaiting &CreateReserve &updatereserves &getreservetitle &Findgroupreserve); +@EXPORT = qw(&FindReserves &CheckReserves &CheckWaiting &CancelReserve &FillReserve &ReserveWaiting &CreateReserve &updatereserves &UpdateReserve &getreservetitle &Findgroupreserve); # make all your functions, whether exported or not; @@ -510,7 +510,7 @@ sub updatereserves{ my ($rank,$biblio,$borrower,$del,$branch)=@_; my $dbh=C4Connect; my $query="Update reserves "; - if ($del ==0){ + if ($del == 0){ $query.="set priority='$rank',branchcode='$branch' where biblionumber=$biblio and borrowernumber=$borrower"; } else { @@ -543,6 +543,32 @@ sub updatereserves{ $sth->finish; $dbh->disconnect; } +sub UpdateReserve { + #subroutine to update a reserve + my ($rank,$biblio,$borrower,$branch)=@_; + return if $rank eq "W"; + my $dbh=C4Connect; + if ($rank eq "del") { + my $query = "UPDATE reserves SET cancellationdate=now() + WHERE biblionumber = ? + AND borrowernumber = ? + AND cancellationdate is NULL + AND (found <> 'F' or found is NULL)"; + my $sth=$dbh->prepare($query); + $sth->execute($biblio, $borrower); + $sth->finish; + } else { + my $query = "UPDATE reserves SET priority = ? ,branchcode = ?, itemnumber = NULL, found = NULL + WHERE biblionumber = ? + AND borrowernumber = ? + AND cancellationdate is NULL + AND (found <> 'F' or found is NULL)"; + my $sth=$dbh->prepare($query); + $sth->execute($rank, $branch, $biblio, $borrower); + $sth->finish; + } + $dbh->disconnect; +} sub getreservetitle { my ($biblio,$bor,$date,$timestamp)=@_; diff --git a/modrequest.pl b/modrequest.pl index a205ba9b91..aec24f1e93 100755 --- a/modrequest.pl +++ b/modrequest.pl @@ -39,17 +39,13 @@ my @biblio=$input->param('biblio'); my @borrower=$input->param('borrower'); my @branch=$input->param('pickup'); my $count=@rank; -my $del=0; + +# goes through and manually changes the reserves record.... +# no attempt is made to check consistency. for (my $i=0;$i<$count;$i++){ - if ($rank[$i] ne 'del' && $del == 0){ - updatereserves($rank[$i],$biblio[$i],$borrower[$i],0,$branch[$i]); #from C4::Reserves2 - - } elsif ($rank[$i] eq 'del'){ - updatereserves($rank[$i],$biblio[$i],$borrower[$i],1); #from C4::Reserves2 - $del=1; - } - + UpdateReserve($rank[$i],$biblio[$i],$borrower[$i],$branch[$i]); #from C4::Reserves2 } + my $from=$input->param('from'); if ($from eq 'borrower'){ print $input->redirect("/cgi-bin/koha/moremember.pl?bornum=$borrower[0]"); diff --git a/request.pl b/request.pl index 7844348dc0..8ed764e440 100755 --- a/request.pl +++ b/request.pl @@ -39,6 +39,7 @@ my $dat = bibdata($bib); # get existing reserves ..... my ($count,$reserves) = FindReserves($bib); +my $totalcount = $count; foreach my $res (@$reserves) { if ($res->{'found'} eq 'W') { $count--; @@ -111,7 +112,7 @@ EOF my $existingreserves = ""; foreach my $res (sort {$a->{'found'} cmp $b->{'found'}} @$reserves){ - my $prioropt = priorityoptions($count, $res->{'priority'}); + my $prioropt = priorityoptions($totalcount, $res->{'priority'}); my $bropt = branchoptions($res->{'branchcode'}); my $bor=$res->{'borrowernumber'}; $date = slashifyDate($res->{'reservedate'}); @@ -126,26 +127,26 @@ foreach my $res (sort {$a->{'found'} cmp $b->{'found'}} @$reserves){ my $notes = $res->{'reservenotes'}." "; my $rank; my $pickup; - my $change; if ($res->{'found'} eq 'W') { my %env; my $item = $res->{'itemnumber'}; $item = getiteminformation(\%env,$item); $item = "{'biblionumber'} &type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$item->{'barcode'}"; - my $wbra = $branches->{$res->{'branchcode'}}->{'branchname'}; - $rank = "Item waiting"; + my $wbrcd = $res->{'branchcode'}; + my $wbra = $branches->{$wbrcd}->{'branchname'}; $type = $item; - $pickup = "at ".$wbra.""; - $change = "delete"; + $rank = ""; + $pickup = "Item waiting at ".$wbra." "; } else { - $rank = ""; + $rank = ""; $pickup = ""; } $existingreserves .= <<"EOF"; + + {'borrowernumber'}> {'biblionumber'}> - -$rank +$rank $res->{'firstname'} $res->{'surname'} @@ -167,7 +168,7 @@ sub priorityoptions { if ($sel == $i){ $out .= " selected"; } - $out .= ">$i\n"; + $out .= ">$i\n"; } return $out; } @@ -182,21 +183,25 @@ sub branchoptions { if ($br eq $selbr) { $selected = "selected"; } - $out .= "\n"; } return $out; } +#get the time for the form name... +my $time = time(); + # printout the page -print $input->header; + + +print $input->header(-expires=>'now'); #setup colours -print startpage(); print startmenu('catalogue'); @@ -215,7 +220,7 @@ print < - + @@ -240,7 +245,7 @@ $branchoptions
Next Available,
(or choose from list below)
-

+ @@ -255,13 +260,15 @@ $branchoptions $bibitemrows
-

+

 

- + + +
@@ -269,7 +276,6 @@ $bibitemrows - -- 2.39.5
MODIFY EXISTING REQUESTS
Rank