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 176-215 Returns the ID of the newly-created bookseller. Link Here
176
=cut
179
=cut
177
180
178
sub AddBookseller {
181
sub AddBookseller {
179
    my ($data) = @_;
182
    my ($data, $contacts) = @_;
180
    my $dbh    = C4::Context->dbh;
183
    my $dbh    = C4::Context->dbh;
181
    my $query  = q|
184
    my $query = q|
182
        INSERT INTO aqbooksellers
185
        INSERT INTO aqbooksellers
183
            (
186
            (
184
                name,      address1,      address2,     address3,   address4,
187
                name,      address1,      address2,     address3, address4,
185
                postal,    phone,         accountnumber,fax,        url,
188
                postal,    phone,         accountnumber,fax,      url,
186
                contact,   contpos,       contphone,    contfax,    contaltphone,
189
                active,    listprice,     invoiceprice, gstreg,
187
                contemail, contnotes,     active,       listprice,  invoiceprice,
190
                listincgst,invoiceincgst, gstrate,      discount, notes,
188
                gstreg,    listincgst,    invoiceincgst,gstrate,    discount,
191
                deliverytime
189
                notes,     deliverytime
190
            )
192
            )
191
        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) |
193
        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) |
192
      ;
194
      ;
193
    my $sth = $dbh->prepare($query);
195
    my $sth = $dbh->prepare($query);
194
    $sth->execute(
196
    $sth->execute(
195
        $data->{name}         ,$data->{address1},
197
        $data->{'name'},         $data->{'address1'},
196
        $data->{address2}     ,$data->{address3},
198
        $data->{'address2'},     $data->{'address3'},
197
        $data->{address4}     ,$data->{postal},
199
        $data->{'address4'},     $data->{'postal'},
198
        $data->{phone}        ,$data->{accountnumber},
200
        $data->{'phone'},        $data->{'accountnumber'},
199
        $data->{fax},
201
        $data->{'fax'},          $data->{'url'},
200
        $data->{url}          ,$data->{contact},
202
        $data->{'active'},       $data->{'listprice'},
201
        $data->{contpos}      ,$data->{contphone},
203
        $data->{'invoiceprice'}, $data->{'gstreg'},
202
        $data->{contfax}      ,$data->{contaltphone},
204
        $data->{'listincgst'},   $data->{'invoiceincgst'},
203
        $data->{contemail}    ,$data->{contnotes},
205
        $data->{'gstrate'},      $data->{'discount'},
204
        $data->{active}       ,$data->{listprice},
206
        $data->{notes},          $data->{deliverytime},
205
        $data->{invoiceprice} ,$data->{gstreg},
206
        $data->{listincgst}   ,$data->{invoiceincgst},
207
        $data->{gstrate}      ,$data->{discount},
208
        $data->{notes}        ,$data->{deliverytime},
209
    );
207
    );
210
208
211
    # return the id of this new supplier
209
    # return the id of this new supplier
212
    return $dbh->{'mysql_insertid'};
210
    my $id = $dbh->{'mysql_insertid'};
211
    if ($id && $contacts) {
212
        $contacts->[0] = C4::Bookseller::Contact->new( $contacts->[0] )
213
          unless ref $contacts->[0] eq 'C4::Bookseller::Contact';
214
        $contacts->[0]->bookseller($id);
215
        $contacts->[0]->save();
216
    }
217
    return $id;
