[Koha-patches] [PATCH] Cleanup authtypes and currency .pl and .tmpl

Joe Atzberger joe.atzberger at liblime.com
Wed Jun 10 21:04:50 CEST 2009


Removed unused javascript.  Enabled warnings.  Use common $dbh.
Removed sth->finish calls.  Removed toggle code.  Added row highlight where
none had been implemented.  Added some HTML escaping in TMPL.
---
 admin/authtypes.pl                                 |  140 ++++++----------
 admin/currency.pl                                  |   85 +++------
 .../prog/en/modules/admin/authtypes.tmpl           |  108 ++++++------
 .../prog/en/modules/admin/currency.tmpl            |  183 ++++++++------------
 4 files changed, 207 insertions(+), 309 deletions(-)

diff --git a/admin/authtypes.pl b/admin/authtypes.pl
index d360680..8789559 100755
--- a/admin/authtypes.pl
+++ b/admin/authtypes.pl
@@ -1,7 +1,6 @@
 #!/usr/bin/perl
-# NOTE: 4-character tabs
 
-#written 20/02/2002 by paul.poulain at free.fr
+# written 20/02/2002 by paul.poulain at free.fr
 # This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html)
 
 # Copyright 2000-2002 Katipo Communications
@@ -22,37 +21,25 @@
 # Suite 330, Boston, MA  02111-1307 USA
 
 use strict;
+use warnings;
 use CGI;
 use C4::Context;
 use C4::Auth;
 use C4::Output;
 
-
 sub StringSearch  {
-    my ($searchstring,$type)=@_;
-    my $dbh = C4::Context->dbh;
-    $searchstring=~ s/\'/\\\'/g;
-    my @data=split(' ',$searchstring);
-    my $count=@data;
-    my $sth=$dbh->prepare("SELECT * FROM auth_types WHERE (authtypecode like ?) ORDER BY authtypecode");
-    $sth->execute("$data[0]%");
-    my @results;
-    while (my $data=$sth->fetchrow_hashref){
-    push(@results,$data);
-    }
-    #  $sth->execute;
-    $sth->finish;
-    return (scalar(@results),\@results);
+    my $sth = C4::Context->dbh->prepare("SELECT * FROM auth_types WHERE (authtypecode like ?) ORDER BY authtypecode");
+    $sth->execute((shift || '') . "%");
+    return $sth->fetchall_arrayref({});
 }
 
 my $input = new CGI;
-my $searchfield=$input->param('authtypecode');
-my $offset=$input->param('offset');
-my $script_name="/cgi-bin/koha/admin/authtypes.pl";
-my $authtypecode=$input->param('authtypecode');
-my $pagesize=20;
-my $op = $input->param('op');
-$searchfield=~ s/\,//g;
+my $script_name  = "/cgi-bin/koha/admin/authtypes.pl";
+my $searchfield  = $input->param('authtypecode');  # FIXME: Auth Type search not really implemented
+my $authtypecode = $input->param('authtypecode');
+my $offset       = $input->param('offset') || 0;
+my $op           = $input->param('op')     || '';
+my $pagesize     = 20;
 my ($template, $borrowernumber, $cookie)
     = get_template_and_user({template_name => "admin/authtypes.tmpl",
                 query => $input,
@@ -62,101 +49,76 @@ my ($template, $borrowernumber, $cookie)
                 debug => 1,
                 });
 
