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

(-)a/C4/Bookseller.pm (-37 / +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-237 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
    return unless $data->{'id'};
234
    return unless $data->{'id'};
230
    my $query  = 'UPDATE aqbooksellers
235
    my $query  = 'UPDATE aqbooksellers
231
        SET name=?,address1=?,address2=?,address3=?,address4=?,
236
        SET name=?,address1=?,address2=?,address3=?,address4=?,
232
            postal=?,phone=?,accountnumber=?,fax=?,url=?,contact=?,contpos=?,
237
            postal=?,phone=?,accountnumber=?,fax=?,url=?,
233
            contphone=?,contfax=?,contaltphone=?,contemail=?,
238
            active=?,listprice=?, invoiceprice=?,
234
            contnotes=?,active=?,listprice=?, invoiceprice=?,
235
            gstreg=?,listincgst=?,invoiceincgst=?,
239
            gstreg=?,listincgst=?,invoiceincgst=?,
236
            discount=?,notes=?,gstrate=?,deliverytime=?
240
            discount=?,notes=?,gstrate=?,deliverytime=?
237
        WHERE id=?';
241
        WHERE id=?';
Lines 241-259 sub ModBookseller { Link Here
241
        $data->{'address2'},     $data->{'address3'},
245
        $data->{'address2'},     $data->{'address3'},
242
        $data->{'address4'},     $data->{'postal'},
246
        $data->{'address4'},     $data->{'postal'},
243
        $data->{'phone'},        $data->{'accountnumber'},
247
        $data->{'phone'},        $data->{'accountnumber'},
244
        $data->{'fax'},
248
        $data->{'fax'},          $data->{'url'},
245
        $data->{'url'},          $data->{'contact'},
246
        $data->{'contpos'},      $data->{'contphone'},
247
        $data->{'contfax'},      $data->{'contaltphone'},
248
        $data->{'contemail'},    $data->{'contnotes'},
249
        $data->{'active'},       $data->{'listprice'},
249
        $data->{'active'},       $data->{'listprice'},
250
        $data->{'invoiceprice'}, $data->{'gstreg'},
250
        $data->{'invoiceprice'}, $data->{'gstreg'},
251
        $data->{'listincgst'},   $data->{'invoiceincgst'},
251
        $data->{'listincgst'},   $data->{'invoiceincgst'},
252
        $data->{'discount'},     $data->{'notes'},
252
        $data->{'discount'},     $data->{'notes'},
253
        $data->{'gstrate'},
253
        $data->{'gstrate'},      $data->{deliverytime},
254
        $data->{deliverytime},
255
        $data->{'id'}
254
        $data->{'id'}
256
    );
255
    );
256
    $contacts ||= $data->{'contacts'};
257
    if ($contacts) {
258
        $contacts->[0] = C4::Bookseller::Contact->new( $contacts->[0] )
259
          unless ref $contacts->[0] eq 'C4::Bookseller::Contact';
260
        $contacts->[0]->bookseller($data->{'id'});
261
        $contacts->[0]->save();
262
    }
263
    return;
