Skip to content

Commit

Permalink
Allow Duedates to be set in the past for testing
Browse files Browse the repository at this point in the history
    Add system preference to enable/disable this feature
  • Loading branch information
colinsc authored and J. David Bavousett committed Apr 5, 2010
1 parent 9c54d01 commit ba971da
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 33 deletions.
1 change: 1 addition & 0 deletions admin/systempreferences.pl
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ =head1 systempreferences.pl
$tabsysprefs{HoldButtonConfirm} = "Circulation";
$tabsysprefs{HoldButtonPrintConfirm} = "Circulation";
$tabsysprefs{HoldButtonIgnore} = "Circulation";
$tabsysprefs{AllowDueDateInPast} = "Circulation";

# Staff Client
$tabsysprefs{TemplateEncoding} = "StaffClient";
Expand Down
33 changes: 20 additions & 13 deletions circ/circulation.pl
Original file line number Diff line number Diff line change
Expand Up @@ -148,21 +148,27 @@
$globalduedate = C4::Dates->new(C4::Context->preference('globalDueDate'));
}
my $duedatespec_allow = C4::Context->preference('SpecifyDueDate');
my $testduedate_allow = C4::Context->preference('AllowDueDateInPast');
if($duedatespec_allow){
if ($duedatespec) {
if ($duedatespec =~ C4::Dates->regexp('syspref')) {
my $tempdate = C4::Dates->new($duedatespec);
if ($tempdate and $tempdate->output('iso') gt C4::Dates->new()->output('iso')) {
# i.e., it has to be later than today/now
$datedue = $tempdate;
} else {
$invalidduedate = 1;
$template->param(IMPOSSIBLE=>1, INVALID_DATE=>$duedatespec);
}
} else {
$invalidduedate = 1;
$template->param(IMPOSSIBLE=>1, INVALID_DATE=>$duedatespec);
}
if ($duedatespec =~ C4::Dates->regexp('syspref')) {
my $tempdate = C4::Dates->new($duedatespec);
if ($tempdate and $tempdate->output('iso') gt C4::Dates->new()->output('iso')) {
# i.e., it has to be later than today/now
$datedue = $tempdate;
} else {
if ($testduedate_allow) {
$datedue = $tempdate;
}
else {
$invalidduedate = 1;
$template->param(IMPOSSIBLE=>1, INVALID_DATE=>$duedatespec);
}
}
} else {
$invalidduedate = 1;
$template->param(IMPOSSIBLE=>1, INVALID_DATE=>$duedatespec);
}
} else {
# pass global due date to tmpl if specifyduedate is true
# and we have no barcode (loading circ page but not checking out)
Expand Down Expand Up @@ -738,5 +744,6 @@
AllowRenewalLimitOverride => C4::Context->preference("AllowRenewalLimitOverride"),
dateformat => C4::Context->preference("dateformat"),
DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
AllowDueDateInPast => C4::Context->preference('AllowDueDateInPast'),
);
output_html_with_http_headers $query, $cookie, $template->output;
44 changes: 24 additions & 20 deletions koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -408,27 +408,31 @@ No patron matched <span class="ex"><!-- TMPL_VAR name="message" --></span>
//<![CDATA[
function validate1(date) {
var today = new Date();
if ( date < today ) {
return true;
} else {
return false;
}
};
function refocus(calendar) {
$('#barcode').focus();
calendar.hide();
};
if ( date < today ) {
return true;
} else {
return false;
}
};
function refocus(calendar) {
document.getElementById('barcode').focus();
calendar.hide();
};
//#TODO - ADD syspref (AllowPostDatedCheckouts).
Calendar.setup(
{
inputField : "duedatespec",
ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
button : "CalendarDueDate",
disableFunc : validate1,
dateStatusFunc : validate1,
onClose : refocus
}
);
Calendar.setup(
{
inputField : "duedatespec",
ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
button : "CalendarDueDate",
<!-- TMPL_IF NAME="AllowDueDateInPast" -->
onClose : refocus
<!-- TMPL_ELSE -->
disableFunc : validate1,
dateStatusFunc : validate1,
onClose : refocus
<!-- /TMPL_IF -->
}
);
//]]>
</script>

Expand Down

0 comments on commit ba971da

Please sign in to comment.