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 (-2 / +17 lines)
Lines 1123-1128 __PACKAGE__->might_have( Link Here
1123
  { cascade_copy => 0, cascade_delete => 0 },
1123
  { cascade_copy => 0, cascade_delete => 0 },
1124
);
1124
);
1125
1125
1126
=head2 problem_reports
1127
1128
Type: has_many
1129
1130
Related object: L<Koha::Schema::Result::ProblemReport>
1131
1132
=cut
1133
1134
__PACKAGE__->has_many(
1135
  "problem_reports",
1136
  "Koha::Schema::Result::ProblemReport",
1137
  { "foreign.borrowernumber" => "self.borrowernumber" },
1138
  { cascade_copy => 0, cascade_delete => 0 },
1139
);
1140
1126
=head2 ratings
1141
=head2 ratings
1127
1142
1128
Type: has_many
1143
Type: has_many
Lines 1334-1341 Composing rels: L</aqorder_users> -> ordernumber Link Here
1334
__PACKAGE__->many_to_many("ordernumbers", "aqorder_users", "ordernumber");
1349
__PACKAGE__->many_to_many("ordernumbers", "aqorder_users", "ordernumber");
1335
1350
1336
1351
1337
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-10-31 10:39:35
1352
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-01-12 03:37:07
1338
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Lc6GQ2E7d+tyzTk3v2sWjQ
1353
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+NQSF0ArnOrdywq4aESwmA
1339
1354
1340
__PACKAGE__->belongs_to(
1355
__PACKAGE__->belongs_to(
1341
    "guarantor",
1356
    "guarantor",
(-)a/Koha/Schema/Result/Branch.pm (-2 / +17 lines)
Lines 487-492 __PACKAGE__->has_many( Link Here
487
  { cascade_copy => 0, cascade_delete => 0 },
487
  { cascade_copy => 0, cascade_delete => 0 },
488
);
488
);
489
489
490
=head2 problem_reports
491
492
Type: has_many
493
494
Related object: L<Koha::Schema::Result::ProblemReport>
495
496
=cut
497
498
__PACKAGE__->has_many(
499
  "problem_reports",
500
  "Koha::Schema::Result::ProblemReport",
501
  { "foreign.branchcode" => "self.branchcode" },
502
  { cascade_copy => 0, cascade_delete => 0 },
503
);
504
490
=head2 reserves
505
=head2 reserves
491
506
492
Type: has_many
507
Type: has_many
Lines 543-550 Composing rels: L</branchrelations> -> categorycode Link Here
543
__PACKAGE__->many_to_many("categorycodes", "branchrelations", "categorycode");
558
__PACKAGE__->many_to_many("categorycodes", "branchrelations", "categorycode");
544
559
545
560
546
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-10-24 13:56:21
561
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-01-12 03:37:07
547
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:/9YwsU+GXK+fzc6IX2Tj5g
562
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:NbUmXDojsTcjNO5MLfgbHw
548
563
549
564
550
# You can replace this text with custom code or comments, and it will be preserved on regeneration
565
# You can replace this text with custom code or comments, and it will be preserved on regeneration
(-)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 (+16 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;
16
(-)a/installer/data/mysql/kohastructure.sql (+20 lines)
Lines 1396-1401 CREATE TABLE `printers_profile` ( Link Here
1396
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1396
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1397
1397
1398
--
1398
--
1399
-- Table structure for table `problem_reports`
1400
--
1401
1402
DROP TABLE IF EXISTS `problem_reports`;
1403
CREATE TABLE `problem_reports` ( -- problems reported by users through OPAC
1404
  `id` int(11) NOT NULL auto_increment, -- unqiue identifier assigned by Koha
1405
  `title` varchar(40) NOT NULL default '', -- report subject line
1406
  `content` varchar(255) NOT NULL default '', -- report message content
1407
  `borrowernumber` int(11) default NULL, -- the user who created the problem report
1408
  `branchcode` varchar(10) NOT NULL default '', -- borrower's branch
1409
  `username` varchar(75) default NULL, -- OPAC username
1410
  `problempage` varchar(255) default NULL, -- page the user triggered the problem report form from
1411
  `recipient` enum('admin','library') NOT NULL default 'library', -- the 'to-address' of the problem report
1412
  `reportdate` datetime default NULL, -- date and time of report submission
1413
  PRIMARY KEY (`id`),
1414
  CONSTRAINT `problem_reports_ibfk1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1415
  CONSTRAINT `problem_reports_ibfk2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
1416
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1417
1418
--
1399
-- Table structure for table `repeatable_holidays`
1419
-- Table structure for table `repeatable_holidays`
1400
--
1420
--
1401
1421
(-)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 (+110 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
                    <div id="reportproblem" class="maincontent toptabs">
33
                        <ul>
34
                            <li><a href="#reportlib">Report to librarian</a></li>
35
                            <li><a href="#reportadmin">Report to Koha Administrator</a></li>
36
                        </ul>
37
                        <div id="reportlib">
38
                            <form name="reportlibform" action="/cgi-bin/koha/opac-reportproblem.pl" method="post">
39
                                <input type="hidden" name="op" value="addreport">
40
                                <input type="hidden" name="recipient" value="library">
41
                                <fieldset class="rows">
42
                                    <ol>
43
                                        <li>
44
                                            <label for="place">Problem found on page: </label>
45
                                            <input type="hidden" name="place" id="place" value="[% probpage %]" class="span6">
46
                                            [% probpage | html %]
47
                                        </li>
48
                                        <li>
49
                                            <label for="user">Username: </label>
50
                                            <input type="hidden" name="user" id="user" value="[% username %]" class="span3">
51
                                            [% username | html %]
52
                                        <li>
53
                                            <label for="subject">Subject: </label>
54
                                            <input type="text" name="subject" id="subject" value="[% subject %]" class="span3">
55
                                        </li>
56
                                        <li>
57
                                            <label for="message">Message: </label>
58
                                            <textarea name="message" id="message" rows="7" cols="60"></textarea>
59
                                        </li>
60
                                    </ol>
61
                                </fieldset>
62
                                <fieldset class="action">
63
                                    <input type="submit" value="Submit" class="btn" />
64
                                </fieldset>
65
                            </form>
66
                        </div>
67
                        <div id="reportadmin">
68
                             <form name="reportadminform" action="/cgi-bin/koha/opac-reportproblem.pl" method="post">
69
                                <input type="hidden" name="op" value="addreport">
70
                                <input type="hidden" name="recipient" value="admin">
71
                                <fieldset class="rows">
72
                                    <ol>
73
                                        <li>
74
                                            <label for="place">Problem found on page: </label>
75
                                            <input type="hidden" name="place" id="place" value="[% probpage %]">
76
                                            [% probpage | html %]
77
                                        </li>
78
                                        <li>
79
                                            <label for="user">Username: </label>
80
                                            <input type="hidden" name="user" id="user" value="[% username %]" class="span3">
81
                                            [% username | html %]
82
                                        <li>
83
                                            <label for="subject">Subject: </label>
84
                                            <input type="text" name="subject" id="subject" value="[% subject %]" class="span3">
85
                                        </li>
86
                                        <li>
87
                                            <label for="message">Message: </label>
88
                                            <textarea name="message" id="message" rows="7" cols="60"></textarea>
89
                                        </li>
90
                                    </ol>
91
                                </fieldset>
92
                                <fieldset class="action">
93
                                    <input type="submit" value="Submit" class="btn" />
94
                                </fieldset>
95
                            </form>
96
                        </div>
97
                    </div>
98
                </div> <!-- / .span10/12 -->
99
            </div> <!-- / .row-fluid -->
100
        </div> <!-- / .container-fluid -->
101
    </div> <!-- / .main -->
102
103
[% INCLUDE 'opac-bottom.inc' %]
104
[% BLOCK jsinclude %][% END %]
105
106
<script type="text/javascript">
107
    $(document).ready(function(){
108
        $("#reportproblem").tabs();
109
    });
110
</script>
(-)a/opac/opac-reportproblem.pl (-1 / +94 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 $recipient = $input->param('recipient') || 'library';
47
$template->param(
48
    username => $username,
49
    probpage => $problempage,
50
);
51
52
my $op = $input->param('op') || '';
53
if ( $op eq 'addreport' ) {
54
    my $subject = $input->param('subject');
55
    my $message = $input->param('message');
56
    my $place = $input->param('place');
57
    my $problem = Koha::ProblemReport->new({ title => $subject, content => $message, borrowernumber => $borrowernumber, branchcode => $branchcode, username => $username, problempage => $place, recipient => $recipient, reportdate => dt_from_string() })->store;
58
    $template->param(
59
        recipient => $recipient,
60
        successfuladd => 1,
61
        probpage => $place,
62
    );
63
64
    my $problemreport = $problem->unblessed;
65
    $problemreport->{code} = 'PROBLEM_REPORT';
66
    $problemreport->{content} .= "\nUsername: $username";
67
    $problemreport->{content} .= "\nProblem page: $place";
68
    my $transport = 'email';
69
70
    my $koha_admin = C4::Context->preference('KohaAdminEmailAddress');
71
    my $from_address = $member->{email} || $member->{emailpro} || $member->{B_email} || $koha_admin;
72
73
    if ( $recipient eq 'admin' ) {
74
        C4::Letters::EnqueueLetter({
75
            letter                 => $problemreport,
76
            borrowernumber         => $borrowernumber,
77
            message_transport_type => $transport,
78
            to_address             => $koha_admin,
79
            from_address           => $from_address,
80
        });
81
    } else {
82
        my $library = Koha::Libraries->find($branchcode);
83
        my $to_address = $library->branchemail;
84
        C4::Letters::EnqueueLetter({
85
            letter                 => $problemreport,
86
            borrowernumber         => $borrowernumber,
87
            message_transport_type => $transport,
88
            to_address             => $to_address,
89
            from_address           => $from_address,
90
        });
91
    }
92
}
93
94
output_html_with_http_headers $input, $cookie, $template->output;

Return to bug 4461