View | Details | Raw Unified | Return to bug 4461
Collapse All | Expand All

(-)a/Koha/ProblemReport.pm (+46 lines)
Line 0 Link Here
1
package Koha::ProblemReport;
2
3
# This file is part of Koha.
4
#
5
# Copyright 2017 Aleisha Amohia <aleisha@catalyst.net.nz>
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
26
use base qw(Koha::Object);
27
28
=head1 NAME
29
30
Koha::ProblemReport - Koha Problem Report Object class
31
32
=head1 API
33
34
=head2 Class Methods
35
36
=cut
37
38
=head3 type
39
40
=cut
41
42
sub _type {
43
    return 'ProblemReport';
44
}
45
46
1;
(-)a/Koha/ProblemReports.pm (+55 lines)
Line 0 Link Here
1
package Koha::ProblemReports;
2
3
# This file is part of Koha.
4
#
5
# Copyright 2017 Aleisha Amohia <aleisha@catalyst.net.nz>
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
use Koha::ProblemReport;
26
27
use base qw(Koha::Objects);
28
29
=head1 NAME
30
31
Koha::ProblemReports - Koha Problem Report Object set class
32
33
=head1 API
34
35
=head2 Class Methods
36
37
=cut
38
39
=head3 type
40
41
=cut
42
43
sub _type {
44
    return 'ProblemReport';
45
}
46
47
=head3 object_class
48
49
=cut
50
51
sub object_class {
52
    return 'Koha::ProblemReport';
53
}
54
55
1;
(-)a/Koha/Schema/Result/Borrower.pm (+15 lines)
Lines 1167-1172 __PACKAGE__->might_have( Link Here
1167
  { cascade_copy => 0, cascade_delete => 0 },
1167
  { cascade_copy => 0, cascade_delete => 0 },
1168
);
1168
);
1169
1169
1170
=head2 problem_reports
1171
1172
Type: has_many
1173
1174
Related object: L<Koha::Schema::Result::ProblemReport>
1175
1176
=cut
1177
1178
__PACKAGE__->has_many(
1179
  "problem_reports",
1180
  "Koha::Schema::Result::ProblemReport",
1181
  { "foreign.borrowernumber" => "self.borrowernumber" },
1182
  { cascade_copy => 0, cascade_delete => 0 },
1183
);
1184
1170
=head2 ratings
1185
=head2 ratings
1171
1186
1172
Type: has_many
1187
Type: has_many
(-)a/Koha/Schema/Result/Branch.pm (-1 / +15 lines)
Lines 540-545 __PACKAGE__->has_many( Link Here
540
  { cascade_copy => 0, cascade_delete => 0 },
540
  { cascade_copy => 0, cascade_delete => 0 },
541
);
541
);
542
542
543
=head2 problem_reports
544
545
Type: has_many
546
547
Related object: L<Koha::Schema::Result::ProblemReport>
548
549
=cut
550
551
__PACKAGE__->has_many(
552
  "problem_reports",
553
  "Koha::Schema::Result::ProblemReport",
554
  { "foreign.branchcode" => "self.branchcode" },
555
  { cascade_copy => 0, cascade_delete => 0 },
556
);
557
543
=head2 reserves
558
=head2 reserves
544
559
545
Type: has_many
560
Type: has_many
Lines 599-605 __PACKAGE__->many_to_many("categorycodes", "branchrelations", "categorycode"); Link Here
599
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-04-26 16:17:25
614
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-04-26 16:17:25
600
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:99U1YQ4iSum4LbBha4hDTQ
615
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:99U1YQ4iSum4LbBha4hDTQ
601
616
602
603
# You can replace this text with custom code or comments, and it will be preserved on regeneration
617
# You can replace this text with custom code or comments, and it will be preserved on regeneration
604
618
605
sub koha_objects_class {
619
sub koha_objects_class {
(-)a/Koha/Schema/Result/ProblemReport.pm (+178 lines)
Line 0 Link Here
1
use utf8;
2
package Koha::Schema::Result::ProblemReport;
3
4
# Created by DBIx::Class::Schema::Loader
5
# DO NOT MODIFY THE FIRST PART OF THIS FILE
6
7
=head1 NAME
8
9
Koha::Schema::Result::ProblemReport
10
11
=cut
12
13
use strict;
14
use warnings;
15
16
use base 'DBIx::Class::Core';
17
18
=head1 TABLE: C<problem_reports>
19
20
=cut
21
22
__PACKAGE__->table("problem_reports");
23
24
=head1 ACCESSORS
25
26
=head2 id
27
28
  data_type: 'integer'
29
  is_auto_increment: 1
30
  is_nullable: 0
31
32
=head2 title
33
34
  data_type: 'varchar'
35
  default_value: (empty string)
36
  is_nullable: 0
37
  size: 40
38
39
=head2 content
40
41
  data_type: 'varchar'
42
  default_value: (empty string)
43
  is_nullable: 0
44
  size: 255
45
46
=head2 borrowernumber
47
48
  data_type: 'integer'
49
  is_foreign_key: 1
50
  is_nullable: 1
51
52
=head2 branchcode
53
54
  data_type: 'varchar'
55
  default_value: (empty string)
56
  is_foreign_key: 1
57
  is_nullable: 0
58
  size: 10
59
60
=head2 username
61
62
  data_type: 'varchar'
63
  is_nullable: 1
64
  size: 75
65
66
=head2 problempage
67
68
  data_type: 'varchar'
69
  is_nullable: 1
70
  size: 255
71
72
=head2 recipient
73
74
  data_type: 'enum'
75
  default_value: 'library'
76
  extra: {list => ["admin","library"]}
77
  is_nullable: 0
78
79
=head2 reportdate
80
81
  data_type: 'datetime'
82
  datetime_undef_if_invalid: 1
83
  is_nullable: 1
84
85
=cut
86
87
__PACKAGE__->add_columns(
88
  "id",
89
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
90
  "title",
91
  { data_type => "varchar", default_value => "", is_nullable => 0, size => 40 },
92
  "content",
93
  { data_type => "varchar", default_value => "", is_nullable => 0, size => 255 },
94
  "borrowernumber",
95
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
96
  "branchcode",
97
  {
98
    data_type => "varchar",
99
    default_value => "",
100
    is_foreign_key => 1,
101
    is_nullable => 0,
102
    size => 10,
103
  },
104
  "username",
105
  { data_type => "varchar", is_nullable => 1, size => 75 },
106
  "problempage",
107
  { data_type => "varchar", is_nullable => 1, size => 255 },
108
  "recipient",
109
  {
110
    data_type => "enum",
111
    default_value => "library",
112
    extra => { list => ["admin", "library"] },
113
    is_nullable => 0,
114
  },
115
  "reportdate",
116
  {
117
    data_type => "datetime",
118
    datetime_undef_if_invalid => 1,
119
    is_nullable => 1,
120
  },
121
);
122
123
=head1 PRIMARY KEY
124
125
=over 4
126
127
=item * L</id>
128
129
=back
130
131
=cut
132
133
__PACKAGE__->set_primary_key("id");
134
135
=head1 RELATIONS
136
137
=head2 borrowernumber
138
139
Type: belongs_to
140
141
Related object: L<Koha::Schema::Result::Borrower>
142
143
=cut
144
145
__PACKAGE__->belongs_to(
146
  "borrowernumber",
147
  "Koha::Schema::Result::Borrower",
148
  { borrowernumber => "borrowernumber" },
149
  {
150
    is_deferrable => 1,
151
    join_type     => "LEFT",
152
    on_delete     => "CASCADE",
153
    on_update     => "CASCADE",
154
  },
155
);
156
157
=head2 branchcode
158
159
Type: belongs_to
160
161
Related object: L<Koha::Schema::Result::Branch>
162
163
=cut
164
165
__PACKAGE__->belongs_to(
166
  "branchcode",
167
  "Koha::Schema::Result::Branch",
168
  { branchcode => "branchcode" },
169
  { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
170
);
171
172
173
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-01-12 22:06:40
174
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Gh48Q5QmR+oI4oI0c6Hizg
175
176
177
# You can replace this text with custom code or comments, and it will be preserved on regeneration
178
1;
(-)a/installer/data/mysql/atomicupdate/bug-4461_add-problem-reports-table.sql (+15 lines)
Line 0 Link Here
1
DROP TABLE IF EXISTS `problem_reports`;
2
CREATE TABLE `problem_reports` ( -- problems reported by users through OPAC
3
    `id` int(11) NOT NULL auto_increment, -- unqiue identifier assigned by Koha
4
    `title` varchar(40) NOT NULL default '', -- report subject line
5
    `content` varchar(255) NOT NULL default '', -- report message content
6
    `borrowernumber` int(11) default NULL, -- the user who created the problem report
7
    `branchcode` varchar(10) NOT NULL default '', -- borrower's branch
8
    `username` varchar(75) default NULL, -- OPAC username
9
    `problempage` varchar(255) default NULL, -- page the user triggered the problem report form from
10
    `recipient` enum('admin','library') NOT NULL default 'library', -- the 'to-address' of the problem report
11
    `reportdate` datetime default NULL, -- date and time of report submission
12
    PRIMARY KEY (`id`),
13
    CONSTRAINT `problem_reports_ibfk1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
14
    CONSTRAINT `problem_reports_ibfk2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
15
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
(-)a/installer/data/mysql/kohastructure.sql (+20 lines)
Lines 1412-1417 CREATE TABLE `printers_profile` ( Link Here
1412
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1412
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1413
1413
1414
--
1414
--
1415
-- Table structure for table `problem_reports`
1416
--
1417
1418
DROP TABLE IF EXISTS `problem_reports`;
1419
CREATE TABLE `problem_reports` ( -- problems reported by users through OPAC
1420
  `id` int(11) NOT NULL auto_increment, -- unqiue identifier assigned by Koha
1421
  `title` varchar(40) NOT NULL default '', -- report subject line
1422
  `content` varchar(255) NOT NULL default '', -- report message content
1423
  `borrowernumber` int(11) default NULL, -- the user who created the problem report
1424
  `branchcode` varchar(10) NOT NULL default '', -- borrower's branch
1425
  `username` varchar(75) default NULL, -- OPAC username
1426
  `problempage` varchar(255) default NULL, -- page the user triggered the problem report form from
1427
  `recipient` enum('admin','library') NOT NULL default 'library', -- the 'to-address' of the problem report
1428
  `reportdate` datetime default NULL, -- date and time of report submission
1429
  PRIMARY KEY (`id`),
1430
  CONSTRAINT `problem_reports_ibfk1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1431
  CONSTRAINT `problem_reports_ibfk2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
1432
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1433
1434
--
1415
-- Table structure for table `repeatable_holidays`
1435
-- Table structure for table `repeatable_holidays`
1416
--
1436
--
1417
1437
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc (+3 lines)
Lines 16-21 Link Here
16
        <div class="container-fluid">
16
        <div class="container-fluid">
17
            <div class="row-fluid">
17
            <div class="row-fluid">
18
                <div class="span12">
18
                <div class="span12">
19
                    <div id="report_a_problem" class="noprint" style="float:left;">
20
                        <a class="koha_url" href="/cgi-bin/koha/opac-reportproblem.pl">Report a problem</a>
21
                    </div>
19
                    <div id="koha_url" class="clearfix noprint">
22
                    <div id="koha_url" class="clearfix noprint">
20
                        <p>Powered by
23
                        <p>Powered by
21
                        [% IF template.name.match('opac-main.tt') %]
24
                        [% IF template.name.match('opac-main.tt') %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reportproblem.tt (+129 lines)
Line 0 Link Here
1
[% USE Koha %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; Report a Problem</title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
[% BLOCK cssinclude %][% END %]
6
</head>
7
[% INCLUDE 'bodytag.inc' bodyid='opac-reportproblem' bodyclass='scrollto' %]
8
[% INCLUDE 'masthead.inc' %]
9
10
    <div class="main">
11
        <ul class="breadcrumb">
12
            <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
13
            <li><a href="#">Report a problem</a></li>
14
        </ul>
15
16
        <div class="container-fluid">
17
            <div class="row-fluid">
18
                [% IF ( OpacNav || OpacNavBottom ) %]
19
                    <div class="span2">
20
                        <div id="navigation">
21
                            [% INCLUDE 'navigation.inc' %]
22
                        </div>
23
                    </div>
24
                    <div class="span10">
25
                [% ELSE %]
26
                    <div class="span12">
27
                [% END %]
28
                    <h1>Report a problem</h1>
29
                    [% IF ( successfuladd ) %]
30
                        <div class="alert alert-info">Your problem report has been sent to the [% IF ( recipient == 'admin' ) %]Koha Administrator[% ELSE %] [% recipient %][% END %].</div>
31
                    [% END %]
32
                    [% IF ( nolibemail ) %]
33
                        <div class="alert">Your library has not provided an email address.</div>
34
                    [% END %]
35
                    [% IF ( noadminemail ) %]
36
                        <div class="alert">The Koha Administrator has not provided an email address.</div>
37
                    [% END %]
38
                    [% IF ( nolibemail && noadminemail ) %]
39
                        <div class="alert">Unable to send problem reports.</div>
40
                    [% END %]
41
                    <div id="reportproblem" class="maincontent toptabs">
42
                        <ul>
43
                            <li><a href="#reportlib">Report to librarian</a></li>
44
                            <li><a href="#reportadmin">Report to Koha Administrator</a></li>
45
                        </ul>
46
                        <div id="reportlib">
47
                            <form name="reportlibform" action="/cgi-bin/koha/opac-reportproblem.pl" method="post">
48
                                <input type="hidden" name="op" value="addreport">
49
                                <input type="hidden" name="recipient" value="library">
50
                                <fieldset class="rows">
51
                                    <ol>
52
                                        <li>
53
                                            <label for="place">Problem found on page: </label>
54
                                            <input type="hidden" name="place" id="libplace" value="[% probpage %]" class="span6">
55
                                            [% probpage | html %]
56
                                        </li>
57
                                        <li>
58
                                            <label for="user">Username: </label>
59
                                            <input type="hidden" name="user" id="libuser" value="[% username %]" class="span3">
60
                                            [% username | html %]
61
                                        <li>
62
                                            <label for="subject">Subject: </label>
63
                                            <input type="text" name="subject" id="libsubject" value="[% subject %]" class="span3">
64
                                        </li>
65
                                        <li>
66
                                            <label for="message">Message: </label>
67
                                            <textarea name="message" id="libmessage" rows="7" cols="60"></textarea>
68
                                        </li>
69
                                    </ol>
70
                                </fieldset>
71
                                <fieldset class="action">
72
                                    [% IF ( nolibemail ) %]
73
                                        <input type="submit" value="Submit" class="btn" disabled="disabled">
74
                                    [% ELSE %]
75
                                        <input type="submit" value="Submit" class="btn">
76
                                    [% END %]
77
                                </fieldset>
78
                            </form>
79
                        </div>
80
                        <div id="reportadmin">
81
                             <form name="reportadminform" action="/cgi-bin/koha/opac-reportproblem.pl" method="post">
82
                                <input type="hidden" name="op" value="addreport">
83
                                <input type="hidden" name="recipient" value="admin">
84
                                <fieldset class="rows">
85
                                    <ol>
86
                                        <li>
87
                                            <label for="place">Problem found on page: </label>
88
                                            <input type="hidden" name="place" id="adminplace" value="[% probpage %]">
89
                                            [% probpage | html %]
90
                                        </li>
91
                                        <li>
92
                                            <label for="user">Username: </label>
93
                                            <input type="hidden" name="user" id="adminuser" value="[% username %]" class="span3">
94
                                            [% username | html %]
95
                                        <li>
96
                                            <label for="subject">Subject: </label>
97
                                            <input type="text" name="subject" id="adminsubject" value="[% subject %]" class="span3">
98
                                        </li>
99
                                        <li>
100
                                            <label for="message">Message: </label>
101
                                            <textarea name="message" id="adminmessage" rows="7" cols="60"></textarea>
102
                                        </li>
103
                                    </ol>
104
                                </fieldset>
105
                                <fieldset class="action">
106
                                    [% IF ( noadminemail ) %]
107
                                        <input type="submit" value="Submit" class="btn" disabled="disabled">
108
                                    [% ELSE %]
109
                                        <input type="submit" value="Submit" class="btn">
110
                                    [% END %]
111
                                </fieldset>
112
                            </form>
113
                        </div>
114
                    </div>
115
                </div> <!-- / .span10/12 -->
116
            </div> <!-- / .row-fluid -->
117
        </div> <!-- / .container-fluid -->
118
    </div> <!-- / .main -->
119
120
[% INCLUDE 'opac-bottom.inc' %]
121
[% BLOCK jsinclude %]
122
123
    <script type="text/javascript">
124
        $(document).ready(function(){
125
            $("#reportproblem").tabs();
126
        });
127
    </script>
128
129
[% END %]
(-)a/opac/opac-reportproblem.pl (-1 / +100 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Copyright 2017 Aleisha Amohia <aleisha@catalyst.net.nz>
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
21
use Modern::Perl;
22
use CGI qw ( -utf8 );
23
use C4::Auth;    # get_template_and_user
24
use C4::Output;
25
use C4::Members;
26
use C4::Letters;
27
use Koha::ProblemReport;
28
use Koha::DateUtils;
29
use Koha::Libraries;
30
31
my $input = new CGI;
32
33
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
34
    {
35
        template_name   => "opac-reportproblem.tt",
36
        type            => "opac",
37
        query           => $input,
38
        authnotrequired => 0,
39
    }
40
);
41
42
my $problempage = $ENV{HTTP_REFERER};
43
my $member = GetMember( borrowernumber => $borrowernumber );
44
my $username = $member->{'userid'};
45
my $branchcode = $member->{'branchcode'};
46
my $library = Koha::Libraries->find($branchcode);
47
if ( $library->branchemail eq undef || ! $library->branchemail ) {
48
    $template->param( nolibemail => 1 );
49
}
50
my $koha_admin = C4::Context->preference('KohaAdminEmailAddress');
51
if ( ! $koha_admin ) {
52
    $template->param( noadminemail => 1 );
53
}
54
my $recipient = $input->param('recipient') || 'library';
55
$template->param(
56
    username => $username,
57
    probpage => $problempage,
58
);
59
60
my $op = $input->param('op') || '';
61
if ( $op eq 'addreport' ) {
62
    my $subject = $input->param('subject');
63
    my $message = $input->param('message');
64
    my $place = $input->param('place');
65
    my $problem = Koha::ProblemReport->new({ title => $subject, content => $message, borrowernumber => $borrowernumber, branchcode => $branchcode, username => $username, problempage => $place, recipient => $recipient, reportdate => dt_from_string() })->store;
66
    $template->param(
67
        recipient => $recipient,
68
        successfuladd => 1,
69
        probpage => $place,
70
    );
71
72
    my $problemreport = $problem->unblessed;
73
    $problemreport->{code} = 'PROBLEM_REPORT';
74
    $problemreport->{content} .= "\nUsername: $username";
75
    $problemreport->{content} .= "\nProblem page: $place";
76
    my $transport = 'email';
77
78
    my $from_address = $member->{email} || $member->{emailpro} || $member->{B_email} || $koha_admin;
79
80
    if ( $recipient eq 'admin' ) {
81
        C4::Letters::EnqueueLetter({
82
            letter                 => $problemreport,
83
            borrowernumber         => $borrowernumber,
84
            message_transport_type => $transport,
85
            to_address             => $koha_admin,
86
            from_address           => $from_address,
87
        });
88
    } else {
89
        my $to_address = $library->branchemail;
90
        C4::Letters::EnqueueLetter({
91
            letter                 => $problemreport,
92
            borrowernumber         => $borrowernumber,
93
            message_transport_type => $transport,
94
            to_address             => $to_address,
95
            from_address           => $from_address,
96
        });
97
    }
98
}
99
100
output_html_with_http_headers $input, $cookie, $template->output;

Return to bug 4461