stray closing /TABLE in the no-ticket case
[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 <TR>
169   <TH CLASS="background" COLSPAN=2>&nbsp;</TH>
170 </TR>
171
172 <TR>
173   <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1"><% mt('Display options') |h %></FONT></TH>
174 </TR>
175
176 <!--
177 <TR>
178   <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="separate_0freq" VALUE="1"></TD>
179   <TD>Separate one-time vs. recurring sales</TD>
180 </TR>
181 -->
182
183 % foreach ( qw(Setup Usage) ) {
184 <& /elements/tr-select.html,
185     'label'   => "$_ fees",
186     'field'   => 'use_'.lc($_),
187     'options' => [ 0, 1, 2 ],
188     'labels'  => { 0 => 'Combine', 1 => 'Separate', 2 => 'Do not show' },
189     'onchange'=> 'enable_agent_totals',
190 &>
191 % }
192 <& /elements/tr-select.html,
193     'label'   => 'Discounts',
194     'field'   => 'use_discount',
195     'options' => [ 1, 2 ],
196     'labels'  => { 1 => 'Separate', 2 => 'Do not show' },
197 &>
198 <& /elements/tr-select.html,
199     'label'   => 'Taxes',
200     'field'   => 'use_taxes',
201     'options' => [ 1, 2 ],
202     'labels'  => { 1 => 'Separate', 2 => 'Do not show' },
203 &>
204
205 <TR>
206   <TD ALIGN="right">Colors</TD>
207   <TD>
208 %   my @names = ();
209 %
210 %   #no particular long-term attachment to this, just trying to replicate
211 %   # historical behavior so people's graphs don't change color suddenly in 3.x
212 %   my $hue = 0;
213 %   my $hue_increment = 125;
214
215       <TABLE>
216 %       my $anum = 0;
217 %       foreach my $agent ( @agents ) {
218           <TR <% $anum ? 'STYLE="display:none"' : '' %>
219               ID="agent<%$anum%>-colors"
220           >
221             <TD <% $anum ? '' :'STYLE="display:none"' %>
222                 ID="agent<%$anum%>-label"
223             >
224               <% $agent->agent |h %>
225             </TD>
226             <TD>
227 %            my $col_scheme = Color::Scheme->new
228 %                               ->from_hue($hue) #->from_hex($agent->color)
229 %                               ->scheme('analogic')
230 %                             ;
231 %
232 %            my $cnum = 0;
233 %            my @colors = ($col_scheme->colors)[ 0,4,8,1,5,9 ];#again some some random historical shite
234 %            for (@colors) {
235 %              my $name = "agent$anum-color$cnum";
236 %              push @names, $name;
237 %              $cnum++;
238                <INPUT TYPE  = "color"
239                       NAME  = "<% $name %>"
240                       ID    = "<% $name %>"
241                       VALUE = "#<%$_%>"
242                >
243 %            }
244             </TD>
245           </TR>
246 %         $anum++;
247 %         $hue += $hue_increment;
248 %       }
249      </TABLE>
250   </TD>
251 </TR>
252
253 <SCRIPT TYPE="text/javascript">
254   $(document).ready(function() {
255 %   foreach my $name (@names) {
256       $("#<% $name %>").spectrum({
257         clickoutFiresChange: true
258       });
259 %   }
260   });
261 </SCRIPT>
262
263 <TR>
264   <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="agent_totals" VALUE="1" DISABLED="1"></TD>
265   <TD>Show per-agent subtotals</TD>
266 </TR>
267
268 <TR>
269   <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="use_override" VALUE="1"></TD>
270   <TD>Separate sub-packages from parents</TD>
271 </TR>
272
273 <TR>
274   <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="average_per_cust_pkg" VALUE="1"></TD>
275   <TD>Average per customer package</TD>
276 </TR>
277
278 <TR>
279   <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="distribute" VALUE="1"></TD>
280   <TD>Distribute recurring fees over billing period</TD>
281 </TR>
282
283 </TABLE>
284
285 <BR><INPUT TYPE="submit" VALUE="Display">
286 </FORM>
287
288 <% include('/elements/footer.html') %>
289 <%init>
290
291 die "access denied"
292   unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
293
294 my @agents = $FS::CurrentUser::CurrentUser->agents;
295
296 </%init>