Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / httemplate / search / report_cust_pkg.html
1 <& /elements/header.html, mt($title, @title_arg) &>
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 CLASS="background" 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 (@date_fields) {
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     <TR>
92       <TD COLSPAN=2>
93         <TABLE>
94           <TR>
95             <TD></TD>
96             <TD>From date <i>(m/d/y)</i></TD>
97             <TD>To date <i>(m/d/y)</i></TD>
98           </TR>
99 %   my $noinit = 0;
100 %   foreach my $field (@date_fields) {
101
102           <TR>
103             <TD ALIGN="right" VALIGN="center"><% $label{$field} %></TD>
104 %     foreach (qw(beginning ending)) {
105             <TD>
106               <& /elements/input-date-field.html, {
107                 'name'    => $field.'_'.$_,
108                 'value'   => '',
109                 'noinit'  => $noinit,
110                 'format'  => '%m/%d/%Y',
111               } &>
112             </TD>
113 %     $noinit = 1;
114 %     }
115           </TR>
116 %   } #foreach $field
117         </TABLE>
118       </TD>
119     </TR>
120     
121     <SCRIPT TYPE="text/javascript">
122   
123       function custom_changed(what) {
124
125         if ( what.checked  ) {
126
127           what.form.pkgpart.disabled = true;
128           what.form.pkgpart.style.backgroundColor = '#dddddd';
129
130         } else {
131
132           what.form.pkgpart.disabled = false;
133           what.form.pkgpart.style.backgroundColor = '#ffffff';
134
135         }
136
137       }
138
139     </SCRIPT>
140
141     <% include( '/elements/tr-checkbox.html',
142                 'label' => 'Custom packages',
143                 'field' => 'custom',
144                 'value' => 1,
145                 'onchange' => 'custom_changed(this);',
146               )
147     %> 
148
149     <% include( '/elements/tr-selectmultiple-part_pkg.html' ) %> 
150
151     <TR>
152       <TH CLASS="background" COLSPAN=2>&nbsp;</TH>
153     </TR>
154
155     <TR>
156       <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1">Display options</FONT></TH>
157     </TR>
158     <% include( '/elements/tr-select-cust-fields.html' ) %>
159     
160   </TABLE>
161
162 <BR>
163 <INPUT TYPE="submit" VALUE="Get Report">
164
165 </FORM>
166
167 <% include('/elements/footer.html') %>
168 <%init>
169
170 die "access denied"
171   unless $FS::CurrentUser::CurrentUser->access_right('List packages');
172
173 my $title = 'Package Report';
174 #false laziness w/report_cust_bill.html
175 my @title_arg = ();
176
177 my $custnum = '';
178 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
179   $custnum = $1;
180   my $cust_main = qsearchs({
181     'table'     => 'cust_main', 
182     'hashref'   => { 'custnum' => $custnum },
183     'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
184   }) or die "unknown custnum $custnum";
185   $title .= ': [_1]';
186   push @title_arg, $cust_main->name;
187 }
188
189 </%init>
190 <%once>
191
192 tie my %label, 'Tie::IxHash',
193   'setup'        => 'Setup',
194   'last_bill'    => 'Last bill',
195   'bill'         => 'Next bill',
196   'adjourn'      => 'Adjourns',
197   'susp'         => 'Suspended',
198   'dundate'      => 'Suspension delayed until',
199   'expire'       => 'Expires',
200   'contract_end' => 'Contract ends',
201   'change_date'  => 'Changed from other package',
202   'cancel'       => 'Cancelled',
203 ;
204 my @date_fields = keys %label;
205
206 #false laziness w/cust_pkg.cgi
207 my %disable = (
208   'all'             => {},
209   'not yet billed'  => { 'setup'=>1, 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, },
210   'one-time charge' => { 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, 'contract_end'=>1, 'dundate'=>1, },
211   'active'          => { 'susp'=>1, 'cancel'=>1 },
212   'suspended'       => { 'cancel'=>1, 'dundate'=>1, },
213   'cancelled'       => {},
214   ''                => {},
215 );
216
217 #hmm?
218 my %checkbox = (
219   'setup'     => 0,
220   'last_bill' => 0,
221   'bill'      => 0,
222   'susp'      => 1,
223   'dundate'   => 1,
224   'expire'    => 1,
225   'cancel'    => 1,
226 );
227
228 </%once>