1e54df3abd156304618d748fce3e813d31ec4a8a
[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="GET">
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   if (mode == 'pkg') {
68     div_pkg.style.display = '';
69     div_report.style.display = 'none';
70   } else if (mode == 'report') {
71     div_pkg.style.display = 'none';
72     div_report.style.display = '';
73   }
74 }
75 window.onload = class_mode_changed;
76 </SCRIPT>
77
78 <& /elements/tr-select-agent.html,
79   'field'         => 'agentnum',
80   'label'         => 'Agent ',
81   'disable_empty' => 0,
82   'pre_options'   => [ 'all' => 'all (aggregate)' ],
83   'empty_label'   => 'all (breakdown)',
84   'onchange'      => 'agent_changed',
85 &>
86
87 <& /elements/tr-select-cust_class.html,
88   'field'         => 'cust_classnum',
89   'label'         => 'Customer class',
90   'multiple'      => 1,
91 &>
92
93 <& /elements/tr-select-part_referral.html,
94   'field'         => 'refnum',
95   'label'         => 'Advertising source ',
96   'disable_empty' => 0,
97   'pre_options'   => [ 'all' => 'all (aggregate)' ],
98   'empty_label'   => 'all (breakdown)',
99   'onchange'      => 'enable_agent_totals'
100 &>
101
102 <TR>
103
104   <TD>
105     <INPUT TYPE="radio" NAME="class_mode" VALUE="pkg" onchange="class_mode_changed('pkg')" CHECKED>
106     <% emt('Package class') %>
107     <BR>
108     <INPUT TYPE="radio" NAME="class_mode" VALUE="report" onchange="class_mode_changed('report')">
109     <% emt('Report class') %>
110   </TD>
111
112   <TD>
113     <TABLE>
114       <TR>
115
116         <TD>
117           <DIV ID="pkg_class">
118           <& /elements/select-pkg_class.html,
119             'field'         => 'classnum',
120             'multiple'      => 1,
121             'all_selected'  => 1,
122             'pre_options'   => [ #'all'  => 'all (aggregate)',
123                                 #   ''  => 'all (breakdown)',
124                                   '0'  => '(empty class)' ],
125             'disable_empty' => 1,
126             'onchange'      => 'enable_agent_totals',
127           &>
128           </DIV>
129           <DIV ID="report_class" STYLE="display: none">
130           <& /elements/select-table.html,
131             'field'         => 'report_optionnum',
132             'table'         => 'part_pkg_report_option',
133             'name_col'      => 'name',
134             'value_col'     => 'num',
135             'multiple'      => 1,
136             'all_selected'  => 1,
137             'pre_options'   => [ #'all' => 'all (aggregate)',
138                                #   '' => 'all (breakdown)', 
139                                  '0'  => '(empty class)' ],
140             'disable_empty' => 1,
141             'onchange'      => 'enable_agent_totals',
142           &>
143           </DIV>
144         </TD>
145
146         <TD>
147           <INPUT TYPE="radio" NAME="class_agg_break" ID="class_agg_break_aggregate" VALUE="aggregate" onchange="enable_agent_totals(this)" CHECKED>
148           <% emt('Aggregate') %>
149           <BR>
150           <INPUT TYPE="radio" NAME="class_agg_break" ID="class_agg_break_breakdown" VALUE="breakdown" onchange="enable_agent_totals(this)">
151           <% emt('Breakdown') %>
152         </TD>
153
154       </TR>
155     </TABLE>
156   </TD>
157
158 </TR>
159
160
161 <TR>
162   <TH CLASS="background" COLSPAN=2>&nbsp;</TH>
163 </TR>
164
165 <TR>
166   <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1"><% mt('Display options') |h %></FONT></TH>
167 </TR>
168
169 <!--
170 <TR>
171   <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="separate_0freq" VALUE="1"></TD>
172   <TD>Separate one-time vs. recurring sales</TD>
173 </TR>
174 -->
175
176 % foreach ( qw(Setup Usage) ) {
177 <& /elements/tr-select.html,
178     'label'   => "$_ fees",
179     'field'   => 'use_'.lc($_),
180     'options' => [ 0, 1, 2 ],
181     'labels'  => { 0 => 'Combine', 1 => 'Separate', 2 => 'Do not show' },
182     'onchange'=> 'enable_agent_totals',
183 &>
184 % }
185
186 <TR>
187   <TD ALIGN="right">Colors</TD>
188   <TD>
189 %   my @names = ();
190 %
191 %   #no particular long-term attachment to this, just trying to replicate
192 %   # historical behavior so people's graphs don't change color suddenly in 3.x
193 %   my $hue = 0;
194 %   my $hue_increment = 125;
195
196       <TABLE>
197 %       my $anum = 0;
198 %       foreach my $agent ( @agents ) {
199           <TR <% $anum ? 'STYLE="display:none"' : '' %>
200               ID="agent<%$anum%>-colors"
201           >
202             <TD <% $anum ? '' :'STYLE="display:none"' %>
203                 ID="agent<%$anum%>-label"
204             >
205               <% $agent->agent |h %>
206             </TD>
207             <TD>
208 %            my $col_scheme = Color::Scheme->new
209 %                               ->from_hue($hue) #->from_hex($agent->color)
210 %                               ->scheme('analogic')
211 %                             ;
212 %
213 %            my $cnum = 0;
214 %            my @colors = ($col_scheme->colors)[ 0,4,8,1,5,9 ];#again some some random historical shite
215 %            for (@colors) {
216 %              my $name = "agent$anum-color$cnum";
217 %              push @names, $name;
218 %              $cnum++;
219                <INPUT TYPE  = "color"
220                       NAME  = "<% $name %>"
221                       ID    = "<% $name %>"
222                       VALUE = "#<%$_%>"
223                >
224 %            }
225             </TD>
226           </TR>
227 %         $anum++;
228 %         $hue += $hue_increment;
229 %       }
230      </TABLE>
231   </TD>
232 </TR>
233
234 <SCRIPT TYPE="text/javascript">
235   $(document).ready(function() {
236 %   foreach my $name (@names) {
237       $("#<% $name %>").spectrum({
238         clickoutFiresChange: true
239       });
240 %   }
241   });
242 </SCRIPT>
243
244 <TR>
245   <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="agent_totals" VALUE="1" DISABLED="1"></TD>
246   <TD>Show per-agent subtotals</TD>
247 </TR>
248
249 <TR>
250   <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="use_override" VALUE="1"></TD>
251   <TD>Separate sub-packages from parents</TD>
252 </TR>
253
254 <TR>
255   <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="average_per_cust_pkg" VALUE="1"></TD>
256   <TD>Average per customer package</TD>
257 </TR>
258
259 <TR>
260   <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="distribute" VALUE="1"></TD>
261   <TD>Distribute recurring fees over billing period</TD>
262 </TR>
263
264 </TABLE>
265
266 <BR><INPUT TYPE="submit" VALUE="Display">
267 </FORM>
268
269 <% include('/elements/footer.html') %>
270 <%init>
271
272 die "access denied"
273   unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
274
275 my @agents = $FS::CurrentUser::CurrentUser->agents;
276
277 </%init>