- my @names=$input->param();
- my $sth_search = $dbh->prepare("select count(*) as total from issuingrules where branchcode=? and categorycode=? and itemtype=?");
-
- my $sth_Iinsert = $dbh->prepare("insert into issuingrules (branchcode,categorycode,itemtype,maxissueqty,issuelength,rentaldiscount) values (?,?,?,?,?,?)");
- my $sth_Iupdate=$dbh->prepare("Update issuingrules set maxissueqty=?, issuelength=?, rentaldiscount=? where branchcode=? and categorycode=? and itemtype=?");
- my $sth_Idelete=$dbh->prepare("delete from issuingrules where branchcode=? and categorycode=? and itemtype=? and fine=0");
- foreach my $key (@names){
- # ISSUES
- if ($key =~ /I-(.*)-(.*)\.(.*)/) {
- my $br = $1; # branch
- my $bor = $2; # borrower category
- my $cat = $3; # item type
- my $data=$input->param($key);
- my ($issuelength,$maxissueqty,$rentaldiscount)=split(',',$data);
-# if ($maxissueqty >0) {
- $sth_search->execute($br,$bor,$cat);
- my $res = $sth_search->fetchrow_hashref();
- if ($res->{total}) {
- $sth_Iupdate->execute($maxissueqty,$issuelength,$rentaldiscount,$br,$bor,$cat);
- } else {
- $sth_Iinsert->execute($br,$bor,$cat,$maxissueqty,$issuelength,$rentaldiscount);
- }
-# } else {
-# $sth_Idelete->execute($br,$bor,$cat);
-# }
- }
- }