[Koha-cvs] CVS: koha charges.pl,1.5,1.6 updatecharges.pl,1.5,1.6

Paul POULAIN tipaul at users.sourceforge.net
Wed Sep 17 12:22:27 CEST 2003


Update of /cvsroot/koha/koha
In directory sc8-pr-cvs1:/tmp/cvs-serv13201

Modified Files:
	charges.pl updatecharges.pl 
Log Message:
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)

Index: charges.pl
===================================================================
RCS file: /cvsroot/koha/koha/charges.pl,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** charges.pl	29 Mar 2003 23:15:17 -0000	1.5
--- charges.pl	17 Sep 2003 10:22:25 -0000	1.6
***************
*** 38,43 ****
  print $input->header;
  my $type=$input->param('type');
! 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";
--- 38,43 ----
  print $input->header;
  my $type=$input->param('type');
! # 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";
***************
*** 73,77 ****
      $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>";
    }
    print mktablerow(11,'white',$data->{'description'}, at trow2);
--- 73,77 ----
      $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>";
    }
    print mktablerow(11,'white',$data->{'description'}, at trow2);

Index: updatecharges.pl
===================================================================
RCS file: /cvsroot/koha/koha/updatecharges.pl,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** updatecharges.pl	29 Mar 2003 23:15:17 -0000	1.5
--- updatecharges.pl	17 Sep 2003 10:22:25 -0000	1.6
***************
*** 42,56 ****
  
  foreach my $key (@names){
! 
!   my $bor=substr($key,0,1);
!   my $cat=$key;
!   $cat =~ s/[A-Z]//i;
    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;
  }
  print $input->redirect("/cgi-bin/koha/charges.pl");
--- 42,63 ----
  
  foreach my $key (@names){
! 	$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_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");





More information about the Koha-cvs mailing list