display sent mail on customer notes page, and improve sent mail log UI, #29250
[freeside.git] / httemplate / search / cust_msg.html
index f71a866..2b6f08e 100644 (file)
@@ -1,11 +1,11 @@
 <& 'elements/search.html',
        'title' => $title,
-       'name'  => 'messages',
+       'name_singular'  => 'message',
        'query' => $query,
        'count_query' => $count_query,
        'header' => [ 
                      'Date',
-                     'Template',
+                     'Type',
                      'Destination',
                      'Status',
                      '', #error
                        my $date = $_[0]->_date;
                        $date ? time2str('%Y-%m-%d %T',$_[0]->_date) : '' 
                      },
-                     'msgname',
+                     sub {
+                       ucfirst($_[0]->msgtype) || $_[0]->msgname
+                     },
                      sub {
                        join('<BR>', split(/,\s*/, $_[0]->env_to) )
                      },
                      'status',
                      sub { encode_entities($_[0]->error) },
                   ],
+       'sort_fields' => [ '_date',
+                          'msgtype',
+                          'env_to',
+                          'status',
+                          'error',
+                        ],
        'align' => 'rllcl',
        'links' => [ ],
        'link_onclicks' => [ 
                     '',
                     '',
                   ],
-       'color' => [ ('') x 3, 
-                     $statuscolor,
-                     $statuscolor,
+       'color' => [ '',
+                    $typecolor,
+                    '',
+                    $statuscolor,
+                    $statuscolor,
                   ],
        'html_init' => $html_init,
        'really_disable_download' => 1,
+       @_
 &>
 <%init>
 #hmm...
@@ -51,6 +62,12 @@ my @where;
 if ( $cgi->param('status') =~ /^(\w+)$/ ) {
   push @where, "status = '$1'";
 }
+if ( $cgi->param('msgtype') =~ /^(\w+)$/ ) {
+  push @where, "msgtype = '$1'";
+}
+if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
+  push @where, "custnum = $1";
+}
 my ($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, '');
 push @where, "(_date >= $beginning AND _date <= $ending)";
 
@@ -79,16 +96,22 @@ my $sub_popup_link = sub {
   include('/elements/popup_link_onclick.html',
     'action'      => $p. 'view/cust_msg.html?' . $custmsgnum,
     'actionlabel' => 'Message detail',
-    'width'       => 600,
-    'height'      => 500,
+    'width'       => 680,
+    'height'      => 550,
   );
 };
 
 my %color = (
   'failed'   => 'FF0000',
   'sent'     => '',
+
+  'invoice'  => '00CC00',
+  'receipt'  => '0000CC',
+  'admin'    => 'CC0000',
+  ''         => '000000',
 );
 my $statuscolor = sub { $color{$_[0]->status} };
+my $typecolor = sub { $color{$_[0]->msgtype} };
 
 my $html_init = qq!<FORM ACTION="$p/search/cust_msg.html" METHOD="GET">
 <TABLE cellspacing="10">!.
@@ -110,6 +133,17 @@ include('/elements/select.html',
                 'failed'  => 'failed',
                 'sent'    => 'sent', },
 ) .
+'</TD><TD> Type '.
+include('/elements/select.html',
+  'field' => 'msgtype',
+  'curr_value' => $cgi->param('msgtype') || '',
+  'options' => [ '', 'invoice', 'receipt', 'admin' ],
+  'labels'  => { ''         => '(any)',
+                 'invoice'  => 'Invoices',
+                 'receipt'  => 'Receipts',
+                 'admin'    => 'Admin notices',
+               },
+) .
 '</TD>
 <TD><INPUT type="submit" value="Search"></TD></TR>
 </TABLE></FORM><BR>