[freeside-commits] branch FREESIDE_3_BRANCH updated. aac2d8662226b1105d157f59983140589bd89c43

Jonathan Prykop jonathan at 420.am
Mon Feb 23 15:25:07 PST 2015


The branch, FREESIDE_3_BRANCH has been updated
       via  aac2d8662226b1105d157f59983140589bd89c43 (commit)
       via  2fd56c72e2bc28352da250e061277918f3fdb17c (commit)
      from  e3004bbda87eaba918f5742a7ccb53fe3aa38031 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit aac2d8662226b1105d157f59983140589bd89c43
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Fri Feb 20 15:28:46 2015 -0600

    RT#23598: Feature Request - Email notice to A/R Report Results [now uses checkboxes and a proper popup]

diff --git a/httemplate/elements/popup_link_onclick.html b/httemplate/elements/popup_link_onclick.html
index 961f623..5173115 100644
--- a/httemplate/elements/popup_link_onclick.html
+++ b/httemplate/elements/popup_link_onclick.html
@@ -8,6 +8,9 @@ Example:
 
     #required
     'action'         => 'content.html', # uri for content of popup
+
+    #alternately, use instead of action
+    'js_action'      => 'url',          # javascript variable or expression
    
     #strongly recommended
     'actionlabel     => 'You clicked',  # popup title
@@ -47,7 +50,8 @@ if (ref($_[0]) eq 'HASH') {
   $params = { @_ };
 }
 
-$action      = $params->{'action'}      if exists $params->{'action'};
+$action      = q(') . $params->{'action'} . q(') if exists $params->{'action'};
+$action      = $params->{'js_action'}   if exists $params->{'js_action'};
 $actionlabel = $params->{'actionlabel'} if exists $params->{'actionlabel'};
 $width       = $params->{'width'}       if exists $params->{'width'};
 $height      = $params->{'height'}      if exists $params->{'height'};
@@ -61,7 +65,7 @@ $scrolling   = $params->{'scrolling'}   if exists $params->{'scrolling'};
 my $popup_name = 'popup-'.time. "-$$-". rand() * 2**32;
 
 my $onclick =
-  "overlib( OLiframeContent('$action', $width, $height, '$popup_name', 0, '$scrolling' ), ".
+  "overlib( OLiframeContent($action, $width, $height, '$popup_name', 0, '$scrolling' ), ".
     "CAPTION, '$actionlabel', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, ".
     "DRAGGABLE, CLOSECLICK, ".
     "BGCOLOR, '$color', CGCOLOR, '$color', CLOSETEXT, '$closetext'".
diff --git a/httemplate/misc/email-customers.html b/httemplate/misc/email-customers.html
index c74c15b..83e8615 100644
--- a/httemplate/misc/email-customers.html
+++ b/httemplate/misc/email-customers.html
@@ -1,4 +1,9 @@
+% if ($popup) {
+<% include('/elements/header-popup.html', $title) %>
+% } else {
 <% include('/elements/header.html', $title) %>
+% }
+
 
 <FORM NAME="OneTrueForm" ACTION="email-customers.html" METHOD="POST">
 <INPUT TYPE="hidden" NAME="table" VALUE="<% $table %>">
@@ -7,6 +12,8 @@
 %# multi-valued search params.  We are no longer in search context, so we 
 %# pack the search into a Storable string for later use.
 <INPUT TYPE="hidden" NAME="search" VALUE="<% encode_base64(nfreeze(\%search)) %>">
+<INPUT TYPE="hidden" NAME="popup" VALUE="<% $popup %>">
+<INPUT TYPE="hidden" NAME="url" VALUE="<% $url | h %>">
 
 % if ( $cgi->param('action') eq 'send' ) { 
 
@@ -16,7 +23,7 @@
                  'OneTrueForm',
                  [ qw( search table from subject html_body text_body msgnum ) ],
                  'process/email-customers.html',
-                 { 'message' => "Notice sent" }, #would be nice to show #, but..
+                 $pdest,
               )
     %>
 
@@ -159,13 +166,18 @@ my $conf = FS::Conf->new;
 my $table = $cgi->param('table') or die "'table' required";
 my $agent_virt_agentnum = $cgi->param('agent_virt_agentnum') || '';
 
