|
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 |