customer link to package reports for that customer, RT#6180
[freeside.git] / httemplate / search / report_cust_pkg.html
1 <% include('/elements/header.html', $title ) %>
2
3 <FORM ACTION="cust_pkg.cgi" METHOD="GET">
4 <INPUT TYPE="hidden" NAME="magic" VALUE="bill">
5 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
6
7   <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
8
9     <TR>
10       <TH BGCOLOR="#e8e8e8" COLSPAN=2 ALIGN="left">
11         <FONT SIZE="+1">Search options</FONT>
12       </TH>
13     </TR>
14
15 % unless ( $custnum ) {
16     <% include( '/elements/tr-select-agent.html',
17                    'curr_value'    => scalar( $cgi->param('agentnum') ),
18                    'disable_empty' => 0,
19                )
20     %>
21 % }
22
23     <% include( '/elements/tr-select-cust_pkg-status.html',
24                   'onchange' => 'status_changed(this);',
25               )
26     %>
27
28     <SCRIPT TYPE="text/javascript">
29   
30       function status_changed(what) {
31
32 %       foreach my $status ( '', FS::cust_pkg->statuses() ) {
33
34           if ( what.options[what.selectedIndex].value == '<% $status %>' ) {
35
36 %           foreach my $field (qw( setup last_bill bill adjourn susp expire cancel )) {
37 %             if ( $disable{$status}->{$field} ) {
38
39                 what.form.<% $field %>_beginning_text.disabled = true;
40                 what.form.<% $field %>_ending_text.disabled = true;
41                 what.form.<% $field %>_beginning_text.style.backgroundColor = '#dddddd';
42                 what.form.<% $field %>_ending_text.style.backgroundColor = '#dddddd';
43
44                 what.form.<% $field %>_beginning_button.style.display = 'none';
45                 what.form.<% $field %>_ending_button.style.display = 'none';
46                 what.form.<% $field %>_beginning_disabled.style.display = '';
47                 what.form.<% $field %>_ending_disabled.style.display = '';
48
49 %             } else {
50
51                 what.form.<% $field %>_beginning_text.disabled = false;
52                 what.form.<% $field %>_ending_text.disabled = false;
53                 what.form.<% $field %>_beginning_text.style.backgroundColor = '#ffffff';
54                 what.form.<% $field %>_ending_text.style.backgroundColor = '#ffffff';
55
56                 what.form.<% $field %>_beginning_button.style.display = '';
57                 what.form.<% $field %>_ending_button.style.display = '';
58                 what.form.<% $field %>_beginning_disabled.style.display = 'none';
59                 what.form.<% $field %>_ending_disabled.style.display = 'none';
60
61 %             }
62 %           }
63
64           }
65
66 %       }
67
68       }
69
70     </SCRIPT>
71
72     <% include( '/elements/tr-select-pkg_class.html',
73                    'pre_options' => [ '0' => 'all' ],
74                    'empty_label' => '(empty class)',
75                )
76     %>
77
78 %   if ( scalar( qsearch( 'part_pkg_report_option', { 'disabled' => '' } ) ) ) {
79
80     <% include( '/elements/tr-select-table.html',
81                    'label'        => 'Report classes',
82                    'table'        => 'part_pkg_report_option',
83                    'name_col'     => 'name',
84                    'hashref'      => { 'disabled' => '' },
85                    'element_name' => 'report_option',
86                    'multiple'     => 'multiple',
87                )
88     %>
89
90 %   }
91
92 %   foreach my $field (qw( setup last_bill bill adjourn susp expire cancel )) {
93
94       <TR>
95         <TD ALIGN="right" VALIGN="center"><% $label{$field} %></TD>
96         <TD>
97           <TABLE>
98             <% include( '/elements/tr-input-beginning_ending.html',
99                           prefix   => $field,
100                           layout   => 'horiz',
101                       )
102             %>
103           </TABLE>
104         </TD>
105       </TR>
106
107 %   }
108     
109     <SCRIPT TYPE="text/javascript">
110   
111       function custom_changed(what) {
112
113         if ( what.checked  ) {
114
115           what.form.pkgpart.disabled = true;
116           what.form.pkgpart.style.backgroundColor = '#dddddd';
117
118         } else {
119
120           what.form.pkgpart.disabled = false;
121           what.form.pkgpart.style.backgroundColor = '#ffffff';
122
123         }
124
125       }
126
127     </SCRIPT>
128
129     <% include( '/elements/tr-checkbox.html',
130                 'label' => 'Custom packages',
131                 'field' => 'custom',
132                 'value' => 1,
133                 'onchange' => 'custom_changed(this);',
134               )
135     %> 
136
137     <% include( '/elements/tr-selectmultiple-part_pkg.html' ) %> 
138
139     <TR>
140       <TH BGCOLOR="#e8e8e8" COLSPAN=2>&nbsp;</TH>
141     </TR>
142
143     <TR>
144       <TH BGCOLOR="#e8e8e8" COLSPAN=2 ALIGN="left"><FONT SIZE="+1">Display options</FONT></TH>
145     </TR>
146     <% include( '/elements/tr-select-cust-fields.html' ) %>
147     
148   </TABLE>
149
150 <BR>
151 <INPUT TYPE="submit" VALUE="Get Report">
152
153 </FORM>
154
155 <% include('/elements/footer.html') %>
156 <%init>
157
158 die "access denied"
159   unless $FS::CurrentUser::CurrentUser->access_right('List packages');
160
161 my $title = 'Package Report';
162
163 my $custnum = '';
164 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
165   $custnum = $1;
166   my $cust_main = qsearchs({
167     'table'     => 'cust_main', 
168     'hashref'   => { 'custnum' => $custnum },
169     'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
170   }) or die "unknown custnum $custnum";
171   $title .= ': '. $cust_main->name;
172 }
173
174 </%init>
175 <%once>
176
177 my %label = (
178   'setup'     => 'Setup',
179   'last_bill' => 'Last bill',
180   'bill'      => 'Next bill',
181   'adjourn'   => 'Adjourns',
182   'susp'      => 'Suspended',
183   'expire'    => 'Expires',
184   'cancel'    => 'Cancelled',
185 );
186
187 #false laziness w/cust_pkg.cgi
188 my %disable = (
189   'all'             => {},
190   'not yet billed'  => { 'setup'=>1, 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, },
191   'one-time charge' => { 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, },
192   'active'          => { 'susp'=>1, 'cancel'=>1 },
193   'suspended'       => { 'cancel' => 1 },
194   'cancelled'       => {},
195   ''                => {},
196 );
197
198 #hmm?
199 my %checkbox = (
200   'setup'     => 0,
201   'last_bill' => 0,
202   'bill'      => 0,
203   'susp'      => 1,
204   'expire'    => 1,
205   'cancel'    => 1,
206 );
207
208 </%once>