Bug 6939 DefaultClassificationSource should be default in 942
[koha_fer] / C4 / Letters.pm
index 5a929d0..4bde166 100644 (file)
@@ -38,7 +38,7 @@ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 BEGIN {
        require Exporter;
        # set the version for version checking
-       $VERSION = 3.01;
+    $VERSION = 3.07.00.049;
        @ISA = qw(Exporter);
        @EXPORT = qw(
        &GetLetters &GetPreparedLetter &GetWrappedLetter &addalert &getalert &delalert &findrelatedto &SendAlerts &GetPrintMessages
@@ -307,7 +307,8 @@ sub SendAlerts {
         # 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
@@ -316,7 +317,8 @@ sub SendAlerts {
             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
@@ -356,7 +358,7 @@ sub SendAlerts {
 
         # ... 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} ),
@@ -659,7 +661,7 @@ places a letter in the message_queue database table, which will
 eventually get processed (sent) by the process_message_queue.pl
 cronjob when it calls SendQueuedMessages.
 
-return true on success
+return message_id on success
 
 =cut
 
@@ -670,6 +672,13 @@ sub EnqueueLetter ($) {
     return unless exists $params->{'borrowernumber'};
     return unless exists $params->{'message_transport_type'};
 
+    my $content = $params->{letter}->{content};
+    $content =~ s/\s+//g if(defined $content);
+    if ( not defined $content or $content eq '' ) {
+        warn "Trying to add an empty message to the message queue" if $debug;
+        return;
+    }
+
     # If we have any attachments we should encode then into the body.
     if ( $params->{'attachments'} ) {
         $params->{'letter'} = _add_attachments(
@@ -701,7 +710,7 @@ ENDSQL
         $params->{'from_address'},                # from_address
         $params->{'letter'}->{'content-type'},    # content_type
     );
-    return $result;
+    return $dbh->last_insert_id(undef,undef,'message_queue', undef);
 }
 
 =head2 SendQueuedMessages ([$hashref])