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