diff --git a/C4/Circulation/Circ2.pm b/C4/Circulation/Circ2.pm index 1dc21055c1..0913771a80 100755 --- a/C4/Circulation/Circ2.pm +++ b/C4/Circulation/Circ2.pm @@ -137,8 +137,15 @@ sub getiteminformation { $sth->execute; my $iteminformation=$sth->fetchrow_hashref; $sth->finish; + if ($iteminformation) { + $sth=$dbh->prepare("select date_due from issues where itemnumber=$iteminformation->{'itemnumber'} and isnull(returndate)"); + $sth->execute; + my ($date_due) = $sth->fetchrow; + $iteminformation->{'date_due'}=$date_due; + $sth->finish; + $iteminformation->{'dewey'}=~s/0*$//; + } $dbh->disconnect; - $iteminformation->{'dewey'}=~s/0*$//; return($iteminformation); } @@ -189,6 +196,10 @@ sub issuebook { $rejected=sprintf "Patron owes \$%.02f.", $amount; last SWITCH; } + unless ($iteminformation) { + $rejected="$barcode is not a valid barcode."; + last SWITCH; + } if ($iteminformation->{'notforloan'} == 1) { $rejected="Item not for loan."; last SWITCH; diff --git a/circ/circulation.pl b/circ/circulation.pl index a838c7be75..f66b32d3d6 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -7,16 +7,48 @@ use DBI; my %env; +my $headerbackgroundcolor='#990000'; my $query=new CGI; -print $query->header; -print startpage(); -print startmenu('circulation'); my $branches=getbranches(\%env); my $printers=getprinters(\%env); my $branch=$query->param('branch'); my $printer=$query->param('printer'); +($branch) || ($branch=$query->cookie('branch')); +($printer) || ($printer=$query->cookie('printer')); +my ($oldbranch, $oldprinter); +if ($query->param('selectnewbranchprinter')) { + $oldbranch=$branch; + $oldprinter=$printer; + $branch=''; + $printer=''; +} $env{'branchcode'}=$branch; $env{'printer'}=$printer; +my $branchcount=0; +my $printercount=0; +my $branchoptions; +my $printeroptions; +foreach (keys %$branches) { + (next) unless ($_); + $branchcount++; + my $selected=''; + ($selected='selected') if ($_ eq $oldbranch); + $branchoptions.="$branches->{$_}->{'branchname'}\n"; +} +foreach (keys %$printers) { + (next) unless ($_); + $printercount++; + my $selected=''; + ($selected='selected') if ($_ eq $oldprinter); + $printeroptions.="$printers->{$_}->{'printername'}\n"; +} +if ($printercount==1) { + ($printer)=keys %$printers; +} +if ($branchcount==1) { + ($branch)=keys %$branches; +} + my $branchname=''; my $printername=''; @@ -24,18 +56,30 @@ if ($branch && $printer) { $branchname=$branches->{$branch}->{'branchname'}; $printername=$printers->{$printer}->{'printername'}; } + + +my $branchcookie=$query->cookie(-name=>'branch', -value=>"$branch", -expires=>'+1y'); +my $printercookie=$query->cookie(-name=>'printer', -value=>"$printer", -expires=>'+1y'); + +print $query->header(-type=>'text/html',-expires=>'now', -cookie=>[$branchcookie,$printercookie]); +print startpage(); +print startmenu('circulation'); + + print << "EOF"; -$branchname +$branchname + +Set Branch/Printer -$printername +$printername @@ -44,7 +88,6 @@ print << "EOF"; EOF - if ($printer && $branch) { SWITCH: { @@ -53,25 +96,11 @@ if ($printer && $branch) { issues(); } } else { - my $branchcount=0; - my $printercount=0; - my $branchoptions; - my $printeroptions; - foreach (keys %$branches) { - (next) unless ($_); - $branchcount++; - $branchoptions.="$branches->{$_}->{'branchname'}\n"; - } - foreach (keys %$printers) { - (next) unless ($_); - $printercount++; - $printeroptions.="$printers->{$_}->{'printername'}\n"; - } my ($printerform, $branchform); if ($printercount>1) { $printerform=<<"EOF"; -Choose a Printer +Choose a Printer $printeroptions @@ -89,7 +118,7 @@ EOF if ($branchcount>1) { $branchform=<<"EOF"; -Choose a Branch +Choose a Branch $branchoptions @@ -99,7 +128,7 @@ $branchoptions EOF } print << "EOF"; - Select a printer and a branch + Select a branch and a printer @@ -125,36 +154,93 @@ EOF sub returns { + my %returneditems; + foreach ($query->param) { + (next) unless (/ri-(\d*)/); + my $counter=$1; + (next) if ($counter>20); + my $barcode=$query->param("ri-$counter"); + $counter++; + $returneditems{$counter}=$barcode; + $ritext.="\n"; + } + if (my $barcode=$query->param('barcode')) { + $ritext.="\n"; + $returneditems{0}=$barcode; + } + print << "EOF"; - ReturnsEnter Book Barcode + ReturnsEnter Book Barcode Item Barcode: + $ritext EOF if (my $barcode=$query->param('barcode')) { - print "Returning $barcode\n"; my ($iteminformation, $borrower, $messages, $overduecharge) = returnbook(\%env, $barcode); + (my $nosuchitem=1) unless ($iteminformation); my $itemtable=<<"EOF"; -Item Information +Item Information Title: $iteminformation->{'title'} Author: $iteminformation->{'author'} -Barcode: $iteminformation->{'barcode'} +Barcode: {'biblionumber'}&type=intra onClick="openWindow(this, 'Item', 480, 640)">$iteminformation->{'barcode'} +Date Due: $iteminformation->{'date_due'} EOF - if ($borrower) { - my ($patrontable, $flaginfotext) = patrontable($borrower); - print "$patrontable$flaginfotext$itemtable\n"; + if ($nosuchitem) { + print << "EOF"; + + Error + + + + $barcode is not a valid barcode. + + + + +EOF } else { - print "Not loaned out.\n"; + if ($borrower) { + my ($patrontable, $flaginfotext) = patrontable($borrower); + print "$patrontable$flaginfotext$itemtable\n"; + } else { + print << "EOF"; + + Error + + + + $iteminformation->{'title'} by $iteminformation->{'author'} was not loaned out. + + + + +EOF + } } + print << "EOF"; + + + + + Returned Items + Bar CodeTitleAuthorClass +EOF + foreach (sort {$a <=> $b} keys %returneditems) { + my $barcode=$returneditems{$_}; + my ($iteminformation) = getiteminformation(\$env, 0, $barcode); + print "{'biblionumber'}&type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$barcode$iteminformation->{'title'}$iteminformation->{'author'}$iteminformation->{'dewey'} $iteminformation->{'subclass'}\n"; + } + print "\n"; } } @@ -200,12 +286,26 @@ sub issues { } unless ($invalidduedate) { my ($iteminformation, $duedate, $rejected, $question, $questionnumber, $defaultanswer, $message) = issuebook(\%env, $borrower, $barcode, \%responses); + unless ($iteminformation) { + print << "EOF"; + + Error + + + + $barcode is not a valid barcode. + + + + +EOF + } if ($rejected) { if ($rejected == -1) { } else { print << "EOF" - Error Issuing Book + Error Issuing Book $rejected @@ -220,7 +320,7 @@ EOF my $stickyduedate=$query->param('stickyduedate'); print << "EOF"; - Issuing Question + Issuing Question @@ -277,7 +377,7 @@ EOF if ($message) { print << "EOF"; - Message + Message $message @@ -304,7 +404,7 @@ EOF } } if ($flaginfotext) { - $flaginfotext="Patron Flags$flaginfotext\n"; + $flaginfotext="Patron Flags$flaginfotext\n"; } $env{'nottodaysissues'}=1; my ($borrowerissues) = currentissues(\%env, $borrower); @@ -323,12 +423,13 @@ EOF if ($datedue < $todaysdate) { $bgcolor="bgcolor=red"; } - $previssues.="$bookissue->{'date_due'}$bookissue->{'barcode'}$bookissue->{'title'}$bookissue->{'author'}$bookissue->{'dewey'} $bookissue->{'subclass'}\n"; + #$previssues.="$bookissue->{'date_due'}$bookissue->{'barcode'}$bookissue->{'title'}$bookissue->{'author'}$bookissue->{'dewey'} $bookissue->{'subclass'}\n"; + $previssues.="$bookissue->{'date_due'}{'biblionumber'}&type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$bookissue->{'barcode'}$bookissue->{'title'}$bookissue->{'author'}$bookissue->{'dewey'} $bookissue->{'subclass'}\n"; } my $todaysissues=''; foreach (sort keys %$today) { my $bookissue=$today->{$_}; - $todaysissues.="$bookissue->{'date_due'}$bookissue->{'barcode'}$bookissue->{'title'}$bookissue->{'author'}$bookissue->{'dewey'} $bookissue->{'subclass'}\n"; + $todaysissues.="$bookissue->{'date_due'}{'biblionumber'}&type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$bookissue->{'barcode'}$bookissue->{'title'}$bookissue->{'author'}$bookissue->{'dewey'} $bookissue->{'subclass'}\n"; } for ($i=1; $i<32; $i++) { my $selected=''; @@ -362,9 +463,9 @@ EOF - + - Enter Book Barcode + Enter Book Barcode Item Barcode: @@ -382,7 +483,7 @@ EOF - + $patrontable $flaginfotable @@ -391,7 +492,7 @@ EOF - Issues Today + Issues Today Due DateBar CodeTitleAuthorClass $todaysissues @@ -400,7 +501,7 @@ EOF - Previous Issues + Previous Issues Due DateBar CodeTitleAuthorClass $previssues @@ -429,7 +530,7 @@ EOF print "\n"; print "\n"; print ""; - print "IssuesSelect a borrower\n"; + print "IssuesSelect a borrower\n"; print "\n"; print "\n"; foreach (sort {$a->{'surname'}.$a->{'firstname'} cmp $b->{'surname'}.$b->{'firstname'}} @$borrowers) { @@ -443,7 +544,7 @@ EOF print << "EOF"; -IssuesEnter borrower card number or partial last name +IssuesEnter borrower card number or partial last name @@ -471,17 +572,25 @@ sub patrontable { } $flags->{$flag}->{'message'}=~s/\n//g; if ($flags->{$flag}->{'noissues'}) { - $flaginfotext.="$flag$flags->{$flag}->{'message'}\n"; + if ($flag eq 'CHARGES') { + $flaginfotext.="$flag$flags->{$flag}->{'message'} {'borrowernumber'} onClick=\"openWindow(this, 'Payment', 480,640)\">Payment\n"; + } else { + $flaginfotext.="$flag$flags->{$flag}->{'message'}\n"; + } } else { - $flaginfotext.="$flag$flags->{$flag}->{'message'}\n"; + if ($flag eq 'CHARGES') { + $flaginfotext.="$flag$flags->{$flag}->{'message'} {'borrowernumber'} onClick=\"openWindow(this, 'Payment', 480,640)\">Payment\n"; + } else { + $flaginfotext.="$flag$flags->{$flag}->{'message'}\n"; + } } } - ($flaginfotext) && ($flaginfotext="Patron Flags$flaginfotext\n"); + ($flaginfotext) && ($flaginfotext="Patron Flags$flaginfotext\n"); my $patrontable= << "EOF"; - Patron Information + Patron Information - $borrower->{'cardnumber'} $borrower->{'surname'}, $borrower->{'title'} $borrower->{'firstname'} + {'borrowernumber'} onClick="openWindow(this,'Member', 480, 640)">$borrower->{'cardnumber'} $borrower->{'surname'}, $borrower->{'title'} $borrower->{'firstname'} $borrower->{'streetaddress'} $borrower->{'city'} $borrower->{'categorycode'} $flagtext
+
@@ -304,7 +404,7 @@ EOF } } if ($flaginfotext) { - $flaginfotext="