]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/templates-bootstrap/opac/myopac/circ_history.tt2
LP1778972 A slew of updates
[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-danger 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"></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>[% sort_head("sort_title", l("Title")) %]</th>
57                     <th>[% sort_head("author", l("Author")) %]</th>
58                     <th>[% sort_head("callnum", l("Call Number")) %]</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                 </tr>
64             </thead>
65             <tbody>
66                 [%# Copy the ctx.circs into a local array, then add a SORT field
67                     that contains the value to sort on.  Since we need the item attrs,
68                     invoke it and save the result in ATTRS.
69         %]
70         [%
71                 circ_items = ctx.circs;  # Array assignment
72
73                 FOR circ IN circ_items;
74                     circ.ATTRS = {marc_xml => circ.marc_xml};
75                     PROCESS get_marc_attrs args=circ.ATTRS;
76
77                     SWITCH sort_field;
78
79                     CASE "sort_title";
80                         circ.SORTING = circ.ATTRS.sort_title;
81
82                     CASE "author";
83                         circ.SORTING = circ.ATTRS.author;
84
85                     CASE "checkout";
86                         circ.SORTING = circ.circ.xact_start;
87
88                     CASE "due";
89                         circ.SORTING = circ.circ.due_date;
90
91                     CASE "returned";
92                         circ.SORTING = circ.circ.checkin_time;
93
94                     CASE "barcode";
95                         circ.SORTING = circ.circ.target_copy.barcode;
96
97                     CASE "callnum";
98                         circ.SORTING = circ.circ.target_copy.call_number.label;
99
100                     CASE;
101                         sort_field = "";
102                     END; # SWITCH
103                 END; #FOR circ
104
105                 IF (sort_field != "sort_title");
106                 deemphasize_class = "";
107                 ELSE;
108                 deemphasize_class = " class=\"sort_deemphasize\"";
109                 END;
110
111                 # Apply sorting to circ_items
112                 IF (sort_field);
113                 circ_items = circ_items.sort("SORTING");
114                 IF (CGI.param("sort_type") == "desc");
115                     circ_items = circ_items.reverse;
116                 END;
117
118                 # Shorten the circ_items list per offset/limit/cout
119                 hi = offset + limit - 1;
120                 hi = hi > circ_items.max ? circ_items.max : hi;
121
122                 circ_items = circ_items.slice(offset, hi);
123                 END;
124
125                 # circ_items list is now sorted.  Traverse and dump the information.
126
127                 FOR circ IN circ_items; %]
128                     <tr>
129             <td class="checkbox_column">
130                 <input type="checkbox" name="circ_id" value="[% circ.circ.id %]" aria-label="Select Item"/>
131             </td>
132                         <td>
133                             <a href="[% mkurl(ctx.opac_root _ '/record/' _
134                                 circ.circ.target_copy.call_number.record.id, {}, 1) %]">
135                                 <span[%- deemphasize_class -%]>
136                                 [%- circ.ATTRS.title.substr(0,circ.ATTRS.nonfiling_characters) | html %]</span>
137                                 [%- circ.ATTRS.title.substr(circ.ATTRS.nonfiling_characters) | html %]</a>
138                         </td>
139                         <td>
140                             [% IF circ.ATTRS.author %]
141                             <a href="[% mkurl(ctx.opac_root _ '/results',
142                                 {qtype => 'author', query => circ.ATTRS.author.replace('[,\.:;]', '')},
143                                 1
144                             ) %]">[% circ.ATTRS.author | html %]</a>
145                             [%END; %]
146                         </td>
147                         <td>[% circ.circ.target_copy.call_number.label | html %]</td>
148                         <td>
149                             [% date.format(ctx.parse_datetime(circ.circ.xact_start),DATE_FORMAT); %]
150                         </td>
151                         <td>
152                             [% IF circ.circ.source_circ;
153                                 date.format(ctx.parse_datetime(circ.circ.due_date, circ.circ.source_circ.circ_lib),DATE_FORMAT);
154                                ELSE;
155                                 date.format(ctx.parse_datetime(circ.circ.due_date, ctx.user.home_ou),DATE_FORMAT);
156                                END;
157                             %]
158                         </td>
159                         <td>
160                             [% IF circ.circ.checkin_time;
161                                     date.format(ctx.parse_datetime(circ.circ.checkin_time),DATE_FORMAT);
162                                 ELSE; %]
163                                 <span style='color:blue;'>Not Returned</span><!-- meh -->
164                             [% END; %]
165                         </td>
166                         <td>[% circ.circ.target_copy.barcode | html %]</td>
167                         
168                     </tr>
169                 [% END %]
170             </tbody>
171         </table>
172     </div>
173     </form>
174     <form action="[% mkurl(ctx.opac_root _ '/myopac/circ_history/export') %]" method="post">
175                 <div>
176                     [%- INCLUDE "opac/parts/preserve_params.tt2" %]
177                     [% IF ctx.circs.size > 0 %]
178                     <input type="hidden" name="filename" value="[% l('circ_history.csv') %]"/>
179                     <button type="submit" class="btn btn-action"><i class="fas fa-file-download"></i> [% l('Download CSV') %]</button>
180                     [% END %]
181                 </div>
182             </form>
183     [% END %]
184 </div></div>
185 [% END %]