#!/usr/bin/perl
# Copyright 2001-2022 Leslie Richardson
# This file is part of Open Admin for Schools.
# Get Grade and Year-Month and display attendance for each day.
my %lex = ('Teacher' => 'Teacher',
'Error' => 'Error',
'Main' => 'Main',
'Attendance' => 'Attendance',
'Report' => 'Report',
'Month' => 'Month',
'Start' => 'Start',
'Continue' => 'Continue',
'Select' => 'Select',
'Grade' => 'Grade',
'Student' => 'Student',
'Subject' => 'Subject',
'Show' => 'Show',
'Withdrawn' => 'Withdrawn',
'or' => 'or',
'Homeroom' => 'Homeroom',
'Missing' => 'Missing',
'Value' => 'Value',
'View' => 'View',
'Hover' => 'Hover',
'Students' => 'Students',
'Starting' => 'Starting',
'Ending' => 'Ending',
'Override' => 'Override',
'Days Open' => 'Days Open',
'No Students Selected' => 'No Students Selected',
'Open' => 'Open',
'End' => 'End',
'Yearly' => 'Yearly',
);
my $self = 'rptattstud1.pl';
my $closedcolor = '#AAA';
my $partclosedcolor = '#EEE';
my $notenrolledcolor = '#DDD';
use DBI;
use CGI;
use Cwd;
use Time::JulianDay;
use Number::Format qw(:all);
# Get current dir so know what path for config files.
my $configpath;
my $teachermode;
if ( getcwd() =~ /tcgi/ ){ # we are in tcgi
$teachermode = 1;
$configpath = '..'; # go back one to get to etc.
} else {
$configpath = '../..'; # go back two to get to etc.
}
# only load passwords and users
eval require "$configpath/etc/admin.conf.root";
if ( $@ ) {
print $lex{Error}. " $@
\n";
die $lex{Error}. " $@\n";
}
eval require "$configpath/lib/libattend.pl";
if ( $@ ) {
print $lex{Error}. " $@
\n";
die $lex{Error}. " $@\n";
}
eval require "$configpath/lib/libschedule.pl";
if ( $@ ) {
print $lex{Error}. " $@
\n";
die $lex{Error}. " $@\n";
}
# for parseGradesPeriod function
eval require "$configpath/lib/libDate.pl";
if ( $@ ) {
print $lex{Error}. " $@
\n";
die $lex{Error}. " $@\n";
}
my $dbtype = 'mysql';
my $dsn = "DBI:$dbtype:dbname=$dbase";
my $dbh = DBI->connect($dsn,$user,$password);
$dbh->{mysql_enable_utf8} = 1;
# Load Configuration Variables;
my $sth = $dbh->prepare("select id, datavalue from conf_system where filename = 'admin'");
$sth->execute;
if ( $DBI::errstr ) { print $DBI::errstr; die $DBI::errstr; }
while ( my ($id, $datavalue) = $sth->fetchrow ) {
eval $datavalue;
if ( $@ ) {
print "$lex{Error}: $@
\n";
die "$lex{Error}: $@\n";
}
}
# Teachermode
if ( $teachermode ) { # running on teacher site
$css = $tchcss;
$homepage = $tchpage;
$downloaddir = $tchdownloaddir;
$webdownloaddir = $tchwebdownloaddir;
}
my $q = new CGI;
print $q->header( -charset, $charset );
my %arr = $q->Vars;
# Set Date
my @tim = localtime(time);
my $cyear = @tim[5] + 1900;
my $cmonth = @tim[4] + 1;
my $cday = @tim[3];
my $currdate = "$cyear-$cmonth-$cday";
my $currjd = julian_day( split('-', $currdate) );
if (length $cmonth == 1 ) { $cmonth = '0'. $cmonth; }
my $curryrmo = "$cyear-$cmonth";
my $prevyrmo;
if ( $cmonth == 1 ) {
my $prevyr = $cyear - 1;
$prevyrmo = "$prevyr-12";
} else {
my $prevmo = $cmonth - 1;
if (length $prevmo == 1 ) { $prevmo = '0'. $prevmo; }
$prevyrmo = "$cyear-$prevmo";
}
my $title = "$lex{Yearly} $lex{Student} $lex{Attendance} $lex{Report} 1";
print qq{$doctype\n