[Koha-patches] [PATCH] Cleanup transferstoreceive.pl and .tmpl

Joe Atzberger joe.atzberger at liblime.com
Fri May 22 21:35:35 CEST 2009


Removed unused variables.  Replaced EXPR.
Inserted hidden span to correct tablesorter behavior on title field.  Without this patch
because of the link href in the cell, the sort would end up being effectively on
biblionumber, not title.

Mostly whitespace edits in template.
---
 circ/transferstoreceive.pl                         |   26 ++---
 .../prog/en/modules/circ/transferstoreceive.tmpl   |  116 ++++++++++----------
 2 files changed, 67 insertions(+), 75 deletions(-)

diff --git a/circ/transferstoreceive.pl b/circ/transferstoreceive.pl
index c070a17..88ae91d 100755
--- a/circ/transferstoreceive.pl
+++ b/circ/transferstoreceive.pl
@@ -19,10 +19,11 @@
 # Suite 330, Boston, MA  02111-1307 USA
 
 use strict;
+use warnings;
 use CGI;
 use C4::Context;
 use C4::Output;
-use C4::Branch;
+use C4::Branch;     # GetBranches
 use C4::Auth;
 use C4::Dates qw/format_date/;
 use C4::Biblio;
@@ -38,8 +39,6 @@ use C4::Koha;
 use C4::Reserves;
 
 my $input = new CGI;
-
-my $theme = $input->param('theme');    # only used if allowthemeoverride is set
 my $itemnumber = $input->param('itemnumber');
 
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
@@ -79,9 +78,8 @@ foreach my $br ( keys %$branches ) {
                 C4::Context->preference('TransfersMaxDaysWarning'));
             my $calcDate = Date_to_Days( $sent_year, $sent_month, $sent_day );
             my $today    = Date_to_Days(&Today);
-            my $warning  = ( $today > $calcDate );
 
-            if ( $warning > 0 ) {
+            if ($today > $calcDate) {
                 $getransf{'messcompa'} = 1;
             }
             my $gettitle     = GetBiblioFromItemNumber( $num->{'itemnumber'} );
@@ -93,19 +91,15 @@ foreach my $br ( keys %$branches ) {
             	$getransf{$_} = $gettitle->{$_};
 			}
 
-            # 				we check if we have a reserv for this transfer
+            # we check if we have a reserv for this transfer
             my @checkreserv = GetReservesFromItemnumber($num->{'itemnumber'} );
             if ( $checkreserv[0] ) {
-                my $getborrower =
-                  GetMemberDetails( $checkreserv[1] );
-                $getransf{'borrowernum'}  = $getborrower->{'borrowernumber'};
-                $getransf{'borrowername'} = $getborrower->{'surname'};
+                my $getborrower = GetMemberDetails( $checkreserv[1] );
+                $getransf{'borrowernum'}       = $getborrower->{'borrowernumber'};
+                $getransf{'borrowername'}      = $getborrower->{'surname'};
                 $getransf{'borrowerfirstname'} = $getborrower->{'firstname'};
-                if ( $getborrower->{'emailaddress'} ) {
-                    $getransf{'borrowermail'} = $getborrower->{'emailaddress'};
-                }
-                $getransf{'borrowerphone'} = $getborrower->{'phone'};
-
+                $getransf{'borrowermail'}      = $getborrower->{'emailaddress'} if $getborrower->{'emailaddress'};
+                $getransf{'borrowerphone'}     = $getborrower->{'phone'};
             }
             push( @transferloop, \%getransf );
         }