-if ($op) {
-$template->param(script_name => $script_name,
-                        $op              => 1); # we show only the TMPL_VAR names $op
-} else {
-$template->param(script_name => $script_name,
-                        'else'              => 1); # we show only the TMPL_VAR names $op
-}
-################## ADD_FORM ##################################
+$template->param(
+    script_name => $script_name,
+    ($op || 'else') => 1,
+);
+
+my $dbh = C4::Context->dbh;
+
 # called by default. Used to create form to add or  modify a record
 if ($op eq 'add_form') {
-    #start the page and read in includes
     #---- if primkey exists, it's a modify action, so read values to modify...
-    my $data;
     if ($authtypecode) {
-        my $dbh = C4::Context->dbh;
-        my $sth=$dbh->prepare("SELECT * FROM auth_types WHERE authtypecode=?");
+        my $sth = $dbh->prepare("SELECT * FROM auth_types WHERE authtypecode=?");
         $sth->execute($authtypecode);
-        $data=$sth->fetchrow_hashref;
-        $sth->finish;
-        $template->param(authtypecode => $authtypecode,
-                    authtypetext => $data->{'authtypetext'},
-                    auth_tag_to_report => $data->{'auth_tag_to_report'},
-                    summary => $data->{'summary'},
-                    );
+        my $data = $sth->fetchrow_hashref();
+        $template->param(
+            authtypecode       => $authtypecode,
+            authtypetext       => $data->{'authtypetext'},
+            auth_tag_to_report => $data->{'auth_tag_to_report'},
+            summary            => $data->{'summary'},
+        );
     }
                                                     # END $OP eq ADD_FORM
 ################## ADD_VALIDATE ##################################
 # called by add_form, used to insert/modify data in DB
 } elsif ($op eq 'add_validate') {
-    my $dbh = C4::Context->dbh;
-    if ($input->param('modif')) {
-        my $sth=$dbh->prepare("UPDATE auth_types SET authtypetext=? ,auth_tag_to_report=?, summary=? WHERE authtypecode=?");
-        $sth->execute($input->param('authtypetext'),$input->param('auth_tag_to_report'),$input->param('summary'),$input->param('authtypecode'));
-        $sth->finish;
-    } else {
-        my $sth=$dbh->prepare("INSERT INTO auth_types SET authtypetext=? ,auth_tag_to_report=?, summary=?, authtypecode=?");
-        $sth->execute($input->param('authtypetext'),$input->param('auth_tag_to_report'),$input->param('summary'),$input->param('authtypecode'));
-        $sth->finish;
-    }
-    print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=authtypes.pl\"></html>";
+    my $sth = $input->param('modif') ? 
+            $dbh->prepare("UPDATE auth_types SET authtypetext=? ,auth_tag_to_report=?, summary=? WHERE authtypecode=?") :
+            $dbh->prepare("INSERT INTO auth_types SET authtypetext=?, auth_tag_to_report=?, summary=?, authtypecode=?") ;
+    $sth->execute($input->param('authtypetext'),$input->param('auth_tag_to_report'),$input->param('summary'),$input->param('authtypecode'));
+    print $input->redirect($script_name);    # FIXME: unnecessary redirect
     exit;
                                                     # END $OP eq ADD_VALIDATE
 ################## DELETE_CONFIRM ##################################
 # called by default form, used to confirm deletion of data in DB
 } elsif ($op eq 'delete_confirm') {
     #start the page and read in includes
-    my $dbh = C4::Context->dbh;
-
-    my $total = 0;
-    for my $table ('auth_tag_structure') {
-    my $sth=$dbh->prepare("SELECT count(*) AS total FROM $table WHERE authtypecode=?");
+    my $sth=$dbh->prepare("SELECT count(*) AS total FROM auth_tag_structure WHERE authtypecode=?");
     $sth->execute($authtypecode);
-    $total += $sth->fetchrow_hashref->{total};
-    $sth->finish;
-    }
+    my $total = $sth->fetchrow_hashref->{total};
 
-    my $sth=$dbh->prepare("SELECT * FROM auth_types WHERE authtypecode=?");
-    $sth->execute($authtypecode);
-    my $data=$sth->fetchrow_hashref;
-    $sth->finish;
+    my $sth2 = $dbh->prepare("SELECT * FROM auth_types WHERE authtypecode=?");
+    $sth2->execute($authtypecode);
+    my $data = $sth2->fetchrow_hashref;
 
     $template->param(authtypecode => $authtypecode,
-                            authtypetext => $data->{'authtypetext'},
-                            summary => $data->{'summary'},
+                     authtypetext => $data->{'authtypetext'},
+                          summary => $data->{'summary'},
                             total => $total);
                                                     # END $OP eq DELETE_CONFIRM
 ################## DELETE_CONFIRMED ##################################
 # called by delete_confirm, used to effectively confirm deletion of data in DB
 } elsif ($op eq 'delete_confirmed') {
     #start the page and read in includes
-    my $dbh = C4::Context->dbh;
-    my $authtypecode=uc($input->param('authtypecode'));
     my $sth=$dbh->prepare("DELETE FROM auth_types WHERE authtypecode=?");
-    $sth->execute($authtypecode);
-    $sth->finish;
-    print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=authtypes.pl\"></html>";
+    $sth->execute(uc $input->param('authtypecode'));
+    print $input->redirect($script_name);   # FIXME: unnecessary redirect
     exit;
                                                     # END $OP eq DELETE_CONFIRMED
 ################## DEFAULT ##################################
 } else { # DEFAULT
-    my ($count,$results)=StringSearch($searchfield,'web');
-    my $toggle="white";
+    my $results = StringSearch($searchfield);
+    my $count = scalar @$results;
     my @loop_data;
     for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
-        my %row_data;
-        if ($toggle eq 'white'){
-            $row_data{toggle}="#ffffcc";
-        } else {
-            $row_data{toggle}="white";
-        }
-        $row_data{authtypecode} = $results->[$i]{'authtypecode'};
-        $row_data{authtypetext} = $results->[$i]{'authtypetext'};
-        $row_data{auth_tag_to_report} = $results->[$i]{'auth_tag_to_report'};
-        $row_data{summary} = $results->[$i]{'summary'};
-        push(@loop_data, \%row_data);
+        push @loop_data, {
+            authtypecode       => $results->[$i]{'authtypecode'},
+            authtypetext       => $results->[$i]{'authtypetext'},
+            auth_tag_to_report => $results->[$i]{'auth_tag_to_report'},
+            summary            => $results->[$i]{'summary'},
+        };
     }
     $template->param(loop => \@loop_data);
     if ($offset>0) {
@@ -164,12 +126,8 @@ if ($op eq 'add_form') {
         $template->param(previous => "$script_name?offset=".$prevpage);
     }
     if ($offset+$pagesize<$count) {
-        my $nextpage =$offset+$pagesize;
+        my $nextpage = $offset+$pagesize;
         $template->param(next => "$script_name?offset=".$nextpage);
     }
 } #---- END $OP eq DEFAULT
 output_html_with_http_headers $input, $cookie, $template->output;
