From 76b22e66bf8e615def0a24cd8cda23c3949eae70 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Tue, 26 Jul 2016 15:06:36 -0700 Subject: prevent reload loops on process pages, #71249 --- httemplate/elements/header-full.html | 2 +- httemplate/elements/header-popup.html | 1 + httemplate/elements/topreload.js | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 httemplate/elements/topreload.js (limited to 'httemplate/elements') diff --git a/httemplate/elements/header-full.html b/httemplate/elements/header-full.html index 07595a539..850eaed8c 100644 --- a/httemplate/elements/header-full.html +++ b/httemplate/elements/header-full.html @@ -53,7 +53,7 @@ Example: % } <% include('init_overlib.html') |n %> <% include('rs_init_object.html') |n %> - + <% $head |n %> %# announce our base path, and the Mason comp path of this page diff --git a/httemplate/elements/header-popup.html b/httemplate/elements/header-popup.html index 6c0f80b37..839a63676 100644 --- a/httemplate/elements/header-popup.html +++ b/httemplate/elements/header-popup.html @@ -34,6 +34,7 @@ Example: % } % } + <% $head |n %> > diff --git a/httemplate/elements/topreload.js b/httemplate/elements/topreload.js new file mode 100644 index 000000000..a66703b29 --- /dev/null +++ b/httemplate/elements/topreload.js @@ -0,0 +1,5 @@ +window.topreload = function() { + if (window != window.top) { + window.top.location.reload(); + } +} -- cgit v1.2.1 From 4f3d9e2ef5ce5305363ae426b87ed2b873b355d8 Mon Sep 17 00:00:00 2001 From: Jonathan Prykop Date: Tue, 2 Aug 2016 00:07:01 -0500 Subject: RT#27396: Why does it take so long for the New/Edit billing event pages to load? [stable checkpoint, work in progress] --- httemplate/elements/selectlayersx.html | 248 ++++++++++++++++++++++++++++++ httemplate/elements/tr-selectlayersx.html | 25 +++ 2 files changed, 273 insertions(+) create mode 100644 httemplate/elements/selectlayersx.html create mode 100644 httemplate/elements/tr-selectlayersx.html (limited to 'httemplate/elements') diff --git a/httemplate/elements/selectlayersx.html b/httemplate/elements/selectlayersx.html new file mode 100644 index 000000000..41f3cb0b7 --- /dev/null +++ b/httemplate/elements/selectlayersx.html @@ -0,0 +1,248 @@ +<%doc> + +Example: + + include( '/elements/selectlayers.html', + 'field' => $key, # SELECT element NAME (passed as form field) + # also used as ID and a unique key for layers and + # functions + 'curr_value' => $selected_layer, + 'options' => [ 'option1', 'option2' ], + 'labels' => { 'option1' => 'Option 1 Label', + 'option2' => 'Option 2 Label', + }, + + #XXX put this handling it its own selectlayers-fields.html element? + 'layer_prefix' => 'prefix_', #optional prefix for fieldnames + 'layer_fields' => { 'layer' => [ 'fieldname', + { label => 'fieldname2', + type => 'text', #implemented: + # text, money, fixed, + # hidden, checkbox, + # checkbox-multiple, + # select, select-agent, + # select-pkg_class, + # select-part_referral, + # select-taxclass, + # select-table, + #XXX tbd: + # more? + }, + ... + ], + 'layer2' => [ 'l2fieldname', + ... + ], + }, + + #current values for layer fields above + 'layer_values' => { 'layer' => { 'fieldname' => 'current_value', + 'fieldname2' => 'field2value', + ... + }, + 'layer2' => { 'l2fieldname' => 'l2value', + ... + }, + ... + }, + + #or manual control, instead of layer_fields and layer_values above + #called with args: my( $layer, $layer_fields, $layer_values, $layer_prefix ) + 'layer_callback' => + + 'html_between => '', #optional HTML displayed between the SELECT and the + #layers, scalar or coderef ('field' passed as a param) + 'onchange' => '', #javascript code run when the SELECT changes + # ("what" is the element) + 'js_only' => 0, #set true to return only the JS portions + 'html_only' => 0, #set true to return only the HTML portions + 'select_only' => 0, #set true to return only the + +% foreach my $option ( keys %$options ) { + + + +% } + + + +% } +% unless ( grep $opt{$_}, qw(js_only select_only layers_only) ) { + +<% ref($between) ? &{$between}($key) : $between %> + +% } +% +% unless ( grep $opt{$_}, qw(js_only select_only) ) { + +% foreach my $layer ( @layers ) { +% my $selected_layer; +% $selected_layer = $selected; + +
+ + <% &{$layer_callback}($layer, $layer_fields, $layer_values, $layer_prefix) %> + +
+ +% } + +% } +<%once> + +my $conf = new FS::Conf; +my $money_char = $conf->config('money_char') || '$'; +my $date_noinit = 0; + + +<%shared> + +my $selectlayersx_init = 0; + + +<%init> + +my %opt = @_; + +#use Data::Dumper; +#warn Dumper(%opt); + +my $key = $opt{field}; # || 'generate_one' #? + +tie my %options, 'Tie::IxHash', + map { $_ => $opt{'labels'}->{$_} } + @{ $opt{'options'} }; #just arrayref for now + +my $between = exists($opt{html_between}) ? $opt{html_between} : ''; +my $options = \%options; + +my @layers = (); +@layers = keys %options; + +my $selected = exists($opt{curr_value}) ? $opt{curr_value} : ''; + +#XXX eek. also eek $layer_fields in the layer_callback() call... +my $layer_fields = $opt{layer_fields}; +my $layer_values = $opt{layer_values}; +my $layer_prefix = $opt{layer_prefix}; + +my $layer_callback = $opt{layer_callback} || \&layer_callback; + +sub layer_callback { + my( $layer, $layer_fields, $layer_values, $layer_prefix ) = @_; + + return '' unless $layer && exists $layer_fields->{$layer}; + tie my %fields, 'Tie::IxHash', @{ $layer_fields->{$layer} }; + + #XXX this should become an element itself... (false laziness w/edit.html) + # but at least all the elements inside are the shared mason elements now + + return '' unless keys %fields; + my $html = ""; + + foreach my $field ( keys %fields ) { + + my $lf = ref($fields{$field}) + ? $fields{$field} + : { 'label'=>$fields{$field} }; + + my $value = $layer_values->{$layer}{$field}; + + my $type = $lf->{type} || 'text'; + + my $include = $type; + + if ( $include eq 'date' ) { + # several important differences from other tr-* + $html .= include( '/elements/tr-input-date-field.html', + { + 'name' => "$layer_prefix$field", + 'value' => $value, + 'label' => $lf->{label}, + 'format'=> $lf->{format}, + 'noinit'=> $date_noinit, + } + ); + $date_noinit = 1; + } + else { + $include = "input-$include" if $include =~ /^(text|money|percentage)$/; + $include = "tr-$include" unless $include eq 'hidden'; + $html .= include( "/elements/$include.html", + %$lf, + 'field' => "$layer_prefix$field", + 'id' => "$layer_prefix$field", #separate? + #don't want field0_label0...? + 'label_id' => $layer_prefix.$field."_label", + + 'value' => ( $lf->{'value'} || $value ), #hmm. + 'curr_value' => $value, + ); + } + } #foreach $field + $html .= '
'; + return $html; +} + + diff --git a/httemplate/elements/tr-selectlayersx.html b/httemplate/elements/tr-selectlayersx.html new file mode 100644 index 000000000..ca7a36079 --- /dev/null +++ b/httemplate/elements/tr-selectlayersx.html @@ -0,0 +1,25 @@ +% unless ( $opt{js_only} ) { + + <% include('tr-td-label.html', @_ ) %> + + > + +% } + + <% include('selectlayersx.html', @_ ) %> + +% unless ( $opt{js_only} ) { + + + + + +% } + +<%init> + +my %opt = @_; + +my $style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : ''; + + -- cgit v1.2.1 From 34c878349988d97957f1d53427896a4d70afb392 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Tue, 2 Aug 2016 11:41:51 -0700 Subject: agent commission schedules for consecutive invoices, #71217 --- httemplate/elements/commission_rate.html | 68 +++++++++++++++++++++++++++++++ httemplate/elements/menu.html | 5 ++- httemplate/elements/tr-select-reason.html | 3 +- 3 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 httemplate/elements/commission_rate.html (limited to 'httemplate/elements') diff --git a/httemplate/elements/commission_rate.html b/httemplate/elements/commission_rate.html new file mode 100644 index 000000000..071ebb1e3 --- /dev/null +++ b/httemplate/elements/commission_rate.html @@ -0,0 +1,68 @@ +% unless ( $opt{'js_only'} ) { + + + + <& select.html, + field => "${name}_cycle", + options => [ '', 1 .. 12 ], + option_labels => { + '' => '', + 1 => '1st', + 2 => '2nd', + 3 => '3rd', + map { $_ => $_.'th' } 4 .. 12 + }, + onchange => $onchange, + curr_value => $commission_rate->get("cycle"), + &> + <% $money_char %> + <& input-text.html, + field => "${name}_amount", + size => 8, + curr_value => $commission_rate->get("amount") + || '0.00', + 'text-align' => 'right' + &> + + + <& input-text.html, + field => "${name}_percent", + size => 8, + curr_value => $commission_rate->get("percent") + || '0', + 'text-align' => 'right' + &>% +% } +<%init> + +my( %opt ) = @_; + +my $conf = new FS::Conf; +my $money_char = $conf->config('money_char') || '$'; + +my $name = $opt{'field'} || 'commissionratenum'; +my $id = $opt{'id'} || 'commissionratenum'; + +my $curr_value = $opt{'curr_value'} || $opt{'value'}; + +my $onchange = ''; +if ( $opt{'onchange'} ) { + $onchange = $opt{'onchange'}; + $onchange .= '(this)' unless $onchange =~ /\(\w*\);?$/; + $onchange =~ s/\(what\);/\(this\);/g; #ugh, terrible hack. all onchange + #callbacks should act the same + $onchange = 'onChange="'. $onchange. '"'; +} + +my $commission_rate; +if ( $curr_value ) { + $commission_rate = qsearchs('commission_rate', { 'commissionratenum' => $curr_value } ); +} else { + $commission_rate = new FS::commission_rate {}; +} + +foreach my $field (qw( amount percent cycle)) { + my $value = $cgi->param("${name}_${field}"); + $commission_rate->set($field, $value) if $value; +} + + diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html index 0f98bc960..88c1df3c8 100644 --- a/httemplate/elements/menu.html +++ b/httemplate/elements/menu.html @@ -672,7 +672,10 @@ $config_cust{'Note classes'} = [ $fsurl.'browse/cust_note_class.html', 'Note cla tie my %config_agent, 'Tie::IxHash', 'Agent types' => [ $fsurl.'browse/agent_type.cgi', 'Agent types define groups of package definitions that you can then assign to particular agents' ], 'Agents' => [ $fsurl.'browse/agent.cgi', 'Agents are resellers of your service. Agents may be limited to a subset of your full offerings (via their type)' ], - 'Agent payment gateways' => [ $fsurl.'browse/payment_gateway.html', 'Credit card and electronic check processors for agent overrides' ]; + 'Agent payment gateways' => [ $fsurl.'browse/payment_gateway.html', 'Credit card and electronic check processors for agent overrides' ], + 'separator' => '', + 'Commission schedules' => [ $fsurl.'browse/commission_schedule.html', + 'Commission schedules for consecutive billing periods' ], ; tie my %config_sales, 'Tie::IxHash', diff --git a/httemplate/elements/tr-select-reason.html b/httemplate/elements/tr-select-reason.html index 97466f175..9a430222c 100755 --- a/httemplate/elements/tr-select-reason.html +++ b/httemplate/elements/tr-select-reason.html @@ -188,9 +188,8 @@ my $class = $opt{'reason_class'}; my $init_reason; if ( $opt{'cgi'} ) { $init_reason = $opt{'cgi'}->param($name); -} else { - $init_reason = $opt{'curr_value'}; } +$init_reason ||= $opt{'curr_value'}; my $id = $opt{'id'} || $name; $id =~ s/\./_/g; # for edit/part_event -- cgit v1.2.1