#written 8/5/2002 by Finlay
#script to execute issuing of books
+
+# 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 CGI;
use C4::Circulation::Circ2;
use C4::Search;
use C4::Output;
-
+use C4::Print;
my %env;
my $headerbackgroundcolor='#99cc33';
($printer) || ($printer=$query->cookie('printer')) ;
#set up cookie.....
+my $info = '';
my $branchcookie;
my $printercookie;
-unless ($query->cookie('branch')) {
+if ($query->param('setcookies')) {
$branchcookie = $query->cookie(-name=>'branch', -value=>"$branch", -expires=>'+1y');
-}
-unless ($query->cookie('printer')) {
$printercookie = $query->cookie(-name=>'printer', -value=>"$printer", -expires=>'+1y');
}
$env{'queue'}=$printer;
my @datearr = localtime(time());
-my $todaysdate = (1900+$datearr[5]).sprintf ("%0.2d", ($datearr[4]+1)).sprintf ("%0.2d", $datearr[3]);
-
+my $tday = localtime(time());
+warn "today: $tday \n";
+my $todaysdate = (1900+$datearr[5]).sprintf ("%0.2d", ($datearr[4]+1)).sprintf ("%0.2d", ($datearr[3]));
+#warn $todaysdate;
my $message;
}
my $borrowernumber = $query->param('borrnumber');
+my $bornum = $query->param('borrnumber');
+# check and see if we should print
+my $print=$query->param('print');
+my $barcode = $query->param('barcode');
+if ($barcode eq '' && $print eq 'maybe'){
+ $print = 'yes';
+}
+if ($print eq 'yes' && $borrowernumber ne ''){
+ printslip(\%env,$borrowernumber);
+ $query->param('borrnumber','');
+ $borrowernumber='';
+}
+
+
# get the currently issued books......
my $borrower;
}
-# if the barcode is set
-my $barcode = $query->param('barcode');
+# if the barcode is set
my ($iteminformation, $duedate, $rejected, $question, $questionnumber, $defaultanswer);
my $year=$query->param('year');
my ($datedue, $invalidduedate) = fixdate($year, $month, $day);
unless ($invalidduedate) {
+ $env{'datedue'}=$datedue;
my @time=localtime(time);
my $date= (1900+$time[5])."-".($time[4]+1)."-".$time[3];
($iteminformation, $duedate, $rejected, $question, $questionnumber, $defaultanswer, $message)
} else {
$rejectedtext = << "EOF";
<table border=1 cellpadding=5 cellspacing=0 bgcolor="#dddddd">
-<tr><th><font color=black size=6>Error Issuing Book</font></th></tr>
-<tr><td><font color=red size=6>$rejected</font></td></tr>
+<tr><th><font color=black size=5>Error Issuing Book</font></th></tr>
+<tr><td><font color=red size=5>$rejected</font></td></tr>
</table>
<br>
EOF
my $selectborrower;
if ($borrowerslist) {
$selectborrower = <<"EOF";
-<form method=get action=/cgi-bin/koha/circ/issues.pl>
+<form method=post action=/cgi-bin/koha/circ/circulation.pl>
<input type=hidden name=branch value=$branch>
<input type=hidden name=printer value=$printer>
<table border=1 cellspacing=0 cellpadding=5 bgcolor="#dddddd">
# title....
my $title = <<"EOF";
-<p>
-<table border=0 cellpadding=5 width=90%><tr>
-<td align="left"><FONT SIZE=6><em>Circulation: Issues</em></FONT><br>
+<table align="right"><tr><td>
+<a href=circulation.pl?borrnumber=$borrowernumber&branch=$branch&printer=$printer&print=yes>
+<img src="/images/button-next-borrower.gif" width="171" height="42" border="0" alt="Next Borrower"></a>  
+<a href=returns.pl>
+<img src="/images/button-returns.gif" width="110" height="42" border="0" alt="Returns"></a>
+ <a href=branchtransfers.pl>
+<img src="/images/button-transfers.gif" width="127" height="42" border="0" alt="Transfers">
+</a>
+</td></tr></table>
+<FONT SIZE=6><em>Circulation: Issues</em></FONT><br>
<b>Branch:</b> $branches->{$branch}->{'branchname'}  
<b>Printer:</b> $printers->{$printer}->{'printername'} <br>
<a href=selectbranchprinter.pl>Change Settings</a></td>
-<td align="right" valign="top">
-<FONT SIZE=2 face="arial, helvetica">
-<a href=circulation.pl>Next Borrower</a> ||
-<a href=returns.pl>Returns</a> ||
-<a href=branchtransfers.pl>Transfers</a></font><p>
+<input type=hidden name=branch value=$branch>
+<input type=hidden name=printer value=$printer>
+<p>
+EOF
+
+my $titlenoborrower = <<"EOF";
+<table align="right"><tr><td>
+<a href=returns.pl>
+<img src="/images/button-returns.gif" width="110" height="42" border="0" alt="Returns"></a>
+ <a href=branchtransfers.pl>
+<img src="/images/button-transfers.gif" width="127" height="42" border="0" alt="Transfers">
+</a>
</td></tr></table>
+<FONT SIZE=6><em>Circulation: Issues</em></FONT><br>
+<b>Branch:</b> $branches->{$branch}->{'branchname'}  
+<b>Printer:</b> $printers->{$printer}->{'printername'} <br>
+<a href=selectbranchprinter.pl>Change Settings</a></td>
<input type=hidden name=branch value=$branch>
<input type=hidden name=printer value=$printer>
-</p>
+<p>
EOF
my $cardnumberinput = << "EOF";
-<form method=get action=/cgi-bin/koha/circ/issues.pl>
+<form method=post action=/cgi-bin/koha/circ/circulation.pl>
<table border=1 cellpadding=5 cellspacing=0 bgcolor="#dddddd">
<tr><th bgcolor=$headerbackgroundcolor background=$backgroundimage>
<font color=black><b>Enter borrower card number<br> or partial last name</b></font></td></tr>
<tr><td><input name=findborrower></td></tr>
-</table>
-<input type=hidden name=branch value=$branch>
+ <input type=hidden name=branch value=$branch>
<input type=hidden name=printer value=$printer>
+</table>
</form>
EOF
my $barcodeentrytext = <<"EOF";
-<form method=post action=/cgi-bin/koha/circ/issues.pl>
+<form method=post action=/cgi-bin/koha/circ/circulation.pl>
<table border=1 cellpadding=5>
<tr>
<td align=center valign=top>
<input type=hidden name=borrnumber value=$borrowernumber>
<input type=hidden name=branch value=$branch>
<input type=hidden name=printer value=$printer>
+<input type=hidden name=print value=maybe>
+EOF
+if ($flags->{'CHARGES'}){
+ $barcodeentrytext.="<input type=hidden name=charges value=yes>";
+}
+my $amountold=$flags->{'CHARGES'}->{'message'};
+my @temp=split(/\$/,$amountold);
+$amountold=$temp[1];
+$barcodeentrytext.="<input type=hidden name=oldamount value=$amountold>";
+$barcodeentrytext.=<<"EOF";
</td></tr></table>
</td></tr></table>
</form>
# make the issued books table.....
my $todaysissues='';
my $previssues='';
-my $info='';
if ($borrower) {
+ my @todaysissues;
+ my @previousissues;
my $issueslist = getissues($borrower);
- my $tcolor = '';
- my $pcolor = '';
- foreach my $it (sort keys %$issueslist) {
- my $dd = $issueslist->{$it}->{'date_due'};
+ foreach my $it (keys %$issueslist) {
my $issuedate = $issueslist->{$it}->{'timestamp'};
$issuedate = substr($issuedate, 0, 8);
-
- my $bookissue = $issueslist->{$it};
- my $bgcolor='';
- my $datedue = $bookissue->{'date_due'};
+ if ($todaysdate == $issuedate) {
+ push @todaysissues, $issueslist->{$it};
+ } else {
+ push @previousissues, $issueslist->{$it};
+ }
+ }
+ my $tcolor = '';
+ my $pcolor = '';
+ foreach my $book (sort {$b->{'timestamp'} <=> $a->{'timestamp'}} @todaysissues){
+ my $dd = $book->{'date_due'};
+ my $datedue = $book->{'date_due'};
#convert to nz style dates
#this should be set with some kinda config variable
my @tempdate=split(/-/,$dd);
if ($datedue < $todaysdate) {
$dd="<font color=red>$dd</font>\n";
}
- if ($todaysdate == $issuedate) {
- ($tcolor eq $linecolor1) ? ($tcolor=$linecolor2) : ($tcolor=$linecolor1);
- $todaysissues .=<< "EOF";
+ ($tcolor eq $linecolor1) ? ($tcolor=$linecolor2) : ($tcolor=$linecolor1);
+ $todaysissues .=<< "EOF";
<tr><td bgcolor=$tcolor align=center>$dd</td>
<td bgcolor=$tcolor align=center>
-<a href=/cgi-bin/koha/detail.pl?bib=$bookissue->{'biblionumber'}&type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$bookissue->{'barcode'}</a></td>
-<td bgcolor=$tcolor>$bookissue->{'title'}</td>
-<td bgcolor=$tcolor>$bookissue->{'author'}</td>
-<td bgcolor=$tcolor align=center>$bookissue->{'dewey'} $bookissue->{'subclass'}</td></tr>
+<a href=/cgi-bin/koha/detail.pl?bib=$book->{'biblionumber'}&type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$book->{'barcode'}</a></td>
+<td bgcolor=$tcolor>$book->{'title'}</td>
+<td bgcolor=$tcolor>$book->{'author'}</td>
+<td bgcolor=$tcolor align=center>$book->{'dewey'} $book->{'subclass'}</td></tr>
EOF
- } else {
- ($pcolor eq $linecolor1) ? ($pcolor=$linecolor2) : ($pcolor=$linecolor1);
- $previssues .= << "EOF";
+ }
+ foreach my $book (sort {$a->{'due_date'} <=> $b->{'due_date'}} @previousissues){
+ my $dd = $book->{'date_due'};
+ my $datedue = $book->{'date_due'};
+ #convert to nz style dates
+ #this should be set with some kinda config variable
+ my @tempdate=split(/-/,$dd);
+ $dd="$tempdate[2]/$tempdate[1]/$tempdate[0]";
+ $datedue=~s/-//g;
+ if ($datedue < $todaysdate) {
+ $dd="<font color=red>$dd</font>\n";
+ }
+ ($pcolor eq $linecolor1) ? ($pcolor=$linecolor2) : ($pcolor=$linecolor1);
+ $previssues .= << "EOF";
<tr><td bgcolor=$pcolor align=center>$dd</td>
<td bgcolor=$pcolor align=center>
-<a href=/cgi-bin/koha/detail.pl?bib=$bookissue->{'biblionumber'}&type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$bookissue->{'barcode'}</a></td>
-<td bgcolor=$pcolor>$bookissue->{'title'}</td>
-<td bgcolor=$pcolor>$bookissue->{'author'}</td>
-<td bgcolor=$pcolor align=center>$bookissue->{'dewey'} $bookissue->{'subclass'}</td></tr>
+<a href=/cgi-bin/koha/detail.pl?bib=$book->{'biblionumber'}&type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$book->{'barcode'}</a></td>
+<td bgcolor=$pcolor>$book->{'title'}</td>
+<td bgcolor=$pcolor>$book->{'author'}</td>
+<td bgcolor=$pcolor align=center>$book->{'dewey'} $book->{'subclass'}</td></tr>
EOF
- }
}
}
}
print startpage();
-print startmenu('circulation');
+my @inp=startmenu('circulation');
+if ($query->param('barcode') eq '' && $query->param('charges') eq 'yes'){
+ my $count=@inp;
+ for (my $i=0;$i<$count;$i++){
+ $inp[$i]=~ s/onLoad=focusinput\(\)/onLoad=focusinput\(\)\;messenger\(\"\/cgi-bin\/koha\/pay.pl?bornum=$bornum\",700,600\)\;window1.focus\(\)/;
+ }
+}
+
+print @inp;
-print $title;
+
+#print startmenu('circulation');
+if ($borrower) {
+ print $title;
+} else {
+ print $titlenoborrower;
+}
print $info;
print $rejectedtext;
print $messagetable;
+
unless ($borrower) {
if ($borrowerslist) {
print $selectborrower;
print $patrontable;
print $flaginfotable;
print $barcodeentrytext;
- print "<p clear=all>";
+ print "<p clear=all><br><br>";
print $issuedbookstable;
}
-
+sub printslip {
+ my ($env,$borrowernumber)=@_;
+ my ($borrower, $flags) = getpatroninformation($env,$borrowernumber,0);
+ $env->{'todaysissues'}=1;
+ my ($borrowerissues) = currentissues($env, $borrower);
+ $env->{'nottodaysissues'}=1;
+ $env->{'todaysissues'}=0;
+ my ($borroweriss2)=currentissues($env, $borrower);
+ $env->{'nottodaysissues'}=0;
+ my $i=0;
+ my @issues;
+ foreach (sort keys %$borrowerissues) {
+ $issues[$i]=$borrowerissues->{$_};
+ my $dd=$issues[$i]->{'date_due'};
+ #convert to nz style dates
+ #this should be set with some kinda config variable
+ my @tempdate=split(/-/,$dd);
+ $issues[$i]->{'date_due'}="$tempdate[2]/$tempdate[1]/$tempdate[0]";
+ $i++;
+ }
+ foreach (sort keys %$borroweriss2) {
+ $issues[$i]=$borroweriss2->{$_};
+ my $dd=$issues[$i]->{'date_due'};
+ #convert to nz style dates
+ #this should be set with some kinda config variable
+ my @tempdate=split(/-/,$dd);
+ $issues[$i]->{'date_due'}="$tempdate[2]/$tempdate[1]/$tempdate[0]";
+ $i++;
+ }
+ remoteprint($env,\@issues,$borrower);
+}