\n};
my $cycletext;
if ( $g_DaysPerCycle == 1 ) {
$cycletext = "( Every Day is the same.)";
} elsif ( $g_DaysPerCycle == 5 or $g_DaysPerCycle eq 'w' or $g_DaysPerCycle eq 'W' ) {
$cycletext = "( Weekly Cycle - Each monday the same, each tuesday, etc.)";
}
print qq{
Days in a School Cycle - $g_DaysPerCycle $cycletext
\n};
print qq{
};
print qq{An Activity is a period which is Not a
course, but may be a part of a course or may be another type of
activity not associated with a course, but does have an area of study
which you may set
\n};
# foreach my $key ( keys %arr ) { print "K:$key V:$arr{$key} \n"; }
if ( not $arr{page} ) {
showStartPage();
} elsif ( $arr{page} == 1 ) {
delete $arr{page};
setActivity();
} elsif ( $arr{page} == 2 ) {
delete $arr{page};
writeActivity();
}
#----------------
sub showStartPage {
#----------------
# load existing activities, then display them in table with edit/delete options.
my $sth = $dbh->prepare("select * from dbkactivity where userid = ?");
$sth->execute( $userid );
if ( $DBI::errstr ) { print $DBI::errstr; die $DBI::errstr; }
my (%activity, %sort);
while ( my $ref = $sth->fetchrow_hashref ) {
my %r = %$ref;
$activity{ $r{id} } = $ref;
$sort{"$r{title}$r{id}"} = $r{id};
}
# Display current activities, floated
my $first = 1;
foreach my $key ( sort keys %sort ) {
my $id = $sort{$key};
my %r = %{ $activity{$id} };
if ( $first ) {
print qq{
};
print qq{
Current Activities
\n};
print qq{
$lex{Title}
$lex{Description}
\n};
$first = 0;
}
# Edit this Time Set
print qq{
$r{title}
$r{description}
\n
};
print qq{\n};
print qq{
\n};
} # end of display current activities
if ( not $first ) { # end the table
print qq{
\n};
}
# Add new activity
print qq{\n\n
\n};
print qq{
\n};
print qq{\n};
exit;
} # end of showStartPage
#--------------
sub setActivity {
#--------------
# foreach my $key ( sort keys %arr ) { print "K:$key V:$arr{$key} \n"; }
# Passed: actcount - number of activities to add when adding.
# Load Courses for this teacher
my (%course,%csort); # csort sorts by description of course.
my $sth = $dbh->prepare("select * from subject where teacher = ?");
$sth->execute( $userid );
if ( $DBI::errstr ) { print $DBI::errstr; die $DBI::errstr; }
while ( my $ref = $sth->fetchrow_hashref ) {
$course{ $ref->{subjsec} } = $ref;
$csort{"$ref->{description}$ref->{subjsec}"} = $ref->{subjsec};
}
# Get Max Terms from subjects
my $sth = $dbh->prepare("select max(endrptperiod) from subject");
$sth->execute;
if ( $DBI::errstr ) { print $DBI::errstr; die $DBI::errstr; }
my $maxendterm = $sth->fetchrow;
# Single record edit
my %r;
if ( $arr{id} ) { # edit a single record.
$arr{actcount} = 1; # loop once.
my $sth = $dbh->prepare("select * from dbkactivity where id = ?");
$sth->execute( $arr{id} );
if ( $DBI::errstr ) { print $DBI::errstr; die $DBI::errstr; }
my $ref = $sth->fetchrow_hashref;
%r = %$ref;
}
# Form / Table Start
print qq{\n};
print qq{