257
}
264
}
258
265
259
=head2 DelBookseller
266
=head2 DelBookseller
(-)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 20-25 if (f.company.value == "") { Link Here
20
    f.submit();
52
    f.submit();
21
}
53
}
22
54
55
function add_contact() {
56
}
57
23
 $(document).ready(function() {
58
 $(document).ready(function() {
24
    [% IF (dateformat == 'metric') %]
59
    [% IF (dateformat == 'metric') %]
25
        dt_add_type_uk_date();
60
        dt_add_type_uk_date();
Lines 80-102 if (f.company.value == "") { Link Here
80
            <li><label for="accountnumber">Account number: </label>
115
            <li><label for="accountnumber">Account number: </label>
81
                <input type="text" size="40" id="accountnumber" name="accountnumber" value="[% accountnumber %]" /></li></ol>
116
                <input type="text" size="40" id="accountnumber" name="accountnumber" value="[% accountnumber %]" /></li></ol>
82
        </fieldset>
117
        </fieldset>
83
        <fieldset class="rows">
118
        [% FOREACH contact IN contacts %]
84
            <legend>Contact details</legend>
119
            <fieldset class="supplier-contact rows">
85
        <ol> <li><label for="company_contact_name">Contact name: </label>
120
                <legend>Contact details</legend>
86
                <input type="text" size="40" id="company_contact_name" name="company_contact_name" value="[% contact %]" /></li>
121
                [% INCLUDE edit_contact %]
87
            <li><label for="company_contact_position">Position: </label>
122
            </fieldset>
88
                <input type="text" size="40" id="company_contact_position" name="company_contact_position" value="[% contpos %]" /></li>
123
        [% END %]
89
            <li><label for="contact_phone">Phone: </label>
90
                <input type="text" size="20" id="contact_phone" name="contact_phone" value="[% contphone %]" /> </li>
91
            <li><label for="contact_phone_2">Alternative phone: </label>
92
                <input type="text" size="20" id="contact_phone_2" name="contact_phone_2" value="[% contaltphone %]" /></li>
93
            <li><label for="contact_fax">Fax: </label>
94
                <input type="text" size="20" id="contact_fax" name="contact_fax" value="[% contfax %]" /></li>
95
            <li><label for="company_email">Email: </label>
96
                <input type="text" size="40" id="company_email" name="company_email" value="[% contemail %]" /></li>
97
            <li><label for="contact_notes">Notes: </label>
98
                <textarea id="contact_notes" name="contact_notes" cols="40" rows="4">[% contnotes %]</textarea></li></ol>
99
        </fieldset>
100
    </div>
124
    </div>
101
        <div class="yui-g">
125
        <div class="yui-g">
102
        <fieldset class="rows">
126
        <fieldset class="rows">
Lines 206-225 if (f.company.value == "") { Link Here
206
                    <p><span class="label">Account number: </span>[% accountnumber %]</p>
230
                    <p><span class="label">Account number: </span>[% accountnumber %]</p>
207
                [% END %]
231
                [% END %]
208
            </div>
232
            </div>
209
            <div id="supplier-contact-details" class="yui-u">
233
            [% FOREACH contact IN contacts %]
210
                <h2>Contact details</h2>
234
                <div class="supplier-contact-details yui-u">
211
                <p><span class="label">Contact name: </span>[% contact %]</p>
235
                    <h2>Contact details</h2>
212
                <p><span class="label">Position: </span>[% contpos %]</p>
236
                    [% INCLUDE show_contact %]
213
                <p><span class="label">Phone: </span>[% contphone %]</p>
237
                </div>
214
                <p><span class="label">Alternative phone: </span>[% contaltphone %]</p>
238
            [% END %]
215
                <p><span class="label">Fax: </span>[% contfax %]</p>
216
                [% IF ( contemail ) %]
217
                    <p><span class="label">Email: </span><a href="mailto:[% contemail %]">[% contemail %]</a></p>
218
                [% END %]
219
                [% IF ( contnotes ) %]
220
                    <p><span class="label">Notes: </span>[% contnotes %]</p>
221
                [% END %]
222
            </div>
223
        </div>
239
        </div>
224
        <div id="supplier-ordering-information" class="yui-g">
240
        <div id="supplier-ordering-information" class="yui-g">
225
        <h3>Ordering information</h3>
241
        <h3>Ordering information</h3>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/uncertainprice.tt (-8 / +10 lines)
Lines 56-69 function check(form) { Link Here
56
                [% booksellerphone %] / Fax:
56
                [% booksellerphone %] / Fax:
57
                [% booksellerfax %]</p>
57
                [% booksellerfax %]</p>
58
            <dl>
58
            <dl>
59
                <dt><strong>Contact: </strong></dt>
59
                [% FOREACH contact IN contacts %]
60
                <dd>[% booksellercontact %]
60
                    <dt><strong>Contact: </strong></dt>
61
                [% booksellercontpos %]
61
                    <dd>[% contact.name %]
62
                [% booksellercontphone %]
62
                        [% contact.position %]
63
                [% booksellercontaltphone %]
63
                        [% contact.phone %]
64
                [% booksellercontemail %]
64
                        [% contact.altphone %]
65
                [% booksellercontnotes %]
65
                        [% contact.email %]
66
                </dd>
66
                        [% contact.notes %]
67
                    </dd>
68
                [% END %]
67
            </dl>
69
            </dl>
68
            [% IF ( booksellernotes ) %]
70
            [% IF ( booksellernotes ) %]
69
            <p><strong>Notes: </strong>
71
            <p><strong>Notes: </strong>
(-)a/t/db_dependent/Bookseller.t (-2 / +54 lines)
Lines 2-8 Link Here
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
4
5
use Test::More tests => 55;
5
use Test::More tests => 67;
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 666-671 ok( exists( $suppliers{$id_supplier1} ), Link Here
666
    "Supplier1 has late orders and $daysago10==$daysago10 " )
666
    "Supplier1 has late orders and $daysago10==$daysago10 " )
667
  ;
667
  ;
668
668
669
#Test contact editing
670
my $booksellerid = C4::Bookseller::AddBookseller(
671
    {
672
        name     => "my vendor",
673
        address1 => "bookseller's address",
674
        phone    => "0123456",
675
        active   => 1
676
    },
677
    [ { name => 'John Smith', phone => '0123456x1' } ]
678
);
679
680
my @booksellers = C4::Bookseller::GetBookSeller('my vendor');
681
ok(
682
    (grep { $_->{'id'} == $booksellerid } @booksellers),
683
    'GetBookSeller returns correct record when passed a name'
684
);
685
686
my $bookseller = C4::Bookseller::GetBookSellerFromId($booksellerid);
687
is( $bookseller->{'id'}, $booksellerid, 'Retrieved desired record' );
688
is( $bookseller->{'phone'}, '0123456', 'New bookseller has expected phone' );
689
is( ref $bookseller->{'contacts'},
690
    'ARRAY', 'GetBookSellerFromId returns arrayref of contacts' );
691
is(
692
    ref $bookseller->{'contacts'}->[0],
693
    'C4::Bookseller::Contact',
694
    'First contact is a contact object'
695
);
696
is( $bookseller->{'contacts'}->[0]->phone,
697
    '0123456x1', 'Contact has expected phone number' );
698
699
$bookseller->{'name'} = 'your vendor';
700
$bookseller->{'contacts'}->[0]->phone('654321');
701
C4::Bookseller::ModBookseller($bookseller);
702
703
$bookseller = C4::Bookseller::GetBookSellerFromId($booksellerid);
704
is( $bookseller->{'name'}, 'your vendor',
705
    'Successfully changed name of vendor' );
706
is( $bookseller->{'contacts'}->[0]->phone,
707
    '654321',
708
    'Successfully changed contact phone number by modifying bookseller hash' );
709
710
C4::Bookseller::ModBookseller( $bookseller,
711
    [ { name => 'John Jacob Jingleheimer Schmidt' } ] );
712
713
$bookseller = C4::Bookseller::GetBookSellerFromId($booksellerid);
714
is(
715
    $bookseller->{'contacts'}->[0]->name,
716
    'John Jacob Jingleheimer Schmidt',
717
    'Changed name of contact'
718
);
719
is( $bookseller->{'contacts'}->[0]->phone,
720
    undef, 'Removed phone number from contact' );
721
669
#End transaction
722
#End transaction
670
$dbh->rollback;
723
$dbh->rollback;
671
724
672
- 

Return to bug 10402