|
1 | 1 | [% USE raw %]
|
2 | 2 | [% USE KohaDates %]
|
3 | 3 | [% SET footerjs = 1 %]
|
| 4 | +[% PROCESS 'i18n.inc' %] |
| 5 | +[% PROCESS 'patron-search.inc' %] |
4 | 6 | [% INCLUDE 'doc-head-open.inc' %]
|
5 | 7 | <title>[% IF ( op ) %]Create routing list[% ELSE %]Edit routing list[% END %] › [% title | html %] › Serials › Koha</title>
|
6 | 8 | [% INCLUDE 'doc-head-close.inc' %]
|
|
88 | 90 | [% END %]
|
89 | 91 | </table>
|
90 | 92 | [% END %]
|
| 93 | + <input type="hidden" id="new_recipients" name="new_recipients" value=""> |
91 | 94 |
|
92 | 95 | <p style="margin-left:10em;">
|
93 |
| - <a href="#" id="add_recipients"><i class="fa fa-plus"></i> Add recipients</a> |
| 96 | + <a href="#patron_search_modal" id="add_recipients" data-toggle="modal"><i class="fa fa-plus"></i> Add recipients</a> |
94 | 97 | [% IF memberloop %]
|
95 | 98 | <a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscriptionid | uri %]&op=delete"><i class="fa fa-trash-can"></i> Delete all</a>
|
96 | 99 | [% END %]
|
|
116 | 119 | [% MACRO jsinclude BLOCK %]
|
117 | 120 | <script>
|
118 | 121 | $(document).ready(function(){
|
119 |
| - $("#add_recipients").on("click",function(e){ |
120 |
| - e.preventDefault(); |
121 |
| - userPopup(); |
122 |
| - }); |
123 | 122 | $(".itemrank").on("change",function(){
|
124 | 123 | var subscriptionid = $(this).data("subscriptionid");
|
125 | 124 | var routingid = $(this).data("routingid");
|
|
131 | 130 | window.location.href=mylocation;
|
132 | 131 | }
|
133 | 132 |
|
134 |
| - function userPopup() { |
135 |
| - window.open("/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,action&selection_type=add", |
136 |
| - 'PatronPopup', |
137 |
| - 'width=1024,height=768,scrollbars=yes,toolbar=no,' |
138 |
| - + 'scrollbars=yes,resize=yes' |
139 |
| - ); |
| 133 | + function add_user(borrowernumber) { |
| 134 | + let users = $("#new_recipients").val().split(':'); |
| 135 | + if ( !users.includes(borrowernumber) ) { |
| 136 | + users.push(borrowernumber); |
| 137 | + } |
| 138 | + users = [...new Set(users)]; // unique |
| 139 | + $("#new_recipients").val(users.filter(Number).join(':')); // remove empty and join |
140 | 140 | }
|
141 | 141 |
|
142 |
| - function add_user(borrowernumber) { |
143 |
| - var myurl = "/cgi-bin/koha/serials/routing.pl?subscriptionid="+[% subscriptionid | html %]+"&borrowernumber="+borrowernumber+"&op=add"; |
144 |
| - window.location.href = myurl; |
| 142 | + </script> |
| 143 | + |
| 144 | + [% INCLUDE 'select2.inc' %] |
| 145 | + [% SET columns = ['cardnumber','name','category','branch','action'] %] |
| 146 | + [% PROCESS patron_search_modal columns => columns, modal_title => t("Add recipients") %] |
| 147 | + [% PROCESS patron_search_js columns => columns, actions => ["add"], preview_on_name_click => 1 %] |
| 148 | + |
| 149 | + <script> |
| 150 | + $(document).on( |
| 151 | + "hidden.bs.modal", |
| 152 | + "#patron_search_modal", |
| 153 | + add_new_recipients); |
| 154 | + |
| 155 | + function add_new_recipients(e){ |
| 156 | + e.preventDefault(); |
| 157 | + let borrowernumbers = $("#new_recipients").val(); |
| 158 | + if(!borrowernumbers.length > 0) { |
| 159 | + return; |
| 160 | + } |
| 161 | + $.ajax({ |
| 162 | + data: { |
| 163 | + subscriptionid: [% subscriptionid | html %], |
| 164 | + borrowernumbers, |
| 165 | + op: 'add_new_recipients' |
| 166 | + }, |
| 167 | + type: 'POST', |
| 168 | + url: '/cgi-bin/koha/serials/routing.pl', |
| 169 | + success: function (data) { |
| 170 | + document.location.href = '/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscriptionid | uri %]'; |
| 171 | + return false; |
| 172 | + }, |
| 173 | + error: function (data) { |
| 174 | + alert(data); |
| 175 | + }, |
| 176 | + }); |
145 | 177 | }
|
146 | 178 | </script>
|
147 | 179 | [% END %]
|
|
0 commit comments