Bug 11636 - make it possible to remove patrons from patron list during add process
[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; New list</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
16     $( "#find_patron" ).autocomplete({
17         source: "/cgi-bin/koha/circ/ysearch.pl",
18         minLength: 3,
19         select: function( event, ui ) {
20             AddPatron( ui.item.firstname + " " + ui.item.surname, ui.item.cardnumber );
21             return false;
22         }
23     })
24     .data( "autocomplete" )._renderItem = function( ul, item ) {
25         return $( "<li></li>" )
26         .data( "item.autocomplete", item )
27         .append( "<a>" + item.surname + ", " + item.firstname + " (" + item.cardnumber + ") <small>" + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "</small></a>" )
28         .appendTo( ul );
29     };
30
31     $("body").on("click",".removePatron",function(e){
32         e.preventDefault();
33         var divid = $(this).parent().attr("id");
34         var cardnumber = divid.replace("borrower_","");
35         RemovePatron(cardnumber);
36     });
37 });
38
39 function AddPatron( name, cardnumber ) {
40     div = "<div id='borrower_" + cardnumber + "'>" + name + " ( <a href='#' class='removePatron'> " + _("Remove") + " </a> ) <input type='hidden' name='patrons_to_add' value='" + cardnumber + "' /></div>";
41     $('#patrons_to_add').append( div );
42
43     $('#find_patron').val('').focus();
44
45     $('#patrons_to_add_fieldset').show( 800 );
46 }
47
48 function RemovePatron( cardnumber ) {
49     $( '#borrower_' + cardnumber ).remove();
50
51     if ( ! $('#patrons_to_add').html() ) {
52         $('#patrons_to_add_fieldset').hide( 800 );
53     }
54 }
55 //]]>
56 </script>
57
58 </head>
59
60 <body>
61 [% INCLUDE 'header.inc' %]
62 [% INCLUDE 'cat-search.inc' %]
63 <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; Add patrons</div>
64
65 <div class="yui-t7">
66     <div class="yui-main">
67         <h1>[% list.name %]</h1>
68
69         <form action="list.pl" method="post">
70             <fieldset>
71                 <legend>Add patrons</legend>
72
73                     <label for="find_patron">Patron search: </label>
74                     <input autocomplete="off" id="find_patron" type="text" style="width:150px" class="noEnterSubmit" />
75                     <div id="find_patron_container"></div>
76
77                 <fieldset id="patrons_to_add_fieldset">
78                     <legend>Patrons to be added</legend>
79                     <div id="patrons_to_add"></div>
80                 </fieldset>
81
82             </fieldset>
83
84             <p>
85                 <input type="submit" class="btn" value="Update" />
86                 <a href="lists.pl" class="cancel">Cancel</a>
87             </p>
88
89             <table id="patron-list-table">
90                 <thead>
91                     <tr>
92                         <th><i title="Remove patron from list" class="icon-trash"></i></th>
93                         <th>Card</th>
94                         <th>Firstname</th>
95                         <th>Surname</th>
96                         <th>Address</th>
97                         <th>Category</th>
98                         <th>Library</th>
99                         <th>Expires on</th>
100                         <th>Circ notes</th>
101                     </tr>
102                 </thead>
103
104                 <tbody>
105                     [% FOREACH p IN list.patron_list_patrons %]
106                         <tr>
107                             <td><input type="checkbox" name="patrons_to_remove" value="[% p.patron_list_patron_id %]" /></td>
108                             <td>
109                                 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% p.borrowernumber.borrowernumber %]">
110                                     [% p.borrowernumber.cardnumber %]
111                                 </a>
112                             </td>
113                             <td>[% p.borrowernumber.firstname %]</td>
114                             <td>[% p.borrowernumber.surname %]</td>
115                             <td>
116                                 [% p.borrowernumber.address %]
117                                 [% p.borrowernumber.address2 %]
118                                 [% p.borrowernumber.city %]
119                                 [% p.borrowernumber.state %]
120                                 [% p.borrowernumber.country %]
121                             </td>
122                             <td>[% p.borrowernumber.categorycode.description %] ([% p.borrowernumber.categorycode.categorycode %])</td>
123                             <td>[% p.borrowernumber.branchcode.branchname %]</td>
124                             <td>[% p.borrowernumber.dateexpiry | $KohaDates %]</td>
125                             <td>[% p.borrowernumber.borrowernotes %]</td>
126                         </tr>
127                     [% END %]
128                 </tbody>
129             </table>
130
131             <input type="hidden" name="patron_list_id" value="[% list.patron_list_id %]" />
132             <input type="submit" class="btn" value="Update" />
133             <a href="lists.pl" class="cancel">Cancel</a>
134         </form>
135     </div>
136 </div>
137 [% INCLUDE 'intranet-bottom.inc' %]