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