From c422010521a7c09673a8d4d0068d3fd482dd2dbc Mon Sep 17 00:00:00 2001 From: Jonathan Prykop Date: Tue, 5 May 2015 15:49:51 -0500 Subject: RT#34289: Flag service fields as mandatory --- httemplate/edit/elements/edit.html | 1 + httemplate/edit/elements/part_svc_column.html | 7 ++- httemplate/edit/elements/svc_Common.html | 3 ++ httemplate/edit/svc_acct.cgi | 63 ++++++++++++++-------- httemplate/edit/svc_acct/communigate.html | 5 +- httemplate/edit/svc_broadband.cgi | 11 +++- httemplate/elements/tr-input-date-field.html | 9 ++-- httemplate/elements/tr-select-hardware_type.html | 5 +- httemplate/elements/tr-select-router_block_ip.html | 6 +-- 9 files changed, 74 insertions(+), 36 deletions(-) (limited to 'httemplate') diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html index 76df82064..7b02994d1 100644 --- a/httemplate/edit/elements/edit.html +++ b/httemplate/edit/elements/edit.html @@ -418,6 +418,7 @@ Example: % 'value' => $opt{curr_value}, % 'label' => $label, % 'noinit' => $f->{noinit}, +% 'required' => $f->{'required'}, % } % ); % } diff --git a/httemplate/edit/elements/part_svc_column.html b/httemplate/edit/elements/part_svc_column.html index 23a6deb56..bc679e577 100644 --- a/httemplate/edit/elements/part_svc_column.html +++ b/httemplate/edit/elements/part_svc_column.html @@ -76,7 +76,7 @@ my %communigate_fields = ( Field Label Modifier - Required? + <% $manual_require ? 'Required?' : '' %> % $part_svc->set('svcpart' => $opt{'clone'}) if $opt{'clone'}; # for now % my $i = 0; @@ -211,7 +211,9 @@ my %communigate_fields = ( % } -% if (!$def->{'type'} || !(grep {$_ eq $def->{'type'}} ('checkbox','disabled'))) { +% if ($manual_require && +% (!$def->{'type'} || !(grep {$_ eq $def->{'type'}} ('checkbox','disabled'))) +% ) { required || $def->{'required'}) ? 'CHECKED' : '' %> <% $def->{'required'} ? 'DISABLED' : '' %> @@ -309,4 +311,5 @@ if ( $svcdb eq 'svc_acct' } my @defs = map { FS::part_svc->svc_table_fields($svcdb)->{$_} } @fields; +my $manual_require = FS::part_svc->svc_table_info($svcdb)->{'manual_require'}; diff --git a/httemplate/edit/elements/svc_Common.html b/httemplate/edit/elements/svc_Common.html index 97b630f76..a4e345e40 100644 --- a/httemplate/edit/elements/svc_Common.html +++ b/httemplate/edit/elements/svc_Common.html @@ -102,6 +102,9 @@ my $columndef = $part_svc->part_svc_column($f->{'field'}); my $flag = $columndef->columnflag; + $f->{'required'} = 1 + if $columndef->required; + if ( $flag eq 'F' ) { #fixed $f->{'value'} = $columndef->columnvalue; if (length($columndef->columnvalue)) { diff --git a/httemplate/edit/svc_acct.cgi b/httemplate/edit/svc_acct.cgi index 2c694a8fe..31678a991 100755 --- a/httemplate/edit/svc_acct.cgi +++ b/httemplate/edit/svc_acct.cgi @@ -30,8 +30,9 @@ <% $part_svc->svc %> - - <% mt('Username') |h %> +<% include('/elements/tr-td-label.html', + 'label' => mt('Username'), + 'required' => $part_svc->part_svc_column('username')->required ) %> % if ( $svcnum && $conf->exists('svc_acct-no_edit_username') ) { <% $svc_acct->username() %> @@ -43,9 +44,10 @@ %if ( $part_svc->part_svc_column('_password')->columnflag ne 'F' ) { - % #XXX eventually should require "Edit Password" ACL - <% mt('Password') |h %> +<% include('/elements/tr-td-label.html', + 'label' => mt('Password'), + 'required' => $part_svc->part_svc_column('_password')->required ) %> MAXLENGTH=<% $pmax %>> <& /elements/random_pass.html, 'clear_password' &> @@ -60,8 +62,9 @@ %if ( $conf->exists('security_phrase') % && $part_svc->part_svc_column('sec_phrase')->columnflag ne 'F' ) { - - <% mt('Security phrase') |h %> +<% include('/elements/tr-td-label.html', + 'label' => mt('Security phrase'), + 'required' => $part_svc->part_svc_column('sec_phrase')->required ) %> (<% mt('for forgotten passwords') |h %>) @@ -97,8 +100,9 @@ % ) % ); - - <% mt('Domain') |h %> +<% include('/elements/tr-td-label.html', + 'label' => mt('Domain'), + 'required' => $part_svc->part_svc_column('domsvc')->required ) %> % } else { - - <% mt('Access number') |h %> +<% include('/elements/tr-td-label.html', + 'label' => mt('Access number'), + 'required' => $part_svc->part_svc_column('popnum')->required ) %> <% FS::svc_acct_pop::popselector($popnum) %> % } @@ -156,6 +161,7 @@ 'curr_value' => $svc_acct->sectornum, #'part_svc' => $part_svc, #'cust_pkg' => $cust_pkg, + 'required' => $part_svc->part_svc_column('sectornum')->required, &> %} else { @@ -176,6 +182,9 @@ % % if ( length($svc_acct->$xid()) ) { +<% include('/elements/tr-td-label.html', + 'label' => uc($xid), + 'required' => $part_svc->part_svc_column($xid)->required ) %> <% uc($xid) %> <% $svc_acct->$xid() %> @@ -187,8 +196,9 @@ % } else { - - <% uc($xid) %> +<% include('/elements/tr-td-label.html', + 'label' => uc($xid), + 'required' => $part_svc->part_svc_column($xid)->required ) %> @@ -205,8 +215,9 @@ % } else { - - <% mt('Real Name') |h %> +<% include('/elements/tr-td-label.html', + 'label' => mt('Real Name'), + 'required' => $part_svc->part_svc_column('finger')->required ) %> @@ -223,8 +234,9 @@ % } else { - - <% mt('Home directory') |h %> +<% include('/elements/tr-td-label.html', + 'label' => mt('Home directory'), + 'required' => $part_svc->part_svc_column('dir')->required ) %> % } @@ -240,8 +252,9 @@ % } else { - - <% mt('Shell') |h %> +<% include('/elements/tr-td-label.html', + 'label' => mt('Shell'), + 'required' => $part_svc->part_svc_column('shell')->required ) %> % } else { - - <% mt('IP') |h %> +<% include('/elements/tr-td-label.html', + 'label' => mt('IP'), + 'required' => $part_svc->part_svc_column('slipip')->required ) %> % } @@ -324,8 +340,9 @@ % } - - <% mt('RADIUS groups') |h %> +<% include('/elements/tr-td-label.html', + 'label' => mt('RADIUS groups'), + 'required' => $part_svc->part_svc_column('usergroup')->required ) %> % if ( $part_svc_usergroup->columnflag eq 'F' ) { <% join('
', @groupnames) %> % } else { diff --git a/httemplate/edit/svc_acct/communigate.html b/httemplate/edit/svc_acct/communigate.html index 6370a54dc..370bfb0e7 100644 --- a/httemplate/edit/svc_acct/communigate.html +++ b/httemplate/edit/svc_acct/communigate.html @@ -47,8 +47,9 @@ % } else { % my $quota_label = $communigate ? 'Mail storage limit' : 'Quota'; - - <% $quota_label %> +<% include('/elements/tr-td-label.html', + 'label' => $quota_label, + 'required' => $part_svc->part_svc_column('quota')->required ) %> % } diff --git a/httemplate/edit/svc_broadband.cgi b/httemplate/edit/svc_broadband.cgi index 1b85460e6..81c694aa5 100644 --- a/httemplate/edit/svc_broadband.cgi +++ b/httemplate/edit/svc_broadband.cgi @@ -102,7 +102,16 @@ END my @fields = ( qw( description speed_down speed_up ), { field=>'sectornum', type=>'select-tower_sector', }, - { field=>'routernum', type=>'select-router_block_ip' }, + { field=>'routernum', type=>'select-router_block_ip', + include_opt_callback => sub { + my $svc_broadband = shift; + my $part_svc = $svc_broadband->part_svc; + return () unless $part_svc; #sanity check + my $col = $part_svc->part_svc_column('ip_addr'); + return () unless $col; #sanity check + return ('ip_addr_required' => $col->required); + }, + }, { field=>'mac_addr' , type=>'input-mac_addr' }, qw( latitude longitude altitude diff --git a/httemplate/elements/tr-input-date-field.html b/httemplate/elements/tr-input-date-field.html index ff9855184..f2a570b99 100644 --- a/httemplate/elements/tr-input-date-field.html +++ b/httemplate/elements/tr-input-date-field.html @@ -13,6 +13,7 @@ Example: 'usedatetime' => 1, #use DateTime->strftime to format the date # instead of Date::Format->time2str 'noinit' => 1, #first one on the page is enough + 'required' => 1, }, &> @@ -24,8 +25,9 @@ Example: % } - - <% $label %> +<% include('/elements/tr-td-label.html', + 'label' => $label, + 'required' => $required ) %> > @@ -48,7 +50,7 @@ Example: <%init> -my($name, $value, $label, $format, $usedatetime, $noinit, $colspan); +my($name, $value, $label, $format, $usedatetime, $noinit, $colspan, $required); if ( ref($_[0]) ) { my $opt = shift; $name = $opt->{'name'}; @@ -58,6 +60,7 @@ if ( ref($_[0]) ) { $usedatetime = $opt->{'usedatetime'}; $noinit = $opt->{'noinit'}; $colspan = $opt->{'colspan'} || 1; + $required = $opt->{'required'}; } else { ($name, $value, $label, $format, $usedatetime) = @_; $colspan = 1; diff --git a/httemplate/elements/tr-select-hardware_type.html b/httemplate/elements/tr-select-hardware_type.html index c3066417b..b51afc0a5 100644 --- a/httemplate/elements/tr-select-hardware_type.html +++ b/httemplate/elements/tr-select-hardware_type.html @@ -1,5 +1,6 @@ - - <% $opt{'label'} || 'Device type: ' %> +<% include('/elements/tr-td-label.html', + 'label' => $opt{'label'} || 'Device type: ', + 'required' => $opt{'required'} ) %> <% include('select-hardware_type.html', %opt) %> diff --git a/httemplate/elements/tr-select-router_block_ip.html b/httemplate/elements/tr-select-router_block_ip.html index 11f7c4831..ee135686c 100644 --- a/httemplate/elements/tr-select-router_block_ip.html +++ b/httemplate/elements/tr-select-router_block_ip.html @@ -30,7 +30,7 @@ function clearhint_ip_addr (what) { what.value = ''; } -<& /elements/tr-td-label.html, label => ($opt{'label'} || 'Router') &> +<& /elements/tr-td-label.html, label => ($opt{'label'} || 'Router'), required => $opt{'required'} &> <& /elements/select-tiered.html, prefix => 'router_', tiers => [ { @@ -56,9 +56,9 @@ function clearhint_ip_addr (what) { ] &> -<& /elements/tr-td-label.html, label => 'IP address' &> +<& /elements/tr-td-label.html, label => 'IP address', required => $opt{'ip_addr_required'} &> -% warn Dumper \%fixed; +% #warn Dumper \%fixed; % if ( exists $fixed{$ip_field} ) { <% $opt{'ip_addr'} || '' %> -- cgit v1.2.1 From 95606bc9db41352511c886773a311f2166cc6cf2 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Wed, 6 May 2015 16:43:45 -0700 Subject: display N most recent emails in customer view, #30164 --- httemplate/pref/pref-process.html | 1 + httemplate/pref/pref.html | 9 +++ httemplate/search/cust_msg.html | 2 +- httemplate/search/elements/search.html | 9 ++- httemplate/view/cust_main/notes.html | 11 +-- httemplate/view/cust_main/notes/email.html | 106 +++++++++++++++++++++++++++++ 6 files changed, 123 insertions(+), 15 deletions(-) create mode 100644 httemplate/view/cust_main/notes/email.html (limited to 'httemplate') diff --git a/httemplate/pref/pref-process.html b/httemplate/pref/pref-process.html index cd400ee3f..68f0f6e2f 100644 --- a/httemplate/pref/pref-process.html +++ b/httemplate/pref/pref-process.html @@ -55,6 +55,7 @@ unless ( $error ) { # if ($access_user) { enable_fuzzy_on_exact disable_html_editor disable_enter_submit_onetimecharge enable_mask_clipboard_hack dashboard_customers + customer_view_emails email_address snom-ip snom-username snom-password vonage-fromnumber vonage-username vonage-password diff --git a/httemplate/pref/pref.html b/httemplate/pref/pref.html index 5e722b043..ffc90fde8 100644 --- a/httemplate/pref/pref.html +++ b/httemplate/pref/pref.html @@ -151,6 +151,15 @@ Interface + + How many recent outbound emails to show in customer view + + + + + + +
diff --git a/httemplate/search/cust_msg.html b/httemplate/search/cust_msg.html index d5b865c3b..401f52ebb 100644 --- a/httemplate/search/cust_msg.html +++ b/httemplate/search/cust_msg.html @@ -47,7 +47,7 @@ ], 'html_init' => $html_init, 'really_disable_download' => 1, - @_ #why? + 'order_by' => '_date DESC', &> <%init> #hmm... diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html index 62a0e4786..64f3a665f 100644 --- a/httemplate/search/elements/search.html +++ b/httemplate/search/elements/search.html @@ -386,10 +386,7 @@ unless ( $type =~ /^(csv|xml|\w*.xls)$/) { } #order by override -my $order_by = ''; -#if ( $cgi->param('order_by') =~ /^([\w\, ]+)$/ ) { -# $order_by = $1; -#} +my $order_by = $opt{order_by} || ''; $order_by = $cgi->param('order_by') if $cgi->param('order_by'); # run the query @@ -415,6 +412,8 @@ if ( ref($opt{query}) ) { } } + $opt{query}->{'order_by'} .= " $limit"; + } elsif (ref($opt{query}) eq 'ARRAY') { @query = @{ $opt{query} }; } else { @@ -434,7 +433,7 @@ if ( ref($opt{query}) ) { } @query ], - 'order_by' => $opt{order_by}. " ". $limit, + #'order_by' => $opt{order_by}. " ". $limit, ) ]; } else { diff --git a/httemplate/view/cust_main/notes.html b/httemplate/view/cust_main/notes.html index 1cd6e0970..deba956ae 100755 --- a/httemplate/view/cust_main/notes.html +++ b/httemplate/view/cust_main/notes.html @@ -77,15 +77,8 @@ % if ( $curuser->access_right('View email logs') % and FS::cust_msg->count("custnum = $custnum")) {
-% if (!$cgi->param('order_by')) { -% my $order_by = '_date'; -% $order_by .= ' DESC' if $curuser->option('history_order') eq 'newest'; -% $cgi->param('order_by', $order_by); -% } -<& /search/cust_msg.html, - nohtmlheader => 1, - html_init => mt('Mail sent to this customer: '), -&> +<& notes/email.html, 'cust_main' => $cust_main &> +
% } <%init> diff --git a/httemplate/view/cust_main/notes/email.html b/httemplate/view/cust_main/notes/email.html new file mode 100644 index 000000000..da2c352b6 --- /dev/null +++ b/httemplate/view/cust_main/notes/email.html @@ -0,0 +1,106 @@ +% if ( scalar(@rows) ) { + +
+ <% mt('Email sent to this customer') %>
+% if ($maxrecords < $total) { +<% mt('Showing [_1] most recent of [quant,_2,total message]', $maxrecords, $total) %> + + (<% mt('view all') %>) + +% } else { +<% mt('[quant,_1,total message]', $total) %> +% } +
+<& /elements/table-grid.html &> + + <% mt('Date') %> + <% mt('Type') %> + <% mt('Destination') %> + <% mt('Subject') %> + + +% my $i = 0; +% foreach my $row (@rows) { +% my $onclick = $sub_popup_link->($row); +% my $link = qq!!; + + <% $link %> + <% $row->_date ? time2str('%Y-%m-%d %T', $row->_date) : '' %> + + <% $link %> + <% ucfirst($row->msgtype) || $row->msgname %> + + <% $link %> + <% join('
', split(/,\s*/, $row->env_to)) %> + + + <% $row->status %> + + + <% $row->error |h %> + + +% $i = 1 - $i; +% } + +
+% } +<%init> +my %opt = @_; + +my $curuser = $FS::CurrentUser::CurrentUser; +my $cust_main = $opt{'cust_main'} + or die "cust_main required"; +my $custnum = $cust_main->custnum; + +my $where = "WHERE cust_msg.custnum = $custnum"; +my $maxrecords = $curuser->option('customer_view_emails') || 10; + +my $order_by = '_date DESC'; + +my $query = { + 'table' => 'cust_msg', + 'select' => join(', ', + 'cust_msg.*', + 'msg_template.msgname', + ), + 'addl_from' => ' LEFT JOIN msg_template USING ( msgnum ) ', + 'hashref' => {}, + 'extra_sql' => $where, + 'order_by' => "ORDER BY $order_by LIMIT $maxrecords", +}; +my $count_query = "SELECT COUNT(*) FROM cust_msg $where"; + +my @rows = qsearch($query); +my $total = FS::Record->scalar_sql($count_query); + +my $sub_popup_link = sub { + my $custmsgnum = $_[0]->custmsgnum; + include('/elements/popup_link_onclick.html', + 'action' => $p. 'view/cust_msg.html?' . $custmsgnum, + 'actionlabel' => 'Message detail', + 'width' => 680, + 'height' => 550, + ); +}; + +my %color = ( + 'failed' => '#FF0000', + 'sent' => '#000000', + + 'invoice' => '#00CC00', + 'receipt' => '#0000CC', + 'admin' => '#CC0000', + '' => '#000000', +); +my $statuscolor = sub { $color{$_[0]->status} }; +my $typecolor = sub { $color{$_[0]->msgtype} }; + + -- cgit v1.2.1