Bug 20110: Adding same user multiple times to same budget

In javascript, using indexOf to test if a number exists in an array
of strings doesn't work, and makes it possible to add the same user
multiple times into the same budget fund.
Make borrowernumber into string and compare that instead.

Test plan:

1) Go to Home -> Administration -> Budgets -> Funds -> Add Fund
2) Add a user to the fund
3) Try to add the same user again to the same fund. No error.
4) Apply patch
5) Do 1, 2, and 3 again. You should now get an error message
   saying the user is already in the list.

Signed-off-by: Pasi Kallinen <pasi.kallinen@joensuu.fi>

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Pasi Kallinen 2018-01-31 11:11:56 +02:00 committed by Jonathan Druart
parent 127da0e35c
commit 3c2cd21cc3
1 changed files with 1 additions and 1 deletions

View File

@ -487,7 +487,7 @@
function add_user(borrowernumber, borrowername) {
var ids = $("#budget_users_id").val().split(':');
if(borrowernumber && ids.indexOf(borrowernumber) == -1) {
if(borrowernumber && ids.indexOf(borrowernumber.toString()) == -1) {
var li = '<li id="user_' + borrowernumber + '">'
+ '<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber='
+ borrowernumber + '">' + borrowername + '</a> '