#!/usr/bin/perl

#use utf8;
use strict;
use CGI;
use Digest::SHA qw(
    sha1_base64
    sha1_hex
);

use Opals::Context;
use Opals::Template_ajax qw(
    tmpl_read
    tmpl_write
    tmpl_preference
);

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

my $cgi      = CGI->new;
my $input    = $cgi->Vars();
my $user       = $input->{"user"};


my ($status,$errorCode,$errorMsg)    ;
my ($permission, $cookie, $template) = tmpl_read(
    {
        dbh             => $dbh,
        cgi             => $cgi,
        tmplFile        => 'ajax/circ/fineConf.tmpl',
        reqPermission   => 'circ_loan|circ_return',
    }
);
if ($permission && $permission->{'circ_loan'}
    || $permission && $permission->{'circ_return'}) {
    my $syspref = tmpl_preference($dbh);
    my $chargeFine   = $syspref->{'charge_overdue'};
    my $chargeDamage = $syspref->{'charge_damage'};
    my $chargeLost   = $syspref->{'charge_lost'};
    my $fineRate =fine_getFineRate($dbh);
     $template->param(chargeOverdue =>$chargeFine ,
                      chargeDamage  =>$chargeDamage,
                      chargeLost    =>$chargeLost,
                      fineRateTbl   =>$fineRate,
     );
    #Tue, Jan 29, 2013 @ 10:56:00 EST
    #
    my $sth = $dbh->prepare("select catid from opl_category where ODexempt>0 order by catid");
    $sth->execute();
    my @ODexemptTbl;
    while(my $rec =$sth->fetchrow_hashref){
        push @ODexemptTbl,$rec;
    }
    $sth->finish;
    $template->param(ODexemptTbl  => \@ODexemptTbl);
}


 
tmpl_write($dbh, $cgi, $cookie, $template);
#------------------------------------------------------------------------------
