Bugzilla – Attachment 19881 Details for
Bug 6473
Test bug for Git-bz ✔ ❤ ★
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Signed off 0001-Bug-10402-Use-an-object-for-contacts.patch
0001-Bug-10402-Use-an-object-for-contacts.patch (text/plain), 30.62 KB, created by
Jared Camins-Esakov
on 2013-07-23 17:56:04 UTC
(
hide
)
Description:
Signed off 0001-Bug-10402-Use-an-object-for-contacts.patch
Filename:
MIME Type:
Creator:
Jared Camins-Esakov
Created:
2013-07-23 17:56:04 UTC
Size:
30.62 KB
patch
obsolete
>From 9e97f7bee302bbcf9c35c44f0d2e4645ae059c6d 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: Jared Camins-Esakov <jcamins@cpbibliography.com> >--- > C4/Bookseller.pm | 82 ++++----- > 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 | 68 ++++++++ > 9 files changed, 385 insertions(+), 150 deletions(-) > create mode 100644 C4/Bookseller/Contact.pm > create mode 100644 t/db_dependent/Bookseller.t > >diff --git a/C4/Bookseller.pm b/C4/Bookseller.pm >index 3e1454f..77d0a8c 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,13 +229,12 @@ C<&ModBookseller> with the result. > =cut > > sub ModBookseller { >- my ($data) = @_; >+ my ($data, $contacts) = @_; > my $dbh = C4::Context->dbh; >- my $query = 'UPDATE aqbooksellers >+ 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=?'; >@@ -240,19 +244,21 @@ 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; > } > >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 15ca462..2d5b228 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >+++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >@@ -2048,6 +2048,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 16b2fd1..2c9ed9f 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" /> >@@ -22,6 +54,9 @@ if (f.company.value == "") { > f.submit(); > } > >+function add_contact() { >+} >+ > $(document).ready(function() { > [% IF (dateformat == 'metric') %] > dt_add_type_uk_date(); >@@ -82,23 +117,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"> >@@ -208,20 +232,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 a7b5fc9..0114f4a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/uncertainprice.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/uncertainprice.tt >@@ -58,14 +58,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 >new file mode 100644 >index 0000000..78d8e2c >--- /dev/null >+++ b/t/db_dependent/Bookseller.t >@@ -0,0 +1,68 @@ >+#!/usr/bin/perl >+ >+use strict; >+use warnings; >+ >+use Test::More tests => 12; >+ >+BEGIN { >+ use_ok('C4::Bookseller'); >+} >+ >+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 { >+ C4::Bookseller::DelBookseller($booksellerid); >+ is( C4::Bookseller::GetBookSellerFromId($booksellerid), >+ undef, 'Bookseller successfully deleted' ); >+} >-- >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 6473
:
4386
|
6837
|
6838
|
6839
|
6840
|
6841
|
6842
|
6843
|
7154
|
7155
|
7567
|
7994
|
7995
|
7996
|
7997
|
8018
|
9807
|
9808
|
9813
|
9831
|
9832
|
9836
|
9854
|
10842
|
10843
|
10844
|
10845
|
10846
|
10847
|
10848
|
10849
|
10850
|
10851
|
10852
|
10853
|
10854
|
10855
|
10856
|
10857
|
10858
|
11540
|
11543
|
11544
|
12502
|
12513
|
12514
|
12515
|
12516
|
12517
|
12518
|
12519
|
13473
|
13673
|
14955
|
14969
|
14970
|
14972
|
15201
|
18949
|
18950
|
18951
|
18952
|
18953
|
18954
|
18955
|
18956
|
18957
|
18958
|
18959
|
18960
|
18961
|
18962
|
18963
|
18971
|
18972
|
19518
|
19519
|
19591
|
19592
|
19871
|
19879
|
19880
|
19881
|
19882
|
20011
|
20012
|
20013
|
20014
|
22477
|
22481
|
22482
|
22496
|
22502
|
22503
|
31958
|
32444
|
32445
|
32446
|
32447
|
32448
|
32449
|
32450
|
32451
|
32452
|
34200
|
34201
|
34625
|
34999
|
35130
|
35269
|
35273
|
35274
|
35275
|
35276
|
35277
|
35279
|
35280
|
35303
|
40954
|
40957
|
45345
|
45349
|
45731
|
45732
|
45733
|
45734
|
47283
|
47284
|
47298
|
47299
|
47300
|
47334
|
47336
|
49083
|
56974
|
61059
|
61069
|
62038
|
65313
|
77301
|
78016
|
79959
|
80178
|
80179
|
80180
|
80181
|
80182
|
84400
|
86644
|
86645
|
87152
|
88128
|
95586
|
95716
|
97394
|
99026
|
99027
|
114217
|
114218
|
114219
|
114220
|
114221
|
114222
|
114223
|
114224
|
114225
|
114226
|
119255
|
121181
|
131891
|
131893
|
131894
|
134862
|
144109
|
144144
|
144671
|
144672
|
144673
|
147183
|
149030
|
149031
|
149032
|
149033
|
160566
|
160567
|
160568