Bug 11703 [QA Followup]
authorKyle M Hall <kyle@bywatersolutions.com>
Mon, 14 Apr 2014 17:45:22 +0000 (13:45 -0400)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Thu, 3 Jul 2014 14:22:10 +0000 (11:22 -0300)
* Bold record title, fix table width
* Change output_pref_due to output_pref
* Retain functionality of IssuesDefaultSortOrder system preferences
* Use datatables.inc in circulation.tt
* Fix up holds table details
* Add plugin to about
* fix relatives' checkouts
* add too_many string
* remove dead syspref from db
* Sort relatives' checkouts and holds tables client side
* Provide context for translation of strings
* Fix unterminated string literal, add missing paren
* Add replacement of _AUTHOR_ with title's author for holds
* Format prices correctly
* Format checkout dates correctly

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
installer/data/mysql/updatedatabase.pl
koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc
koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js
koha-tmpl/intranet-tmpl/prog/en/js/holds.js
koha-tmpl/intranet-tmpl/prog/en/modules/about.tt
koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
svc/checkin.pl
svc/checkouts.pl
svc/holds.pl
svc/renew.pl

index c68ba51..fb2406a 100755 (executable)
@@ -8560,6 +8560,16 @@ if ( CheckVersion($DBversion) ) {
     SetVersion($DBversion);
 }
 
+$DBversion = "3.15.00.XXX";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        DELETE FROM systempreferences WHERE variable = 'UseTableSortForCirc'
+    });
+
+    print "Upgrade to $DBversion done (Bug 11703 - Convert checkouts table to ajax datatable)\n";
+    SetVersion($DBversion);
+}
+
 =head1 FUNCTIONS
 
 =head2 TableExists($table)
index e22810a..3755dd1 100644 (file)
     var REASON_UNKNOWN = _("reason unkown");
     var TODAYS_CHECKOUTS = _("Today's checkouts");
     var PREVIOUS_CHECKOUTS = _("Previous checkouts");
-    var BY = _("by");
+    var BY = _("by _AUTHOR_");
     var ON_HOLD = _("On hold");
     var NOT_RENEWABLE = _("Not renewable");
-    var OF = _("of");
-    var RENEWALS_REMAINING = _("renewals remaining");
-    var HOLD_IS = _("Hold is");
-    var SUSPENDED = _("suspended");
-    var UNTIL = _("until");
-    var ITEM_IS = _("Item is");
-    var WAITING = _("waiting");
-    var AT = _("at");
-    var IN_TRANSIT = _("in transit");
+    var NOT_RENEWABLE_TOO_SOON = _("Cannot renew, renewal is premature");
+    var RENEWALS_REMAINING = _("_RENEWALS_REMAINING_ of _RENEWALS_ALLOWED_ renewals remaining");
+    var HOLD_IS_SUSPENDED = _("Hold is <strong>suspended</strong>");
+    var UNTIL = _("until _SUSPEND_UNTIL_");
+    var ITEM_IS_WAITING = _("Item is <strong>waiting</strong>"); //
+    var AT = _("at _WAITING_AT_BRANCH_");
+    var ITEM_IS_IN_TRANSIT = _("Item is <strong>in transit</strong> from _FROM_BRANCH_");
     var FROM = _("from");
-    var NOT_TRANSFERRED_YET = _("Item hasn't been transferred yet from");
+    var NOT_TRANSFERRED_YET = _("Item hasn't been transferred yet from _FROM_BRANCH_");
     var NO = _("No");
     var YES = _("Yes");
 //]]>
