]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/templates-bootstrap/opac/myopac/circ_history.tt2
LP 2061136 follow-up: ng lint --fix
[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 = "circ_history"
6     parent="circs";
7     limit = ctx.circ_history_limit;
8     offset = ctx.circ_history_offset;
9 %]
10 <h3>[% l('History of Checked Out Items') %]</h3>
11 <div style="padding:0px;">
12     [%
13     # In the sorting case, the size is the size of ALL the circ items.  In the non-sorting case,
14     # the size is simply the size of the chunk passed in.  See the TODO below for the still-lingering
15     # bug.
16     sort_field = CGI.param('sort');
17     IF (sort_field);
18         no_next = ctx.circs.size - offset <= limit;
19     ELSE;
20         no_next = ctx.circs.size < limit;
21     END;
22     %]
23 <div>
24
25
26     [% IF ctx.circs.size < 1 %]
27     <div class="warning_box">[% l('There are no items in your circulation history.') %]</div>
28     [% ELSE %]
29
30         <form method="post" id="circ-form">
31
32         <div class="row">
33         <div class="col-3 text-left">[% IF offset != 0 %]<a href='[% mkurl('circ_history', {limit => limit, offset => (offset - limit)}) %]'
34                  class="btn btn-action mr-3" ><span class="nav_arrow_fix">&#9668;</span>[% l('Previous') %]</a>[% END %]
35                  <button name="action" class="btn btn-deny my-2" id="delete" value="delete" type="submit" onclick="return confirm('[% l("Are you sure you wish to delete the selected item(s)?") %]');">
36             <i class="fas fa-trash-alt" aria-hidden="true"></i> Delete Selected</button>
37             </div>
38         <div class="col-6 text-center"></div>
39         <div class="col-3 text-right">[% IF !no_next %]<a href='[% mkurl('circ_history', {limit => limit, offset => (offset + limit)}) %]'
40                class="btn btn-action" >[% l('Next') %]<span class="nav_arrow_fix">&#9658;</span></a>[% END %] </div>
41     </div>
42     <div id='checked_main'>
43      <div class="d-block d-md-none">
44
45
46             <input id="check_all_circ_hist" checked="checked" 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;}"/>
47
48             <label for="check_all_circ_hist">[% l('Check/Uncheck All') %]</label>
49         </div>
50         <table title="[% l('History of Items Checked Out') %]" id="acct_checked_hist_header" class="table table-hover table-bordered miniTable circHistTable my-3">
51             <thead>
52                 <tr>
53                     <td class="checkCell">
54                         <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;}" aria-label="[% l('Click to (un)select all items') %]"/>
55                     </td>
56                     <th>[% l("Cover") %]</th>
57                     <th>[% sort_head("sort_title", l("Title")) %]</th>
58                     <th>[% sort_head("author", l("Author")) %]</th>
59                     <th>[% sort_head("checkout", l("Checkout Date")) %]</th>
60                     <th>[% sort_head("due", l("Due Date")) %]</th>
61                     <th>[% sort_head("returned", l("Date Returned")) %]</th>
62                     <th>[% sort_head("barcode", l("Barcode")) %]</th>
63                     <th>[% sort_head("callnum", l("Call Number")) %]</th>
64                 </tr>
65             </thead>
66             <tbody>
67                 [%# Copy the ctx.circs into a local array, then add a SORT field
68                     that contains the value to sort on.  Since we need the item attrs,
69                     invoke it and save the result in ATTRS.
70         %]
71         [%
72                 circ_items = ctx.circs;  # Array assignment
73
74                 FOR circ IN circ_items;
75                     circ.ATTRS = {marc_xml => circ.marc_xml};
76                     PROCESS get_marc_attrs args=circ.ATTRS;
77
78                     SWITCH sort_field;
79
80                     CASE "sort_title";
81                         circ.SORTING = circ.ATTRS.sort_title;
82
83                     CASE "author";
84                         circ.SORTING = circ.ATTRS.author;
85
86                     CASE "checkout";
87                         circ.SORTING = circ.circ.xact_start;
88
89                     CASE "due";
90                         circ.SORTING = circ.circ.due_date;
91
92                     CASE "returned";
93                         circ.SORTING = circ.circ.checkin_time;
94
95                     CASE "barcode";
96                         circ.SORTING = circ.circ.target_copy.barcode;
97
98                     CASE "callnum";
99                         sortlist = [];
100
101                         FOREACH element IN [circ.circ.target_copy.call_number.prefix.label_sortkey
102                                             circ.circ.target_copy.call_number.label_sortkey
103                                             circ.circ.target_copy.call_number.suffix.label_sortkey
104                                             circ.circ.target_copy.parts.0.label_sortkey];
105                             IF (element);
106                                 sortlist.push(element);
107                             END;
108                         END;
109                         circ.SORTING = sortlist.join("");
110
111                     CASE;
112                         sort_field = "";
113                     END; # SWITCH
114                 END; #FOR circ
115
116                 IF (sort_field != "sort_title");
117                 deemphasize_class = "";
118                 ELSE;
119                 deemphasize_class = " class=\"sort_deemphasize\"";
120                 END;
121
122                 # Apply sorting to circ_items
123                 IF (sort_field);
124                 circ_items = circ_items.sort("SORTING");
125                 IF (CGI.param("sort_type") == "desc");
126                     circ_items = circ_items.reverse;
127                 END;
128
129                 # Shorten the circ_items list per offset/limit/cout
130                 hi = offset + limit - 1;
131                 hi = hi > circ_items.max ? circ_items.max : hi;
132
133                 circ_items = circ_items.slice(offset, hi);
134                 END;
135
136                 # circ_items list is now sorted.  Traverse and dump the information.
137
138                 FOR circ IN circ_items; %]
139                     <tr>
140             <td class="checkbox_column">
141                 <input type="checkbox" name="circ_id" value="[% circ.circ.id %]" aria-label="Select Item"/>
142             </td>
143                         [%  IF circ.ATTRS.issns.0;
144                                 row_isbnissn = circ.ATTRS.issns.0;
145                             ELSIF circ.ATTRS.isbns.0;
146                                 row_isbnissn = circ.ATTRS.isbns.0;
147                             ELSE;
148                                 row_isbnissn = '';
149                             END;
150                             row_rec_id = circ.circ.target_copy.call_number.record.id;
151                             row_title = circ.ATTRS.title;
152                             PROCESS show_cover;
153                         %]
154                         <td>
155                           [% IF circ.circ.target_copy.call_number.id == -1 %]
156                                 [% circ.circ.target_copy.dummy_title | html %]
157                           [% ELSIF circ.ATTRS.title %]
158                             <a href="[% mkurl(ctx.opac_root _ '/record/' _
159                                 circ.circ.target_copy.call_number.record.id, {}, 1) %]">
160                                 <span[%- deemphasize_class -%]>
161                                 [%- circ.ATTRS.title.substr(0,circ.ATTRS.nonfiling_characters) | html %]</span>
162                                 [%- circ.ATTRS.title.substr(circ.ATTRS.nonfiling_characters) | html %]</a>
163                           [% END %]
164                         </td>
165                         <td>
166                             [% IF circ.circ.target_copy.call_number.id == -1 %]
167                                 [% circ.circ.target_copy.dummy_author | html %]
168                             [% ELSIF circ.ATTRS.author %]
169                                 <a href="[% mkurl(ctx.opac_root _ '/results',
170                                     {qtype => 'author', query => circ.ATTRS.author.replace('[,\.:;]', '')},
171                                     1
172                                 ) %]">[% circ.ATTRS.author | html %]</a>
173                             [% END; %]
174                         </td>
175                         <td>
176                             [% date.format(ctx.parse_datetime(circ.circ.xact_start),DATE_FORMAT); %]
177                         </td>
178                         <td>
179                             [% IF circ.circ.source_circ;
180                                 date.format(ctx.parse_datetime(circ.circ.due_date, circ.circ.source_circ.circ_lib),DATE_FORMAT);
181                                ELSE;
182                                 date.format(ctx.parse_datetime(circ.circ.due_date, ctx.user.home_ou),DATE_FORMAT);
183                                END;
184                             %]
185                         </td>
186                         <td>
187                             [% IF circ.circ.checkin_time;
188                                     date.format(ctx.parse_datetime(circ.circ.checkin_time),DATE_FORMAT);
189                                 ELSE; %]
190                                 <span style='color:blue;'>Not Returned</span><!-- meh -->
191                             [% END %]
192                         </td>
193                         <td>[% circ.circ.target_copy.barcode | html %]</td>
194                         <td>
195                               [%-
196                                    cnlist = [];
197                                    FOREACH element IN [circ.circ.target_copy.call_number.prefix.label
198                                                 circ.circ.target_copy.call_number.label
199                                                 circ.circ.target_copy.call_number.suffix.label];
200                                        IF (element);
201                                          cnlist.push(element);
202                                        END;
203                                    END;
204                                    cn = cnlist.join(' ');
205                               %]
206                               [% cn | html %]
207                               [%- IF circ.circ.target_copy.parts.0.label %]
208                                     </BR>[% circ.circ.target_copy.parts.0.label | html -%]
209                               [%- END %]
210                         </td>
211
212                     </tr>
213                 [% END %]
214             </tbody>
215         </table>
216     </div>
217     </form>
218     <form action="[% mkurl(ctx.opac_root _ '/myopac/circ_history/export') %]" method="post">
219                 <div>
220                     [%- INCLUDE "opac/parts/preserve_params.tt2" %]
221                     [% IF ctx.circs.size > 0 %]
222                     <input type="hidden" name="filename" value="[% l('circ_history.csv') %]"/>
223                     <button type="submit" class="btn btn-action"><i class="fas fa-file-download" aria-hidden="true"></i> [% l('Download CSV') %]</button>
224                     [% END %]
225                 </div>
226             </form>
227     [% END %]
228 </div></div>
229 [% END %]