+my $popup = $cgi->param('popup');
+my $url   = $cgi->param('url');
+my $pdest = { 'message' => "Notice sent" };
+$pdest->{'url'} = $cgi->param('url') if $url;
+
 my %search;
 if ( $cgi->param('search') ) {
   %search = %{ thaw(decode_base64($cgi->param('search'))) };
 }
 else {
   %search = $cgi->Vars;
-  delete $search{$_} for qw( action table from subject html_body text_body );
+  delete $search{$_} for qw( action table from subject html_body text_body popup url );
   # FS::$table->search is expected to know which parameters might be 
   # multi-valued, and to accept scalar values for them also.  No good 
   # solution to this since CGI can't tell whether a parameter _might_
diff --git a/httemplate/search/elements/checkbox-foot.html b/httemplate/search/elements/checkbox-foot.html
index cc4bac6..c470094 100644
--- a/httemplate/search/elements/checkbox-foot.html
+++ b/httemplate/search/elements/checkbox-foot.html
@@ -75,6 +75,15 @@ function setAll(setTo) {
     checkboxes[i].checked = setTo;
   }
 }
+function toCGIString() {
+  var out = '';
+  for (var i = 0; i < checkboxes.length; i++) {
+    if (checkboxes[i].checked) {
+      out += '&' + checkboxes[i].name + '=' + checkboxes[i].value;
+    }
+  }
+  return out;
+}
 </SCRIPT>
 <%init>
 my %opt = @_;
