Lines 42-48
BEGIN {
Link Here
|
42 |
@ISA = qw(Exporter); |
42 |
@ISA = qw(Exporter); |
43 |
@EXPORT = qw( |
43 |
@EXPORT = qw( |
44 |
&GetBasket &NewBasket &CloseBasket &DelBasket &ModBasket |
44 |
&GetBasket &NewBasket &CloseBasket &DelBasket &ModBasket |
45 |
&GetBasketAsCSV |
45 |
&GetBasketAsCSV |
46 |
&GetBasketsByBookseller &GetBasketsByBasketgroup |
46 |
&GetBasketsByBookseller &GetBasketsByBasketgroup |
47 |
&GetBasketsInfosByBookseller |
47 |
&GetBasketsInfosByBookseller |
48 |
|
48 |
|
Lines 182-188
The other parameters are optional, see ModBasketHeader for more info on them.
Link Here
|
182 |
# FIXME : this function seems to be unused. |
182 |
# FIXME : this function seems to be unused. |
183 |
|
183 |
|
184 |
sub NewBasket { |
184 |
sub NewBasket { |
185 |
my ( $booksellerid, $authorisedby, $basketname, $basketnote, $basketbooksellernote, $basketcontractnumber ) = @_; |
185 |
my ( $booksellerid, $authorisedby, $basketname, $basketnote, $basketbooksellernote, $basketcontractnumber, $deliveryplace, $billingplace ) = @_; |
186 |
my $dbh = C4::Context->dbh; |
186 |
my $dbh = C4::Context->dbh; |
187 |
my $query = " |
187 |
my $query = " |
188 |
INSERT INTO aqbasket |
188 |
INSERT INTO aqbasket |
Lines 193-199
sub NewBasket {
Link Here
|
193 |
$dbh->do($query); |
193 |
$dbh->do($query); |
194 |
#find & return basketno MYSQL dependant, but $dbh->last_insert_id always returns null :-( |
194 |
#find & return basketno MYSQL dependant, but $dbh->last_insert_id always returns null :-( |
195 |
my $basket = $dbh->{'mysql_insertid'}; |
195 |
my $basket = $dbh->{'mysql_insertid'}; |
196 |
ModBasketHeader($basket, $basketname || '', $basketnote || '', $basketbooksellernote || '', $basketcontractnumber || undef); |
196 |
ModBasketHeader( $basket, $basketname || '', $basketnote || '', $basketbooksellernote || '', $basketcontractnumber || undef, $deliveryplace || undef, $billingplace || undef ); |
197 |
return $basket; |
197 |
return $basket; |
198 |
} |
198 |
} |
199 |
|
199 |
|
Lines 240-277
sub GetBasketAsCSV {
Link Here
|
240 |
# TODO: Translate headers |
240 |
# TODO: Translate headers |
241 |
my @headers = qw(contractname ordernumber entrydate isbn author title publishercode collectiontitle notes quantity rrp); |
241 |
my @headers = qw(contractname ordernumber entrydate isbn author title publishercode collectiontitle notes quantity rrp); |
242 |
|
242 |
|
243 |
$csv->combine(@headers); |
243 |
$csv->combine(@headers); |
244 |
$output = $csv->string() . "\n"; |
244 |
$output = $csv->string() . "\n"; |
245 |
|
245 |
|
246 |
my @rows; |
246 |
my @rows; |
247 |
foreach my $order (@orders) { |
247 |
foreach my $order (@orders) { |
248 |
my @cols; |
248 |
my @cols; |
249 |
# newlines are not valid characters for Text::CSV combine() |
249 |
# newlines are not valid characters for Text::CSV combine() |
250 |
$order->{'notes'} =~ s/[\r\n]+//g; |
250 |
$order->{'notes'} =~ s/[\r\n]+//g; |
251 |
push(@cols, |
251 |
push(@cols, |
252 |
$contract->{'contractname'}, |
252 |
$contract->{'contractname'}, |
253 |
$order->{'ordernumber'}, |
253 |
$order->{'ordernumber'}, |
254 |
$order->{'entrydate'}, |
254 |
$order->{'entrydate'}, |
255 |
$order->{'isbn'}, |
255 |
$order->{'isbn'}, |
256 |
$order->{'author'}, |
256 |
$order->{'author'}, |
257 |
$order->{'title'}, |
257 |
$order->{'title'}, |
258 |
$order->{'publishercode'}, |
258 |
$order->{'publishercode'}, |
259 |
$order->{'collectiontitle'}, |
259 |
$order->{'collectiontitle'}, |
260 |
$order->{'notes'}, |
260 |
$order->{'notes'}, |
261 |
$order->{'quantity'}, |
261 |
$order->{'quantity'}, |
262 |
$order->{'rrp'}, |
262 |
$order->{'rrp'}, |
263 |
); |
263 |
$basket->{'deliveryplace'}, |
264 |
push (@rows, \@cols); |
264 |
$basket->{'billingplace'}, |
|
|
265 |
); |
266 |
push (@rows, \@cols); |
265 |
} |
267 |
} |
266 |
|
268 |
|
267 |
foreach my $row (@rows) { |
269 |
foreach my $row (@rows) { |
268 |
$csv->combine(@$row); |
270 |
$csv->combine(@$row); |
269 |
$output .= $csv->string() . "\n"; |
271 |
$output .= $csv->string() . "\n"; |
270 |
|
|
|
271 |
} |
272 |
} |
272 |
|
|
|
273 |
return $output; |
274 |
|
273 |
|
|
|
274 |
return $output; |
275 |
} |
275 |
} |
276 |
|
276 |
|
277 |
|
277 |
|
Lines 385-391
sub ModBasket {
Link Here
|
385 |
|
385 |
|
386 |
=head3 ModBasketHeader |
386 |
=head3 ModBasketHeader |
387 |
|
387 |
|
388 |
&ModBasketHeader($basketno, $basketname, $note, $booksellernote, $contractnumber); |
388 |
&ModBasketHeader($basketno, $basketname, $note, $booksellernote, $contractnumber, $deliveryplace, $billingplace); |
389 |
|
389 |
|
390 |
Modifies a basket's header. |
390 |
Modifies a basket's header. |
391 |
|
391 |
|
Lines 401-416
Modifies a basket's header.
Link Here
|
401 |
|
401 |
|
402 |
=item C<$contractnumber> is the "contractnumber" (foreign) key in the "aqbasket" table. |
402 |
=item C<$contractnumber> is the "contractnumber" (foreign) key in the "aqbasket" table. |
403 |
|
403 |
|
|
|
404 |
=item C<$deliveryplace> is the "deliveryplace" field in the aqbasket table. |
405 |
|
406 |
=item C<$billingplace> is the "billingplace" field in the aqbasket table. |
407 |
|
404 |
=back |
408 |
=back |
405 |
|
409 |
|
406 |
=cut |
410 |
=cut |
407 |
|
411 |
|
408 |
sub ModBasketHeader { |
412 |
sub ModBasketHeader { |
409 |
my ($basketno, $basketname, $note, $booksellernote, $contractnumber) = @_; |
413 |
my ($basketno, $basketname, $note, $booksellernote, $contractnumber, $deliveryplace, $billingplace) = @_; |
410 |
my $query = "UPDATE aqbasket SET basketname=?, note=?, booksellernote=? WHERE basketno=?"; |
414 |
my $query = qq{ |
|
|
415 |
UPDATE aqbasket |
416 |
SET basketname=?, note=?, booksellernote=?, deliveryplace=?, billingplace=? |
417 |
WHERE basketno=? |
418 |
}; |
411 |
my $dbh = C4::Context->dbh; |
419 |
my $dbh = C4::Context->dbh; |
412 |
my $sth = $dbh->prepare($query); |
420 |
my $sth = $dbh->prepare($query); |
413 |
$sth->execute($basketname,$note,$booksellernote,$basketno); |
421 |
$sth->execute($basketname, $note, $booksellernote, $deliveryplace, $billingplace, $basketno); |
414 |
if ( $contractnumber ) { |
422 |
if ( $contractnumber ) { |
415 |
my $query2 ="UPDATE aqbasket SET contractnumber=? WHERE basketno=?"; |
423 |
my $query2 ="UPDATE aqbasket SET contractnumber=? WHERE basketno=?"; |
416 |
my $sth2 = $dbh->prepare($query2); |
424 |
my $sth2 = $dbh->prepare($query2); |