View | Details | Raw Unified | Return to bug 10402
Collapse All | Expand All

(-)a/C4/Bookseller.pm (-5 / +7 lines)
Lines 209-218 sub AddBookseller { Link Here
209
    # return the id of this new supplier
209
    # return the id of this new supplier
210
    my $id = $dbh->{'mysql_insertid'};
210
    my $id = $dbh->{'mysql_insertid'};
211
    if ($id && $contacts) {
211
    if ($id && $contacts) {
212
        $contacts->[0] = C4::Bookseller::Contact->new( $contacts->[0] )
212
        foreach my $contact (@$contacts) {
213
          unless ref $contacts->[0] eq 'C4::Bookseller::Contact';
213
            $contact = C4::Bookseller::Contact->new( $contact )
214
        $contacts->[0]->bookseller($id);
214
                unless ref $contacts eq 'C4::Bookseller::Contact';
215
        $contacts->[0]->save();
215
            $contact->bookseller($id);
216
            $contact->save();
217
        }
216
    }
218
    }
217
    return $id;
219
    return $id;
218
}
220
}
Lines 265-271 sub ModBookseller { Link Here
265
    if ($contacts) {
267
    if ($contacts) {
266
        foreach my $contact (@$contacts) {
268
        foreach my $contact (@$contacts) {
267
            $contact = C4::Bookseller::Contact->new( $contact )
269
            $contact = C4::Bookseller::Contact->new( $contact )
268
                unless ref $contacts->[0] eq 'C4::Bookseller::Contact';
270
                unless ref $contacts eq 'C4::Bookseller::Contact';
269
            $contact->bookseller($data->{'id'});
271
            $contact->bookseller($data->{'id'});
270
            $contact->save();
272
            $contact->save();
271
            push @contactparams, $contact->id if $contact->id;
273
            push @contactparams, $contact->id if $contact->id;
(-)a/acqui/updatesupplier.pl (-1 / +3 lines)
Lines 108-117 foreach (qw(id name position phone altphone fax email notes)) { Link Here
108
108
109
for my $cnt (0..scalar(@{$contact_info{'id'}})) {
109
for my $cnt (0..scalar(@{$contact_info{'id'}})) {
110
    my %contact;
110
    my %contact;
111
    my $real_contact;
111
    foreach (qw(id name position phone altphone fax email notes)) {
112
    foreach (qw(id name position phone altphone fax email notes)) {
112
        $contact{$_} = $contact_info{$_}->[$cnt];
113
        $contact{$_} = $contact_info{$_}->[$cnt];
114
        $real_contact = 1 if $contact{$_};
113
    }
115
    }
114
    push @contacts, C4::Bookseller::Contact->new(\%contact);
116
    push @contacts, C4::Bookseller::Contact->new(\%contact) if $real_contact;
115
}
117
}
116
118
117
if($data{'name'}) {
119
if($data{'name'}) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css (+8 lines)
Lines 2060-2065 div#acqui_order_supplierlist > div.supplier > div.baskets { Link Here
2060
    float: left;
2060
    float: left;
2061
}
2061
}
2062
2062
2063
#add-contact {
2064
    margin: 0 0 8px 8px;
2065
}
2066
2067
#contact-template {
2068
    display: none;
2069
}
2070
2063
/* Override core jQueryUI widgets */
2071
/* Override core jQueryUI widgets */
2064
.ui-widget-content { border: 1px solid #B9D8D9; background: #ffffff none; color: #222222; }
2072
.ui-widget-content { border: 1px solid #B9D8D9; background: #ffffff none; color: #222222; }
2065
.ui-widget-header { border: 1px solid #B9D8D9; background: #E6F0F2 none; color: #222222; font-weight: bold; }
2073
.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 (-17 / +45 lines)
Lines 2-21 Link Here
2
[% BLOCK edit_contact %]
2
[% BLOCK edit_contact %]
3
    <ol id="contact-form">
3
    <ol id="contact-form">
4
        <input type="hidden" name="contact_id" value="[% contact.id %]" />
4
        <input type="hidden" name="contact_id" value="[% contact.id %]" />
5
        <li><label for="contact_name">Contact name: </label>
5
        <li><label for="contact_name[% contact.id %]">Contact name: </label>
6
            <input type="text" size="40" id="contact_name" name="contact_name" value="[% contact.name %]" /></li>
6
            <input type="text" size="40" id="contact_name[% contact.id %]" name="contact_name" value="[% contact.name %]" /></li>
7
        <li><label for="contact_position">Position: </label>
7
        <li><label for="contact_position[% contact.id %]">Position: </label>
8
            <input type="text" size="40" id="contact_position" name="contact_position" value="[% contact.position %]" /></li>
8
            <input type="text" size="40" id="contact_position[% contact.id %]" name="contact_position" value="[% contact.position %]" /></li>
9
        <li><label for="contact_phone">Phone: </label>
9
        <li><label for="contact_phone[% contact.id %]">Phone: </label>
10
                <input type="text" size="20" id="contact_phone" name="contact_phone" value="[% contact.phone %]" /> </li>
10
                <input type="text" size="20" id="contact_phone[% contact.id %]" name="contact_phone" value="[% contact.phone %]" /> </li>
11
        <li><label for="contact_phone_2">Alternative phone: </label>
11
        <li><label for="contact_altphone[% contact.id %]">Alternative phone: </label>
12
            <input type="text" size="20" id="contact_altphone" name="contact_altphone" value="[% contact.altphone %]" /></li>
12
            <input type="text" size="20" id="contact_altphone[% contact.id %]" name="contact_altphone" value="[% contact.altphone %]" /></li>
13
        <li><label for="contact_fax">Fax: </label>
13
        <li><label for="contact_fax[% contact.id %]">Fax: </label>
14
            <input type="text" size="20" id="contact_fax" name="contact_fax" value="[% contact.fax %]" /></li>
14
            <input type="text" size="20" id="contact_fax[% contact.id %]" name="contact_fax" value="[% contact.fax %]" /></li>
15
        <li><label for="contact_email">Email: </label>
15
        <li><label for="contact_email[% contact.id %]">Email: </label>
16
            <input type="text" size="40" id="contact_email" name="contact_email" value="[% contact.email %]" /></li>
16
            <input type="text" size="40" id="contact_email[% contact.id %]" name="contact_email" value="[% contact.email %]" /></li>
17
        <li><label for="contact_notes">Notes: </label>
17
        <li><label for="contact_notes[% contact.id %]">Notes: </label>
18
            <textarea id="contact_notes" name="contact_notes" cols="40" rows="4">[% contnotes %]</textarea></li>
18
            <textarea id="contact_notes[% contact.id %]" name="contact_notes" cols="40" rows="4">[% contnotes %]</textarea></li>
19
        [% IF contact.id %]<li><button class="btn" class="delete-contact"><i class="icon-remove"></i>Delete contact</li>[% END %]
19
    </ol>
20
    </ol>
20
[% END %]
21
[% END %]
21
[% BLOCK show_contact %]
22
[% BLOCK show_contact %]
Lines 53-58 if (f.company.value == "") { Link Here
53
}
54
}
54
55
55
function add_contact() {
56
function add_contact() {
57
    var new_contact = $('#contact-template').clone();
58
    var timestamp = new Date().getTime();
59
    $(new_contact).removeAttr('id');
60
    $('input, textarea', new_contact).each(function () {
61
        $(this).attr('id', $(this).attr('id') + '_' + timestamp);
62
    });
63
    $('label', new_contact).each(function () {
64
        $(this).attr('for', $(this).attr('for') + '_' + timestamp);
65
    });
66
    $(new_contact).insertBefore(this);
67
    $('input[name="contact_name"]', new_contact).focus();
68
    return false;
69
}
70
71
function delete_contact() {
72
    $(this).parents('fieldset').delete();
73
    return false;
56
}
74
}
57
75
58
 $(document).ready(function() {
76
 $(document).ready(function() {
Lines 71-76 function add_contact() { Link Here
71
        'bFilter': false,
89
        'bFilter': false,
72
        'bInfo': false,
90
        'bInfo': false,
73
    } ) );
91
    } ) );
92
    $('.delete-contact').click(delete_contact);
93
    $('#add-contact').click(add_contact);
74
 });
94
 });
