Bug 7756: FIX send email for late orders
authorJonathan Druart <jonathan.druart@biblibre.com>
Tue, 10 Apr 2012 08:06:59 +0000 (10:06 +0200)
committerPaul Poulain <paul.poulain@biblibre.com>
Thu, 12 Apr 2012 14:50:27 +0000 (16:50 +0200)
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
- sending claim mails works now
- claim counter is not increased when vendor has no email address

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
C4/Letters.pm
acqui/lateorders.pl

index 5a929d0..89213fe 100644 (file)
@@ -307,7 +307,8 @@ sub SendAlerts {
         # search the biblionumber
         my $strsth =  $type eq 'claimacquisition'
             ? qq{
         # search the biblionumber
         my $strsth =  $type eq 'claimacquisition'
             ? qq{
-            SELECT aqorders.*,aqbasket.*,biblio.*,biblioitems.*,aqbooksellers.*
+            SELECT aqorders.*,aqbasket.*,biblio.*,biblioitems.*,aqbooksellers.*,
+            aqbooksellers.id AS booksellerid
             FROM aqorders
             LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
             LEFT JOIN biblio ON aqorders.biblionumber=biblio.biblionumber
             FROM aqorders
             LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
             LEFT JOIN biblio ON aqorders.biblionumber=biblio.biblionumber
@@ -316,7 +317,8 @@ sub SendAlerts {
             WHERE aqorders.ordernumber IN (
             }
             : qq{
             WHERE aqorders.ordernumber IN (
             }
             : qq{
-            SELECT serial.*,subscription.*, biblio.*, aqbooksellers.*
+            SELECT serial.*,subscription.*, biblio.*, aqbooksellers.*,
+            aqbooksellers.id AS booksellerid
             FROM serial
             LEFT JOIN subscription ON serial.subscriptionid=subscription.subscriptionid
             LEFT JOIN biblio ON serial.biblionumber=biblio.biblionumber
             FROM serial
             LEFT JOIN subscription ON serial.subscriptionid=subscription.subscriptionid
             LEFT JOIN biblio ON serial.biblionumber=biblio.biblionumber
@@ -356,7 +358,7 @@ sub SendAlerts {
 
         # ... then send mail
         my %mail = (
 
         # ... then send mail
         my %mail = (
-            To => join( ','. @email),
+            To => join( ',', @email),
             From           => $userenv->{emailaddress},
             Subject        => Encode::encode( "utf8", "" . $letter->{title} ),
             Message        => Encode::encode( "utf8", "" . $letter->{content} ),
             From           => $userenv->{emailaddress},
             Subject        => Encode::encode( "utf8", "" . $letter->{title} ),
             Message        => Encode::encode( "utf8", "" . $letter->{content} ),
index 21ee186..031fc88 100755 (executable)
@@ -81,11 +81,13 @@ if ($op and $op eq "send_alert"){
     my $err;
     eval {
         $err = SendAlerts( 'claimacquisition', \@ordernums, $input->param("letter_code") );    # FIXME: Fallback value?
     my $err;
     eval {
         $err = SendAlerts( 'claimacquisition', \@ordernums, $input->param("letter_code") );    # FIXME: Fallback value?
-        AddClaim ( $_ ) for @ordernums;
+        if ( not ref $err or not exists $err->{error} ) {
+            AddClaim ( $_ ) for @ordernums;
+        }
     };
     if ( $@ ) {
         $template->param(error_claim => $@);
     };
     if ( $@ ) {
         $template->param(error_claim => $@);
-    } elsif ( defined $err->{error} and $err->{error} eq "no_email" ) {
+    } elsif ( ref $err and exists $err->{error} and $err->{error} eq "no_email" ) {
         $template->{VARS}->{'error_claim'} = "no_email";
     } else {
         $template->{VARS}->{'info_claim'} = 1;
         $template->{VARS}->{'error_claim'} = "no_email";
     } else {
         $template->{VARS}->{'info_claim'} = 1;