Merge remote-tracking branch 'origin/new/bug_7001'

This commit is contained in:
Paul Poulain 2012-03-13 12:27:32 +01:00
commit 5540986811
5 changed files with 36 additions and 15 deletions

View file

@ -255,7 +255,6 @@ sub findrelatedto ($$) {
sub SendAlerts {
my ( $type, $externalid, $letter_code ) = @_;
my $dbh = C4::Context->dbh;
my $strsth;
if ( $type eq 'issue' ) {
# prepare the letter...
@ -295,8 +294,8 @@ sub SendAlerts {
my %mail = (
To => $email,
From => $email,
Subject => "" . $letter->{title},
Message => "" . $letter->{content},
Subject => Encode::encode( "utf8", "" . $letter->{title} ),
Message => Encode::encode( "utf8", "" . $letter->{content} ),
'Content-Type' => 'text/plain; charset="utf8"',
);
sendmail(%mail) or carp $Mail::Sendmail::error;
@ -306,7 +305,7 @@ sub SendAlerts {
# prepare the letter...
# search the biblionumber
$strsth = $type eq 'claimacquisition'
my $strsth = $type eq 'claimacquisition'
? qq{
SELECT aqorders.*,aqbasket.*,biblio.*,biblioitems.*,aqbooksellers.*
FROM aqorders
@ -323,8 +322,8 @@ sub SendAlerts {
LEFT JOIN biblio ON serial.biblionumber=biblio.biblionumber
LEFT JOIN aqbooksellers ON subscription.aqbooksellerid=aqbooksellers.id
WHERE serial.serialid IN (
}
. join( ",", @$externalid ) . ")";
};
$strsth .= join( ",", @$externalid ) . ")";
my $sthorders = $dbh->prepare($strsth);
$sthorders->execute;
my $dataorders = $sthorders->fetchall_arrayref( {} );
@ -339,7 +338,7 @@ sub SendAlerts {
push @email, $databookseller->{contemail} if $databookseller->{contemail};
unless (@email) {
warn "Bookseller $dataorders->[0]->{booksellerid} without emails";
return;
return { error => "no_email" };
}
my $userenv = C4::Context->userenv;
@ -359,8 +358,8 @@ sub SendAlerts {
my %mail = (
To => join( ','. @email),
From => $userenv->{emailaddress},
Subject => "" . $letter->{title},
Message => "" . $letter->{content},
Subject => Encode::encode( "utf8", "" . $letter->{title} ),
Message => Encode::encode( "utf8", "" . $letter->{content} ),
'Content-Type' => 'text/plain; charset="utf8"',
);
sendmail(%mail) or carp $Mail::Sendmail::error;
@ -392,11 +391,12 @@ sub SendAlerts {
want_librarian => 1,
) or return;
return { error => "no_email" } unless $externalid->{'emailaddr'};
my %mail = (
To => $externalid->{'emailaddr'},
From => $branchdetails->{'branchemail'} || C4::Context->preference("KohaAdminEmailAddress"),
Subject => $letter->{'title'},
Message => $letter->{'content'},
Subject => Encode::encode( "utf8", $letter->{'title'} ),
Message => Encode::encode( "utf8", $letter->{'content'} ),
'Content-Type' => 'text/plain; charset="utf8"',
);
sendmail(%mail) or carp $Mail::Sendmail::error;

View file

@ -47,7 +47,7 @@ The functions in this module handle sending text to a printer.
=cut
=comment
=for comment
my $slip = <<"EOF";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Date: $todaysdate;

View file

@ -82,6 +82,17 @@
<div id="yui-main">
<div class="yui-b">
[% IF error_alert %]
[% IF ( error_alert == "no_email" ) %]
<div class="error">This member has no email</div>
[% ELSE %]
<div class="error">[% error_alert %]</div>
[% END %]
[% END %]
[% IF info_alert %]
<div class="dialog message">Email has been sent.</div>
[% END %]
[% IF ( no_add ) %]<div class="dialog alert"><h3>Cannot add patron</h3>
[% IF ( no_branches ) %]<p>There are <strong>no libraries defined</strong>. [% IF ( CAN_user_parameters ) %]Please <a href="/cgi-bin/koha/admin/branches.pl">add a library</a>.[% ELSE %]An administrator must define at least one library.[% END %]</p>[% END %]
[% IF ( no_categories ) %]<p>There are <strong>no patron categories defined</strong>. [% IF ( CAN_user_parameters ) %]Please <a href="/cgi-bin/koha/admin/categorie.pl">add a patron category</a>.[% ELSE %]An administrator must define at least one patron category.</p>[% END %][% END %]</div>[% END %]

View file

@ -347,9 +347,19 @@ if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){
# if we manage to find a valid email address, send notice
if ($emailaddr) {
$newdata{emailaddr} = $emailaddr;
SendAlerts ( 'members', \%newdata, "ACCTDETAILS" );
my $err;
eval {
$err = SendAlerts ( 'members', \%newdata, "ACCTDETAILS" );
};
if ( $@ ) {
$template->param(error_alert => $@);
} elsif ( defined $err->{error} and $err->{error} eq "no_email" ) {
$template->{VARS}->{'error_alert'} = "no_email";
} else {
$template->{VARS}->{'info_alert'} = 1;
}
}
}
}
if ($data{'organisations'}){
# need to add the members organisations

View file

@ -325,7 +325,7 @@ sub default_display {
my $loop_data = [];
my $protected_letters = protected_letters();
foreach my $row (@{$results}) {
$row->{protected} = $protected_letters->{ $row->{code}};
$row->{protected} = !$row->{branchcode} && $protected_letters->{ $row->{code} };
push @{$loop_data}, $row;
}