summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/RHRD/rddb.pm38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm
index 0074833..b1641ed 100755
--- a/lib/RHRD/rddb.pm
+++ b/lib/RHRD/rddb.pm
@@ -181,5 +181,43 @@ sub get_dropboxes
return @allowed_dbs;
}
+sub get_show_carts
+{
+ my ($dbh, $logname, $group_low_cart, $group_high_cart) = @_;
+
+ my $sql = qq{select LOG_EXISTS from LOGS where NAME = ?;};
+ my $sth = $dbh->prepare($sql)
+ or return (undef, 'ERROR', "Database Error: " . $dbh->errstr);
+
+ $sth->execute($logname)
+ or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
+
+ my $log_exists = $sth->fetchrow_array;
+ $sth->finish();
+
+ if(!defined $log_exists && $log_exists eq 'Y') {
+ return (undef, 'ERROR', "Log with name '$logname' does not exist")
+ }
+
+ $logname=~s/ /_/g;
+ $logname = $dbh->quote_identifier($logname . '_LOG');
+ $sql = qq{select COUNT,CART_NUMBER from $logname order by COUNT;};
+
+ $sth = $dbh->prepare($sql)
+ or return (undef, 'ERROR', "Database Error: " . $dbh->errstr);
+
+ $sth->execute()
+ or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
+
+ my @carts;
+ while(my ($count, $cart) = $sth->fetchrow_array()) {
+ if($cart >= $group_low_cart && $cart <= $group_high_cart) {
+ push @carts, $cart;
+ }
+ }
+ $sth->finish();
+
+ return @carts;
+}
return 1;