1 <& /elements/header.html,
2 { title => 'Sales Report',
4 <SCRIPT TYPE="text/javascript" SRC="'. $p. 'elements/jquery.js"></SCRIPT>
5 <SCRIPT TYPE="text/javascript" SRC="'. $p. 'elements/jquery-migrate-3.0.1.min.js"></SCRIPT>
6 <SCRIPT TYPE="text/javascript" SRC="'. $p. 'elements/spectrum.js"></SCRIPT>
7 <LINK REL="stylesheet" HREF="'. $p. 'elements/spectrum.css" />',
11 <FORM ACTION="cust_bill_pkg.cgi" METHOD="POST">
13 <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
16 <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1"><% mt('Search options') |h %></FONT></TH>
19 <% include('/elements/tr-select-from_to.html' ) %>
22 <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="projection" VALUE="1"></TD>
23 <TD>Show projected data for future months</TD>
26 <SCRIPT TYPE="text/javascript">
28 function agent_changed(obj) {
30 if ( obj.value == '' ) { //breakdown, one color list per agent needed
31 document.getElementById('agent0-label').style.display = '';
32 % for ( 1 .. $#agents ) {
33 document.getElementById('agent<% $_ %>-colors').style.display = '';
35 } else { //aggregate, only one color list needed
36 document.getElementById('agent0-label').style.display = 'none';
37 % for ( 1 .. $#agents ) {
38 document.getElementById('agent<% $_ %>-colors').style.display = 'none';
42 enable_agent_totals(obj);
45 function enable_agent_totals(obj) {
46 %# enable it iff we are breaking down by agent AND something else
47 obj.form.agent_totals.disabled = !(
48 obj.form.agentnum.value == '' && (
49 obj.form.refnum.value == '' ||
50 document.getElementById('class_agg_break_breakdown').checked ||
51 obj.form.use_setup.value == 1 ||
52 obj.form.use_usage.value == 1
57 function class_mode_changed() {
58 var options = document.getElementsByName('class_mode');
60 for(var i=0; i < options.length; i++) {
61 if (options[i].checked) {
62 mode = options[i].value;
66 var div_pkg = document.getElementById('pkg_class');
67 var div_report = document.getElementById('report_class');
68 var span_exact = document.getElementById('exact_match');
70 div_pkg.style.display = '';
71 div_report.style.display = 'none';
72 span_exact.style.display = 'none';
73 } else if (mode == 'report') {
74 div_pkg.style.display = 'none';
75 div_report.style.display = '';
76 span_exact.style.display = '';
79 window.onload = class_mode_changed;
82 <& /elements/tr-select-agent.html,
83 'field' => 'agentnum',
86 'pre_options' => [ 'all' => 'all (aggregate)' ],
87 'empty_label' => 'all (breakdown)',
88 'onchange' => 'agent_changed',
91 <& /elements/tr-select-cust_class.html,
92 'field' => 'cust_classnum',
93 'label' => 'Customer class',
97 <& /elements/tr-select-part_referral.html,
99 'label' => 'Advertising source ',
100 'disable_empty' => 0,
101 'pre_options' => [ 'all' => 'all (aggregate)' ],
102 'empty_label' => 'all (breakdown)',
103 'onchange' => 'enable_agent_totals'
109 <INPUT TYPE="radio" NAME="class_mode" VALUE="pkg" onchange="class_mode_changed('pkg')" CHECKED>
110 <% emt('Package class') %>
112 <INPUT TYPE="radio" NAME="class_mode" VALUE="report" onchange="class_mode_changed('report')">
113 <% emt('Report class') %>
122 <& /elements/select-pkg_class.html,
123 'field' => 'classnum',
126 'pre_options' => [ #'all' => 'all (aggregate)',
127 # '' => 'all (breakdown)',
128 '0' => '(empty class)' ],
129 'disable_empty' => 1,
130 'onchange' => 'enable_agent_totals',
133 <DIV ID="report_class" STYLE="display: none">
134 <& /elements/select-table.html,
135 'field' => 'report_optionnum',
136 'table' => 'part_pkg_report_option',
137 'name_col' => 'name',
138 'value_col' => 'num',
141 'pre_options' => [ #'all' => 'all (aggregate)',
142 # '' => 'all (breakdown)',
143 '0' => '(empty class)' ],
144 'disable_empty' => 1,
145 'onchange' => 'enable_agent_totals',
151 <INPUT TYPE="radio" NAME="class_agg_break" ID="class_agg_break_aggregate" VALUE="aggregate" onchange="enable_agent_totals(this)" CHECKED>
152 <% emt('Aggregate') %>
154 <INPUT TYPE="radio" NAME="class_agg_break" ID="class_agg_break_breakdown" VALUE="breakdown" onchange="enable_agent_totals(this)">
155 <% emt('Breakdown') %>
157 <SPAN ID="exact_match" style="display:none">
158 <INPUT TYPE="radio" NAME="class_agg_break" ID="class_agg_break_exact" VALUE="exact" onchange="enable_agent_totals(this)">
159 <% emt('Exact match') %>
170 <TH CLASS="background" COLSPAN=2> </TH>
174 <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1"><% mt('Display options') |h %></FONT></TH>
179 <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="separate_0freq" VALUE="1"></TD>
180 <TD>Separate one-time vs. recurring sales</TD>
184 % foreach ( qw(Setup Usage) ) {
185 <& /elements/tr-select.html,
186 'label' => "$_ fees",
187 'field' => 'use_'.lc($_),
188 'options' => [ 0, 1, 2 ],
189 'labels' => { 0 => 'Combine', 1 => 'Separate', 2 => 'Do not show' },
190 'onchange'=> 'enable_agent_totals',
193 <& /elements/tr-select.html,
194 'label' => 'Discounts',
195 'field' => 'use_discount',
196 'options' => [ 1, 2 ],
197 'labels' => { 1 => 'Separate', 2 => 'Do not show' },
199 <& /elements/tr-select.html,
201 'field' => 'use_taxes',
202 'options' => [ 1, 2 ],
203 'labels' => { 1 => 'Separate', 2 => 'Do not show' },
207 <TD ALIGN="right">Colors</TD>
211 % #no particular long-term attachment to this, just trying to replicate
212 % # historical behavior so people's graphs don't change color suddenly in 3.x
214 % my $hue_increment = 125;
218 % foreach my $agent ( @agents ) {
219 <TR <% $anum ? 'STYLE="display:none"' : '' %>
220 ID="agent<%$anum%>-colors"
222 <TD <% $anum ? '' :'STYLE="display:none"' %>
223 ID="agent<%$anum%>-label"
225 <% $agent->agent |h %>
228 % my $col_scheme = Color::Scheme->new
229 % ->from_hue($hue) #->from_hex($agent->color)
230 % ->scheme('analogic')
234 % my @colors = ($col_scheme->colors)[ 0,4,8,1,5,9 ];#again some some random historical shite
236 % my $name = "agent$anum-color$cnum";
237 % push @names, $name;
239 <INPUT TYPE = "color"
248 % $hue += $hue_increment;
254 <SCRIPT TYPE="text/javascript">
255 $(document).ready(function() {
256 % foreach my $name (@names) {
257 $("#<% $name %>").spectrum({
258 clickoutFiresChange: true
265 <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="agent_totals" VALUE="1" DISABLED="1"></TD>
266 <TD>Show per-agent subtotals</TD>
270 <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="use_override" VALUE="1"></TD>
271 <TD>Separate sub-packages from parents</TD>
275 <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="average_per_cust_pkg" VALUE="1"></TD>
276 <TD>Average per customer package</TD>
280 <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="distribute" VALUE="1"></TD>
281 <TD>Distribute recurring fees over billing period</TD>
286 <BR><INPUT TYPE="submit" VALUE="Display">
289 <% include('/elements/footer.html') %>
293 unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
295 my @agents = $FS::CurrentUser::CurrentUser->agents;