bug 2000 - alternate issuing rules - some form cleanup
authorGalen Charlton <galen.charlton@liblime.com>
Fri, 20 Jun 2008 13:11:14 +0000 (08:11 -0500)
committerJoshua Ferraro <jmf@liblime.com>
Fri, 20 Jun 2008 13:19:00 +0000 (08:19 -0500)
Improvements to smart-rules.pl to allow it to
replace issuingrules.pl.

* standardized "borrower type" to "patron category"
* made default item type and patron category ('Any')
  translatable
* regularized construction of parameters for rule
  deletion operatrion

Signed-off-by: Joshua Ferraro <jmf@liblime.com>
admin/smart-rules.pl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tmpl

index 01dbb60..bc9f9a7 100755 (executable)
@@ -44,9 +44,9 @@ my ($template, $loggedinuser, $cookie)
                             debug => 1,
                             });
 
-if ($op =~ /delete-(.+)-(.+)/) {
-    my $itemtype = $1;
-    my $categorycode = $2;
+if ($op eq 'delete') {
+    my $itemtype     = $input->param('itemtype');
+    my $categorycode = $input->param('categorycode');
     $debug and warn "deleting $1 $2 $branch";
 
     my $sth_Idelete = $dbh->prepare("delete from issuingrules where branchcode=? and categorycode=? and itemtype=?");
@@ -94,9 +94,6 @@ while (my $data=$sth->fetchrow_hashref){
     push @category_loop,$data;
 }
 
-my %row = (categorycode => "*", description => 'Any');
-push @category_loop, \%row;
-
 $sth->finish;
 $sth=$dbh->prepare("SELECT description,itemtype FROM itemtypes ORDER BY description");
 $sth->execute;
@@ -107,8 +104,6 @@ my @itemtypes;
 while (my $row=$sth->fetchrow_hashref){
     push @itemtypes,$row;
 }
-my %row = (itemtype => '*', description => 'Any');
-push @itemtypes,\%row;
 
 my $sth2 = $dbh->prepare("
     SELECT issuingrules.*, itemtypes.description AS humanitemtype, categories.description AS humancategorycode
@@ -123,9 +118,9 @@ $sth2->execute($branch);
 
 while (my $row = $sth2->fetchrow_hashref) {
     $row->{'humanitemtype'} ||= $row->{'itemtype'};
-    $row->{'humanitemtype'} = 'Any' if $row->{'humanitemtype'} eq '*';
+    $row->{'default_humanitemtype'} = 1 if $row->{'humanitemtype'} eq '*';
     $row->{'humancategorycode'} ||= $row->{'categorycode'};
-    $row->{'humancategorycode'} = 'Any' if $row->{'humancategorycode'} eq '*';
+    $row->{'default_humancategorycode'} = 1 if $row->{'humancategorycode'} eq '*';
     $row->{'fine'} = sprintf('%.2f', $row->{'fine'});
     push @row_loop, $row;
 }
index 63f4d7a..a00c16e 100644 (file)
@@ -47,7 +47,7 @@ $(document).ready(function() {
         <form method="get" action="/cgi-bin/koha/admin/smart-rules.pl" id="selectlibrary">
         Select a branch :
             <select name="branch" id="branch" style="width:20em;">
-                <option value="">Default</option>
+                <option value="*">Default</option>
             <!-- TMPL_LOOP NAME="branchloop" -->
                                <!-- TMPL_IF NAME="selected" --><option value="<!-- TMPL_VAR NAME="value" -->" selected="selected"><!-- TMPL_VAR NAME="branchname" --></option><!-- TMPL_ELSE --><option value="<!-- TMPL_VAR NAME="value" -->"><!-- TMPL_VAR NAME="branchname" --></option><!-- /TMPL_IF -->
             <!-- /TMPL_LOOP -->
@@ -59,25 +59,36 @@ $(document).ready(function() {
             <input type="hidden" name="op" value="add" />
             <table>
             <tr>
-                <th>Item Type</th><th>Borrower Type</th><th>Amount</th><th>Grace<br />Period</th><th>Charging<br />Interval</th><th>Amount<br />Loanable</th><th>Loan time</th><th>&nbsp;</th>
+                <th>Item Type</th><th>Patron Category</th><th>Amount</th><th>Grace<br />Period</th><th>Charging<br />Interval</th><th>Amount<br />Loanable</th><th>Loan time</th><th>&nbsp;</th>
             </tr>
             <!-- TMPL_LOOP NAME="rules" -->
                 <tr>
-                    <td><!-- TMPL_VAR NAME="humanitemtype" --></td>
-                    <td><!-- TMPL_VAR NAME="humancategorycode" --></td>
+                    <td><!-- TMPL_IF NAME="default_humanitemtype" -->
+                            Any
+                        <!-- TMPL_ELSE -->
+                            <!-- TMPL_VAR NAME="humanitemtype" -->
+                        <!-- /TMPL_IF -->
+                    </td>
+                    <td><!-- TMPL_IF NAME="default_humancategorycode" -->
+                            Any
+                        <!-- TMPL_ELSE -->
+                            <!-- TMPL_VAR NAME="humancategorycode" -->
+                        <!-- /TMPL_IF -->
+                    </td>
                     <td>$<!-- TMPL_VAR NAME="fine" --></td>
                     <td><!-- TMPL_IF NAME="firstremind" --><!-- TMPL_VAR NAME="firstremind" --> day(s)<!-- /TMPL_IF --></td>
                     <td><!-- TMPL_IF NAME="chargeperiod" --><!-- TMPL_VAR NAME="chargeperiod" --> day(s)<!-- /TMPL_IF --></td>
                     <td><!-- TMPL_VAR NAME="maxissueqty" --></td>
                     <td><!-- TMPL_IF NAME="issuelength" --><!-- TMPL_VAR NAME="issuelength" --> day(s)<!-- /TMPL_IF --></td>
                     <td>
-                        <a class="button" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-<!-- TMPL_VAR NAME="itemtype" -->-<!-- TMPL_VAR NAME="categorycode" -->&amp;branch=<!-- TMPL_VAR NAME="branch" -->">Delete</a>
+                        <a class="button" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;itemtype=<!-- TMPL_VAR NAME="itemtype" -->&amp;categorycode=<!-- TMPL_VAR NAME="categorycode" -->&amp;branch=<!-- TMPL_VAR NAME="branch" -->">Delete</a>
                     </td>
                 </tr>
             <!-- /TMPL_LOOP -->
                 <tr>
                     <td>
                         <select name="itemtype" style="width:13em;">
+                            <option value="*">Any</option>
                         <!-- TMPL_LOOP NAME="itemtypeloop" -->
                             <option value="<!-- TMPL_VAR NAME="itemtype" -->"><!-- TMPL_VAR NAME="description" --></option>
                         <!-- /TMPL_LOOP -->
@@ -85,6 +96,7 @@ $(document).ready(function() {
                     </td>
                     <td>
                         <select name="categorycode">
+                            <option value="*">Any</option>
                         <!-- TMPL_LOOP NAME="categoryloop" -->
                             <option value="<!-- TMPL_VAR NAME="categorycode" -->"><!-- TMPL_VAR NAME="description" --></option>
                         <!-- /TMPL_LOOP -->