projects
/
infodrom.org
/
service.infodrom.org
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c7a75d1
)
use strict and warnings
author
Joey Schulze
<joey@infodrom.org>
Mon, 4 Feb 2008 08:48:47 +0000
(08:48 +0000)
committer
Joey Schulze
<joey@infodrom.org>
Mon, 4 Feb 2008 08:48:47 +0000
(08:48 +0000)
src/InfoCon/buch/infocon
patch
|
blob
|
history
diff --git
a/src/InfoCon/buch/infocon
b/src/InfoCon/buch/infocon
index
8534e2b
..
26f6faa
100755
(executable)
--- a/
src/InfoCon/buch/infocon
+++ b/
src/InfoCon/buch/infocon
@@
-19,19
+19,26
@@
# $Id$
# $Id$
+use strict;
+use warnings;
+
use DBI;
use Term::ReadLine;
use DBI;
use Term::ReadLine;
-$table = "sales";
-$engine = "dbi:Pg:dbname=infocon";
-$dbh = DBI->connect($engine);
+
my
$table = "sales";
+
my
$engine = "dbi:Pg:dbname=infocon";
+
my
$dbh = DBI->connect($engine);
if (!$dbh) {
print "Access to database denied!\n";
return 1;
}
if (!$dbh) {
print "Access to database denied!\n";
return 1;
}
-@categories = ();
-$term = undef;
+my @categories = ();
+my $term = undef;
+my $opt_all = 0;
+my $opt_verbose = 0;
+my $opt_year = 0;
+my $opt_direction = undef;
sub sdate
{
sub sdate
{
@@
-44,9
+51,11
@@
sub sdate
#
sub date_to_string
{
#
sub date_to_string
{
+ my ($day,$mon,$year);
+
return "" if (!$_[0]);
return "" if (!$_[0]);
- ($date_sec,$date_min,$date_hour,$date_mday,$date_mon,$date_year,$date_wday,$date_isdst)
+
my
($date_sec,$date_min,$date_hour,$date_mday,$date_mon,$date_year,$date_wday,$date_isdst)
= localtime;
if ($_[0] eq "heute" || $_[0] eq "sofort" || $_[0] eq "pronto" || $_[0] eq "today" || $_[0] eq "now") {
= localtime;
if ($_[0] eq "heute" || $_[0] eq "sofort" || $_[0] eq "pronto" || $_[0] eq "today" || $_[0] eq "now") {
@@
-145,7
+154,7
@@
sub sales_list
$query .= " WHERE $where" if ($where);
$query .= " ORDER by date,nr";
$sth = $dbh->prepare($query);
$query .= " WHERE $where" if ($where);
$query .= " ORDER by date,nr";
$sth = $dbh->prepare($query);
- if ($sth && ($rc = $sth->execute) > 0) {
+ if ($sth && (
my
$rc = $sth->execute) > 0) {
print " Nr. Datum Bezeichnung Betrag\n";
print "------------------------------------------------------------------\n";
while (@row = $sth->fetchrow_array) {
print " Nr. Datum Bezeichnung Betrag\n";
print "------------------------------------------------------------------\n";
while (@row = $sth->fetchrow_array) {
@@
-180,7
+189,7
@@
sub get_descriptions
$query = sprintf("SELECT DISTINCT description FROM %s WHERE date LIKE '%d%%' ORDER by description",
$table, $date_year+1900);
$sth = $dbh->prepare($query);
$query = sprintf("SELECT DISTINCT description FROM %s WHERE date LIKE '%d%%' ORDER by description",
$table, $date_year+1900);
$sth = $dbh->prepare($query);
- if ($sth && ($rc = $sth->execute) > 0) {
+ if ($sth && (
my
$rc = $sth->execute) > 0) {
while (@row = $sth->fetchrow_array) {
push(@arr, $row[0]) if ($row[0]);
}
while (@row = $sth->fetchrow_array) {
push(@arr, $row[0]) if ($row[0]);
}
@@
-197,7
+206,7
@@
sub get_categories
$query = "SELECT DISTINCT category FROM $table ORDER by category";
$sth = $dbh->prepare($query);
$query = "SELECT DISTINCT category FROM $table ORDER by category";
$sth = $dbh->prepare($query);
- if ($sth && ($rc = $sth->execute) > 0) {
+ if ($sth && (
my
$rc = $sth->execute) > 0) {
while (@row = $sth->fetchrow_array) {
push(@arr, $row[0]) if ($row[0]);
}
while (@row = $sth->fetchrow_array) {
push(@arr, $row[0]) if ($row[0]);
}
@@
-260,6
+269,7
@@
sub buchung_input
my @input = ();
my $weiter = 'y';
my $i;
my @input = ();
my $weiter = 'y';
my $i;
+ my $ans;
my $query;
my ($date_sec,$date_min,$date_hour,$date_mday,$date_mon,$date_year,$date_wday,$date_isdst)
= localtime;
my $query;
my ($date_sec,$date_min,$date_hour,$date_mday,$date_mon,$date_year,$date_wday,$date_isdst)
= localtime;
@@
-274,7
+284,7
@@
sub buchung_input
my $attribs = $term->Attribs;
my $attribs = $term->Attribs;
- $sth = $dbh->prepare ("INSERT INTO $table VALUES (?,?,?,?,?,?,?,?,?)");
+
my
$sth = $dbh->prepare ("INSERT INTO $table VALUES (?,?,?,?,?,?,?,?,?)");
print "Buchungseingabe\n\n";
while ($weiter =~ /[JjYy1]/) {
print "Buchungseingabe\n\n";
while ($weiter =~ /[JjYy1]/) {
@@
-361,10
+371,7
@@
sub usage
exit 0;
}
exit 0;
}
-$i = 0;
-$opt_all = 0;
-$opt_verbose = 0;
-$opt_year = 0;
+my $i = 0;
usage unless @ARGV;
while ($i <= $#ARGV) {
# Some aliases
usage unless @ARGV;
while ($i <= $#ARGV) {
# Some aliases
@@
-399,21
+406,21
@@
while ($i <= $#ARGV) {
sales_list;
}
} elsif ($ARGV[$i] eq "hidden") {
sales_list;
}
} elsif ($ARGV[$i] eq "hidden") {
- $saved_table = $table;
+
my
$saved_table = $table;
$table = "sales_dm";
sales_list("visible = 0");
$table = "sales";
sales_list("visible = 0");
$table = "sales_dm";
sales_list("visible = 0");
$table = "sales";
sales_list("visible = 0");
- $table = $
table_saved
;
+ $table = $
saved_table
;
} elsif ($ARGV[$i] eq "input") {
buchung_input;
} elsif ($ARGV[$i] eq "unpaid") {
} elsif ($ARGV[$i] eq "input") {
buchung_input;
} elsif ($ARGV[$i] eq "unpaid") {
- $saved_table = $table;
+
my
$saved_table = $table;
$table = "sales_dm";
sales_list("paid = 0");
$table = "sales";
sales_list("paid = 0");
$table = "sales_dm";
sales_list("paid = 0");
$table = "sales";
sales_list("paid = 0");
- $table = $
table_saved
;
+ $table = $
saved_table
;
} else {
usage;
}
} else {
usage;
}