]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/templates/opac/myopac/circs.tt2
LP2061136 - Stamping 1405 DB upgrade script
[working/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                           sortlist = [];
121
122                           FOREACH element IN [circ.circ.target_copy.call_number.prefix.label_sortkey
123                                               circ.circ.target_copy.call_number.label_sortkey
124                                               circ.circ.target_copy.call_number.suffix.label_sortkey
125                                               circ.circ.target_copy.parts.0.label_sortkey];
126                               IF (element);
127                                   sortlist.push(element);
128                               END;
129                           END;
130                           circ.SORTING = sortlist.join("");
131
132                        CASE "lib";
133                           circ.SORTING = circ.circ.target_copy.call_number.owning_lib.name;
134                        
135                        CASE;
136                           sort_field = "";
137                     END; # SWITCH
138                 END; #FOR circ
139
140                 IF (sort_field != "sort_title");
141                    deemphasize_class = "";
142                 ELSE;
143                    deemphasize_class = " class=\"sort_deemphasize\"";
144                 END;
145
146                 # Apply sorting to circ_items
147                 IF (sort_field);
148                     circ_items = circ_items.sort("SORTING");
149                     IF (CGI.param("sort_type") == "desc");
150                         circ_items = circ_items.reverse;
151                     END;
152                 END;
153
154                 # circ_items list is now sorted.  Traverse and dump the information.
155
156                 FOR circ IN circ_items; %]
157                     <tr>
158                         <td class="checkbox_column" valign="top">
159                             <input type="checkbox" name="circ"
160                                 title="[% l('Item Selected') %]"
161                                 [% IF circ.circ.renewal_remaining < 1 %] disabled="disabled" [% END %]
162                                 value="[% circ.circ.id %]" />
163                         </td>
164                         <td name="title">
165                             [% IF circ.circ.target_copy.call_number.id == -1 %]
166                                 [% circ.circ.target_copy.dummy_title | html %]
167                             [% ELSIF circ.ATTRS.title %]
168                                 <a href="[% mkurl(ctx.opac_root _ '/record/' _ 
169                                     circ.circ.target_copy.call_number.record.id, {}, 1) %]"
170                                     name="[% l('Catalog record') %]"><span[%- deemphasize_class -%]>
171                                     [%- circ.ATTRS.title.substr(0,circ.ATTRS.nonfiling_characters) | html %]</span>
172                                     [%- circ.ATTRS.title.substr(circ.ATTRS.nonfiling_characters) | html %]</a>
173                             [% END %]
174                         </td>
175                         <td name="author">
176                             [% IF circ.circ.target_copy.call_number.id == -1 %]
177                                 [% circ.circ.target_copy.dummy_author | html %]
178                             [% ELSIF circ.ATTRS.author %]
179                                 <a href="[% mkurl(ctx.opac_root _ '/results',
180                                     {qtype => 'author', query => circ.ATTRS.author.replace('[,\.:;]', '')},
181                                     1
182                                 ) %]">[% circ.ATTRS.author | html %]</a>
183                             [% END %]
184                         </td>
185                         <td name="renewals">
186                             [% circ.circ.renewal_remaining %]
187                         </td>
188                         [%
189                             due_date = ctx.parse_datetime(circ.circ.due_date, circ.circ.circ_lib);
190                             due_class = (date.now > date.format(due_date, '%s')) ? 'error' : '';
191                         %]
192                         <td name="due_date" class='[% due_class %]'>
193                             [% date.format(due_date, DATE_FORMAT) %]
194                         </td>
195                         <td name="barcode">
196                             [% circ.circ.target_copy.barcode | html %]
197                         </td>
198                         <td name="call_number">
199                             [%-
200                                  cnlist = [];
201                                  FOREACH element IN [circ.circ.target_copy.call_number.prefix.label
202                                               circ.circ.target_copy.call_number.label
203                                               circ.circ.target_copy.call_number.suffix.label];
204                                      IF (element);
205                                        cnlist.push(element);
206                                      END;
207                                  END;
208                                  cn = cnlist.join(' ');
209                             %]
210                             [% cn | html %]
211                             [%- IF circ.circ.target_copy.parts.0.label %]
212                                   </BR>[% circ.circ.target_copy.parts.0.label | html -%]
213                             [%- END %]
214                         </td>
215                         [% IF ctx.get_org_setting(ctx.user.home_ou, 'opac.show_owning_lib_column'); %]
216                           <td name="lib">
217                           [%- fleshed_ou = circ.circ.target_copy.call_number.owning_lib;
218                             INCLUDE "opac/parts/library_name_link_from_ou.tt2";
219                           %]
220                           </td>
221                         [% END; %]
222                     </tr>
223
224                     [%  IF circ.renewal_response AND
225                             circ.renewal_response.textcode != 'SUCCESS' %]
226                     <tr>
227                         <td colspan="[% column_count %]">[%# XXX colspan="0" does not work in IE %]
228                             <span class="failure-text" title="[% circ.renewal_response.textcode | html %] / [% circ.renewal_response.fail_part | html %]">
229                                 [%
230                                     renew_fail_msg = '';
231                                     IF circ.renewal_response.textcode == 'TOTAL_HOLD_COPY_RATIO_EXCEEDED' OR
232                                         circ.renewal_response.textcode == 'AVAIL_HOLD_COPY_RATIO_EXCEEDED';
233                                         # the stock hold ratio message may not be patron friendly
234                                         renew_fail_msg = l('Item is needed for a hold');
235                                     ELSE;
236                                         renew_fail_msg = circ.renewal_response.desc || 
237                                             circ.renewal_response.fail_part || 
238                                             circ.renewal_response.textcode;
239                                     END;
240                                     renew_fail_msg | html;
241                                 %]
242                             </span>
243                         </td>
244                     </tr>
245                     [% END; %]
246
247                 [% END; %]
248                 </tbody>
249             </table>
250         </form>
251     </div>
252     [% END %]
253 </div>
254 [% END %]