. Changes required to support dm/eur currency where required.
[infodrom.org/service.infodrom.org] / src / InfoCon / buch / infocon
index 4af5f9d..8410a65 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/perl
 
 #  infocon - Admin-Tool for InfoCon
 #! /usr/bin/perl
 
 #  infocon - Admin-Tool for InfoCon
-#  Copyright (c) 1998-2001  Martin Schulze <joey@infodrom.org>
+#  Copyright (c) 1998-2002  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
 
 #  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
@@ -21,6 +21,7 @@
 
 use DBI;
 
 
 use DBI;
 
+$table = "sales";
 $engine  = "dbi:Pg:dbname=infocon";
 $dbh = DBI->connect($engine);
 if (!$dbh) {
 $engine  = "dbi:Pg:dbname=infocon";
 $dbh = DBI->connect($engine);
 if (!$dbh) {
@@ -119,7 +120,7 @@ sub sales_list
        }
     }
 
        }
     }
 
-    $query  = "SELECT nr,date,description,price FROM sales";
+    $query  = "SELECT nr,date,description,price FROM $table";
     $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);
@@ -153,7 +154,7 @@ sub get_categories
     my $sth;
     my @arr = ();
 
     my $sth;
     my @arr = ();
 
-    $query  = "SELECT DISTINCT category FROM sales ORDER by category";
+    $query  = "SELECT DISTINCT category FROM $table ORDER by category";
     $sth = $dbh->prepare($query);
     if ($sth && ($rc = $sth->execute) > 0) {
        while (@row = $sth->fetchrow_array) {
     $sth = $dbh->prepare($query);
     if ($sth && ($rc = $sth->execute) > 0) {
        while (@row = $sth->fetchrow_array) {
@@ -200,7 +201,7 @@ sub get_next_nr
     my $rc;
     my @row;
 
     my $rc;
     my @row;
 
-    $query = "SELECT nr FROM sales ORDER BY nr DESC";
+    $query = "SELECT nr FROM $table ORDER BY nr DESC";
     $sth = $dbh->prepare($query);
     if ($sth) {
        $rc = $sth->execute;
     $sth = $dbh->prepare($query);
     if ($sth) {
        $rc = $sth->execute;
@@ -266,6 +267,7 @@ sub usage
     print "    --verbose|-v\n";
     print "    --year|-y year\n";
     print "    --direction|--dir|-d in|out\n";
     print "    --verbose|-v\n";
     print "    --year|-y year\n";
     print "    --direction|--dir|-d in|out\n";
+    print "    --dm\n";
     exit 0;
 }
 
     exit 0;
 }
 
@@ -329,6 +331,11 @@ while ($i <= $#ARGV) {
            } elsif ($opt_year < 100) {
                $opt_year += 1900;
            }
            } elsif ($opt_year < 100) {
                $opt_year += 1900;
            }
+           if ($opt_year < 2002) {
+               $table = "sales_dm";
+           } elsif ($opt_year > 2001) {
+               $table = "sales";
+           }
        }
     } elsif ($ARGV[$i] eq "--direction" || $ARGV[$i] eq "--dir"
             || $ARGV[$i] eq "-d") {
        }
     } elsif ($ARGV[$i] eq "--direction" || $ARGV[$i] eq "--dir"
             || $ARGV[$i] eq "-d") {
@@ -336,6 +343,8 @@ while ($i <= $#ARGV) {
            $i++;
            $opt_direction = $1;
        }
            $i++;
            $opt_direction = $1;
        }
+    } elsif ($ARGV[$i] eq "--dm") {
+       $table = "sales_dm";
     } elsif ($ARGV[$i] eq "-v" || $ARGV[$i] eq "--verbose") {
        $opt_verbose = 1;
     }
     } elsif ($ARGV[$i] eq "-v" || $ARGV[$i] eq "--verbose") {
        $opt_verbose = 1;
     }