diff --git a/httemplate/search/elements/cust_main_dayranges.html b/httemplate/search/elements/cust_main_dayranges.html
index 73a429f..e5b1f47 100644
--- a/httemplate/search/elements/cust_main_dayranges.html
+++ b/httemplate/search/elements/cust_main_dayranges.html
@@ -21,6 +21,7 @@ Example:
                  'query'       => $sql_query,
                  'count_query' => $count_sql,
                  'header'      => [
+                                    @act_blank,
                                     @cust_header,
                                     '0-30',
                                     '30-60',
@@ -28,9 +29,9 @@ Example:
                                     '90+',
                                     emt('Total'),
                                     @pay_head,
-                                    @act_header,
                                   ],
                  'footer'      => [
+                                    @act_blank,
                                     'Total',
                                     ( map '',( 1 .. $#cust_header ),),
                                     sprintf( $money_char.'%.2f',
@@ -44,9 +45,9 @@ Example:
                                     sprintf( '<b>'.$money_char.'%.2f</b>',
                                              $row->{'rangecol_0_0'} ),
                                     ('') x @pay_labels,
-                                    @act_blank,
                                   ],
                  'fields'      => [
+                                    @act_fields,
                                     FS::UI::Web::cust_fields_subs(),
                                     format_rangecol('0_30'),
                                     format_rangecol('30_60'),
@@ -54,9 +55,9 @@ Example:
                                     format_rangecol('90_0'),
                                     format_rangecol('0_0'),
                                     @pay_labels,
-                                    @act_fields,
                                   ],
                  'links'       => [
+                                    @act_blank,
                                     ( map { $_ ne 'Cust. Status' ? $clink : '' }
                                           @cust_header
                                     ),
@@ -66,44 +67,41 @@ Example:
                                     '',
                                     '',
                                     @pay_links,
-                                    @act_blank,
                                   ],
-                 'link_onclicks' => [ ( map '', @cust_header ),
-                                      '', '', '', '', '', 
-                                      ( map '', @pay_labels ),
-                                      @act_link_onclicks,
-                                    ],
-                 'align'       => FS::UI::Web::cust_aligns(). 
+                 'align'       => $act_align.
+                                  FS::UI::Web::cust_aligns(). 
                                    'rrrrr'.
                                   ('c' x @pay_labels),
-                                  @act_align,
-                 'size'        => [ ( map '', @cust_header ),
+                 'size'        => [ 
+                                    @act_blank,
+                                    ( map '', @cust_header ),
                                     #'-1', '', '', '', '',  '', ],
-                                    '', '', '', '', '',  '', 
+                                    '', '', '', '', '',
                                     ( map '', @pay_labels ),
+                                  ],
+                 'style'       => [ 
                                     @act_blank,
-                                    ],
-                 'style'       => [ FS::UI::Web::cust_styles(),
+                                    FS::UI::Web::cust_styles(),
                                     #'b', '', '', '', '', 'b', ],
                                     '', '', '', '', 'b', 
                                     ( map '', @pay_labels ),
-                                    @act_blank,
                                     ],
-                 'xls_format'  => [ (map '', FS::UI::Web::cust_styles),
-                                    '', '', '', '', { bold => 1 },
+                 'xls_format'  => [ 
                                     @act_blank,
+                                    (map '', FS::UI::Web::cust_styles),
+                                    '', '', '', '', { bold => 1 },
                                   ],
                  'color'       => [
+                                    @act_blank,
                                     FS::UI::Web::cust_colors(),
                                     '',
                                     '',
                                     '',
                                     '',
                                     '',
-                                    '',
                                     ( map '', @pay_labels ),
-                                    @act_blank,
                                   ],
+                 'html_foot'   => $html_foot,
                %opt,
 &>
 <%init>
@@ -250,16 +248,29 @@ if($opt{'payment_links'} && $curuser->access_right('Process payment') && @payby)
                          @payby );
 }
 
-my (@act_header, @act_fields, @act_link_onclicks, @act_align, @act_blank);
-if (delete($opt{'email_links'})) {
-  push @act_header, 'Actions';
-  push @act_fields, sub { 'send email' };
-  push @act_link_onclicks, sub {
+my (@act_blank, @act_fields, $act_align, $html_foot);
+if (delete($opt{'email_checkboxes'})) {
+  my $email_link = q!var url = toCGIString(); !;
+  $email_link   .= q/if (!url) { alert('No customers selected'); return false; }; /;
+  $email_link   .= q!url = '!;
+  $email_link   .= "${p}misc/email-customers.html?table=cust_main";
+  $email_link   .= q!' + url + '&popup=1&url=javascript%3Awindow.top.location.reload%28%29%3B'; !;
+  $email_link   .= include('/elements/popup_link_onclick.html',
+    'js_action' => 'url',
+    'actionlabel' => 'Send Customer Email',
+    'width' => '900',
+    'height' => '500',
+  );
+  $html_foot = include('checkbox-foot.html',
+    label   => 'Email selected customers',
+    onclick => $email_link,
+  );
+  push @act_fields, sub { 
     my $row = shift;
     my $custnum = $row->custnum;
-    return qq!window.open('${p}misc/email-customers.html?table=cust_main&custnum=$custnum','_blank')!;
+    qq!<input type="checkbox" name="custnum" value="$custnum">!;
   };
-  push @act_align, 'l';
+  $act_align = 'l';
   push @act_blank, '';
 }
 
diff --git a/httemplate/search/report_receivables.cgi b/httemplate/search/report_receivables.cgi
index bca2a05..adbbc85 100755
--- a/httemplate/search/report_receivables.cgi
+++ b/httemplate/search/report_receivables.cgi
@@ -2,7 +2,7 @@
                  'title'       => emt('Accounts Receivable Aging Summary'),
                  'range_sub'   => \&balance,
                  'payment_links' => 1,
-                 'email_links' => 1,
+                 'email_checkboxes' => 1,
 &>
 <%init>
 

commit 2fd56c72e2bc28352da250e061277918f3fdb17c
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Mon Feb 16 20:02:30 2015 -0600

    RT#23598: Feature Request - Email notice to A/R Report Results

diff --git a/httemplate/search/elements/cust_main_dayranges.html b/httemplate/search/elements/cust_main_dayranges.html
index 5dbece8..73a429f 100644
--- a/httemplate/search/elements/cust_main_dayranges.html
+++ b/httemplate/search/elements/cust_main_dayranges.html
@@ -5,6 +5,7 @@ Example:
   <& elements/cust_main_dayranges.html,
                  'title'       => 'Accounts Receivable Aging Summary',
                  'range_sub'   => $mysub,
+                 'email_link'  => 1,  #adds an action column with an email link if true
   &>
 
   my $mysub = sub {
@@ -27,6 +28,7 @@ Example:
                                     '90+',
                                     emt('Total'),
                                     @pay_head,
+                                    @act_header,
                                   ],
                  'footer'      => [
                                     'Total',
@@ -42,6 +44,7 @@ Example:
                                     sprintf( '<b>'.$money_char.'%.2f</b>',
                                              $row->{'rangecol_0_0'} ),
                                     ('') x @pay_labels,
+                                    @act_blank,
                                   ],
                  'fields'      => [
                                     FS::UI::Web::cust_fields_subs(),
@@ -51,6 +54,7 @@ Example:
                                     format_rangecol('90_0'),
                                     format_rangecol('0_0'),
                                     @pay_labels,
+                                    @act_fields,
                                   ],
                  'links'       => [
                                     ( map { $_ ne 'Cust. Status' ? $clink : '' }
@@ -62,22 +66,32 @@ Example:
                                     '',
                                     '',
                                     @pay_links,
+                                    @act_blank,
                                   ],
+                 'link_onclicks' => [ ( map '', @cust_header ),
+                                      '', '', '', '', '', 
+                                      ( map '', @pay_labels ),
+                                      @act_link_onclicks,
+                                    ],
                  'align'       => FS::UI::Web::cust_aligns(). 
                                    'rrrrr'.
                                   ('c' x @pay_labels),
+                                  @act_align,
                  'size'        => [ ( map '', @cust_header ),
                                     #'-1', '', '', '', '',  '', ],
                                     '', '', '', '', '',  '', 
                                     ( map '', @pay_labels ),
+                                    @act_blank,
                                     ],
                  'style'       => [ FS::UI::Web::cust_styles(),
                                     #'b', '', '', '', '', 'b', ],
                                     '', '', '', '', 'b', 
                                     ( map '', @pay_labels ),
+                                    @act_blank,
                                     ],
                  'xls_format'  => [ (map '', FS::UI::Web::cust_styles),
                                     '', '', '', '', { bold => 1 },
+                                    @act_blank,
                                   ],
                  'color'       => [
                                     FS::UI::Web::cust_colors(),
@@ -88,6 +102,7 @@ Example:
                                     '',
                                     '',
                                     ( map '', @pay_labels ),
+                                    @act_blank,
                                   ],
                %opt,
 &>
@@ -235,6 +250,19 @@ if($opt{'payment_links'} && $curuser->access_right('Process payment') && @payby)
                          @payby );
 }
 
+my (@act_header, @act_fields, @act_link_onclicks, @act_align, @act_blank);
+if (delete($opt{'email_links'})) {
+  push @act_header, 'Actions';
+  push @act_fields, sub { 'send email' };
+  push @act_link_onclicks, sub {
+    my $row = shift;
+    my $custnum = $row->custnum;
+    return qq!window.open('${p}misc/email-customers.html?table=cust_main&custnum=$custnum','_blank')!;
+  };
+  push @act_align, 'l';
+  push @act_blank, '';
+}
+
 </%init>
 <%once>
 
diff --git a/httemplate/search/report_receivables.cgi b/httemplate/search/report_receivables.cgi
index 9c5c0e2..bca2a05 100755
--- a/httemplate/search/report_receivables.cgi
+++ b/httemplate/search/report_receivables.cgi
@@ -2,6 +2,7 @@
                  'title'       => emt('Accounts Receivable Aging Summary'),
                  'range_sub'   => \&balance,
                  'payment_links' => 1,
+                 'email_links' => 1,
 &>
 <%init>
 

-----------------------------------------------------------------------

Summary of changes:
 httemplate/elements/popup_link_onclick.html        |    8 ++-
 httemplate/misc/email-customers.html               |   16 +++++-
 httemplate/search/elements/checkbox-foot.html      |    9 ++++
 .../search/elements/cust_main_dayranges.html       |   53 +++++++++++++++++---
 httemplate/search/report_receivables.cgi           |    1 +
 5 files changed, 76 insertions(+), 11 deletions(-)




More information about the freeside-commits mailing list