[Koha-cvs] CVS: koha/C4 Log.pm,1.2,1.3

Henri-Damien LAURENT hdl at users.sourceforge.net
Wed Jul 20 18:09:06 CEST 2005


Update of /cvsroot/koha/koha/C4
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv423/C4

Modified Files:
	Log.pm 
Log Message:
Adding page to display log views.
can be called by admin/viewlog.pl
Works with C4/Log.pm
uses action_logs table

Index: Log.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Log.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** Log.pm	19 Jul 2005 16:48:15 -0000	1.2
--- Log.pm	20 Jul 2005 16:09:04 -0000	1.3
***************
*** 50,54 ****
  
  @ISA = qw(Exporter);
! @EXPORT = qw(&logaction &logstatus);
  
  =item logaction
--- 50,54 ----
  
  @ISA = qw(Exporter);
! @EXPORT = qw(&logaction &logstatus &displaylog);
  
  =item logaction
***************
*** 96,106 ****
  	my $dbh = C4::Context->dbh;
  	my $strsth;
! 	if ($modulename eq "acqui.simple"){
! 		$strsth="select action_logs.timestamp, action_logs.action, borrowers.cardnumber, borrowers.surname, borrowers.firstname, borrowers.userid,";
  		$strsth .= "biblio.biblionumber, biblio.title, biblio.author" ;#if ($modulename eq "acqui.simple");
  		$strsth .= "FROM borrowers,action_logs ";
! 		$strsth .= ",biblio" ;#if ($modulename eq "acqui.simple");
  	
! 		$strsth .="WHERE borrowers.borrowernumber=action_logs.user";
  		$strsth .= "AND action_logs.module = 'acqui.simple' AND action_logs.object=biblio.biblionumber ";# if ($modulename eq "acqui.simple");
  		if (@filters){
--- 96,128 ----
  	my $dbh = C4::Context->dbh;
  	my $strsth;
! 	if ($modulename eq "catalogue"){
! 		$strsth="select action_logs.timestamp, action_logs.action, action_logs.info, borrowers.cardnumber, borrowers.surname, borrowers.firstname, borrowers.userid,";
! 		$strsth .= "biblio.biblionumber, biblio.title, biblio.author" ;#if ($modulename eq "acqui.simple");
! 		$strsth .= " FROM borrowers,action_logs ";
! 		$strsth .= ",biblio " ;#if ($modulename eq "acqui.simple");
! 	
! 		$strsth .=" WHERE borrowers.borrowernumber=action_logs.user";
! 		$strsth .=" AND action_logs.module = 'acqui.simple' AND action_logs.object=biblio.biblionumber ";# if ($modulename eq "acqui.simple");
! 		if (@filters){
! 			foreach my $filter (@filters){
! 				if ($filter->{name} =~ /user/){
! 					$filter->{value}=~s/\*/%/g;
! 					$strsth .= " AND borrowers.surname like ".$filter->{value};
! 				}elsif ($filter->{name} =~ /title/){
! 					$filter->{value}=~s/\*/%/g;
! 					$strsth .= " AND biblio.title like ".$filter->{value};
! 				}elsif ($filter->{name} =~ /author/){
! 					$filter->{value}=~s/\*/%/g;
! 					$strsth .= " AND biblio.author like ".$filter->{value};
! 				}
! 			}
! 		}
! 	} elsif ($modulename eq "acqui")  {
! 		$strsth="select action_logs.timestamp, action_logs.action, action_logs.info, borrowers.cardnumber, borrowers.surname, borrowers.firstname, borrowers.userid,";
  		$strsth .= "biblio.biblionumber, biblio.title, biblio.author" ;#if ($modulename eq "acqui.simple");
  		$strsth .= "FROM borrowers,action_logs ";
! 		$strsth .= ",biblio " ;#if ($modulename eq "acqui.simple");
  	
! 		$strsth .=" WHERE borrowers.borrowernumber=action_logs.user";
  		$strsth .= "AND action_logs.module = 'acqui.simple' AND action_logs.object=biblio.biblionumber ";# if ($modulename eq "acqui.simple");
  		if (@filters){
***************
*** 118,135 ****
  			}
  		}
- 	} elsif ($modulename eq "acqui")  {
- 	} elsif ($modulename eq "circ")   {
  	} elsif ($modulename eq "members"){
  	}
  	warn "displaylog :".$strsth;
! 	my $sth=$dbh->prepare($strsth);
! 	$sth->execute;
! 	my @results;
! 	my $count;
! 	while (my $data = $sth->fetchrow_hashref){
! 		push @results, $data;
! 		$count++;
! 	}
! 	return ($count, \@results);
  }
  END { }       # module clean-up code here (global destructor)
--- 140,183 ----
  			}
  		}
  	} elsif ($modulename eq "members"){
+ 		$strsth="select action_logs.timestamp, action_logs.action, action_logs.info, borrowers.cardnumber, borrowers.surname, borrowers.firstname, borrowers.userid,";
+ 		$strsth .= "bor2.cardnumber, bor2.surname, bor2.firstname, bor2.userid,";
+ 		$strsth .= "FROM borrowers,action_logs,borrowers as bor2 ";
+ 	
+ 		$strsth .=" WHERE borrowers.borrowernumber=action_logs.user";
+ 		$strsth .= "AND action_logs.module = 'members' AND action_logs.object=bor2.borrowernumber ";# if ($modulename eq "acqui.simple");
+ 		if (@filters){
+ 			foreach my $filter (@filters){
+ 				if ($filter->{name} =~ /user/){
+ 					$filter->{value}=~s/\*/%/g;
+ 					$strsth .= " AND borrowers.surname like ".$filter->{value};
+ 				}elsif ($filter->{name} =~ /surname/){
+ 					$filter->{value}=~s/\*/%/g;
+ 					$strsth .= " AND bor2.surname like ".$filter->{value};
+ 				}elsif ($filter->{name} =~ /firstname/){
+ 					$filter->{value}=~s/\*/%/g;
+ 					$strsth .= " AND bor2.firsntame like ".$filter->{value};
+ 				}elsif ($filter->{name} =~ /cardnumber/){
+ 					$filter->{value}=~s/\*/%/g;
+ 					$strsth .= " AND bor2.cardnumber like ".$filter->{value};
+ 				}
+ 			}
+ 		}
  	}
  	warn "displaylog :".$strsth;
! 	if ($strsth){
! 		my $sth=$dbh->prepare($strsth);
! 		$sth->execute;
! 		my @results;
! 		my $count;
! 		my $hilighted=1;
! 		while (my $data = $sth->fetchrow_hashref){
! 			$data->{hilighted} = ($hilighted>0);
! 			push @results, $data;
! 			$count++;
! 			$hilighted = -$hilighted;
! 		}
! 		return ($count, \@results);
! 	} else {return 0;}
  }
  END { }       # module clean-up code here (global destructor)





More information about the Koha-cvs mailing list