RT# 81706 Remove redundant loads of jquery.js
[freeside.git] / httemplate / graph / report_cust_bill_pkg.html
1 <& /elements/header.html,
2      { title => 'Sales Report',
3        head  => '
4   <SCRIPT TYPE="text/javascript"  SRC="'. $p. 'elements/spectrum.js"></SCRIPT>
5   <LINK   REL="stylesheet"       HREF="'. $p. 'elements/spectrum.css" />',
6      }
7 &>
8
9 <FORM ACTION="cust_bill_pkg.cgi" METHOD="POST">
10
11 <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
12
13 <TR>
14   <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1"><% mt('Search options') |h %></FONT></TH>
15 </TR>
16
17 <% include('/elements/tr-select-from_to.html' ) %>
18
19 <TR>
20   <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="projection" VALUE="1"></TD>
21   <TD>Show projected data for future months</TD>
22 </TR>
23
24 <SCRIPT TYPE="text/javascript">
25
26 function agent_changed(obj) {
27
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 = '';
32 %   }
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';
37 %   }
38   } 
39
40   enable_agent_totals(obj);
41 }
42
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
51     )
52   );
53 }
54
55 function class_mode_changed() {
56   var options = document.getElementsByName('class_mode');
57   var mode;
58   for(var i=0; i < options.length; i++) {
59     if (options[i].checked) {
60       mode = options[i].value;
61     }
62   }
63     
64   var div_pkg = document.getElementById('pkg_class');
65   var div_report = document.getElementById('report_class');
66   var span_exact = document.getElementById('exact_match');
67   if (mode == 'pkg') {
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 = '';
75   }
76 }
77 window.onload = class_mode_changed;
78 </SCRIPT>
79
80 <& /elements/tr-select-agent.html,
81   'field'         => 'agentnum',
82   'label'         => 'Agent ',
83   'disable_empty' => 0,
84   'pre_options'   => [ 'all' => 'all (aggregate)' ],
85   'empty_label'   => 'all (breakdown)',
86   'onchange'      => 'agent_changed',
87 &>
88
89 <& /elements/tr-select-cust_class.html,
90   'field'         => 'cust_classnum',
91   'label'         => 'Customer class',
92   'multiple'      => 1,
93 &>
94
95 <& /elements/tr-select-part_referral.html,
96   'field'         => 'refnum',
97   'label'         => 'Advertising source ',
98   'disable_empty' => 0,
99   'pre_options'   => [ 'all' => 'all (aggregate)' ],
100   'empty_label'   => 'all (breakdown)',
101   'onchange'      => 'enable_agent_totals'
102 &>
103
104 <TR>
105
106   <TD>
107     <INPUT TYPE="radio" NAME="class_mode" VALUE="pkg" onchange="class_mode_changed('pkg')" CHECKED>
108     <% emt('Package class') %>
109     <BR>
110     <INPUT TYPE="radio" NAME="class_mode" VALUE="report" onchange="class_mode_changed('report')">
111     <% emt('Report class') %>
112   </TD>
113
114   <TD>
115     <TABLE>
116       <TR>
117
118         <TD>
119           <DIV ID="pkg_class">
120           <& /elements/select-pkg_class.html,
121             'field'         => 'classnum',
122             'multiple'      => 1,
123             'all_selected'  => 1,
124             'pre_options'   => [ #'all'  => 'all (aggregate)',
125                                 #   ''  => 'all (breakdown)',
126                                   '0'  => '(empty class)' ],
127             'disable_empty' => 1,
128             'onchange'      => 'enable_agent_totals',
129           &>
130           </DIV>
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',
137             'multiple'      => 1,
138             'all_selected'  => 1,
139             'pre_options'   => [ #'all' => 'all (aggregate)',
140                                #   '' => 'all (breakdown)', 
141                                  '0'  => '(empty class)' ],
142             'disable_empty' => 1,
143             'onchange'      => 'enable_agent_totals',
144           &>
145           </DIV>
146         </TD>
147
148         <TD>
149           <INPUT TYPE="radio" NAME="class_agg_break" ID="class_agg_break_aggregate" VALUE="aggregate" onchange="enable_agent_totals(this)" CHECKED>
150           <% emt('Aggregate') %>
151           <BR>
152           <INPUT TYPE="radio" NAME="class_agg_break" ID="class_agg_break_breakdown" VALUE="breakdown" onchange="enable_agent_totals(this)">
153           <% emt('Breakdown') %>
154           <BR>
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') %>
158           </SPAN>
159         </TD>
160
161       </TR>
162     </TABLE>
163   </TD>
164
165 </TR>
166
167 <TR>
168   <TH CLASS="background" COLSPAN=2>&nbsp;</TH>
169 </TR>
170
171 <TR>
172   <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1"><% mt('Display options') |h %></FONT></TH>
173 </TR>
174
175 <!--
176 <TR>
177   <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="separate_0freq" VALUE="1"></TD>
178   <TD>Separate one-time vs. recurring sales</TD>
179 </TR>
180 -->
181
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',
189 &>
190 % }
191 <& /elements/tr-select.html,
192     'label'   => 'Discounts',
193     'field'   => 'use_discount',
194     'options' => [ 1, 2 ],
195     'labels'  => { 1 => 'Separate', 2 => 'Do not show' },
196 &>
197 <& /elements/tr-select.html,
198     'label'   => 'Taxes',
199     'field'   => 'use_taxes',
200     'options' => [ 1, 2 ],
201     'labels'  => { 1 => 'Separate', 2 => 'Do not show' },
202 &>
203
204 <TR>
205   <TD ALIGN="right">Colors</TD>
206   <TD>
207 %   my @names = ();
208 %
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
211 %   my $hue = 0;
212 %   my $hue_increment = 125;
213
214       <TABLE>
215 %       my $anum = 0;
216 %       foreach my $agent ( @agents ) {
217           <TR <% $anum ? 'STYLE="display:none"' : '' %>
218               ID="agent<%$anum%>-colors"
219           >
220             <TD <% $anum ? '' :'STYLE="display:none"' %>
221                 ID="agent<%$anum%>-label"
222             >
223               <% $agent->agent |h %>
224             </TD>
225             <TD>
226 %            my $col_scheme = Color::Scheme->new
227 %                               ->from_hue($hue) #->from_hex($agent->color)
228 %                               ->scheme('analogic')
229 %                             ;
230 %
231 %            my $cnum = 0;
232 %            my @colors = ($col_scheme->colors)[ 0,4,8,1,5,9 ];#again some some random historical shite
233 %            for (@colors) {
234 %              my $name = "agent$anum-color$cnum";
235 %              push @names, $name;
236 %              $cnum++;
237                <INPUT TYPE  = "color"
238                       NAME  = "<% $name %>"
239                       ID    = "<% $name %>"
240                       VALUE = "#<%$_%>"
241                >
242 %            }
243             </TD>
244           </TR>
245 %         $anum++;
246 %         $hue += $hue_increment;
247 %       }
248      </TABLE>
249   </TD>
250 </TR>
251
252 <SCRIPT TYPE="text/javascript">
253   $(document).ready(function() {
254 %   foreach my $name (@names) {
255       $("#<% $name %>").spectrum({
256         clickoutFiresChange: true
257       });
258 %   }
259   });
260 </SCRIPT>
261
262 <TR>
263   <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="agent_totals" VALUE="1" DISABLED="1"></TD>
264   <TD>Show per-agent subtotals</TD>
265 </TR>
266
267 <TR>
268   <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="use_override" VALUE="1"></TD>
269   <TD>Separate sub-packages from parents</TD>
270 </TR>
271
272 <TR>
273   <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="average_per_cust_pkg" VALUE="1"></TD>
274   <TD>Average per customer package</TD>
275 </TR>
276
277 <TR>
278   <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="distribute" VALUE="1"></TD>
279   <TD>Distribute recurring fees over billing period</TD>
280 </TR>
281
282 </TABLE>
283
284 <BR><INPUT TYPE="submit" VALUE="Display">
285 </FORM>
286
287 <% include('/elements/footer.html') %>
288 <%init>
289
290 die "access denied"
291   unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
292
293 my @agents = $FS::CurrentUser::CurrentUser->agents;
294
295 </%init>