[Koha-patches] [PATCH] Bug 2965: Allow due date in the past

Robin Sheat robin at catalyst.net.nz
Mon Oct 4 04:00:53 CEST 2010


From: Srdjan Jankovic <srdjan at catalyst.net.nz>

Raise warning rather than disallowing
Remove due date js validation when checking out

Signed-off-by: Robin Sheat <robin at catalyst.net.nz>
---
 C4/Circulation.pm                                  |    9 +++++++--
 circ/circulation.pl                                |   12 ++++++------
 .../prog/en/modules/circ/circulation.tmpl          |   13 ++++++++++---
 3 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/C4/Circulation.pm b/C4/Circulation.pm
index 644ab27..1962d57 100644
--- a/C4/Circulation.pm
+++ b/C4/Circulation.pm
@@ -641,7 +641,7 @@ reserved for someone else.
 
 =head3 INVALID_DATE
 
-sticky due date is invalid
+sticky due date is invalid or due date in the past
 
 =head3 TOO_MANY
 
@@ -679,7 +679,12 @@ sub CanBookBeIssued {
         # Offline circ calls AddIssue directly, doesn't run through here
         #  So issuingimpossible should be ok.
     }
-    $issuingimpossible{INVALID_DATE} = $duedate->output('syspref') unless ( $duedate && $duedate->output('iso') ge C4::Dates->today('iso') );
+    if ($duedate) {
+        $needsconfirmation{INVALID_DATE} = $duedate->output('syspref')
+          unless $duedate->output('iso') ge C4::Dates->today('iso');
+    } else {
+        $issuingimpossible{INVALID_DATE} = $duedate->output('syspref');
+    }
 
     #
     # BORROWER STATUS
diff --git a/circ/circulation.pl b/circ/circulation.pl
index 4b67920..4a79695 100755
--- a/circ/circulation.pl
+++ b/circ/circulation.pl
@@ -142,13 +142,13 @@ 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
+#           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);
+#           }
         } else {
             $invalidduedate = 1;
             $template->param(IMPOSSIBLE=>1, INVALID_DATE=>$duedatespec);
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tmpl
index 980d195..73bc536 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tmpl
@@ -267,7 +267,14 @@ function refocus(calendar) {
     <input type="hidden" name="borrowernumber" value="<!-- TMPL_VAR NAME="borrowernumber" -->" />
     <input type="hidden" name="issueconfirmed" value="1" />
     <!-- TMPL_IF NAME="DEBT" --><input type="hidden" name="debt_confirmed" value="1" /><!-- /TMPL_IF -->
+    <!-- TMPL_IF NAME="INVALID_DATE" -->
+    <p>
+    <input type="text" size="10" id="duedatespec" name="duedatespec" value="<!-- TMPL_VAR NAME="duedatespec" -->" />
+    <label for="duedatespec">Due Date</label>
+    </p>
+    <!-- TMPL_ELSE -->
     <input type="hidden" name="duedatespec" value="<!-- TMPL_VAR NAME="duedatespec" -->" />
+    <!-- /TMPL_IF -->
     <input type="hidden" name="stickyduedate" value="<!-- TMPL_VAR NAME="stickyduedate" -->" />
     <input type="hidden" name="branch" value="<!-- TMPL_VAR NAME="branch" -->" />
     <input type="submit" class="approve" value="Yes, Check Out (Y)" accesskey="y" />
@@ -420,7 +427,7 @@ No patron matched <span class="ex"><!-- TMPL_VAR name="message" --></span>
     <!-- TMPL_IF NAME="NEEDSCONFIRMATION" -->
 	    <input type="text" name="barcode" id="barcode" class="barcode focus" size="14" disabled="disabled" />
     <!-- TMPL_ELSE -->
-	    <input type="text" name="barcode" id="barcode" class="barcode focus" size="14" />
+	    <!-- TMPL_IF NAME="barcode" -->><input type="text" name="barcode" id="barcode" class="barcode focus" size="14" value="<!-- TMPL_VAR NAME="barcode" -->"/><!-- TMPL_ELSE --><input type="text" name="barcode" id="barcode" class="barcode focus" size="14" /><!-- /TMPL_IF -->
     <!-- /TMPL_IF -->
     <input type="submit" value="Check Out" />
 
@@ -449,8 +456,8 @@ No patron matched <span class="ex"><!-- TMPL_VAR name="message" --></span>
                              inputField : "duedatespec",
                              ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
                              button : "CalendarDueDate",
-                             disableFunc : validate1,
-                             dateStatusFunc : validate1,
+//                           disableFunc : validate1,
+//                           dateStatusFunc : validate1,
                              onClose : refocus
                            }
                         );
-- 
1.7.1



More information about the Koha-patches mailing list