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