@@ -, +, @@
information is there.
> prove t/db_dependent/Bookseller.t
see that the result is correct.
---
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(-)
--- a/C4/Bookseller.pm
+++ a/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;
--- a/acqui/updatesupplier.pl
+++ a/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'}) {
--- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
+++ a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
@@ -2047,6 +2047,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; }
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt
@@ -2,20 +2,21 @@
[% BLOCK edit_contact %]
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
+ -
+
+ -
+
+ -
+
+ -
+
+ -
+
+ -
+
+ -
+
+ [% IF contact.id %][% END %]
[% 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);
});
//]]>
@@ -117,12 +137,20 @@ function add_contact() {
- [% FOREACH contact IN contacts %]
-