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

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc (+5 lines)
Lines 20-25 Link Here
20
        <div class="container-fluid">
20
        <div class="container-fluid">
21
            <div class="row-fluid">
21
            <div class="row-fluid">
22
                <div class="span12">
22
                <div class="span12">
23
                    [% IF Koha.Preference('OPACReportProblem') %]
24
                        <div id="report_a_problem" class="noprint" style="float:left;">
25
                            <a class="koha-url" href="/cgi-bin/koha/opac-reportproblem.pl">Report a problem</a>
26
                        </div>
27
                    [% END %]
23
                    <div id="koha_url" class="clearfix noprint">
28
                    <div id="koha_url" class="clearfix noprint">
24
                        <p>Powered by
29
                        <p>Powered by
25
                        [% IF template.name.match('opac-main.tt') %]
30
                        [% IF template.name.match('opac-main.tt') %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reportproblem.tt (+92 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
30
                    [% IF Koha.Preference('OPACReportProblem') %]
31
32
                        [% IF ( successfuladd ) %]
33
                            <div class="alert alert-info">Your problem report has been sent to the [% IF ( recipient == 'admin' ) %]Koha Administrator[% ELSE %][% recipient %][% END %].</div>
34
                        [% END %]
35
                        [% IF ( ( nolibemail and noadminemail ) or norecipients ) %]
36
                            <div class="alert">Unable to send problem reports.</div>
37
                        [% ELSE %]
38
                            <div id="reportproblem" class="maincontent toptabs">
39
                                <form name="reportlibform" action="/cgi-bin/koha/opac-reportproblem.pl" method="post">
40
                                    <input type="hidden" name="op" value="addreport">
41
                                    <fieldset class="rows">
42
                                        <ol>
43
                                            <li>
44
                                                <label for="recipient">Send problem report to: </label>
45
                                                [% IF !nolibemail and noadminemail %]
46
                                                    <option value="library">A librarian</option>
47
                                                [% ELSIF !noadminemail and nolibemail %]
48
                                                    <option value="admin">Koha Administrator</option>
49
                                                [% ELSE %]
50
                                                    <select name="recipient" id="recipient">
51
                                                        <option value="library">A librarian</option>
52
                                                        <option value="admin">Koha Administrator</option>
53
                                                    </select>
54
                                                [% END %]
55
                                            </li>
56
                                            <li>
57
                                                <label for="place">Problem found on page: </label>
58
                                                <input type="hidden" name="place" id="place" value="[% probpage %]">
59
                                                [% probpage | html %]
60
                                            </li>
61
                                            <li>
62
                                                <label for="user">Username: </label>
63
                                                <input type="hidden" name="user" id="user" value="[% username %]" class="span3">
64
                                                [% username | html %]
65
                                            <li>
66
                                                <label for="subject">Subject: </label>
67
                                                <input type="text" name="subject" id="subject" value="[% subject %]" class="span3">
68
                                            </li>
69
                                            <li>
70
                                                <label for="message">Message: </label>
71
                                                <textarea name="message" id="message" rows="7" cols="60"></textarea>
72
                                            </li>
73
                                        </ol>
74
                                    </fieldset>
75
                                    <fieldset class="action">
76
                                        <input type="submit" value="Submit" class="btn">
77
                                    </fieldset>
78
                                </form>
79
                            </div>
80
                        [% END %]
81
82
                    [% ELSE %] <!-- OPACReportProblem preference -->
83
                        <div class="alert">Your library has not activated this feature.</div>
84
                    [% END %]
85
86
                </div> <!-- / .span10/12 -->
87
            </div> <!-- / .row-fluid -->
88
        </div> <!-- / .container-fluid -->
89
    </div> <!-- / .main -->
90
91
[% INCLUDE 'opac-bottom.inc' %]
92
[% BLOCK jsinclude %][% END %]
(-)a/opac/opac-reportproblem.pl (-1 / +118 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Copyright 2019 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
use Modern::Perl;
21
use CGI qw ( -utf8 );
22
use C4::Auth;    # get_template_and_user
23
use C4::Output;
24
use C4::Members;
25
use C4::Letters;
26
use Koha::ProblemReport;
27
use Koha::DateUtils;
28
use Koha::Libraries;
29
use Koha::Patrons;
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 = Koha::Patrons->find($borrowernumber);
44
my $username = $member->userid;
45
my $branchcode = $member->branchcode;
46
my $library = Koha::Libraries->find($branchcode);
47
my $recipients = 2;
48
49
if (
50
    ( !defined($library->branchreplyto) || $library->branchreplyto eq '' ) &&
51
    ( C4::Context->preference('ReplytoDefault') eq '' ) &&
52
    ( !defined($library->branchemail) || $library->branchemail eq '' )
53
    ) {
54
    $template->param( nolibemail => 1 );
55
    $recipients--;
56
}
57
58
my $koha_admin = C4::Context->preference('KohaAdminEmailAddress');
59
if ( $koha_admin eq '' ) {
60
    $template->param( noadminemail => 1 );
61
    $recipients--;
62
}
63
64
$template->param(
65
    username => $username,
66
    probpage => $problempage,
67
);
68
69
my $op = $input->param('op') || '';
70
if ( $op eq 'addreport' ) {
71
72
    if ( $recipients == 0 ){
73
        print $input->redirect("/cgi-bin/koha/opac-reportproblem?norecipients=1.pl");
74
        exit;
75
    }
76
77
    my $subject = $input->param('subject');
78
    my $message = $input->param('message');
79
    my $place = $input->param('place');
80
    my $recipient = $input->param('recipient') || 'library';
81
    my $problem = Koha::ProblemReport->new({ title => $subject, content => $message, borrowernumber => $borrowernumber, branchcode => $branchcode, username => $username, problempage => $place, recipient => $recipient, reportdate => dt_from_string() })->store;
82
    $template->param(
83
        recipient => $recipient,
84
        successfuladd => 1,
85
        probpage => $place,
86
    );
87
88
    my $problemreport = $problem->unblessed;
89
    $problemreport->{code} = 'PROBLEM_REPORT';
90
    $problemreport->{content} .= "\nUsername: $username";
91
    $problemreport->{content} .= "\nProblem page: $place";
92
    my $transport = 'email';
93
94
    my $from_address = $member->email || $member->emailpro || $member->B_email || $koha_admin;
95
96
    if ( $recipient eq 'admin' ) {
97
        C4::Letters::EnqueueLetter({
98
            letter                 => $problemreport,
99
            borrowernumber         => $borrowernumber,
100
            message_transport_type => $transport,
101
            to_address             => $koha_admin,
102
            from_address           => $from_address,
103
        });
104
    } else {
105
        my  $to_address = $library->branchreplyto ||
106
            C4::Context->preference('ReplytoDefault') ||
107
            $library->branchemail;
108
        C4::Letters::EnqueueLetter({
109
            letter                 => $problemreport,
110
            borrowernumber         => $borrowernumber,
111
            message_transport_type => $transport,
112
            to_address             => $to_address,
113
            from_address           => $from_address,
114
        });
115
    }
116
}
117
118
output_html_with_http_headers $input, $cookie, $template->output;

Return to bug 4461