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)
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");
//]]>
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>";
},
{
"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;
title += " " + value.subfield;
});
- title += "</a>";
+ title += "</a></span>";
if ( oObj.author ) {
- title += " " + BY + " " + oObj.author;
+ title += " " + BY.replace( "_AUTHOR_", " " + oObj.author );
}
if ( oObj.itemnotes ) {
}
},
{ "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 ) {
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
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>";
$("#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 );
},
{
"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;
title += " " + value.subfield;
});
- title += "</a>";
+ title += "</a></span>";
if ( oObj.author ) {
title += " " + BY + " " + oObj.author;
}
},
{ "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 + "'>"
],
"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 ) {
$("#holds-tab").click( function() {
if ( ! holdsTable ) {
holdsTable = $("#holds-table").dataTable({
+ "bAutoWidth": false,
"sDom": "<'row-fluid'<'span6'><'span6'>r>t<'row-fluid'>t",
"aoColumns": [
{
},
{
"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;
title += "</a>";
if ( oObj.author ) {
- title += " " + BY + " " + oObj.author;
+ title += " " + BY.replace( "_AUTHOR_", oObj.author );
}
if ( oObj.itemnotes ) {
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;
}
},
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>";
}
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;
}
},
{
+ "bSortable": false,
"mDataProp": function( oObj ) {
return "<select name='rank-request'>"
+ "<option value='n'>" + NO + "</option>"
],
"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 } );
<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">
[% 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>
<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>
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 ) =
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 )
$sql .= '= ?';
}
else {
- $sql = ' IN (' . join( ',', ('?') x @borrowernumber ) . ') ';
+ $sql .= ' IN (' . join( ',', ('?') x @borrowernumber ) . ') ';
}
push( @parameters, @borrowernumber );
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} );
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;
'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{},
};
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
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;
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);