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

(-)a/C4/Bookseller.pm (-5 / +7 lines)
Lines 203-212 sub AddBookseller { Link Here
203
    # return the id of this new supplier
203
    # return the id of this new supplier
204
    my $id = $dbh->{'mysql_insertid'};
204
    my $id = $dbh->{'mysql_insertid'};
205
    if ($id && $contacts) {
205
    if ($id && $contacts) {
206
        $contacts->[0] = C4::Bookseller::Contact->new( $contacts->[0] )
206
        foreach my $contact (@$contacts) {
207
          unless ref $contacts->[0] eq 'C4::Bookseller::Contact';
207
            $contact = C4::Bookseller::Contact->new( $contact )
208
        $contacts->[0]->bookseller($id);
208
                unless ref $contacts eq 'C4::Bookseller::Contact';
209
        $contacts->[0]->save();
209
            $contact->bookseller($id);
210
            $contact->save();
211
        }
210
    }
212
    }
211
    return $id;
213
    return $id;
212
}
214
}
Lines 259-265 sub ModBookseller { Link Here
259
    if ($contacts) {
261
    if ($contacts) {
260
        foreach my $contact (@$contacts) {
262
        foreach my $contact (@$contacts) {
261
            $contact = C4::Bookseller::Contact->new( $contact )
263
            $contact = C4::Bookseller::Contact->new( $contact )
262
                unless ref $contacts->[0] eq 'C4::Bookseller::Contact';
264
                unless ref $contacts eq 'C4::Bookseller::Contact';
263
            $contact->bookseller($data->{'id'});
265
            $contact->bookseller($data->{'id'});
264
            $contact->save();
266
            $contact->save();
265
            push @contactparams, $contact->id if $contact->id;
267
            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 2047-2052 div#acqui_order_supplierlist > div.supplier > div.baskets { Link Here
2047
    float: left;
2047
    float: left;
2048
}
2048
}
2049
2049
2050
#add-contact {
2051
    margin: 0 0 8px 8px;
2052
}
2053
2054
#contact-template {
2055
    display: none;
2056
}
2057
2050
/* Override core jQueryUI widgets */
2058
/* Override core jQueryUI widgets */
2051
.ui-widget-content { border: 1px solid #B9D8D9; background: #ffffff none; color: #222222; }
2059
.ui-widget-content { border: 1px solid #B9D8D9; background: #ffffff none; color: #222222; }
2052
.ui-widget-header { border: 1px solid #B9D8D9; background: #E6F0F2 none; color: #222222; font-weight: bold; }
2060
.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 => 67;
5
use Test::More tests => 70;
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 674-685 my $booksellerid = C4::Bookseller::AddBookseller( Link Here
674
        phone    => "0123456",
674
        phone    => "0123456",
675
        active   => 1
675
        active   => 1
676
    },
676
    },
677
    [ { name => 'John Smith', phone => '0123456x1' } ]
677
    [
678
        { name => 'John Smith',  phone => '0123456x1' },
679
        { name => 'Leo Tolstoy', phone => '0123456x2' },
680
    ]
678
);
681
);
679
682
680
my @booksellers = C4::Bookseller::GetBookSeller('my vendor');
683
my @booksellers = C4::Bookseller::GetBookSeller('my vendor');
681
ok(
684
ok(
682
    (grep { $_->{'id'} == $booksellerid } @booksellers),
685
    ( grep { $_->{'id'} == $booksellerid } @booksellers ),
683
    'GetBookSeller returns correct record when passed a name'
686
    'GetBookSeller returns correct record when passed a name'
684
);
687
);
685
688
Lines 695-701 is( Link Here
695
);
698
);
696
is( $bookseller->{'contacts'}->[0]->phone,
699
is( $bookseller->{'contacts'}->[0]->phone,
697
    '0123456x1', 'Contact has expected phone number' );
700
    '0123456x1', 'Contact has expected phone number' );
701
is( scalar @{ $bookseller->{'contacts'} }, 2, 'Saved two contacts' );
698
702
703
pop @{ $bookseller->{'contacts'} };
699
$bookseller->{'name'} = 'your vendor';
704
$bookseller->{'name'} = 'your vendor';
700
$bookseller->{'contacts'}->[0]->phone('654321');
705
$bookseller->{'contacts'}->[0]->phone('654321');
701
C4::Bookseller::ModBookseller($bookseller);
706
C4::Bookseller::ModBookseller($bookseller);
Lines 706-711 is( $bookseller->{'name'}, 'your vendor', Link Here
706
is( $bookseller->{'contacts'}->[0]->phone,
711
is( $bookseller->{'contacts'}->[0]->phone,
707
    '654321',
712
    '654321',
708
    'Successfully changed contact phone number by modifying bookseller hash' );
713
    'Successfully changed contact phone number by modifying bookseller hash' );
714
is( scalar @{ $bookseller->{'contacts'} },
715
    1, 'Only one contact after modification' );
709
716
710
C4::Bookseller::ModBookseller( $bookseller,
717
C4::Bookseller::ModBookseller( $bookseller,
711
    [ { name => 'John Jacob Jingleheimer Schmidt' } ] );
718
    [ { name => 'John Jacob Jingleheimer Schmidt' } ] );
Lines 718-723 is( Link Here
718
);
725
);
719
is( $bookseller->{'contacts'}->[0]->phone,
726
is( $bookseller->{'contacts'}->[0]->phone,
720
    undef, 'Removed phone number from contact' );
727
    undef, 'Removed phone number from contact' );
728
is( scalar @{ $bookseller->{'contacts'} },
729
    1, 'Only one contact after modification' );
721
730
722
#End transaction
731
#End transaction
723
$dbh->rollback;
732
$dbh->rollback;
724
- 

Return to bug 10402