X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=www%2Findex.pl;h=7546d658ac8a4b5bf14bf8a30b8e46d408c4092b;hb=854c8eb6e0a3f9836043faaf2f43c05c190619fb;hp=8274574a23df52464c1c26a6a783d6d74d1be778;hpb=b055272098b04525aaea3631b4b20a0777f2b0ee;p=wloh diff --git a/www/index.pl b/www/index.pl index 8274574..7546d65 100755 --- a/www/index.pl +++ b/www/index.pl @@ -39,19 +39,13 @@ sub color { return int(255.0 * ($x ** (1.80))); } -sub get_max_season { - my $dbh = shift; - my $ref = $dbh->selectrow_hashref('SELECT MAX(sesong) AS max_sesong FROM fotballserier'); - return $ref->{'max_sesong'}; -} - sub get_divisions { - my ($dbh, $season) = @_; + my ($dbh, $locale, $season) = @_; my @divisions = (); - my $q = $dbh->prepare('SELECT DISTINCT(divisjon) FROM fotballserier WHERE sesong=? ORDER BY divisjon'); - $q->execute($season); + my $q = $dbh->prepare('SELECT DISTINCT(divisjon) FROM fotballserier se JOIN fotballspraak sp ON se.spraak=sp.id WHERE kultur=? AND sesong=? ORDER BY divisjon'); + $q->execute($locale, $season); while (my $ref = $q->fetchrow_hashref) { push @divisions, $ref->{'divisjon'}; @@ -61,12 +55,12 @@ sub get_divisions { } sub get_subdivisions { - my ($dbh, $season, $division) = @_; + my ($dbh, $locale, $season, $division) = @_; my @subdivisions = (); - my $q = $dbh->prepare('SELECT DISTINCT(avdeling) FROM fotballserier WHERE sesong=? AND divisjon=? ORDER BY avdeling'); - $q->execute($season, $division); + my $q = $dbh->prepare('SELECT DISTINCT(avdeling) FROM fotballserier se JOIN fotballspraak sp ON se.spraak=sp.id WHERE kultur=? AND sesong=? AND divisjon=? ORDER BY avdeling'); + $q->execute($locale, $season, $division); while (my $ref = $q->fetchrow_hashref) { push @subdivisions, $ref->{'avdeling'}; @@ -76,10 +70,10 @@ sub get_subdivisions { } sub print_division_selector { - my ($dbh, $divisions, $subdivisions, $division, $subdivision) = @_; + my ($dbh, $locale, $divisions, $subdivisions, $division, $subdivision) = @_; print <<"EOF"; -