From: MJ Ray <[email protected]>

Add some test cases and fix a bug in C4::Log found by in review.
Thanks-to: Katrin Fischer.

Signed-off-by: Katrin Fischer <[email protected]>
Tested the inferface and ran the tests. No problems found.
---
 C4/Log.pm                                          |    3 +-
 .../intranet-tmpl/prog/en/modules/tools/viewlog.tt |   85 +------------------
 t/db_dependent/Log.t                               |   32 ++++++++
 tools/viewlog.pl                                   |    6 +-
 4 files changed, 44 insertions(+), 82 deletions(-)
 create mode 100644 t/db_dependent/Log.t

diff --git a/C4/Log.pm b/C4/Log.pm
index 98cd8d5..6b8ff17 100644
--- a/C4/Log.pm
+++ b/C4/Log.pm
@@ -4,6 +4,7 @@ package C4::Log;
 
 
 # Copyright 2000-2002 Katipo Communications
+# Copyright 2011 MJ Ray and software.coop
 #
 # This file is part of Koha.
 #
@@ -217,7 +218,7 @@ sub GetLogs {
        $query .= " AND user = ? ";
        push(@parameters,$user);
     }
-    if(scalar @$modules > 1 or @$modules[0] ne "") {
+    if($modules && scalar(@$modules)) {
        $query .= " AND module IN (".join(",",map {"?"} @$modules).") ";
        push(@parameters,@$modules);
     }
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt 
b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt
index c109744..f20569d 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt
@@ -59,11 +59,11 @@
                                                                <label 
for="action">Action:</label>
                                                                <select 
name="action" id="action">
                                                                        <option 
value ="">All</option>
-                                                                       <option 
value ="add">Add</option>
-                                                                       <option 
value ="del">Delete</option>
-                                                                       <option 
value ="mod">Modify</option>
-                                                                       <option 
value="issue">Checkout</option>
-                                                                       <option 
value="return">Return</option>
+                                                                       <option 
value ="ADD">Add</option>
+                                                                       <option 
value ="DELETE">Delete</option>
+                                                                       <option 
value ="MODIFY">Modify</option>
+                                                                       <option 
value="ISSUE">Checkout</option>
+                                                                       <option 
value="RETURN">Return</option>
                                                                </select>
                                                        </li>
                                                        <li>
@@ -133,81 +133,6 @@
                                                <input type="submit" 
value="Submit" />
                                                <input type="hidden" 
name="do_it" value="1" />
                                        </fieldset>
-                                       [% IF ( do_it ) %]
-                                               [% IF ( total ) %]
-                                                       <h4>[% total %] lines 
found.</h4>
-                                                       <table>
-                                                               <tr>
-                                                                       
<th>Date</th>
-                                                                       
<th>Librarian</th>
-                                                                       
<th>Module</th>
-                                                                       
<th>Action</th>
-                                                                       
<th>Object</th>
-                                                                       
<th>Info</th>
-                                                               </tr>
-                                                               [% FOREACH 
loopro IN looprow %]
-                                                                       [% 
UNLESS ( loop.odd ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
-                                                                               
<td>[% loopro.timestamp %]</td>
-                                                                               
<td>
-                                                                               
        <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% 
loopro.user %]" title="display detail for this librarian."> [% loopro.user %] 
</a>
-                                                                               
</td>
-                                                                               
<td>[% loopro.module %]</td>
-                                                                               
<td>[% loopro.action %]</td>
-                                                                               
<td>
-                                                                               
        [% IF ( module == 'MEMBERS' ) %]
-                                                                               
                <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% 
loopro.object %]" title="Display member details."> member [% loopro.object %] 
</a>
-                                                                               
        [% ELSE %]
-                                                                               
                [% IF ( module == 'CIRCULATION' ) %]
-                                                                               
                        <a 
href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% loopro.object %]" 
title="Display member details.">
-                                                                               
                                [% IF ( loopro.object ) %]
-                                                                               
                                        member [% loopro.object %]
-                                                                               
                                [% END %]
-                                                                               
                        </a>
-                                                                               
                [% ELSE %]
-                                                                               
                        [% IF ( module == 'CATALOGUING' ) %]
-                                                                               
                                [% IF ( info == 'item' ) %]
-                                                                               
                                        <a 
href="/cgi-bin/koha/catalogue/moredetail.pl?item=[% loopro.object 
%]&amp;biblionumber=[% loopro.biblionumber %]&amp;bi=[% loopro.biblioitemnumber 
%]#item[% loopro.object %]">Item [% loopro.object %]</a>
-                                                                               
                                [% ELSE %]
