summaryrefslogtreecommitdiff
path: root/httemplate/misc/order_pkg.html
blob: b232debd7baa139c54b4e1ed1f634689655fdc6e (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
<% include('/elements/header-popup.html', 'Order new package' ) %>

<LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2">
<SCRIPT TYPE="text/javascript" SRC="../elements/calendar_stripped.js"></SCRIPT>
<SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT>
<SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT>

<SCRIPT TYPE="text/javascript">

  function enable_order_pkg () {
    if ( document.OrderPkgForm.pkgpart.selectedIndex > 0 ) {
      document.OrderPkgForm.submitButton.disabled = false;
      if ( document.OrderPkgForm.pkgpart.options[document.OrderPkgForm.pkgpart.selectedIndex].getAttribute('data-can_discount') == 1 ) {
        document.OrderPkgForm.discountnum.disabled = false;
      } else {
        document.OrderPkgForm.discountnum.disabled = true;
      }
    } else {
      document.OrderPkgForm.submitButton.disabled = true;
      document.OrderPkgForm.discountnum.disabled = true;
    }
  }

</SCRIPT>

<% include('/elements/error.html') %>

<FORM NAME="OrderPkgForm" ACTION="<% $p %>edit/process/quick-cust_pkg.cgi" METHOD="POST">

<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $cust_main->custnum %>">

<% ntable("#cccccc", 2) %>
<% include('/elements/tr-select-cust-part_pkg.html',
             'curr_value' => $pkgpart,
             'classnum'   => -1,
             'cust_main'  => $cust_main,
             'onchange'   => 'enable_order_pkg',
          )
%>

<TR>
  <TH ALIGN="right">Start date </TD>
  <TD COLSPAN=6>
    <% include('/elements/input-date-field.html',{
                'name'      => 'start_date',
                'format'    => $date_format,
                'value'     => $start_date,
                'noinit'    => 1,
              }) %>
    <FONT SIZE=-1>(leave blank to start immediately)</FONT>
  </TD>
</TR>

% if ( $cust_main->payby =~ /^(CARD|CHEK)$/ ) {
%   my $what = lc(FS::payby->shortname($cust_main->payby));
    <TR>
      <TH ALIGN="right">Disable automatic <% $what %> charge </TH>
      <TD COLSPAN=6><INPUT TYPE="checkbox" NAME="no_auto" VALUE="Y"></TD>
    </TR>
% }

% if ( $curuser->access_right('Discount customer package') ) {
  <% include('/elements/tr-select-discount.html',
               'element_etc' => 'DISABLED',
               'colspan'     => 7,
               'cgi'         => $cgi,
            )
  %>
% }

% if ( $conf->exists('pkg_referral') ) {
  <% include('/elements/tr-select-part_referral.html',
               'curr_value'    => scalar( $cgi->param('refnum') ), #get rid of empty_label first# || $cust_main->refnum,
               'disable_empty' => 1,
               'multiple'      => $conf->exists('pkg_referral-multiple'),
               'colspan'       => 7,
            )
  %>
% }

<% include('/elements/tr-select-cust_location.html',
             'cgi'       => $cgi,
             'cust_main' => $cust_main,
          )
%>

<TR>
  <TH ALIGN="right">Contract end date </TD>
  <TD COLSPAN=6>
    <% include('/elements/input-date-field.html',{
                'name'      => 'contract_end',
                'format'    => $date_format,
                'value'     => '',
                'noinit'    => 1,
                }) %>
  </TD>
</TR>

</TABLE>

<% include( '/elements/standardize_locations.html',
            'form'       => "OrderPkgForm",
            'onlyship'   => 1,
            'no_company' => 1,
            'callback'   => 'document.OrderPkgForm.submit();',
          )
%>

<BR>
<INPUT NAME="submitButton" TYPE="button" VALUE="Order Package" onClick = "this.disabled=true; standardize_locations();" <% $pkgpart ? '' : 'DISABLED' %>>

</FORM>
</BODY>
</HTML>
<%init>

my $curuser = $FS::CurrentUser::CurrentUser;

die "access denied"
  unless $curuser->access_right('Order customer package');

my $conf = new FS::Conf;
my $date_format = $conf->config('date_format') || '%m/%d/%Y';

$cgi->param('custnum') =~ /^(\d+)$/ or die "no custnum";
my $custnum = $1;
my $cust_main = qsearchs({
  'table'     => 'cust_main',
  'hashref'   => { 'custnum' => $custnum },
  'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
});

my $pkgpart = scalar($cgi->param('pkgpart'));

my $format = $date_format. ' %T %z (%Z)'; #false laziness w/REAL_cust_pkg.cgi?
my $start_date = '';
if( ! $conf->exists('order_pkg-no_start_date') ) {
  $start_date = $cust_main->next_bill_date;
  $start_date = $start_date ? time2str($format, $start_date) : '';
}

</%init>