fixing some bugs in charges.pl, script that fills the categoryitem table.

The categoryitem table contains fines for every itemtype-borrowercategory.
Should be templated and added to admin part of Koha (i'll take care of this next week probably)
This commit is contained in:
tipaul 2003-09-17 10:22:25 +00:00
parent 45414c767b
commit 43b29b60f6
2 changed files with 18 additions and 11 deletions

View File

@ -37,8 +37,8 @@ my ($loggedinuser, $cookie, $sessionID) = checkauth($input, 0, $flagsrequired);
print $input->header;
my $type=$input->param('type');
print startpage();
print startmenu('issue');
# print startpage();
# print startmenu('issue');
print "Each box needs to be filled in with fine,time to start charging,charging cycle<br>
eg 1,7,7 = $1 fine, after 7 days, every 7 days";
@ -72,7 +72,7 @@ while (my $data=$sth->fetchrow_hashref){
my $dat=$sth2->fetchrow_hashref;
$sth2->finish;
my $fine=$dat->{'fine'}+0;
$trow2[$i]="<input type=text name=\"$trow3[$i]$data->{'itemtype'}\" value=\"$fine,$dat->{'firstremind'},$dat->{'chargeperiod'}\" size=6>";
$trow2[$i]="<input type=text name=\"$trow3[$i].$data->{'itemtype'}\" value=\"$fine,$dat->{'firstremind'},$dat->{'chargeperiod'}\" size=6>";
}
print mktablerow(11,'white',$data->{'description'},@trow2);
}

View File

@ -41,17 +41,24 @@ my $dbh = C4::Context->dbh;
my @names=$input->param();
foreach my $key (@names){
my $bor=substr($key,0,1);
my $cat=$key;
$cat =~ s/[A-Z]//i;
$key =~ /(.*)\.(.*)/;
my $bor=$1;
my $cat=$2;
my $data=$input->param($key);
my @dat=split(',',$data);
# print "$bor $cat $dat[0] $dat[1] $dat[2] <br> ";
my $sth=$dbh->prepare("Update categoryitem set fine=?,firstremind=?,chargeperiod=? where
categorycode=? and itemtype=?");
$sth->execute($dat[0],$dat[1],$dat[2],$bor,$cat);
$sth->finish;
my $sth_search = $dbh->prepare("select count(*) as total from categoryitem where categorycode=? and itemtype=?");
my $sth_insert = $dbh->prepare("insert into categoryitem (categorycode,itemtype,fine,firstremind,chargeperiod) values (?,?,?,?,?)");
my $sth_update=$dbh->prepare("Update categoryitem set fine=?,firstremind=?,chargeperiod=? where categorycode=? and itemtype=?");
$sth_search->execute($bor,$cat);
my $res = $sth_search->fetchrow_hashref();
if ($res->{total}) {
warn "UPDATE";
$sth_update->execute($dat[0],$dat[1],$dat[2],$bor,$cat);
} else {
warn "INSERT";
$sth_insert->execute($bor,$cat,$dat[0],$dat[1],$dat[2]);
}
}
print $input->redirect("/cgi-bin/koha/charges.pl");
#print endmenu('issue');