diff --git a/C4/Circulation/Circ2.pm b/C4/Circulation/Circ2.pm
index b5555ed76b..a544d2e72e 100755
--- a/C4/Circulation/Circ2.pm
+++ b/C4/Circulation/Circ2.pm
@@ -279,6 +279,9 @@ sub issuebook {
my $datedue=time+($loanlength)*86400;
my @datearr = localtime($datedue);
$dateduef = (1900+$datearr[5])."-".($datearr[4]+1)."-".$datearr[3];
+ if ($env->{'datedue'}) {
+ $dateduef=$env->{'datedue'};
+ }
my $sth=$dbh->prepare("insert into issues (borrowernumber, itemnumber, date_due, branchcode) values ($patroninformation->{'borrowernumber'}, $iteminformation->{'itemnumber'}, '$dateduef', '$env->{'branchcode'}')");
$sth->execute;
$sth->finish;
diff --git a/circ/circulation.pl b/circ/circulation.pl
index baf2000bec..754cf46dfc 100755
--- a/circ/circulation.pl
+++ b/circ/circulation.pl
@@ -35,10 +35,58 @@ print << "EOF";
EOF
}
+
+sub returns {
+ if (my $barcode=$query->param('barcode')) {
+ print "Returning $barcode
\n";
+ my ($iteminformation, $borrower, $messages, $overduecharge) = returnbook(\%env, $barcode);
+ if ($borrower) {
+ print "Borrowed by $borrower->{'title'} $borrower->{'firstname'} $borrower->{'surname'}
\n"; + } else { + print "Not loaned out.\n"; + } + } + print << "EOF"; +
+EOF +} + sub issues { 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')) { + 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.
\n"; + $invalidduedate=1; + } elsif (($day>29) && ($month==2)) { + print "Invalid Due Date Specified. Book was not issued.
\n"; + $invalidduedate=1; + } elsif (($day>28) && (($year%4) && ((!($year%100) || ($year%400))))) { + print "Invalid Due Date Specified. Book was not issued.
\n";
+ $invalidduedate=1;
+ } else {
+ $env{'datedue'}="$year-$month-$day";
+ }
+ }
+ }
my %responses;
foreach (sort $query->param) {
if ($_ =~ /response-(\d*)/) {
@@ -48,65 +96,90 @@ sub issues {
if (my $qnumber=$query->param('questionnumber')) {
$responses{$qnumber}=$query->param('answer');
}
- my ($iteminformation, $duedate, $rejected, $question, $questionnumber, $defaultanswer) = issuebook(\%env, $borrower, $barcode, \%responses);
- if ($rejected) {
- if ($rejected == -1) {
- } else {
- print "Error issuing book: $rejected
\n";
+ unless ($invalidduedate) {
+ my ($iteminformation, $duedate, $rejected, $question, $questionnumber, $defaultanswer) = issuebook(\%env, $borrower, $barcode, \%responses);
+ if ($rejected) {
+ if ($rejected == -1) {
+ } else {
+ print "Error issuing book: $rejected
\n";
+ }
}
- }
- my $responsesform='';
- foreach (keys %responses) {
- $responsesform.="\n";
- }
- if ($question) {
- print << "EOF";
-
| Issuing Question | ||
|---|---|---|
|
- Attempting to issue $iteminformation->{'title'} by $iteminformation->{'author'} to $borrower->{'firstname'} $borrower->{'surname'}.
- - $question - |
| Issuing Question | ||
|---|---|---|
|
+ Attempting to issue $iteminformation->{'title'} by $iteminformation->{'author'} to $borrower->{'firstname'} $borrower->{'surname'}.
+ + $question + | ||
-
|
| + + | ++ + | +
| Patron Flags |
|---|