use DBI;
use Text::Wrap;
+# Some generic stuff for all LaTeX output files
+$latex_foot = '\end{document}';
+$latex_headline = '\centerline{\textbf{\large LinuxTag 2001 -- %s}}' . "\n\\vspace{2ex}";
+
$engine = "dbi:Pg:dbname=elt2k1;host=kuolema";
$dbh = DBI->connect($engine);
if (!$dbh) {
sub list
{
- my $query = "SELECT name,boothnr FROM project ORDER BY name";
+ my $query = "SELECT name,boothnr FROM project ";
my $sth;
my $rc;
my @row;
my $nr = 0;
+ $query .= " WHERE boothnr <> ''" if ($opt_onlybooth);
+ $query .= " ORDER BY name";
+
$sth = $dbh->prepare($query);
if ($sth && ($rc = $sth->execute) > 0) {
while (@row = $sth->fetchrow_array) {
my @row;
$query = "SELECT DISTINCT project.boothnr,appendix.boothtitle "
- . "FROM project,appendix WHERE project.name = appendix.project ORDER BY boothnr,boothtitle";
+ . "FROM project,appendix WHERE project.name = appendix.project";
+ $query .= " AND boothnr <> ''" if ($opt_onlybooth);
+ $query .= " ORDER BY boothnr,boothtitle";
$sth = $dbh->prepare($query);
if ($sth && ($rc = $sth->execute) > 0) {
while (@row = $sth->fetchrow_array) {
}
}
+sub latex_head
+{
+ my $result = '\documentclass[12pt]{article}\usepackage{humanist}';
+ my @args = @_;
+
+ $result .= '\usepackage[latin1]{inputenc}\usepackage[T1]{fontenc}';
+ if (@args) {
+ $result .= join ("\n", @args);
+ }
+
+ $result .= '\topmargin=-1cm\setlength{\oddsidemargin}{0.5cm}'
+ . '\setlength{\textheight}{25.0cm}\thispagestyle{empty}'
+ . '\begin{document}';
+
+ return $result;
+}
+
+sub latex_members
+{
+ my $query;
+ my $sth;
+ my $rc;
+ my @row;
+ my $count = 0;
+
+ my $thead = '\parbox{5cm}{\textbf{Name}} &\parbox{8cm}{\textbf{Project}}\\\\';
+ my $head = '\tablefirsthead{' . $thead .'\hline\hline}'
+ . '\tablehead{'
+ . '\multicolumn{2}{l}{Members continued...} \\\\[2ex]'
+ . $thead . '\hline\hline}'
+ . '\begin{supertabular}{l|l}' . "\n";
+
+ my $foot = '\end{supertabular}';
+ my $trow = '%s & %s \\\\';
+
+ print latex_head ("\\usepackage{supertabular}");
+ printf $latex_headline, "Projects-Staff";
+
+ $query = "SELECT name,project FROM person WHERE list=0 ORDER BY name";
+ $sth = $dbh->prepare($query);
+ if ($sth && ($rc = $sth->execute) > 0) {
+ print $head;
+ while (@row = $sth->fetchrow_array) {
+ $count++;
+ printf $trow, $row[0], $row[1];
+ print '\hline' if (!($count % 5));
+ print "\n";
+ }
+ print $foot;
+ }
+
+ print "\\clearpage\n";
+
+ $query = "SELECT name,project FROM person WHERE list=0 ORDER BY project,name";
+ $sth = $dbh->prepare($query);
+ if ($sth && ($rc = $sth->execute) > 0) {
+ print $head;
+ while (@row = $sth->fetchrow_array) {
+ $count++;
+ printf $trow, $row[0], $row[1];
+ print '\hline' if (!($count % 5));
+ print "\n";
+ }
+ print $foot;
+ }
+ print $latex_foot;
+}
+
+sub latex_table
+{
+ my $query;
+ my $sth;
+ my $rc;
+ my @row;
+
+ my $head = '\renewcommand{\arraystretch}{1.5}\begin{tabular}{ll}';
+ my $foot = '\end{tabular}';
+ my $trow = '%s & \hspace{8cm}\ \\\\\cline{2-2}';
+
+ $query = "SELECT name FROM project WHERE name <> 'intern'";
+ $query .= " AND boothnr <> ''" if ($opt_onlybooth);
+ $query .= " ORDER BY name";
+ $sth = $dbh->prepare($query);
+ if ($sth && ($rc = $sth->execute) > 0) {
+ print latex_head ();
+ printf $latex_headline, "Projekte";
+ print $head;
+ while (@row = $sth->fetchrow_array) {
+ printf $trow . "\n", $row[0];
+ }
+ print $foot;
+ print $latex_foot;
+ }
+}
+
sub descr
{
my $query;
my $cols;
$query = "SELECT name,url,boothnr FROM project";
+ $query .= " WHERE boothnr <> ''" if ($opt_onlybooth);
$sth = $dbh->prepare($query);
if ($sth && ($rc = $sth->execute) > 0) {
while (@row = $sth->fetchrow_array) {
}
}
- $query = "SELECT project,description,description_en FROM appendix";
+ if ($opt_onlybooth) {
+ $query = "SELECT appendix.project,appendix.description,appendix.description_en FROM appendix,project WHERE ";
+ $query .= "project.name = appendix.project AND project.boothnr <> ''";
+ } else {
+ $query = "SELECT project,description,description_en FROM appendix";
+ }
+
$sth = $dbh->prepare($query);
if ($sth && ($rc = $sth->execute) > 0) {
while (@row = $sth->fetchrow_array) {
sub exportlt
{
- my $query = "SELECT name,boothnr,url FROM project ORDER BY name";
+ my $query = "SELECT name,boothnr,url FROM project";
my $sth;
my $rc;
my @row;
my $nr = 0;
+ $query .= " WHERE boothnr <> ''" if ($opt_onlybooth);
+ $query .= " ORDER BY name";
$sth = $dbh->prepare($query);
if ($sth && ($rc = $sth->execute) > 0) {
while (@row = $sth->fetchrow_array) {
print "Options:\n";
print " --cols <n> Text will be wrapped at n columns\n";
print " --nospace No leading spaces\n";
+ print " --onlybooth Only projects with a non-empty boothnr\n";
print "Commands:\n";
print " --help This help\n";
print " --descr List project descriptions\n";
print " --exportlt Export for LT database\n";
print " --list|-l List all projects\n";
print " --mails List mail addresses of all projects\n";
+ print " --members LaTeX file with all project members\n";
print " --nili Table for Nili accommodation\n";
print " --nili-details Details for Nili accommodation\n";
print " --night [<place>] List people that need a place to stay\n";
print " --titles List booth titles\n";
+ print " --table LaTeX table with all projects\n";
print " --workshops Workshop Schedule\n";
}
#
$argc = 0;
$opt_nospace = 0;
+$opt_onlybooth = 0;
$opt_cols = 70;
while ($argc <= $#ARGV) {
if ($ARGV[$argc] eq "-h" || $ARGV[$argc] eq "--help") {
exportlt ();
} elsif ($ARGV[$argc] eq "--mails") {
list_mails ('');
+ } elsif ($ARGV[$argc] eq "--members") {
+ latex_members ('');
} elsif ($ARGV[$argc] eq "--nili") {
nili ();
} elsif ($ARGV[$argc] eq "--nili-details") {
}
} elsif ($ARGV[$argc] eq "--nospace") {
$opt_nospace++;
+ } elsif ($ARGV[$argc] eq "--onlybooth") {
+ $opt_onlybooth++;
+ } elsif ($ARGV[$argc] eq "--table") {
+ latex_table ();
} elsif ($ARGV[$argc] eq "--titles") {
list_titles ();
} elsif ($ARGV[$argc] eq "--workshops") {