Bugzilla – Attachment 21019 Details for
Bug 10402
Add multiple contacts for vendors
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10402: Use an object for contacts
Bug-10402-Use-an-object-for-contacts.patch (text/plain), 30.68 KB, created by
Jared Camins-Esakov
on 2013-09-12 13:31:36 UTC
(
hide
)
Description:
Bug 10402: Use an object for contacts
Filename:
MIME Type:
Creator:
Jared Camins-Esakov
Created:
2013-09-12 13:31:36 UTC
Size:
30.68 KB
patch
obsolete
>From 82600f600673fe75aa01670a7d56a6d3c1596f55 Mon Sep 17 00:00:00 2001 >From: Jared Camins-Esakov <jcamins@cpbibliography.com> >Date: Thu, 6 Jun 2013 22:38:19 -0400 >Subject: [PATCH] Bug 10402: Use an object for contacts > >In preparation for adding the ability to handle multiple contacts, this >patch moves booksellers' contacts into their own class, >C4::Bookseller::Contact. > >To test: >1) Apply patch. >2) Run database update. >3) Edit a bookseller, making sure to add a contact. >4) View the bookseller's information, making sure the contact > information is there. >5) Run the unit test: > > prove t/db_dependent/Bookseller.t > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com> >--- > C4/Bookseller.pm | 81 +++++---- > C4/Bookseller/Contact.pm | 177 ++++++++++++++++++++ > acqui/supplier.pl | 63 ++----- > acqui/uncertainprice.pl | 9 +- > acqui/updatesupplier.pl | 36 ++-- > .../intranet-tmpl/prog/en/css/staff-global.css | 4 + > .../prog/en/modules/acqui/supplier.tt | 78 +++++---- > .../prog/en/modules/acqui/uncertainprice.tt | 18 +- > t/db_dependent/Bookseller.t | 55 +++++- > 9 files changed, 371 insertions(+), 150 deletions(-) > create mode 100644 C4/Bookseller/Contact.pm > >diff --git a/C4/Bookseller.pm b/C4/Bookseller.pm >index f56f4e3..03b070c 100644 >--- a/C4/Bookseller.pm >+++ b/C4/Bookseller.pm >@@ -23,6 +23,8 @@ use warnings; > > use base qw( Exporter ); > >+use C4::Bookseller::Contact; >+ > # set the version for version checking > our $VERSION = 3.07.00.049; > our @EXPORT_OK = qw( >@@ -52,8 +54,8 @@ a bookseller. > > @results = GetBookSeller($searchstring); > >-Looks up a book seller. C<$searchstring> may be either a book seller >-ID, or a string to look for in the book seller's name. >+Looks up a book seller. C<$searchstring> is a string to look for in the >+book seller's name. > > C<@results> is an array of hash_refs whose keys are the fields of of the > aqbooksellers table in the Koha database. >@@ -90,6 +92,7 @@ sub GetBookSellerFromId { > ( $vendor->{subscriptioncount} ) = $dbh->selectrow_array( > 'SELECT count(*) FROM subscription WHERE aqbooksellerid = ?', > {}, $id ); >+ $vendor->{'contacts'} = C4::Bookseller::Contact->get_from_bookseller($id); > } > return $vendor; > } >@@ -170,40 +173,42 @@ Returns the ID of the newly-created bookseller. > =cut > > sub AddBookseller { >- my ($data) = @_; >+ my ($data, $contacts) = @_; > my $dbh = C4::Context->dbh; >- my $query = q| >+ my $query = q| > INSERT INTO aqbooksellers > ( >- name, address1, address2, address3, address4, >- postal, phone, accountnumber,fax, url, >- contact, contpos, contphone, contfax, contaltphone, >- contemail, contnotes, active, listprice, invoiceprice, >- gstreg, listincgst, invoiceincgst,gstrate, discount, >- notes, deliverytime >+ name, address1, address2, address3, address4, >+ postal, phone, accountnumber,fax, url, >+ active, listprice, invoiceprice, gstreg, >+ listincgst,invoiceincgst, gstrate, discount, notes, >+ deliverytime > ) >- VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) | >+ VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) | > ; > my $sth = $dbh->prepare($query); > $sth->execute( >- $data->{name} ,$data->{address1}, >- $data->{address2} ,$data->{address3}, >- $data->{address4} ,$data->{postal}, >- $data->{phone} ,$data->{accountnumber}, >- $data->{fax}, >- $data->{url} ,$data->{contact}, >- $data->{contpos} ,$data->{contphone}, >- $data->{contfax} ,$data->{contaltphone}, >- $data->{contemail} ,$data->{contnotes}, >- $data->{active} ,$data->{listprice}, >- $data->{invoiceprice} ,$data->{gstreg}, >- $data->{listincgst} ,$data->{invoiceincgst}, >- $data->{gstrate} ,$data->{discount}, >- $data->{notes} ,$data->{deliverytime}, >+ $data->{'name'}, $data->{'address1'}, >+ $data->{'address2'}, $data->{'address3'}, >+ $data->{'address4'}, $data->{'postal'}, >+ $data->{'phone'}, $data->{'accountnumber'}, >+ $data->{'fax'}, $data->{'url'}, >+ $data->{'active'}, $data->{'listprice'}, >+ $data->{'invoiceprice'}, $data->{'gstreg'}, >+ $data->{'listincgst'}, $data->{'invoiceincgst'}, >+ $data->{'gstrate'}, $data->{'discount'}, >+ $data->{notes}, $data->{deliverytime}, > ); > > # return the id of this new supplier >- return $dbh->{'mysql_insertid'}; >+ my $id = $dbh->{'mysql_insertid'}; >+ if ($id && $contacts) { >+ $contacts->[0] = C4::Bookseller::Contact->new( $contacts->[0] ) >+ unless ref $contacts->[0] eq 'C4::Bookseller::Contact'; >+ $contacts->[0]->bookseller($id); >+ $contacts->[0]->save(); >+ } >+ return $id; > } > > #-----------------------------------------------------------------# >@@ -224,14 +229,13 @@ C<&ModBookseller> with the result. > =cut > > sub ModBookseller { >- my ($data) = @_; >+ my ($data, $contacts) = @_; > my $dbh = C4::Context->dbh; > return unless $data->{'id'}; > my $query = 'UPDATE aqbooksellers > SET name=?,address1=?,address2=?,address3=?,address4=?, >- postal=?,phone=?,accountnumber=?,fax=?,url=?,contact=?,contpos=?, >- contphone=?,contfax=?,contaltphone=?,contemail=?, >- contnotes=?,active=?,listprice=?, invoiceprice=?, >+ postal=?,phone=?,accountnumber=?,fax=?,url=?, >+ active=?,listprice=?, invoiceprice=?, > gstreg=?,listincgst=?,invoiceincgst=?, > discount=?,notes=?,gstrate=?,deliverytime=? > WHERE id=?'; >@@ -241,19 +245,22 @@ sub ModBookseller { > $data->{'address2'}, $data->{'address3'}, > $data->{'address4'}, $data->{'postal'}, > $data->{'phone'}, $data->{'accountnumber'}, >- $data->{'fax'}, >- $data->{'url'}, $data->{'contact'}, >- $data->{'contpos'}, $data->{'contphone'}, >- $data->{'contfax'}, $data->{'contaltphone'}, >- $data->{'contemail'}, $data->{'contnotes'}, >+ $data->{'fax'}, $data->{'url'}, > $data->{'active'}, $data->{'listprice'}, > $data->{'invoiceprice'}, $data->{'gstreg'}, > $data->{'listincgst'}, $data->{'invoiceincgst'}, > $data->{'discount'}, $data->{'notes'}, >- $data->{'gstrate'}, >- $data->{deliverytime}, >+ $data->{'gstrate'}, $data->{deliverytime}, > $data->{'id'} > ); >+ $contacts ||= $data->{'contacts'}; >+ if ($contacts) { >+ $contacts->[0] = C4::Bookseller::Contact->new( $contacts->[0] ) >+ unless ref $contacts->[0] eq 'C4::Bookseller::Contact'; >+ $contacts->[0]->bookseller($data->{'id'}); >+ $contacts->[0]->save(); >+ } >+ return; > } > > =head2 DelBookseller >diff --git a/C4/Bookseller/Contact.pm b/C4/Bookseller/Contact.pm >new file mode 100644 >index 0000000..e08d66d >--- /dev/null >+++ b/C4/Bookseller/Contact.pm >@@ -0,0 +1,177 @@ >+package C4::Bookseller::Contact; >+ >+# Copyright 2013 C & P Bibliography Services >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+=head1 NAME >+ >+C4::Bookseller::Contact - object class for contacts associated with vendors >+ >+=head1 SYNPOSIS >+ >+This class provides an object-oriented interface for handling vendor contacts. >+It uses Class::Accessor to provide access to the following fields: >+ >+=head1 FIELDS >+ >+=over 8 >+ >+=item id >+ >+ID of the contact. This is not used initially, since contacts are actually >+stored in the aqbooksellers table. >+ >+=item name >+ >+Contact name. >+ >+=item position >+ >+Contact's position. >+ >+=item phone >+ >+Contact's primary phone number. >+ >+=item altphone >+ >+Contact's alternate phone number. >+ >+=item fax >+ >+Contact's fax number. >+ >+=item email >+ >+Contact's e-mail address. >+ >+=item notes >+ >+Notes about contact. >+ >+=item primary >+ >+Flag to indicate whether a contact is "primary" or not. Initially unused since >+each bookseller can have only one contact. >+ >+=item bookseller >+ >+ID of the bookseller the contact is associated with. >+ >+=back >+ >+=cut >+ >+use Modern::Perl; >+use C4::Context; >+ >+use base qw(Class::Accessor); >+ >+__PACKAGE__->mk_accessors(qw(id name position phone altphone fax email notes primary bookseller)); >+ >+=head1 METHODS >+ >+=head2 get_from_bookseller >+ >+ my @contacts = @{C4::Bookseller::Contact->get_from_bookseller($booksellerid)}; >+ >+Returns a reference to an array of C4::Bookseller::Contact objects for the >+specified bookseller. >+ >+=cut >+ >+sub get_from_bookseller { >+ my ($class, $bookseller) = @_; >+ >+ return unless $bookseller; >+ >+ my @contacts; >+ my $query = "SELECT contact AS name, contpos AS position, contphone AS phone, contaltphone AS altphone, contfax AS fax, contemail AS email, contnotes AS notes, id AS bookseller FROM aqbooksellers WHERE id = ?"; >+ # When we have our own table, we can use: my $query = "SELECT * FROM aqcontacts WHERE bookseller = ?"; >+ my $dbh = C4::Context->dbh; >+ my $sth = $dbh->prepare($query); >+ $sth->execute($bookseller); >+ while (my $rec = $sth->fetchrow_hashref()) { >+ $rec->{'primary'} = 1; >+ push @contacts, $class->new($rec); >+ } >+ >+ return \@contacts; >+} >+ >+ >+=head2 fetch >+ >+ my $contact = C4::Bookseller::Contact->fetch($contactid); >+ >+Retrieves the specified contact from the database. Currently commented out >+because there is no separate table from which contacts can be fetched. >+ >+=cut >+ >+#sub fetch { >+# my ($class, $id) = @_; >+# >+# my $rec = { }; >+# if ($id) { >+# my $query = "SELECT * FROM aqcontacts WHERE id = ?"; >+# my $dbh = C4::Context->dbh; >+# my $sth = $dbh->prepare($query); >+# $sth->execute($id); >+# $rec = $sth->fetchrow_hashref(); >+# } >+# my $self = $class->SUPER::new($rec); >+# bless $self, $class; >+# return $self; >+#} >+ >+=head2 save >+ >+ $contact->save(); >+ >+Save a contact to the database. >+ >+=cut >+ >+sub save { >+ my ($self) = @_; >+ >+ my $query; >+# if ($self->id) { >+# $query = 'UPDATE aqcontacts SET name = ?, position = ?, phone = ?, altphone = ?, fax = ?, email = ?, notes = ?, primary = ? WHERE id = ?;'; >+# } else { >+# $query = 'INSERT INTO aqcontacts (name, position, phone, altphone, fax, email, notes, primary) VALUES (?, ?, ?, ?, ? ,? ,?, ?);'; >+# } >+ if ($self->bookseller) { >+ $query = 'UPDATE aqbooksellers SET contact = ?, contpos = ?, contphone = ?, contaltphone = ?, contfax = ?, contemail = ?, contnotes = ? WHERE id = ?;'; >+ } else { >+ return; >+ } >+ my $dbh = C4::Context->dbh; >+ my $sth = $dbh->prepare($query); >+ $sth->execute($self->name, $self->position, $self->phone, $self->altphone, $self->fax, $self->email, $self->notes, $self->bookseller); >+ #$self->id = $dbh->last_insert_id(undef, undef, 'aqcontacts', undef); >+ return $self->bookseller; >+} >+ >+=head1 AUTHOR >+ >+Jared Camins-Esakov <jcamins@cpbibliography.com> >+ >+=cut >+ >+1; >diff --git a/acqui/supplier.pl b/acqui/supplier.pl >index df417c0..c480c2a 100755 >--- a/acqui/supplier.pl >+++ b/acqui/supplier.pl >@@ -49,14 +49,10 @@ use C4::Output; > use CGI; > > use C4::Bookseller qw( GetBookSellerFromId DelBookseller ); >+use C4::Bookseller::Contact; > use C4::Budgets; > > my $query = CGI->new; >-my $booksellerid = $query->param('booksellerid'); >-my $supplier = {}; >-if ($booksellerid) { >- $supplier = GetBookSellerFromId($booksellerid); >-} > my $op = $query->param('op') || 'display'; > my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > { template_name => 'acqui/supplier.tmpl', >@@ -67,6 +63,15 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > debug => 1, > } > ); >+my $booksellerid = $query->param('booksellerid'); >+my $supplier = {}; >+if ($booksellerid) { >+ $supplier = GetBookSellerFromId($booksellerid); >+ foreach ( keys $supplier ) { >+ $template->{'VARS'}->{$_} = $supplier->{$_}; >+ } >+ $template->{'VARS'}->{'booksellerid'} = $booksellerid; >+} > > #build array for currencies > if ( $op eq 'display' ) { >@@ -74,32 +79,8 @@ if ( $op eq 'display' ) { > my $contracts = GetContract( { booksellerid => $booksellerid } ); > > $template->param( >- booksellerid => $booksellerid, >- name => $supplier->{'name'}, >- postal => $supplier->{'postal'}, >- address1 => $supplier->{'address1'}, >- address2 => $supplier->{'address2'}, >- address3 => $supplier->{'address3'}, >- address4 => $supplier->{'address4'}, >- phone => $supplier->{'phone'}, >- accountnumber => $supplier->{'accountnumber'}, >- fax => $supplier->{'fax'}, >- url => $supplier->{'url'}, >- contact => $supplier->{'contact'}, >- contpos => $supplier->{'contpos'}, >- contphone => $supplier->{'contphone'}, >- contaltphone => $supplier->{'contaltphone'}, >- contfax => $supplier->{'contfax'}, >- contemail => $supplier->{'contemail'}, >- contnotes => $supplier->{'contnotes'}, >- notes => $supplier->{'notes'}, > active => $supplier->{'active'}, >- gstreg => $supplier->{'gstreg'}, >- listincgst => $supplier->{'listincgst'}, >- invoiceincgst => $supplier->{'invoiceincgst'}, > gstrate => $supplier->{'gstrate'} + 0.0, >- discount => $supplier->{'discount'}, >- deliverytime => $supplier->{deliverytime}, > invoiceprice => $supplier->{'invoiceprice'}, > listprice => $supplier->{'listprice'}, > basketcount => $supplier->{'basketcount'}, >@@ -141,34 +122,10 @@ if ( $op eq 'display' ) { > }, split( '\|', C4::Context->preference("gist") ); > > $template->param( >- booksellerid => $booksellerid, >- name => $supplier->{'name'}, >- postal => $supplier->{'postal'}, >- address1 => $supplier->{'address1'}, >- address2 => $supplier->{'address2'}, >- address3 => $supplier->{'address3'}, >- address4 => $supplier->{'address4'}, >- phone => $supplier->{'phone'}, >- accountnumber=> $supplier->{'accountnumber'}, >- fax => $supplier->{'fax'}, >- url => $supplier->{'url'}, >- contact => $supplier->{'contact'}, >- contpos => $supplier->{'contpos'}, >- contphone => $supplier->{'contphone'}, >- contaltphone => $supplier->{'contaltphone'}, >- contfax => $supplier->{'contfax'}, >- contemail => $supplier->{'contemail'}, >- contnotes => $supplier->{'contnotes'}, >- notes => $supplier->{'notes'}, > # set active ON by default for supplier add (id empty for add) > active => $booksellerid ? $supplier->{'active'} : 1, >- gstreg => $supplier->{'gstreg'}, >- listincgst => $supplier->{'listincgst'}, >- invoiceincgst => $supplier->{'invoiceincgst'}, > gstrate => $supplier->{gstrate} ? $supplier->{'gstrate'}+0.0 : 0, > gst_values => \@gst_values, >- discount => $supplier->{'discount'}, >- deliverytime => $supplier->{deliverytime}, > loop_currency => $loop_currency, > enter => 1, > ); >diff --git a/acqui/uncertainprice.pl b/acqui/uncertainprice.pl >index 924f9bd..2bb8070 100755 >--- a/acqui/uncertainprice.pl >+++ b/acqui/uncertainprice.pl >@@ -52,6 +52,7 @@ use C4::Output; > use CGI; > > use C4::Bookseller qw/GetBookSellerFromId/; >+use C4::Bookseller::Contact; > use C4::Acquisition qw/GetPendingOrders GetOrder ModOrder/; > use C4::Biblio qw/GetBiblioData/; > >@@ -119,16 +120,10 @@ $template->param( uncertainpriceorders => \@orders, > booksellerphone =>$bookseller->{'phone'}, > booksellerfax => $bookseller->{'fax'}, > booksellerurl => $bookseller->{'url'}, >- booksellercontact => $bookseller->{'contact'}, >- booksellercontpos => $bookseller->{'contpos'}, >- booksellercontphone => $bookseller->{'contphone'}, >- booksellercontaltphone => $bookseller->{'contaltphone'}, >- booksellercontfax => $bookseller->{'contfax'}, >- booksellercontemail => $bookseller->{'contemail'}, >- booksellercontnotes => $bookseller->{'contnotes'}, > booksellernotes => $bookseller->{'notes'}, > basketcount => $bookseller->{'basketcount'}, > subscriptioncount => $bookseller->{'subscriptioncount'}, > owner => $owner, > scriptname => "/cgi-bin/koha/acqui/uncertainprice.pl"); >+$template->{'VARS'}->{'contacts'} = $bookseller->{'contacts'}; > output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/acqui/updatesupplier.pl b/acqui/updatesupplier.pl >index 7b3bf9d..77fa276 100755 >--- a/acqui/updatesupplier.pl >+++ b/acqui/updatesupplier.pl >@@ -45,11 +45,13 @@ list_currency, gst, list_gst, invoice_gst, discount, gstrate. > =cut > > use strict; >-#use warnings; FIXME - Bug 2505 >+use warnings; >+use List::Util; > use C4::Context; > use C4::Auth; > > use C4::Bookseller qw( ModBookseller AddBookseller ); >+use C4::Bookseller::Contact; > use C4::Biblio; > use C4::Output; > use CGI; >@@ -83,13 +85,6 @@ $data{'phone'}=$input->param('company_phone'); > $data{'accountnumber'}=$input->param('accountnumber'); > $data{'fax'}=$input->param('company_fax'); > $data{'url'}=$input->param('website'); >-$data{'contact'}=$input->param('company_contact_name'); >-$data{'contpos'}=$input->param('company_contact_position'); >-$data{'contphone'}=$input->param('contact_phone'); >-$data{'contaltphone'}=$input->param('contact_phone_2'); >-$data{'contfax'}=$input->param('contact_fax'); >-$data{'contemail'}=$input->param('company_email'); >-$data{'contnotes'}=$input->param('contact_notes'); > # warn "".$data{'contnotes'}; > $data{'notes'}=$input->param('notes'); > $data{'active'}=$input->param('status'); >@@ -104,14 +99,29 @@ $data{'gstrate'} = $input->param('gstrate'); > $data{'discount'} = $input->param('discount'); > $data{deliverytime} = $input->param('deliverytime'); > $data{'active'}=$input->param('status'); >+my @contacts; >+my %contact_info; >+ >+foreach (qw(id name position phone altphone fax email notes)) { >+ $contact_info{$_} = [ $input->param('contact_' . $_) ]; >+} >+ >+for my $cnt (0..scalar(@{$contact_info{'id'}})) { >+ my %contact; >+ foreach (qw(id name position phone altphone fax email notes)) { >+ $contact{$_} = $contact_info{$_}->[$cnt]; >+ } >+ push @contacts, C4::Bookseller::Contact->new(\%contact); >+} >+ > if($data{'name'}) { > if ($data{'id'}){ >- ModBookseller(\%data); >+ ModBookseller(\%data, \@contacts); > } else { >- $data{id}=AddBookseller(\%data); >+ $data{id}=AddBookseller(\%data, \@contacts); > } >-#redirect to booksellers.pl >-print $input->redirect("booksellers.pl?booksellerid=".$data{id}); >+ #redirect to booksellers.pl >+ print $input->redirect("booksellers.pl?booksellerid=".$data{id}); > } else { >-print $input->redirect("supplier.pl?op=enter"); # fail silently. >+ print $input->redirect("supplier.pl?op=enter"); # fail silently. > } >diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >index 9d4446c..5062301 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >+++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >@@ -2043,6 +2043,10 @@ div#acqui_order_supplierlist > div.supplier > div.baskets { > margin-top: 0.5em; > } > >+.supplier-contact-details { >+ float: left; >+} >+ > /* Override core jQueryUI widgets */ > .ui-widget-content { border: 1px solid #B9D8D9; background: #ffffff none; color: #222222; } > .ui-widget-header { border: 1px solid #B9D8D9; background: #E6F0F2 none; color: #222222; font-weight: bold; } >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 0dba956..d85204a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt >@@ -1,4 +1,36 @@ > [% USE KohaDates %] >+[% BLOCK edit_contact %] >+ <ol id="contact-form"> >+ <input type="hidden" name="contact_id" value="[% contact.id %]" /> >+ <li><label for="contact_name">Contact name: </label> >+ <input type="text" size="40" id="contact_name" name="contact_name" value="[% contact.name %]" /></li> >+ <li><label for="contact_position">Position: </label> >+ <input type="text" size="40" id="contact_position" name="contact_position" value="[% contact.position %]" /></li> >+ <li><label for="contact_phone">Phone: </label> >+ <input type="text" size="20" id="contact_phone" name="contact_phone" value="[% contact.phone %]" /> </li> >+ <li><label for="contact_phone_2">Alternative phone: </label> >+ <input type="text" size="20" id="contact_altphone" name="contact_altphone" value="[% contact.altphone %]" /></li> >+ <li><label for="contact_fax">Fax: </label> >+ <input type="text" size="20" id="contact_fax" name="contact_fax" value="[% contact.fax %]" /></li> >+ <li><label for="contact_email">Email: </label> >+ <input type="text" size="40" id="contact_email" name="contact_email" value="[% contact.email %]" /></li> >+ <li><label for="contact_notes">Notes: </label> >+ <textarea id="contact_notes" name="contact_notes" cols="40" rows="4">[% contnotes %]</textarea></li> >+ </ol> >+[% END %] >+[% BLOCK show_contact %] >+ <p><span class="label">Contact name: </span>[% contact.name %]</p> >+ <p><span class="label">Position: </span>[% contact.position %]</p> >+ <p><span class="label">Phone: </span>[% contact.phone %]</p> >+ <p><span class="label">Alternative phone: </span>[% contact.altphone %]</p> >+ <p><span class="label">Fax: </span>[% contact.fax %]</p> >+ [% IF ( contact.email ) %] >+ <p><span class="label">Email: </span><a href="mailto:[% contact.email %]">[% contact.email %]</a></p> >+ [% END %] >+ [% IF ( contact.notes ) %] >+ <p><span class="label">Notes: </span>[% contact.notes %]</p> >+ [% END %] >+[% END %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Vendor [% bookselname %]</title> > <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" /> >@@ -20,6 +52,9 @@ if (f.company.value == "") { > f.submit(); > } > >+function add_contact() { >+} >+ > $(document).ready(function() { > [% IF (dateformat == 'metric') %] > dt_add_type_uk_date(); >@@ -80,23 +115,12 @@ if (f.company.value == "") { > <li><label for="accountnumber">Account number: </label> > <input type="text" size="40" id="accountnumber" name="accountnumber" value="[% accountnumber %]" /></li></ol> > </fieldset> >- <fieldset class="rows"> >- <legend>Contact details</legend> >- <ol> <li><label for="company_contact_name">Contact name: </label> >- <input type="text" size="40" id="company_contact_name" name="company_contact_name" value="[% contact %]" /></li> >- <li><label for="company_contact_position">Position: </label> >- <input type="text" size="40" id="company_contact_position" name="company_contact_position" value="[% contpos %]" /></li> >- <li><label for="contact_phone">Phone: </label> >- <input type="text" size="20" id="contact_phone" name="contact_phone" value="[% contphone %]" /> </li> >- <li><label for="contact_phone_2">Alternative phone: </label> >- <input type="text" size="20" id="contact_phone_2" name="contact_phone_2" value="[% contaltphone %]" /></li> >- <li><label for="contact_fax">Fax: </label> >- <input type="text" size="20" id="contact_fax" name="contact_fax" value="[% contfax %]" /></li> >- <li><label for="company_email">Email: </label> >- <input type="text" size="40" id="company_email" name="company_email" value="[% contemail %]" /></li> >- <li><label for="contact_notes">Notes: </label> >- <textarea id="contact_notes" name="contact_notes" cols="40" rows="4">[% contnotes %]</textarea></li></ol> >- </fieldset> >+ [% FOREACH contact IN contacts %] >+ <fieldset class="supplier-contact rows"> >+ <legend>Contact details</legend> >+ [% INCLUDE edit_contact %] >+ </fieldset> >+ [% END %] > </div> > <div class="yui-g"> > <fieldset class="rows"> >@@ -206,20 +230,12 @@ if (f.company.value == "") { > <p><span class="label">Account number: </span>[% accountnumber %]</p> > [% END %] > </div> >- <div id="supplier-contact-details" class="yui-u"> >- <h2>Contact details</h2> >- <p><span class="label">Contact name: </span>[% contact %]</p> >- <p><span class="label">Position: </span>[% contpos %]</p> >- <p><span class="label">Phone: </span>[% contphone %]</p> >- <p><span class="label">Alternative phone: </span>[% contaltphone %]</p> >- <p><span class="label">Fax: </span>[% contfax %]</p> >- [% IF ( contemail ) %] >- <p><span class="label">Email: </span><a href="mailto:[% contemail %]">[% contemail %]</a></p> >- [% END %] >- [% IF ( contnotes ) %] >- <p><span class="label">Notes: </span>[% contnotes %]</p> >- [% END %] >- </div> >+ [% FOREACH contact IN contacts %] >+ <div class="supplier-contact-details yui-u"> >+ <h2>Contact details</h2> >+ [% INCLUDE show_contact %] >+ </div> >+ [% END %] > </div> > <div id="supplier-ordering-information" class="yui-g"> > <h3>Ordering information</h3> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/uncertainprice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/uncertainprice.tt >index 41aad00..a503f2b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/uncertainprice.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/uncertainprice.tt >@@ -56,14 +56,16 @@ function check(form) { > [% booksellerphone %] / Fax: > [% booksellerfax %]</p> > <dl> >- <dt><strong>Contact: </strong></dt> >- <dd>[% booksellercontact %] >- [% booksellercontpos %] >- [% booksellercontphone %] >- [% booksellercontaltphone %] >- [% booksellercontemail %] >- [% booksellercontnotes %] >- </dd> >+ [% FOREACH contact IN contacts %] >+ <dt><strong>Contact: </strong></dt> >+ <dd>[% contact.name %] >+ [% contact.position %] >+ [% contact.phone %] >+ [% contact.altphone %] >+ [% contact.email %] >+ [% contact.notes %] >+ </dd> >+ [% END %] > </dl> > [% IF ( booksellernotes ) %] > <p><strong>Notes: </strong> >diff --git a/t/db_dependent/Bookseller.t b/t/db_dependent/Bookseller.t >index fca6913..ff8408e 100644 >--- a/t/db_dependent/Bookseller.t >+++ b/t/db_dependent/Bookseller.t >@@ -2,7 +2,7 @@ > > use Modern::Perl; > >-use Test::More tests => 55; >+use Test::More tests => 67; > use C4::Context; > use Koha::DateUtils; > use DateTime::Duration; >@@ -666,6 +666,59 @@ ok( exists( $suppliers{$id_supplier1} ), > "Supplier1 has late orders and $daysago10==$daysago10 " ) > ; > >+#Test contact editing >+my $booksellerid = C4::Bookseller::AddBookseller( >+ { >+ name => "my vendor", >+ address1 => "bookseller's address", >+ phone => "0123456", >+ active => 1 >+ }, >+ [ { name => 'John Smith', phone => '0123456x1' } ] >+); >+ >+my @booksellers = C4::Bookseller::GetBookSeller('my vendor'); >+ok( >+ (grep { $_->{'id'} == $booksellerid } @booksellers), >+ 'GetBookSeller returns correct record when passed a name' >+); >+ >+my $bookseller = C4::Bookseller::GetBookSellerFromId($booksellerid); >+is( $bookseller->{'id'}, $booksellerid, 'Retrieved desired record' ); >+is( $bookseller->{'phone'}, '0123456', 'New bookseller has expected phone' ); >+is( ref $bookseller->{'contacts'}, >+ 'ARRAY', 'GetBookSellerFromId returns arrayref of contacts' ); >+is( >+ ref $bookseller->{'contacts'}->[0], >+ 'C4::Bookseller::Contact', >+ 'First contact is a contact object' >+); >+is( $bookseller->{'contacts'}->[0]->phone, >+ '0123456x1', 'Contact has expected phone number' ); >+ >+$bookseller->{'name'} = 'your vendor'; >+$bookseller->{'contacts'}->[0]->phone('654321'); >+C4::Bookseller::ModBookseller($bookseller); >+ >+$bookseller = C4::Bookseller::GetBookSellerFromId($booksellerid); >+is( $bookseller->{'name'}, 'your vendor', >+ 'Successfully changed name of vendor' ); >+is( $bookseller->{'contacts'}->[0]->phone, >+ '654321', >+ 'Successfully changed contact phone number by modifying bookseller hash' ); >+ >+C4::Bookseller::ModBookseller( $bookseller, >+ [ { name => 'John Jacob Jingleheimer Schmidt' } ] ); >+ >+$bookseller = C4::Bookseller::GetBookSellerFromId($booksellerid); >+is( >+ $bookseller->{'contacts'}->[0]->name, >+ 'John Jacob Jingleheimer Schmidt', >+ 'Changed name of contact' >+); >+is( $bookseller->{'contacts'}->[0]->phone, >+ undef, 'Removed phone number from contact' ); >+ > #End transaction > $dbh->rollback; > >-- >1.7.9.5
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 10402
:
18973
|
18974
|
18975
|
19233
|
19234
|
19235
|
19603
|
19604
|
19808
|
19809
|
19810
|
20019
|
20020
|
20021
|
20045
|
20046
|
20047
|
20048
|
20559
|
20560
|
20561
|
20562
|
21019
|
21020
|
21021
|
21022
|
21023
|
21056
|
21547
|
21549
|
21804
|
23370
|
23371
|
23372
|
23373
|
23374
|
23375
|
23376
|
23377
|
24561
|
24562
|
24563
|
24564
|
24565
|
24566
|
24567
|
24568
|
29223
|
29224
|
29225
|
29226
|
29227
|
29511
|
29600
|
29601
|
29602
|
29603
|
29604
|
29761
|
30209
|
30210
|
30211
|
30212
|
30213
|
30460
|
30461
|
30462
|
30463
|
30464
|
31091
|
31092
|
31093
|
31094
|
31095
|
31096