View | Details | Raw Unified | Return to bug 7422
Collapse All | Expand All

(-)a/acqui/supplier.pl (+13 lines)
Lines 121-126 if ( $op eq 'display' ) { Link Here
121
    print $query->redirect('/cgi-bin/koha/acqui/acqui-home.pl');
121
    print $query->redirect('/cgi-bin/koha/acqui/acqui-home.pl');
122
    exit;
122
    exit;
123
} else {
123
} else {
124
    my $dbh = C4::Context->dbh;
125
    # get the list of existing vendors to ensure (client-side with JS)
126
    # that we won't create a duplicate
127
    my $sth = $dbh->prepare( "SELECT DISTINCT name FROM aqbooksellers");
128
    $sth->execute();
129
    my $name;
130
    my $loop_names;
131
    while ($name = $sth->fetchrow_array) {  # retrieve one row
132
        $name =~ s/"/'/g;
133
        push @{$loop_names}, $name;
134
    }
135
124
    my @currencies = GetCurrencies();
136
    my @currencies = GetCurrencies();
125
    my $loop_currency;
137
    my $loop_currency;
126
    my $active_currency = GetCurrency();
138
    my $active_currency = GetCurrency();
Lines 174-179 if ( $op eq 'display' ) { Link Here
174
        loop_currency => $loop_currency,
186
        loop_currency => $loop_currency,
175
        GST           => $tax_rate,
187
        GST           => $tax_rate,
176
        enter         => 1,
188
        enter         => 1,
189
        loop_names    => $loop_names,
177
        default_gst_rate => $default_gst_rate,
190
        default_gst_rate => $default_gst_rate,
178
    );
191
    );
179
}
192
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt (-6 / +36 lines)
Lines 9-20 function confirm_deletion() { Link Here
9
    }
9
    }
10
}
10
}
11
function check(f) {
11
function check(f) {
12
if (f.company.value == "") {
12
    // invalid characters
13
    alert(_("You must specify a name for this vendor."));
13
    var patt=/"/g;
14
    return false;
14
15
}
15
    // array containing names of existing vendors (to avoid duplicates)
16
    f.submit();
16
    var nameloop = new Array();
17
    [% FOREACH existingname IN loop_names %]nameloop[[% loop.count %]] = "[% existingname %]";
18
    [% END %]
19
20
    var companyName = f.company.value;
21
    companyName = companyName.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
22
23
    if (companyName == "") {
24
        alert(_("You must specify a name for this vendor."));
25
        return false;
26
    }
27
    else if (patt.test(companyName) ) {
28
        alert(_("The vendor name contains invalid characters."));
29
        return false;
30
    }
31
    else {
32
        var i;
33
        var duplicateFound = 0;
34
        for (i=1;i<=nameloop.length-1;i++) {
35
            if (companyName.toLowerCase() == nameloop[i].toString().toLowerCase()) {
36
                duplicateFound = 1;
37
            }
38
        }
39
        if (duplicateFound) {
40
            alert(_("A vendor with this name already exists."));
41
            return false;
42
        }
43
        else {
44
            f.submit();
45
        }
46
    }
17
}
47
}
48
18
//]]>
49
//]]>
19
</script>
50
</script>
20
</head>
51
</head>
21
- 

Return to bug 7422