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