#! /usr/bin/perl
# infocon - Administration tool for InfoCon
-# Copyright (c) 1998-2003,2005-8 Martin Schulze <joey@infodrom.org>
+# Copyright (c) 1998-2003,2005-8,10 Martin Schulze <joey@infodrom.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
if ($opt_year) {
if ($where) {
- $where .= " AND date ~* '$opt_year'";
+ $where .= " AND date LIKE '$opt_year%'";
} else {
- $where .= "date ~* '$opt_year'";
+ $where .= "date LIKE '$opt_year%'";
}
}
}
}
+ if ($where !~ /visible/) {
+ $where .= " AND " if $where;
+ $where .= "visible = 1";
+ }
+
$query = "SELECT nr,date,description,price FROM $table";
$query .= " WHERE $where" if ($where);
$query .= " ORDER by date,nr";
+
$sth = $dbh->prepare($query);
if ($sth && (my $rc = $sth->execute) > 0) {
print " Nr. Datum Bezeichnung Betrag\n";
'unpay' => undef,
'hide' => undef,
'unhide' => undef,
+ 'mailto' => undef,
'buchung-input' => undef,
'buchung-unpaid' => undef,
'buchung-hidden' => undef,
'hide=s' => \$data{hide},
'unhide=s' => \$data{unhide},
'year=i' => \$opt_year,
- 'direction=s' => \$opt_direction,
+ 'direction|d=s' => \$opt_direction,
+ 'mailto:s' => \$data{mailto},
'all' => \$opt_all,
'verbose' => \$opt_verbose,
'help' => \&usage,
'list-categories|lc' => \$data{'list-categories'},
);
+my $cmdln = 'infocon ' . join (' ', @ARGV);
GetOptions(%options);
if ($opt_year != 0 && $opt_year < 2002) {
usage unless $opt_direction =~ /^(in|out)$/i;
}
+if (defined $data{mailto}) {
+ if (open(STDOUT, "| /usr/sbin/sendmail -t")) {
+ print "From: Joey Schulze <joey\@infodrom.org>\n";
+ printf "To: %s\n", length($data{mailto})?$data{mailto}:'Joey Schulze <joey@infodrom.org>';
+ printf "Subject: %s\n", $cmdln;
+ print "MIME-Version: 1.0\n";
+ print "Content-type: text/plain; charset=iso-8859-1\n";
+ print "Content-Disposition: inline\n";
+ print "Content-Transfer-Encoding: 8bit\n";
+ print "\n";
+ }
+}
+
if (defined $data{category}) {
if (length($data{category})) {
sales_list("category = '".$data{category}."'");
} elsif (defined $data{'list-categories'}) {
list_categories;
} elsif (defined $data{pay}) {
- pay_invoce($data{pay}, 1);
+ pay_invoice($data{pay}, 1);
} elsif (defined $data{unpay}) {
- pay_invoce($data{unpay}, 0);
+ pay_invoice($data{unpay}, 0);
} elsif (defined $data{hide}) {
- hide_invoce($data{hide}, 1);
+ hide_invoice($data{hide}, 1);
} elsif (defined $data{unhide}) {
- hide_invoce($data{unhide}, 0);
+ hide_invoice($data{unhide}, 0);
+} else {
+ usage;
}
-
-usage;