RT 81913 - fixed error with batch email from advanced customer reports and contacts...
authorChristopher Burger <burgerc@freeside.biz>
Thu, 3 Jan 2019 17:38:32 +0000 (12:38 -0500)
committerChristopher Burger <burgerc@freeside.biz>
Thu, 3 Jan 2019 17:59:41 +0000 (12:59 -0500)
Conflicts:
httemplate/search/contact.html
httemplate/search/cust_main.html

httemplate/misc/email-customers.html
httemplate/search/cust_main.html

index 1c22f8f..577e5df 100644 (file)
@@ -168,7 +168,7 @@ Template:
     },
   &>
    </div>
-% if ($send_to_domain) {
+% if ($send_to_domain && $cgi->param('custnum')) {
    <div>
      <INPUT TYPE="checkbox" NAME="emailtovoice"  ID="emailtovoice" VALUE="ON" onclick="toggleDiv(this)">Email to voice
    </div>
@@ -295,6 +295,15 @@ else {
   @search{keys %search} = map { /\0/ ? [ split /\0/, $_ ] : $_ } values %search;
 }
 
+# rebuild contacts hash
+delete $search{contacts}
+    if exists $search{contacts} && ref $search{contacts};
+$search{'contacts'} = {
+  map { $_ => $search{$_}, }
+    grep { /^(contacts_*)/ && $search{$_} }
+      keys %search
+};
+
 &{$opt{'post_search_hook'}}(
   'conf'   => $conf,
   'search' => \%search,
index d4b4faf..7cfe5ec 100755 (executable)
@@ -133,8 +133,16 @@ my $menubar = [];
 
 if ( $FS::CurrentUser::CurrentUser->access_right('Bulk send customer notices') ) {
 
+  # URI::query_from does not support hashref
+  #   results in: ...&contacts=HASH(0x55e16cb81da8)&...
+  my %query_hash = %search_hash;
+  foreach (keys %{$query_hash{contacts}}) { $query_hash{$_} = $query_hash{contacts}{$_}; }
+
+  delete $query_hash{contacts}
+    if exists $query_hash{contacts} && ref $query_hash{contacts};
+
   my $uri = new URI;
-  $uri->query_form( \%search_hash );
+  $uri->query_form( \%query_hash );
   my $query = $uri->query;
 
   push @$menubar, emt('Email a notice to these customers') =>