]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/templates/opac/myopac/circs.tt2
LP1753536 - Add a new Owning Library column to the OPAC Items Out
[Evergreen.git] / Open-ILS / src / templates / opac / myopac / circs.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 <h3 class="sr-only">[% l('Current Items Checked Out') %]</h3>
7 <div id='myopac_checked_div'>
8
9     <div id="acct_checked_tabs">
10         <div class="align selected">
11             <a href="#">[% l("Current Items Checked Out") %]</a>
12         </div>
13         [%- IF ebook_api.enabled == 'true' %]
14         <div class="align">
15             <a href="[% mkurl('ebook_circs',{},1) %]">[% l("E-Items Currently Checked Out") %]</a>
16         </div>
17         [%- END %]
18         <div class="align">
19             <a href="[% mkurl('circ_history',{},1) %]">[% l("Check Out History") %]</a>
20         </div>
21     </div>
22
23     <div class="header_middle">
24         <span class="float-left">[% l('Current Items Checked Out') %]</span>
25     </div>
26     <div class="clear-both"></div>
27     [% IF ctx.circs.size < 1 %]
28     <div class="warning_box">[% l('You have no items checked out.') %]</div>
29     [% ELSE %]
30     [% IF ctx.success_renewals %]
31     <div class="renew-summary">
32         [% l("Successfully renewed [_1] item(s)", ctx.success_renewals) %]
33     </div>
34     [% END %]
35     [% IF ctx.failed_renewals %]
36     <div class="renew-summary alert">
37         [% l("Failed to renew [_1] item(s)", ctx.failed_renewals) %]
38     </div>
39     [% END %]
40     <div id='checked_main'>
41         <form method="post" id="circ-form"
42             onsubmit="return confirm('[% l("Are you sure you wish to renew the selected item(s)?") %]');">
43         <div>
44             <span>
45                 <select name="action" title="[% l('Select Action') %]">
46                     <option value="renew">[% l('Renew Selected Titles') %]</option>
47                 </select>
48             </span>
49             <span style="padding-left:9px;">
50                 <input type="submit"
51                     value="[% l('Go') %]"
52                     title="[% l('Go') %]"
53                     class="opac-button" />
54             </span>
55             <span style="padding-left:5px;">
56                 <a href="#"><img 
57                     alt="[% l('Renewing Help') %]"
58                     title="[% l('Actions for checked out items') %]"
59                     src="[% ctx.media_prefix %]/images/question-mark.png[% ctx.cache_key %]" /></a>
60             </span>
61         </div>
62
63         <table id="acct_checked_main_header" 
64             title="[% l('Items Checked Out') %]"
65             class="table_no_border_space table_no_cell_pad item_list_padding">
66             <thead>
67             <tr>
68                 <th class="checkbox_column">
69                     <input type="checkbox" id="check_all_checked"
70                         title="[% l('Select All Items') %]"
71                         onclick="var inputs=document.getElementsByTagName('input'); for (i = 0; i < inputs.length; i++) { if (inputs[i].name == 'circ' &amp;&amp; !inputs[i].disabled) inputs[i].checked = this.checked;}"
72                     />
73                 </th>
74                 <th>[% sort_head("sort_title", l("Title")) %]</th>
75                 <th>[% sort_head("author", l("Author")) %]</th>
76                 <th>[% sort_head("renews", l("Renewals Left")) %]</th>
77                 <th>[% sort_head("due", l("Due Date")) %]</th>
78                 <th>[% sort_head("barcode", l("Barcode")) %]</th>
79                 <th>[% sort_head("callnum", l("Call Number")) %]</th>
80                 [% IF ctx.get_org_setting(ctx.user.home_ou, 'opac.show_owning_lib_column'); %]
81                    <th>[% sort_head("lib", l("Owning Library")) %]</th>
82                    [% column_count = 8;
83                 ELSE ;
84                    column_count = 7;
85                 END; %]
86             </tr>
87             </thead>
88             <tbody>
89                 [%# Copy the ctx.circs into a local array, then add a SORT field
90                     that contains the value to sort on.  Since we need the item attrs,
91                     invoke it and save the result in ATTRS.
92                 %]
93                 [% 
94                 circ_items = ctx.circs;  # Array assignment
95
96                 sort_field = CGI.param('sort');  # unless changed below...
97
98                 FOR circ IN circ_items;
99                     circ.ATTRS = {marc_xml => circ.marc_xml};
100                     PROCESS get_marc_attrs args=circ.ATTRS;
101                 
102                     SWITCH sort_field;
103
104                        CASE "sort_title";
105                           circ.SORTING = circ.ATTRS.sort_title;
106
107                        CASE "author";
108                           circ.SORTING = circ.ATTRS.author;
109
110                        CASE "renews";
111                           circ.SORTING = circ.circ.renewal_remaining;
112                        
113                        CASE "due";
114                           circ.SORTING = circ.circ.due_date;
115                        
116                        CASE "barcode";
117                           circ.SORTING = circ.circ.target_copy.barcode;
118
119                        CASE "callnum";
120                           circ.SORTING = circ.circ.target_copy.call_number.label;
121                        CASE "lib";
122                           circ.SORTING = circ.circ.target_copy.call_number.owning_lib.name;
123                        
124                        CASE;
125                           sort_field = "";
126                     END; # SWITCH
127                 END; #FOR circ
128
129                 IF (sort_field != "sort_title");
130                    deemphasize_class = "";
131                 ELSE;
132                    deemphasize_class = " class=\"sort_deemphasize\"";
133                 END;
134
135                 # Apply sorting to circ_items
136                 IF (sort_field);
137                     circ_items = circ_items.sort("SORTING");
138                     IF (CGI.param("sort_type") == "desc");
139                         circ_items = circ_items.reverse;
140                     END;
141                 END;
142
143                 # circ_items list is now sorted.  Traverse and dump the information.
144
145                 FOR circ IN circ_items; %]
146                     <tr>
147                         <td class="checkbox_column" valign="top">
148                             <input type="checkbox" name="circ"
149                                 title="[% l('Item Selected') %]"
150                                 [% IF circ.circ.renewal_remaining < 1 %] disabled="disabled" [% END %]
151                                 value="[% circ.circ.id %]" />
152                         </td>
153                         <td name="title">
154                             [% IF circ.circ.target_copy.call_number.id == -1 %]
155                                 [% circ.circ.target_copy.dummy_title | html %]
156                             [% ELSIF circ.ATTRS.title %]
157                                 <a href="[% mkurl(ctx.opac_root _ '/record/' _ 
158                                     circ.circ.target_copy.call_number.record.id, {}, 1) %]"
159                                     name="[% l('Catalog record') %]"><span[%- deemphasize_class -%]>
160                                     [%- circ.ATTRS.title.substr(0,circ.ATTRS.nonfiling_characters) | html %]</span>
161                                     [%- circ.ATTRS.title.substr(circ.ATTRS.nonfiling_characters) | html %]</a>
162                             [% END %]
163                         </td>
164                         <td name="author">
165                             [% IF circ.circ.target_copy.call_number.id == -1 %]
166                                 [% circ.circ.target_copy.dummy_author | html %]
167                             [% ELSIF circ.ATTRS.author %]
168                                 <a href="[% mkurl(ctx.opac_root _ '/results',
169                                     {qtype => 'author', query => circ.ATTRS.author.replace('[,\.:;]', '')},
170                                     1
171                                 ) %]">[% circ.ATTRS.author | html %]</a>
172                             [% END %]
173                         </td>
174                         <td name="renewals">
175                             [% circ.circ.renewal_remaining %]
176                         </td>
177                         [%
178                             due_date = ctx.parse_datetime(circ.circ.due_date, circ.circ.circ_lib);
179                             due_class = (date.now > date.format(due_date, '%s')) ? 'error' : '';
180                         %]
181                         <td name="due_date" class='[% due_class %]'>
182                             [% date.format(due_date, DATE_FORMAT) %]
183                         </td>
184                         <td name="barcode">
185                             [% circ.circ.target_copy.barcode | html %]
186                         </td>
187                         <td name="call_number">
188                             [% circ.circ.target_copy.call_number.label | html %]
189                         </td>
190                         [% IF ctx.get_org_setting(ctx.user.home_ou, 'opac.show_owning_lib_column'); %]
191                           <td name="lib">
192                           [%- fleshed_ou = circ.circ.target_copy.call_number.owning_lib;
193                             INCLUDE "opac/parts/library_name_link_from_ou.tt2";
194                           %]
195                           </td>
196                         [% END; %]
197                     </tr>
198
199                     [%  IF circ.renewal_response AND
200                             circ.renewal_response.textcode != 'SUCCESS' %]
201                     <tr>
202                         <td colspan="[% column_count %]">[%# XXX colspan="0" does not work in IE %]
203                             <span class="failure-text" title="[% circ.renewal_response.textcode | html %] / [% circ.renewal_response.fail_part | html %]">
204                                 [%
205                                     renew_fail_msg = '';
206                                     IF circ.renewal_response.textcode == 'TOTAL_HOLD_COPY_RATIO_EXCEEDED' OR
207                                         circ.renewal_response.textcode == 'AVAIL_HOLD_COPY_RATIO_EXCEEDED';
208                                         # the stock hold ratio message may not be patron friendly
209                                         renew_fail_msg = l('Item is needed for a hold');
210                                     ELSE;
211                                         renew_fail_msg = circ.renewal_response.desc || 
212                                             circ.renewal_response.fail_part || 
213                                             circ.renewal_response.textcode;
214                                     END;
215                                     renew_fail_msg | html;
216                                 %]
217                             </span>
218                         </td>
219                     </tr>
220                     [% END; %]
221
222                 [% END; %]
223                 </tbody>
224             </table>
225         </form>
226     </div>
227     [% END %]
228 </div>
229 [% END %]