#!/usr/bin/perl #this code has been modified (slightly) by Trendsetters (originally from circulation.pl) # Please use 8-character tabs for this file (indents are every 4 characters) #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; use C4::Search; use C4::Output; use C4::Print; use DBI; use C4::Authsco; use C4::Output; use C4::Koha; use HTML::Template::Pro; use C4::Date; my $query=new CGI; #my ($loggedinuser, $sessioncookie, $sessionID) = checkauth # ($query, 0, { circulate => 1 }); my ($template, $loggedinuser, $cookie) = get_template_and_user ({ #Begin code modified by Christina Lee template_name => 'sco/receipt.tmpl', query => $query, type => "opac", authnotrequired => 0, flagsrequired => { borrow => 1 }, # End Code Modified by Christina Lee }); #Begin code by Christina Lee--Sets variable $borr equal to loggedinuser's data my ($borr, $flags) = getpatroninformation(undef, $loggedinuser); # End code by Christina Lee my %env; my $linecolor1='#339999'; my $linecolor2='white'; my $branches = getbranches(); my $printers = getprinters(\%env); my $branch = "APL"; #getbranch($query, $branches); my $printer = getprinter($query, $printers); #set up cookie..... my $branchcookie; my $printercookie; if ($query->param('setcookies')) { $branchcookie = $query->cookie(-name=>'branch', -value=>"$branch", -expires=>'+1y'); $printercookie = $query->cookie(-name=>'printer', -value=>"$printer", -expires=>'+1y'); } $env{'branchcode'}=$branch; $env{'printer'}=$printer; $env{'queue'}=$printer; my @datearr = localtime(time()); # FIXME - Could just use POSIX::strftime("%Y%m%d", localtime); my $todaysdate = (1900+$datearr[5]).sprintf ("%0.2d", ($datearr[4]+1)).sprintf ("%0.2d", ($datearr[3])); #warn $todaysdate; ################# Start code modified by Christina Lee########################### # get borrower information .... #my ($borr, $flags) = getpatroninformation(undef, $loggedinusername); #my @bordat; #$bordat[0] = $borr; #$template->param(BORROWER_INFO => \@bordat); ######################End code modified by christina Lee############################ my $message; my $borrowerslist; # if there is a list of find borrowers.... my $findborrower = $query->param('findborrower'); if ($findborrower) { my ($count,$borrowers)=BornameSearch(\%env,$findborrower,'web'); my @borrowers=@$borrowers; if ($#borrowers == -1) { $query->param('findborrower', ''); $message = "'$findborrower'"; } elsif ($#borrowers == 0) { $query->param('borrnumber', $borrowers[0]->{'borrowernumber'}); $query->param('barcode',''); } else { $borrowerslist = \@borrowers; } } 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 borrower information..... my $borrower; my $flags; if ($borrowernumber) { ($borrower, $flags) = getpatroninformation(\%env,$borrowernumber,0); } # get the responses to any questions..... my %responses; foreach (sort $query->param) { if ($_ =~ /response-(\d*)/) { $responses{$1} = $query->param($_); } } if (my $qnumber = $query->param('questionnumber')) { $responses{$qnumber} = $query->param('answer'); } my ($iteminformation, $duedate, $rejected, $question, $questionnumber, $defaultanswer); #Begin code edited by Christina Lee #my $barc = 123456789; my $barc = cuecatbarcodedecode($barcode); (my $year, my $month, my $day) = set_duedate($barc); #End code edited by Christina Lee # if the barcode is set if ($barcode) { $barcode = cuecatbarcodedecode($barcode); #note: edit code here --Christina Lee 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) = issuebook(\%env, $borr, $barcode, \%responses, $date); } } # reload the borrower info for the sake of reseting the flags..... if ($borrowernumber) { ($borrower, $flags) = getpatroninformation(\%env,$borrowernumber,0); } ################################################################################## # HTML code.... my %responseform; my @responsearray; foreach (keys %responses) { # $responsesform.="\n"; $responseform{'name'}=$_; $responseform{'value'}=$responses{$_}; push @responsearray,\%responseform; } my $questionform; my $stickyduedate; if ($question) { $stickyduedate=$query->param('stickyduedate'); } # Barcode entry box, with hidden inputs attached.... # FIXME - How can we move this HTML into the template? Can we create # arrays of the months, dates, etc and use in the template to # output the data that's getting built here? my $counter = 1; my $dayoptions = ''; my $monthoptions = ''; my $yearoptions = ''; for (my $i=1; $i<32; $i++) { my $selected=''; if (($query->param('stickyduedate')) && ($day==$i)) { $selected='selected'; } $dayoptions.="