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