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

(-)a/C4/Bookseller.pm (-38 / +44 lines)
Lines 23-28 use warnings; Link Here
23
23
24
use base qw( Exporter );
24
use base qw( Exporter );
25
25
26
use C4::Bookseller::Contact;
27
26
# set the version for version checking
28
# set the version for version checking
27
our $VERSION   = 3.07.00.049;
29
our $VERSION   = 3.07.00.049;
28
our @EXPORT_OK = qw(
30
our @EXPORT_OK = qw(
Lines 52-59 a bookseller. Link Here
52
54
53
@results = GetBookSeller($searchstring);
55
@results = GetBookSeller($searchstring);
54
56
55
Looks up a book seller. C<$searchstring> may be either a book seller
57
Looks up a book seller. C<$searchstring> is a string to look for in the
56
ID, or a string to look for in the book seller's name.
58
book seller's name.
57
59
58
C<@results> is an array of hash_refs whose keys are the fields of of the
60
C<@results> is an array of hash_refs whose keys are the fields of of the
59
aqbooksellers table in the Koha database.
61
aqbooksellers table in the Koha database.
Lines 90-95 sub GetBookSellerFromId { Link Here
90
        ( $vendor->{subscriptioncount} ) = $dbh->selectrow_array(
92
        ( $vendor->{subscriptioncount} ) = $dbh->selectrow_array(
91
            'SELECT count(*) FROM subscription WHERE aqbooksellerid = ?',
93
            'SELECT count(*) FROM subscription WHERE aqbooksellerid = ?',
92
            {}, $id );
94
            {}, $id );
95
        $vendor->{'contacts'} = C4::Bookseller::Contact->get_from_bookseller($id);
93
    }
96
    }
94
    return $vendor;
97
    return $vendor;
95
}
98
}
Lines 170-209 Returns the ID of the newly-created bookseller. Link Here
170
=cut
173
=cut
171
174
172
sub AddBookseller {
175
sub AddBookseller {
173
    my ($data) = @_;
176
    my ($data, $contacts) = @_;
174
    my $dbh    = C4::Context->dbh;
177
    my $dbh    = C4::Context->dbh;
175
    my $query  = q|
178
    my $query = q|
176
        INSERT INTO aqbooksellers
179
        INSERT INTO aqbooksellers
177
            (
180
            (
178
                name,      address1,      address2,     address3,   address4,
181
                name,      address1,      address2,     address3, address4,
179
                postal,    phone,         accountnumber,fax,        url,
182
                postal,    phone,         accountnumber,fax,      url,
180
                contact,   contpos,       contphone,    contfax,    contaltphone,
183
                active,    listprice,     invoiceprice, gstreg,
181
                contemail, contnotes,     active,       listprice,  invoiceprice,
184
                listincgst,invoiceincgst, gstrate,      discount, notes,
182
                gstreg,    listincgst,    invoiceincgst,gstrate,    discount,
185
                deliverytime
183
                notes,     deliverytime
184
            )
186
            )
185
        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) |
187
        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) |
186
      ;
188
      ;
187
    my $sth = $dbh->prepare($query);
189
    my $sth = $dbh->prepare($query);
188
    $sth->execute(
190
    $sth->execute(
189
        $data->{name}         ,$data->{address1},
191
        $data->{'name'},         $data->{'address1'},
190
        $data->{address2}     ,$data->{address3},
192
        $data->{'address2'},     $data->{'address3'},
191
        $data->{address4}     ,$data->{postal},
193
        $data->{'address4'},     $data->{'postal'},
192
        $data->{phone}        ,$data->{accountnumber},
194
        $data->{'phone'},        $data->{'accountnumber'},
193
        $data->{fax},
195
        $data->{'fax'},          $data->{'url'},
194
        $data->{url}          ,$data->{contact},
196
        $data->{'active'},       $data->{'listprice'},
195
        $data->{contpos}      ,$data->{contphone},
197
        $data->{'invoiceprice'}, $data->{'gstreg'},
196
        $data->{contfax}      ,$data->{contaltphone},
198
        $data->{'listincgst'},   $data->{'invoiceincgst'},
197
        $data->{contemail}    ,$data->{contnotes},
199
        $data->{'gstrate'},      $data->{'discount'},
198
        $data->{active}       ,$data->{listprice},
200
        $data->{'notes'},        $data->{'deliverytime'}
199
        $data->{invoiceprice} ,$data->{gstreg},
200
        $data->{listincgst}   ,$data->{invoiceincgst},
201
        $data->{gstrate}      ,$data->{discount},
202
        $data->{notes}        ,$data->{deliverytime},
203
    );
201
    );
204
202
205
    # return the id of this new supplier
