koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] koha admin/issuingrules.pl koha-tmpl/intranet-t...


From: Henri-Damien LAURENT
Subject: [Koha-cvs] koha admin/issuingrules.pl koha-tmpl/intranet-t...
Date: Mon, 16 Apr 2007 16:54:34 +0000

CVSROOT:        /cvsroot/koha
Module name:    koha
Changes by:     Henri-Damien LAURENT <hdl>      07/04/16 16:54:33

Modified files:
        admin          : issuingrules.pl 
        koha-tmpl/intranet-tmpl/prog/en/admin: issuingrules.tmpl 
Added files:
        admin          : finesrules.pl 
        koha-tmpl/intranet-tmpl/prog/en/admin: finesrules.tmpl 

Log message:
        Adding Finerules script.
        It tears issuingrules script into two.
        + Fixing save button that would bring back to default branch.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/admin/issuingrules.pl?cvsroot=koha&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/koha/admin/finesrules.pl?cvsroot=koha&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/admin/issuingrules.tmpl?cvsroot=koha&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/admin/finesrules.tmpl?cvsroot=koha&rev=1.1

Patches:
Index: admin/issuingrules.pl
===================================================================
RCS file: /cvsroot/koha/koha/admin/issuingrules.pl,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- admin/issuingrules.pl       9 Mar 2007 14:30:55 -0000       1.12
+++ admin/issuingrules.pl       16 Apr 2007 16:54:33 -0000      1.13
@@ -51,10 +51,6 @@
        my @names=$input->param();
        my $sth_search = $dbh->prepare("select count(*) as total from 
issuingrules where branchcode=? and categorycode=? and itemtype=?");
 
-       my $sth_Finsert = $dbh->prepare("insert into issuingrules 
(branchcode,categorycode,itemtype,fine,firstremind,chargeperiod) values 
(?,?,?,?,?,?)");
-       my $sth_Fupdate=$dbh->prepare("Update issuingrules set 
fine=?,firstremind=?,chargeperiod=? where branchcode=? and categorycode=? and 
itemtype=?");
-       my $sth_Fdelete=$dbh->prepare("delete from issuingrules where 
branchcode=? and categorycode=? and itemtype=? and issuelength=0");
-
        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");
@@ -78,25 +74,6 @@
 #                              $sth_Idelete->execute($br,$bor,$cat);
 #                      }
                }
-               # FINES
-               if ($key =~ /F-(.*)-(.*)\.(.*)/) {
-                       my $br = $1; # branch
-                       my $bor = $2; # borrower category
-                       my $cat = $3; # item type
-                       my $data=$input->param($key);
-                       my ($fine,$firstremind,$chargeperiod)=split(',',$data);
-#                      if ($fine >0) {
-                               $sth_search->execute($br,$bor,$cat);
-                               my $res = $sth_search->fetchrow_hashref();
-                               if ($res->{total}) {
-                                       
$sth_Fupdate->execute($fine,$firstremind,$chargeperiod,$br,$bor,$cat);
-                               } else {
-                                       
$sth_Finsert->execute($br,$bor,$cat,$fine,$firstremind,$chargeperiod);
-                               }
-#                      } else {
-#                              $sth_Fdelete->execute($br,$bor,$cat);
-#                      }
-               }
        }
 
 }
@@ -162,16 +139,8 @@
                my $finesvalue;
                $finesvalue= 
"$fine,$dat->{'firstremind'},$dat->{'chargeperiod'}" if 
$fine+$dat->{'firstremind'}+$dat->{'chargeperiod'}>0;
                my $issuingvalue;
-#              if ($maxissueqty>0) {
                    $issuingvalue = "$issuelength,$maxissueqty,$rentaldiscount" 
if $issuelength+$maxissueqty>0;
-#              }
-#              else {          
-#                  $issuingvalue = "$issuelength, 5";
-#                  $maxissueqty = 5;
-#              }
-               my %row = (finesname=> 
"F-$branch-$trow3[$i].$$data->{'itemtype'}",
-                                       finesvalue => $finesvalue,
-                                       issuingname => 
"I-$branch-$trow3[$i].$$data->{itemtype}",
+               my %row = (     issuingname => 
"I-$branch-$trow3[$i].$$data->{itemtype}",
                                        issuingvalue => $issuingvalue,
                                        toggle => $toggle,
                                        );

Index: koha-tmpl/intranet-tmpl/prog/en/admin/issuingrules.tmpl
===================================================================
RCS file: 
/cvsroot/koha/koha/koha-tmpl/intranet-tmpl/prog/en/admin/issuingrules.tmpl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- koha-tmpl/intranet-tmpl/prog/en/admin/issuingrules.tmpl     11 Mar 2007 
21:08:12 -0000      1.2
+++ koha-tmpl/intranet-tmpl/prog/en/admin/issuingrules.tmpl     16 Apr 2007 
16:54:33 -0000      1.3
@@ -10,12 +10,7 @@
                <h3>HINT for issues</h3>
                <p>Each box needs to be filled in with issuelength,maxissues</p>
                <p>eq 21,5</span> enables 5 issues for 21 days</p>
-               
-       <div class="help">
-               <h3>HINT for fines</h3>
-               <p>Each box needs to be filled in with fine,time to start 
charging,charging cycle</p>
-               <p>eg 1,7,7</span> = 1 [USD,EUR,etc] fine after 7 days, every 7 
days</p>
-               <p>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>
+       </div>
        
        <div class="help">
                <h3>Default values</h3>
@@ -27,7 +22,7 @@
                        <li>everywhere</li>
                        <li>If nothing is set, default is 21,5 (hardcoded)</li>
                </ul>
-       
+       </div>
                <form method="post" 
action="/cgi-bin/koha/admin/issuingrules.pl">
                <label for="branch">Select a branch :</label>
                        <select id="branch" name="branch">
@@ -38,19 +33,19 @@
                </form>
                <form method="post" 
action="/cgi-bin/koha/admin/issuingrules.pl">
                        <input type="hidden" name="op" value="save" />
+                       <input type="hidden" name="branch" value="<!-- TMPL_VAR 
NAME="branch" -->" />
                        
                        <table>
                        <caption>Defining issuing rules for <!-- TMPL_VAR 
NAME="branch" --></caption>
                        <tr>
-                               <th>&nbsp;</th><!-- TMPL_LOOP NAME="title" 
--><th scope="col"><!-- TMPL_VAR NAME="in_title" --><br/>Issue / fine</th><!-- 
/TMPL_LOOP -->
+                               <th>&nbsp;</th><!-- TMPL_LOOP NAME="title" 
--><th scope="col"><!-- TMPL_VAR NAME="in_title" --></th><!-- /TMPL_LOOP -->
                        </tr>
                        <!-- TMPL_LOOP NAME="row" -->
                                <tr>
                                        <th><!-- TMPL_VAR NAME="categorycode" 
--></th>
                                        <!-- TMPL_LOOP NAME="cell" -->
                                                <td<!-- TMPL_IF NAME="toggle" 
--> class="highlight"<!-- /TMPL_IF -->>
-                                                       <input name="<!-- 
TMPL_VAR NAME="issuingname" -->" value="<!-- TMPL_VAR NAME="issuingvalue" -->" 
size="6" maxlength="10" /> /
-                                                       <input name="<!-- 
TMPL_VAR NAME="finesname" -->" value="<!-- TMPL_VAR NAME="finesvalue" -->" 
size="6" maxlength="10" />
+                                                       <input name="<!-- 
TMPL_VAR NAME="issuingname" -->" value="<!-- TMPL_VAR NAME="issuingvalue" -->" 
size="6" maxlength="10" />
                                                </td>
                                        <!-- /TMPL_LOOP -->
                                </tr>

Index: admin/finesrules.pl
===================================================================
RCS file: admin/finesrules.pl
diff -N admin/finesrules.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ admin/finesrules.pl 16 Apr 2007 16:54:33 -0000      1.1
@@ -0,0 +1,160 @@
+#!/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::Auth;
+use C4::Output;
+use C4::Koha;
+use C4::Interface::CGI::Output;
+use C4::Branch; # GetBranches
+
+my $input = new CGI;
+my $dbh = C4::Context->dbh;
+
+my $type=$input->param('type');
+my $branch = $input->param('branch');
+$branch="" unless $branch;
+my $op = $input->param('op');
+
+# my $flagsrequired;
+# $flagsrequired->{circulation}=1;
+my ($template, $loggedinuser, $cookie)
+    = get_template_and_user({template_name => "admin/finesrules.tmpl",
+                             query => $input,
+                             type => "intranet",
+                             authnotrequired => 0,
+                            flagsrequired => {parameters => 1},
+                             debug => 1,
+                             });
+# save the values entered
+if ($op eq 'save') {
+  my @names=$input->param();
+  my $sth_search = $dbh->prepare("select count(*) as total from issuingrules 
where branchcode=? and categorycode=? and itemtype=?");
+
+  my $sth_Finsert = $dbh->prepare("insert into issuingrules 
(branchcode,categorycode,itemtype,fine,firstremind,chargeperiod) values 
(?,?,?,?,?,?)");
+  my $sth_Fupdate=$dbh->prepare("Update issuingrules set 
fine=?,firstremind=?,chargeperiod=? where branchcode=? and categorycode=? and 
itemtype=?");
+  my $sth_Fdelete=$dbh->prepare("delete from issuingrules where branchcode=? 
and categorycode=? and itemtype=? and issuelength=0");
+
+  foreach my $key (@names){
+    # FINES
+    if ($key =~ /F-(.*)-(.*)\.(.*)/) {
+      my $br = $1; # branch
+      my $bor = $2; # borrower category
+      my $cat = $3; # item type
+      my $data=$input->param($key);
+      my ($fine,$firstremind,$chargeperiod)=split(',',$data);
+      warn "$br $bor $cat $fine $firstremind $chargeperiod";
+#                      if ($fine >0) {
+#       $br="*" unless ($br);
+      $bor="*" unless ($bor);
+      $cat="*" unless ($cat);
+      $sth_search->execute($br,$bor,$cat);
+      my $res = $sth_search->fetchrow_hashref();
+      if ($res->{total}) {
+              
$sth_Fupdate->execute($fine,$firstremind,$chargeperiod,$br,$bor,$cat);
+      } else {
+              
$sth_Finsert->execute($br,$bor,$cat,$fine,$firstremind,$chargeperiod);
+      }
+    }
+  }
+
+}
+my $branches = GetBranches;
+my @branchloop;
+foreach my $thisbranch (keys %$branches) {
+       my $selected = 1 if $thisbranch eq $branch;
+       my %row =(value => $thisbranch,
+                               selected => $selected,
+                               branchname => 
$branches->{$thisbranch}->{'branchname'},
+                       );
+       push @branchloop, \%row;
+}
+
+my $sth=$dbh->prepare("Select description,categorycode from categories order 
by description");
+$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;
+       push @trow3,$data->{'categorycode'};
+#      $i++;
+}
+
+my %row = (in_title => "*");
+push @title_loop, \%row;
+push @trow3,'*';
+
+$sth->finish;
+$sth=$dbh->prepare("Select description,itemtype from itemtypes order by 
description");
+$sth->execute;
+# $i=0;
+my $toggle= 1;
+my @row_loop;
+my @itemtypes;
+while (my $row=$sth->fetchrow_hashref){
+       push @itemtypes,\$row;
+}
+my $line;
+$line->{itemtype} = "*";
+$line->{description} = "*";
+push @itemtypes,\$line;
+
+foreach my $data (@itemtypes) {
+       my @trow2;
+       my @cell_loop;
+       if ( $toggle eq 1 ) {
+               $toggle = 0;
+       } else {
+               $toggle = 1;
+       }
+       for (my $i=0;$i<=$#trow3;$i++){
+               my $sth2=$dbh->prepare("select * from issuingrules where 
branchcode=? and categorycode=? and itemtype=?");
+               $sth2->execute($branch,$trow3[$i],$$data->{'itemtype'});
+               my $dat=$sth2->fetchrow_hashref;
+               $sth2->finish;
+               my $fine=$dat->{'fine'}+0;
+               my $finesvalue;
+               $finesvalue= 
"$fine,$dat->{'firstremind'},$dat->{'chargeperiod'}" if 
$fine+$dat->{'firstremind'}+$dat->{'chargeperiod'}>0;
+               my %row = (finesname=> 
"F-$branch-$trow3[$i].$$data->{'itemtype'}",
+                                       finesvalue => $finesvalue,
+                                       toggle => $toggle,
+                                       );
+               push @cell_loop,\%row;
+       }
+       my %row = (categorycode => $$data->{description},
+                                       cell =>address@hidden);
+       push @row_loop, \%row;
+}
+
+$sth->finish;
+$template->param(title => address@hidden,
+                row => address@hidden,
+                branchloop => address@hidden,
+                branch => $branch,
+                intranetcolorstylesheet => 
C4::Context->preference("intranetcolorstylesheet"),
+               intranetstylesheet => 
C4::Context->preference("intranetstylesheet"),
+               IntranetNav => C4::Context->preference("IntranetNav"),
+                                               );
+output_html_with_http_headers $input, $cookie, $template->output;

Index: koha-tmpl/intranet-tmpl/prog/en/admin/finesrules.tmpl
===================================================================
RCS file: koha-tmpl/intranet-tmpl/prog/en/admin/finesrules.tmpl
diff -N koha-tmpl/intranet-tmpl/prog/en/admin/finesrules.tmpl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ koha-tmpl/intranet-tmpl/prog/en/admin/finesrules.tmpl       16 Apr 2007 
16:54:33 -0000      1.1
@@ -0,0 +1,60 @@
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
+<title>Koha &rsaquo; System Administration &rsaquo; Issuing Rules</title>
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+
+<!-- TMPL_INCLUDE NAME="menus.inc" -->
+<!-- TMPL_INCLUDE NAME="menu-admin.inc" -->
+
+       <h1>Defining <!-- TMPL_IF NAME="branch" -->fining rules for <!-- 
TMPL_VAR NAME="branch" --><!-- TMPL_ELSE -->default fining rules<!-- /TMPL_IF 
--></h1>
+               
+       <div class="help">
+               <h3>HINT for fines</h3>
+               <p>Each box needs to be filled in with fine,time to start 
charging,charging cycle</p>
+               <p>eg 1,7,7</span> = 1 [USD,EUR,etc] fine after 7 days, every 7 
days</p>
+               <p>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>
+       </div>
+       <div class="help">
+               <h3>Default values</h3>
+               <p> If a cell is not filled, the 1st of the following value is 
searched :</p>
+               <ul>
+                       <li>same branch and same borrower category, itemtype 
*</li>
+                       <li>same branch and same itemtype, borrower category 
*</li>
+                       <li>same itemtype and borrower category, branch *</li>
+                       <li>branch * and itemtype *, same borrower category</li>
+                       <li>branch * and borrower category *, same itemtype 
</li>
+                       <li>branch * and borrower category *, itemtype *</li>
+               </ul>
+       
+               <form method="post" action="/cgi-bin/koha/admin/finesrules.pl">
+               <label for="branch">Select a branch :</label>
+                       <select id="branch" name="branch">
+                               <option value="">Default</option>
+                       <!-- TMPL_LOOP NAME="branchloop" -->
+                               <option value="<!-- TMPL_VAR NAME="value" 
-->"<!-- TMPL_IF NAME="selected" --> selected="selected"<!-- /TMPL_IF -->><!-- 
TMPL_VAR NAME="branchname" --></option><!-- /TMPL_LOOP --></select>
+                       <input type="submit" value="Select" />
+               </form>
+               <form method="post" action="/cgi-bin/koha/admin/finesrules.pl">
+                       <input type="hidden" name="op" value="save" />
+                       <input type="hidden" name="branch" value="<!-- TMPL_VAR 
NAME="branch" -->" />
+                       
+                       <table>
+                       <caption>Defining fines rules for <!-- TMPL_VAR 
NAME="branch" --></caption>
+                       <tr>
+                               <th>&nbsp;</th><!-- TMPL_LOOP NAME="title" 
--><th scope="col"><!-- TMPL_VAR NAME="in_title" --></th><!-- /TMPL_LOOP -->
+                       </tr>
+                       <!-- TMPL_LOOP NAME="row" -->
+                               <tr>
+                                       <th><!-- TMPL_VAR NAME="categorycode" 
--></th>
+                                       <!-- TMPL_LOOP NAME="cell" -->
+                                               <td<!-- TMPL_IF NAME="toggle" 
--> class="highlight"<!-- /TMPL_IF -->>
+                                                       <input name="<!-- 
TMPL_VAR NAME="finesname" -->" value="<!-- TMPL_VAR NAME="finesvalue" -->" 
size="6" maxlength="10" />
+                                               </td>
+                                       <!-- /TMPL_LOOP -->
+                               </tr>
+                       <!-- /TMPL_LOOP -->
+                       </table>
+                       
+                       <input type="submit" value="Save Changes" />
+               </form>
+
+<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->




reply via email to

[Prev in Thread] Current Thread [Next in Thread]