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