#!/usr/bin/perl
# Copyright 2001-2010 Leslie Richardson
# This file is part of Open Admin for Schools.
# Passed as "group": Accept Grade, Class, or All for group to
# find for attendance.
# Passed as "mode": Weekly or Biweekly Mode. (or Date Range?)
# Passed as "class": The value of the group: ie. 8c, 10.
my %lex = ( 'Multi-Day Attendance Entry' => 'Multi-Day Attendance Entry',
'Attendance' => 'Attendance',
'Name' => 'Name',
'Continue' => 'Continue',
'Error' => 'Error',
'Weekly' => 'Weekly',
'Select by' => 'Select by',
'Grade' => 'Grade',
'Homeroom' => 'Homeroom',
'Weekly' => 'Weekly',
'Biweekly' => 'Biweekly',
'Continue' => 'Continue',
'Mode' => 'Mode',
'Blank=All' => 'Blank=All',
);
my $self = 'attentrymd0.pl';
use DBI;
use CGI;
use Time::JulianDay;
eval require "../../etc/admin.conf";
if ( $@ ) {
print $lex{Error}. ": $@ \n";
die $lex{Error}. ": $@\n";
}
my $q = new CGI;
print $q->header( -charset, $charset );
my %arr = $q->Vars;
print "$doctype\n
\n";
if ( not $arr{page} ) {
showStartPage();
} else {
delete $arr{page};
}
# Setup MaxPPD.(Maximum Periods per Day)
my $maxppd; # Maximum periods per day
if ( not %g_ppd ) {
print "Periods per Day not set in configuration file!";
print "\n";
exit;
}
foreach my $key ( keys %g_ppd){
if ($g_ppd{$key} > $maxppd){ $maxppd = $g_ppd{$key};}
}
# Set # of weeks to do.
if ( $arr{mode} eq $lex{Weekly} ){ $weekcount = 1;}
else {$weekcount = 2;}
# Get Date
if ( $arr{date} ) {
# Generate a list from those dates. Assume year-mon-day
($year,$month,$day) = split /-/,$arr{date};
$jd = julian_day($year,$month,$day);
$dow = day_of_week($jd);
$mondayjd = $jd - ($dow-1);
if (length($month) == 1){ $month = "0".$month;}
if (length($day) == 1){ $day = "0".$day;}
$currsdate = "$year$month$day";
$currdate = "$year-$month-$day";
} else { # get current date
@tim = localtime(time);
$year = @tim[5] + 1900;
$month = @tim[4] + 1;
$day = @tim[3];
$jd = julian_day($year,$month,$day);
$mondayjd = $jd - ($tim[6]-1); #This will now give Monday of that week.
if (length($month) == 1){ $month = "0".$month;}
if (length($day) == 1){ $day = "0".$day;}
$currdate = "$year-$month-$day";
$currsdate = "$year$month$day";
$currdate1 = "@month[$month] $day, $year";
}
# Setup Array and Hash to hold Dates and DOW Dates
mkDateData($mondayjd,$weekcount);
my $dsn = "DBI:$dbtype:dbname=$dbase";
my $dbh = DBI->connect($dsn,$user,$password);
$dbh->{mysql_enable_utf8} = 1;
# Setup the select from passed values: grouptype, groupvalue
my $select;
if ( $arr{grouptype} eq $lex{Homeroom} and $arr{groupvalue} ){
$select = " where homeroom = ? ";
} elsif ( $arr{grouptype} eq $lex{Grade} and $arr{groupvalue} ) {
$select = " where grade = ? ";
}
# Find the kids' names and studnum
my $sth = $dbh->prepare("select lastname, firstname, studnum from student
$select order by lastname, firstname");
if ( $arr{groupvalue} ) {
$sth->execute( $arr{groupvalue} );
} else {
$sth->execute;
}
if ($DBI::errstr){ print $DBI::errstr; die "$DBI::errstr\n";}
print "