-
-# Local Variables:
-# tab-width: 4
-# End:
diff --git a/admin/currency.pl b/admin/currency.pl
index 0a237bc..6c74842 100755
--- a/admin/currency.pl
+++ b/admin/currency.pl
@@ -38,6 +38,7 @@
 # Suite 330, Boston, MA  02111-1307 USA
 
 use strict;
+# use warnings; # FIXME
 use CGI;
 use C4::Context;
 use C4::Auth;
@@ -45,47 +46,33 @@ use C4::Dates qw(format_date);
 use C4::Output;
 
 sub StringSearch  {
-	my ($searchstring,$type)=@_;
-	my $dbh = C4::Context->dbh;
-	$searchstring=~ s/\'/\\\'/g;
-	my @data=split(' ',$searchstring);
-	my $count=@data;
-	my $query="Select * from currency where (currency like \"$data[0]%\") order by currency";
-	my $sth=$dbh->prepare($query);
-	$sth->execute;
-	my @results;
-	my $cnt=0;
-	while (my $data=$sth->fetchrow_hashref){
-	push(@results,$data);
-		$cnt++;
-	}
-	#  $sth->execute;
-	$sth->finish;
-	return ($cnt,\@results);
+	my $query = "SELECT * FROM currency WHERE (currency LIKE ?) ORDER BY currency";
+    warn "$query :: @_[0]";
+	my $sth = C4::Context->dbh->prepare($query);
+	$sth->execute((shift || '') . '%');
+	return $sth->fetchall_arrayref({});
 }
 
 my $input = new CGI;
-my $searchfield=$input->param('searchfield');
-#my $branchcode=$input->param('branchcode');
-my $offset=$input->param('offset');
-my $script_name="/cgi-bin/koha/admin/currency.pl";
-
-my $pagesize=20;
-my $op = $input->param('op');
-$searchfield=~ s/\,//g;
-
-my ($template, $loggedinuser, $cookie) 
-    = get_template_and_user({template_name => "admin/currency.tmpl",
-                             query => $input,
-                             type => "intranet",
-			     flagsrequired => {parameters => 1},
-			     authnotrequired => 0,
-                             debug => 1,
-                             });
+my $searchfield = $input->param('searchfield') || $input->param('description') || '';
+my $offset      = $input->param('offset') || 0;
+my $op          = $input->param('op')     || '';
+my $script_name = "/cgi-bin/koha/admin/currency.pl";
+my $pagesize = 20;
+
+my ($template, $loggedinuser, $cookie) = get_template_and_user({
+    template_name => "admin/currency.tmpl",
+    query => $input,
+     type => "intranet",
+      flagsrequired => {parameters => 1},
+    authnotrequired => 0,
+    debug => 1,
+});
 
 $template->param(searchfield => $searchfield,
 		 script_name => $script_name);
 
+my $dbh = C4::Context->dbh;
 
 ################## ADD_FORM ##################################
 # called by default. Used to create form to add or  modify a record
