summaryrefslogtreecommitdiff
path: root/httemplate/graph/report_cust_bill_pkg.html
blob: 76d3a6ca330312a7cb24ca27459efa9a79114a51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
<& /elements/header.html,
     { title => 'Sales Report',
       head  => '
  <SCRIPT TYPE="text/javascript"  SRC="'. $p. 'elements/jquery.js"></SCRIPT>
  <SCRIPT TYPE="text/javascript"  SRC="'. $p. 'elements/spectrum.js"></SCRIPT>
  <LINK   REL="stylesheet"       HREF="'. $p. 'elements/spectrum.css" />',
     }
&>

<FORM ACTION="cust_bill_pkg.cgi" METHOD="POST">

<TABLE BGCOLOR="#cccccc" CELLSPACING=0>

<TR>
  <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1"><% mt('Search options') |h %></FONT></TH>
</TR>

<% include('/elements/tr-select-from_to.html' ) %>

<TR>
  <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="projection" VALUE="1"></TD>
  <TD>Show projected data for future months</TD>
</TR>

<SCRIPT TYPE="text/javascript">

function agent_changed(obj) {

  if ( obj.value == '' ) { //breakdown, one color list per agent needed
    document.getElementById('agent0-label').style.display = '';
%   for ( 1 .. $#agents ) {
      document.getElementById('agent<% $_ %>-colors').style.display = '';
%   }
  } else { //aggregate, only one color list needed
    document.getElementById('agent0-label').style.display = 'none';
%   for ( 1 .. $#agents ) {
      document.getElementById('agent<% $_ %>-colors').style.display = 'none';
%   }
  } 

  enable_agent_totals(obj);
}

function enable_agent_totals(obj) {
%# enable it iff we are breaking down by agent AND something else
  obj.form.agent_totals.disabled = !(
    obj.form.agentnum.value == '' && (
      obj.form.refnum.value == ''   ||
      document.getElementById('class_agg_break_breakdown').checked ||
      obj.form.use_setup.value == 1 ||
      obj.form.use_usage.value == 1
    )
  );
}

function class_mode_changed() {
  var options = document.getElementsByName('class_mode');
  var mode;
  for(var i=0; i < options.length; i++) {
    if (options[i].checked) {
      mode = options[i].value;
    }
  }
    
  var div_pkg = document.getElementById('pkg_class');
  var div_report = document.getElementById('report_class');
  var span_exact = document.getElementById('exact_match');
  if (mode == 'pkg') {
    div_pkg.style.display = '';
    div_report.style.display = 'none';
    span_exact.style.display = 'none';
  } else if (mode == 'report') {
    div_pkg.style.display = 'none';
    div_report.style.display = '';
    span_exact.style.display = '';
  }
}
window.onload = class_mode_changed;
</SCRIPT>

<& /elements/tr-select-agent.html,
  'field'         => 'agentnum',
  'label'         => 'Agent ',
  'disable_empty' => 0,
  'pre_options'   => [ 'all' => 'all (aggregate)' ],
  'empty_label'   => 'all (breakdown)',
  'onchange'      => 'agent_changed',
&>

<& /elements/tr-select-cust_class.html,
  'field'         => 'cust_classnum',
  'label'         => 'Customer class',
  'multiple'      => 1,
&>

<& /elements/tr-select-part_referral.html,
  'field'         => 'refnum',
  'label'         => 'Advertising source ',
  'disable_empty' => 0,
  'pre_options'   => [ 'all' => 'all (aggregate)' ],
  'empty_label'   => 'all (breakdown)',
  'onchange'      => 'enable_agent_totals'
&>

