Bugzilla – Attachment 19879 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-Add-ability-to-enter-multiple-contacts.patch
0001-Bug-10402-Add-ability-to-enter-multiple-contacts.patch (text/plain), 11.30 KB, created by
Jared Camins-Esakov
on 2013-07-23 17:40:20 UTC
(
hide
)
Description:
Signed off 0001-Bug-10402-Add-ability-to-enter-multiple-contacts.patch
Filename:
MIME Type:
Creator:
Jared Camins-Esakov
Created:
2013-07-23 17:40:20 UTC
Size:
11.30 KB
patch
obsolete
>From 3cd2fb91ca7f7fe3044a35d316594f1af7df34f5 Mon Sep 17 00:00:00 2001 >From: Jared Camins-Esakov <jcamins@cpbibliography.com> >Date: Thu, 13 Jun 2013 11:31:21 -0400 >Subject: [PATCH] Bug 10402: Add ability to enter multiple contacts > >Some vendors may have more than one contact. For example, a technical >contact and a billing contact, or a contact for journals and a contact >for monographs. Rather than require that each contact be either made >into a separate vendor or recorded somewhere outside of Koha, it would >be really useful of Koha had the ability to add multiple additional >contacts to vendors in the Acquisitions module. > >To test: >1) Apply patch. >2) Edit a bookseller, making sure to add a contact. >3) View the bookseller's information, making sure the contact > information is there. >4) Run the unit test: > > prove t/db_dependent/Bookseller.t >5) Add multiple contacts to a vendor, see that they show up. >6) Delete one contact from a vendor with multiple contacts, > see that the result is correct. >7) Sign off. > >Note: This test plan can supersede that on the previous two patches, >as all functionality of the previous two patches is required by this >one. >Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com> >--- > C4/Bookseller.pm | 12 ++-- > acqui/updatesupplier.pl | 4 +- > .../intranet-tmpl/prog/en/css/staff-global.css | 8 +++ > .../prog/en/modules/acqui/supplier.tt | 62 ++++++++++++++------ > t/db_dependent/Bookseller.t | 15 ++++- > 5 files changed, 75 insertions(+), 26 deletions(-) > >diff --git a/C4/Bookseller.pm b/C4/Bookseller.pm >index 8472c27..1d7515b 100644 >--- a/C4/Bookseller.pm >+++ b/C4/Bookseller.pm >@@ -203,10 +203,12 @@ sub AddBookseller { > # return the id of this new supplier > 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(); >+ foreach my $contact (@$contacts) { >+ $contact = C4::Bookseller::Contact->new( $contact ) >+ unless ref $contacts eq 'C4::Bookseller::Contact'; >+ $contact->bookseller($id); >+ $contact->save(); >+ } > } > return $id; > } >@@ -258,7 +260,7 @@ sub ModBookseller { > if ($contacts) { > foreach my $contact (@$contacts) { > $contact = C4::Bookseller::Contact->new( $contact ) >- unless ref $contacts->[0] eq 'C4::Bookseller::Contact'; >+ unless ref $contacts eq 'C4::Bookseller::Contact'; > $contact->bookseller($data->{'id'}); > $contact->save(); > push @contactparams, $contact->id if $contact->id; >diff --git a/acqui/updatesupplier.pl b/acqui/updatesupplier.pl >index 77fa276..7ce5633 100755 >--- a/acqui/updatesupplier.pl >+++ b/acqui/updatesupplier.pl >@@ -108,10 +108,12 @@ foreach (qw(id name position phone altphone fax email notes)) { > > for my $cnt (0..scalar(@{$contact_info{'id'}})) { > my %contact; >+ my $real_contact; > foreach (qw(id name position phone altphone fax email notes)) { > $contact{$_} = $contact_info{$_}->[$cnt]; >+ $real_contact = 1 if $contact{$_}; > } >- push @contacts, C4::Bookseller::Contact->new(\%contact); >+ push @contacts, C4::Bookseller::Contact->new(\%contact) if $real_contact; > } > > if($data{'name'}) { >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 2d5b228..c8ea054 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >+++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >@@ -2052,6 +2052,14 @@ div#acqui_order_supplierlist > div.supplier > div.baskets { > float: left; > } > >+#add-contact { >+ margin: 0 0 8px 8px; >+} >+ >+#contact-template { >+ display: none; >+} >+ > /* 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 2c9ed9f..fcbaea4 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt >@@ -2,20 +2,21 @@ > [% 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> >+ <li><label for="contact_name[% contact.id %]">Contact name: </label> >+ <input type="text" size="40" id="contact_name[% contact.id %]" name="contact_name" value="[% contact.name %]" /></li> >+ <li><label for="contact_position[% contact.id %]">Position: </label> >+ <input type="text" size="40" id="contact_position[% contact.id %]" name="contact_position" value="[% contact.position %]" /></li> >+ <li><label for="contact_phone[% contact.id %]">Phone: </label> >+ <input type="text" size="20" id="contact_phone[% contact.id %]" name="contact_phone" value="[% contact.phone %]" /> </li> >+ <li><label for="contact_altphone[% contact.id %]">Alternative phone: </label> >+ <input type="text" size="20" id="contact_altphone[% contact.id %]" name="contact_altphone" value="[% contact.altphone %]" /></li> >+ <li><label for="contact_fax[% contact.id %]">Fax: </label> >+ <input type="text" size="20" id="contact_fax[% contact.id %]" name="contact_fax" value="[% contact.fax %]" /></li> >+ <li><label for="contact_email[% contact.id %]">Email: </label> >+ <input type="text" size="40" id="contact_email[% contact.id %]" name="contact_email" value="[% contact.email %]" /></li> >+ <li><label for="contact_notes[% contact.id %]">Notes: </label> >+ <textarea id="contact_notes[% contact.id %]" name="contact_notes" cols="40" rows="4">[% contnotes %]</textarea></li> >+ [% IF contact.id %]<li><button class="btn" class="delete-contact"><i class="icon-remove"></i>Delete contact</li>[% END %] > </ol> > [% END %] > [% BLOCK show_contact %] >@@ -55,6 +56,23 @@ if (f.company.value == "") { > } > > function add_contact() { >+ var new_contact = $('#contact-template').clone(); >+ var timestamp = new Date().getTime(); >+ $(new_contact).removeAttr('id'); >+ $('input, textarea', new_contact).each(function () { >+ $(this).attr('id', $(this).attr('id') + '_' + timestamp); >+ }); >+ $('label', new_contact).each(function () { >+ $(this).attr('for', $(this).attr('for') + '_' + timestamp); >+ }); >+ $(new_contact).insertBefore(this); >+ $('input[name="contact_name"]', new_contact).focus(); >+ return false; >+} >+ >+function delete_contact() { >+ $(this).parents('fieldset').delete(); >+ return false; > } > > $(document).ready(function() { >@@ -73,6 +91,8 @@ function add_contact() { > 'bFilter': false, > 'bInfo': false, > } ) ); >+ $('.delete-contact').click(delete_contact); >+ $('#add-contact').click(add_contact); > }); > //]]> > </script> >@@ -117,12 +137,20 @@ function add_contact() { > <li><label for="accountnumber">Account number: </label> > <input type="text" size="40" id="accountnumber" name="accountnumber" value="[% accountnumber %]" /></li></ol> > </fieldset> >- [% FOREACH contact IN contacts %] >- <fieldset class="supplier-contact rows"> >+ <fieldset class="rows"> >+ <legend>Contacts</legend> >+ <fieldset id="contact-template" class="supplier-contact"> > <legend>Contact details</legend> > [% INCLUDE edit_contact %] > </fieldset> >- [% END %] >+ [% FOREACH contact IN contacts %] >+ <fieldset class="supplier-contact"> >+ <legend>Contact details</legend> >+ [% INCLUDE edit_contact %] >+ </fieldset> >+ [% END %] >+ <button id="add-contact" class="btn"><i class="icon-plus"></i>Add contact</button> >+ </fieldset> > </div> > <div class="yui-g"> > <fieldset class="rows"> >diff --git a/t/db_dependent/Bookseller.t b/t/db_dependent/Bookseller.t >index 78d8e2c..8332357 100644 >--- a/t/db_dependent/Bookseller.t >+++ b/t/db_dependent/Bookseller.t >@@ -3,7 +3,7 @@ > use strict; > use warnings; > >-use Test::More tests => 12; >+use Test::More tests => 15; > > BEGIN { > use_ok('C4::Bookseller'); >@@ -16,12 +16,15 @@ my $booksellerid = C4::Bookseller::AddBookseller( > phone => "0123456", > active => 1 > }, >- [ { name => 'John Smith', phone => '0123456x1' } ] >+ [ >+ { name => 'John Smith', phone => '0123456x1' }, >+ { name => 'Leo Tolstoy', phone => '0123456x2' }, >+ ] > ); > > my @booksellers = C4::Bookseller::GetBookSeller('my vendor'); > ok( >- (grep { $_->{'id'} == $booksellerid } @booksellers), >+ ( grep { $_->{'id'} == $booksellerid } @booksellers ), > 'GetBookSeller returns correct record when passed a name' > ); > >@@ -37,7 +40,9 @@ is( > ); > is( $bookseller->{'contacts'}->[0]->phone, > '0123456x1', 'Contact has expected phone number' ); >+is( scalar @{ $bookseller->{'contacts'} }, 2, 'Saved two contacts' ); > >+pop @{ $bookseller->{'contacts'} }; > $bookseller->{'name'} = 'your vendor'; > $bookseller->{'contacts'}->[0]->phone('654321'); > C4::Bookseller::ModBookseller($bookseller); >@@ -48,6 +53,8 @@ is( $bookseller->{'name'}, 'your vendor', > is( $bookseller->{'contacts'}->[0]->phone, > '654321', > 'Successfully changed contact phone number by modifying bookseller hash' ); >+is( scalar @{ $bookseller->{'contacts'} }, >+ 1, 'Only one contact after modification' ); > > C4::Bookseller::ModBookseller( $bookseller, > [ { name => 'John Jacob Jingleheimer Schmidt' } ] ); >@@ -60,6 +67,8 @@ is( > ); > is( $bookseller->{'contacts'}->[0]->phone, > undef, 'Removed phone number from contact' ); >+is( scalar @{ $bookseller->{'contacts'} }, >+ 1, 'Only one contact after modification' ); > > END { > C4::Bookseller::DelBookseller($booksellerid); >-- >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