Next Borrower ||
Returns ||
Transfers
Circulation: Issues
EOF
}
if (my $borrnumber=$query->param('borrnumber')) {
my ($borrower, $flags) = getpatroninformation(\%env,$borrnumber,0);
my $year=$query->param('year');
my $month=$query->param('month');
my $day=$query->param('day');
if (my $barcode=$query->param('barcode')) {
# decode cuecat
chomp($barcode);
@fields = split(/\./,$barcode);
@results = map(decode($_), @fields[1..$#fields]);
if ($#results == 2)
{
$barcode=$results[2];
}
# end decode
my $invalidduedate=0;
$env{'datedue'}='';
if (($year eq 0) && ($month eq 0) && ($year eq 0)) {
$env{'datedue'}='';
} else {
if (($year eq 0) || ($month eq 0) || ($year eq 0)) {
print "Invalid Due Date Specified. Book was not issued.\n";
$invalidduedate=1;
} else {
if (($day>30) && (($month==4) || ($month==6) || ($month==9) || ($month==11))) {
print "Invalid Due Date Specified. Book was not issued. Only 30 days in $month month.
\n";
$invalidduedate=1;
} elsif (($day>29) && ($month==2)) {
print "Invalid Due Date Specified. Book was not issued. Never that many days in February!
\n";
$invalidduedate=1;
} elsif (($month==2) && ($day>28) && (($year%4) && ((!($year%100) || ($year%400))))) {
print "Invalid Due Date Specified. Book was not issued. $year is not a leap year.
\n";
$invalidduedate=1;
} else {
$env{'datedue'}="$year-$month-$day";
}
}
}
my %responses;
foreach (sort $query->param) {
if ($_ =~ /response-(\d*)/) {
$responses{$1}=$query->param($_);
}
}
if (my $qnumber=$query->param('questionnumber')) {
$responses{$qnumber}=$query->param('answer');
}
unless ($invalidduedate) {
my @time=localtime(time);
my $date= (1900+$time[5])."-".($time[4]+1)."-".$time[3];
my ($iteminformation, $duedate, $rejected, $question, $questionnumber, $defaultanswer, $message) = issuebook(\%env, $borrower, $barcode, \%responses,$date);
unless ($iteminformation) {
print << "EOF";
Error
$barcode is not a valid barcode.
EOF
}
if ($rejected) {
if ($rejected == -1) {
} else {
print << "EOF"
Error Issuing Book
$rejected
EOF
}
}
my $responsesform='';
foreach (keys %responses) {
$responsesform.=" \n";
}
if ($question) {
my $stickyduedate=$query->param('stickyduedate');
print << "EOF";
Issuing Question
Attempting to issue $iteminformation->{'title'} by $iteminformation->{'author'} to $borrower->{'firstname'} $borrower->{'surname'}.
$question
EOF
return;
}
if ($message) {
print << "EOF";
EOF
}
}
}
my $issueid=$query->param('issueid');
($issueid) || ($issueid=int(rand()*1000000000));
my $flag='';
my $flagtext='';
my $flaginfotext='';
foreach $flag (sort keys %$flags) {
if ($flags->{$flag}->{'noissues'}) {
$flagtext.="$flag ";
} else {
$flagtext.="$flag ";
}
$flags->{$flag}->{'message'}=~s/\n/ /g;
if ($flags->{$flag}->{'noissues'}) {
$flaginfotext.="
$flag $flags->{$flag}->{'message'} \n";
} else {
$flaginfotext.="$flag $flags->{$flag}->{'message'} \n";
}
}
if ($flaginfotext) {
$flaginfotext="Patron Flags $flaginfotext
\n";
}
$env{'nottodaysissues'}=1;
my ($borrowerissues) = currentissues(\%env, $borrower);
$env{'nottodaysissues'}=0;
$env{'todaysissues'}=1;
my ($today) = currentissues(\%env, $borrower);
$env{'todaysissues'}=0;
my $previssues='';
my @datearr = localtime(time());
my $todaysdate = (1900+$datearr[5]).sprintf ("%0.2d", ($datearr[4]+1)).sprintf ("%0.2d", $datearr[3]);
my $color='';
foreach (sort keys %$borrowerissues) {
($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
my $bookissue=$borrowerissues->{$_};
my $bgcolor='';
my $datedue=$bookissue->{'date_due'};
my $dd=$bookissue->{'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="$dd \n";
}
$previssues.="$dd {'biblionumber'}&type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$bookissue->{'barcode'} $bookissue->{'title'} $bookissue->{'author'} $bookissue->{'dewey'} $bookissue->{'subclass'} \n";
}
my $todaysissues='';
$color='';
foreach (sort keys %$today) {
($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
my $bookissue=$today->{$_};
$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='';
if (($query->param('stickyduedate')) && ($day==$i)) {
$selected='selected';
}
$dayoptions.="$i";
}
my $counter=1;
foreach (('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')) {
my $selected='';
if (($query->param('stickyduedate')) && ($month==$counter)) {
$selected='selected';
}
$monthoptions.=" $_";
$counter++;
}
for ($i=$datearr[5]+1900; $i<$datearr[5]+1905; $i++) {
my $selected='';
if (($query->param('stickyduedate')) && ($year==$i)) {
$selected='selected';
}
$yearoptions.=" $i";
}
my $selected='';
($query->param('stickyduedate')) && ($selected='checked');
my ($borrower, $flags) = getpatroninformation(\%env,$borrnumber,0);
my ($patrontable, $flaginfotable) = patrontable($borrower);
print << "EOF";
$patrontable
$flaginfotable
Issues Branch: $branch,
Printer: $printer
EOF
}
}
}
sub patrontable {
my ($borrower) = @_;
my $flags=$borrower->{'flags'};
my $flagtext='';
my $flaginfotable='';
my $flaginfotext='';
my $flag;
foreach $flag (sort keys %$flags) {
($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
if ($flags->{$flag}->{'noissues'}) {
$flagtext.="$flag ";
} else {
$flagtext.="$flag ";
}
$flags->{$flag}->{'message'}=~s/\n/ /g;
if ($flags->{$flag}->{'noissues'}) {
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 {
if ($flag eq 'CHARGES') {
$flaginfotext.="$flag $flags->{$flag}->{'message'} {'borrowernumber'} onClick=\"openWindow(this, 'Payment', 480,640)\">Payment \n";
} elsif ($flag eq 'WAITING') {
my $itemswaiting='';
my $items=$flags->{$flag}->{'itemlist'};
foreach $item (@$items) {
my ($iteminformation) = getiteminformation($env, $item->{'itemnumber'}, 0);
$itemswaiting.="{'biblionumber'}&type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$iteminformation->{'barcode'} $iteminformation->{'title'} ($branches->{$iteminformation->{'holdingbranch'}}->{'branchname'}) \n";
}
$flaginfotext.="$flag $itemswaiting \n";
} elsif ($flag eq 'ODUES') {
my $items=$flags->{$flag}->{'itemlist'};
my $itemswaiting="\n";
if ($query->param('module') ne 'returns'){
$flaginfotext.="$flag $flags->{$flag}->{'message'}, See below \n";
} else {
$flaginfotext.="$flag $flags->{$flag}->{'message'} \n";
}
} else {
$flaginfotext.="$flag $flags->{$flag}->{'message'} \n";
}
}
}
($flaginfotext) && ($flaginfotext="Flags $flaginfotext\n");
$flaginfotext.="";
my $patrontable= << "EOF";