[Koha-patches] [PATCH] Add predefined fee types

Colin Campbell colin.campbell at ptfs-europe.com
Sat Jul 25 11:22:51 CEST 2009


From: PTFS <koha-dev at ptfs.com>

Ability in system administration to define additional fee and fine options that appear in dropdown box
on the create manual invoice tab in patron fines.

To use create authorised values with the category MANUAL_INV,
Authorized Value is the description, and Description is the default fee, if any.

This work sponsered by East Brunswick Public Library, East Brunswick, NJ, USA

Signed-off-by: Colin Campbell <colin.campbell at ptfs-europe.com>
---
 .../prog/en/modules/members/maninvoice.tmpl        |   31 +++++++++++++++----
 members/maninvoice.pl                              |   13 +++++++-
 2 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tmpl
index e4824f5..a7c49e8 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tmpl
@@ -41,13 +41,30 @@ $(document).ready(function(){
 	<fieldset class="rows">
 	<legend>Manual Invoice</legend>
 	<ol>
-	<li><label for="type">Type: </label><select name="type" id="type">
-<option value="L">Lost Item</option>
-<option value="F">Fine</option>
-<option value="A">Account Management Fee</option>
-<option value="N">New Card</option>
-<option value="M">Sundry</option>
-</select></li>
+      <li>
+<script type="text/javascript">
+var type_fees = new Array();
+type_fees['L'] = '';
+type_fees['F'] = '';
+type_fees['A'] = '';
+type_fees['N'] = '';
+type_fees['M'] = '';
+<!-- TMPL_LOOP NAME="invoice_types_loop" -->
+type_fees['<!-- TMPL_VAR NAME="authorised_value" -->'] = "<!-- TMPL_VAR NAME="lib" -->";
+<!-- /TMPL_LOOP -->
+</script>
+        <label for="type">Type: </label>
+        <select name="type" id="type" onchange="this.form.desc.value=this.options[this.selectedIndex].value; this.form.amount.value=type_fees[this.options[this.selectedIndex].value];">
+          <option value="L">Lost Item</option>
+          <option value="F">Fine</option>
+          <option value="A">Account Management Fee</option>
+          <option value="N">New Card</option>
+          <option value="M">Sundry</option>
+          <!-- TMPL_LOOP NAME="invoice_types_loop" -->
+            <option value="<!-- TMPL_VAR NAME="authorised_value" -->"><!--TMPL_VAR NAME="authorised_value" --></option>
+          <!-- /TMPL_LOOP -->
+        </select>
+      </li>
 	<li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li>
 	<li><label for="desc">Description: </label><input type="text" name="desc" id="desc" size="50" /></li>
 	<li><label for="amount">Amount: </label><input type="text" name="amount" id="amount" /> Example: 5.00</li>
diff --git a/members/maninvoice.pl b/members/maninvoice.pl
index 4ad2067..8eb42ad 100755
--- a/members/maninvoice.pl
+++ b/members/maninvoice.pl
@@ -34,13 +34,14 @@ my $input=new CGI;
 
 my $borrowernumber=$input->param('borrowernumber');
 
+
 # get borrower details
 my $data=GetMember($borrowernumber,'borrowernumber');
 my $add=$input->param('add');
 if ($add){
 #  print $input->header;
     my $barcode=$input->param('barcode');
-	my $itemnum = GetItemnumberFromBarcode($barcode) if $barcode;
+    my $itemnum = GetItemnumberFromBarcode($barcode) if $barcode;
     my $desc=$input->param('desc');
     my $amount=$input->param('amount');
     my $type=$input->param('type');
@@ -75,6 +76,16 @@ if ($add){
 					debug => 1,
 					});
 					
+  # get authorised values with type of MANUAL_INV
+  my @invoice_types;
+  my $dbh = C4::Context->dbh;
+  my $sth = $dbh->prepare('SELECT * FROM authorised_values WHERE category = "MANUAL_INV"');
+  $sth->execute();
+  while ( my $row = $sth->fetchrow_hashref() ) {
+    push @invoice_types, $row;
+  }
+  $template->param( invoice_types_loop => \@invoice_types );
+
     if ( $data->{'category_type'} eq 'C') {
         my  ( $catcodes, $labels ) =  GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
         my $cnt = scalar(@$catcodes);
-- 
1.6.2.5




More information about the Koha-patches mailing list