Improve work without category
[infodrom.org/service.infodrom.org] / src / InfoCon / buch / infocon
index b0d6961..c10413b 100755 (executable)
@@ -168,6 +168,11 @@ sub sales_list
        $where .= sprintf("year = %d", $opt_year);
     }
 
+    if (defined $data{category} && length $data{category}) {
+       $where .= " AND " if $where;
+       $where .= sprintf("category = %s", $dbh->quote($data{category}));
+    }
+
     if ($opt_direction) {
        if ($opt_direction eq "in") {
            $d = "price >= 0"
@@ -587,9 +592,9 @@ my %options = (
     'verbose' => \$opt_verbose,
     'help' => \&usage,
     'dm' => sub {$table = "sales_dm"},
-    'buchung-input|bi' => \$data{'buchung-input'},
-    'buchung-unpaid|bu' => \$data{'buchung-unpaid'},
-    'buchung-hidden|bh' => \$data{'buchung-hidden'},
+    'buchung-input|bi' => \&buchung_input,
+    'buchung-unpaid|bu' => \&buchung_unpaid,
+    'buchung-hidden|bh' => \&buchung_hidden,
     'list-categories|lc' => \$data{'list-categories'},
     );
 
@@ -618,18 +623,8 @@ if (defined $data{mailto}) {
 }
 
 if (defined $data{category}) {
-    if (length($data{category})) {
-       sales_list("category = '".$data{category}."'");
-    } else {
-       sales_list;
-    }
+    sales_list;
     exit;
-} elsif (defined $data{'buchung-input'}) {
-    buchung_input;
-} elsif (defined $data{'buchung-unpaid'}) {
-    buchung_unpaid;
-} elsif (defined $data{'buchung-hidden'}) {
-    buchung_hidden;
 } elsif (defined $data{'list-categories'}) {
     list_categories;
 } elsif (defined $data{pay}) {