moving & templating charges to admin part of Koha
authortipaul <tipaul>
Mon, 6 Oct 2003 13:40:49 +0000 (13:40 +0000)
committertipaul <tipaul>
Mon, 6 Oct 2003 13:40:49 +0000 (13:40 +0000)
admin/charges.pl [new file with mode: 0755]
admin/updatecharges.pl [new file with mode: 0755]
charges.pl [deleted file]
koha-tmpl/intranet-tmpl/default/en/parameters/admin-home.tmpl
koha-tmpl/intranet-tmpl/default/en/parameters/charges.tmpl [new file with mode: 0644]
koha-tmpl/intranet-tmpl/default/fr/parameters/admin-home.tmpl
koha-tmpl/intranet-tmpl/default/fr/parameters/charges.tmpl [new file with mode: 0644]
updatecharges.pl [deleted file]

diff --git a/admin/charges.pl b/admin/charges.pl
new file mode 100755 (executable)
index 0000000..090b938
--- /dev/null
@@ -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]="<input type=text name=\"$trow3[$i].$data->{'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/admin/updatecharges.pl b/admin/updatecharges.pl
new file mode 100755 (executable)
index 0000000..4915ff2
--- /dev/null
@@ -0,0 +1,55 @@
+#!/usr/bin/perl
+
+# $Id$
+
+#script to update charges for overdue in database
+#updates categoryitem
+# is called by charges.pl
+# written 1/1/2000 by chris@katipo.co.nz
+
+
+# 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;
+
+my $input = new CGI;
+
+my $dbh = C4::Context->dbh;
+my @names=$input->param();
+
+foreach my $key (@names){
+       $key =~ /(.*)\.(.*)/;
+       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/admin/charges.pl");
diff --git a/charges.pl b/charges.pl
deleted file mode 100755 (executable)
index 5e481aa..0000000
+++ /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<br>
-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 "<form action=/cgi-bin/koha/updatecharges.pl method=post>";
-$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]="<input type=text name=\"$trow3[$i].$data->{'itemtype'}\" value=\"$fine,$dat->{'firstremind'},$dat->{'chargeperiod'}\" size=6>";
-  }
-  print mktablerow(11,'white',$data->{'description'},@trow2);
-}
-
-$sth->finish;
-
-
-print "</table>";
-print "<input type=submit></form>";
-print endmenu('issue');
-print endpage();
index d30174c..e982487 100644 (file)
        <td>Book fund administration. Remember to edit your book funds before you start editing the budgets.</td>
 </tr>
 <tr>
+       <td valign="top" width="25%"><a href=/cgi-bin/koha/admin/charges.pl>Charges</a></td>
+       <td>Charges amounts for itemtypes / borrower types.</td>
+</tr>
+<tr>
        <td valign="top" width="25%"><a href=/cgi-bin/koha/admin/aqbudget.pl>Budget</a></td>
        <td>The monies allocated to your book funds.</td>
 </tr>
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 (file)
index 0000000..01d3de0
--- /dev/null
@@ -0,0 +1,28 @@
+<TMPL_INCLUDE NAME="parameters-top.inc">
+<p>
+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</p>
+<p>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
+</p>
+<form action=/cgi-bin/koha/admin/updatecharges.pl method=post>
+<table border=0>
+<TR align="center">
+       <th>&nbsp;</th><TMPL_LOOP name="title"><th><TMPL_VAR name="in_title"></th></TMPL_LOOP>
+</TR>
+<TMPL_LOOP name="row">
+       <TR align="center">
+               <th>
+                       <TMPL_VAR name="categorycode">
+               </th>
+               <TMPL_LOOP name="cell">
+                       <td bgcolor="<TMPL_VAR name="toggle">">
+                               <input name="<TMPL_VAR name="inputname">" value="<TMPL_VAR name="inputvalue">" size=6 maxlength=10>
+                       </td>
+               </TMPL_LOOP>
+       </TR>
+</TMPL_LOOP>
+</table>
+<center><input type=submit value="OK"></center>
+</form>
+<TMPL_INCLUDE NAME="parameters-bottom.inc">
index 9089a78..8dddbf8 100644 (file)
        <td>Les différents fonds et leurs budgets</td>
 </tr>
 <tr>
+       <td valign="top" width="25%"><a href=/cgi-bin/koha/admin/charges.pl>Amendes</a></td>
+       <td>Les amendes en fonction du type d'exemplaire et du type de lecteur.</td>
+</tr>
+<tr>
        <td valign="top" width="25%"><a href=/cgi-bin/koha/admin/authorised_values.pl>Valeurs autorisées</a></td>
        <td>Les différentes catégories et les valeurs autorisées pour chaque catégorie.
        Les valeurs autorisées sont utilisées dans la saisie des notices MARc pour faciliter la saisie.</td>
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 (file)
index 0000000..33580b3
--- /dev/null
@@ -0,0 +1,33 @@
+<TMPL_INCLUDE NAME="parameters-top.inc">
+<p>
+Chaque zone doit être remplie avec :
+<ul>
+<li>Le montant de l'amende</li>
+<li>Le retard toléré avant amende</li>
+<li>La période de répétition de l'amende</li>
+</ul>
+exemple : 1,7,7 1Euro d'amende après 7 jours, tous les 7 jours.</p>
+<p>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.
+</p>
+<form action=/cgi-bin/koha/admin/updatecharges.pl method=post>
+<table border=0>
+<TR align="center">
+       <th>&nbsp;</th><TMPL_LOOP name="title"><th><TMPL_VAR name="in_title"></th></TMPL_LOOP>
+</TR>
+<TMPL_LOOP name="row">
+       <TR align="center">
+               <th>
+                       <TMPL_VAR name="categorycode">
+               </th>
+               <TMPL_LOOP name="cell">
+                       <td bgcolor="<TMPL_VAR name="toggle">">
+                               <input name="<TMPL_VAR name="inputname">" value="<TMPL_VAR name="inputvalue">" size=6 maxlength=10>
+                       </td>
+               </TMPL_LOOP>
+       </TR>
+</TMPL_LOOP>
+</table>
+<center><input type=submit value="OK"></center>
+</form>
+<TMPL_INCLUDE NAME="parameters-bottom.inc">
diff --git a/updatecharges.pl b/updatecharges.pl
deleted file mode 100755 (executable)
index c29f986..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/usr/bin/perl
-
-# $Id$
-
-#script to update charges for overdue in database
-#updates categoryitem
-# is called by charges.pl
-# written 1/1/2000 by chris@katipo.co.nz
-
-
-# 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;
-
-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] <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");
-#print endmenu('issue');
-#print endpage();