]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/templates/opac/myopac/circ_history.tt2
LP 2061136 follow-up: ng lint --fix
[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                         sortlist = [];
140
141                         FOREACH element IN [circ.circ.target_copy.call_number.prefix.label_sortkey
142                                             circ.circ.target_copy.call_number.label_sortkey
143                                             circ.circ.target_copy.call_number.suffix.label_sortkey
144                                             circ.circ.target_copy.parts.0.label_sortkey];
145                             IF (element);
146                                 sortlist.push(element);
147                             END;
148                         END;
149                         circ.SORTING = sortlist.join("");
150
151                     CASE;
152                         sort_field = "";
153                     END; # SWITCH
154                 END; #FOR circ
155
156                 IF (sort_field != "sort_title");
157                 deemphasize_class = "";
158                 ELSE;
159                 deemphasize_class = " class=\"sort_deemphasize\"";
160                 END;
161
162                 # Apply sorting to circ_items
163                 IF (sort_field);
164                 circ_items = circ_items.sort("SORTING");
165                 IF (CGI.param("sort_type") == "desc");
166                     circ_items = circ_items.reverse;
167                 END;
168
169                 # Shorten the circ_items list per offset/limit/cout
170                 hi = offset + limit - 1;
171                 hi = hi > circ_items.max ? circ_items.max : hi;
172
173                 circ_items = circ_items.slice(offset, hi);
174                 END;
175
176                 # circ_items list is now sorted.  Traverse and dump the information.
177
178                 FOR circ IN circ_items; %]
179                     <tr>
180             <td class="checkbox_column">
181                 <input type="checkbox" name="circ_id" value="[% circ.circ.id %]" />
182             </td>
183                         <td>
184                             <a href="[% mkurl(ctx.opac_root _ '/record/' _
185                                 circ.circ.target_copy.call_number.record.id, {}, 1) %]"
186                                 name="[% l('Catalog record') %]"><span[%- deemphasize_class -%]>
187                                 [%- circ.ATTRS.title.substr(0,circ.ATTRS.nonfiling_characters) | html %]</span>
188                                 [%- circ.ATTRS.title.substr(circ.ATTRS.nonfiling_characters) | html %]</a>
189                         </td>
190                         <td>
191                             <a href="[% mkurl(ctx.opac_root _ '/results',
192                                 {qtype => 'author', query => circ.ATTRS.author.replace('[,\.:;]', '')},
193                                 1
194                             ) %]">[% circ.ATTRS.author | html %]</a>
195                         </td>
196                         <td>
197                             [% date.format(ctx.parse_datetime(circ.circ.xact_start),DATE_FORMAT); %]
198                         </td>
199                         <td>
200                             [% IF circ.circ.source_circ;
201                                 date.format(ctx.parse_datetime(circ.circ.due_date, circ.circ.source_circ.circ_lib),DATE_FORMAT);
202                                ELSE;
203                                 date.format(ctx.parse_datetime(circ.circ.due_date, ctx.user.home_ou),DATE_FORMAT);
204                                END;
205                             %]
206                         </td>
207                         <td>
208                             [% IF circ.circ.checkin_time;
209                                     date.format(ctx.parse_datetime(circ.circ.checkin_time),DATE_FORMAT);
210                                 ELSE; %]
211                                 <span style='color:blue;'>*</span><!-- meh -->
212                             [% END; %]
213                         </td>
214                         <td>[% circ.circ.target_copy.barcode | html %]</td>
215                         <td>
216                             [%-
217                                  cnlist = [];
218                                  FOREACH element IN [circ.circ.target_copy.call_number.prefix.label
219                                               circ.circ.target_copy.call_number.label
220                                               circ.circ.target_copy.call_number.suffix.label];
221                                      IF (element);
222                                        cnlist.push(element);
223                                      END;
224                                  END;
225                                  cn = cnlist.join(' ');
226                             %]
227                             [% cn | html %]
228                             [%- IF circ.circ.target_copy.parts.0.label %]
229                                   </BR>[% circ.circ.target_copy.parts.0.label | html -%]
230                             [%- END %]
231                          </td>
232                     </tr>
233                 [% END %]
234             </tbody>
235         </table>
236     </div>
237     </form>
238     [% END %]
239 </div>
240 [% END %]