Bug 34913: DataTables upgrade: Update CSS and option names
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / patron_lists / list.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE KohaDates %]
4 [% USE TablesSettings %]
5 [% PROCESS 'i18n.inc' %]
6 [% SET footerjs = 1 %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 [% INCLUDE 'columns_settings.inc' %]
9 <title>[% FILTER collapse %]
10     [% list.name | html %] &rsaquo;
11     [% t("Patron lists") | html %] &rsaquo;
12     [% t("Tools") | html %] &rsaquo;
13     [% t("Koha") | html %]
14 [% END %]</title>
15 [% INCLUDE 'doc-head-close.inc' %]
16
17 <style>
18     #add_patrons_by_search {
19         display: none;
20     }
21     #patron_ids_line {
22         display: none;
23     }
24     #patron_ids_submit {
25         display: none;
26     }
27     #searchheader {
28         margin-top: 1em;
29     }
30 </style>
31 </head>
32
33 <body id="patlist_list" class="pat patlist">
34 [% WRAPPER 'header.inc'  %]
35     [% INCLUDE 'cat-search.inc' %]
36 [% END %]
37
38 [% WRAPPER 'sub-header.inc' %]
39     [% WRAPPER breadcrumbs %]
40         [% WRAPPER breadcrumb_item %]
41             <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
42         [% END %]
43         [% WRAPPER breadcrumb_item %]
44             <a href="lists.pl">Patron lists</a>
45         [% END %]
46         [% WRAPPER breadcrumb_item bc_active= 1 %]
47             [% list.name | html %]
48         [% END %]
49     [% END #/ WRAPPER breadcrumbs %]
50 [% END #/ WRAPPER sub-header.inc %]
51
52 <div class="main container-fluid">
53     <div class="row">
54         <div class="col-sm-10 col-sm-push-2">
55             <main>
56
57         <h1>[% list.name | html %]</h1>
58
59         [% IF ( not_found.size > 0 ) %]
60         [% IF id_column == 'borrowernumbers' %]
61             <div class="dialog alert"><p>Warning, the following borrowernumbers were not found:</p></div>
62         [% ELSE %]
63             <div class="dialog alert"><p>Warning, the following cardnumbers were not found:</p></div>
64         [% END %]
65         <table style="margin:auto;">
66             <thead>
67                 [% IF id_column == 'borrowernumbers' %]
68                     <tr><th>Borrowernumbers not found</th></tr>
69                 [% ELSE %]
70                     <tr><th>Cardnumbers not found</th></tr>
71                 [% END %]
72             </thead>
73             <tbody>
74             [% FOREACH nf IN not_found %]
75                 <tr><td>[% nf | html %]</td></td>
76             [% END %]
77             </tbody>
78         </table>
79         [% END %]
80
81         [% IF ( existed.size > 0 ) %]
82         [% IF id_column == 'borrowernumbers' %]
83             <div class="dialog alert"><p>Warning, the following borrowernumbers were already in this list:</p></div>
84         [% ELSE %]
85             <div class="dialog alert"><p>Warning, the following cardnumbers were already in this list:</p></div>
86         [% END %]
87         <table style="margin:auto;">
88             <thead>
89                 [% IF id_column == 'borrowernumbers' %]
90                     <tr><th>Borrowernumbers already in list</th></tr>
91                 [% ELSE %]
92                     <tr><th>Cardnumbers already in list</th></tr>
93                 [% END %]
94             </thead>
95             <tbody>
96             [% FOREACH ed IN existed %]
97                 <tr><td>[% ed | html %]</td></td>
98             [% END %]
99             </tbody>
100         </table>
101         [% END %]
102
103         <form action="list.pl" id="add_patrons" method="post" class="clearfix">
104             <fieldset class="rows">
105                 <legend>Add patrons</legend>
106                 <ol>
107                     <li id="patron_search_line">
108                         <label for="find_patron">Patron search: </label>
109                         <input autocomplete="off" id="find_patron" type="text" style="width:150px" class="noEnterSubmit" />
110                     </li>
111                     <li id="add_patrons_by_search"><a href="#">
112                         <span class="label">&nbsp;</span>
113                         <i class="fa fa-plus"></i> Search for patrons</a></li>
114                     <li id="add_patrons_by_id"><a href="#">
115                         <span class="label">&nbsp;</span>
116                         <i class="fa fa-plus"></i> Add multiple patrons</a></li>
117                     <span id="patron_ids_line">
118                         <li><strong>Choose type of IDs to enter:</strong></li>
119                         <li class="radio">
120                             <label class="id_choice" for="add_by_cardnumbers">
121                                 <input id="add_by_cardnumbers" type="radio" name="id_column" value="cardnumbers" checked="checked">
122                                 <span class="add_by_cardnumbers">Cardnumbers</span>
123                             </label>
124                             <label class="id_choice" for="add_by_borrowernumbers">
125                                 <input id="add_by_borrwernumbers" type="radio" name="id_column" value="borrowernumbers">
126                                 <span class="add_by_borrowernumbers">Borrowernumbers</span>
127                             </label>
128                         </li>
129                         <li>
130                             <label for="patrons_by_id">List (one ID per line):</label>
131                             <textarea id="patrons_by_id" name="patrons_by_id" id="" cols="30" rows="10"></textarea>
132                         </li>
133                     </span>
134                 </ol>
135             </fieldset>
136             <fieldset id="patron_ids_submit" class="action">
137                 <input type="submit" class="btn btn-primary" value="Submit" />
138             </fieldset>
139
140             <div class="clearfix"></div>
141
142             <fieldset id="patrons_to_add_fieldset">
143                 <legend>Patrons to be added</legend>
144                 <div id="patrons_to_add"></div>
145
146                 <fieldset class="action">
147                     <input type="hidden" name="patron_list_id" value="[% list.patron_list_id | html %]" />
148                     <input type="submit" class="btn btn-primary" value="Add patrons" />
149                     <a href="lists.pl" class="cancel">Cancel</a>
150                 </fieldset>
151             </fieldset>
152         </form>
153
154         <form action="list.pl" id="remove_patrons" method="post">
155
156             <div class="searchheader" id="searchheader">
157                 <span class="checkall"><a id="CheckAll" href="#"><i class="fa fa-check"></i> Select all</a></span> |
158                 <span class="clearall"><a id="CheckNone" href="#"><i class="fa fa-times"></i> Clear all</a></span> |
159                 <div class="btn-group">
160                     <button class="btn btn-default btn-xs list-remove" type="submit"><i class="fa fa-trash-can"></i> Remove selected</button>
161                 </div>
162                 |
163                 <div class="btn-group">
164                     <button class="btn btn-default btn-xs merge-patrons"><i class="fa fa-compress"></i> Merge selected patrons</button>
165                 </div>
166             </div>
167
168             <div class="page-section">
169                 <table id="patron-list-table">
170                     <thead>
171                         <tr>
172                             <th class="NoSort">&nbsp;</th>
173                             <th>Card</th>
174                             <th>First name</th>
175                             <th>Surname</th>
176                             <th>Address</th>
177                             <th>Category</th>
178                             <th>Library</th>
179                             <th>Expires on</th>
180                             <th>Circ notes</th>
181                         </tr>
182                     </thead>
183
184                     <tbody>
185                         [% FOREACH p IN list.patron_list_patrons %]
186                             <tr>
187                                 <td>
188                                     <input type="checkbox" name="patrons_to_remove" class="selection" value="[% p.patron_list_patron_id | html %]" />
189                                     <input type="hidden" id="borrowernumber_[% p.patron_list_patron_id | html %]" value="[% p.borrowernumber.id | html %]" />
190                                 </td>
191                                 <td>
192                                     <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% p.borrowernumber.borrowernumber | uri %]">
193                                         [% p.borrowernumber.cardnumber | html %]
194                                     </a>
195                                 </td>
196                                 <td>[% p.borrowernumber.firstname | html %]</td>
197                                 <td>[% p.borrowernumber.surname | html %]</td>
198                                 <td>
199                                     [% p.borrowernumber.address | html %]
200                                     [% p.borrowernumber.address2 | html %]
201                                     [% p.borrowernumber.city | html %]
202                                     [% p.borrowernumber.state | html %]
203                                     [% p.borrowernumber.country | html %]
204                                 </td>
205                                 <td>[% p.borrowernumber.categorycode.description | html %] ([% p.borrowernumber.categorycode.categorycode | html %])</td>
206                                 <td>[% p.borrowernumber.branchcode.branchname | html %]</td>
207                                 <td data-order="[% p.borrowernumber.dateexpiry | html %]">[% p.borrowernumber.dateexpiry | $KohaDates %]</td>
208                                 <td>[% p.borrowernumber.borrowernotes | $raw | html_line_break %]</td>
209                             </tr>
210                         [% END %]
211                     </tbody>
212                 </table>
213             </div> <!-- /.page-section -->
214
215             <fieldset class="action">
216                 <input type="hidden" name="patron_list_id" value="[% list.patron_list_id | html %]" />
217                 <button type="submit" class="btn btn-default btn-sm list-remove"><i class="fa fa-trash-can" aria-hidden="true"></i> Remove selected patrons</button>
218                 <button class="btn btn-default btn-sm merge-patrons" type="submit"><i class="fa fa-compress"></i> Merge selected patrons</button>
219             </fieldset>
220         </form>
221
222             </main>
223         </div> <!-- /.col-sm-10.col-sm-push-2 -->
224
225         <div class="col-sm-2 col-sm-pull-10">
226             <aside>
227                 [% INCLUDE 'tools-menu.inc' %]
228             </aside>
229         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
230      </div> <!-- /.row -->
231
232 [% MACRO jsinclude BLOCK %]
233     [% Asset.js("js/tools-menu.js") | $raw %]
234     [% INCLUDE 'datatables.inc' %]
235
236     <script>
237         var MSG_REMOVE_PATRON = _("Remove");
238         $(document).ready(function() {
239             $('#patrons_to_add_fieldset').hide();
240
241                 var table_settings = [% TablesSettings.GetTableSettings('members', 'patron-lists', 'patron-list-table', 'json') | $raw %]
242                 KohaTable('patron-list-table', {
243                     "pagingType": "full"
244                 }, table_settings);
245
246             function AddPatron( patron_name, value, container, input_name ) {
247                 div = "<div id='borrower_" + value + "'>" + patron_name + " ( <a href='#' class='removePatron'><i class='fa fa-trash-can' aria-hidden='true'></i> " + MSG_REMOVE_PATRON + " </a> ) <input type='hidden' name='" + input_name + "' value='" + value + "' /></div>";
248                 $(container).append( div );
249
250                 $(container).parent().show( 800 );
251             }
252             function RemovePatron( cardnumber, container ) {
253                 $( '#borrower_' + cardnumber ).remove();
254
255                 if ( ! $(container).html() ) {
256                     $(container).parent("fieldset").hide( 800 );
257                 }
258             }
259             patron_autocomplete($("#find_patron"), {
260                 'on-select-callback': function( event, ui ) {
261                     var field = ui.item.cardnumber;
262                     AddPatron( ( ui.item.firstname || "" ) + " " + ( ui.item.middle_name || "" ) + " " + ( ui.item.surname || "" ), field, $("#patrons_to_add"), 'patrons_to_add' );
263                     $("#find_patron").val('').focus();
264                     return false;
265                 }
266             });
267             $("body").on("click",".removePatron",function(e){
268                 e.preventDefault();
269                 var divid = $(this).parent().attr("id");
270                 var cardnumber = divid.replace("borrower_","");
271                 RemovePatron(cardnumber, $("#patrons_to_add"));
272             });
273
274             $("body").on("click", "#CheckAll", function(e){
275                 e.preventDefault();
276                 $("input[type='checkbox']","#patron-list-table").each(function(){
277                     $(this).prop("checked",1);
278                 });
279             });
280             $("body").on("click", "#CheckNone", function(e){
281                 e.preventDefault();
282                 $("input[type='checkbox']","#patron-list-table").each(function(){
283                     $(this).prop("checked",0);
284                 });
285             });
286
287             $("#remove_patrons").submit(function(){
288                 var checkedItems = $("input:checked");
289                 if ($(checkedItems).size() == 0) {
290                     alert(_("You must select one or more patrons to remove"));
291                     return false;
292                 }
293                 $(checkedItems).parents('tr').addClass("warn");
294                 if( confirm(_("Are you sure you want to remove the selected patrons?")) ) {
295                     return true;
296                 } else {
297                     $(checkedItems).parents('tr').removeClass("warn");
298                     return false;
299                 }
300             });
301
302             $("#add_patrons_by_id a").on("click", function(){
303                 $("#add_patrons_by_id, #patron_search_line").hide();
304                 $("#add_patrons_by_search, #patron_ids_line, #patron_ids_submit").show();
305             });
306
307             $("#add_patrons_by_search a").on("click", function(){
308                 $("#add_patrons_by_id, #patron_search_line").show();
309                 $("#add_patrons_by_search, #patron_ids_line, #patron_ids_submit").hide();
310             });
311
312             $('.merge-patrons').on('click', function() {
313                 var checkedItems = $("input:checked");
314                 if ($(checkedItems).length < 2) {
315                     alert(_("You must select two or more patrons to merge"));
316                     return false;
317                 }
318                 $(checkedItems).parents('tr').addClass("warn");
319                 if (confirm(_("Are you sure you want to merge the selected patrons?"))) {
320                     var merge_patrons_url = '/cgi-bin/koha/members/merge-patrons.pl?' +
321                         $('.selection:checked')
322                         .map(function() {
323                             return "id=" + $( '#borrowernumber_' + $(this).val() ).val()
324                         }).get().join('&');
325
326                     window.location.href = merge_patrons_url;
327                     return false;
328                 } else {
329                     $(checkedItems).parents('tr').removeClass("warn");
330                     return false;
331                 }
332             });
333         });
334     </script>
335 [% END %]
336
337 [% INCLUDE 'intranet-bottom.inc' %]