[% PROCESS "opac/parts/header.tt2"; PROCESS "opac/parts/misc_util.tt2"; PROCESS "opac/parts/myopac/column_sort_support.tt2"; WRAPPER "opac/parts/myopac/base.tt2"; myopac_page = "circs" limit = ctx.circ_history_limit; offset = ctx.circ_history_offset; %]

[% l('History of Checked Out Items') %]

[%- IF ebook_api.enabled == 'true' %] [%- END %]
[% # In the sorting case, the size is the size of ALL the circ items. In the non-sorting case, # the size is simply the size of the chunk passed in. See the TODO below for the still-lingering # bug. sort_field = CGI.param('sort'); IF (sort_field); no_next = ctx.circs.size - offset <= limit; ELSE; no_next = ctx.circs.size < limit; END; %]
[% l('Previously Checked Out Items') %] limit, offset => (offset - limit)}) %]' [% IF offset == 0 %] class='invisible' [% END %]>[% l('Previous') %] [%# TODO: get total to prevent paging off then end of the list.. %] limit, offset => (offset + limit)}) %]' [% IF no_next %] class='invisible' [% END %] >[% l('Next') %]
[%- INCLUDE "opac/parts/preserve_params.tt2" %] [% IF ctx.circs.size > 0 %] [% END %]
[% IF ctx.circs.size < 1 %]
[% l('There are no items in your circulation history.') %]
[% ELSE %]
[%# Copy the ctx.circs into a local array, then add a SORT field that contains the value to sort on. Since we need the item attrs, invoke it and save the result in ATTRS. %] [% circ_items = ctx.circs; # Array assignment FOR circ IN circ_items; circ.ATTRS = {marc_xml => circ.marc_xml}; PROCESS get_marc_attrs args=circ.ATTRS; SWITCH sort_field; CASE "sort_title"; circ.SORTING = circ.ATTRS.sort_title; CASE "author"; circ.SORTING = circ.ATTRS.author; CASE "checkout"; circ.SORTING = circ.circ.xact_start; CASE "due"; circ.SORTING = circ.circ.due_date; CASE "returned"; circ.SORTING = circ.circ.checkin_time; CASE "barcode"; circ.SORTING = circ.circ.target_copy.barcode; CASE "callnum"; circ.SORTING = circ.circ.target_copy.call_number.label; CASE; sort_field = ""; END; # SWITCH END; #FOR circ IF (sort_field != "sort_title"); deemphasize_class = ""; ELSE; deemphasize_class = " class=\"sort_deemphasize\""; END; # Apply sorting to circ_items IF (sort_field); circ_items = circ_items.sort("SORTING"); IF (CGI.param("sort_type") == "desc"); circ_items = circ_items.reverse; END; # Shorten the circ_items list per offset/limit/cout hi = offset + limit - 1; hi = hi > circ_items.max ? circ_items.max : hi; circ_items = circ_items.slice(offset, hi); END; # circ_items list is now sorted. Traverse and dump the information. FOR circ IN circ_items; %] [% END %]
[% sort_head("sort_title", l("Title")) %] [% sort_head("author", l("Author")) %] [% sort_head("checkout", l("Checkout Date")) %] [% sort_head("due", l("Due Date")) %] [% sort_head("returned", l("Date Returned")) %] [% sort_head("barcode", l("Barcode")) %] [% sort_head("callnum", l("Call Number")) %]
[%- circ.ATTRS.title.substr(0,circ.ATTRS.nonfiling_characters) | html %] [%- circ.ATTRS.title.substr(circ.ATTRS.nonfiling_characters) | html %] [% circ.ATTRS.author | html %] [% date.format(ctx.parse_datetime(circ.circ.xact_start),DATE_FORMAT); %] [% IF circ.circ.source_circ; date.format(ctx.parse_datetime(circ.circ.due_date, circ.circ.source_circ.circ_lib),DATE_FORMAT); ELSE; date.format(ctx.parse_datetime(circ.circ.due_date, ctx.user.home_ou),DATE_FORMAT); END; %] [% IF circ.circ.checkin_time; date.format(ctx.parse_datetime(circ.circ.checkin_time),DATE_FORMAT); ELSE; %] * [% END; %] [% circ.circ.target_copy.barcode | html %] [% circ.circ.target_copy.call_number.label | html %]
[% END %]
[% END %]