75
//]]>
95
//]]>
76
</script>
96
</script>
Lines 115-126 function add_contact() { Link Here
115
            <li><label for="accountnumber">Account number: </label>
135
            <li><label for="accountnumber">Account number: </label>
116
                <input type="text" size="40" id="accountnumber" name="accountnumber" value="[% accountnumber %]" /></li></ol>
136
                <input type="text" size="40" id="accountnumber" name="accountnumber" value="[% accountnumber %]" /></li></ol>
117
        </fieldset>
137
        </fieldset>
118
        [% FOREACH contact IN contacts %]
138
        <fieldset class="rows">
119
            <fieldset class="supplier-contact rows">
139
            <legend>Contacts</legend>
140
            <fieldset id="contact-template" class="supplier-contact">
120
                <legend>Contact details</legend>
141
                <legend>Contact details</legend>
121
                [% INCLUDE edit_contact %]
142
                [% INCLUDE edit_contact %]
122
            </fieldset>
143
            </fieldset>
123
        [% END %]
144
            [% FOREACH contact IN contacts %]
145
                <fieldset class="supplier-contact">
146
                    <legend>Contact details</legend>
147
                    [% INCLUDE edit_contact %]
148
                </fieldset>
149
            [% END %]
150
            <button id="add-contact" class="btn"><i class="icon-plus"></i>Add contact</button>
151
        </fieldset>
124
    </div>
152
    </div>
125
        <div class="yui-g">
153
        <div class="yui-g">
126
        <fieldset class="rows">
154
        <fieldset class="rows">
(-)a/t/db_dependent/Bookseller.t (-4 / +12 lines)
Lines 2-8 Link Here
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
4
5
use Test::More tests => 69;
5
use Test::More tests => 72;
6
use C4::Context;
6
use C4::Context;
7
use Koha::DateUtils;
7
use Koha::DateUtils;
8
use DateTime::Duration;
8
use DateTime::Duration;
Lines 671-682 my $booksellerid = C4::Bookseller::AddBookseller( Link Here
671
        phone    => "0123456",
671
        phone    => "0123456",
672
        active   => 1
672
        active   => 1
673
    },
673
    },
