]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/templates/opac/myopac/circ_history.tt2
LP#1713160: fix crash viewing circ history in public catalog
[working/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         [%- IF ebook_api.enabled == 'true' %]
18         <div class="align">
19             <a href="[% mkurl('ebook_circs',{},1) %]">[% l("E-Items Currently Checked Out") %]</a>
20         </div>
21         [%- END %]
22         <div class="align selected">
23             <a href="#">[% l("Check Out History") %]</a>
24         </div>
25     </div>
26
27     [%
28     # In the sorting case, the size is the size of ALL the circ items.  In the non-sorting case,
29     # the size is simply the size of the chunk passed in.  See the TODO below for the still-lingering
30     # bug.
31     sort_field = CGI.param('sort');
32     IF (sort_field);
33         no_next = ctx.circs.size - offset <= limit;
34     ELSE;
35         no_next = ctx.circs.size < limit;
36     END;
37     %]
38
39     <div class="header_middle">
40         <span class="float-left">[% l('Previously Checked Out Items') %]</span>
41         <span class='float-left' style='padding-left: 10px;'>
42             <a href='[% mkurl('circ_history', {limit => limit, offset => (offset - limit)}) %]'
43                 [% IF offset == 0 %] class='invisible' [% END %]><span class="nav_arrow_fix">&#9668;</span>[% l('Previous') %]</a>
44             [%# TODO: get total to prevent paging off then end of the list.. %]
45             <a href='[% mkurl('circ_history', {limit => limit, offset => (offset + limit)}) %]'
46             [% IF no_next %] class='invisible' [% END %] >[% l('Next') %]<span class="nav_arrow_fix">&#9658;</span></a>
47         </span>
48         <div class="float-left">
49             <form action="[% mkurl(ctx.opac_root _ '/myopac/circ_history/export') %]" method="post">
50                 <div>
51                     [%- INCLUDE "opac/parts/preserve_params.tt2" %]
52                     [% IF ctx.circs.size > 0 %]
53                     <input type="hidden" name="filename" value="[% l('circ_history.csv') %]"/>
54                     <button type="submit">[% l('Download CSV') %]</button>
55                     [% END %]
56                 </div>
57             </form>
58         </div>
59     </div>
60     <div class="clear-both"></div>
61
62     [% IF ctx.circs.size < 1 %]
63     <div class="warning_box">[% l('There are no items in your circulation history.') %]</div>
64     [% ELSE %]
65
66         <form method="post" id="circ-form"
67             onsubmit="return confirm('[% l("Are you sure you wish to delete the selected item(s)?") %]');">
68         <table cellpadding='0' cellspacing='0' class="item_list_padding">
69             <tr>
70                 <td>
71                     <select name="action">
72                         <option value="delete">[% l('Delete Selected Titles') %]</option>
73                     </select>
74                 </td>
75                 <td style="padding-left:9px;">
76                     <input type="submit"
77                         value="[% l('Go') %]"
78                         alt="[% l('Go') %]" title="[% l('Go') %]"
79                         class="opac-button" />
80                 </td>
81                 <!--
82                 <td style="padding-left:5px;">
83                     <a href="#"><img alt="[% l('Deleting Help') %]"
84                         src="[% ctx.media_prefix %]/images/question-mark.png[% ctx.cache_key %]" /></a>
85                 </td>
86                 -->
87             </tr>
88         </table>
89     <div id='checked_main'>
90         <table id="acct_checked_hist_header"
91             title="[% l('History of Items Checked Out') %]">
92             <thead>
93                 <tr>
94                     <th class="checkbox_column">
95                         <input type="checkbox" onclick="var inputs=document.getElementsByTagName('input'); for (i = 0; i < inputs.length; i++) { if (inputs[i].name == 'circ_id' && !inputs[i].disabled) inputs[i].checked = this.checked;}"/>
96                     </th>
97                     <th>[% sort_head("sort_title", l("Title")) %]</th>
98                     <th>[% sort_head("author", l("Author")) %]</th>
99                     <th>[% sort_head("checkout", l("Checkout Date")) %]</th>
100                     <th>[% sort_head("due", l("Due Date")) %]</th>
101                     <th>[% sort_head("returned", l("Date Returned")) %]</th>
102                     <th>[% sort_head("barcode", l("Barcode")) %]</th>
103                     <th>[% sort_head("callnum", l("Call Number")) %]</th>
104                 </tr>
105             </thead>
106             <tbody>
107                 [%# Copy the ctx.circs into a local array, then add a SORT field
108                     that contains the value to sort on.  Since we need the item attrs,
109                     invoke it and save the result in ATTRS.
110         %]
111         [%
112                 circ_items = ctx.circs;  # Array assignment
113
114                 FOR circ IN circ_items;
115                     circ.ATTRS = {marc_xml => circ.marc_xml};
116                     PROCESS get_marc_attrs args=circ.ATTRS;
117
118                     SWITCH sort_field;
119
120                     CASE "sort_title";
121                         circ.SORTING = circ.ATTRS.sort_title;
122
123                     CASE "author";
124                         circ.SORTING = circ.ATTRS.author;
125
126                     CASE "checkout";
127                         circ.SORTING = circ.circ.xact_start;
128
129                     CASE "due";
130                         circ.SORTING = circ.circ.due_date;
131
132                     CASE "returned";
133                         circ.SORTING = circ.circ.checkin_time;
134
135                     CASE "barcode";
136                         circ.SORTING = circ.circ.target_copy.barcode;
137
138                     CASE "callnum";
139                         circ.SORTING = circ.circ.target_copy.call_number.label;
140
141                     CASE;
142                         sort_field = "";
143                     END; # SWITCH
144                 END; #FOR circ
145
146                 IF (sort_field != "sort_title");
147                 deemphasize_class = "";
148                 ELSE;
149                 deemphasize_class = " class=\"sort_deemphasize\"";
150                 END;
151
152                 # Apply sorting to circ_items
153                 IF (sort_field);
154                 circ_items = circ_items.sort("SORTING");
155                 IF (CGI.param("sort_type") == "desc");
156                     circ_items = circ_items.reverse;
157                 END;
158
159                 # Shorten the circ_items list per offset/limit/cout
160                 hi = offset + limit - 1;
161                 hi = hi > circ_items.max ? circ_items.max : hi;
162
163                 circ_items = circ_items.slice(offset, hi);
164                 END;
165
166                 # circ_items list is now sorted.  Traverse and dump the information.
167
168                 FOR circ IN circ_items; %]
169                     <tr>
170             <td class="checkbox_column">
171                 <input type="checkbox" name="circ_id" value="[% circ.circ.id %]" />
172             </td>
173                         <td>
174                             <a href="[% mkurl(ctx.opac_root _ '/record/' _
175                                 circ.circ.target_copy.call_number.record.id, {}, 1) %]"
176                                 name="[% l('Catalog record') %]"><span[%- deemphasize_class -%]>
177                                 [%- circ.ATTRS.title.substr(0,circ.ATTRS.nonfiling_characters) | html %]</span>
178                                 [%- circ.ATTRS.title.substr(circ.ATTRS.nonfiling_characters) | html %]</a>
179                         </td>
180                         <td>
181                             <a href="[% mkurl(ctx.opac_root _ '/results',
182                                 {qtype => 'author', query => circ.ATTRS.author.replace('[,\.:;]', '')},
183                                 1
184                             ) %]">[% circ.ATTRS.author | html %]</a>
185                         </td>
186                         <td>
187                             [% date.format(ctx.parse_datetime(circ.circ.xact_start),DATE_FORMAT); %]
188                         </td>
189                         <td>
190                             [% IF circ.circ.source_circ;
191                                 date.format(ctx.parse_datetime(circ.circ.due_date, circ.circ.source_circ.circ_lib),DATE_FORMAT);
192                                ELSE;
193                                 date.format(ctx.parse_datetime(circ.circ.due_date, ctx.user.home_ou),DATE_FORMAT);
194                                END;
195                             %]
196                         </td>
197                         <td>
198                             [% IF circ.circ.checkin_time;
199                                     date.format(ctx.parse_datetime(circ.circ.checkin_time),DATE_FORMAT);
200                                 ELSE; %]
201                                 <span style='color:blue;'>*</span><!-- meh -->
202                             [% END; %]
203                         </td>
204                         <td>[% circ.circ.target_copy.barcode | html %]</td>
205                         <td>[% circ.circ.target_copy.call_number.label | html %]</td>
206                     </tr>
207                 [% END %]
208             </tbody>
209         </table>
210     </div>
211     </form>
212     [% END %]
213 </div>
214 [% END %]