fix usps-validation misfire and inability to submit on change package too, RT#12377...
[freeside.git] / httemplate / misc / order_pkg.html
1 <% include('/elements/header-popup.html', 'Order new package' ) %>
2
3 <LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2">
4 <SCRIPT TYPE="text/javascript" SRC="../elements/calendar_stripped.js"></SCRIPT>
5 <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT>
6 <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT>
7
8 <SCRIPT TYPE="text/javascript" SRC="../elements/order_pkg.js"></SCRIPT>
9
10 <% include('/elements/error.html') %>
11
12 <FORM NAME="OrderPkgForm" ACTION="<% $p %>edit/process/quick-cust_pkg.cgi" METHOD="POST">
13
14 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $cust_main->custnum %>">
15
16 <% ntable("#cccccc", 2) %>
17 <% include('/elements/tr-select-cust-part_pkg.html',
18              'curr_value' => $pkgpart,
19              'classnum'   => -1,
20              'cust_main'  => $cust_main,
21              'onchange'   => 'enable_order_pkg',
22           )
23 %>
24
25 <TR>
26   <TH ALIGN="right">Start date </TD>
27   <TD COLSPAN=6>
28     <% include('/elements/input-date-field.html',{
29                 'name'      => 'start_date',
30                 'format'    => $date_format,
31                 'value'     => $start_date,
32                 'noinit'    => 1,
33               }) %>
34     <FONT SIZE=-1>(leave blank to start immediately)</FONT>
35   </TD>
36 </TR>
37
38 % if ( $cust_main->payby =~ /^(CARD|CHEK)$/ ) {
39 %   my $what = lc(FS::payby->shortname($cust_main->payby));
40     <TR>
41       <TH ALIGN="right">Disable automatic <% $what %> charge </TH>
42       <TD COLSPAN=6><INPUT TYPE="checkbox" NAME="no_auto" VALUE="Y"></TD>
43     </TR>
44 % }
45
46 % if ( $curuser->access_right('Discount customer package') ) {
47   <% include('/elements/tr-select-discount.html',
48                'element_etc' => 'DISABLED',
49                'colspan'     => 7,
50                'cgi'         => $cgi,
51             )
52   %>
53 % }
54
55 % if ( $conf->exists('pkg_referral') ) {
56   <% include('/elements/tr-select-part_referral.html',
57                'curr_value'    => scalar( $cgi->param('refnum') ), #get rid of empty_label first# || $cust_main->refnum,
58                'disable_empty' => 1,
59                'multiple'      => $conf->exists('pkg_referral-multiple'),
60                'colspan'       => 7,
61             )
62   %>
63 % }
64
65 <% include('/elements/tr-select-cust_location.html',
66              'cgi'       => $cgi,
67              'cust_main' => $cust_main,
68           )
69 %>
70
71 <TR>
72   <TH ALIGN="right">Contract end date </TD>
73   <TD COLSPAN=6>
74     <% include('/elements/input-date-field.html',{
75                 'name'      => 'contract_end',
76                 'format'    => $date_format,
77                 'value'     => '',
78                 'noinit'    => 1,
79                 }) %>
80   </TD>
81 </TR>
82
83 </TABLE>
84
85 <% include( '/elements/standardize_locations.html',
86             'form'       => "OrderPkgForm",
87             'onlyship'   => 1,
88             'no_company' => 1,
89             'callback'   => 'document.OrderPkgForm.submit();',
90           )
91 %>
92
93 <BR>
94 <INPUT NAME    = "submitButton"
95        TYPE    = "button"
96        VALUE   = "Order Package"
97        onClick = "this.disabled=true; standardize_new_location();"
98        <% $pkgpart ? '' : 'DISABLED' %>
99 >
100
101 </FORM>
102 </BODY>
103 </HTML>
104 <%init>
105
106 my $curuser = $FS::CurrentUser::CurrentUser;
107
108 die "access denied"
109   unless $curuser->access_right('Order customer package');
110
111 my $conf = new FS::Conf;
112 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
113
114 $cgi->param('custnum') =~ /^(\d+)$/ or die "no custnum";
115 my $custnum = $1;
116 my $cust_main = qsearchs({
117   'table'     => 'cust_main',
118   'hashref'   => { 'custnum' => $custnum },
119   'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
120 });
121
122 my $pkgpart = scalar($cgi->param('pkgpart'));
123
124 my $format = $date_format. ' %T %z (%Z)'; #false laziness w/REAL_cust_pkg.cgi?
125 my $start_date = '';
126 if( ! $conf->exists('order_pkg-no_start_date') ) {
127   $start_date = $cust_main->next_bill_date;
128   $start_date = $start_date ? time2str($format, $start_date) : '';
129 }
130
131 </%init>