Bug 4461: Simplify recipients code
As the feature is now turned off without KohaAdminEmailAddress, we only need to check if the email address of the library if defined. Not that we should not check for $library->branchreplyto or ReplytoDefault, but only $library->branchemail, as we do everywhere else (I think) Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
a0775299e2
commit
d198aaec04
|
|
@ -25,57 +25,57 @@
|
|||
[% ELSE %]
|
||||
<div class="span12">
|
||||
[% END %]
|
||||
<h1>Report a problem</h1>
|
||||
<h1>Report a problem</h1>
|
||||
|
||||
[% IF ( successfuladd ) %]
|
||||
<div class="alert alert-info">Your problem report has been sent to the [% IF ( recipient == 'admin' ) %]Koha Administrator[% ELSE %][% recipient | html %][% END %].</div>
|
||||
[% END %]
|
||||
[% IF ( ( nolibemail and noadminemail ) or norecipients ) %]
|
||||
<div class="alert">Unable to send problem reports.</div>
|
||||
[% ELSE %]
|
||||
<div id="reportproblem" class="maincontent toptabs">
|
||||
<form name="reportlibform" action="/cgi-bin/koha/opac-reportproblem.pl" method="post">
|
||||
<input type="hidden" name="op" value="addreport">
|
||||
<fieldset class="rows">
|
||||
<ol>
|
||||
<li>
|
||||
<label for="recipient">Send problem report to: </label>
|
||||
[% IF !nolibemail and noadminemail %]
|
||||
<option value="library">A librarian</option>
|
||||
[% ELSIF !noadminemail and nolibemail %]
|
||||
<option value="admin">Koha Administrator</option>
|
||||
[% ELSE %]
|
||||
<select name="recipient" id="recipient">
|
||||
<option value="library">A librarian</option>
|
||||
<option value="admin">Koha Administrator</option>
|
||||
</select>
|
||||
[% END %]
|
||||
</li>
|
||||
<li>
|
||||
<label for="place">Problem found on page: </label>
|
||||
<input type="hidden" name="place" id="place" value="[% probpage | html %]">
|
||||
[% probpage | html %]
|
||||
</li>
|
||||
<li>
|
||||
<label for="user">Username: </label>
|
||||
<input type="hidden" name="user" id="user" value="[% username | html %]" class="span3">
|
||||
[% username | html %]
|
||||
<li>
|
||||
<label for="subject">Subject: </label>
|
||||
<input type="text" name="subject" id="subject" value="[% subject | html %]" class="span3">
|
||||
</li>
|
||||
<li>
|
||||
<label for="message">Message: </label>
|
||||
<textarea name="message" id="message" rows="7" cols="60"></textarea>
|
||||
</li>
|
||||
</ol>
|
||||
</fieldset>
|
||||
<fieldset class="action">
|
||||
<input type="submit" value="Submit" class="btn">
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
[% END %]
|
||||
[% IF ( successfuladd ) %]
|
||||
<div class="alert alert-info">
|
||||
[% IF recipient == 'admin' %]
|
||||
Your problem report has been sent to the Koha administrator.
|
||||
[% ELSE %]
|
||||
Your problem report has been sent to the library.
|
||||
[% END %]
|
||||
</div>
|
||||
[% END %]
|
||||
<div id="reportproblem" class="maincontent toptabs">
|
||||
<form name="reportlibform" action="/cgi-bin/koha/opac-reportproblem.pl" method="post">
|
||||
<input type="hidden" name="op" value="addreport">
|
||||
<fieldset class="rows">
|
||||
<ol>
|
||||
<li>
|
||||
<label for="recipient">Send problem report to: </label>
|
||||
[% IF library.branchemail %]
|
||||
<select name="recipient" id="recipient">
|
||||
<option value="library">A librarian</option>
|
||||
<option value="admin">Koha administrator</option>
|
||||
</select>
|
||||
[% ELSE %]
|
||||
<span>Koha administrator</span>
|
||||
[% END %]
|
||||
</li>
|
||||
<li>
|
||||
<label for="place">Problem found on page: </label>
|
||||
<input type="hidden" name="place" id="place" value="[% probpage | html %]">
|
||||
[% probpage | html %]
|
||||
</li>
|
||||
<li>
|
||||
<label for="user">Username: </label>
|
||||
<input type="hidden" name="user" id="user" value="[% username | html %]" class="span3">
|
||||
[% username | html %]
|
||||
<li>
|
||||
<label for="subject">Subject: </label>
|
||||
<input type="text" name="subject" id="subject" value="[% subject | html %]" class="span3">
|
||||
</li>
|
||||
<li>
|
||||
<label for="message">Message: </label>
|
||||
<textarea name="message" id="message" rows="7" cols="60"></textarea>
|
||||
</li>
|
||||
</ol>
|
||||
</fieldset>
|
||||
<fieldset class="action">
|
||||
<input type="submit" value="Submit" class="btn">
|
||||
</fieldset>
|
||||
</form>
|
||||
</div> <!-- / #reportproblem -->
|
||||
|
||||
</div> <!-- / .span10/12 -->
|
||||
</div> <!-- / .row-fluid -->
|
||||
|
|
|
|||
|
|
@ -52,40 +52,20 @@ my $member = Koha::Patrons->find($borrowernumber);
|
|||
my $username = $member->userid;
|
||||
my $branchcode = $member->branchcode;
|
||||
my $library = Koha::Libraries->find($branchcode);
|
||||
my $recipients = 2;
|
||||
|
||||
if (
|
||||
( !defined($library->branchreplyto) || $library->branchreplyto eq '' ) &&
|
||||
( C4::Context->preference('ReplytoDefault') eq '' ) &&
|
||||
( !defined($library->branchemail) || $library->branchemail eq '' )
|
||||
) {
|
||||
$template->param( nolibemail => 1 );
|
||||
$recipients--;
|
||||
}
|
||||
|
||||
my $koha_admin = C4::Context->preference('KohaAdminEmailAddress');
|
||||
if ( $koha_admin eq '' ) {
|
||||
$template->param( noadminemail => 1 );
|
||||
$recipients--;
|
||||
}
|
||||
|
||||
$template->param(
|
||||
username => $username,
|
||||
probpage => $problempage,
|
||||
library => $library,
|
||||
);
|
||||
|
||||
my $op = $input->param('op') || '';
|
||||
if ( $op eq 'addreport' ) {
|
||||
|
||||
if ( $recipients == 0 ){
|
||||
print $input->redirect("/cgi-bin/koha/opac-reportproblem?norecipients=1.pl");
|
||||
exit;
|
||||
}
|
||||
|
||||
my $subject = $input->param('subject');
|
||||
my $message = $input->param('message');
|
||||
my $place = $input->param('place');
|
||||
my $recipient = $input->param('recipient') || 'library';
|
||||
my $recipient = $input->param('recipient') || 'admin';
|
||||
my $problem = Koha::ProblemReport->new(
|
||||
{
|
||||
title => $subject,
|
||||
|
|
@ -121,18 +101,15 @@ if ( $op eq 'addreport' ) {
|
|||
letter => $letter,
|
||||
borrowernumber => $borrowernumber,
|
||||
message_transport_type => $transport,
|
||||
to_address => $koha_admin,
|
||||
to_address => C4::Context->preference('KohaAdminEmailAddress'),
|
||||
from_address => $from_address,
|
||||
});
|
||||
} else {
|
||||
my $to_address = $library->branchreplyto ||
|
||||
C4::Context->preference('ReplytoDefault') ||
|
||||
$library->branchemail;
|
||||
C4::Letters::EnqueueLetter({
|
||||
letter => $letter,
|
||||
borrowernumber => $borrowernumber,
|
||||
message_transport_type => $transport,
|
||||
to_address => $to_address,
|
||||
to_address => $library->branchemail,
|
||||
from_address => $from_address,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue