Merge branch 'new/bug11137' into 3.14.x
authorGalen Charlton <gmc@esilibrary.com>
Thu, 14 Nov 2013 15:52:27 +0000 (15:52 +0000)
committerGalen Charlton <gmc@esilibrary.com>
Thu, 14 Nov 2013 15:52:27 +0000 (15:52 +0000)
C4/Circulation.pm
koha-tmpl/intranet-tmpl/prog/en/js/datatables.js
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt
koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
t/db_dependent/Circulation.t

index 34aa358..0a22b76 100644 (file)
@@ -2433,7 +2433,7 @@ FROM issues
 LEFT JOIN items USING (itemnumber)
 LEFT OUTER JOIN branches USING (branchcode)
 WHERE returndate is NULL
-HAVING days_until_due > 0 AND days_until_due < ?
+HAVING days_until_due >= 0 AND days_until_due <= ?
 END_SQL
 
     my @bind_parameters = ( $params->{'days_in_advance'} );
index d4c161a..c2a2cf8 100644 (file)
@@ -115,7 +115,7 @@ jQuery.fn.dataTableExt.oApi.fnAddFilters = function ( oSettings, sClass, iDelay
     var table = this;
     this.fnSetFilteringDelay(iDelay);
     var filterTimerId = null;
-    $("input."+sClass).keyup(function(event) {
+    $(table).find("input."+sClass).keyup(function(event) {
       if (blacklist_keys.indexOf(event.keyCode) != -1) {
         return this;
       }else if ( event.keyCode == '13' ) {
index 520e6d2..84206fe 100644 (file)
@@ -374,7 +374,7 @@ var holdForPatron = function () {
                             [% IF ( ms_ticommaphr ) %]<option selected="selected" value="ti,phr">Title phrase</option>
                             [% ELSE %]<option value="ti,phr">Title phrase</option>[% END %]
                             [% IF ( ms_aucommaphr ) %]<option selected="selected" value="au,phr">Author</option>
-                            [% ELSE %]<option value"au,phr">Author</option>[% END %]
+                            [% ELSE %]<option value="au,phr">Author</option>[% END %]
                             [% IF ( ms_su ) %]<option selected="selected" value="su">Subject</option>
                             [% ELSE %]<option value="su">Subject</option>[% END %]
                             [% IF ( ms_sucommaphr ) %]<option selected="selected" value="su,phr">Subject phrase</option>
index 18b3db3..c14c165 100644 (file)
@@ -4,8 +4,7 @@
 [% INCLUDE 'calendar.inc' %]
 <!-- Plugin datatables -->
 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
-<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
-<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
+[% INCLUDE 'datatables.inc' %]
 <script type="text/JavaScript" language="JavaScript">
 //<![CDATA[
 $(document).ready(function() {
index b158556..4aa88cf 100644 (file)
@@ -59,7 +59,7 @@
         });
         $("#cancel_manual_restriction").on("click",function(e){
             $('#debarred_expiration').val('');
-            $('#add_debarment').prop('checked', false);
+            $('#add_debarment').val(0);
             $('#debarred_comment').val('');
             mrlink.show();
             mrform.hide();
                 [% END %]
                     <p><a href="#" id="add_manual_restriction">Add manual restriction</a></p>
                     <fieldset id="manual_restriction_form">
-                        <input type="hidden" id="add_debarment" name="add_debarment" value="1" />
+                        <input type="hidden" id="add_debarment" name="add_debarment" value="0" />
                         <legend>Add manual restriction</legend>
                         <ol>
-                            <li><label for="debarred_comment">Comment: </label><input type="text" id="debarred_comment" name="debarred_comment" onchange="$('#add_debarment').prop('checked', true);" /></li>
-                            <li><label for="debarred_expiration">Expiration: </label><input name="debarred_expiration" id="debarred_expiration" size="10" readonly="readonly" value="" class="datepicker" onchange="$('#add_debarment').prop('checked', true);" />
+                            <li><label for="debarred_comment">Comment: </label><input type="text" id="debarred_comment" name="debarred_comment" onchange="$('#add_debarment').val(1);" /></li>
+                            <li><label for="debarred_expiration">Expiration: </label><input name="debarred_expiration" id="debarred_expiration" size="10" readonly="readonly" value="" class="datepicker" onchange="$('#add_debarment').val(1);" />
                                     <a href='javascript:void(0)' onclick="$('#debarred_expiration').val('');">Clear date</a></li>
 
                         </ol>
index 60b93e2..aa2a969 100755 (executable)
@@ -9,7 +9,7 @@ use C4::Items;
 use C4::Members;
 use C4::Reserves;
 
-use Test::More tests => 38;
+use Test::More tests => 44;
 
 BEGIN {
     use_ok('C4::Circulation');
@@ -336,8 +336,28 @@ C4::Context->dbh->do("DELETE FROM accountlines");
     # GetUpcomingDueIssues tests
     my $barcode  = 'R00000342';
     my $barcode2 = 'R00000343';
+    my $barcode3 = 'R00000344';
     my $branch   = 'MPL';
 
+    #Create another record
+    my $biblio2 = MARC::Record->new();
+    my $title2 = 'Something is worng here';
+    $biblio2->append_fields(
+        MARC::Field->new('100', ' ', ' ', a => 'Anonymous'),
+        MARC::Field->new('245', ' ', ' ', a => $title2),
+    );
+    my ($biblionumber2, $biblioitemnumber2) = AddBiblio($biblio2, '');
+
+    #Create third item
+    AddItem(
+        {
+            homebranch       => $branch,
+            holdingbranch    => $branch,
+            barcode          => $barcode3
+        },
+        $biblionumber2
+    );
+
     # Create a borrower
     my %a_borrower_data = (
         firstname =>  'Fridolyn',
@@ -351,23 +371,52 @@ C4::Context->dbh->do("DELETE FROM accountlines");
 
     my $yesterday = DateTime->today(time_zone => C4::Context->tz())->add( days => -1 );
     my $two_days_ahead = DateTime->today(time_zone => C4::Context->tz())->add( days => 2 );
+    my $today = DateTime->today(time_zone => C4::Context->tz());
 
     my $datedue  = AddIssue( $a_borrower, $barcode, $yesterday );
     my $datedue2 = AddIssue( $a_borrower, $barcode2, $two_days_ahead );
 
+    my $upcoming_dues;
+
     diag( "GetUpcomingDueIssues tests" );
 
-    for my $i(0..2) {
-        my $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => $i } );
-        is ( scalar( @$upcoming_dues ), 0, "No items due in less than two days ($i days in advance)" );
+    for my $i(0..1) {
+        $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => $i } );
+        is ( scalar( @$upcoming_dues ), 0, "No items due in less than one day ($i days in advance)" );
     }
 
+    #days_in_advance needs to be inclusive, so 1 matches items due tomorrow, 0 items due today etc.
+    $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => 2 } );
+    is ( scalar ( @$upcoming_dues), 1, "Only one item due in 2 days or less" );
+
     for my $i(3..5) {
-        my $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => $i } );
+        $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => $i } );
         is ( scalar( @$upcoming_dues ), 1,
             "Bug 9362: Only one item due in more than 2 days ($i days in advance)" );
     }
 
+    # Bug 11218 - Due notices not generated - GetUpcomingDueIssues needs to select due today items as well
+
+    my $datedue3 = AddIssue( $a_borrower, $barcode3, $today );
+
+    $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => -1 } );
+    is ( scalar ( @$upcoming_dues), 0, "Overdues can not be selected" );
+
+    $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => 0 } );
+    is ( scalar ( @$upcoming_dues), 1, "1 item is due today" );
+
+    $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => 1 } );
+    is ( scalar ( @$upcoming_dues), 1, "1 item is due today, none tomorrow" );
+
+    $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => 2 }  );
+    is ( scalar ( @$upcoming_dues), 2, "2 items are due withing 2 days" );
+
+    $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => 3 } );
+    is ( scalar ( @$upcoming_dues), 2, "2 items are due withing 2 days" );
+
+    $upcoming_dues = C4::Circulation::GetUpcomingDueIssues();
+    is ( scalar ( @$upcoming_dues), 2, "days_in_advance is 7 in GetUpcomingDueIssues if not provided" );
+
 }
 
 $dbh->rollback;