<TR>

  <TD>
    <INPUT TYPE="radio" NAME="class_mode" VALUE="pkg" onchange="class_mode_changed('pkg')" CHECKED>
    <% emt('Package class') %>
    <BR>
    <INPUT TYPE="radio" NAME="class_mode" VALUE="report" onchange="class_mode_changed('report')">
    <% emt('Report class') %>
  </TD>

  <TD>
    <TABLE>
      <TR>

        <TD>
          <DIV ID="pkg_class">
          <& /elements/select-pkg_class.html,
            'field'         => 'classnum',
            'multiple'      => 1,
            'all_selected'  => 1,
            'pre_options'   => [ #'all'  => 'all (aggregate)',
                                #   ''  => 'all (breakdown)',
                                  '0'  => '(empty class)' ],
            'disable_empty' => 1,
            'onchange'      => 'enable_agent_totals',
          &>
          </DIV>
          <DIV ID="report_class" STYLE="display: none">
          <& /elements/select-table.html,
            'field'         => 'report_optionnum',
            'table'         => 'part_pkg_report_option',
            'name_col'      => 'name',
            'value_col'     => 'num',
            'multiple'      => 1,
            'all_selected'  => 1,
            'pre_options'   => [ #'all' => 'all (aggregate)',
                               #   '' => 'all (breakdown)', 
                                 '0'  => '(empty class)' ],
            'disable_empty' => 1,
            'onchange'      => 'enable_agent_totals',
          &>
          </DIV>
        </TD>

        <TD>
          <INPUT TYPE="radio" NAME="class_agg_break" ID="class_agg_break_aggregate" VALUE="aggregate" onchange="enable_agent_totals(this)" CHECKED>
          <% emt('Aggregate') %>
          <BR>
          <INPUT TYPE="radio" NAME="class_agg_break" ID="class_agg_break_breakdown" VALUE="breakdown" onchange="enable_agent_totals(this)">
          <% emt('Breakdown') %>
          <BR>
          <SPAN ID="exact_match" style="display:none">
          <INPUT TYPE="radio" NAME="class_agg_break" ID="class_agg_break_exact" VALUE="exact" onchange="enable_agent_totals(this)">
          <% emt('Exact match') %>
          </SPAN>
        </TD>

      </TR>
    </TABLE>
  </TD>

</TR>


<TR>
  <TH CLASS="background" COLSPAN=2>&nbsp;</TH>
</TR>

<TR>
  <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1"><% mt('Display options') |h %></FONT></TH>
</TR>

<!--
<TR>
  <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="separate_0freq" VALUE="1"></TD>
  <TD>Separate one-time vs. recurring sales</TD>
</TR>
-->

% foreach ( qw(Setup Usage) ) {
<& /elements/tr-select.html,
    'label'   => "$_ fees",
    'field'   => 'use_'.lc($_),
    'options' => [ 0, 1, 2 ],
    'labels'  => { 0 => 'Combine', 1 => 'Separate', 2 => 'Do not show' },
    'onchange'=> 'enable_agent_totals',
&>
% }

<TR>
  <TD ALIGN="right">Colors</TD>
  <TD>
%   my @names = ();
%
%   #no particular long-term attachment to this, just trying to replicate
%   # historical behavior so people's graphs don't change color suddenly in 3.x
%   my $hue = 0;
%   my $hue_increment = 125;

      <TABLE>
%       my $anum = 0;
%       foreach my $agent ( @agents ) {
          <TR <% $anum ? 'STYLE="display:none"' : '' %>
              ID="agent<%$anum%>-colors"
          >
            <TD <% $anum ? '' :'STYLE="display:none"' %>
                ID="agent<%$anum%>-label"
            >
              <% $agent->agent |h %>
            </TD>
            <TD>
%            my $col_scheme = Color::Scheme->new
%                               ->from_hue($hue) #->from_hex($agent->color)
%                               ->scheme('analogic')
%                             ;
%
%            my $cnum = 0;
%            my @colors = ($col_scheme->colors)[ 0,4,8,1,5,9 ];#again some some random historical shite
%            for (@colors) {
%              my $name = "agent$anum-color$cnum";
%              push @names, $name;
%              $cnum++;
               <INPUT TYPE  = "color"
                      NAME  = "<% $name %>"
                      ID    = "<% $name %>"
                      VALUE = "#<%$_%>"
               >
%            }
            </TD>
          </TR>
%         $anum++;
%         $hue += $hue_increment;
%       }
     </TABLE>
  </TD>
</TR>

<SCRIPT TYPE="text/javascript">
  $(document).ready(function() {
%   foreach my $name (@names) {
      $("#<% $name %>").spectrum({
        clickoutFiresChange: true
      });
%   }
  });
</SCRIPT>

<TR>
  <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="agent_totals" VALUE="1" DISABLED="1"></TD>
  <TD>Show per-agent subtotals</TD>
</TR>

<TR>
  <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="use_override" VALUE="1"></TD>
  <TD>Separate sub-packages from parents</TD>
</TR>

<TR>
  <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="average_per_cust_pkg" VALUE="1"></TD>
  <TD>Average per customer package</TD>
</TR>

<TR>
  <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="distribute" VALUE="1"></TD>
  <TD>Distribute recurring fees over billing period</TD>
</TR>

</TABLE>

<BR><INPUT TYPE="submit" VALUE="Display">
</FORM>

<% include('/elements/footer.html') %>
<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');

my @agents = $FS::CurrentUser::CurrentUser->agents;

</%init>