Lines 23-28
use warnings;
Link Here
|
23 |
|
23 |
|
24 |
use base qw( Exporter ); |
24 |
use base qw( Exporter ); |
25 |
|
25 |
|
|
|
26 |
use C4::Bookseller::Contact; |
27 |
|
26 |
# set the version for version checking |
28 |
# set the version for version checking |
27 |
our $VERSION = 3.07.00.049; |
29 |
our $VERSION = 3.07.00.049; |
28 |
our @EXPORT_OK = qw( |
30 |
our @EXPORT_OK = qw( |
Lines 52-59
a bookseller.
Link Here
|
52 |
|
54 |
|
53 |
@results = GetBookSeller($searchstring); |
55 |
@results = GetBookSeller($searchstring); |
54 |
|
56 |
|
55 |
Looks up a book seller. C<$searchstring> may be either a book seller |
57 |
Looks up a book seller. C<$searchstring> is a string to look for in the |
56 |
ID, or a string to look for in the book seller's name. |
58 |
book seller's name. |
57 |
|
59 |
|
58 |
C<@results> is an array of hash_refs whose keys are the fields of of the |
60 |
C<@results> is an array of hash_refs whose keys are the fields of of the |
59 |
aqbooksellers table in the Koha database. |
61 |
aqbooksellers table in the Koha database. |
Lines 90-95
sub GetBookSellerFromId {
Link Here
|
90 |
( $vendor->{subscriptioncount} ) = $dbh->selectrow_array( |
92 |
( $vendor->{subscriptioncount} ) = $dbh->selectrow_array( |
91 |
'SELECT count(*) FROM subscription WHERE aqbooksellerid = ?', |
93 |
'SELECT count(*) FROM subscription WHERE aqbooksellerid = ?', |
92 |
{}, $id ); |
94 |
{}, $id ); |
|
|
95 |
$vendor->{'contacts'} = C4::Bookseller::Contact->get_from_bookseller($id); |
93 |
} |
96 |
} |
94 |
return $vendor; |
97 |
return $vendor; |
95 |
} |
98 |
} |
Lines 170-209
Returns the ID of the newly-created bookseller.
Link Here
|
170 |
=cut |
173 |
=cut |
171 |
|
174 |
|
172 |
sub AddBookseller { |
175 |
sub AddBookseller { |
173 |
my ($data) = @_; |
176 |
my ($data, $contacts) = @_; |
174 |
my $dbh = C4::Context->dbh; |
177 |
my $dbh = C4::Context->dbh; |
175 |
my $query = q| |
178 |
my $query = q| |
176 |
INSERT INTO aqbooksellers |
179 |
INSERT INTO aqbooksellers |
177 |
( |
180 |
( |
178 |
name, address1, address2, address3, address4, |
181 |
name, address1, address2, address3, address4, |
179 |
postal, phone, accountnumber,fax, url, |
182 |
postal, phone, accountnumber,fax, url, |
180 |
contact, contpos, contphone, contfax, contaltphone, |
183 |
active, listprice, invoiceprice, gstreg, |
181 |
contemail, contnotes, active, listprice, invoiceprice, |
184 |
listincgst,invoiceincgst, gstrate, discount, notes, |
182 |
gstreg, listincgst, invoiceincgst,gstrate, discount, |
185 |
deliverytime |
183 |
notes, deliverytime |
|
|
184 |
) |
186 |
) |
185 |
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) | |
187 |
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) | |
186 |
; |
188 |
; |
187 |
my $sth = $dbh->prepare($query); |
189 |
my $sth = $dbh->prepare($query); |
188 |
$sth->execute( |
190 |
$sth->execute( |
189 |
$data->{name} ,$data->{address1}, |
191 |
$data->{'name'}, $data->{'address1'}, |
190 |
$data->{address2} ,$data->{address3}, |
192 |
$data->{'address2'}, $data->{'address3'}, |
191 |
$data->{address4} ,$data->{postal}, |
193 |
$data->{'address4'}, $data->{'postal'}, |
192 |
$data->{phone} ,$data->{accountnumber}, |
194 |
$data->{'phone'}, $data->{'accountnumber'}, |
193 |
$data->{fax}, |
195 |
$data->{'fax'}, $data->{'url'}, |
194 |
$data->{url} ,$data->{contact}, |
196 |
$data->{'active'}, $data->{'listprice'}, |
195 |
$data->{contpos} ,$data->{contphone}, |
197 |
$data->{'invoiceprice'}, $data->{'gstreg'}, |
196 |
$data->{contfax} ,$data->{contaltphone}, |
198 |
$data->{'listincgst'}, $data->{'invoiceincgst'}, |
197 |
$data->{contemail} ,$data->{contnotes}, |
199 |
$data->{'gstrate'}, $data->{'discount'}, |
198 |
$data->{active} ,$data->{listprice}, |
200 |
$data->{'notes'}, $data->{'deliverytime'} |
199 |
$data->{invoiceprice} ,$data->{gstreg}, |
|
|
200 |
$data->{listincgst} ,$data->{invoiceincgst}, |
201 |
$data->{gstrate} ,$data->{discount}, |
202 |
$data->{notes} ,$data->{deliverytime}, |
203 |
); |
201 |
); |
204 |
|
202 |
|
205 |
# return the id of this new supplier |
203 |
# return the id of this new supplier |
206 |
return $dbh->{'mysql_insertid'}; |
204 |
my $id = $dbh->{'mysql_insertid'}; |
|
|
205 |
if ($id && $contacts) { |
206 |
$contacts->[0] = C4::Bookseller::Contact->new( $contacts->[0] ) |
207 |
unless ref $contacts->[0] eq 'C4::Bookseller::Contact'; |
208 |
$contacts->[0]->bookseller($id); |
209 |
$contacts->[0]->save(); |
210 |
} |
211 |
return $id; |
207 |
} |
212 |
} |
208 |
|
213 |
|
209 |
#-----------------------------------------------------------------# |
214 |
#-----------------------------------------------------------------# |
Lines 224-236
C<&ModBookseller> with the result.
Link Here
|
224 |
=cut |
229 |
=cut |
225 |
|
230 |
|
226 |
sub ModBookseller { |
231 |
sub ModBookseller { |
227 |
my ($data) = @_; |
232 |
my ($data, $contacts) = @_; |
228 |
my $dbh = C4::Context->dbh; |
233 |
my $dbh = C4::Context->dbh; |
229 |
my $query = 'UPDATE aqbooksellers |
234 |
my $query = 'UPDATE aqbooksellers |
230 |
SET name=?,address1=?,address2=?,address3=?,address4=?, |
235 |
SET name=?,address1=?,address2=?,address3=?,address4=?, |
231 |
postal=?,phone=?,accountnumber=?,fax=?,url=?,contact=?,contpos=?, |
236 |
postal=?,phone=?,accountnumber=?,fax=?,url=?, |
232 |
contphone=?,contfax=?,contaltphone=?,contemail=?, |
237 |
active=?,listprice=?, invoiceprice=?, |
233 |
contnotes=?,active=?,listprice=?, invoiceprice=?, |
|
|
234 |
gstreg=?,listincgst=?,invoiceincgst=?, |
238 |
gstreg=?,listincgst=?,invoiceincgst=?, |
235 |
discount=?,notes=?,gstrate=?,deliverytime=? |
239 |
discount=?,notes=?,gstrate=?,deliverytime=? |
236 |
WHERE id=?'; |
240 |
WHERE id=?'; |
Lines 240-258
sub ModBookseller {
Link Here
|
240 |
$data->{'address2'}, $data->{'address3'}, |
244 |
$data->{'address2'}, $data->{'address3'}, |
241 |
$data->{'address4'}, $data->{'postal'}, |
245 |
$data->{'address4'}, $data->{'postal'}, |
242 |
$data->{'phone'}, $data->{'accountnumber'}, |
246 |
$data->{'phone'}, $data->{'accountnumber'}, |
243 |
$data->{'fax'}, |
247 |
$data->{'fax'}, $data->{'url'}, |
244 |
$data->{'url'}, $data->{'contact'}, |
|
|
245 |
$data->{'contpos'}, $data->{'contphone'}, |
246 |
$data->{'contfax'}, $data->{'contaltphone'}, |
247 |
$data->{'contemail'}, $data->{'contnotes'}, |
248 |
$data->{'active'}, $data->{'listprice'}, |
248 |
$data->{'active'}, $data->{'listprice'}, |
249 |
$data->{'invoiceprice'}, $data->{'gstreg'}, |
249 |
$data->{'invoiceprice'}, $data->{'gstreg'}, |
250 |
$data->{'listincgst'}, $data->{'invoiceincgst'}, |
250 |
$data->{'listincgst'}, $data->{'invoiceincgst'}, |
251 |
$data->{'discount'}, $data->{'notes'}, |
251 |
$data->{'discount'}, $data->{'notes'}, |
252 |
$data->{'gstrate'}, |
252 |
$data->{'gstrate'}, $data->{deliverytime}, |
253 |
$data->{deliverytime}, |
|
|
254 |
$data->{'id'} |
253 |
$data->{'id'} |
255 |
); |
254 |
); |
|
|
255 |
$contacts ||= $data->{'contacts'}; |
256 |
if ($contacts) { |
257 |
$contacts->[0] = C4::Bookseller::Contact->new( $contacts->[0] ) |
258 |
unless ref $contacts->[0] eq 'C4::Bookseller::Contact'; |
259 |
$contacts->[0]->bookseller($data->{'id'}); |
260 |
$contacts->[0]->save(); |
261 |
} |
256 |
return; |
262 |
return; |
257 |
} |
263 |
} |
258 |
|
264 |
|