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