1 <& /elements/header.html,
2 { title => 'Sales Report',
4 <SCRIPT TYPE="text/javascript" SRC="'. $p. 'elements/spectrum.js"></SCRIPT>
5 <LINK REL="stylesheet" HREF="'. $p. 'elements/spectrum.css" />',
9 <FORM ACTION="cust_bill_pkg.cgi" METHOD="POST">
11 <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
14 <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1"><% mt('Search options') |h %></FONT></TH>
17 <% include('/elements/tr-select-from_to.html' ) %>
20 <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="projection" VALUE="1"></TD>
21 <TD>Show projected data for future months</TD>
24 <SCRIPT TYPE="text/javascript">
26 function agent_changed(obj) {
28 if ( obj.value == '' ) { //breakdown, one color list per agent needed
29 document.getElementById('agent0-label').style.display = '';
30 % for ( 1 .. $#agents ) {
31 document.getElementById('agent<% $_ %>-colors').style.display = '';
33 } else { //aggregate, only one color list needed
34 document.getElementById('agent0-label').style.display = 'none';
35 % for ( 1 .. $#agents ) {
36 document.getElementById('agent<% $_ %>-colors').style.display = 'none';
40 enable_agent_totals(obj);
43 function enable_agent_totals(obj) {
44 %# enable it iff we are breaking down by agent AND something else
45 obj.form.agent_totals.disabled = !(
46 obj.form.agentnum.value == '' && (
47 obj.form.refnum.value == '' ||
48 document.getElementById('class_agg_break_breakdown').checked ||
49 obj.form.use_setup.value == 1 ||
50 obj.form.use_usage.value == 1
55 function class_mode_changed() {
56 var options = document.getElementsByName('class_mode');
58 for(var i=0; i < options.length; i++) {
59 if (options[i].checked) {
60 mode = options[i].value;
64 var div_pkg = document.getElementById('pkg_class');
65 var div_report = document.getElementById('report_class');
66 var span_exact = document.getElementById('exact_match');
68 div_pkg.style.display = '';
69 div_report.style.display = 'none';
70 span_exact.style.display = 'none';
71 } else if (mode == 'report') {
72 div_pkg.style.display = 'none';
73 div_report.style.display = '';
74 span_exact.style.display = '';
77 window.onload = class_mode_changed;
80 <& /elements/tr-select-agent.html,
81 'field' => 'agentnum',
84 'pre_options' => [ 'all' => 'all (aggregate)' ],
85 'empty_label' => 'all (breakdown)',
86 'onchange' => 'agent_changed',
89 <& /elements/tr-select-cust_class.html,
90 'field' => 'cust_classnum',
91 'label' => 'Customer class',
95 <& /elements/tr-select-part_referral.html,
97 'label' => 'Advertising source ',
99 'pre_options' => [ 'all' => 'all (aggregate)' ],
100 'empty_label' => 'all (breakdown)',
101 'onchange' => 'enable_agent_totals'
107 <INPUT TYPE="radio" NAME="class_mode" VALUE="pkg" onchange="class_mode_changed('pkg')" CHECKED>
108 <% emt('Package class') %>
110 <INPUT TYPE="radio" NAME="class_mode" VALUE="report" onchange="class_mode_changed('report')">
111 <% emt('Report class') %>
120 <& /elements/select-pkg_class.html,
121 'field' => 'classnum',
124 'pre_options' => [ #'all' => 'all (aggregate)',
125 # '' => 'all (breakdown)',
126 '0' => '(empty class)' ],
127 'disable_empty' => 1,
128 'onchange' => 'enable_agent_totals',
131 <DIV ID="report_class" STYLE="display: none">
132 <& /elements/select-table.html,
133 'field' => 'report_optionnum',
134 'table' => 'part_pkg_report_option',
135 'name_col' => 'name',
136 'value_col' => 'num',
139 'pre_options' => [ #'all' => 'all (aggregate)',
140 # '' => 'all (breakdown)',
141 '0' => '(empty class)' ],
142 'disable_empty' => 1,
143 'onchange' => 'enable_agent_totals',
149 <INPUT TYPE="radio" NAME="class_agg_break" ID="class_agg_break_aggregate" VALUE="aggregate" onchange="enable_agent_totals(this)" CHECKED>
150 <% emt('Aggregate') %>
152 <INPUT TYPE="radio" NAME="class_agg_break" ID="class_agg_break_breakdown" VALUE="breakdown" onchange="enable_agent_totals(this)">
153 <% emt('Breakdown') %>
155 <SPAN ID="exact_match" style="display:none">
156 <INPUT TYPE="radio" NAME="class_agg_break" ID="class_agg_break_exact" VALUE="exact" onchange="enable_agent_totals(this)">
157 <% emt('Exact match') %>
168 <TH CLASS="background" COLSPAN=2> </TH>
172 <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1"><% mt('Display options') |h %></FONT></TH>
177 <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="separate_0freq" VALUE="1"></TD>
178 <TD>Separate one-time vs. recurring sales</TD>
182 % foreach ( qw(Setup Usage) ) {
183 <& /elements/tr-select.html,
184 'label' => "$_ fees",
185 'field' => 'use_'.lc($_),
186 'options' => [ 0, 1, 2 ],
187 'labels' => { 0 => 'Combine', 1 => 'Separate', 2 => 'Do not show' },
188 'onchange'=> 'enable_agent_totals',
191 <& /elements/tr-select.html,
192 'label' => 'Discounts',
193 'field' => 'use_discount',
194 'options' => [ 1, 2 ],
195 'labels' => { 1 => 'Separate', 2 => 'Do not show' },
197 <& /elements/tr-select.html,
199 'field' => 'use_taxes',
200 'options' => [ 1, 2 ],
201 'labels' => { 1 => 'Separate', 2 => 'Do not show' },
205 <TD ALIGN="right">Colors</TD>
209 % #no particular long-term attachment to this, just trying to replicate
210 % # historical behavior so people's graphs don't change color suddenly in 3.x
212 % my $hue_increment = 125;
216 % foreach my $agent ( @agents ) {
217 <TR <% $anum ? 'STYLE="display:none"' : '' %>
218 ID="agent<%$anum%>-colors"
220 <TD <% $anum ? '' :'STYLE="display:none"' %>
221 ID="agent<%$anum%>-label"
223 <% $agent->agent |h %>
226 % my $col_scheme = Color::Scheme->new
227 % ->from_hue($hue) #->from_hex($agent->color)
228 % ->scheme('analogic')
232 % my @colors = ($col_scheme->colors)[ 0,4,8,1,5,9 ];#again some some random historical shite
234 % my $name = "agent$anum-color$cnum";
235 % push @names, $name;
237 <INPUT TYPE = "color"
246 % $hue += $hue_increment;
252 <SCRIPT TYPE="text/javascript">
253 $(document).ready(function() {
254 % foreach my $name (@names) {
255 $("#<% $name %>").spectrum({
256 clickoutFiresChange: true
263 <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="agent_totals" VALUE="1" DISABLED="1"></TD>
264 <TD>Show per-agent subtotals</TD>
268 <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="use_override" VALUE="1"></TD>
269 <TD>Separate sub-packages from parents</TD>
273 <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="average_per_cust_pkg" VALUE="1"></TD>
274 <TD>Average per customer package</TD>
278 <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="distribute" VALUE="1"></TD>
279 <TD>Distribute recurring fees over billing period</TD>
284 <BR><INPUT TYPE="submit" VALUE="Display">
287 <% include('/elements/footer.html') %>
291 unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
293 my @agents = $FS::CurrentUser::CurrentUser->agents;