213
}
218
}
214
219
215
#-----------------------------------------------------------------#
220
#-----------------------------------------------------------------#
Lines 230-243 C<&ModBookseller> with the result. Link Here
230
=cut
235
=cut
231
236
232
sub ModBookseller {
237
sub ModBookseller {
233
    my ($data) = @_;
238
    my ($data, $contacts) = @_;
234
    my $dbh    = C4::Context->dbh;
239
    my $dbh    = C4::Context->dbh;
235
    return unless $data->{'id'};
240
    return unless $data->{'id'};
236
    my $query  = 'UPDATE aqbooksellers
241
    my $query  = 'UPDATE aqbooksellers
237
        SET name=?,address1=?,address2=?,address3=?,address4=?,
242
        SET name=?,address1=?,address2=?,address3=?,address4=?,
238
            postal=?,phone=?,accountnumber=?,fax=?,url=?,contact=?,contpos=?,
243
            postal=?,phone=?,accountnumber=?,fax=?,url=?,
239
            contphone=?,contfax=?,contaltphone=?,contemail=?,
244
            active=?,listprice=?, invoiceprice=?,
240
            contnotes=?,active=?,listprice=?, invoiceprice=?,
241
            gstreg=?,listincgst=?,invoiceincgst=?,
245
            gstreg=?,listincgst=?,invoiceincgst=?,
242
            discount=?,notes=?,gstrate=?,deliverytime=?
246
            discount=?,notes=?,gstrate=?,deliverytime=?
243
        WHERE id=?';
247
        WHERE id=?';
Lines 247-265 sub ModBookseller { Link Here
247
        $data->{'address2'},     $data->{'address3'},
251
        $data->{'address2'},     $data->{'address3'},
248
        $data->{'address4'},     $data->{'postal'},
252
        $data->{'address4'},     $data->{'postal'},
249
        $data->{'phone'},        $data->{'accountnumber'},
253
        $data->{'phone'},        $data->{'accountnumber'},
250
        $data->{'fax'},
254
        $data->{'fax'},          $data->{'url'},
251
        $data->{'url'},          $data->{'contact'},
252
        $data->{'contpos'},      $data->{'contphone'},
253
        $data->{'contfax'},      $data->{'contaltphone'},
254
        $data->{'contemail'},    $data->{'contnotes'},
255
        $data->{'active'},       $data->{'listprice'},
255
        $data->{'active'},       $data->{'listprice'},
256
        $data->{'invoiceprice'}, $data->{'gstreg'},
256
        $data->{'invoiceprice'}, $data->{'gstreg'},
257
        $data->{'listincgst'},   $data->{'invoiceincgst'},
257
        $data->{'listincgst'},   $data->{'invoiceincgst'},
258
        $data->{'discount'},     $data->{'notes'},
258
        $data->{'discount'},     $data->{'notes'},
259
        $data->{'gstrate'},
259
        $data->{'gstrate'},      $data->{deliverytime},
260
        $data->{deliverytime},
261
        $data->{'id'}
260
        $data->{'id'}
262
    );
261
    );
262
    $contacts ||= $data->{'contacts'};
263
    if ($contacts) {
264
        $contacts->[0] = C4::Bookseller::Contact->new( $contacts->[0] )
265
          unless ref $contacts->[0] eq 'C4::Bookseller::Contact';
266
        $contacts->[0]->bookseller($data->{'id'});
267
        $contacts->[0]->save();
268
    }
269
    return;
263
}
270
}
264
271
265
=head2 DelBookseller
272
=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/SearchOrders GetOrder ModOrder/;
56
use C4::Acquisition qw/SearchOrders GetOrder ModOrder/;
56
use C4::Biblio qw/GetBiblioData/;
57
use C4::Biblio qw/GetBiblioData/;
57
58
Lines 124-139 $template->param( uncertainpriceorders => \@orders, Link Here
124
                                   booksellerphone =>$bookseller->{'phone'},
125
                                   booksellerphone =>$bookseller->{'phone'},
125
                                   booksellerfax => $bookseller->{'fax'},
126
                                   booksellerfax => $bookseller->{'fax'},
126
                                   booksellerurl => $bookseller->{'url'},
127
                                   booksellerurl => $bookseller->{'url'},
127
                                   booksellercontact => $bookseller->{'contact'},
128
                                   booksellercontpos => $bookseller->{'contpos'},
129
                                   booksellercontphone => $bookseller->{'contphone'},
130
                                   booksellercontaltphone => $bookseller->{'contaltphone'},
131
                                   booksellercontfax => $bookseller->{'contfax'},
132
                                   booksellercontemail => $bookseller->{'contemail'},
133
                                   booksellercontnotes => $bookseller->{'contnotes'},
134
                                   booksellernotes => $bookseller->{'notes'},
128
                                   booksellernotes => $bookseller->{'notes'},
135
                                   basketcount   => $bookseller->{'basketcount'},
129
                                   basketcount   => $bookseller->{'basketcount'},
136
                                   subscriptioncount   => $bookseller->{'subscriptioncount'},
130
                                   subscriptioncount   => $bookseller->{'subscriptioncount'},
137
                                   owner => $owner,
131
                                   owner => $owner,
138
                                   scriptname => "/cgi-bin/koha/acqui/uncertainprice.pl");
