From 518d8795445922e2a5d27a8cf224bc400dbe78a5 Mon Sep 17 00:00:00 2001 From: tipaul Date: Mon, 6 Oct 2003 13:40:49 +0000 Subject: [PATCH] moving & templating charges to admin part of Koha --- admin/charges.pl | 95 +++++++++++++++++++ updatecharges.pl => admin/updatecharges.pl | 40 +++----- charges.pl | 86 ----------------- .../default/en/parameters/admin-home.tmpl | 4 + .../default/en/parameters/charges.tmpl | 28 ++++++ .../default/fr/parameters/admin-home.tmpl | 4 + .../default/fr/parameters/charges.tmpl | 33 +++++++ 7 files changed, 179 insertions(+), 111 deletions(-) create mode 100755 admin/charges.pl rename updatecharges.pl => admin/updatecharges.pl (62%) delete mode 100755 charges.pl create mode 100644 koha-tmpl/intranet-tmpl/default/en/parameters/charges.tmpl create mode 100644 koha-tmpl/intranet-tmpl/default/fr/parameters/charges.tmpl diff --git a/admin/charges.pl b/admin/charges.pl new file mode 100755 index 0000000000..090b938095 --- /dev/null +++ b/admin/charges.pl @@ -0,0 +1,95 @@ +#!/usr/bin/perl + +# Copyright 2000-2002 Katipo Communications +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA + +use strict; +use CGI; +use C4::Context; +use C4::Output; +use C4::Database; +use C4::Auth; +use C4::Output; +use C4::Interface::CGI::Output; +use HTML::Template; + +my $input = new CGI; + +my $flagsrequired; +$flagsrequired->{circulation}=1; +my ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "parameters/charges.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {parameters => 1}, + debug => 1, + }); + +my $type=$input->param('type'); + +my $dbh = C4::Context->dbh; +my $query="Select description,categorycode from categories"; +my $sth=$dbh->prepare($query); +$sth->execute; + my @trow3; +my @title_loop; +my $i=0; +while (my $data=$sth->fetchrow_hashref){ + my %row = (in_title => $data->{'description'}); + push @title_loop,\%row; + $trow3[$i]=$data->{'categorycode'}; + $i++; +} +$sth->finish; +$query="Select description,itemtype from itemtypes"; +$sth=$dbh->prepare($query); +$sth->execute; +$i=0; +my $toggle="white"; +my @row_loop; +while (my $data=$sth->fetchrow_hashref){ + my @trow2; + my @cell_loop; + if ( $toggle eq 'white' ) { + $toggle = '#ffffcc'; + } else { + $toggle = 'white'; + } + for ($i=0;$i<9;$i++){ + $query="select * from categoryitem where categorycode=? and itemtype=?"; + my $sth2=$dbh->prepare($query); + $sth2->execute($trow3[$i],$data->{'itemtype'}); + my $dat=$sth2->fetchrow_hashref; + $sth2->finish; + my $fine=$dat->{'fine'}+0; +# $trow2[$i]="{'itemtype'}\" value=\"$fine,$dat->{'firstremind'},$dat->{'chargeperiod'}\" size=6>"; + my %row = (inputname=> "$trow3[$i].$data->{'itemtype'}", + inputvalue => "$fine,$dat->{'firstremind'},$dat->{'chargeperiod'}", + toggle => $toggle, + ); + push @cell_loop,\%row; + } + my %row = (categorycode => $data->{description}, + cell =>\@cell_loop); + push @row_loop, \%row; +} + +$sth->finish; +$template->param(title => \@title_loop, + row => \@row_loop); +output_html_with_http_headers $input, $cookie, $template->output; diff --git a/updatecharges.pl b/admin/updatecharges.pl similarity index 62% rename from updatecharges.pl rename to admin/updatecharges.pl index c29f986ad3..4915ff24d7 100755 --- a/updatecharges.pl +++ b/admin/updatecharges.pl @@ -31,35 +31,25 @@ use C4::Context; use C4::Output; my $input = new CGI; -#print $input->header; -#print startpage(); -#print startmenu('issue'); - my $dbh = C4::Context->dbh; -#print $input->dump; my @names=$input->param(); 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]
"; - 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]); -} + my $bor=$1; + my $cat=$2; + my $data=$input->param($key); + my @dat=split(',',$data); + 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}) { + $sth_update->execute($dat[0],$dat[1],$dat[2],$bor,$cat); + } else { + $sth_insert->execute($bor,$cat,$dat[0],$dat[1],$dat[2]); + } } -print $input->redirect("/cgi-bin/koha/charges.pl"); -#print endmenu('issue'); -#print endpage(); +print $input->redirect("/cgi-bin/koha/admin/charges.pl"); diff --git a/charges.pl b/charges.pl deleted file mode 100755 index 5e481aabbf..0000000000 --- a/charges.pl +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/perl - -#script to display reports -#written 8/11/99 - - -# Copyright 2000-2002 Katipo Communications -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA - -use strict; -use CGI; -use C4::Context; -use C4::Output; -use C4::Database; -use C4::Auth; - -my $input = new CGI; - -my $flagsrequired; -$flagsrequired->{circulation}=1; -my ($loggedinuser, $cookie, $sessionID) = checkauth($input, 0, $flagsrequired); - - -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
-eg 1,7,7 = $1 fine, after 7 days, every 7 days"; - -my $dbh = C4::Context->dbh; -my $query="Select description,categorycode from categories"; -my $sth=$dbh->prepare($query); -$sth->execute; -print mktablehdr; -my @trow; -my @trow3; -my $i=0; -while (my $data=$sth->fetchrow_hashref){ - $trow[$i]=$data->{'description'}; - $trow3[$i]=$data->{'categorycode'}; - $i++; -} -$sth->finish; -print mktablerow(10,'white','',@trow); -print "
"; -$query="Select description,itemtype from itemtypes"; -$sth=$dbh->prepare($query); -$sth->execute; -$i=0; - -while (my $data=$sth->fetchrow_hashref){ - my @trow2; - for ($i=0;$i<9;$i++){ - $query="select * from categoryitem where categorycode=? and itemtype=?"; - my $sth2=$dbh->prepare($query); - $sth2->execute($trow3[$i],$data->{'itemtype'}); - my $dat=$sth2->fetchrow_hashref; - $sth2->finish; - my $fine=$dat->{'fine'}+0; - $trow2[$i]="{'itemtype'}\" value=\"$fine,$dat->{'firstremind'},$dat->{'chargeperiod'}\" size=6>"; - } - print mktablerow(11,'white',$data->{'description'},@trow2); -} - -$sth->finish; - - -print ""; -print "
"; -print endmenu('issue'); -print endpage(); diff --git a/koha-tmpl/intranet-tmpl/default/en/parameters/admin-home.tmpl b/koha-tmpl/intranet-tmpl/default/en/parameters/admin-home.tmpl index d30174cc15..e9824870a9 100644 --- a/koha-tmpl/intranet-tmpl/default/en/parameters/admin-home.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/parameters/admin-home.tmpl @@ -16,6 +16,10 @@ Book funds Book fund administration. Remember to edit your book funds before you start editing the budgets. + + Charges + Charges amounts for itemtypes / borrower types. + Budget The monies allocated to your book funds. diff --git a/koha-tmpl/intranet-tmpl/default/en/parameters/charges.tmpl b/koha-tmpl/intranet-tmpl/default/en/parameters/charges.tmpl new file mode 100644 index 0000000000..01d3de063c --- /dev/null +++ b/koha-tmpl/intranet-tmpl/default/en/parameters/charges.tmpl @@ -0,0 +1,28 @@ + +