@@ -119,7 +113,7 @@ foreach my $br ( keys %$branches ) {
 $template->param(
     branchesloop => \@branchesloop,
     show_date    => format_date(C4::Dates->today('iso')),
-	dateformat    => C4::Context->preference("dateformat"),
+	'dateformat_' . (C4::Context->preference("dateformat") || '') => 1,
 );
 
 output_html_with_http_headers $input, $cookie, $template->output;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/transferstoreceive.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/transferstoreceive.tmpl
index e457b77..6a7e902 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/transferstoreceive.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/transferstoreceive.tmpl
@@ -2,7 +2,7 @@
 <title>Koha &rsaquo; Circulation &rsaquo; Transfers to your library</title>
 <!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
 <script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
-<script type="text/JavaScript" language="JavaScript">
+<script type="text/javascript" language="JavaScript">
 //<![CDATA[
 $.tablesorter.addParser({
     id: 'articles', 
@@ -10,16 +10,16 @@ $.tablesorter.addParser({
     format: function(s) { return s.toLowerCase().replace(/^(the|an|a) /,''); }, 
     type: 'text' 
 });
-	 $(document).ready(function() {
-            <!-- TMPL_LOOP NAME="branchesloop" -->
-		$.tablesorter.defaults.widgets = ['zebra']; 
-		$("#transferst<!-- TMPL_VAR NAME="branchcode" -->").tablesorter({<!-- TMPL_IF EXPR="dateformat eq 'metric'" -->
-		dateFormat: 'uk',<!-- /TMPL_IF -->
-			sortList: [[1,0]],
-			headers: { 1: { sorter: 'articles' },4:{sorter:false}}
-		}); 
-		<!-- /TMPL_LOOP -->
-	 });
+$(document).ready(function() {
+    <!-- TMPL_LOOP NAME="branchesloop" -->
+    $.tablesorter.defaults.widgets = ['zebra']; 
+    $("#transferst<!-- TMPL_VAR NAME="branchcode" -->").tablesorter({<!-- TMPL_IF ="dateformat_metric" -->
+        dateFormat: 'uk',<!-- /TMPL_IF -->
+        sortList: [[1,0]],
+        headers: { 1: { sorter: 'articles' },4:{sorter:false}}
+    }); 
+    <!-- /TMPL_LOOP -->
+});
 //]]>
 </script>
 </head>
@@ -35,63 +35,61 @@ $.tablesorter.addParser({
 	<div id="yui-main">
 	<div class="yui-g">
 
-
 	<h1>Transfers made to your library on : <!-- TMPL_VAR NAME="show_date" --></h1>
 	<!-- TMPL_IF name="branchesloop" -->
-            <p>Your library is the destination for the following transfer(s)</p>
-            <div id="resultlist">
-            <!-- TMPL_LOOP NAME="branchesloop" -->
-                <!-- TMPL_IF NAME="branchcode" -->
-                <table style="width: 100%" id="transferst<!-- TMPL_VAR NAME="branchcode" -->">
-				<caption>Coming from <!-- TMPL_VAR NAME="branchname" --></caption>
-                <thead><tr>
-                    <th>Date of transfer</th>
-                    <th>Title</th>
-                    <th>Reserved by </th>
-                    <th>Location</th>
-                </tr></thead>
-                <tbody><!-- TMPL_LOOP NAME="reserv" -->
-				<!-- TMPL_IF NAME="messcompa" -->
-                    <tr class="problem">
-					<!-- TMPL_ELSE -->
-					<tr>
-					<!-- /TMPL_IF -->
-                        <td><p><!-- TMPL_VAR NAME="datetransfer" --></p> <!-- TMPL_IF NAME="messcompa" --> check this transfer<!-- /TMPL_IF --></td>
-                        <td><!-- TMPL_IF name="BiblioDefaultViewmarc" -->
+        <p>Your library is the destination for the following transfer(s)</p>
+        <div id="resultlist">
+        <!-- TMPL_LOOP NAME="branchesloop" -->
+            <!-- TMPL_IF NAME="branchcode" -->
+            <table style="width: 100%" id="transferst<!-- TMPL_VAR NAME="branchcode" -->">
+            <caption>Coming from <!-- TMPL_VAR NAME="branchname" --></caption>
+            <thead><tr>
+                <th>Date of transfer</th>
+                <th>Title</th>
+                <th>Reserved by </th>
+                <th>Location</th>
+            </tr></thead>
+            <tbody><!-- TMPL_LOOP NAME="reserv" -->
+                <!-- TMPL_IF NAME="messcompa" -->
+                <tr class="problem">
+                <!-- TMPL_ELSE -->
+                <tr>
+                <!-- /TMPL_IF -->
+                    <td><p><!-- TMPL_VAR NAME="datetransfer" --></p> <!-- TMPL_IF NAME="messcompa" -->check this transfer<!-- /TMPL_IF --></td>
+                    <td><span style="display:none;"><!-- TMPL_VAR NAME="title" escape="html" --></span><!-- invisible title for tablesorter -->
+                        <!-- TMPL_IF name="BiblioDefaultViewmarc" -->
 <a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->"><!-- TMPL_VAR NAME="title" escape="html" --></a>
 <!-- TMPL_ELSIF NAME="BiblioDefaultViewisbd" -->
 <a href="/cgi-bin/koha/catalogue/ISBDdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->"><!-- TMPL_VAR NAME="title" escape="html" --></a>
 <!-- TMPL_ELSE -->
 <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->"><!-- TMPL_VAR NAME="title" escape="html" -->  <!-- TMPL_VAR NAME="subtitle" --></a><!-- /TMPL_IF -->
-                                &nbsp; (<b><!-- TMPL_VAR NAME="itemtype" --> </b>)
-                                <br />Barcode : <!-- TMPL_VAR NAME="barcode" -->
-                        </td>
-                        <td><!-- TMPL_IF NAME="borrowername" -->
-                            <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!--TMPL_VAR Name="borrowernum"-->">
-                                    <!-- TMPL_VAR NAME="borrowername" --> &nbsp; <!-- TMPL_VAR NAME="borrowerfirstname" -->
+                            &nbsp; (<b><!-- TMPL_VAR NAME="itemtype" --></b>)
+                            <br />Barcode: <!-- TMPL_VAR NAME="barcode" -->
+                    </td>
+                    <td><!-- TMPL_IF NAME="borrowername" -->
+                        <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!--TMPL_VAR Name="borrowernum"-->">
+                            <!-- TMPL_VAR NAME="borrowername" --> &nbsp; <!-- TMPL_VAR NAME="borrowerfirstname" -->
+                        </a>
+                        <br /><!-- TMPL_VAR NAME="borrowerphone" --><br />
+                            <!-- TMPL_IF NAME="borrowermail" -->
+                                <a href="mailto:<!-- TMPL_VAR NAME="email" -->?subject=Reservation: <!-- TMPL_VAR NAME="title" -->">
+                                    <!-- TMPL_VAR NAME="borrowermail" -->
                                 </a>
-                                <br /><!-- TMPL_VAR NAME="borrowerphone" --><br />
-                                <!-- TMPL_IF NAME="borrowermail" -->
-                                    <a href="mailto:<!-- TMPL_VAR NAME="email" -->?subject=Reservation: <!-- TMPL_VAR NAME="title" -->">
-                                        <!-- TMPL_VAR NAME="borrowermail" -->
-                                    </a>
-                                <!--/TMPL_IF-->
+                            <!--/TMPL_IF-->
                         <!-- TMPL_ELSE -->
-                            <p>
-                            None
-                            </p>
-                        <!-- /TMPL_IF -->
-                        </td>
-                        <td><!-- TMPL_VAR NAME="homebranch" --> <!-- TMPL_VAR NAME="itemcallnumber" --></td>
-                    </tr>
-                <!-- /TMPL_LOOP -->	</tbody>
-                </table>
-                <!-- /TMPL_IF -->
-            <!-- /TMPL_LOOP -->
-            </div>
-        <!-- TMPL_ELSE -->
-            <p>No transfers to receive</p>
-        <!-- /TMPL_IF -->
+                        <p>None</p>
+                    <!-- /TMPL_IF -->
+                    </td>
+                    <td><!-- TMPL_VAR NAME="homebranch" --> <!-- TMPL_VAR NAME="itemcallnumber" --></td>
+                </tr>
+            <!-- /TMPL_LOOP --></tbody>
+            </table>
+            <!-- /TMPL_IF -->
+        <!-- /TMPL_LOOP -->
+        </div>
+    <!-- TMPL_ELSE -->
+        <p>No transfers to receive</p>
+    <!-- /TMPL_IF -->
 
 </div>
 </div>
-- 
1.5.6.5




More information about the Koha-patches mailing list