summaryrefslogtreecommitdiff
path: root/httemplate/search/report_cust_pkg.html
blob: 4e17d1f51a71108bc6c3c3e564e5839a8e926fe9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
<& /elements/header.html, mt($title, @title_arg) &>

<FORM ACTION="cust_pkg.cgi" METHOD="GET">
<INPUT TYPE="hidden" NAME="magic" VALUE="bill">
<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">

% unless ( $custnum ) {

  <FONT CLASS="fsinnerbox-title"><% emt('Customer search options') %></FONT>
  <TABLE CLASS="fsinnerbox">

    <& /elements/tr-select-agent.html,
                   'curr_value'    => scalar( $cgi->param('agentnum') ),
                   'disable_empty' => 0,
                   'onchange'      => 'agent_changed(this)',
    &>

    <& /elements/tr-select-cust_main-status.html,
         'label' => 'Customer status',
         'field' => 'cust_status',
    &>

    <SCRIPT TYPE="text/javascript">

      function agent_changed(what) {
%       # update sales dropdowns
        salesnum_agentnum_changed(what);
        cust_main_salesnum_agentnum_changed(what);
      }

      <&| /elements/onload.js &>
      agent_changed(document.getElementById('agentnum'))
      </&>
 
    </SCRIPT>

    <& /elements/tr-select-sales.html,
                  'label'         => 'Customer sales person',
                  'element_name'  => 'cust_main_salesnum',
                  'id'            => 'cust_main_salesnum',
                  'curr_value'    => scalar($cgi->param('cust_main_salesnum')),
                  'pre_options'   => [ '' => 'all',
                                       0  => '(none)', ],
                  'disable_empty' => 1,
    &>

  </TABLE>
  <BR>

% }

<FONT CLASS="fsinnerbox-title"><% emt('Package search options') %></FONT>
<TABLE CLASS="fsinnerbox">

    <& /elements/tr-select-sales.html,
                  'label'         => 'Package sales person',
                  'curr_value'    => scalar($cgi->param('salesnum')),
                  'pre_options'   => [ '' => 'all',
                                        0  => '(none)', ],
                  'disable_empty' => 1,
    &>

    <& /elements/tr-select-cust_pkg-status.html,
                  'label'    => 'Package status',
                  'onchange' => 'status_changed(this);',
    &>

    <& /elements/tr-select-reason.html,
             'field'          => 'reasonnum',
             'reason_class'   => 'S',
             'label'          => 'Suspended Reason',
             'label_id'       => 'reasonnum_label',
             'hide_addnew'    => '1',
             'hide_onload'    => '1',
             'cgi'            => $cgi,
             'control_button' => 'confirm_suspend_cust_button',
             'pre_options'    => [ 0 => 'all' ],
    &>

    <SCRIPT TYPE="text/javascript">
  
      function status_changed(what) {

        if (what.options[what.selectedIndex].value == 'suspended') {
          document.getElementById('reasonnum_row').style.visibility = 'visible';
        }
        else {
          document.getElementById('reasonnum_row').style.visibility = 'collapse';
        }

%       foreach my $status ( '', FS::cust_pkg->statuses() ) {

          if ( what.options[what.selectedIndex].value == '<% $status %>' ) {

%           foreach my $field (@date_fields) {
%             if ( $disable{$status}->{$field} ) {

                what.form.<% $field %>_beginning_text.disabled = true;
                what.form.<% $field %>_ending_text.disabled = true;
                what.form.<% $field %>_null.disabled = true;
                what.form.<% $field %>_beginning_text.style.backgroundColor = '#dddddd';
                what.form.<% $field %>_ending_text.style.backgroundColor = '#dddddd';

                what.form.<% $field %>_beginning_button.style.display = 'none';
                what.form.<% $field %>_ending_button.style.display = 'none';
                what.form.<% $field %>_beginning_disabled.style.display = '';
                what.form.<% $field %>_ending_disabled.style.display = '';

%             } else {

                what.form.<% $field %>_null.disabled = false;

                if ( ! what.form.<% $field %>_null.checked ) {

                  what.form.<% $field %>_beginning_text.disabled = false;
                  what.form.<% $field %>_ending_text.disabled = false;
                  what.form.<% $field %>_beginning_text.style.backgroundColor = '#ffffff';
                  what.form.<% $field %>_ending_text.style.backgroundColor = '#ffffff';

                  what.form.<% $field %>_beginning_button.style.display = '';
                  what.form.<% $field %>_ending_button.style.display = '';
                  what.form.<% $field %>_beginning_disabled.style.display = 'none';
                  what.form.<% $field %>_ending_disabled.style.display = 'none';

                }

%             }
%           }

          }

%       }

      }

%     foreach my $field (@date_fields) {

        function <% $field %>_null_changed(what) {

          if ( what.checked ) {
            what.form.<% $field %>_beginning_text.disabled = true;
            what.form.<% $field %>_ending_text.disabled = true;
            what.form.<% $field %>_beginning_text.style.backgroundColor = '#dddddd';
            what.form.<% $field %>_ending_text.style.backgroundColor = '#dddddd';
            what.form.<% $field %>_beginning_button.style.display = 'none';
            what.form.<% $field %>_ending_button.style.display = 'none';
            what.form.<% $field %>_beginning_disabled.style.display = '';
            what.form.<% $field %>_ending_disabled.style.display = '';

          } else {
            what.form.<% $field %>_beginning_text.disabled = false;
            what.form.<% $field %>_ending_text.disabled = false;
            what.form.<% $field %>_beginning_text.style.backgroundColor = '#ffffff';
            what.form.<% $field %>_ending_text.style.backgroundColor = '#ffffff';

            what.form.<% $field %>_beginning_button.style.display = '';
            what.form.<% $field %>_ending_button.style.display = '';
            what.form.<% $field %>_beginning_disabled.style.display = 'none';
            what.form.<% $field %>_ending_disabled.style.display = 'none';

          }

        }

%     }

    </SCRIPT>

    <& /elements/tr-select-pkg_class.html,
                   'pre_options' => [ '0' => 'all' ],
                   'empty_label' => '(empty class)',
    &>