674
    [ { name => 'John Smith', phone => '0123456x1' } ]
674
    [
675
        { name => 'John Smith',  phone => '0123456x1' },
676
        { name => 'Leo Tolstoy', phone => '0123456x2' },
677
    ]
675
);
678
);
676
679
677
my @booksellers = C4::Bookseller::GetBookSeller('my vendor');
680
my @booksellers = C4::Bookseller::GetBookSeller('my vendor');
678
ok(
681
ok(
679
    (grep { $_->{'id'} == $booksellerid } @booksellers),
682
    ( grep { $_->{'id'} == $booksellerid } @booksellers ),
680
    'GetBookSeller returns correct record when passed a name'
683
    'GetBookSeller returns correct record when passed a name'
681
);
684
);
682
685
Lines 692-698 is( Link Here
692
);
695
);
693
is( $bookseller->{'contacts'}->[0]->phone,
696
is( $bookseller->{'contacts'}->[0]->phone,
694
    '0123456x1', 'Contact has expected phone number' );
697
    '0123456x1', 'Contact has expected phone number' );
698
is( scalar @{ $bookseller->{'contacts'} }, 2, 'Saved two contacts' );
695
699
700
pop @{ $bookseller->{'contacts'} };
696
$bookseller->{'name'} = 'your vendor';
701
$bookseller->{'name'} = 'your vendor';
697
$bookseller->{'contacts'}->[0]->phone('654321');
702
$bookseller->{'contacts'}->[0]->phone('654321');
698
C4::Bookseller::ModBookseller($bookseller);
703
C4::Bookseller::ModBookseller($bookseller);
Lines 703-708 is( $bookseller->{'name'}, 'your vendor', Link Here
703
is( $bookseller->{'contacts'}->[0]->phone,
708
is( $bookseller->{'contacts'}->[0]->phone,
704
    '654321',
709
    '654321',
705
    'Successfully changed contact phone number by modifying bookseller hash' );
710
    'Successfully changed contact phone number by modifying bookseller hash' );
711
is( scalar @{ $bookseller->{'contacts'} },
712
    1, 'Only one contact after modification' );
706
713
707
C4::Bookseller::ModBookseller( $bookseller,
714
C4::Bookseller::ModBookseller( $bookseller,
708
    [ { name => 'John Jacob Jingleheimer Schmidt' } ] );
715
    [ { name => 'John Jacob Jingleheimer Schmidt' } ] );
Lines 715-720 is( Link Here
715
);
722
);
716
is( $bookseller->{'contacts'}->[0]->phone,
723
is( $bookseller->{'contacts'}->[0]->phone,
717
    undef, 'Removed phone number from contact' );
724
    undef, 'Removed phone number from contact' );
725
is( scalar @{ $bookseller->{'contacts'} },
726
    1, 'Only one contact after modification' );
718
727
719
#End transaction
728
#End transaction
720
$dbh->rollback;
729
$dbh->rollback;
721
- 

Return to bug 10402