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 2076-2081 div#acqui_order_supplierlist > div.supplier > div.baskets { Link Here
2076
    float: left;
2076
    float: left;
2077
}
2077
}
2078
2078
2079
#add-contact {
2080
    margin: 0 0 8px 8px;
2081
}
2082
2083
#contact-template {
2084
    display: none;
2085
}
2086
2079
/* Override core jQueryUI widgets */
2087
/* Override core jQueryUI widgets */
2080
.ui-widget-content { border: 1px solid #B9D8D9; background: #ffffff none; color: #222222; }
2088
.ui-widget-content { border: 1px solid #B9D8D9; background: #ffffff none; color: #222222; }
2081
.ui-widget-header { border: 1px solid #B9D8D9; background: #E6F0F2 none; color: #222222; font-weight: bold; }
2089
.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 46-51 function confirm_deletion() { Link Here
46
}
47
}
47
48
48
function add_contact() {
49
function add_contact() {
50
    var new_contact = $('#contact-template').clone();
51
    var timestamp = new Date().getTime();
52
    $(new_contact).removeAttr('id');
53
    $('input, textarea', new_contact).each(function () {
54
        $(this).attr('id', $(this).attr('id') + '_' + timestamp);
55
    });
56
    $('label', new_contact).each(function () {
57
        $(this).attr('for', $(this).attr('for') + '_' + timestamp);
58
    });
59
    $(new_contact).insertBefore(this);
60
    $('input[name="contact_name"]', new_contact).focus();
61
    return false;
62
}
63
64
function delete_contact() {
65
    $(this).parents('fieldset').delete();
66
    return false;
49
}
67
}
50
68
51
 $(document).ready(function() {
69
 $(document).ready(function() {
Lines 56-61 function add_contact() { Link Here
56
        ],
74
        ],
57
        'sDom': 't'
75
        'sDom': 't'
58
    } ) );
76
    } ) );
77
    $('.delete-contact').click(delete_contact);
78
    $('#add-contact').click(add_contact);
59
 });
79
 });
60
//]]>
80
//]]>
61
</script>
81
</script>
Lines 100-111 function add_contact() { Link Here
100
            <li><label for="accountnumber">Account number: </label>
120
            <li><label for="accountnumber">Account number: </label>
101
                <input type="text" size="40" id="accountnumber" name="accountnumber" value="[% accountnumber %]" /></li></ol>
121
                <input type="text" size="40" id="accountnumber" name="accountnumber" value="[% accountnumber %]" /></li></ol>
102
        </fieldset>
122
        </fieldset>
103
        [% FOREACH contact IN contacts %]
123
        <fieldset class="rows">
104
            <fieldset class="supplier-contact rows">
124
            <legend>Contacts</legend>
125
            <fieldset id="contact-template" class="supplier-contact">
105
                <legend>Contact details</legend>
126
                <legend>Contact details</legend>
106
                [% INCLUDE edit_contact %]
127
                [% INCLUDE edit_contact %]
107
            </fieldset>
128
            </fieldset>
108
        [% END %]
129
            [% FOREACH contact IN contacts %]
130
                <fieldset class="supplier-contact">
131
                    <legend>Contact details</legend>
132
                    [% INCLUDE edit_contact %]
133
                </fieldset>
134
            [% END %]
135
            <button id="add-contact" class="btn"><i class="icon-plus"></i>Add contact</button>
136
        </fieldset>
109
    </div>
137
    </div>
110
        <div class="yui-g">
138
        <div class="yui-g">
111
        <fieldset class="rows">
139
        <fieldset class="rows">
(-)a/t/db_dependent/Bookseller.t (-3 / +11 lines)
Lines 710-721 my $booksellerid = C4::Bookseller::AddBookseller( Link Here
710
        phone    => "0123456",
710
        phone    => "0123456",
711
        active   => 1
711
        active   => 1
712
    },
712
    },
713
    [ { name => 'John Smith', phone => '0123456x1' } ]
713
    [
714
        { name => 'John Smith',  phone => '0123456x1' },
715
        { name => 'Leo Tolstoy', phone => '0123456x2' },
716
    ]
714
);
717
);
715
718
716
my @booksellers = C4::Bookseller::GetBookSeller('my vendor');
719
my @booksellers = C4::Bookseller::GetBookSeller('my vendor');
717
ok(
720
ok(
718
    (grep { $_->{'id'} == $booksellerid } @booksellers),
721
    ( grep { $_->{'id'} == $booksellerid } @booksellers ),
719
    'GetBookSeller returns correct record when passed a name'
722
    'GetBookSeller returns correct record when passed a name'
720
);
723
);
721
724
Lines 731-737 is( Link Here
731
);
734
);
732
is( $bookseller->{'contacts'}->[0]->phone,
735
is( $bookseller->{'contacts'}->[0]->phone,
733
    '0123456x1', 'Contact has expected phone number' );
736
    '0123456x1', 'Contact has expected phone number' );
737
is( scalar @{ $bookseller->{'contacts'} }, 2, 'Saved two contacts' );
734
738
739
pop @{ $bookseller->{'contacts'} };
735
$bookseller->{'name'} = 'your vendor';
740
$bookseller->{'name'} = 'your vendor';
736
$bookseller->{'contacts'}->[0]->phone('654321');
741
$bookseller->{'contacts'}->[0]->phone('654321');
737
C4::Bookseller::ModBookseller($bookseller);
742
C4::Bookseller::ModBookseller($bookseller);
Lines 742-747 is( $bookseller->{'name'}, 'your vendor', Link Here
742
is( $bookseller->{'contacts'}->[0]->phone,
747
is( $bookseller->{'contacts'}->[0]->phone,
743
    '654321',
748
    '654321',
744
    'Successfully changed contact phone number by modifying bookseller hash' );
749
    'Successfully changed contact phone number by modifying bookseller hash' );
750
is( scalar @{ $bookseller->{'contacts'} },
751
    1, 'Only one contact after modification' );
745
752
746
C4::Bookseller::ModBookseller( $bookseller,
753
C4::Bookseller::ModBookseller( $bookseller,
747
    [ { name => 'John Jacob Jingleheimer Schmidt' } ] );
754
    [ { name => 'John Jacob Jingleheimer Schmidt' } ] );
Lines 754-759 is( Link Here
754
);
761
);
755
is( $bookseller->{'contacts'}->[0]->phone,
762
is( $bookseller->{'contacts'}->[0]->phone,
756
    undef, 'Removed phone number from contact' );
763
    undef, 'Removed phone number from contact' );
764
is( scalar @{ $bookseller->{'contacts'} },
765
    1, 'Only one contact after modification' );
757
766
758
#End transaction
767
#End transaction
759
$dbh->rollback;
768
$dbh->rollback;
760
- 

Return to bug 10402