use base qw( Exporter );
# set the version for version checking
-our $VERSION = 4.01;
+our $VERSION = 3.07.00.049;
our @EXPORT_OK = qw(
GetBookSeller GetBooksellersWithLateOrders GetBookSellerFromId
ModBookseller
sub GetBookSeller {
my $searchstring = shift;
$searchstring = q{%} . $searchstring . q{%};
- my $query =
-'select aqbooksellers.*, count(*) as basketcount from aqbooksellers left join aqbasket '
- . 'on aqbasket.booksellerid = aqbooksellers.id where name like ? group by aqbooksellers.id order by name';
+ my $query = "
+ SELECT aqbooksellers.*, count(*) AS basketcount
+ FROM aqbooksellers
+ LEFT JOIN aqbasket ON aqbasket.booksellerid = aqbooksellers.id
+ WHERE name LIKE ? GROUP BY aqbooksellers.id ORDER BY name
+ ";
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare($query);
=head2 GetBooksellersWithLateOrders
-%results = GetBooksellersWithLateOrders($delay);
+%results = GetBooksellersWithLateOrders( $delay, $estimateddeliverydatefrom, $estimateddeliverydateto );
Searches for suppliers with late orders.
=cut
sub GetBooksellersWithLateOrders {
- my ( $delay, $branch, $estimateddeliverydatefrom, $estimateddeliverydateto ) = @_; # FIXME: Branch argument unused.
+ my ( $delay, $estimateddeliverydatefrom, $estimateddeliverydateto ) = @_;
my $dbh = C4::Context->dbh;
# FIXME NOT quite sure that this operation is valid for DBMs different from Mysql, HOPING so
)
AND aqorders.rrp <> 0
AND aqorders.ecost <> 0
- AND aqorders.quantity - IFNULL(aqorders.quantityreceived,0) <> 0
+ AND aqorders.quantity - COALESCE(aqorders.quantityreceived,0) <> 0
AND aqbasket.closedate IS NOT NULL
";
if ( defined $delay ) {
my $query = q|
INSERT INTO aqbooksellers
(
- name, address1, address2, address3, address4,
- postal, phone, accountnumber, fax, url,
- contact,
- contpos, contphone, contfax, contaltphone, contemail,
- contnotes, active, listprice, invoiceprice, gstreg,
- listincgst,invoiceincgst, gstrate, discount,
- notes
+ name, address1, address2, address3, address4,
+ postal, phone, accountnumber,fax, url,
+ contact, contpos, contphone, contfax, contaltphone,
+ contemail, contnotes, active, listprice, invoiceprice,
+ gstreg, listincgst, invoiceincgst,gstrate, discount,
+ notes, deliverytime
)
- VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) |
+ VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) |
;
my $sth = $dbh->prepare($query);
$sth->execute(
- $data->{'name'}, $data->{'address1'},
- $data->{'address2'}, $data->{'address3'},
- $data->{'address4'}, $data->{'postal'},
- $data->{'phone'}, $data->{'accountnumber'},
- $data->{'fax'},
- $data->{'url'}, $data->{'contact'},
- $data->{'contpos'}, $data->{'contphone'},
- $data->{'contfax'}, $data->{'contaltphone'},
- $data->{'contemail'}, $data->{'contnotes'},
- $data->{'active'}, $data->{'listprice'},
- $data->{'invoiceprice'}, $data->{'gstreg'},
- $data->{'listincgst'}, $data->{'invoiceincgst'},
- $data->{'gstrate'},
- $data->{'discount'}, $data->{'notes'}
+ $data->{name} ,$data->{address1},
+ $data->{address2} ,$data->{address3},
+ $data->{address4} ,$data->{postal},
+ $data->{phone} ,$data->{accountnumber},
+ $data->{fax},
+ $data->{url} ,$data->{contact},
+ $data->{contpos} ,$data->{contphone},
+ $data->{contfax} ,$data->{contaltphone},
+ $data->{contemail} ,$data->{contnotes},
+ $data->{active} ,$data->{listprice},
+ $data->{invoiceprice} ,$data->{gstreg},
+ $data->{listincgst} ,$data->{invoiceincgst},
+ $data->{gstrate} ,$data->{discount},
+ $data->{notes} ,$data->{deliverytime},
);
# return the id of this new supplier