index 268eefe..eca940a 100644 (file)
@@ -127,12 +127,12 @@ $(document).ready(function() {
     var issuesTable;
     var drawn = 0;
     issuesTable = $("#issues-table").dataTable({
+        "bAutoWidth": false,
         "sDom": "<'row-fluid'<'span6'><'span6'>r>t<'row-fluid'>t",
-        "aaSorting": [[ 0, "desc" ]],
         "aoColumns": [
             {
                 "mDataProp": function( oObj ) {
-                    if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) {
+                    if ( oObj.issued_today ) {
                         return "<strong>" + TODAYS_CHECKOUTS + "</strong>";
                     } else {
                         return "<strong>" + PREVIOUS_CHECKOUTS + "</strong>";
@@ -157,7 +157,7 @@ $(document).ready(function() {
             },
             {
                 "mDataProp": function ( oObj ) {
-                    title = "<a href='/cgi-bin/koha/catalogue/detail.pl?biblionumber="
+                    title = "<span class='strong'><a href='/cgi-bin/koha/catalogue/detail.pl?biblionumber="
                           + oObj.biblionumber
                           + "'>"
                           + oObj.title;
@@ -166,10 +166,10 @@ $(document).ready(function() {
                               title += " " + value.subfield;
                     });
 
-                    title += "</a>";
+                    title += "</a></span>";
 
                     if ( oObj.author ) {
-                        title += " " + BY + " " + oObj.author;
+                        title += " " + BY.replace( "_AUTHOR_",  " " + oObj.author );
                     }
 
                     if ( oObj.itemnotes ) {
@@ -195,18 +195,21 @@ $(document).ready(function() {
                 }
             },
             { "mDataProp": "itemtype" },
-            { "mDataProp": "issuedate" },
+            { "mDataProp": "issuedate_formatted" },
             { "mDataProp": "branchname" },
             { "mDataProp": "itemcallnumber" },
             {
-                "bSortable": false,
                 "mDataProp": function ( oObj ) {
+                    if ( ! oObj.charge ) oObj.charge = 0;
                     return parseFloat(oObj.charge).toFixed(2);
                 }
             },
             {
-                "bSortable": false,
-                "mDataProp": "price" },
+                "mDataProp": function ( oObj ) {
+                    if ( ! oObj.price ) oObj.price = 0;
+                    return parseFloat(oObj.price).toFixed(2);
+                }
+            },
             {
                 "bSortable": false,
                 "mDataProp": function ( oObj ) {
@@ -233,6 +236,13 @@ $(document).ready(function() {
 
                         span_style = "display: none";
                         span_class = "renewals-allowed";
+                    } else if ( oObj.can_renew_error == "too_soon" ) {
+                        content += "<span class='renewals-disabled'>"
+                                + NOT_RENEWABLE_TOO_SOON
+                                + "</span>";
+
+                        span_style = "display: none";
+                        span_class = "renewals-allowed";
                     } else {
                         content += "<span class='renewals-disabled'>"
                                 + oObj.can_renew_error
@@ -248,10 +258,8 @@ $(document).ready(function() {
 
                     if ( oObj.renewals_remaining ) {
                         content += "<span class='renewals'>("
-                                + oObj.renewals_remaining
-                                + " " + OF + " "
-                                + oObj.renewals_allowed + " "
-                                + RENEWALS_REMAINING + ")</span>";
+                                + RENEWALS_REMAINING.replace( "_RENEWALS_REMAINING_", oObj.renewals_remaining ).replace( "_RENEWALS_ALLOWED_", oObj.renewals_allowed )
+                                + ")</span>";
                     }
 
                     content += "</span>";
@@ -333,10 +341,16 @@ $(document).ready(function() {
     $("#relatives-issues-tab").click( function() {
         if ( ! relativesIssuesTable ) {
             relativesIssuesTable = $("#relatives-issues-table").dataTable({
+                "bAutoWidth": false,
                 "sDom": "<'row-fluid'<'span6'><'span6'>r>t<'row-fluid'>t",
                 "aaSorting": [],
                 "aoColumns": [
                     {
+                        "mDataProp": "date_due",
+                        "bVisible": false,
+                    },
+                    {
+                        "iDataSort": 1, // Sort on hidden unformatted date due column
                         "mDataProp": function( oObj ) {
                             var today = new Date();
                             var due = new Date( oObj.date_due );
@@ -349,7 +363,7 @@ $(document).ready(function() {
                     },
                     {
                         "mDataProp": function ( oObj ) {
-                            title = "<a href='/cgi-bin/koha/catalogue/detail.pl?biblionumber="
+                            title = "<span class='strong'><a href='/cgi-bin/koha/catalogue/detail.pl?biblionumber="
                                   + oObj.biblionumber
                                   + "'>"
                                   + oObj.title;
@@ -358,7 +372,7 @@ $(document).ready(function() {
                                       title += " " + value.subfield;
                             });
 
-                            title += "</a>";
+                            title += "</a></span>";
 
                             if ( oObj.author ) {
                                 title += " " + BY + " " + oObj.author;
@@ -387,11 +401,21 @@ $(document).ready(function() {
                         }
                     },
                     { "mDataProp": "itemtype" },
-                    { "mDataProp": "issuedate" },
+                    { "mDataProp": "issuedate_formatted" },
                     { "mDataProp": "branchname" },
                     { "mDataProp": "itemcallnumber" },
-                    { "mDataProp": "charge" },
-                    { "mDataProp": "price" },
+                    {
+                        "mDataProp": function ( oObj ) {
+                            if ( ! oObj.charge ) oObj.charge = 0;
+                            return parseFloat(oObj.charge).toFixed(2);
+                        }
+                    },
+                    {
+                        "mDataProp": function ( oObj ) {
+                            if ( ! oObj.price ) oObj.price = 0;
+                            return parseFloat(oObj.price).toFixed(2);
+                        }
+                    },
                     {
                         "mDataProp": function( oObj ) {
                             return "<a href='/cgi-bin/koha/members/moremember.pl?borrowernumber=" + oObj.borrowernumber + "'>"
@@ -401,7 +425,7 @@ $(document).ready(function() {
                 ],
                 "bPaginate": false,
                 "bProcessing": true,
-                "bServerSide": true,
+                "bServerSide": false,
                 "sAjaxSource": '/cgi-bin/koha/svc/checkouts.pl',
                 "fnServerData": function ( sSource, aoData, fnCallback ) {
                     $.each(relatives_borrowernumbers, function( index, value ) {
index 76dfee5..eab5ae4 100644 (file)
@@ -4,6 +4,7 @@ $(document).ready(function() {
     $("#holds-tab").click( function() {
         if ( ! holdsTable ) {
             holdsTable = $("#holds-table").dataTable({
+                "bAutoWidth": false,
                 "sDom": "<'row-fluid'<'span6'><'span6'>r>t<'row-fluid'>t",
                 "aoColumns": [
                     {
@@ -11,7 +12,7 @@ $(document).ready(function() {
                     },
                     {
                         "mDataProp": function ( oObj ) {
-                            title = "<a href='/cgi-bin/koha/catalogue/detail.pl?biblionumber="
+                            title = "<a href='/cgi-bin/koha/reserve/request.pl?biblionumber="
                                   + oObj.biblionumber
                                   + "'>"
                                   + oObj.title;
@@ -23,7 +24,7 @@ $(document).ready(function() {
                             title += "</a>";
 
                             if ( oObj.author ) {
-                                title += " " + BY + " " + oObj.author;
+                                title += " " + BY.replace( "_AUTHOR_",  oObj.author );
                             }
 
                             if ( oObj.itemnotes ) {
@@ -34,17 +35,6 @@ $(document).ready(function() {
                                 title += " - <span class='" + span_class + "'>" + oObj.itemnotes + "</span>"
                             }
 
-                            title += " "
-                                  + "<a href='/cgi-bin/koha/catalogue/moredetail.pl?biblionumber="
-                                  + oObj.biblionumber
-                                  + "&itemnumber="
-                                  + oObj.itemnumber
-                                  + "#"
-                                  + oObj.itemnumber
-                                  + "'>"
-                                  + oObj.barcode
-                                  + "</a>";
-
                             return title;
                         }
                     },
@@ -58,9 +48,9 @@ $(document).ready(function() {
                             var data = "";
 
                             if ( oObj.suspend == 1 ) {
-                                data += "<p>" + HOLD_IS + " <strong> " + SUSPENDED + " </strong>";
+                                data += "<p>" + HOLD_IS_SUSPENDED;
                                 if ( oObj.suspend_until ) {
-                                    data += " " + UNTIL + " " + oObj.suspend_until_formatted;
+                                    data += " " + UNTIL.replace( "_SUSPEND_UNTIL_", oObj.suspend_until_formatted );
                                 }
                                 data += "</p>";
                             }
@@ -68,19 +58,27 @@ $(document).ready(function() {
                             if ( oObj.barcode ) {
                                 data += "<em>";
                                 if ( oObj.found == "W" ) {
-                                    data += ITEM_IS + " <strong> " + WAITING + " </strong>";
+                                    data += ITEM_IS_WAITING;
 
                                     if ( ! oObj.waiting_here ) {
-                                        data += " " + AT + " " + oObj.waiting_at;
+                                        data += " " + AT.replace("_WAITING_AT_BRANCH_", oObj.waiting_at );
                                     }
                                 } else if ( oObj.transferred ) {
-                                    data += ITEM_IS + " <strong> " + IN_TRANSIT + " </strong> " + FROM + oObj.from_branch;
+                                    data += ITEM_IS_IN_TRANSIT.replace( "_FROM_BRANCH_", oObj.from_branch );
                                 } else if ( oObj.not_transferred ) {
-                                    data += NOT_TRANSFERRED_YET + " " + oObj.not_transferred_by;
-                                }                                 data += "</em>";
+                                    data += NOT_TRANSFERRED_YET.replace( "_FROM_BRANCH_", oObj.not_transferred_by );
+                                }
+                                data += "</em>";
 
                                 data += " <a href='/cgi-bin/koha/catalogue/detail.pl?biblionumber="
-                                     + oObj.biblionumber + "'>" + oObj.barcode + "</a>";
+                                  + oObj.biblionumber
+                                  + "&itemnumber="
+                                  + oObj.itemnumber
+                                  + "#"
+                                  + oObj.itemnumber
+                                  + "'>"
+                                  + oObj.barcode
+                                  + "</a>";
                             }
 
                             return data;
@@ -97,6 +95,7 @@ $(document).ready(function() {
                         }
                     },
                     {
+                        "bSortable": false,
                         "mDataProp": function( oObj ) {
                             return "<select name='rank-request'>"
                                  + "<option value='n'>" + NO + "</option>"
@@ -110,7 +109,7 @@ $(document).ready(function() {
                 ],
                 "bPaginate": false,
                 "bProcessing": true,
-                "bServerSide": true,
+                "bServerSide": false,
                 "sAjaxSource": '/cgi-bin/koha/svc/holds.pl',
                 "fnServerData": function ( sSource, aoData, fnCallback ) {
                     aoData.push( { "name": "borrowernumber", "value": borrowernumber } );
index 9e5bdc5..daa5f95 100644 (file)
 
             <p>The <a href="http://www.openjs.com/scripts/events/keyboard_shortcuts/">OpenJS keyboard shortcuts library</a>
                by Binny V A is licensed under the BSD license.</p>
+
+            <h2>jquery.dataTables.grouping.js</h2>
+            <p>The <a href="https://code.google.com/p/jquery-datatables-row-grouping/">jquery.dataTables.grouping.js</a>
+               plugin by Jovan Popovic is licensed under the BSD and GPL v2 license.</p>
         </div>
 
         <div id="translations">
index 9951030..e9c4479 100644 (file)
@@ -15,9 +15,9 @@
 [% INCLUDE 'calendar.inc' %]
 
 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
-[% INCLUDE 'datatables.inc' %]
-<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
 [% INCLUDE 'strings.inc' %]
+[% INCLUDE 'datatables.inc' %]
+<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery-ui-timepicker-addon.min.js"></script>
 [% INCLUDE 'timepicker.inc' %]
 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.dataTables.rowGrouping.js"></script>
@@ -721,6 +721,7 @@ No patron matched <span class="ex">[% message %]</span>
         <table id="relatives-issues-table">
             <thead>
                 <tr>
+                    <th scope="col">Due date (unformatted, hidden)</th>
                     <th scope="col">Due date</th>
                     <th scope="col">Title</th>
                     <th scope="col">Item type</th>
index a303e52..000ddbc 100755 (executable)
@@ -27,8 +27,6 @@ use C4::Items qw(GetBarcodeFromItemnumber);
 use C4::Context;
 use C4::Auth qw(check_cookie_auth);
 
-use Koha::DateUtils qw(output_pref_due);
-
 my $input = new CGI;
 
 my ( $auth_status, $sessionID ) =
index ab59fb4..bcb3444 100755 (executable)
@@ -81,7 +81,9 @@ my $sql = '
         borrowernumber,
         surname,
         firstname,
-        cardnumber
+        cardnumber,
+
+        DATEDIFF( issuedate, CURRENT_DATE() ) AS not_issued_today
     FROM issues
         LEFT JOIN items USING ( itemnumber )
         LEFT JOIN biblio USING ( biblionumber )
@@ -95,7 +97,7 @@ if ( @borrowernumber == 1 ) {
     $sql .= '= ?';
 }
 else {
-    $sql = ' IN (' . join( ',', ('?') x @borrowernumber ) . ') ';
+    $sql .= ' IN (' . join( ',', ('?') x @borrowernumber ) . ') ';
 }
 push( @parameters, @borrowernumber );
 
@@ -103,11 +105,12 @@ $sql .= " ORDER BY $sorting_column $sorting_direction ";
 
 my $dbh = C4::Context->dbh();
 my $sth = $dbh->prepare($sql);
-$sth->execute( @parameters );
+$sth->execute(@parameters);
 
 my $item_level_itypes = C4::Context->preference('item-level_itypes');
 
-my @checkouts;
+my @checkouts_today;
+my @checkouts_previous;
 while ( my $c = $sth->fetchrow_hashref() ) {
     my ($charge) = GetIssuingCharges( $c->{itemnumber}, $c->{borrowernumber} );
 
@@ -116,50 +119,71 @@ while ( my $c = $sth->fetchrow_hashref() ) {
 
     my ( $renewals_count, $renewals_allowed, $renewals_remaining ) =
       GetRenewCount( $c->{borrowernumber}, $c->{itemnumber} );
-    push(
-        @checkouts,
-        {
-            DT_RowId   => $c->{itemnumber} . '-' . $c->{borrowernumber},
-            title      => $c->{title},
-            author     => $c->{author},
-            barcode    => $c->{barcode},
-            itemtype   => $item_level_itypes ? $c->{itype} : $c->{itemtype},
-            itemnotes  => $c->{itemnotes},
-            branchcode => $c->{branchcode},
-            branchname => $c->{branchname},
-            itemcallnumber => $c->{itemcallnumber}   || q{},
-            charge         => $charge,
-            price          => $c->{replacementprice} || q{},
-            can_renew      => $can_renew,
-            can_renew_error    => $can_renew_error,
-            itemnumber         => $c->{itemnumber},
-            borrowernumber     => $c->{borrowernumber},
-            biblionumber       => $c->{biblionumber},
-            issuedate          => $c->{issuedate},
-            date_due           => $c->{date_due},
-            renewals_count     => $renewals_count,
-            renewals_allowed   => $renewals_allowed,
-            renewals_remaining => $renewals_remaining,
-            issuedate_formatted =>
-              output_pref( dt_from_string( $c->{issuedate} ) ),
-            date_due_formatted =>
-              output_pref_due( dt_from_string( $c->{date_due} ) ),
-            subtitle => GetRecordValue(
-                'subtitle',
-                GetMarcBiblio( $c->{biblionumber} ),
-                GetFrameworkCode( $c->{biblionumber} )
-            ),
-            borrower => {
-                surname    => $c->{surname},
-                firstname  => $c->{firstname},
-                cardnumber => $c->{cardnumber},
+
+    my $checkout = {
+        DT_RowId   => $c->{itemnumber} . '-' . $c->{borrowernumber},
+        title      => $c->{title},
+        author     => $c->{author},
+        barcode    => $c->{barcode},
+        itemtype   => $item_level_itypes ? $c->{itype} : $c->{itemtype},
+        itemnotes  => $c->{itemnotes},
+        branchcode => $c->{branchcode},
+        branchname => $c->{branchname},
+        itemcallnumber => $c->{itemcallnumber}   || q{},
+        charge         => $charge,
+        price          => $c->{replacementprice} || q{},
+        can_renew      => $can_renew,
+        can_renew_error     => $can_renew_error,
+        itemnumber          => $c->{itemnumber},
+        borrowernumber      => $c->{borrowernumber},
+        biblionumber        => $c->{biblionumber},
+        issuedate           => $c->{issuedate},
+        date_due            => $c->{date_due},
+        renewals_count      => $renewals_count,
+        renewals_allowed    => $renewals_allowed,
+        renewals_remaining  => $renewals_remaining,
+        issuedate_formatted => output_pref(
+            {
+                dt          => dt_from_string( $c->{issuedate} ),
+                as_due_date => 1
+            }
+        ),
+        date_due_formatted => output_pref(
+            {
+                dt          => dt_from_string( $c->{date_due} ),
+                as_due_date => 1
             }
-        }
-    );
+        ),
+        subtitle => GetRecordValue(
+            'subtitle',
+            GetMarcBiblio( $c->{biblionumber} ),
+            GetFrameworkCode( $c->{biblionumber} )
+        ),
+        borrower => {
+            surname    => $c->{surname},
+            firstname  => $c->{firstname},
+            cardnumber => $c->{cardnumber},
+        },
+        issued_today => !$c->{not_issued_today},
+    };
+
+    if ( $c->{not_issued_today} ) {
+        push( @checkouts_previous, $checkout );
+    }
+    else {
+        push( @checkouts_today, $checkout );
+    }
 }
 
+@checkouts_today = reverse(@checkouts_today)
+  if ( C4::Context->preference('todaysIssuesDefaultSortOrder') eq 'desc' );
+@checkouts_previous = reverse(@checkouts_previous)
+  if ( C4::Context->preference('previousIssuesDefaultSortOrder') eq 'desc' );
+
+my @checkouts = ( @checkouts_today, @checkouts_previous );
+
 my $data;
-$data->{'iTotalRecords'}        = scalar @checkouts;                 #FIXME
+$data->{'iTotalRecords'}        = scalar @checkouts;
 $data->{'iTotalDisplayRecords'} = scalar @checkouts;
 $data->{'sEcho'}                = $input->param('sEcho') || undef;
 $data->{'aaData'}               = \@checkouts;
index 9fbdb5f..85e0f5b 100755 (executable)
@@ -95,14 +95,17 @@ while ( my $h = $holds_rs->next() ) {
             'subtitle', GetMarcBiblio($biblionumber),
             GetFrameworkCode($biblionumber)
         ),
-        reservedate_formatted => $h->reservedate()
-        ? output_pref_due( dt_from_string( $h->reservedate() ) )
+        reservedate_formatted => $h->reservedate() ? output_pref(
+            { dt => dt_from_string( $h->reservedate() ), dateonly => 1 }
+          )
         : q{},
-        suspend_until_formatted => $h->suspend_until()
-        ? output_pref_due( dt_from_string( $h->suspend_until() ) )
+        suspend_until_formatted => $h->suspend_until() ? output_pref(
+            { dt => dt_from_string( $h->suspend_until() ), dateonly => 1 }
+          )
         : q{},
-        expirationdate_formatted => $h->expirationdate()
-        ? output_pref_due( dt_from_string( $h->expirationdate() ) )
+        expirationdate_formatted => $h->expirationdate() ? output_pref(
+            { dt => dt_from_string( $h->expirationdate() ), dateonly => 1 }
+          )
         : q{},
     };
 
@@ -120,7 +123,7 @@ while ( my $h = $holds_rs->next() ) {
         if ($transferred_when) {
             $hold->{color}       = 'transferred';
             $hold->{transferred} = 1;
-            $hold->{date_sent}   = format_date($transferred_when);
+            $hold->{date_sent} = output_pref( dt_from_string($transferred_when) );
             $hold->{from_branch} = GetBranchName($transferred_from);
         }
         elsif ( $item->holdingbranch()->branchcode() ne
index add9e9f..fa8475a 100755 (executable)
@@ -26,7 +26,7 @@ use C4::Circulation;
 use C4::Context;
 use C4::Auth qw(check_cookie_auth);
 
-use Koha::DateUtils qw(output_pref_due dt_from_string);
+use Koha::DateUtils qw(output_pref dt_from_string);
 
 my $input = new CGI;
 
@@ -63,7 +63,7 @@ $data->{branchcode} = $branchcode;
 
 if ( $data->{renew_okay} ) {
     $date_due = AddRenewal( $borrowernumber, $itemnumber, $branchcode, $date_due );
-    $data->{date_due} = output_pref_due( $date_due );
+    $data->{date_due} = output_pref( { dt => $date_due, as_due_date => 1 } );
 }
 
 print to_json($data);