-sub displaylog{
- my ($modulename, @filters)=@_;
- 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){
- 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 "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};
- }
- }
- }
+sub displaylog {
+ my ($modulename, @filters) = @_;
+ my $dbh = C4::Context->dbh;
+ my $strsth=qq|
+ SELECT action_logs.timestamp, action_logs.action, action_logs.info,
+ borrowers.cardnumber, borrowers.surname, borrowers.firstname, borrowers.userid,
+ biblio.biblionumber, biblio.title, biblio.author
+ FROM action_logs
+ LEFT JOIN borrowers ON borrowers.borrowernumber=action_logs.user
+ LEFT JOIN biblio ON action_logs.object=biblio.biblionumber
+ WHERE action_logs.module = 'cataloguing'
+ |;
+ my %filtermap = ();
+ if ($modulename eq "catalogue" or $modulename eq "acqui") {
+ %filtermap = (
+ user => 'borrowers.surname',
+ title => 'biblio.title',
+ author => 'biblio.author',
+ );
+ } elsif ($modulename eq "members") {
+ $strsth=qq|
+ SELECT action_logs.timestamp, action_logs.action, action_logs.info,
+ borrowers.cardnumber, borrowers.surname, borrowers.firstname, borrowers.userid,
+ bor2.cardnumber, bor2.surname, bor2.firstname, bor2.userid
+ FROM action_logs
+ LEFT JOIN borrowers ON borrowers.borrowernumber=action_logs.user
+ LEFT JOIN borrowers as bor2 ON action_logs.object=bor2.borrowernumber
+ WHERE action_logs.module = 'members'
+ |;
+ %filtermap = (
+ user => 'borrowers.surname',
+ surname => 'bor2.surname',
+ firstname => 'bor2.firstname',
+ cardnumber => 'bor2.cardnumber',
+ );
+ } else {
+ return 0;