@@ -94,11 +81,9 @@ if ($op eq 'add_form') {
 	#---- if primkey exists, it's a modify action, so read values to modify...
 	my $data;
 	if ($searchfield) {
-		my $dbh = C4::Context->dbh;
 		my $sth=$dbh->prepare("select * from currency where currency=?");
 		$sth->execute($searchfield);
 		$data=$sth->fetchrow_hashref;
-		$sth->finish;
 	}
 	foreach (keys %$data) {
 		$template->param($_ => $data->{$_});
@@ -110,38 +95,26 @@ if ($op eq 'add_form') {
 # called by add_form, used to insert/modify data in DB
 } elsif ($op eq 'add_validate') {
 	$template->param(add_validate => 1);
-	my $dbh = C4::Context->dbh;
-
 	my $check = $dbh->prepare("select * from currency where currency = ?");
 	$check->execute($input->param('currency'));
-	if ( $check->fetchrow )
-	{
+	if ( $check->fetchrow ) {
 		my $sth = $dbh->prepare("UPDATE currency SET rate = ?, symbol = ?, timestamp = ? WHERE currency = ?");
 		$sth->execute($input->param('rate'),$input->param('symbol'),C4::Dates->new->output('iso'),$input->param('currency'));
-		$sth->finish;
-	}
-	else
-	{
+	} else {
 		my $sth = $dbh->prepare("INSERT INTO currency (currency, rate, symbol) VALUES (?,?,?)");
 		$sth->execute($input->param('currency'),$input->param('rate'),$input->param('symbol'));
-		$sth->finish;
 	}	 
-
-	$check->finish;
 													# END $OP eq ADD_VALIDATE
 ################## DELETE_CONFIRM ##################################
 # called by default form, used to confirm deletion of data in DB
 } elsif ($op eq 'delete_confirm') {
 	$template->param(delete_confirm => 1);
-	my $dbh = C4::Context->dbh;
 	my $sth=$dbh->prepare("select count(*) as total from aqbooksellers where currency=?");
 	$sth->execute($searchfield);
 	my $total = $sth->fetchrow_hashref;
-	$sth->finish;
 	my $sth2=$dbh->prepare("select currency,rate from currency where currency=?");
 	$sth2->execute($searchfield);
 	my $data=$sth2->fetchrow_hashref;
-	$sth2->finish;
 
 	if ($total->{'total'} >0) {
 		$template->param(totalgtzero => 1);
@@ -154,25 +127,23 @@ if ($op eq 'add_form') {
 # called by delete_confirm, used to effectively confirm deletion of data in DB
 } elsif ($op eq 'delete_confirmed') {
 	$template->param(delete_confirmed => 1);
-	my $dbh = C4::Context->dbh;
 	my $sth=$dbh->prepare("delete from currency where currency=?");
 	$sth->execute($searchfield);
-	$sth->finish;
 													# END $OP eq DELETE_CONFIRMED
 ################## DEFAULT ##################################
 } else { # DEFAULT
 	$template->param(else => 1);
 
-	my ($count,$results)=StringSearch($searchfield,'web');
+	my $results = StringSearch($searchfield);
+    my $count = scalar(@$results);
 	my @loop;
 	for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
-		my %row = (
+        push @loop, {
 			currency => $results->[$i]{'currency'},
 			    rate => $results->[$i]{'rate'},
 			  symbol => $results->[$i]{'symbol'},
 		   timestamp => format_date($results->[$i]{'timestamp'}),
-		);
-		push @loop, \%row;
+		};
 	}
 	$template->param(loop => \@loop);
 
@@ -181,7 +152,7 @@ if ($op eq 'add_form') {
 				 prevpage => $offset-$pagesize);
 	}
 
-	if ($offset+$pagesize<$count) {
+	if ($offset+$pagesize < scalar @$results) {
 		$template->param(ltcount => 1,
 				 nextpage => $offset+$pagesize);
 	}
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authtypes.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authtypes.tmpl
index 774d947..1a21466 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authtypes.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authtypes.tmpl
@@ -1,5 +1,11 @@
 <!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
-<title>Koha &rsaquo; Administration &rsaquo; <!-- TMPL_IF NAME="add_form" --><!-- TMPL_IF NAME="authtypecode" --> Authority Types &rsaquo; Modify authority type<!-- TMPL_ELSE --> Authority Types &rsaquo; New authority type<!-- /TMPL_IF --><!-- TMPL_ELSE --><!-- TMPL_IF NAME="delete_confirm" -->Authority Types &rsaquo; Confirm Deletion of Authority Type<!-- TMPL_ELSE -->Authority Types<!-- /TMPL_IF --><!-- /TMPL_IF --></title>
+<title>Koha &rsaquo; Administration &rsaquo; Authority Types
+<!-- TMPL_IF NAME="add_form" -->
+&rsaquo; <!-- TMPL_IF NAME="authtypecode" -->Modify authority type<!-- TMPL_ELSE -->New authority type<!-- /TMPL_IF -->
+<!-- TMPL_ELSIF NAME="delete_confirm" -->
+&rsaquo; Confirm Deletion of Authority Type
+<!-- /TMPL_IF -->
+</title>
 <!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
 <script type="text/javascript">
 //<![CDATA[
@@ -17,26 +23,7 @@ function toUC(f) {
 	return true;
 }
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-function isNum(v,maybenull) {
-var n = new Number(v.value);
-if (isNaN(n)) {
-	return false;
-	}
-if (maybenull==0 && v.value=='') {
-	return false;
-}
-return true;
-}
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-function isDate(f) {
-	var t = Date.parse(f.value);
-	if (isNaN(t)) {
-		return false;
-	}
-}
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 function Check(f) {
-	var ok=1;
 	var _alertString="";
 	var alertString2;
 	if (f.authtypecode.value.length==0) {
@@ -54,6 +41,10 @@ function Check(f) {
 		alert(alertString2);
 	}
 }
+
+$(document).ready(function() {
+    new YAHOO.widget.Button("authtype");
+});
 //]]>
 </script>
 </head>
@@ -61,42 +52,60 @@ function Check(f) {
 <!-- TMPL_INCLUDE NAME="header.inc" -->
 <!-- TMPL_INCLUDE NAME="cat-search.inc" -->
 
-<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; <!-- TMPL_IF NAME="add_form" --><!-- TMPL_IF NAME="authtypecode" --> <a href="/cgi-bin/koha/admin/authtypes.pl">Authority Types</a> &rsaquo; Modify authority type<!-- TMPL_ELSE --> <a href="/cgi-bin/koha/admin/authtypes.pl">Authority Types</a> &rsaquo; New authority type<!-- /TMPL_IF --><!-- TMPL_ELSE --><!-- TMPL_IF NAME="delete_confirm" --><a href="/cgi-bin/koha/admin/authtypes.pl">Authority Types</a> &rsaquo; Confirm Deletion of Authority Type<!-- TMPL_ELSE -->Authority Types<!-- /TMPL_IF --><!-- /TMPL_IF --></div>
+<div id="breadcrumbs">
+         <a href="/cgi-bin/koha/mainpage.pl">Home</a>
+&rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
+&rsaquo; <a href="<!-- TMPL_IF NAME="script_name" -->">Authority Types</a>
+<!-- TMPL_IF NAME="add_form" -->
+&rsaquo; <!-- TMPL_IF NAME="authtypecode" -->Modify<!-- TMPL_ELSE -->New<!-- /TMPL_IF --> Authority Type
+<!-- TMPL_ELSIF NAME="delete_confirm" -->
+&rsaquo; Confirm Deletion of Authority Type
+<!-- /TMPL_IF -->
+</div>
 
 <div id="doc3" class="yui-t2">
-   
-   <div id="bd">
+  <div id="bd">
 	<div id="yui-main">
-	<div class="yui-b">
+	  <div class="yui-b">
 
 <!-- TMPL_IF NAME="add_form" -->
 
-	<form action="<!-- TMPL_VAR NAME="script_name" -->" name="Aform" method="post">
-		<fieldset class="rows">
-		<!-- TMPL_IF NAME="authtypecode" -->
-		<legend>Modify authority type</legend>
+    <form action="<!-- TMPL_VAR NAME="script_name" -->" name="Aform" method="post">
+    <fieldset class="rows">
+    <legend>
+    <!-- TMPL_IF NAME="authtypecode" -->
+        Modify authority type
 	<!-- TMPL_ELSE -->
-		<legend>New authority type</legend>
+        New authority type
 	<!-- /TMPL_IF -->
-	<ol>
-			<!-- TMPL_IF NAME="authtypecode" -->
-				<li><span class="label">Authority type</span><input type="hidden" name="op" value="add_validate" />
-		<input type="hidden" name="checked" value="0" /><input type="hidden" name="authtypecode" value="<!-- TMPL_VAR NAME="authtypecode" -->" /><!-- TMPL_VAR NAME="authtypecode" --></li>
-			<!-- TMPL_ELSE -->
-				<li><label for="authtypecode">Authority type: </label><input id="authtypecode" type="text" name="authtypecode" size="10" maxlength="10" onblur="toUC(this)" /></li>
-			<!-- /TMPL_IF -->
+    </legend>
+    <ol>
+        <li>
+    <!-- TMPL_IF NAME="authtypecode" -->
+            <span class="label">Authority type</span>
+            <input type="hidden" name="op" value="add_validate" />
+            <input type="hidden" name="checked" value="0" />
+            <input type="hidden" name="authtypecode" value="<!-- TMPL_VAR NAME="authtypecode" -->" /><!-- TMPL_VAR NAME="authtypecode" -->
+    <!-- TMPL_ELSE -->
+            <label for="authtypecode">Authority type: </label>
+            <input id="authtypecode" type="text" name="authtypecode" size="10" maxlength="10" onblur="toUC(this)" />
+    <!-- /TMPL_IF -->
+        </li>
 		<li><label for="authtypetext">Description: </label><input type="text" id="authtypetext" name="authtypetext" size="40" maxlength="80" value="<!-- TMPL_VAR NAME="authtypetext" ESCAPE="HTML" -->" /></li>
 		<li><label for="summary">Summary: </label><textarea id="summary" name="summary" cols="55" rows="7"><!-- TMPL_VAR NAME="summary" --></textarea></li>
 		<li>
 		<p class="tip">Note: for 'Authority field to copy', enter the authority field that should be copied from the authority record to the bibliographic record. E.g., in MARC21, field 100 in the authority record should be copied to field 100 in the bibliographic record</p>
 		<label for="auth_tag_to_report">Authority field to copy: </label><input type="text" id="auth_tag_to_report" name="auth_tag_to_report" size="5" maxlength="3" value="<!-- TMPL_VAR NAME="auth_tag_to_report">" />
 		<input type="hidden" name="op" value="add_validate" />
-		<!-- TMPL_IF NAME="authtypecode" -->
-		<input type="hidden" name="modif" value="1" />
-	<!-- /TMPL_IF -->
-	</li></ol>
+        <!-- TMPL_IF NAME="authtypecode" -->
+        <input type="hidden" name="modif" value="1" />
+        <!-- /TMPL_IF -->
+        </li>
+    </ol>
 	</fieldset>
-	<fieldset class="action"><input type="submit" value="Submit" onclick="Check(this.form); return false;" /><a class="cancel" href="/cgi-bin/koha/admin/authtypes.pl">Cancel</a></fieldset>
+	<fieldset class="action"><input type="submit" value="Submit" onclick="Check(this.form); return false;" />
+        <a class="cancel" href="<!-- TMPL_VAR NAME="script_name" -->">Cancel</a>
+    </fieldset>
 	</form>
 <!-- /TMPL_IF -->
 
@@ -116,19 +125,8 @@ function Check(f) {
 <!-- TMPL_IF NAME="else" -->
 
 <div id="toolbar">
-	<script type="text/javascript">
-	//<![CDATA[
-	// prepare DOM for YUI Toolbar
-	 $(document).ready(function() {
-	    yuiToolbar();
-	 });
-	// YUI Toolbar Functions
-	function yuiToolbar() {
-	    new YAHOO.widget.Button("authtype");
-	} //]]>
-	</script>
 	<ul class="toolbar">
-	<li><a id="authtype" href="/cgi-bin/koha/admin/authtypes.pl?op=add_form">New Authority Type</a></li>
+	<li><a id="authtype" href="<!-- TMPL_VAR NAME="script_name" -->?op=add_form">New Authority Type</a></li>
 </ul></div>
 
 <h1>Authority Types</h1>
@@ -145,7 +143,11 @@ function Check(f) {
 	</tr>
 	
 	<!-- TMPL_LOOP NAME="loop" -->
+        <!-- TMPL_IF NAME="__odd__" -->
 		<tr>
+        <!-- TMPL_ELSE -->
+        <tr class="highlight">
+        <!-- /TMPL_IF -->
 			<td><!-- TMPL_VAR NAME="authtypecode" --></td>
 			<td><!-- TMPL_VAR NAME="authtypetext" --></td>
 			<td><!-- TMPL_VAR NAME="summary" --></td>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tmpl
index 4dfdd04..8624881 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tmpl
@@ -6,76 +6,52 @@
 <!-- TMPL_IF NAME="delete_confirmed" -->Currency Deleted<!-- /TMPL_IF -->
 <!-- TMPL_IF NAME="else" -->Currencies<!-- /TMPL_IF --></title>
 <!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
-<style type="text/css">
-	.highlight { background-color: #ffffcc;}
-</style>
-<!-- TMPL_IF NAME="add_form" -->
 <script type="text/javascript">
 //<![CDATA[
-        //
-        function isNotNull(f,noalert) {
-                if (f.value.length ==0) {
-   return false;
-                }
-                return true;
-        }
-        //
-        function toUC(f) {
-                var x=f.value.toUpperCase();
-                f.value=x;
-                return true;
-        }
-        //
-        function isNum(v,maybenull) {
-        var n = new Number(v.value);
-        if (isNaN(n)) {
-                return false;
-                }
-        if (maybenull=="0" && v.value=="") {
-                return false;
-        }
+    function toUC(f) {
+        var x=f.value.toUpperCase();
+        f.value=x;
         return true;
+    }
+    function Check(f) {
+        var _alertString="";
+        var alertString2;
+        if (f.currency.value.length==0) {
+            _alertString += "- Currency name missing\\n";
         }
-        //
-        function isDate(f) {
-                var t = Date.parse(f.value);
-                if (isNaN(t)) {
-                        return false;
-                }
+        if (f.rate.value.length==0) {
+            _alertString += "- Rate missing\\n";
         }
-        //
-        function Check(f) {
-                var ok=1;
-                var _alertString="";
-                var alertString2;
-                if (f.currency.value.length==0) {
-                        _alertString += "- Currency name missing\\n";
-                }
-                if (f.rate.value.length==0) {
-                        _alertString += "- Rate missing\\n";
-                }
-                if (_alertString.length==0) {
-                        document.Aform.submit();
-                } else {
-                        alertString2 = "Form not submitted because of the following problem(s)\\n";
-                        alertString2 += "------------------------------------------------------------------------------------\\n\\n";
-                        alertString2 += _alertString;
-                        alert(alertString2);
-                }
+        if (_alertString.length==0) {
+            document.Aform.submit();
+        } else {
+            alertString2 = "Form not submitted because of the following problem(s)\\n";
+            alertString2 += "------------------------------------------------------------------------------------\\n\\n";
+            alertString2 += _alertString;
+            alert(alertString2);
         }
-        //]]>
+    }
+
+    $(document).ready(function() {
+        new YAHOO.widget.Button("newcurrency");
+    });
+//]]>
 </script>
-		<!-- /TMPL_IF -->
 </head>
 <body>
 <!-- TMPL_INCLUDE NAME="header.inc" -->
 <!-- TMPL_INCLUDE NAME="currencies-admin-search.inc" -->
 
-<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo;  <a href="/cgi-bin/koha/admin/currency.pl">Currencies &amp; Exchange Rates</a> &rsaquo; <!-- TMPL_IF NAME="add_form" --><!-- TMPL_IF NAME="searchfield" -->Modify Currency '<!-- TMPL_VAR NAME="searchfield" -->'<!-- TMPL_ELSE -->New Currency<!-- /TMPL_IF --><!-- /TMPL_IF -->
+<div id="breadcrumbs">
+         <a href="/cgi-bin/koha/mainpage.pl">Home</a>
+&rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
+&rsaquo; <a href="<!-- TMPL_VAR NAME="script_name" -->">Currencies &amp; Exchange Rates</a>
+&rsaquo; <!-- TMPL_IF NAME="add_form" --><!-- TMPL_IF NAME="searchfield" -->Modify Currency '<!-- TMPL_VAR NAME="searchfield" -->'<!-- TMPL_ELSE -->New Currency<!-- /TMPL_IF --><!-- /TMPL_IF -->
 <!-- TMPL_IF NAME="add_validate" -->Data Recorded<!-- /TMPL_IF -->
 <!-- TMPL_IF NAME="delete_confirm" -->Confirm Deletion of Currency '<span class="ex"><!-- TMPL_VAR NAME="searchfield" --></span>'<!-- /TMPL_IF -->
 <!-- TMPL_IF NAME="delete_confirmed" -->Currency Deleted<!-- /TMPL_IF -->
-<!-- TMPL_IF NAME="else" -->Currencies<!-- /TMPL_IF --></div>
+<!-- TMPL_IF NAME="else" -->Currencies<!-- /TMPL_IF -->
+</div>
 
 <div id="doc3" class="yui-t2">
    
@@ -85,27 +61,15 @@
 	
 <!-- TMPL_IF NAME="else" -->
 <div id="toolbar">
-	<script type="text/javascript">
-	//<![CDATA[
-	// prepare DOM for YUI Toolbar
-	 $(document).ready(function() {
-	    yuiToolbar();
-	 });
-	// YUI Toolbar Functions
-	function yuiToolbar() {
-	    new YAHOO.widget.Button("newcurrency");
-	}	//]]>
-	</script>
 	<ul class="toolbar">
-	<li><a id="newcurrency" href="/cgi-bin/koha/admin/currency.pl?op=add_form">New Currency</a></li>
+	<li><a id="newcurrency" href="<!-- TMPL_VAR NAME="script_name" -->?op=add_form">New Currency</a></li>
 </ul></div>
 <!-- /TMPL_IF -->
 
 <!-- TMPL_IF NAME="add_form" -->
 
 <form action="<!-- TMPL_VAR NAME="script_name" -->" name="Aform" method="post">
-<input type="hidden" name="op" value="add_validate" />
-
+    <input type="hidden" name="op" value="add_validate" />
 	<fieldset class="rows">
 	<legend><!-- TMPL_IF NAME="searchfield" -->
 		Modify currency
@@ -133,59 +97,62 @@
         <li>
 			<label for="currency">Last Updated: </label><!-- TMPL_VAR NAME="timestamp" -->
 		</li>
-		</ol>
-        </fieldset>
+    </ol>
+    </fieldset>
 		
-		<fieldset class="action"><input type="submit" value="Submit" onclick="Check(this.form)" /> <a class="cancel" href="/cgi-bin/koha/admin/currency.pl">Cancel</a> </fieldset>
-        </form>
+    <fieldset class="action">
+        <input type="submit" value="Submit" onclick="Check(this.form)" /> <a class="cancel" href="<!-- TMPL_VAR NAME="script_name" -->">Cancel</a>
+    </fieldset>
+    </form>
 
 <!-- /TMPL_IF -->
 
 <!-- TMPL_IF NAME="add_validate" -->
 <div class="dialog message">
-<h3>Data Recorded</h3>
-<form action="<!-- TMPL_VAR NAME="script_name" -->" method="post"><input type="submit" class="approve"  value="OK" />
-        </form>
+    <h3>Data Recorded</h3>
+    <form action="<!-- TMPL_VAR NAME="script_name" -->" method="get">
+        <input type="submit" class="approve"  value="OK" />
+    </form>
 </div>
 <!-- /TMPL_IF -->
 
 <!-- TMPL_IF NAME="delete_confirm" -->
-		<!-- TMPL_IF NAME="totalgtzero" -->
-<div class="dialog message">		<h3>Cannot Delete Currencey <span class="ex">'<!-- TMPL_VAR NAME="searchfield" -->'</span></h3>
-						<p>This currency is used <!-- TMPL_VAR NAME="total" --> times. Deletion not possible</span>
-				<form action="<!-- TMPL_VAR NAME="script_name" -->" method="post">
-					<input type="submit" value="OK" class="approve" />
-				</form></div>
-		<!-- TMPL_ELSE -->
-<div class="dialog alert">		<h3>Confirm Deletion of Currency <span class="ex">'<!-- TMPL_VAR NAME="searchfield" -->'</span></h3>
-<table>
-		<tr>
-			<th>Currency</th>
-			<td><!-- TMPL_VAR NAME="searchfield" --></td>
-		</tr>
-       	<tr>
-			<th>Rate</th>
-			<td><!-- TMPL_VAR NAME="rate" --></td>
-		</tr>
-		</table>
-
-
-     	<form action="<!-- TMPL_VAR NAME="script_name" -->" method="post">
-			<input type="hidden" name="op" value="delete_confirmed" />
-			<input type="hidden" name="searchfield" value="<!-- TMPL_VAR NAME="searchfield" -->" />
-				<input type="submit" class="approve" value="Delete this Currency" />
-				</form>
-				<form action="<!-- TMPL_VAR NAME="script_name" -->" method="post">
-					<input type="submit" class="deny" value="No, Do Not Delete" />
-				</form></div>
-		<!-- /TMPL_IF -->
+    <!-- TMPL_IF NAME="totalgtzero" -->
+    <div class="dialog message">
+        <h3>Cannot Delete Currencey <span class="ex">'<!-- TMPL_VAR NAME="searchfield" -->'</span></h3>
+        <p>This currency is used <!-- TMPL_VAR NAME="total" --> times. Deletion not possible</p>
+        <form action="<!-- TMPL_VAR NAME="script_name" -->" method="post">
+            <input type="submit" value="OK" class="approve" />
+        </form>
+    </div>
+    <!-- TMPL_ELSE -->
+    <div class="dialog alert">
+        <h3>Confirm Deletion of Currency <span class="ex">'<!-- TMPL_VAR NAME="searchfield" -->'</span></h3>
+        <table>
+            <tr><th>Currency</th>
+                <td><!-- TMPL_VAR NAME="searchfield" --></td>
+            </tr>
+            <tr><th>Rate</th>
+                <td><!-- TMPL_VAR NAME="rate" --></td>
+            </tr>
+        </table>
+        <form action="<!-- TMPL_VAR NAME="script_name" -->" method="post">
+            <input type="hidden" name="op" value="delete_confirmed" />
+            <input type="hidden" name="searchfield" value="<!-- TMPL_VAR NAME="searchfield" -->" />
+            <input type="submit" class="approve" value="Delete this Currency" />
+        </form>
+        <form action="<!-- TMPL_VAR NAME="script_name" -->" method="post">
+            <input type="submit" class="deny" value="No, Do Not Delete" />
+        </form>
+    </div>
+    <!-- /TMPL_IF -->
 <!-- /TMPL_IF -->
 
 <!-- TMPL_IF NAME="delete_confirmed" -->
 <div class="dialog message"><h3>Currency Deleted</h3>
 <form action="<!-- TMPL_VAR NAME="script_name" -->" method="post">
-		<input type="submit" class="approve" value="OK" />
-	</form></div>
+    <input type="submit" class="approve" value="OK" />
+</form></div>
 <!-- /TMPL_IF -->
 
 <!-- TMPL_IF NAME="else" -->
@@ -211,7 +178,7 @@
 		<!-- /TMPL_UNLESS -->
 			<td><!-- TMPL_VAR NAME="currency" --></td>
 			<td><!-- TMPL_VAR NAME="rate" --></td>
-			<td><!-- TMPL_VAR NAME="symbol" --></td>
+			<td><!-- TMPL_VAR NAME="symbol" ESCAPE="HTML" --></td>
 			<td><!-- TMPL_VAR NAME="timestamp" --></td>
 			<td><a href="<!-- TMPL_VAR NAME="script_name" -->?op=add_form&amp;searchfield=<!-- TMPL_VAR NAME="currency" -->">Edit</a></td>
             <td><a href="<!-- TMPL_VAR NAME="script_name" -->?op=delete_confirm&amp;searchfield=<!-- TMPL_VAR NAME="currency" -->">Delete</a></td>
-- 
1.5.6.5




More information about the Koha-patches mailing list