Bug 11787 - Use validation plugin when adding new vendor

The vendor entry form uses some custom JavaScript which can be removed
in favor of HTML5 validation attributes and Koha's built-in validation
plugin. This patch does so.

Also corrected: Minor validation issue.

To test, apply the patch and go to Acquisitions -> New vendor. Try
submitting the form without entering a vendor name. This should trigger
a validation warning.

Submission of the form with valid data should work correctly. Editing an
existing vendor should also work correctly.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 03675fd553)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Owen Leonard 2014-02-18 14:52:26 -05:00 committed by Fridolin Somers
parent fc50362c23
commit 17281f8a66
1 changed files with 7 additions and 14 deletions

View File

@ -12,13 +12,6 @@ function confirm_deletion() {
window.location="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]&op=delete";
}
}
function check(f) {
if (f.company.value == "") {
alert(_("You must specify a name for this vendor."));
return false;
}
f.submit();
}
$(document).ready(function() {
[% IF (dateformat == 'metric') %]
@ -60,13 +53,13 @@ if (f.company.value == "") {
[% END %]
[% UNLESS ( enter ) %][% INCLUDE 'acquisitions-toolbar.inc' %][% END %]
[% IF ( enter ) %]
<form action="updatesupplier.pl" name="updatesupplier" method="post">
<form action="updatesupplier.pl" name="updatesupplier" class="validated" method="post">
<div class="yui-g">
<input type="hidden" name="booksellerid" value="[% booksellerid %]" />
<fieldset class="rows">
<legend>Company details</legend>
<ol><li><label for="company" class="required">Name: * </label>
<input type="text" size="40" id="company" name="company" value="[% name %]" class="focus" /></li>
<ol><li><label for="company" class="required">Name:</label>
<input type="text" size="40" id="company" name="company" value="[% name %]" required="required" class="required" /><span class="required">Required</span></li>
<li><label for="company_postal">Postal address: </label>
<textarea id="company_postal" name="company_postal" cols="40" rows="3">[% postal %]</textarea></li>
<li><label for="physical">Physical address: </label>
@ -114,7 +107,7 @@ if (f.company.value == "") {
<li><label for="list_currency">List prices are: </label>
<select name="list_currency" id="list_currency">
[% FOREACH loop_currenc IN loop_currency %]
[% IF ( loop_currenc.listprice ) %]<option value="[% loop_currenc.currency %]" selected="1">[% loop_currenc.currency %]</option>
[% IF ( loop_currenc.listprice ) %]<option value="[% loop_currenc.currency %]" selected="selected">[% loop_currenc.currency %]</option>
[% ELSE %]<option value="[% loop_currenc.currency %]">[% loop_currenc.currency %]</option>[% END %]
[% END %]
</select>
@ -122,7 +115,7 @@ if (f.company.value == "") {
<li><label for="invoice_currency">Invoice prices are: </label>
<select name="invoice_currency" id="invoice_currency">
[% FOREACH loop_currenc IN loop_currency %]
[% IF ( loop_currenc.invoiceprice ) %]<option value="[% loop_currenc.currency %]" selected="1">[% loop_currenc.currency %]</option>
[% IF ( loop_currenc.invoiceprice ) %]<option value="[% loop_currenc.currency %]" selected="selected">[% loop_currenc.currency %]</option>
[% ELSE %]<option value="[% loop_currenc.currency %]">[% loop_currenc.currency %]</option>[% END %]
[% END %]
</select>
@ -159,7 +152,7 @@ if (f.company.value == "") {
[% IF gst_values %]
<ol>
<li>
<label for="gst">Tax rate: </label>
<label for="gstrate">Tax rate: </label>
<select name="gstrate" id="gstrate">
[% FOREACH gst IN gst_values %]
[% IF ( gstrate == gst.option ) %]
@ -184,7 +177,7 @@ if (f.company.value == "") {
<li><label for="notes">Notes: </label>
<textarea cols="40" rows="4" id="notes" name="notes" >[% notes %]</textarea></li></ol>
</fieldset>
<fieldset class="action"><input type="button" value="Save" onclick="check(this.form);" /> [% IF ( booksellerid ) %]
<fieldset class="action"><input type="submit" value="Save" /> [% IF ( booksellerid ) %]
<a class="cancel" href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% ELSE %]<a class="cancel" href="/cgi-bin/koha/acqui/acqui-home.pl">
[% END %]Cancel</a></fieldset>
</div>