#! /usr/bin/perl
# Copyright 2001-2020 Leslie Richardson
# This file is part of Open Admin for Schools.
# Open Admin for Schools is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# ======= FN Attendance Report =======
# Get End date; Generate months up to end of enddate month.
# We only print out days enrolled AND that student actually attended.
# Column Format: Grade, Lastname, First, Middlename, Birthdate, Status
# Number (Treaty Number), Reserve, Parent1 Name, then single columns
# for each month (S,O,N,D,J,F,M,A,M,J).
# Sorted by Band, Lastname, Firstname (1 Page per Reserve).
my %lex = ('Attendance Report' => 'Attendance Report',
'Main' => 'Main',
'Attendance' => 'Attendance',
'Periods Per Day' => 'Periods Per Day',
'View/Download' => 'View/Download',
'View Log File' => 'View Log File',
'Last Name' => 'Last Name',
'First' => 'First',
'Middle' => 'Middle',
'Birthdate' => 'Birthdate',
'Status' => 'Status',
'Reserve' => 'Reserve',
'Mother' => 'Mother',
'School Days' => 'School Days',
'Error' => 'Error',
'Date' => 'Date',
'Paper Size' => 'Paper Size',
'Letter' => 'Letter',
'Legal' => 'Legal',
'A4' => 'A4',
'Continue' => 'Continue',
'Records per Page' => 'Records per Page',
'Not Defined' => 'Not Defined',
'Grade' => 'Grade',
'Student' => 'Student',
'Not Found' => 'Not Found',
'Band' => 'Band',
'Font Size' => 'Font Size',
'Group' => 'Group',
'HTML' => 'HTML',
'Homeroom' => 'Homeroom',
'PDF' => 'PDF',
'Separate with Spaces' => 'Separate with Spaces',
'Report Type' => 'Report Type',
);
my $self = 'rptinac.pl';
use DBI;
use CGI;
use Number::Format qw(:all);
# Constants
my $defmaxrecords = 28; # Maximum records per PDF page.
my $group = 'band';
my $pdf = '1';
my $html;
# Read config variables
eval require "../../etc/admin.conf";
if ( $@ ) {
print $lex{Error}. ": $@
\n";
die $lex{Error}. ": $@\n";
}
eval require "../../lib/libattend.pl";
if ( $@ ) {
print $lex{Error}. ": $@
\n";
die $lex{Error}. ": $@\n";
}
eval require "../../lib/liblatex.pl";
if ( $@ ) {
print $lex{Error}. ": $@
\n";
die $lex{Error}. ": $@\n";
}
my $dsn = "DBI:mysql:$dbase";
$dbh = DBI->connect($dsn,$user,$password);
$dbh->{mysql_enable_utf8} = 1;
my @tim = localtime(time);
my $year = $tim[5] + 1900;
my $month = $tim[4] + 1;
my $day = $tim[3];
if (length($month) == 1){ $month = "0".$month;}
if (length($day) == 1){ $day = "0".$day;}
my $currsdate = "$year-$month-$day";
my $currdate = "$month[$month] $day, $year";
my $q = new CGI;
my %arr = $q->Vars;
print $q->header( -charset, $charset );
# HTML Header
my $title = qq{First Nation/ISC $lex{'Attendance Report'}};
print qq{$doctype\n
[ $lex{Main} |\n}; print qq{$lex{Attendance} | \n}; print qq{$lex{'View Log File'} ]\n}; print qq{\n}; #---------------------- sub print_tex_doc_start { #---------------------- print TEX "\\documentclass[10pt,legalpaper,oneside,landscape]{article} \\usepackage{array,colortbl,rotating,inputenc} $a_latex_header \\renewcommand{\\familydefault}{\\sfdefault} \\pagestyle{empty} \\setlength{\\textwidth}{13in} \\setlength{\\textheight}{7.7in} \\setlength{\\hoffset}{-4.3in} \\setlength{\\voffset}{-0.8in} \\setlength{\\headsep}{10pt} \\setlength{\\headheight}{14pt} \\setlength{\\topmargin}{0pt} \\setlength{\\parindent}{0pt} \\setlength{\\tabcolsep}{5pt} \\setlength{\\extrarowheight}{3pt} \\pagestyle{headings} \\markright{$schoolname - $schoolyear \\hfill {\\bf FN $lex{'Attendance Report'} } \\hfill $currdate -- Pg } \n\n \\begin{document}\n"; } # End of Print Tex Doc Start #------------------- sub print_tex_header { #------------------- # Up to 18 Cols: (8 + 10 months) # Grade, Lastname, Firstname, Middlename, Birthdate print TEX "\\begin{tabular}{|p{1cm}|p{3cm}|p{1.6cm}|p{2cm}|p{1.8cm}"; # Treaty, Band, Parent, Up to 10 Months. print TEX "|p{1.7cm}|p{2.2cm}|p{3.2cm}|"; foreach my $yrmo ( sort keys %schooldays ){ print TEX "p{9mm}|"; } print TEX "}\\hline\n\n"; # Now print the column header line. print TEX "\\rowcolor[gray]{0.90}{\\bf Grade}"; print TEX "& {\\bf ". $lex{'Last Name'}. "} & {\\bf ". $lex{First}. "} &"; print TEX "{\\bf ". $lex{Middle}. "} &{\\bf ". $lex{Birthdate}. "} &"; print TEX "{\\bf ". $lex{Status}. "\\#} &{\\bf Band} & \n"; print TEX "{\\bf ". $lex{Mother}. "}"; foreach my $yrmo ( sort keys %schooldays ){ my ($ty,$tm) = split(/-/,$yrmo); print TEX "& {\\bf $s_month[$tm]}"; } print TEX "\\\\ \\hline\n\n"; # Now print the schooldays in month print TEX "\\rowcolor[gray]{0.90}"; print TEX "& & & & & & & ". $lex{'School Days'}; foreach my $yrmo ( sort keys %schooldays ){ print TEX "& {\\bf $schooldays{$yrmo}}"; } print TEX "\\\\ \\hline\n\n"; } #--------------- sub doAttSetup { # Version with monthly attendance info #--------------- # Needs globals: @schoolmonths - ordering of school months. # %schooldays - days in each month in hash. # $periodsperday - number of periods in the school day. my $sref = shift; %sr = %$sref; my $studnum = $sr{studnum}; %absent = (); %tardy = (); %enrol = (); my $periodsperday = $g_ppd{ $sr{grade} }; if ( not $periodsperday ){ if ( not $sr{grade} ){ $sr{grade} = $lex{'Not Found'}; } print qq{