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.tt',
58
    {   template_name   => 'acqui/supplier.tt',
Lines 67-104 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' ) {
73
    my $contracts = GetContracts( { booksellerid => $booksellerid } );
78
    my $contracts = GetContracts( { booksellerid => $booksellerid } );
74
79
75
    $template->param(
80
    $template->param(
76
        booksellerid  => $booksellerid,
77
        name          => $supplier->{'name'},
78
        postal        => $supplier->{'postal'},
79
        address1      => $supplier->{'address1'},
80
        address2      => $supplier->{'address2'},
81
        address3      => $supplier->{'address3'},
82
        address4      => $supplier->{'address4'},
83
        phone         => $supplier->{'phone'},
84
        accountnumber => $supplier->{'accountnumber'},
85
        fax           => $supplier->{'fax'},
86
        url           => $supplier->{'url'},
87
        contact       => $supplier->{'contact'},
88
        contpos       => $supplier->{'contpos'},
89
        contphone     => $supplier->{'contphone'},
90
        contaltphone  => $supplier->{'contaltphone'},
91
        contfax       => $supplier->{'contfax'},
92
        contemail     => $supplier->{'contemail'},
93
        contnotes     => $supplier->{'contnotes'},
94
        notes         => $supplier->{'notes'},
95
        active        => $supplier->{'active'},
81
        active        => $supplier->{'active'},
96
        gstreg        => $supplier->{'gstreg'},
97
        listincgst    => $supplier->{'listincgst'},
98
        invoiceincgst => $supplier->{'invoiceincgst'},
99
        gstrate       => $supplier->{'gstrate'} + 0.0,
82
        gstrate       => $supplier->{'gstrate'} + 0.0,
100
        discount      => $supplier->{'discount'},
101
        deliverytime  => $supplier->{deliverytime},
102
        invoiceprice  => $supplier->{'invoiceprice'},
83
        invoiceprice  => $supplier->{'invoiceprice'},
103
        listprice     => $supplier->{'listprice'},
84
        listprice     => $supplier->{'listprice'},
104
        basketcount   => $supplier->{'basketcount'},
85
        basketcount   => $supplier->{'basketcount'},
Lines 140-173 if ( $op eq 'display' ) { Link Here
140
    }, split( '\|', C4::Context->preference("gist") );
121
    }, split( '\|', C4::Context->preference("gist") );
141
122
142
    $template->param(
123
    $template->param(
143
        booksellerid => $booksellerid,
144
        name         => $supplier->{'name'},
145
        postal       => $supplier->{'postal'},
146
        address1     => $supplier->{'address1'},
147
        address2     => $supplier->{'address2'},
148
        address3     => $supplier->{'address3'},
149
        address4     => $supplier->{'address4'},
150
        phone        => $supplier->{'phone'},
151
        accountnumber=> $supplier->{'accountnumber'},
152
        fax          => $supplier->{'fax'},
153
        url          => $supplier->{'url'},
154
        contact      => $supplier->{'contact'},
155
        contpos      => $supplier->{'contpos'},
156
        contphone    => $supplier->{'contphone'},
157
        contaltphone => $supplier->{'contaltphone'},
158
        contfax      => $supplier->{'contfax'},
159
        contemail    => $supplier->{'contemail'},
160
        contnotes    => $supplier->{'contnotes'},
161
        notes        => $supplier->{'notes'},
162
        # set active ON by default for supplier add (id empty for add)
124
        # set active ON by default for supplier add (id empty for add)
163
        active       => $booksellerid ? $supplier->{'active'} : 1,
125
        active       => $booksellerid ? $supplier->{'active'} : 1,
164
        gstreg        => $supplier->{'gstreg'},
165
        listincgst    => $supplier->{'listincgst'},
166
        invoiceincgst => $supplier->{'invoiceincgst'},
167
        gstrate       => $supplier->{gstrate} ? $supplier->{'gstrate'}+0.0 : 0,
126
        gstrate       => $supplier->{gstrate} ? $supplier->{'gstrate'}+0.0 : 0,
168
        gst_values    => \@gst_values,
127
        gst_values    => \@gst_values,
169
        discount      => $supplier->{'discount'},
170
        deliverytime  => $supplier->{deliverytime},
171
        loop_currency => $loop_currency,
128
        loop_currency => $loop_currency,
172
        enter         => 1,
129
        enter         => 1,
173
    );
130
    );
(-)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 1962-1967 div#acqui_order_supplierlist > div.supplier > div.baskets { Link Here
1962
    margin-top: 0.5em;
1962
    margin-top: 0.5em;
1963
}
1963
}
1964
1964
1965
.supplier-contact-details {
1966
    float: left;
1967
}
1968
1965
/* Override core jQueryUI widgets */
1969
/* Override core jQueryUI widgets */
1966
.ui-widget-content { border: 1px solid #B9D8D9; background: #ffffff none; color: #222222; }
1970
.ui-widget-content { border: 1px solid #B9D8D9; background: #ffffff none; color: #222222; }
1967
.ui-widget-header { border: 1px solid #B9D8D9; background: #E6F0F2 none; color: #222222; font-weight: bold; }
1971
.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 13-18 function confirm_deletion() { Link Here
13
    }
45
    }
14
}
46
}
15
47
48
function add_contact() {
49
}
50
16
 $(document).ready(function() {
51
 $(document).ready(function() {
17
    var contractst = $("#contractst").dataTable($.extend(true, {}, dataTablesDefaults, {
52
    var contractst = $("#contractst").dataTable($.extend(true, {}, dataTablesDefaults, {
18
        "aoColumnDefs": [
53
        "aoColumnDefs": [
Lines 65-87 function confirm_deletion() { Link Here
65
            <li><label for="accountnumber">Account number: </label>
100
            <li><label for="accountnumber">Account number: </label>
66
                <input type="text" size="40" id="accountnumber" name="accountnumber" value="[% accountnumber %]" /></li></ol>
101
                <input type="text" size="40" id="accountnumber" name="accountnumber" value="[% accountnumber %]" /></li></ol>
67
        </fieldset>
102
        </fieldset>
68
        <fieldset class="rows">
103
        [% FOREACH contact IN contacts %]
69
            <legend>Contact details</legend>
104
            <fieldset class="supplier-contact rows">
70
        <ol> <li><label for="company_contact_name">Contact name: </label>
105
                <legend>Contact details</legend>
71
                <input type="text" size="40" id="company_contact_name" name="company_contact_name" value="[% contact %]" /></li>
106
                [% INCLUDE edit_contact %]
72
            <li><label for="company_contact_position">Position: </label>
107
            </fieldset>
73
                <input type="text" size="40" id="company_contact_position" name="company_contact_position" value="[% contpos %]" /></li>
108
        [% END %]
74
            <li><label for="contact_phone">Phone: </label>
75
                <input type="text" size="20" id="contact_phone" name="contact_phone" value="[% contphone %]" /> </li>
76
            <li><label for="contact_phone_2">Alternative phone: </label>
77
                <input type="text" size="20" id="contact_phone_2" name="contact_phone_2" value="[% contaltphone %]" /></li>
78
            <li><label for="contact_fax">Fax: </label>
79
                <input type="text" size="20" id="contact_fax" name="contact_fax" value="[% contfax %]" /></li>
80
            <li><label for="company_email">Email: </label>
81
                <input type="text" size="40" id="company_email" name="company_email" value="[% contemail %]" /></li>
82
            <li><label for="contact_notes">Notes: </label>
83
                <textarea id="contact_notes" name="contact_notes" cols="40" rows="4">[% contnotes %]</textarea></li></ol>
84
        </fieldset>
85
    </div>
109
    </div>
86
        <div class="yui-g">
110
        <div class="yui-g">
87
        <fieldset class="rows">
111
        <fieldset class="rows">
Lines 191-210 function confirm_deletion() { Link Here
191
                    <p><span class="label">Account number: </span>[% accountnumber %]</p>
215
                    <p><span class="label">Account number: </span>[% accountnumber %]</p>
192
                [% END %]
216
                [% END %]
193
            </div>
217
            </div>
194
            <div id="supplier-contact-details" class="yui-u">
218
            [% FOREACH contact IN contacts %]
195
                <h2>Contact details</h2>
219
                <div class="supplier-contact-details yui-u">
196
                <p><span class="label">Contact name: </span>[% contact %]</p>
220
                    <h2>Contact details</h2>
197
                <p><span class="label">Position: </span>[% contpos %]</p>
221
                    [% INCLUDE show_contact %]
198
                <p><span class="label">Phone: </span>[% contphone %]</p>
222
                </div>
199
                <p><span class="label">Alternative phone: </span>[% contaltphone %]</p>
223
            [% END %]
200
                <p><span class="label">Fax: </span>[% contfax %]</p>
201
                [% IF ( contemail ) %]
202
                    <p><span class="label">Email: </span><a href="mailto:[% contemail %]">[% contemail %]</a></p>
203
                [% END %]
204
                [% IF ( contnotes ) %]
205
                    <p><span class="label">Notes: </span>[% contnotes %]</p>
206
                [% END %]
207
            </div>
208
        </div>
224
        </div>
209
        <div id="supplier-ordering-information" class="yui-g">
225
        <div id="supplier-ordering-information" class="yui-g">
210
        <h3>Ordering information</h3>
226
        <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 (-1 / +52 lines)
Lines 702-707 is( Link Here
702
    3,
702
    3,
703
    'superlibrarian can see all subscriptions with IndependentBranches on (bug 12048)'
703
    'superlibrarian can see all subscriptions with IndependentBranches on (bug 12048)'
704
);
704
);
705
#Test contact editing
706
my $booksellerid = C4::Bookseller::AddBookseller(
707
    {
708
        name     => "my vendor",
709
        address1 => "bookseller's address",
710
        phone    => "0123456",
711
        active   => 1
712
    },
713
    [ { name => 'John Smith', phone => '0123456x1' } ]
714
);
715
716
my @booksellers = C4::Bookseller::GetBookSeller('my vendor');
717
ok(
718
    (grep { $_->{'id'} == $booksellerid } @booksellers),
719
    'GetBookSeller returns correct record when passed a name'
720
);
721
722
my $bookseller = C4::Bookseller::GetBookSellerFromId($booksellerid);
723
is( $bookseller->{'id'}, $booksellerid, 'Retrieved desired record' );
724
is( $bookseller->{'phone'}, '0123456', 'New bookseller has expected phone' );
725
is( ref $bookseller->{'contacts'},
726
    'ARRAY', 'GetBookSellerFromId returns arrayref of contacts' );
727
is(
728
    ref $bookseller->{'contacts'}->[0],
729
    'C4::Bookseller::Contact',
730
    'First contact is a contact object'
731
);
732
is( $bookseller->{'contacts'}->[0]->phone,
733
    '0123456x1', 'Contact has expected phone number' );
734
735
$bookseller->{'name'} = 'your vendor';
736
$bookseller->{'contacts'}->[0]->phone('654321');
737
C4::Bookseller::ModBookseller($bookseller);
738
739
$bookseller = C4::Bookseller::GetBookSellerFromId($booksellerid);
740
is( $bookseller->{'name'}, 'your vendor',
741
    'Successfully changed name of vendor' );
742
is( $bookseller->{'contacts'}->[0]->phone,
743
    '654321',
744
    'Successfully changed contact phone number by modifying bookseller hash' );
745
746
C4::Bookseller::ModBookseller( $bookseller,
747
    [ { name => 'John Jacob Jingleheimer Schmidt' } ] );
748
749
$bookseller = C4::Bookseller::GetBookSellerFromId($booksellerid);
750
is(
751
    $bookseller->{'contacts'}->[0]->name,
752
    'John Jacob Jingleheimer Schmidt',
753
    'Changed name of contact'
754
);
755
is( $bookseller->{'contacts'}->[0]->phone,
756
    undef, 'Removed phone number from contact' );
705
757
706
#End transaction
758
#End transaction
707
$dbh->rollback;
759
$dbh->rollback;
708
- 

Return to bug 10402