"on hold" package ordering and status, RT#28508
[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 % unless ( $custnum ) {
8
9   <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
10
11     <& /elements/tr-title.html, value => mt('Customer search options') &>
12
13     <& /elements/tr-select-agent.html,
14                    'curr_value'    => scalar( $cgi->param('agentnum') ),
15                    'disable_empty' => 0,
16                    'onchange'      => 'agent_changed(this)',
17     &>
18
19     <& /elements/tr-select-cust_main-status.html,
20          'label' => 'Customer status',
21          'field' => 'cust_status',
22     &>
23
24     <SCRIPT TYPE="text/javascript">
25
26       function agent_changed(what) {
27 %       # update sales dropdowns
28         salesnum_agentnum_changed(what);
29         cust_main_salesnum_agentnum_changed(what);
30       }
31
32       <&| /elements/onload.js &>
33       agent_changed(document.getElementById('agentnum'))
34       </&>
35  
36     </SCRIPT>
37
38     <& /elements/tr-select-sales.html,
39                   'label'         => 'Customer sales person',
40                   'element_name'  => 'cust_main_salesnum',
41                   'id'            => 'cust_main_salesnum',
42                   'curr_value'    => scalar($cgi->param('cust_main_salesnum')),
43                   'pre_options'   => [ '' => 'all',
44                                        0  => '(none)', ],
45                   'disable_empty' => 1,
46     &>
47
48   </TABLE>
49   <BR>
50
51 % }
52
53   <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
54
55     <& /elements/tr-title.html, value => mt('Package search options') &>
56
57     <& /elements/tr-select-sales.html,
58                   'label'         => 'Package sales person',
59                   'curr_value'    => scalar($cgi->param('salesnum')),
60                   'pre_options'   => [ '' => 'all',
61                                         0  => '(none)', ],
62                   'disable_empty' => 1,
63     &>
64
65     <& /elements/tr-select-cust_pkg-status.html,
66                   'label'    => 'Package status',
67                   'onchange' => 'status_changed(this);',
68     &>
69
70     <SCRIPT TYPE="text/javascript">
71   
72       function status_changed(what) {
73
74 %       foreach my $status ( '', FS::cust_pkg->statuses() ) {
75
76           if ( what.options[what.selectedIndex].value == '<% $status %>' ) {
77
78 %           foreach my $field (@date_fields) {
79 %             if ( $disable{$status}->{$field} ) {
80
81                 what.form.<% $field %>_beginning_text.disabled = true;
82                 what.form.<% $field %>_ending_text.disabled = true;
83                 what.form.<% $field %>_beginning_text.style.backgroundColor = '#dddddd';
84                 what.form.<% $field %>_ending_text.style.backgroundColor = '#dddddd';
85
86                 what.form.<% $field %>_beginning_button.style.display = 'none';
87                 what.form.<% $field %>_ending_button.style.display = 'none';
88                 what.form.<% $field %>_beginning_disabled.style.display = '';
89                 what.form.<% $field %>_ending_disabled.style.display = '';
90
91 %             } else {
92
93                 what.form.<% $field %>_beginning_text.disabled = false;
94                 what.form.<% $field %>_ending_text.disabled = false;
95                 what.form.<% $field %>_beginning_text.style.backgroundColor = '#ffffff';
96                 what.form.<% $field %>_ending_text.style.backgroundColor = '#ffffff';
97
98                 what.form.<% $field %>_beginning_button.style.display = '';
99                 what.form.<% $field %>_ending_button.style.display = '';
100                 what.form.<% $field %>_beginning_disabled.style.display = 'none';
101                 what.form.<% $field %>_ending_disabled.style.display = 'none';
102
103 %             }
104 %           }
105
106           }
107
108 %       }
109
110       }
111
112     </SCRIPT>
113
114     <& /elements/tr-select-pkg_class.html,
115                    'pre_options' => [ '0' => 'all' ],
116                    'empty_label' => '(empty class)',
117     &>
118
119 %   if ( scalar( qsearch( 'part_pkg_report_option', { 'disabled' => '' } ) ) ) {
120
121     <& /elements/tr-select-table.html,
122                    'label'        => 'Report classes',
123                    'table'        => 'part_pkg_report_option',
124                    'name_col'     => 'name',
125                    'hashref'      => { 'disabled' => '' },
126                    'element_name' => 'report_option',
127                    'multiple'     => 'multiple',
128     &>
129
130 %   }
131     <TR>
132       <TD COLSPAN=2>
133         <TABLE>
134           <TR>
135             <TD></TD>
136             <TD>From date <i>(m/d/y)</i></TD>
137             <TD>To date <i>(m/d/y)</i></TD>
138           </TR>
139 %   my $noinit = 0;
140 %   foreach my $field (@date_fields) {
141
142           <TR>
143             <TD ALIGN="right" VALIGN="center"><% $label{$field} %></TD>
144 %     foreach (qw(beginning ending)) {
145             <TD>
146               <& /elements/input-date-field.html, {
147                 'name'    => $field.'_'.$_,
148                 'value'   => '',
149                 'noinit'  => $noinit,
150                 'format'  => '%m/%d/%Y',
151               } &>
152             </TD>
153 %     $noinit = 1;
154 %     }
155           </TR>
156 %   } #foreach $field
157         </TABLE>
158       </TD>
159     </TR>
160     
161     <SCRIPT TYPE="text/javascript">
162   
163       function custom_changed(what) {
164
165         if ( what.checked  ) {
166
167           what.form.pkgpart.disabled = true;
168           what.form.pkgpart.style.backgroundColor = '#dddddd';
169
170         } else {
171
172           what.form.pkgpart.disabled = false;
173           what.form.pkgpart.style.backgroundColor = '#ffffff';
174
175         }
176
177       }
178
179     </SCRIPT>
180
181     <& /elements/tr-checkbox.html,
182                 'label' => 'Custom packages',
183                 'field' => 'custom',
184                 'value' => 1,
185                 'onchange' => 'custom_changed(this);',
186     &> 
187
188     <& /elements/tr-selectmultiple-part_pkg.html &> 
189
190     <& /elements/tr-title.html, value => mt('Location search options') &>
191
192 %   my @location_options = qw(cust nocust census nocensus);
193 %   if ( $conf->exists('enable_taxproducts') ) {
194 %     push @location_options, 'geocode', 'nogeocode';
195 %   }
196     <& /elements/tr-checkbox-multiple.html,
197                 'label'   => 'Where package location:',
198                 'field'   => 'loc',
199                 'options' => \@location_options,
200                 'labels'  => { 'cust'     => "is the customer's default location",
201                                'nocust'   => "is not the customer's default location",
202                                'census'   => "has a census tract",
203                                'nocensus' => "does not have a census tract",
204                                'nogeocode'=> 'has an implicit tax location',
205                                'geocode'  => 'has a hardcoded tax location',
206                              },
207                 'value'   => { map { $_ => 1 } @location_options },
208     &>
209
210     <& /elements/tr-title.html, value => mt('Display options') &>
211
212     <& /elements/tr-select-cust-fields.html &>
213     
214   </TABLE>
215
216 <BR>
217 <INPUT TYPE="submit" VALUE="Get Report">
218
219 </FORM>
220
221 <% include('/elements/footer.html') %>
222 <%init>
223
224 die "access denied"
225   unless $FS::CurrentUser::CurrentUser->access_right('List packages');
226
227 my $title = 'Package Report';
228 #false laziness w/report_cust_bill.html
229 my @title_arg = ();
230
231 my $custnum = '';
232 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
233   $custnum = $1;
234   my $cust_main = qsearchs({
235     'table'     => 'cust_main', 
236     'hashref'   => { 'custnum' => $custnum },
237     'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
238   }) or die "unknown custnum $custnum";
239   $title .= ': [_1]';
240   push @title_arg, $cust_main->name;
241 }
242
243 </%init>
244 <%once>
245
246 tie my %label, 'Tie::IxHash',
247   'setup'        => 'Setup',
248   'last_bill'    => 'Last bill',
249   'bill'         => 'Next bill',
250   'adjourn'      => 'Adjourns',
251   'susp'         => 'Suspended',
252   'dundate'      => 'Suspension delayed until',
253   'expire'       => 'Expires',
254   'contract_end' => 'Contract ends',
255   'change_date'  => 'Changed from other package',
256   'cancel'       => 'Cancelled',
257 ;
258 my @date_fields = keys %label;
259
260 #false laziness w/cust_pkg.cgi
261 my %disable = (
262   'all'             => {},
263   'on hold'         => { 'setup'=>1, 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'expire'=>1, 'cancel'=>1, 'dundate'=> 1, },
264   'not yet billed'  => { 'setup'=>1, 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, 'dundate'=>1, },
265   'one-time charge' => { 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, 'contract_end'=>1, 'dundate'=>1, },
266   'active'          => { 'susp'=>1, 'cancel'=>1 },
267   'suspended'       => { 'cancel'=>1, 'dundate'=>1, },
268   'cancelled'       => {},
269   ''                => {},
270 );
271
272 #hmm?
273 my %checkbox = (
274   'setup'     => 0,
275   'last_bill' => 0,
276   'bill'      => 0,
277   'susp'      => 1,
278   'dundate'   => 1,
279   'expire'    => 1,
280   'cancel'    => 1,
281 );
282
283 my $conf = FS::Conf->new;
284 </%once>