203
    # return the id of this new supplier
206
    return $dbh->{'mysql_insertid'};
204
    my $id = $dbh->{'mysql_insertid'};
205
    if ($id && $contacts) {
206
        $contacts->[0] = C4::Bookseller::Contact->new( $contacts->[0] )
207
          unless ref $contacts->[0] eq 'C4::Bookseller::Contact';
208
        $contacts->[0]->bookseller($id);
209
        $contacts->[0]->save();
210
    }
211
    return $id;
207
}
212
}
208
213
209
#-----------------------------------------------------------------#
214
#-----------------------------------------------------------------#
Lines 224-236 C<&ModBookseller> with the result. Link Here
224
=cut
229
=cut
225
230
226
sub ModBookseller {
231
sub ModBookseller {
227
    my ($data) = @_;
232
    my ($data, $contacts) = @_;
228
    my $dbh    = C4::Context->dbh;
233
    my $dbh    = C4::Context->dbh;
229
    my $query  = 'UPDATE aqbooksellers
234
    my $query = 'UPDATE aqbooksellers
230
        SET name=?,address1=?,address2=?,address3=?,address4=?,
235
        SET name=?,address1=?,address2=?,address3=?,address4=?,
231
            postal=?,phone=?,accountnumber=?,fax=?,url=?,contact=?,contpos=?,
236
            postal=?,phone=?,accountnumber=?,fax=?,url=?,
232
            contphone=?,contfax=?,contaltphone=?,contemail=?,
237
            active=?,listprice=?, invoiceprice=?,
233
            contnotes=?,active=?,listprice=?, invoiceprice=?,
234
            gstreg=?,listincgst=?,invoiceincgst=?,
238
            gstreg=?,listincgst=?,invoiceincgst=?,
235
            discount=?,notes=?,gstrate=?,deliverytime=?
239
            discount=?,notes=?,gstrate=?,deliverytime=?
236
        WHERE id=?';
240
        WHERE id=?';
Lines 240-258 sub ModBookseller { Link Here
240
        $data->{'address2'},     $data->{'address3'},
244
        $data->{'address2'},     $data->{'address3'},
241
        $data->{'address4'},     $data->{'postal'},
245
        $data->{'address4'},     $data->{'postal'},
242
        $data->{'phone'},        $data->{'accountnumber'},
246
        $data->{'phone'},        $data->{'accountnumber'},
243
        $data->{'fax'},
247
        $data->{'fax'},          $data->{'url'},
244
        $data->{'url'},          $data->{'contact'},
245
        $data->{'contpos'},      $data->{'contphone'},
246
        $data->{'contfax'},      $data->{'contaltphone'},
247
        $data->{'contemail'},    $data->{'contnotes'},
248
        $data->{'active'},       $data->{'listprice'},
248
        $data->{'active'},       $data->{'listprice'},
249
        $data->{'invoiceprice'}, $data->{'gstreg'},
249
        $data->{'invoiceprice'}, $data->{'gstreg'},
250
        $data->{'listincgst'},   $data->{'invoiceincgst'},
250
        $data->{'listincgst'},   $data->{'invoiceincgst'},
251
        $data->{'discount'},     $data->{'notes'},
251
        $data->{'discount'},     $data->{'notes'},
252
        $data->{'gstrate'},
252
        $data->{'gstrate'},      $data->{deliverytime},
253
        $data->{deliverytime},
254
        $data->{'id'}
253
        $data->{'id'}
255
    );
254
    );
255
    $contacts ||= $data->{'contacts'};
256
    if ($contacts) {
257
        $contacts->[0] = C4::Bookseller::Contact->new( $contacts->[0] )
258
          unless ref $contacts->[0] eq 'C4::Bookseller::Contact';
259
        $contacts->[0]->bookseller($data->{'id'});
260
        $contacts->[0]->save();
261
    }
256
    return;
262
    return;
257
}
263
}
258
264
(-)a/C4/Bookseller/Contact.pm (+177 lines)
Line 0 Link Here
1
package C4::Bookseller::Contact;
2
3
# Copyright 2013 C & P Bibliography Services
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
=head1 NAME
21
22
C4::Bookseller::Contact - object class for contacts associated with vendors
23
24
=head1 SYNPOSIS
25
26
This class provides an object-oriented interface for handling vendor contacts.
27
It uses Class::Accessor to provide access to the following fields:
28
29
=head1 FIELDS
30
31
=over 8
32
33
=item id
34
35
ID of the contact. This is not used initially, since contacts are actually
36
stored in the aqbooksellers table.
37
38
=item name
39
40
Contact name.
41
42
=item position
43
44
Contact's position.
45
46
=item phone
47
48
Contact's primary phone number.
49
50
=item altphone
51
52
Contact's alternate phone number.
53
54
=item fax
55
56
Contact's fax number.
57
58
=item email
59
60
Contact's e-mail address.
61
62
=item notes
63
64
Notes about contact.
65
66
=item primary
67
68
Flag to indicate whether a contact is "primary" or not. Initially unused since
69
each bookseller can have only one contact.
70
71
=item bookseller
72
73
ID of the bookseller the contact is associated with.
74
75
=back
76
77
=cut
78
79
use Modern::Perl;
80
use C4::Context;
81
82
use base qw(Class::Accessor);
83
84
__PACKAGE__->mk_accessors(qw(id name position phone altphone fax email notes primary bookseller));
85
86
=head1 METHODS
87
88
=head2 get_from_bookseller
89
90
    my @contacts = @{C4::Bookseller::Contact->get_from_bookseller($booksellerid)};
