Bug 17047: SQL reports management with Mana-KB
[koha.git] / Koha / Report.pm
1 package Koha::Report;
2
3 # This file is part of Koha.
4 #
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 3 of the License, or (at your option) any later
8 # version.
9 #
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License along
15 # with Koha; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18 use Modern::Perl;
19
20 use Carp;
21
22 use Koha::Database;
23 use JSON;
24 use Koha::Reports;
25
26 use base qw(Koha::Object);
27
28 =head1 NAME
29
30 Koha::Report - Koha Report Object class
31
32 =head1 API
33
34 =head2 Class Methods
35
36 =cut
37
38 =head3 get_search_info
39
40 Return search info
41
42 =cut
43
44 sub get_search_info {
45     my $self = shift;
46     my $sub_mana_info = { 'query' => shift };
47     return $sub_mana_info;
48 }
49
50 =head3 get_sharable_info
51
52 Return properties that can be shared.
53
54 =cut
55
56 sub get_sharable_info {
57     my $self             = shift;
58     my $shared_report_id = shift;
59     my $report           = Koha::Reports->find($shared_report_id);
60     my $sub_mana_info    = {
61         'savedsql'     => $report->savedsql,
62         'report_name'  => $report->report_name,
63         'notes'        => $report->notes,
64         'report_group' => $report->report_group,
65         'type'         => $report->type,
66     };
67     return $sub_mana_info;
68 }
69
70 =head3 new_from_mana
71
72 Clear a Mana report to be imported in Koha?
73
74 =cut
75
76 sub new_from_mana {
77     my $self = shift;
78     my $data = shift;
79
80     $data->{mana_id} = $data->{id};
81
82     delete $data->{exportemail};
83     delete $data->{kohaversion};
84     delete $data->{creationdate};
85     delete $data->{lastimport};
86     delete $data->{id};
87     delete $data->{nbofusers};
88     delete $data->{language};
89
90     Koha::Report->new($data)->store;
91 }
92
93 =head3 _type
94
95 Returns name of corresponding DBIC resultset
96
97 =cut
98
99 sub _type {
100     return 'SavedSql';
101 }
102
103 1;