#!/usr/bin/perl
# Copyright 2001-2019 Leslie Richardson
# This file is part of Open Admin for Schools.
# Get Grade and Year-Month and display attendance for each day.
# Update: Jan 10, L520, section updated to correctly join days closed with partial days closed for NSD homerooms
my %lex = ('Teacher' => 'Teacher',
'Error' => 'Error',
'Main' => 'Main',
'Attendance' => 'Attendance',
'Report' => 'Report',
'Entry' => 'Entry',
'Month' => 'Month',
'Start' => 'Start',
'Months' => 'Months',
'Continue' => 'Continue',
'Select' => 'Select',
'Grade' => 'Grade',
'Student' => 'Student',
'Subject' => 'Subject',
'Reason' => 'Reason',
'Late' => 'Late',
'Days Open' => 'Days Open',
'Days Closed' => 'Days Closed',
'Show' => 'Show',
'Withdrawn' => 'Withdrawn',
'or' => 'or',
'Homeroom' => 'Homeroom',
'Missing' => 'Missing',
'Value' => 'Value',
'WD' => 'WD',
'Enrolled' => 'Enrolled',
'Attended' => 'Attended',
'Method' => 'Method',
'View' => 'View',
'Hover' => 'Hover',
'Click' => 'Click',
'Edit' => 'Edit',
'Override' => 'Override',
'Periods per Day' => 'Periods per Day',
'Not Found' => 'Not Found',
'Period' => 'Period',
'Method' => 'Method',
'Absent' => 'Absent',
'Present' => 'Present',
'No Entry' => 'No Entry',
'OK' => 'OK',
'Skip' => 'Skip',
'Students' => 'Students',
);
my $self = 'rptmonth4.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";
}
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";
}
}
=head
my $sth = $dbh->prepare("select id, datavalue from conf_system where dataname = ?");
foreach my $field ( css ) {
$sth->execute( $field );
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";
}
}
}
=cut
# 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) );
my $curryrmo = "$cyear-$cmonth";
my $title = "$lex{Monthly} $lex{Attendance} $lex{Report} 4";
print qq{$doctype\n