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-189
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, |
183 |
active, listprice, invoiceprice, gstreg, |
181 |
contpos, contphone, contfax, contaltphone, contemail, |
184 |
listincgst,invoiceincgst, gstrate, discount, notes |
182 |
contnotes, active, listprice, invoiceprice, gstreg, |
|
|
183 |
listincgst,invoiceincgst, gstrate, discount, |
184 |
notes |
185 |
) |
185 |
) |
186 |
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) | |
186 |
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) | |
187 |
; |
187 |
; |
188 |
my $sth = $dbh->prepare($query); |
188 |
my $sth = $dbh->prepare($query); |
189 |
$sth->execute( |
189 |
$sth->execute( |
Lines 191-210
sub AddBookseller {
Link Here
|
191 |
$data->{'address2'}, $data->{'address3'}, |
191 |
$data->{'address2'}, $data->{'address3'}, |
192 |
$data->{'address4'}, $data->{'postal'}, |
192 |
$data->{'address4'}, $data->{'postal'}, |
193 |
$data->{'phone'}, $data->{'accountnumber'}, |
193 |
$data->{'phone'}, $data->{'accountnumber'}, |
194 |
$data->{'fax'}, |
194 |
$data->{'fax'}, $data->{'url'}, |
195 |
$data->{'url'}, $data->{'contact'}, |
|
|
196 |
$data->{'contpos'}, $data->{'contphone'}, |
197 |
$data->{'contfax'}, $data->{'contaltphone'}, |
198 |
$data->{'contemail'}, $data->{'contnotes'}, |
199 |
$data->{'active'}, $data->{'listprice'}, |
195 |
$data->{'active'}, $data->{'listprice'}, |
200 |
$data->{'invoiceprice'}, $data->{'gstreg'}, |
196 |
$data->{'invoiceprice'}, $data->{'gstreg'}, |
201 |
$data->{'listincgst'}, $data->{'invoiceincgst'}, |
197 |
$data->{'listincgst'}, $data->{'invoiceincgst'}, |
202 |
$data->{'gstrate'}, |
198 |
$data->{'gstrate'}, $data->{'discount'}, |
203 |
$data->{'discount'}, $data->{'notes'} |
199 |
$data->{'notes'} |
204 |
); |
200 |
); |
205 |
|
201 |
|
206 |
# return the id of this new supplier |
202 |
# return the id of this new supplier |
207 |
return $dbh->{'mysql_insertid'}; |
203 |
my $id = $dbh->{'mysql_insertid'}; |
|
|
204 |
if ($id && $contacts) { |
205 |
$contacts->[0] = C4::Bookseller::Contact->new( $contacts->[0] ) |
206 |
unless ref $contacts->[0] eq 'C4::Bookseller::Contact'; |
207 |
$contacts->[0]->bookseller($id); |
208 |
$contacts->[0]->save(); |
209 |
} |
210 |
return $id; |
208 |
} |
211 |
} |
209 |
|
212 |
|
210 |
#-----------------------------------------------------------------# |
213 |
#-----------------------------------------------------------------# |
Lines 225-237
C<&ModBookseller> with the result.
Link Here
|
225 |
=cut |
228 |
=cut |
226 |
|
229 |
|
227 |
sub ModBookseller { |
230 |
sub ModBookseller { |
228 |
my ($data) = @_; |
231 |
my ($data, $contacts) = @_; |
229 |
my $dbh = C4::Context->dbh; |
232 |
my $dbh = C4::Context->dbh; |
230 |
my $query = 'UPDATE aqbooksellers |
233 |
my $query = 'UPDATE aqbooksellers |
231 |
SET name=?,address1=?,address2=?,address3=?,address4=?, |
234 |
SET name=?,address1=?,address2=?,address3=?,address4=?, |
232 |
postal=?,phone=?,accountnumber=?,fax=?,url=?,contact=?,contpos=?, |
235 |
postal=?,phone=?,accountnumber=?,fax=?,url=?, |
233 |
contphone=?,contfax=?,contaltphone=?,contemail=?, |
236 |
active=?,listprice=?, invoiceprice=?, |
234 |
contnotes=?,active=?,listprice=?, invoiceprice=?, |
|
|
235 |
gstreg=?,listincgst=?,invoiceincgst=?, |
237 |
gstreg=?,listincgst=?,invoiceincgst=?, |
236 |
discount=?,notes=?,gstrate=?,deliverytime=? |
238 |
discount=?,notes=?,gstrate=?,deliverytime=? |
237 |
WHERE id=?'; |
239 |
WHERE id=?'; |
Lines 241-259
sub ModBookseller {
Link Here
|
241 |
$data->{'address2'}, $data->{'address3'}, |
243 |
$data->{'address2'}, $data->{'address3'}, |
242 |
$data->{'address4'}, $data->{'postal'}, |
244 |
$data->{'address4'}, $data->{'postal'}, |
243 |
$data->{'phone'}, $data->{'accountnumber'}, |
245 |
$data->{'phone'}, $data->{'accountnumber'}, |
244 |
$data->{'fax'}, |
246 |
$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'}, |
247 |
$data->{'active'}, $data->{'listprice'}, |
250 |
$data->{'invoiceprice'}, $data->{'gstreg'}, |
248 |
$data->{'invoiceprice'}, $data->{'gstreg'}, |
251 |
$data->{'listincgst'}, $data->{'invoiceincgst'}, |
249 |
$data->{'listincgst'}, $data->{'invoiceincgst'}, |
252 |
$data->{'discount'}, $data->{'notes'}, |
250 |
$data->{'discount'}, $data->{'notes'}, |
253 |
$data->{'gstrate'}, |
251 |
$data->{'gstrate'}, $data->{deliverytime}, |
254 |
$data->{deliverytime}, |
|
|
255 |
$data->{'id'} |
252 |
$data->{'id'} |
256 |
); |
253 |
); |
|
|
254 |
$contacts ||= $data->{'contacts'}; |
255 |
if ($contacts) { |
256 |
$contacts->[0] = C4::Bookseller::Contact->new( $contacts->[0] ) |
257 |
unless ref $contacts->[0] eq 'C4::Bookseller::Contact'; |
258 |
$contacts->[0]->bookseller($data->{'id'}); |
259 |
$contacts->[0]->save(); |
260 |
} |
257 |
return; |
261 |
return; |
258 |
} |
262 |
} |
259 |
|
263 |
|