132
                                   scriptname => "/cgi-bin/koha/acqui/uncertainprice.pl");
133
$template->{'VARS'}->{'contacts'} = $bookseller->{'contacts'};
139
output_html_with_http_headers $input, $cookie, $template->output;
134
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 2056-2061 div#acqui_order_supplierlist > div.supplier > div.baskets { Link Here
2056
    margin-top: 0.5em;
2056
    margin-top: 0.5em;
2057
}
2057
}
2058
2058
2059
.supplier-contact-details {
2060
    float: left;
2061
}
2062
2059
/* Override core jQueryUI widgets */
2063
/* Override core jQueryUI widgets */
2060
.ui-widget-content { border: 1px solid #B9D8D9; background: #ffffff none; color: #222222; }
2064
.ui-widget-content { border: 1px solid #B9D8D9; background: #ffffff none; color: #222222; }
2061
.ui-widget-header { border: 1px solid #B9D8D9; background: #E6F0F2 none; color: #222222; font-weight: bold; }
2065
.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 => 64;
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 650-655 ok( exists( $suppliers{$id_supplier1} ), Link Here
650
    "Supplier1 has late orders and $daysago10==$daysago10 " )
650
    "Supplier1 has late orders and $daysago10==$daysago10 " )
651
  ;
651
  ;
652
652
653
#Test contact editing
654
my $booksellerid = C4::Bookseller::AddBookseller(
655
    {
656
        name     => "my vendor",
657
        address1 => "bookseller's address",
658
        phone    => "0123456",
659
        active   => 1
660
    },
661
    [ { name => 'John Smith', phone => '0123456x1' } ]
662
);
663
664
my @booksellers = C4::Bookseller::GetBookSeller('my vendor');
665
ok(
666
    (grep { $_->{'id'} == $booksellerid } @booksellers),
667
    'GetBookSeller returns correct record when passed a name'
668
);
669
670
my $bookseller = C4::Bookseller::GetBookSellerFromId($booksellerid);
671
is( $bookseller->{'id'}, $booksellerid, 'Retrieved desired record' );
672
is( $bookseller->{'phone'}, '0123456', 'New bookseller has expected phone' );
673
is( ref $bookseller->{'contacts'},
674
    'ARRAY', 'GetBookSellerFromId returns arrayref of contacts' );
675
is(
676
    ref $bookseller->{'contacts'}->[0],
677
    'C4::Bookseller::Contact',
678
    'First contact is a contact object'
679
);
680
is( $bookseller->{'contacts'}->[0]->phone,
681
    '0123456x1', 'Contact has expected phone number' );
682
683
$bookseller->{'name'} = 'your vendor';
684
$bookseller->{'contacts'}->[0]->phone('654321');
685
C4::Bookseller::ModBookseller($bookseller);
686
687
$bookseller = C4::Bookseller::GetBookSellerFromId($booksellerid);
688
is( $bookseller->{'name'}, 'your vendor',
689
    'Successfully changed name of vendor' );
690
is( $bookseller->{'contacts'}->[0]->phone,
691
    '654321',
692
    'Successfully changed contact phone number by modifying bookseller hash' );
693
694
C4::Bookseller::ModBookseller( $bookseller,
695
    [ { name => 'John Jacob Jingleheimer Schmidt' } ] );
696
697
$bookseller = C4::Bookseller::GetBookSellerFromId($booksellerid);
698
is(
699
    $bookseller->{'contacts'}->[0]->name,
700
    'John Jacob Jingleheimer Schmidt',
701
    'Changed name of contact'
702
);
703
is( $bookseller->{'contacts'}->[0]->phone,
704
    undef, 'Removed phone number from contact' );
705
653
#End transaction
706
#End transaction
654
$dbh->rollback;
707
$dbh->rollback;
655
708
656
- 

Return to bug 10402