+Each box needs to be filled in with fine,time to start charging,charging cycle
+eg 1,7,7 = $1 fine, after 7 days, every 7 days

+

Note : fines are calculated by the fines2.pl script, located in misc directory. +Ask your administrator to put this script in crontab (after midnight) to have fines calculated every night +

+
+ + + + + + + + + + + + +
 
+ + "> + " value="" size=6 maxlength=10> +
+
+
+ diff --git a/koha-tmpl/intranet-tmpl/default/fr/parameters/admin-home.tmpl b/koha-tmpl/intranet-tmpl/default/fr/parameters/admin-home.tmpl index 9089a78228..8dddbf81e1 100644 --- a/koha-tmpl/intranet-tmpl/default/fr/parameters/admin-home.tmpl +++ b/koha-tmpl/intranet-tmpl/default/fr/parameters/admin-home.tmpl @@ -17,6 +17,10 @@ Fonds Les différents fonds et leurs budgets + + Amendes + Les amendes en fonction du type d'exemplaire et du type de lecteur. + Valeurs autorisées Les différentes catégories et les valeurs autorisées pour chaque catégorie. diff --git a/koha-tmpl/intranet-tmpl/default/fr/parameters/charges.tmpl b/koha-tmpl/intranet-tmpl/default/fr/parameters/charges.tmpl new file mode 100644 index 0000000000..33580b3670 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/default/fr/parameters/charges.tmpl @@ -0,0 +1,33 @@ + +

+Chaque zone doit être remplie avec : +

    +
  • Le montant de l'amende
  • +
  • Le retard toléré avant amende
  • +
  • La période de répétition de l'amende
  • +
+exemple : 1,7,7 1Euro d'amende après 7 jours, tous les 7 jours.

+

Note : Les amendes sont calculées par le script fines2.pl situé dans le répertoire misc. +Demandez à votre administrateur de mettre ce script dans la crontab (après minuit) pour que les amendes soient calculées toutes les nuits. +

+
+ + + + + + + + + + + + +
 
+ + "> + " value="" size=6 maxlength=10> +
+
+
+ -- 2.39.2