Bugzilla – Attachment 7105 Details for
Bug 7422
Prevent creation of vendors with the same name
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to ensure vendor names are unique and do not contain " or only spaces.
0001-Bug-7422-name-control-when-creating-a-new-vendor.patch (text/plain), 3.17 KB, created by
Duncan
on 2012-01-11 01:21:58 UTC
(
hide
)
Description:
Patch to ensure vendor names are unique and do not contain " or only spaces.
Filename:
MIME Type:
Creator:
Duncan
Created:
2012-01-11 01:21:58 UTC
Size:
3.17 KB
patch
obsolete
>From 1e187be50a5f673504bf3fe37cc126d7c35155cb Mon Sep 17 00:00:00 2001 >From: Adrien Saurat <adrien.saurat@biblibre.com> >Date: Tue, 10 Jan 2012 15:50:53 +0100 >Subject: [PATCH] Bug 7422: name control when creating a new vendor > >Ensures that : >- name is not a space only string >- name is unique >- name does not contain quotation marks > >Signed-off-by: Duncan Tyler <Duncan Tyler> >--- > acqui/supplier.pl | 13 ++++++ > .../prog/en/modules/acqui/supplier.tt | 41 +++++++++++++++++-- > 2 files changed, 49 insertions(+), 5 deletions(-) > >diff --git a/acqui/supplier.pl b/acqui/supplier.pl >index 3faa560..a71f0ff 100755 >--- a/acqui/supplier.pl >+++ b/acqui/supplier.pl >@@ -121,6 +121,18 @@ if ( $op eq 'display' ) { > print $query->redirect('/cgi-bin/koha/acqui/acqui-home.pl'); > exit; > } else { >+ my $dbh = C4::Context->dbh; >+ # get the list of existing vendors to ensure (client-side with JS) >+ # that we won't create a duplicate >+ my $sth = $dbh->prepare( "SELECT DISTINCT name FROM aqbooksellers"); >+ $sth->execute(); >+ my $name; >+ my $loop_names; >+ while ($name = $sth->fetchrow_array) { # retrieve one row >+ $name =~ s/"/'/g; >+ push @{$loop_names}, $name; >+ } >+ > my @currencies = GetCurrencies(); > my $loop_currency; > my $active_currency = GetCurrency(); >@@ -174,6 +186,7 @@ if ( $op eq 'display' ) { > loop_currency => $loop_currency, > GST => $tax_rate, > enter => 1, >+ loop_names => $loop_names, > default_gst_rate => $default_gst_rate, > ); > } >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt >index f30d839..6059b4c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt >@@ -9,12 +9,43 @@ function confirm_deletion() { > } > } > function check(f) { >-if (f.company.value == "") { >- alert(_("You must specify a name for this vendor.")); >- return false; >-} >- f.submit(); >+ // invalid characters >+ var patt=/"/g; >+ >+ // array containing names of existing vendors (to avoid duplicates) >+ var nameloop = new Array(); >+ [% FOREACH existingname IN loop_names %]nameloop[[% loop.count %]] = "[% existingname %]"; >+ [% END %] >+ >+ var companyName = f.company.value; >+ companyName = companyName.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); >+ >+ if (companyName == "") { >+ alert(_("You must specify a name for this vendor.")); >+ return false; >+ } >+ else if (patt.test(companyName) ) { >+ alert(_("The vendor name contains invalid characters.")); >+ return false; >+ } >+ else { >+ var i; >+ var duplicateFound = 0; >+ for (i=1;i<=nameloop.length-1;i++) { >+ if (companyName.toLowerCase() == nameloop[i].toString().toLowerCase()) { >+ duplicateFound = 1; >+ } >+ } >+ if (duplicateFound) { >+ alert(_("A vendor with this name already exists.")); >+ return false; >+ } >+ else { >+ f.submit(); >+ } >+ } > } >+ > //]]> > </script> > </head> >-- >1.7.5.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 7422
:
7104
|
7105
|
7213
|
7254
|
7255
|
7978