Bug 13618: Add html filters to all the variables
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / patron_lists / list.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE KohaDates %]
4 [% SET footerjs = 1 %]
5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>Koha &rsaquo; Tools &rsaquo; Patron lists &rsaquo; [% list.name | html %] &rsaquo; Add patrons</title>
7 [% INCLUDE 'doc-head-close.inc' %]
8
9 [% Asset.css("css/datatables.css") | $raw %]
10 <style type="text/css">
11     #add_patrons_by_search {
12         display: none;
13     }
14     #patron_barcodes_line {
15         display: none;
16     }
17     #patron_barcodes_submit {
18         display: none;
19     }
20     #searchheader {
21         margin-top: 1em;
22     }
23 </style>
24 </head>
25
26 <body id="patlist_list" class="pat patlist">
27 [% INCLUDE 'header.inc' %]
28 [% INCLUDE 'cat-search.inc' %]
29 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; <a href="lists.pl">Patron lists</a> &rsaquo; <a href="/cgi-bin/koha/patron_lists/list.pl?patron_list_id=[% list.id | html %]">[% list.name | html %]</a> &rsaquo; Add patrons</div>
30
31 <div id="doc3" class="yui-t2">
32    <div id="bd">
33     <div id="yui-main">
34         <div class="yui-b">
35         <h1>[% list.name | html %]</h1>
36
37         [% IF ( not_found.size > 0 ) %]
38         <div class="dialog alert"><p>Warning, the following cardnumbers were not found:</p></div>
39         <table style="margin:auto;">
40             <thead>
41                 <tr><th>Cardnumbers not found</th></tr>
42             </thead>
43             <tbody>
44             [% FOREACH nf IN not_found %]
45                 <tr><td>[% nf | html %]</td></td>
46             [% END %]
47             </tbody>
48         </table>
49         [% END %]
50
51         [% IF ( existed.size > 0 ) %]
52         <div class="dialog alert"><p>Warning, the following cardnumbers were already in this list:</p></div>
53         <table style="margin:auto;">
54             <thead>
55                 <tr><th>Cardnumbers already in list</th></tr>
56             </thead>
57             <tbody>
58             [% FOREACH ed IN existed %]
59                 <tr><td>[% ed | html %]</td></td>
60             [% END %]
61             </tbody>
62         </table>
63         [% END %]
64
65         <form action="list.pl" id="add_patrons" method="post" class="clearfix">
66             <fieldset class="rows">
67                 <legend>Add patrons</legend>
68                 <ol>
69                     <li id="patron_search_line">
70                         <label for="find_patron">Patron search: </label>
71                         <input autocomplete="off" id="find_patron" type="text" style="width:150px" class="noEnterSubmit" />
72                     </li>
73                     <li id="add_patrons_by_search"><a href="#">
74                         <span class="label">&nbsp;</span>
75                         <i class="fa fa-plus"></i> Search for patrons</a></li>
76                     <li id="add_patrons_by_barcode"><a href="#">
77                         <span class="label">&nbsp;</span>
78                         <i class="fa fa-plus"></i> Enter multiple card numbers</a></li>
79                     <li id="patron_barcodes_line">
80                         <label for="patrons_by_barcode">Card number list (one barcode per line):</label>
81                         <textarea id="patrons_by_barcode" name="patrons_by_barcode" id="" cols="30" rows="10"></textarea>
82                     </li>
83                 </ol>
84             </fieldset>
85             <fieldset id="patron_barcodes_submit" class="action">
86                 <input type="submit" value="Submit" />
87             </fieldset>
88
89             <div class="clearfix"></div>
90
91             <fieldset id="patrons_to_add_fieldset">
92                 <legend>Patrons to be added</legend>
93                 <div id="patrons_to_add"></div>
94
95                 <fieldset class="action">
96                     <input type="hidden" name="patron_list_id" value="[% list.patron_list_id | html %]" />
97                     <input type="submit" value="Add patrons" />
98                     <a href="lists.pl" class="cancel">Cancel</a>
99                 </fieldset>
100             </fieldset>
101         </form>
102
103         <form action="list.pl" id="remove_patrons" method="post">
104
105             <div id="searchheader">
106                 <span class="checkall"><a id="CheckAll" href="#"><i class="fa fa-check"></i> Select all</a></span> |
107                 <span class="clearall"><a id="CheckNone" href="#"><i class="fa fa-remove"></i> Clear all</a></span> |
108                 <div class="btn-group">
109                     <button class="btn btn-default btn-xs list-remove" type="submit"><i class="fa fa-trash"></i> Remove selected</button>
110                 </div>
111                 |
112                 <div class="btn-group">
113                     <button class="btn btn-default btn-xs merge-patrons"><i class="fa fa-compress"></i> Merge selected patrons</button>
114                 </div>
115             </div>
116
117             <table id="patron-list-table">
118                 <thead>
119                     <tr>
120                         <th>&nbsp;</th>
121                         <th>Card</th>
122                         <th>First name</th>
123                         <th>Surname</th>
124                         <th>Address</th>
125                         <th>Category</th>
126                         <th>Library</th>
127                         <th>Expires on</th>
128                         <th>Circ notes</th>
129                     </tr>
130                 </thead>
131
132                 <tbody>
133                     [% FOREACH p IN list.patron_list_patrons %]
134                         <tr>
135                             <td>
136                                 <input type="checkbox" name="patrons_to_remove" class="selection" value="[% p.patron_list_patron_id | html %]" />
137                                 <input type="hidden" id="borrowernumber_[% p.patron_list_patron_id | html %]" value="[% p.borrowernumber.id | html %]" />
138                             </td>
139                             <td>
140                                 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% p.borrowernumber.borrowernumber | html %]">
141                                     [% p.borrowernumber.cardnumber | html %]
142                                 </a>
143                             </td>
144                             <td>[% p.borrowernumber.firstname | html %]</td>
145                             <td>[% p.borrowernumber.surname | html %]</td>
146                             <td>
147                                 [% p.borrowernumber.address | html %]
148                                 [% p.borrowernumber.address2 | html %]
149                                 [% p.borrowernumber.city | html %]
150                                 [% p.borrowernumber.state | html %]
151                                 [% p.borrowernumber.country | html %]
152                             </td>
153                             <td>[% p.borrowernumber.categorycode.description | html %] ([% p.borrowernumber.categorycode.categorycode | html %])</td>
154                             <td>[% p.borrowernumber.branchcode.branchname | html %]</td>
155                             <td><span title="[% p.borrowernumber.dateexpiry | html %]">[% p.borrowernumber.dateexpiry | $KohaDates %]</span></td>
156                             <td>[% p.borrowernumber.borrowernotes | html %]</td>
157                         </tr>
158                     [% END %]
159                 </tbody>
160             </table>
161
162             <input type="hidden" name="patron_list_id" value="[% list.patron_list_id | html %]" />
163             <button type="submit" class="btn btn-default btn-sm list-remove"><i class="fa fa-trash" aria-hidden="true"></i> Remove selected patrons</button>
164             <button class="btn btn-default btn-sm merge-patrons" type="submit"><i class="fa fa-compress"></i> Merge selected patrons</button>
165         </form>
166
167             </div>
168         </div>
169         <div class="yui-b noprint">
170             [% INCLUDE 'tools-menu.inc' %]
171         </div>
172     </div>
173
174 [% MACRO jsinclude BLOCK %]
175     [% Asset.js("js/tools-menu.js") | $raw %]
176     [% INCLUDE 'datatables.inc' %]
177
178     [% Asset.js("js/autocomplete/patrons.js") | $raw %]
179     <script type="text/javascript">
180         var MSG_REMOVE_PATRON = _("Remove");
181         $(document).ready(function() {
182             $('#patrons_to_add_fieldset').hide();
183
184                 $('#patron-list-table').dataTable($.extend(true, {}, dataTablesDefaults, {
185                     "order": [[ 3, "asc" ]],
186                     "aoColumns": [
187                         null,null,null,null,null,null,null,{ "sType": "title-string" },null
188                     ],
189                     "aoColumnDefs": [
190                         { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
191                     ],
192                     "sPaginationType": "four_button"
193                 } ));
194
195             patron_autocomplete({
196                 patron_container: $("#patrons_to_add"),
197                 input_autocomplete: $("#find_patron"),
198                 patron_input_name: 'patrons_to_add'
199             });
200
201             var checkBoxes = $("input[type='checkbox']","#patron-list-table");
202
203             $("#CheckAll").click(function(e){
204                 e.preventDefault();
205                 checkBoxes.each(function(){
206                     $(this).prop("checked",1);
207                 });
208             });
209             $("#CheckNone").click(function(e){
210                 e.preventDefault();
211                 checkBoxes.each(function(){
212                     $(this).prop("checked",0);
213                 });
214             });
215
216             $("#remove_patrons").submit(function(){
217                 var checkedItems = $("input:checked");
218                 if ($(checkedItems).size() == 0) {
219                     alert(_("You must select one or more patrons to remove"));
220                     return false;
221                 }
222                 $(checkedItems).parents('tr').addClass("warn");
223                 if( confirm(_("Are you sure you want to remove the selected patrons?")) ) {
224                     return true;
225                 } else {
226                     $(checkedItems).parents('tr').removeClass("warn");
227                     return false;
228                 }
229             });
230
231             $("#add_patrons_by_barcode a").on("click", function(){
232                 $("#add_patrons_by_barcode, #patron_search_line").hide();
233                 $("#add_patrons_by_search, #patron_barcodes_line, #patron_barcodes_submit").show();
234             });
235
236             $("#add_patrons_by_search a").on("click", function(){
237                 $("#add_patrons_by_barcode, #patron_search_line").show();
238                 $("#add_patrons_by_search, #patron_barcodes_line, #patron_barcodes_submit").hide();
239             });
240
241             $('.merge-patrons').on('click', function() {
242                 var checkedItems = $("input:checked");
243                 if ($(checkedItems).length < 2) {
244                     alert(_("You must select one or more patrons to remove"));
245                     return false;
246                 }
247                 $(checkedItems).parents('tr').addClass("warn");
248                 if (confirm(_("Are you sure you want to remove the selected patrons?"))) {
249                     var merge_patrons_url = '/cgi-bin/koha/members/merge-patrons.pl?' +
250                         $('.selection:checked')
251                         .map(function() {
252                             return "id=" + $( '#borrowernumber_' + $(this).val() ).val()
253                         }).get().join('&');
254
255                     window.location.href = merge_patrons_url;
256                     return false;
257                 } else {
258                     $(checkedItems).parents('tr').removeClass("warn");
259                     return false;
260                 }
261             });
262         });
263     </script>
264 [% END %]
265
266 [% INCLUDE 'intranet-bottom.inc' %]