]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/templates/opac/myopac/circ_history.tt2
LP# 1086934 - TPAC: Complete column sorting in some screens
[Evergreen.git] / Open-ILS / src / templates / opac / myopac / circ_history.tt2
1 [%  PROCESS "opac/parts/header.tt2";
2     PROCESS "opac/parts/misc_util.tt2";
3     PROCESS "opac/parts/myopac/column_sort_support.tt2";
4     WRAPPER "opac/parts/myopac/base.tt2";
5     myopac_page = "circs"
6     limit = ctx.circ_history_limit;
7     offset = ctx.circ_history_offset;
8 %]
9
10 <h3 class="sr-only">[% l('History of Checked Out Items') %]</h3>
11 <div style="padding:0px;">
12     
13     <div id="acct_checked_tabs">
14         <div class="align">
15             <a href='[% mkurl('circs',{},1) %]'>[% l("Current Items Checked Out") %]</a>
16         </div>
17         <div class="align selected">
18             <a href="#">[% l("Check Out History") %]</a>
19         </div>
20     </div>
21
22     [% 
23     # In the sorting case, the size is the size of ALL the circ items.  In the non-sorting case,
24     # the size is simply the size of the chunk passed in.  See the TODO below for the still-lingering
25     # bug.
26     sort_field = CGI.param('sort');
27     IF (sort_field);
28         no_next = ctx.circs.size - offset <= limit;
29     ELSE;
30         no_next = ctx.circs.size < limit;
31     END;
32     %]
33
34     <div class="header_middle">
35         <span class="float-left">[% l('Previously Checked Out Items') %]</span>
36         <span class='float-left' style='padding-left: 10px;'>
37             <a href='[% mkurl('circ_history', {limit => limit, offset => (offset - limit)}) %]'
38                 [% IF offset == 0 %] class='invisible' [% END %]><span class="nav_arrow_fix">&#9668;</span>[% l('Previous') %]</a>
39             [%# TODO: get total to prevent paging off then end of the list.. %]
40             <a href='[% mkurl('circ_history', {limit => limit, offset => (offset + limit)}) %]'
41                [% IF no_next %] class='invisible' [% END %] >[% l('Next') %]<span class="nav_arrow_fix">&#9658;</span></a>
42         </span>
43         <div class="float-left">
44             <form action="[% mkurl(ctx.opac_root _ '/myopac/circ_history/export') %]" method="post">
45                 <div>
46                     [%- INCLUDE "opac/parts/preserve_params.tt2" %]
47                     [% IF ctx.circs.size > 0 %]
48                     <input type="hidden" name="filename" value="[% l('circ_history.csv') %]"/> 
49                     <button type="submit">[% l('Download CSV') %]</button>
50                     [% END %]
51                 </div>
52             </form>
53         </div>
54     </div>
55     <div class="clear-both"></div>
56
57     [% IF ctx.circs.size < 1 %]
58     <div class="warning_box">[% l('There are no items in your circulation history.') %]</div>
59     [% ELSE %]
60
61     <div id='checked_main'>
62         <table id="acct_checked_main_header"
63             title="[% l('History of Items Checked Out') %]">
64             <thead>
65                 <tr>
66                     <th>[% sort_head("sort_title", l("Title")) %]</th>
67                     <th>[% sort_head("author", l("Author")) %]</th>
68                     <th>[% sort_head("checkout", l("Checkout Date")) %]</th>
69                     <th>[% sort_head("due", l("Due Date")) %]</th>
70                     <th>[% sort_head("returned", l("Date Returned")) %]</th>
71                     <th>[% sort_head("barcode", l("Barcode")) %]</th>
72                     <th>[% sort_head("callnum", l("Call Number")) %]</th>
73                 </tr>
74             </thead>
75             <tbody>
76                 [%# Copy the ctx.circs into a local array, then add a SORT field
77                     that contains the value to sort on.  Since we need the item attrs,
78                     invoke it and save the result in ATTRS.
79                 %]
80                 [% 
81                 circ_items = ctx.circs;  # Array assignment
82
83                 FOR circ IN circ_items;
84                     circ.ATTRS = {marc_xml => circ.marc_xml};
85                     PROCESS get_marc_attrs args=circ.ATTRS;
86                 
87                     SWITCH sort_field;
88
89                        CASE "sort_title";
90                           circ.SORTING = circ.ATTRS.sort_title;
91
92                        CASE "author";
93                           circ.SORTING = circ.ATTRS.author;
94
95                        CASE "checkout";
96                           circ.SORTING = circ.circ.xact_start;
97
98                        CASE "due";
99                           circ.SORTING = circ.circ.due_date;
100
101                        CASE "returned";
102                           circ.SORTING = circ.circ.checkin_time;
103
104                        CASE "barcode";
105                           circ.SORTING = circ.circ.target_copy.barcode;
106
107                        CASE "callnum";
108                           circ.SORTING = circ.circ.target_copy.call_number.label;
109
110                        CASE;
111                           sort_field = "";
112                     END; # SWITCH
113                 END; #FOR circ
114
115                 IF (sort_field != "sort_title");
116                    deemphasize_class = "";
117                 ELSE;
118                    deemphasize_class = " class=\"sort_deemphasize\"";
119                 END;
120                        
121                 # Apply sorting to circ_items
122                 IF (sort_field);
123                    circ_items = circ_items.sort("SORTING");
124                    IF (CGI.param("sort_type") == "desc");
125                       circ_items = circ_items.reverse;
126                    END;
127
128                    # Shorten the circ_items list per offset/limit/cout
129                    hi = offset + limit - 1;
130                    hi = hi > circ_items.max ? circ_items.max : hi;
131
132                    circ_items = circ_items.slice(offset, hi);
133                 END;
134
135                 # circ_items list is now sorted.  Traverse and dump the information.
136
137                 FOR circ IN circ_items; %]
138                     <tr>
139                         <td>
140                             <a href="[% mkurl(ctx.opac_root _ '/record/' _ 
141                                 circ.circ.target_copy.call_number.record.id, {}, 1) %]"
142                                 name="[% l('Catalog record') %]"><span[%- deemphasize_class -%]>
143                                 [%- circ.ATTRS.title.substr(0,circ.ATTRS.nonfiling_characters) | html %]</span>
144                                 [%- circ.ATTRS.title.substr(circ.ATTRS.nonfiling_characters) | html %]</a>
145                         </td>
146                         <td>
147                             <a href="[% mkurl(ctx.opac_root _ '/results',
148                                 {qtype => 'author', query => circ.ATTRS.author.replace('[,\.:;]', '')},
149                                 1
150                             ) %]">[% circ.ATTRS.author | html %]</a>
151                         </td>
152                         <td>
153                             [% date.format(ctx.parse_datetime(circ.circ.xact_start),DATE_FORMAT); %]
154                         </td>
155                         <td>
156                             [% date.format(ctx.parse_datetime(circ.circ.due_date),DATE_FORMAT); %]
157                         </td>
158                         <td>
159                             [% IF circ.circ.checkin_time; 
160                                     date.format(ctx.parse_datetime(circ.circ.checkin_time),DATE_FORMAT); 
161                                 ELSE; %]
162                                 <span style='color:blue;'>*</span><!-- meh -->
163                             [% END; %]
164                         </td>
165                         <td>[% circ.circ.target_copy.barcode | html %]</td>
166                         <td>[% circ.circ.target_copy.call_number.label | html %]</td>
167                     </tr>
168                 [% END %]
169             </tbody>
170         </table>
171     </div>
172     [% END %]
173 </div>
174 [% END %]