3840663cfbdf9219a55239a480f187602250624e
[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 %   foreach my $field (qw( setup last_bill bill adjourn susp expire cancel )) {
76
77       <TR>
78         <TD ALIGN="right" VALIGN="center"><% $label{$field} %></TD>
79         <TD>
80           <TABLE>
81             <% include( '/elements/tr-input-beginning_ending.html',
82                           prefix   => $field,
83                           layout   => 'horiz',
84                       )
85             %>
86           </TABLE>
87         </TD>
88       </TR>
89
90 %   }
91     
92     <SCRIPT TYPE="text/javascript">
93   
94       function custom_changed(what) {
95
96         if ( what.checked  ) {
97
98           what.form.pkgpart.disabled = true;
99           what.form.pkgpart.style.backgroundColor = '#dddddd';
100
101         } else {
102
103           what.form.pkgpart.disabled = false;
104           what.form.pkgpart.style.backgroundColor = '#ffffff';
105
106         }
107
108       }
109
110     </SCRIPT>
111
112     <% include( '/elements/tr-checkbox.html',
113                 'label' => 'Custom packages',
114                 'field' => 'custom',
115                 'value' => 1,
116                 'onchange' => 'custom_changed(this);',
117               )
118     %> 
119
120     <% include( '/elements/tr-selectmultiple-part_pkg.html' ) %> 
121
122     <TR>
123       <TH BGCOLOR="#e8e8e8" COLSPAN=2>&nbsp;</TH>
124     </TR>
125
126     <TR>
127       <TH BGCOLOR="#e8e8e8" COLSPAN=2 ALIGN="left"><FONT SIZE="+1">Display options</FONT></TH>
128     </TR>
129     <% include( '/elements/tr-select-cust-fields.html' ) %>
130     
131   </TABLE>
132
133 <BR>
134 <INPUT TYPE="submit" VALUE="Get Report">
135
136 </FORM>
137
138 <% include('/elements/footer.html') %>
139 <%init>
140
141 die "access denied"
142   unless $FS::CurrentUser::CurrentUser->access_right('List packages');
143
144 </%init>
145 <%once>
146
147 my %label = (
148   'setup'     => 'Setup',
149   'last_bill' => 'Last bill',
150   'bill'      => 'Next bill',
151   'adjourn'   => 'Adjourns',
152   'susp'      => 'Suspended',
153   'expire'    => 'Expires',
154   'cancel'    => 'Cancelled',
155 );
156
157 #false laziness w/cust_pkg.cgi
158 my %disable = (
159   'all'             => {},
160   'not yet billed'  => { 'setup'=>1, 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, },
161   'one-time charge' => { 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, },
162   'active'          => { 'susp'=>1, 'cancel'=>1 },
163   'suspended'       => { 'cancel' => 1 },
164   'cancelled'       => {},
165   ''                => {},
166 );
167
168 #hmm?
169 my %checkbox = (
170   'setup'     => 0,
171   'last_bill' => 0,
172   'bill'      => 0,
173   'susp'      => 1,
174   'expire'    => 1,
175   'cancel'    => 1,
176 );
177
178 </%once>