91
92
Returns a reference to an array of C4::Bookseller::Contact objects for the
93
specified bookseller.
94
95
=cut
96
97
sub get_from_bookseller {
98
    my ($class, $bookseller) = @_;
99
100
    return unless $bookseller;
101
102
    my @contacts;
103
    my $query = "SELECT contact AS name, contpos AS position, contphone AS phone, contaltphone AS altphone, contfax AS fax, contemail AS email, contnotes AS notes, id AS bookseller FROM aqbooksellers WHERE id = ?";
104
    # When we have our own table, we can use: my $query = "SELECT * FROM aqcontacts WHERE bookseller = ?";
105
    my $dbh = C4::Context->dbh;
106
    my $sth = $dbh->prepare($query);
107
    $sth->execute($bookseller);
108
    while (my $rec = $sth->fetchrow_hashref()) {
109
        $rec->{'primary'} = 1;
110
        push @contacts, $class->new($rec);
111
    }
112
113
    return \@contacts;
114
}
115
116
117
=head2 fetch
118
119
    my $contact = C4::Bookseller::Contact->fetch($contactid);
120
121
Retrieves the specified contact from the database. Currently commented out
122
because there is no separate table from which contacts can be fetched.
123
124
=cut
125
126
#sub fetch {
127
#    my ($class, $id) = @_;
128
#
129
#    my $rec = { };
130
#    if ($id) {
131
#        my $query = "SELECT * FROM aqcontacts WHERE id = ?";
132
#        my $dbh = C4::Context->dbh;
133
#        my $sth = $dbh->prepare($query);
134
#        $sth->execute($id);
135
#        $rec = $sth->fetchrow_hashref();
136
#    }
137
#    my $self = $class->SUPER::new($rec);
138
#    bless $self, $class;
139
#    return $self;
140
#}
141
142
=head2 save
143
144
    $contact->save();
145
146
Save a contact to the database.
147
148
=cut
149
150
sub save {
151
    my ($self) = @_;
152
153
    my $query;
154
#    if ($self->id) {
155
#        $query = 'UPDATE aqcontacts SET name = ?, position = ?, phone = ?, altphone = ?, fax = ?, email = ?, notes = ?, primary = ? WHERE id = ?;';
156
#    } else {
157
#        $query = 'INSERT INTO aqcontacts (name, position, phone, altphone, fax, email, notes, primary) VALUES (?, ?, ?, ?, ? ,? ,?, ?);';
158
#    }
159
    if ($self->bookseller) {
160
        $query = 'UPDATE aqbooksellers SET contact = ?, contpos = ?, contphone = ?, contaltphone = ?, contfax = ?, contemail = ?, contnotes = ? WHERE id = ?;';
161
    } else {
162
        return;
163
    }
164
    my $dbh = C4::Context->dbh;
165
    my $sth = $dbh->prepare($query);
166
    $sth->execute($self->name, $self->position, $self->phone, $self->altphone, $self->fax, $self->email, $self->notes, $self->bookseller);
167
    #$self->id = $dbh->last_insert_id(undef, undef, 'aqcontacts', undef);
168
    return $self->bookseller;
169
}
170
171
=head1 AUTHOR
172
173
Jared Camins-Esakov <jcamins@cpbibliography.com>
174
175
=cut
176
177
1;
(-)a/acqui/supplier.pl (-53 / +10 lines)
Lines 49-62 use C4::Output; Link Here
49
use CGI;
49
use CGI;
50
50
51
use C4::Bookseller qw( GetBookSellerFromId DelBookseller );
51
use C4::Bookseller qw( GetBookSellerFromId DelBookseller );
52
use C4::Bookseller::Contact;
52
use C4::Budgets;
53
use C4::Budgets;
53
54
54
my $query    = CGI->new;
55
my $query    = CGI->new;
55
my $booksellerid       = $query->param('booksellerid');
56
my $supplier = {};
57
if ($booksellerid) {
58
    $supplier = GetBookSellerFromId($booksellerid);
59
}
60
my $op = $query->param('op') || 'display';
56
my $op = $query->param('op') || 'display';
61
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
57
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
62
    {   template_name   => 'acqui/supplier.tmpl',
58
    {   template_name   => 'acqui/supplier.tmpl',
Lines 67-72 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
67
        debug           => 1,
63
        debug           => 1,
68
    }
64
    }
