#!/usr/bin/perl

#use utf8;
use strict;
use CGI;

use Opals::Context;
use Opals::Template qw(
    tmpl_read
    tmpl_write
);

my $dbh = Opals::Context->dbh();
END { $dbh->disconnect(); }

my $cgi = CGI->new;
# $cgi->param('aaa') returns an array of aaa
my $input = $cgi->Vars();
#my $op = $input->{'op'};
my ($permission, $cookieList, $template) = tmpl_read(
    {
        dbh             => $dbh,
        cgi             => $cgi,
        tmplFile        => 'prepare/preparedByTeacher.tmpl',
#        reqPermission   => 'reqPermission1|reqPermission2|etc.',
#        op              => $op,
    }
);


my $msg = 'testing.....';

my $sth = $dbh->prepare(<<_STH_);
select  teacherId, lastName, firstName
from    tbk_teachers
_STH_

$sth->execute() || return;
my @zdb;
while (my $z = $sth->fetchrow_hashref) {
    push @zdb, $z;
}
$sth->finish;

$template->param(
    msmsg=>$msg,
    zdb=>\@zdb,
    );



# See User.pm for the list of permissions
#if ($permission && $permission->{'reqPermission1'}) {
#}
#else { # input for login form
#    $template->param(
#        input => [
#            {name => '', value => $,},
#            {name => '', value => $,},
#        ],
#    );
#}

# Turn on/off search box
#$template->param(
#    search_off      => 1,
#);

tmpl_write($dbh, $cgi, $cookieList, $template);
#$dbh->disconnect();
