#!/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.
%lex = ('Edit' => 'Edit',
'Staff Member' => 'Staff Member',
'Main' => 'Main',
'Eoy' => 'Eoy',
'Unable to open template file:' => 'Unable to open template file:',
'Contact' => 'Contact',
'Update' => 'Update',
'Error' => 'Error',
'Password' => 'Password',
'You MUST have a unique userid and a password' =>
'You MUST have a unique userid and a password',
'Grades' => 'Grades',
'Homeroom(s)' => 'Homeroom(s)',
'Position' => 'Position',
'Record(s) Updated' => 'Record(s) Updated',
'Separate with Spaces' => 'Separate with Spaces',
'Add' => 'Add',
'Required' => 'Required',
'Bold' => 'Bold',
'Preregistration' => 'Preregistration',
'Access Control(s)' => 'Access Control(s)',
'Current' => 'Current',
'Spaces Not Allowed' => 'Spaces Not Allowed',
'Type' => 'Type',
'Percent' => 'Percent',
'Occupation' => 'Occupation',
'Userid Already Exists' => 'Userid Already Exists',
'Staff' => 'Staff',
);
my $self = 'staffed.pl';
my @grades = qw(P3 PK K 1 2 3 4 5 6 7 8 9 10 11 12);
use CGI;
use DBI;
use Data::Password qw(:all); # for password checking...
use Crypt::GeneratePassword qw(:all); # password generation.
# First Nations settings.
my $maxmulti = 4; # Occupation Limits for INAC First Nations occupations.
my $template = 'staff.tpl';
my $fnmode; # set below configuration load.
# Password config; rest in admin.conf
# For Generation
$g_staffpwd_minfreq = .001;
$g_staffpwd_avgfreq = .001;
$g_staffpwd_lang = 'en'; # only en or de available.
# For Checking
my $g_staffpwd_groups = 0; # turn off character group (uppercase, lowercase, symbols) checking
my $g_staffpwd_following = 0; # turn off following character checking (keyboard, same)
# WATCH: Only loading userids and passwords here!
eval require "../../etc/admin.conf.root";
if ( $@ ) {
print $lex{Error}. ": $@
\n";
die $lex{Error}. ": $@\n";
}
eval require "../../lib/libmeta.pl";
if ( $@ ) {
print $lex{Error}. " $@
\n";
die $lex{Error}. " $@\n";
}
# Load audit write function
eval require "../../lib/libaudit.pl";
if ( $@ ) {
print $lex{Error}. ": $@
\n";
die $lex{Error}. ": $@\n";
}
my $q = new CGI;
print $q->header(-charset, $charset );
my %arr = $q->Vars;
my $recid = $arr{id};
# Set Table to edit/add
my $table;
if ( $arr{tbl} ) {
$table = 'prereg_staff';
$multitable = 'prereg_staff_multi';
} else {
$table = 'staff';
$multitable = 'staff_multi';
}
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";
}
}
if ( $g_InacSchool ) { # if no mode here, normal editing operations.
$fnmode = 1; # first nation mode, additional fields, different template
$template = 'staff_inac.tpl';
}
# Print Page Header
my $title = qq{$lex{Add}/$lex{Edit} $lex{'Staff Member'}};
print qq{$doctype\n
$lex{Bold} = $lex{Required}
\n}; # Load the record into a hash, if an edit process. my $sth = $dbh->prepare("select * from staff where id = ?"); $sth->execute( $arr{id} ); if ($DBI::errstr){ print $DBI::errstr; die $DBI::errstr;} my $ref = $sth->fetchrow_hashref; my %rec = %$ref; # Read in Template as single text variable unless (open (FH,"<../../template/$template")) { print qq{$lex{'Unable to open template file:'} - $!\n}; die $lex{'Unable to open template file:'},"$!\n"; } my $formtext; { local $/; $formtext =