LP1164197 - Add page number navigation to my lists and setting for number of lists...
[working/Evergreen.git] / Open-ILS / src / templates / opac / myopac / lists.tt2
1 [%  PROCESS "opac/parts/header.tt2";
2     PROCESS "opac/parts/misc_util.tt2";
3     WRAPPER "opac/parts/myopac/base.tt2";
4     myopac_page = "lists"  
5     limit = ctx.bookbags_limit;
6     offset = ctx.bookbags_offset;
7     item_page = ctx.bookbags_item_page;
8 %]
9 <div id='myopac_bookbag_div' style="padding:5px;">
10
11     <!-- new list creation -->
12     <form action="[% mkurl(ctx.opac_root _ '/myopac/list/update') %]" method="post" id="create_form">
13         <h1>[% l('Create New List') %]</h1><a name="createnewlist"></a>
14         <table cellpadding="0" border="0" id="list_create_table">
15             <tr>
16                 <td>
17                     <label for="list_create_name">[% l('Enter the name of the new list:') %]</label>
18                 </td>
19                 <td>
20                     [%- INCLUDE "opac/parts/preserve_params.tt2"; %]
21                     <input id="list_create_name" type="text" name="name" />
22                     <input type="hidden" name="action" value="create" />
23                     [% IF ctx.add_rec %]
24                     <input type="hidden" name="add_rec" value="[% ctx.add_rec %]" />
25                     [% END %]
26                     [% IF ctx.where_from %]
27                     <input type="hidden" name="where_from" value="[% ctx.where_from %]" />
28                     [% END %]
29                 </td>
30                 <td>
31                     <label for="list_create_shared">[% l('Share this list?') %]</label>
32                     <select name="shared" id="list_create_shared">
33                         <option value="0">[% l('No') %]
34                         <option value="1">[% l('Yes') %]
35                     </select>
36                     <a href="javascript:void(0);" onclick="alert(document.getElementById('bb_publish_text').innerHTML);"><img alt="[% l('Sharing Help') %]"
37                         src="[% ctx.media_prefix %]/images/question-mark.png" /></a>
38                 </td>
39                 <td class="list-create-table-buttons">
40                     <input type="submit"
41                         value="[% l('Submit') %]"
42                         alt="[% l('Submit') %]"
43                         class="opac-button"/>
44                     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
45                     <input type="reset"
46                         value="[% l('Cancel') %]"
47                         alt="[% l('Cancel') %]"
48                         class="opac-button" />
49                 </td>
50             </tr>
51             <tr>
52                 <td class="text-right-top">
53                     <label for="list_description">[% l("List description (optional):") %]</label>
54                 </td>
55                 <td colspan="3">
56                     <textarea cols="40" rows="3" name="description"
57                         id="list_description"></textarea>
58                 </td>
59         </table>
60     </form>
61
62     <h1>[% l("My Existing Lists") %]</h1>
63     [% INCLUDE "opac/parts/anon_list.tt2" %]
64     [% IF ctx.bookbags.size %]
65     <div class="header_middle">
66         <span class="float-left">[% l('Saved Lists') %]</span>
67         [% IF limit < ctx.bookbag_count; %]
68         <span class='float-left' style='padding-left: 10px;'>
69             [%- IF offset > 0 -%]
70                 <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
71                     offset => (offset - limit)
72                 }) %]'><span class="nav_arrow_fix">&#9668;</span>[% l('Previous') %]</a>
73             [%- END; -%]
74             [%- IF (offset - (limit * 3)) >= 0 -%]
75                 <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
76                     offset => (offset - (limit * 3))
77                 }) %]'>[% ((offset - (limit * 3)) / limit) + 1 %]</a>
78             [%- END; -%]
79             [%- IF (offset - (limit * 2)) >= 0 -%]
80                 <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
81                     offset => (offset - (limit * 2))
82                 }) %]'>[% ((offset - (limit * 2)) / limit) + 1 %]</a>
83             [%- END; -%]
84             [%- IF (offset - limit) >= 0 -%]
85                 <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
86                     offset => (offset - limit)
87                 }) %]'>[% ((offset - limit) / limit) + 1 %]</a>
88             [%- END; -%]
89             <span style="color:red;" >[% (offset / limit) + 1 %]</span>
90             [%- IF (offset + limit) <= ctx.bookbag_count -%]
91                 <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
92                     offset => (offset + limit)
93                 }) %]'>[% ((offset + limit) / limit) + 1 %]</a>
94             [%- END; -%]
95             [%- IF (offset + (limit * 2)) <= ctx.bookbag_count -%]
96                 <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
97                     offset => (offset + (limit * 2))
98                 }) %]'>[% ((offset + (limit * 2)) / limit) + 1 %]</a>
99             [%- END; -%]
100             [%- IF (offset + (limit * 3)) <= ctx.bookbag_count -%]
101                 <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
102                     offset => (offset + (limit * 3))
103                 }) %]'>[% ((offset + (limit * 3)) / limit) + 1 %]</a>
104             [%- END; -%]
105             [%- IF (ctx.bookbag_count - offset) > limit; -%] 
106                 <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
107                     offset => (offset + limit)
108                 }) %]'>[% l('Next') %]<span class="nav_arrow_fix">&#9658;</span></a>
109             </span>
110             [%- END; -%]
111         [% END %]
112     </div>
113     <div class="clear-both"></div>
114
115     <div id='acct_lists_prime'>
116         [% FOR bbag IN ctx.bookbags %]
117         <div class="bookbag-controls-holder">
118             <div class="bookbag-controls most">
119                 [% baseurl = ctx.opac_root _ '/myopac/lists';
120                 IF bbag.id != CGI.param("bbid");
121                     url = mkurl(baseurl,{bbid => bbag.id, item_page => 1},['edit_notes','sort']);
122                     ltitle = l("Show items in list");
123                 ELSE;
124                     url = mkurl(baseurl, {}, ['bbid', 'edit_notes', 'sort']);
125                     ltitle = l("Hide items in list");
126                 END %]
127                 <h2 class="bookbag-name"><a title="[% ltitle %]" href="[% url %]">[% bbag.name | html %]</a></h2>
128                 [% IF bbag.description %]<div class="bookbag-description">[% bbag.description | html %]</div>[% END %]
129             </div>
130             [% IF ctx.add_rec %]
131             <form action="[% mkurl(ctx.opac_root _ '/myopac/list/update', {}, 1) %]" method="post">
132                 <div class="bookbag-controls">
133                     <input type="hidden" name="action" value="add_rec" />
134                     <input type="hidden" name="list" value="[% bbag.id %]" />
135                     <input type="hidden" name="add_rec" value="[% ctx.add_rec %]" />
136                     [% IF ctx.where_from %]
137                     <input type="hidden" name="where_from" value="[% ctx.where_from %]" />
138                     [% END %]
139                     <input class="fixed" type="submit" value="[% l('Add to this list') %]" />
140                 </div>
141             </form>
142             [% END %]
143             <form action="[% mkurl(ctx.opac_root _ '/myopac/list/update') %]" method="post">
144                 <div class="bookbag-share">
145                     <input type="hidden" name="list" value="[% bbag.id %]" />
146                     [%- INCLUDE "opac/parts/preserve_params.tt2"; %]
147                     [% IF bbag.pub != 't' %]
148                     <input type="hidden" name="action" value="show" />
149                     <input class="fixed" type="submit" value="[% l('Share') %]" />
150                     [% ELSE %]
151                     <input type="hidden" name="action" value="hide" />
152                     <input class="fixed" type="submit" value="[% l('Hide') %]" />
153                     [% END %]
154                 </div>
155             </form>
156             <form action="[% mkurl(ctx.opac_root _ '/myopac/list/update') %]" method="post">
157                 <div class="bookbag-controls">
158                     <input type="hidden" name="list" value="[% bbag.id %]" />
159                     <input type="hidden" name="action" value="delete" />
160                     [%- INCLUDE "opac/parts/preserve_params.tt2"; %]
161                     <input type="submit" value="[% l('Delete List') %]" />
162                 </div>
163             </form>
164             <form action="[% mkurl(ctx.opac_root _ '/myopac/list/print') %]" method="post">
165                 <div class="bookbag-controls">
166                     <input type="hidden" name="list" value="[% bbag.id %]" />
167                     <input type="hidden" name="sort" value="[% CGI.param('sort') | html %]" />
168                     [%- INCLUDE "opac/parts/preserve_params.tt2"; %]
169                     <input type="submit" value="[% l('Download CSV') %]" />
170                 </div>
171             </form>
172             [% setting = 'opac.default_list'; %]
173             <form action="[% mkurl(ctx.opac_root _ '/myopac/list/update') %]" method="post">
174                 <div class="bookbag-controls">
175                     <input type="hidden" name="list" value="[% bbag.id %]" />
176                     [%- INCLUDE "opac/parts/preserve_params.tt2"; %]
177                     [% IF ctx.user_setting_map.$setting == bbag.id %]
178                     <input type="hidden" name="action" value="remove_default" />
179                     <input type="submit" value="[% l('Remove Default List') %]" />
180                     [% ELSE %]
181                     <input type="hidden" name="action" value="make_default" />
182                     <input type="submit" value="[% l('Make Default List') %]" />
183                     [% END %]
184                 </div>
185             </form>
186             [% IF ctx.is_staff %]
187             <div class="bookbag-controls">
188                 <input 
189                     type="submit" 
190                     onclick='
191                        var path = 
192                           "oils://remote/xul/server/cat/bucketz39_dialog.xul";
193                         window.openDialog(
194                             xulG.url_prefix(path),
195                             "bucketz39_dialog",
196                             "width=800,height=500",
197                             "[% ctx.user.id %]",
198                             "[% ctx.authtoken %]",
199                             "[% ctx.user.ws_ou %]",
200                             "[% bbag.id %]",
201                             xulG
202                         )'
203                     value="[% l('Locate Z39.50 Matches') %]" 
204                 />
205             </div>
206             [% END %]
207             <div class="bookbag-controls">
208                 [% IF bbag.pub == 't'; %]
209                 <a target='_blank' href='/opac/extras/feed/bookbag/rss2-full/[% bbag.id %]'><img
210                     alt="[% l('RSS Feed') %]" border="0"
211                     src="[% ctx.media_prefix %]/images/small-rss.png"/></a>
212                 [% END %]
213             </div>
214             <div class="bookbag-controls">
215                 [% IF bbag.pub == 't'; %]
216                 <a href='[%-
217                     mkurl(
218                         ctx.opac_root _ '/results',
219                         {page => '0', bookbag => bbag.id, depth => 0, locg => ctx.search_ou},
220                         1
221                     )
222                 -%]'>[% l('HTML View') %]</a>
223                 [% END %]
224             </div>
225             <div class="clear-both pad-bottom-five"></div>
226         </div>
227         [% IF CGI.param("bbid") == bbag.id %]
228         <div class="bookbag-specific">
229             <div class="sort">
230                 <form method="get">
231                     <label for="opac.result.sort">[% l("Sort list items by: ") %]</label>
232                     [%- INCLUDE "opac/parts/preserve_params.tt2" params=['loc', 'query', 'qtype']; %]
233                     [% INCLUDE "opac/parts/filtersort.tt2"
234                         value=CGI.param('sort') mode='bookbag' %]
235                     <input type="hidden" name="bbid"
236                         value="[% CGI.param('bbid') | html %]" />
237                     <input type="submit" value="[% l('Sort') %]" />
238                 </form>
239             </div>
240             <div class="meta">
241                 <form method="post">
242                     <input type="hidden" name="bbid" value="[% bbag.id %]" />
243                     <input type="hidden" name="action" value="editmeta" />
244                     <input type="hidden" name="limit" value="[% limit %]" />
245                     <input type="hidden" name="offset" value="[% offset %]" />
246                     [%- INCLUDE "opac/parts/preserve_params.tt2"; %]
247                     <table id="bbag-name-desc-form">
248                         <tr>
249                             <th>
250                                 <label for="bbag-edit-name">[% l('Name:') %]</label>
251                             </th>
252                             <td>
253                                 <input name="name" type="text"
254                                     value="[% bbag.name | html %]"
255                                     id="bbag-edit-name" />
256                             </td>
257                             <td rowspan="2" class="saver">
258                                 [% l("Save changes to name or description?") %]<br />
259                                 <input type="submit" value="[% l('Save') %]" />
260                             </td>
261                         </tr>
262                         <tr>
263                             <th><label for="bbag-edit-description">[% l('Description:') %]</label></th>
264                             <td>
265                                 <textarea name="description"
266                                     id="bbag-edit-description">[% bbag.description | html %]</textarea>
267                             </td>
268                         </tr>
269                     </table>
270                 </form>
271             </div>
272         </div>
273         <br class="clear-both" />
274         <form action="[% mkurl(ctx.opac_root _ '/myopac/list/update') %]" method="post">
275         <input type="hidden" name="list" value="[% bbag.id %]" />
276         <input type="hidden" name="sort" value="[% CGI.param('sort') | uri %]" />
277         <table class="bookbag-specific" cellpadding='0' cellspacing='0' border='0'>
278             <thead id="acct_list_header">
279                 <tr>
280                     <td class="list_checkbox">
281                     <input type="checkbox" onclick="
282                         var inputs=document.getElementsByTagName('input'); 
283                         for (i = 0; i < inputs.length; i++) { 
284                             if (inputs[i].name == 'selected_item' && !inputs[i].disabled && inputs[i].getAttribute('bbag') == [% bbag.id %]) 
285                                 inputs[i].checked = this.checked;}"/>
286
287                     </td>
288                     <td class="list_entry">
289                         <a href="[% mkurl(ctx.opac_root _ '/myopac/lists', {sort=> (CGI.param('sort') == 'titlesort' ? 'titlesort.descending' : 'titlesort')}) %]">[% l('Title') %]</a>
290                     </td>
291                     <td class="list_entry">
292                         <a href="[% mkurl(ctx.opac_root _ '/myopac/lists', {sort=>(CGI.param('sort') == 'authorsort' ? 'authorsort.descending' : 'authorsort')}) %]">[% l('Author(s)') %]</a>
293                     </td>
294                     <td class='list_entry'>
295                         [% l('Local Call Number') %]
296                     </td>
297                     <td class="list_entry">
298                         <a href="[% mkurl(ctx.opac_root _ '/myopac/lists', {sort=>(CGI.param('sort') == 'pubdate' ? 'pubdate.descending' : 'pubdate')}) %]">[% l('Publication Date') %]</a>
299                     </td>
300                     <td class="list_entry">
301                          [% l('Format') %]
302                     </td>
303                     <td class="list_entry">
304                         [% l('Notes') %]
305                         [% IF CGI.param("edit_notes") != bbag.id %]
306                         | <a href="[% mkurl(ctx.opac_root _ '/myopac/lists', {edit_notes=> bbag.id}) %]">[% l('Edit') %]</a>
307                         [% END %]
308                     </td>
309                     <td class="list_actions">
310                         <select name="action">
311                             <option disabled="disabled">[% l('-- Actions for these items --') %]</option>
312                             <option value="place_hold">[% l('Place hold') %]</option>
313                             <option value="del_item">[% l('Remove from list') %]</option>
314                         </select>
315                         [%- INCLUDE "opac/parts/preserve_params.tt2"; %]
316                         <input type="submit" value="[% l('Go') %]" />
317                     </td>
318                 </tr>
319             </thead>
320             <tbody>
321                 [% UNLESS bbag.items.size %]
322                 <tr><td colspan="6" class="list_is_empty">
323                     [% l("This list contains no items.") %]
324                 </td></tr>
325                 [% END %]
326                 [% FOR item IN bbag.items;
327                     rec_id = item.target_biblio_record_entry.id;
328                     attrs = {marc_xml => ctx.bookbags_marc_xml.$rec_id};
329                     PROCESS get_marc_attrs args=attrs %]
330                 <tr class="bookbag-item-row">
331                     <td class="list_checkbox">
332                         <input type="checkbox" name="selected_item" value="[% item.id %]" bbag='[% bbag.id %]'/>
333                     </td>
334                     <td class="list_entry">
335                         <a href="[% mkurl(ctx.opac_root _ '/record/' _ rec_id, {}, ['edit_notes', 'bbid']) %]">[% attrs.title | html %]</a>
336                     </td>
337                     <td class="list_entry">
338                         <a href="[%- 
339                             authorquery = attrs.author | replace('[,\.:;]', '');
340                             mkurl(ctx.opac_root _ '/results', {qtype => 'author', query => authorquery}, ['page', 'bbid', 'edit_notes'])
341                             -%]">[% attrs.author | html %]</a>
342                     </td>
343                     <td class="list_entry">
344                         [% 
345                             copy = attrs.holdings.0;
346                             IF copy;
347                                 # only show a relevant call number
348                                 copy_org = ctx.get_aou_by_shortname(copy.owner);
349                                 FOR ctx_org IN [ctx.pref_ou, ctx.search_ou, ctx.home_ou, ctx.physical_loc];
350                                     NEXT UNLESS ctx_org;
351                                     ctx_org = ctx.get_aou(ctx_org);
352                                     IF ctx.org_within_scope(ctx_org, copy_org, ctx_org.ou_type.depth);
353                                         l('[_1] ([_2])', copy.label, copy_org.name) | html;
354                                         LAST;
355                                     END;
356                                 END;
357                             END;
358                         %]
359                     </td>
360                     <td class="list_entry">
361                           [% attrs.pubdate | html %]
362                     </td>
363                     <td class="list_entry">
364                           [% attrs.format_label | html %]
365                     </td>
366                     [% IF CGI.param("edit_notes") == bbag.id %]
367                     <td class="list_entry">
368                         [% FOR note IN item.notes %]
369                         <input type="text" name="note-[% note.id %]" value="[% note.note | html %]" />
370                         [% END %]
371                         <input type="text" name="item-[% item.id %]" />
372                     </td>
373                     [% ELSE %]
374                     <td class="list_entry">
375                         [% FOR note IN item.notes %]
376                         <div>[% note.note | html %]</div>
377                         [% END %]
378                     </td>
379                     [% END %]
380                 </tr>
381                 [% END %]
382                 [% IF CGI.param("edit_notes") == bbag.id %]
383                 <tr>
384                     <td colspan="3"><!-- All space left of notes column --></td>
385                     <td class="save-notes">
386                         [%- INCLUDE "opac/parts/preserve_params.tt2"; %]
387                         <input type="hidden" name="bbid" value="[% CGI.param('bbid') | html %]" />
388                         <input type="submit" name="save_notes" value="[% l('Save Notes') %]" />
389                     </td>
390                 </tr>
391                 [% END %]
392             </tbody>
393         </table>
394
395         [% IF ctx.bb_page_count > 1; %]
396             <div class="header_middle" style="padding-top:7px;">
397                 <span class="float-left" style="padding-left:34px;">[% l('Navigate Selected List ') %]</span>
398                 <span class='float-left' style='padding-left: 10px;'>
399                     [%- IF item_page > 1 -%]
400                         <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
401                             item_page => item_page - 1
402                         }) %]'><span class="nav_arrow_fix">&#9668;</span>[% l('Previous') %]</a>
403                     [%- END; -%]
404
405                     [%- IF (item_page - 3) >= 1 -%]
406                         <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
407                             item_page => item_page - 3
408                         }) %]'>[% item_page - 3 %]</a>
409                     [%- END; -%]
410                     [%- IF (item_page - 2) >= 1 -%]
411                         <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
412                             item_page => item_page - 2
413                         }) %]'>[% item_page - 2 %]</a>
414                     [%- END; -%]
415                     [%- IF (item_page - 1) >= 1 -%]
416                         <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
417                             item_page => item_page - 1
418                         }) %]'>[% item_page - 1%]</a>
419                     [%- END; -%]
420                     <span class="bookbag-paginator-selected" >[% item_page %]</span>
421                     [%- IF (item_page + 1) <= ctx.bb_page_count -%]
422                         <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
423                             item_page => item_page + 1
424                         }) %]'>[% item_page + 1 %]</a>
425                     [%- END; -%]
426                     [%- IF (item_page + 2) <= ctx.bb_page_count -%]
427                         <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
428                             item_page => item_page + 2
429                         }) %]'>[% item_page + 2 %]</a>
430                     [%- END; -%]
431                     [%- IF (item_page + 3) <= ctx.bb_page_count -%]
432                         <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
433                             item_page => item_page + 3
434                         }) %]'>[% item_page + 3 %]</a>
435                     [%- END; -%]
436
437                     [%- IF (item_page + 1) <= ctx.bb_page_count; -%]
438                         <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
439                             item_page => item_page + 1
440                         }) %]'>[% l('Next') %]<span class="nav_arrow_fix">&#9658;</span></a>
441                     [%- END; -%]
442                  </span>
443             </div>
444             <div class="clear-both"></div>
445         [% END %]
446         <br/>
447
448         </form>
449         [% END %]
450         [% END %]
451     </div>
452     [% END %]
453
454     <span id='bb_publish_text' class='hide_me'>
455 [% l("Sharing a Bookbag means that the contents " _
456 "of the Bookbag will be visible to others. " _
457 "To see the public view of a shared Bookbag, " _
458 "click on the Bookbag's name in the Bookbag list.") %]
459     </span>
460 </div>
461 [% END %]