-                                                                               
                                        <a 
href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% loopro.object %]" 
title="Display detail for this biblio">biblio [% loopro.object %]</a>
-                                                                               
                                [% END %]
-                                                                               
                        [% ELSE %]
-                                                                               
                                [% IF ( module == 'SERIAL' ) %]
-                                                                               
                                        <a 
href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% 
loopro.object %]"> [% loopro.object %] </a>
-                                                                               
                                [% ELSE %]
-                                                                               
                                        [% IF ( module == 'AUTHORITIES' ) %]
-                                                                               
                                                <a 
href="/cgi-bin/koha/authorities/detail.pl?authid=[% loopro.object %]" 
title="Display detail for this authority">auth [% loopro.object %]</a>
-                                                                               
                                        [% ELSE %]
-                                                                               
                                                [% loopro.object %]
-                                                                               
                                        [% END %]
-                                                                               
                                [% END %]
-                                                                               
                        [% END %]
-                                                                               
                [% END %]
-                                                                               
        [% END %]
-                                                                               
</td>
-                                                                               
<td>
-                                                                               
        [% IF ( loopro.CIRCULATION ) %]
-                                                                               
                <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% 
loopro.info %]" title="Display detail for this biblio">biblio [% loopro.info 
|html %]</a>
-                                                                               
        [% ELSE %]
-                                                                               
                [% loopro.info |html %]
-                                                                               
        [% END %]
-                                                                               
</td>
-                                                                       </tr>
-                                                               [% END %]
-                                                       </table>
-                                               [% ELSE %]
-                                                       <div class="dialog 
alert">
-                                                               No log found
-                                                               [% IF ( 
CATALOGUING ) %]
-                                                                       for <a 
href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% object 
%]">Bibliographic Record [% object %]</a>
-                                                               [% END %]
-                                                               [% IF ( MEMBERS 
) %]
-                                                                       for <a 
href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% object %]">[% 
firstname %] [% surname %] ([% cardnumber %])</a>
-                                                               [% END %]
-                                                               .
-                                                       </div>
-                                               [% END %]
-                                       [% END %]
-
                                </form>
                 [% END %]
                 [% IF ( do_it ) %]
diff --git a/t/db_dependent/Log.t b/t/db_dependent/Log.t
new file mode 100644
index 0000000..13910e2
--- /dev/null
+++ b/t/db_dependent/Log.t
@@ -0,0 +1,32 @@
+#!/usr/bin/perl
+#
+# Copyright 2011 MJ Ray and software.coop
+# This Koha test module is a stub!  
+# Add more tests here!!!
+
+use strict;
+use warnings;
+use Test::More tests => 3;
+use C4::Log;
+
+BEGIN {
+       use_ok('C4::Log');
+}
+my $success;
+
+eval {
+    # FIXME: US formatted date hardcoded into test for now
+    $success = GetLogs("","","",undef,undef,"","");
+} or do {
+    diag($@);
+    $success = 0;
+};
+ok($success, "GetLogs returns results for an open search");
+eval {
+    # FIXME: US formatted date hardcoded into test for now
+    $success = GetLogs("09/01/2011","10/01/2011","",undef,undef,"","");
+} or do {
+    diag($@);
+    $success = 0;
+};
+ok($success, "GetLogs accepts dates in an All-matching search");
diff --git a/tools/viewlog.pl b/tools/viewlog.pl
index d689217..5c43098 100755
--- a/tools/viewlog.pl
+++ b/tools/viewlog.pl
@@ -1,6 +1,7 @@
 #!/usr/bin/perl
 
 # Copyright 2010 BibLibre
+# Copyright 2011 MJ Ray and software.coop
 #
 # This file is part of Koha.
 #
@@ -105,7 +106,10 @@ $template->param(
 if ($do_it) {
 
     my @data;
-    my $results = 
GetLogs($datefrom,$dateto,$user,\@modules,\@action,$object,$info);
+    my ($results,$modules,$action);
+    if ($action[0] ne '') { $action = \@action; } # match All means no limit
+    if ($modules[0] ne '') { $modules = \@modules; } # match All means no limit
+    $results = GetLogs($datefrom,$dateto,$user,$modules,$action,$object,$info);
     @data=@$results;
     my $total = scalar @data;
     foreach my $result (@data){
-- 
1.7.4.1

_______________________________________________
Koha-patches mailing list
[email protected]
http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-patches
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to