Bug 13459: Fix datatables paging for patron lists
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / patron_lists / list.tt
1 [% USE KohaDates %]
2 [% INCLUDE 'doc-head-open.inc' %]
3 <title>Koha &rsaquo; Tools &rsaquo; Patron lists &rsaquo; [% list.name %] &rsaquo; Add patrons</title>
4 [% INCLUDE 'doc-head-close.inc' %]
5
6 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
7 [% INCLUDE 'datatables.inc' %]
8
9 <script type="text/javascript">
10 //<![CDATA[
11 $(document).ready(function() {
12     $('#patrons_to_add_fieldset').hide();
13
14         $('#patron-list-table').dataTable($.extend(true, {}, dataTablesDefaults, {
15             "aoColumns": [
16                 null,null,null,null,null,null,null,{ "sType": "title-string" },null
17             ],
18             "aoColumnDefs": [
19                 { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
20             ],
21             "sPaginationType": "four_button"
22         } ));
23
24     $( "#find_patron" ).autocomplete({
25         source: "/cgi-bin/koha/circ/ysearch.pl",
26         minLength: 3,
27         select: function( event, ui ) {
28             AddPatron( ui.item.firstname + " " + ui.item.surname, ui.item.cardnumber );
29             return false;
30         }
31     })
32     .data( "ui-autocomplete" )._renderItem = function( ul, item ) {
33         return $( "<li></li>" )
34         .data( "ui-autocomplete-item", item )
35         .append( "<a>" + item.surname + ", " + item.firstname + " (" + item.cardnumber + ") <small>" + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "</small></a>" )
36         .appendTo( ul );
37     };
38
39     $("body").on("click",".removePatron",function(e){
40         e.preventDefault();
41         var divid = $(this).parent().attr("id");
42         var cardnumber = divid.replace("borrower_","");
43         RemovePatron(cardnumber);
44     });
45
46     var checkBoxes = $("input[type='checkbox']","#patron-list-table");
47
48     $("#CheckAll").click(function(e){
49         e.preventDefault();
50         checkBoxes.each(function(){
51             $(this).prop("checked",1);
52         });
53     });
54     $("#CheckNone").click(function(e){
55         e.preventDefault();
56         checkBoxes.each(function(){
57             $(this).prop("checked",0);
58         });
59     });
60
61     $("#remove_patrons").submit(function(){
62         var checkedItems = $("input:checked");
63         if ($(checkedItems).size() == 0) {
64             alert(_("You must select one or more patrons to remove"));
65             return false;
66         }
67         $(checkedItems).parents('tr').addClass("warn");
68         if( confirm(_("Are you sure you want to remove the selected patrons?")) ) {
69             return true;
70         } else {
71             $(checkedItems).parents('tr').removeClass("warn");
72             return false;
73         }
74     });
75 });
76
77 function AddPatron( name, cardnumber ) {
78     div = "<div id='borrower_" + cardnumber + "'>" + name + " ( <a href='#' class='removePatron'> " + _("Remove") + " </a> ) <input type='hidden' name='patrons_to_add' value='" + cardnumber + "' /></div>";
79     $('#patrons_to_add').append( div );
80
81     $('#find_patron').val('').focus();
82
83     $('#patrons_to_add_fieldset').show( 800 );
84 }
85
86 function RemovePatron( cardnumber ) {
87     $( '#borrower_' + cardnumber ).remove();
88
89     if ( ! $('#patrons_to_add').html() ) {
90         $('#patrons_to_add_fieldset').hide( 800 );
91     }
92 }
93 //]]>
94 </script>
95
96 </head>
97
98 <body>
99 [% INCLUDE 'header.inc' %]
100 [% INCLUDE 'cat-search.inc' %]
101 <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 %]</a> &rsaquo; Add patrons</div>
102
103 <div class="yui-t7">
104     <div class="yui-main">
105         <h1>[% list.name %]</h1>
106
107         <form action="list.pl" id="add_patrons" method="post">
108             <fieldset>
109                 <legend>Add patrons</legend>
110
111                     <label for="find_patron">Patron search: </label>
112                     <input autocomplete="off" id="find_patron" type="text" style="width:150px" class="noEnterSubmit" />
113                     <div id="find_patron_container"></div>
114
115                 <fieldset id="patrons_to_add_fieldset">
116                     <legend>Patrons to be added</legend>
117                     <div id="patrons_to_add"></div>
118
119                     <fieldset class="action">
120                         <input type="hidden" name="patron_list_id" value="[% list.patron_list_id %]" />
121                         <input type="submit" value="Add patrons" />
122                         <a href="lists.pl" class="cancel">Cancel</a>
123                     </fieldset>
124                 </fieldset>
125
126             </fieldset>
127         </form>
128
129         <form action="list.pl" id="remove_patrons" method="post">
130
131             <div id="searchheader">
132                 <span class="checkall"><a id="CheckAll" href="#">Select all</a></span> |
133                 <span class="clearall"><a id="CheckNone" href="#">Clear all</a></span> |
134                 <div class="btn-group">
135                     <button class="btn btn-mini list-remove" type="submit"><i class="icon-remove-sign"></i> Remove selected</button>
136                 </div>
137             </div>
138
139             <table id="patron-list-table">
140                 <thead>
141                     <tr>
142                         <th>&nbsp;</th>
143                         <th>Card</th>
144                         <th>Firstname</th>
145                         <th>Surname</th>
146                         <th>Address</th>
147                         <th>Category</th>
148                         <th>Library</th>
149                         <th>Expires on</th>
150                         <th>Circ notes</th>
151                     </tr>
152                 </thead>
153
154                 <tbody>
155                     [% FOREACH p IN list.patron_list_patrons %]
156                         <tr>
157                             <td><input type="checkbox" name="patrons_to_remove" value="[% p.patron_list_patron_id %]" /></td>
158                             <td>
159                                 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% p.borrowernumber.borrowernumber %]">
160                                     [% p.borrowernumber.cardnumber %]
161                                 </a>
162                             </td>
163                             <td>[% p.borrowernumber.firstname %]</td>
164                             <td>[% p.borrowernumber.surname %]</td>
165                             <td>
166                                 [% p.borrowernumber.address %]
167                                 [% p.borrowernumber.address2 %]
168                                 [% p.borrowernumber.city %]
169                                 [% p.borrowernumber.state %]
170                                 [% p.borrowernumber.country %]
171                             </td>
172                             <td>[% p.borrowernumber.categorycode.description %] ([% p.borrowernumber.categorycode.categorycode %])</td>
173                             <td>[% p.borrowernumber.branchcode.branchname %]</td>
174                             <td><span title="[% p.borrowernumber.dateexpiry %]">[% p.borrowernumber.dateexpiry | $KohaDates %]</span></td>
175                             <td>[% p.borrowernumber.borrowernotes %]</td>
176                         </tr>
177                     [% END %]
178                 </tbody>
179             </table>
180
181             <input type="hidden" name="patron_list_id" value="[% list.patron_list_id %]" />
182             <input type="submit" value="Remove selected patrons" />
183         </form>
184     </div>
185 </div>
186 [% INCLUDE 'intranet-bottom.inc' %]