69
);
65
);
66
my $booksellerid       = $query->param('booksellerid');
67
my $supplier = {};
68
if ($booksellerid) {
69
    $supplier = GetBookSellerFromId($booksellerid);
70
    foreach ( keys $supplier ) {
71
        $template->{'VARS'}->{$_} = $supplier->{$_};
72
    }
73
    $template->{'VARS'}->{'booksellerid'} = $booksellerid;
74
}
70
75
71
#build array for currencies
76
#build array for currencies
72
if ( $op eq 'display' ) {
77
if ( $op eq 'display' ) {
Lines 74-105 if ( $op eq 'display' ) { Link Here
74
    my $contracts = GetContract( { booksellerid => $booksellerid } );
79
    my $contracts = GetContract( { booksellerid => $booksellerid } );
75
80
76
    $template->param(
81
    $template->param(
77
        booksellerid  => $booksellerid,
78
        name          => $supplier->{'name'},
79
        postal        => $supplier->{'postal'},
80
        address1      => $supplier->{'address1'},
81
        address2      => $supplier->{'address2'},
82
        address3      => $supplier->{'address3'},
83
        address4      => $supplier->{'address4'},
84
        phone         => $supplier->{'phone'},
85
        accountnumber => $supplier->{'accountnumber'},
86
        fax           => $supplier->{'fax'},
87
        url           => $supplier->{'url'},
88
        contact       => $supplier->{'contact'},
89
        contpos       => $supplier->{'contpos'},
90
        contphone     => $supplier->{'contphone'},
91
        contaltphone  => $supplier->{'contaltphone'},
92
        contfax       => $supplier->{'contfax'},
93
        contemail     => $supplier->{'contemail'},
94
        contnotes     => $supplier->{'contnotes'},
95
        notes         => $supplier->{'notes'},
96
        active        => $supplier->{'active'},
82
        active        => $supplier->{'active'},
97
        gstreg        => $supplier->{'gstreg'},
98
        listincgst    => $supplier->{'listincgst'},
99
        invoiceincgst => $supplier->{'invoiceincgst'},
100
        gstrate       => $supplier->{'gstrate'} + 0.0,
83
        gstrate       => $supplier->{'gstrate'} + 0.0,
101
        discount      => $supplier->{'discount'},
102
        deliverytime  => $supplier->{deliverytime},
103
        invoiceprice  => $supplier->{'invoiceprice'},
84
        invoiceprice  => $supplier->{'invoiceprice'},
104
        listprice     => $supplier->{'listprice'},
85
        listprice     => $supplier->{'listprice'},
105
        basketcount   => $supplier->{'basketcount'},
86
        basketcount   => $supplier->{'basketcount'},
Lines 141-174 if ( $op eq 'display' ) { Link Here
141
    }, split( '\|', C4::Context->preference("gist") );
122
    }, split( '\|', C4::Context->preference("gist") );
142
123
143
    $template->param(
124
    $template->param(
144
        booksellerid => $booksellerid,
145
        name         => $supplier->{'name'},
146
        postal       => $supplier->{'postal'},
147
        address1     => $supplier->{'address1'},
148
        address2     => $supplier->{'address2'},
149
        address3     => $supplier->{'address3'},
150
        address4     => $supplier->{'address4'},
151
        phone        => $supplier->{'phone'},
152
        accountnumber=> $supplier->{'accountnumber'},
153
        fax          => $supplier->{'fax'},
154
        url          => $supplier->{'url'},
155
        contact      => $supplier->{'contact'},
156
        contpos      => $supplier->{'contpos'},
157
        contphone    => $supplier->{'contphone'},
158
        contaltphone => $supplier->{'contaltphone'},
159
        contfax      => $supplier->{'contfax'},
160
        contemail    => $supplier->{'contemail'},
161
        contnotes    => $supplier->{'contnotes'},
162
        notes        => $supplier->{'notes'},
163
        # set active ON by default for supplier add (id empty for add)
125
        # set active ON by default for supplier add (id empty for add)
164
        active       => $booksellerid ? $supplier->{'active'} : 1,
126
        active       => $booksellerid ? $supplier->{'active'} : 1,
165
        gstreg        => $supplier->{'gstreg'},
166
        listincgst    => $supplier->{'listincgst'},
167
        invoiceincgst => $supplier->{'invoiceincgst'},
168
        gstrate       => $supplier->{gstrate} ? $supplier->{'gstrate'}+0.0 : 0,
127
        gstrate       => $supplier->{gstrate} ? $supplier->{'gstrate'}+0.0 : 0,
169
        gst_values    => \@gst_values,
128
        gst_values    => \@gst_values,
170
        discount      => $supplier->{'discount'},
171
        deliverytime  => $supplier->{deliverytime},
172
        loop_currency => $loop_currency,
129
        loop_currency => $loop_currency,
173
        enter         => 1,
130
        enter         => 1,
174
    );
131
    );
(-)a/acqui/uncertainprice.pl (-7 / +2 lines)
Lines 52-57 use C4::Output; Link Here
52
use CGI;
52
use CGI;
53
53
54
use C4::Bookseller qw/GetBookSellerFromId/;
54
use C4::Bookseller qw/GetBookSellerFromId/;
55
use C4::Bookseller::Contact;
55
use C4::Acquisition qw/GetPendingOrders GetOrder ModOrder/;
56
use C4::Acquisition qw/GetPendingOrders GetOrder ModOrder/;
56
use C4::Biblio qw/GetBiblioData/;
57
use C4::Biblio qw/GetBiblioData/;
57
58
Lines 119-134 $template->param( uncertainpriceorders => \@orders, Link Here
119
                                   booksellerphone =>$bookseller->{'phone'},
120
                                   booksellerphone =>$bookseller->{'phone'},
120
                                   booksellerfax => $bookseller->{'fax'},
121
                                   booksellerfax => $bookseller->{'fax'},
121
                                   booksellerurl => $bookseller->{'url'},
122
                                   booksellerurl => $bookseller->{'url'},
122
                                   booksellercontact => $bookseller->{'contact'},
123
                                   booksellercontpos => $bookseller->{'contpos'},
124
                                   booksellercontphone => $bookseller->{'contphone'},
125
                                   booksellercontaltphone => $bookseller->{'contaltphone'},
126
                                   booksellercontfax => $bookseller->{'contfax'},
127
                                   booksellercontemail => $bookseller->{'contemail'},
128
                                   booksellercontnotes => $bookseller->{'contnotes'},
129
                                   booksellernotes => $bookseller->{'notes'},
123
                                   booksellernotes => $bookseller->{'notes'},
130
                                   basketcount   => $bookseller->{'basketcount'},
124
                                   basketcount   => $bookseller->{'basketcount'},
131
                                   subscriptioncount   => $bookseller->{'subscriptioncount'},
125
                                   subscriptioncount   => $bookseller->{'subscriptioncount'},
132
                                   owner => $owner,
126
                                   owner => $owner,
133
                                   scriptname => "/cgi-bin/koha/acqui/uncertainprice.pl");
127
                                   scriptname => "/cgi-bin/koha/acqui/uncertainprice.pl");
128
$template->{'VARS'}->{'contacts'} = $bookseller->{'contacts'};
134
output_html_with_http_headers $input, $cookie, $template->output;
129
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/acqui/updatesupplier.pl (-13 / +23 lines)
Lines 45-55 list_currency, gst, list_gst, invoice_gst, discount, gstrate. Link Here
45
=cut
45
=cut
46
46
47
use strict;
47
use strict;
48
#use warnings; FIXME - Bug 2505
48
use warnings;
49
use List::Util;
49
use C4::Context;
50
use C4::Context;
50
use C4::Auth;
51
use C4::Auth;
51
52
52
use C4::Bookseller qw( ModBookseller AddBookseller );
53
use C4::Bookseller qw( ModBookseller AddBookseller );
54
use C4::Bookseller::Contact;
53
use C4::Biblio;
55
use C4::Biblio;
54
use C4::Output;
56
use C4::Output;
55
use CGI;
57
use CGI;
Lines 83-95 $data{'phone'}=$input->param('company_phone'); Link Here
83
$data{'accountnumber'}=$input->param('accountnumber');
85
$data{'accountnumber'}=$input->param('accountnumber');
84
$data{'fax'}=$input->param('company_fax');
86
$data{'fax'}=$input->param('company_fax');
85
$data{'url'}=$input->param('website');
87
$data{'url'}=$input->param('website');
86
$data{'contact'}=$input->param('company_contact_name');
87
$data{'contpos'}=$input->param('company_contact_position');
88
$data{'contphone'}=$input->param('contact_phone');
89
$data{'contaltphone'}=$input->param('contact_phone_2');
90
$data{'contfax'}=$input->param('contact_fax');
91
$data{'contemail'}=$input->param('company_email');
92
$data{'contnotes'}=$input->param('contact_notes');
93
# warn "".$data{'contnotes'};
88
# warn "".$data{'contnotes'};
94
$data{'notes'}=$input->param('notes');
89
$data{'notes'}=$input->param('notes');
95
$data{'active'}=$input->param('status');
90
$data{'active'}=$input->param('status');
Lines 104-117 $data{'gstrate'} = $input->param('gstrate'); Link Here
104
$data{'discount'} = $input->param('discount');
99
$data{'discount'} = $input->param('discount');
105
$data{deliverytime} = $input->param('deliverytime');
100
$data{deliverytime} = $input->param('deliverytime');
106
$data{'active'}=$input->param('status');
101
$data{'active'}=$input->param('status');
102
my @contacts;
103
my %contact_info;
104
105
foreach (qw(id name position phone altphone fax email notes)) {
106
    $contact_info{$_} = [ $input->param('contact_' . $_) ];
107
}
108
109
for my $cnt (0..scalar(@{$contact_info{'id'}})) {
110
    my %contact;
111
    foreach (qw(id name position phone altphone fax email notes)) {
112
        $contact{$_} = $contact_info{$_}->[$cnt];
113
    }
114
    push @contacts, C4::Bookseller::Contact->new(\%contact);
115
}
116
107
if($data{'name'}) {
117
if($data{'name'}) {
108
	if ($data{'id'}){
118
	if ($data{'id'}){
109
	    ModBookseller(\%data);
119
        ModBookseller(\%data, \@contacts);
110
	} else {
120
	} else {
111
	    $data{id}=AddBookseller(\%data);
121
        $data{id}=AddBookseller(\%data, \@contacts);
112
	}
122
	}
113
#redirect to booksellers.pl
123
    #redirect to booksellers.pl
114
print $input->redirect("booksellers.pl?booksellerid=".$data{id});
124
    print $input->redirect("booksellers.pl?booksellerid=".$data{id});
115
} else {
125
} else {
116
print $input->redirect("supplier.pl?op=enter"); # fail silently.
126
    print $input->redirect("supplier.pl?op=enter"); # fail silently.
117
}
127
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css (+4 lines)
Lines 2043-2048 div#acqui_order_supplierlist > div.supplier > div.baskets { Link Here
2043
    margin-top: 0.5em;
2043
    margin-top: 0.5em;
2044
}
2044
}
2045
2045
2046
.supplier-contact-details {
2047
    float: left;
2048
}
2049
2046
/* Override core jQueryUI widgets */
2050
/* Override core jQueryUI widgets */
2047
.ui-widget-content { border: 1px solid #B9D8D9; background: #ffffff none; color: #222222; }
2051
.ui-widget-content { border: 1px solid #B9D8D9; background: #ffffff none; color: #222222; }
2048
.ui-widget-header { border: 1px solid #B9D8D9; background: #E6F0F2 none; color: #222222; font-weight: bold; }
2052
.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 (-31 / +47 lines)
Lines 1-4 Link Here
1
[% USE KohaDates %]
1
[% USE KohaDates %]
2
[% BLOCK edit_contact %]
3
    <ol id="contact-form">
4
        <input type="hidden" name="contact_id" value="[% contact.id %]" />
5
        <li><label for="contact_name">Contact name: </label>
6
            <input type="text" size="40" id="contact_name" name="contact_name" value="[% contact.name %]" /></li>
7
        <li><label for="contact_position">Position: </label>
8
            <input type="text" size="40" id="contact_position" name="contact_position" value="[% contact.position %]" /></li>
9
        <li><label for="contact_phone">Phone: </label>
10
                <input type="text" size="20" id="contact_phone" name="contact_phone" value="[% contact.phone %]" /> </li>
11
        <li><label for="contact_phone_2">Alternative phone: </label>
12
            <input type="text" size="20" id="contact_altphone" name="contact_altphone" value="[% contact.altphone %]" /></li>
13
        <li><label for="contact_fax">Fax: </label>
14
            <input type="text" size="20" id="contact_fax" name="contact_fax" value="[% contact.fax %]" /></li>
15
        <li><label for="contact_email">Email: </label>
16
            <input type="text" size="40" id="contact_email" name="contact_email" value="[% contact.email %]" /></li>
17
        <li><label for="contact_notes">Notes: </label>
18
            <textarea id="contact_notes" name="contact_notes" cols="40" rows="4">[% contnotes %]</textarea></li>
19
    </ol>
20
[% END %]
21
[% BLOCK show_contact %]
22
    <p><span class="label">Contact name: </span>[% contact.name %]</p>
23
    <p><span class="label">Position: </span>[% contact.position %]</p>
24
    <p><span class="label">Phone: </span>[% contact.phone %]</p>
25
    <p><span class="label">Alternative phone: </span>[% contact.altphone %]</p>
26
    <p><span class="label">Fax: </span>[% contact.fax %]</p>
27
    [% IF ( contact.email ) %]
28
        <p><span class="label">Email: </span><a href="mailto:[% contact.email %]">[% contact.email %]</a></p>
29
    [% END %]
30
    [% IF ( contact.notes ) %]
31
        <p><span class="label">Notes: </span>[% contact.notes %]</p>
32
    [% END %]
33
[% END %]
2
[% INCLUDE 'doc-head-open.inc' %]
34
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Vendor [% bookselname %]</title>
35
<title>Koha &rsaquo; Vendor [% bookselname %]</title>
4
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
36
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
Lines 22-27 if (f.company.value == "") { Link Here
22
    f.submit();
54
    f.submit();
23
}
55
}
24
56
57
function add_contact() {
58
}
59
25
 $(document).ready(function() {
60
 $(document).ready(function() {
26
    [% IF (dateformat == 'metric') %]
61
    [% IF (dateformat == 'metric') %]
27
        dt_add_type_uk_date();
62
        dt_add_type_uk_date();
Lines 82-104 if (f.company.value == "") { Link Here
82
            <li><label for="accountnumber">Account number: </label>
117
            <li><label for="accountnumber">Account number: </label>
83
                <input type="text" size="40" id="accountnumber" name="accountnumber" value="[% accountnumber %]" /></li></ol>
118
                <input type="text" size="40" id="accountnumber" name="accountnumber" value="[% accountnumber %]" /></li></ol>
84
        </fieldset>
119
        </fieldset>
85
        <fieldset class="rows">
120
        [% FOREACH contact IN contacts %]
86
            <legend>Contact details</legend>
121
            <fieldset class="supplier-contact rows">
87
        <ol> <li><label for="company_contact_name">Contact name: </label>
122
                <legend>Contact details</legend>
88
                <input type="text" size="40" id="company_contact_name" name="company_contact_name" value="[% contact %]" /></li>
123
                [% INCLUDE edit_contact %]
89
            <li><label for="company_contact_position">Position: </label>
124
            </fieldset>
90
                <input type="text" size="40" id="company_contact_position" name="company_contact_position" value="[% contpos %]" /></li>
125
        [% END %]
91
            <li><label for="contact_phone">Phone: </label>
92
                <input type="text" size="20" id="contact_phone" name="contact_phone" value="[% contphone %]" /> </li>
93
            <li><label for="contact_phone_2">Alternative phone: </label>
94
                <input type="text" size="20" id="contact_phone_2" name="contact_phone_2" value="[% contaltphone %]" /></li>
95
            <li><label for="contact_fax">Fax: </label>
96
                <input type="text" size="20" id="contact_fax" name="contact_fax" value="[% contfax %]" /></li>
97
            <li><label for="company_email">Email: </label>
98
                <input type="text" size="40" id="company_email" name="company_email" value="[% contemail %]" /></li>
99
            <li><label for="contact_notes">Notes: </label>
100
                <textarea id="contact_notes" name="contact_notes" cols="40" rows="4">[% contnotes %]</textarea></li></ol>
101
        </fieldset>
102
    </div>
126
    </div>
103
        <div class="yui-g">
127
        <div class="yui-g">
104
        <fieldset class="rows">
128
        <fieldset class="rows">
Lines 208-227 if (f.company.value == "") { Link Here
208
                    <p><span class="label">Account number: </span>[% accountnumber %]</p>
232
                    <p><span class="label">Account number: </span>[% accountnumber %]</p>
209
                [% END %]
233
                [% END %]
210
            </div>
234
            </div>
211
            <div id="supplier-contact-details" class="yui-u">
235
            [% FOREACH contact IN contacts %]
212
                <h2>Contact details</h2>
236
                <div class="supplier-contact-details yui-u">
213
                <p><span class="label">Contact name: </span>[% contact %]</p>
237
                    <h2>Contact details</h2>
214
                <p><span class="label">Position: </span>[% contpos %]</p>
238
                    [% INCLUDE show_contact %]
215
                <p><span class="label">Phone: </span>[% contphone %]</p>
239
                </div>
216
                <p><span class="label">Alternative phone: </span>[% contaltphone %]</p>
240
            [% END %]
217
                <p><span class="label">Fax: </span>[% contfax %]</p>
218
                [% IF ( contemail ) %]
219
                    <p><span class="label">Email: </span><a href="mailto:[% contemail %]">[% contemail %]</a></p>
220
                [% END %]
221
                [% IF ( contnotes ) %]
222
                    <p><span class="label">Notes: </span>[% contnotes %]</p>
223
                [% END %]
224
            </div>
225
        </div>
241
        </div>
226
        <div id="supplier-ordering-information" class="yui-g">
242
        <div id="supplier-ordering-information" class="yui-g">
227
        <h3>Ordering information</h3>
243
        <h3>Ordering information</h3>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/uncertainprice.tt (-8 / +10 lines)
Lines 58-71 function check(form) { Link Here
58
                [% booksellerphone %] / Fax:
58
                [% booksellerphone %] / Fax:
59
                [% booksellerfax %]</p>
59
                [% booksellerfax %]</p>
60
            <dl>
60
            <dl>
61
                <dt><strong>Contact: </strong></dt>
61
                [% FOREACH contact IN contacts %]
62
                <dd>[% booksellercontact %]
62
                    <dt><strong>Contact: </strong></dt>
63
                [% booksellercontpos %]
63
                    <dd>[% contact.name %]
64
                [% booksellercontphone %]
64
                        [% contact.position %]
65
                [% booksellercontaltphone %]
65
                        [% contact.phone %]
66
                [% booksellercontemail %]
66
                        [% contact.altphone %]
67
                [% booksellercontnotes %]
67
                        [% contact.email %]
68
                </dd>
68
                        [% contact.notes %]
69
                    </dd>
70
                [% END %]
69
            </dl>
71
            </dl>
70
            [% IF ( booksellernotes ) %]
72
            [% IF ( booksellernotes ) %]
71
            <p><strong>Notes: </strong>
73
            <p><strong>Notes: </strong>
(-)a/t/db_dependent/Bookseller.t (-1 / +68 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
use strict;
4
use warnings;
5
6
use Test::More tests => 12;
7
8
BEGIN {
9
    use_ok('C4::Bookseller');
10
}
11
12
my $booksellerid = C4::Bookseller::AddBookseller(
13
    {
14
        name     => "my vendor",
15
        address1 => "bookseller's address",
16
        phone    => "0123456",
17
        active   => 1
18
    },
19
    [ { name => 'John Smith', phone => '0123456x1' } ]
20
);
21
22
my @booksellers = C4::Bookseller::GetBookSeller('my vendor');
23
ok(
24
    (grep { $_->{'id'} == $booksellerid } @booksellers),
25
    'GetBookSeller returns correct record when passed a name'
26
);
27
28
my $bookseller = C4::Bookseller::GetBookSellerFromId($booksellerid);
29
is( $bookseller->{'id'}, $booksellerid, 'Retrieved desired record' );
30
is( $bookseller->{'phone'}, '0123456', 'New bookseller has expected phone' );
31
is( ref $bookseller->{'contacts'},
32
    'ARRAY', 'GetBookSellerFromId returns arrayref of contacts' );
33
is(
34
    ref $bookseller->{'contacts'}->[0],
35
    'C4::Bookseller::Contact',
36
    'First contact is a contact object'
37
);
38
is( $bookseller->{'contacts'}->[0]->phone,
39
    '0123456x1', 'Contact has expected phone number' );
40
41
$bookseller->{'name'} = 'your vendor';
42
$bookseller->{'contacts'}->[0]->phone('654321');
43
C4::Bookseller::ModBookseller($bookseller);
44
45
$bookseller = C4::Bookseller::GetBookSellerFromId($booksellerid);
46
is( $bookseller->{'name'}, 'your vendor',
47
    'Successfully changed name of vendor' );
48
is( $bookseller->{'contacts'}->[0]->phone,
49
    '654321',
50
    'Successfully changed contact phone number by modifying bookseller hash' );
51
52
C4::Bookseller::ModBookseller( $bookseller,
53
    [ { name => 'John Jacob Jingleheimer Schmidt' } ] );
54
55
$bookseller = C4::Bookseller::GetBookSellerFromId($booksellerid);
56
is(
57
    $bookseller->{'contacts'}->[0]->name,
58
    'John Jacob Jingleheimer Schmidt',
59
    'Changed name of contact'
60
);
61
is( $bookseller->{'contacts'}->[0]->phone,
62
    undef, 'Removed phone number from contact' );
63
64
END {
65
    C4::Bookseller::DelBookseller($booksellerid);
66
    is( C4::Bookseller::GetBookSellerFromId($booksellerid),
67
        undef, 'Bookseller successfully deleted' );
68
}

Return to bug 10402