%   if ( scalar( qsearch( 'part_pkg_report_option', { 'disabled' => '' } ) ) ) {

    <& /elements/tr-select-table.html,
                   'label'        => 'Report classes',
                   'table'        => 'part_pkg_report_option',
                   'name_col'     => 'name',
                   'hashref'      => { 'disabled' => '' },
                   'element_name' => 'report_option',
                   'multiple'     => 'multiple',
    &>

%   }
    <TR>



            <TD></TD>
            <TH ALIGN="left"><% '&nbsp;'x 10 %>From date <i>(m/d/y)</i></TH>
            <TH ALIGN="center">To date <i>(m/d/y)</i></TH>
            <TH>Empty date</TH>
          </TR>
%   my $noinit = 0;
%   foreach my $field (@date_fields) {

          <TR>
            <TH ALIGN="right" VALIGN="center"><% $label{$field} %></TH>
%     foreach (qw(beginning ending)) {
            <TD>
              <& /elements/input-date-field.html, {
                'name'    => $field.'_'.$_,
                'value'   => '',
                'noinit'  => $noinit,
                'format'  => '%m/%d/%Y',
              } &>
            </TD>
%     $noinit = 1;
%     }
            <TD ALIGN="center">
              <& /elements/checkbox.html,
                   'field'    => $field.'_null',
                   'value'    => 'Y',
                   'onchange' => $field.'_null_changed',
              &>
            </TD>
          </TR>
%   } #foreach $field



    
    <SCRIPT TYPE="text/javascript">
  
      function custom_changed(what) {

        if ( what.checked  ) {

          what.form.pkgpart.disabled = true;
          what.form.pkgpart.style.backgroundColor = '#dddddd';

        } else {

          what.form.pkgpart.disabled = false;
          what.form.pkgpart.style.backgroundColor = '#ffffff';

        }

      }

    </SCRIPT>

    <& /elements/tr-checkbox.html,
                'label' => 'Custom packages',
                'field' => 'custom',
                'value' => 1,
                'onchange' => 'custom_changed(this);',
    &> 

    <& /elements/tr-selectmultiple-part_pkg.html, colspan=>3 &> 

</TABLE>
<BR>

<FONT CLASS="fsinnerbox-title"><% emt('Location search options') %></FONT>
<TABLE CLASS="fsinnerbox">

%   my @location_options = qw(cust nocust census nocensus);
%   if ( $conf->config('tax_data_vendor') eq 'cch' ) {
%     push @location_options, 'geocode', 'nogeocode';
%   }
    <& /elements/tr-checkbox-multiple.html,
                'label'   => 'Where package location:',
                'field'   => 'loc',
                'options' => \@location_options,
                'labels'  => { 'cust'     => "is the customer's default location",
                               'nocust'   => "is not the customer's default location",
                               'census'   => "has a census tract",
                               'nocensus' => "does not have a census tract",
                               'nogeocode'=> 'has an implicit tax location',
                               'geocode'  => 'has a hardcoded tax location',
                             },
                'value'   => { map { $_ => 0 } @location_options },
    &>

</TABLE>
<BR>

<FONT CLASS="fsinnerbox-title"><% emt('Display options') %></FONT>
<TABLE CLASS="fsinnerbox">

    <& /elements/tr-select-cust-fields.html &>
    
  </TABLE>

<BR>
<INPUT TYPE="submit" VALUE="Get Report">

</FORM>

<% include('/elements/footer.html') %>
<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('List packages');

my $title = 'Package Report';
#false laziness w/report_cust_bill.html
my @title_arg = ();

my $custnum = '';
if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
  $custnum = $1;
  my $cust_main = qsearchs({
    'table'     => 'cust_main', 
    'hashref'   => { 'custnum' => $custnum },
    'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
  }) or die "unknown custnum $custnum";
  $title .= ': [_1]';
  push @title_arg, $cust_main->name;
}

</%init>
<%once>

tie my %label, 'Tie::IxHash',
  'setup'        => 'Setup',
  'last_bill'    => 'Last bill',
  'bill'         => 'Next bill',
  'adjourn'      => 'Adjourns',
  'susp'         => 'Suspended',
  'dundate'      => 'Suspension delayed until',
  'expire'       => 'Expires',
  'contract_end' => 'Contract ends',
  'change_date'  => 'Changed from other package',
  'cancel'       => 'Cancelled',
;
my @date_fields = keys %label;

#false laziness w/cust_pkg.cgi
my %disable = (
  'all'             => {},
  'on hold'         => { 'setup'=>1, 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'expire'=>1, 'cancel'=>1, 'dundate'=> 1, },
  'not yet billed'  => { 'setup'=>1, 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, 'dundate'=>1, },
  'one-time charge' => { 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, 'contract_end'=>1, 'dundate'=>1, },
  'active'          => { 'susp'=>1, 'cancel'=>1 },
  'suspended'       => { 'cancel'=>1, 'dundate'=>1, },
  'cancelled'       => {},
  ''                => {},
);

#hmm?
my %checkbox = (
  'setup'     => 0,
  'last_bill' => 0,
  'bill'      => 0,
  'susp'      => 1,
  'dundate'   => 1,
  'expire'    => 1,
  'cancel'    => 1,
);

my $conf = FS::Conf->new;
</%once>