improved address standardization, #13763
[freeside.git] / httemplate / misc / order_pkg.html
1 <& /elements/header-popup.html, $quotationnum ? mt('Add package to quotation')
2                                               : mt('Order new package')
3 &>
4
5 <LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2">
6 <SCRIPT TYPE="text/javascript" SRC="../elements/calendar_stripped.js"></SCRIPT>
7 <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT>
8 <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT>
9
10 <SCRIPT TYPE="text/javascript" SRC="../elements/order_pkg.js"></SCRIPT>
11
12 <& /elements/error.html &>
13
14 <FORM NAME="OrderPkgForm" ACTION="<% $p %>edit/process/quick-cust_pkg.cgi" METHOD="POST">
15
16 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $cust_main ? $cust_main->custnum : '' %>">
17 <INPUT TYPE="hidden" NAME="prospectnum" VALUE="<% $prospect_main ? $prospect_main->prospectnum : '' %>">
18 <INPUT TYPE="hidden" NAME="qualnum" VALUE="<% scalar($cgi->param('qualnum')) |h %>">
19 <INPUT TYPE="hidden" NAME="quotationnum" VALUE="<% $quotationnum %>">
20 % if ( $svcpart ) {
21     <INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>">
22 % }
23
24 <% ntable("#cccccc", 2) %>
25 % if ( $part_pkg ) {
26     <INPUT TYPE="hidden" NAME="pkgpart" VALUE="<% $part_pkg->pkgpart %>">
27     <TR>
28       <TH ALIGN="right"><% mt('Package') |h %></TH>
29       <TD COLSPAN=6><% $part_pkg->pkg_comment |h %></TD>
30     </TR>
31 % } else {
32     <& /elements/tr-select-cust-part_pkg.html,
33                  'curr_value'    => $pkgpart,
34                  'classnum'      => -1,
35                  'cust_main'     => $cust_main,
36                  'prospect_main' => $prospect_main,
37     &>
38 % }
39
40 % if ( $conf->exists('invoice-unitprice') ) {
41     <TR>
42       <TH ALIGN="right"><% mt('Quantity') |h %> </TD>
43       <TD>
44         <INPUT TYPE="text" NAME="quantity" SIZE=4 VALUE="<% $quantity %>">
45       </TD>
46     </TR>
47 % } else {
48     <INPUT TYPE="hidden" NAME="quantity" VALUE="1">
49 % }
50
51 <TR>
52   <TH ALIGN="right"><% mt('Start date') |h %> </TD>
53   <TD COLSPAN=6>
54     <& /elements/input-date-field.html,{
55                 'name'      => 'start_date',
56                 'format'    => $date_format,
57                 'value'     => $start_date,
58                 'noinit'    => 1,
59               } &>
60     <FONT SIZE=-1>(<% mt('leave blank to start immediately') |h %>)</FONT>
61   </TD>
62 </TR>
63
64 % if ( $cust_main && $cust_main->payby =~ /^(CARD|CHEK)$/ ) {
65 %   my $what = lc(FS::payby->shortname($cust_main->payby));
66     <TR>
67       <TH ALIGN="right"><% mt("Disable automatic $what charge") |h %> </TH>
68       <TD COLSPAN=6><INPUT TYPE="checkbox" NAME="no_auto" VALUE="Y"></TD>
69     </TR>
70 % }
71
72 % if ( $curuser->access_right('Discount customer package') ) {
73   <& /elements/tr-select-discount.html,
74                'element_etc' => 'DISABLED',
75                'colspan'     => 7,
76                'cgi'         => $cgi,
77   &>
78 % }
79
80 % if ( $curuser->access_right('Waive setup fee') ) {
81     <TR>
82       <TH ALIGN="right"><% mt('Waive setup fee') |h %> </TH>
83       <TD COLSPAN=6><INPUT TYPE="checkbox" NAME="waive_setup" VALUE="Y"></TD>
84     </TR>
85 % }
86
87 % if ( $conf->exists('pkg_referral') ) {
88   <& /elements/tr-select-part_referral.html,
89                'curr_value'    => scalar( $cgi->param('refnum') ), #get rid of empty_label first# || $cust_main->refnum,
90                'disable_empty' => 1,
91                'multiple'      => $conf->exists('pkg_referral-multiple'),
92                'colspan'       => 7,
93   &>
94 % }
95
96 % if ( $cgi->param('lock_locationnum') ) {
97
98     <INPUT TYPE  = "hidden"
99            NAME  = "locationnum"
100            ID    = "locationnum"
101            VALUE = "<% scalar($cgi->param('lock_locationnum')) |h %>"
102     >
103
104 % } else {
105
106     <& /elements/tr-select-cust_location.html,
107                  'cgi'           => $cgi,
108                  'cust_main'     => $cust_main,
109                  'prospect_main' => $prospect_main,
110     &>
111
112 % }
113
114 <TR>
115   <TH ALIGN="right"><% mt('Contract end date') |h %> </TD>
116   <TD COLSPAN=6>
117     <& /elements/input-date-field.html,{
118                 'name'      => 'contract_end',
119                 'format'    => $date_format,
120                 'value'     => '',
121                 'noinit'    => 1,
122                 } &>
123   </TD>
124 </TR>
125
126 </TABLE>
127
128 % unless ( $cgi->param('lock_locationnum') ) {
129
130   <& /elements/standardize_locations.html,
131                 'form'       => "OrderPkgForm",
132                 'onlyship'   => 1,
133                 'no_company' => 1,
134                 'no_census'  => 1,
135                 'callback'   => 'document.OrderPkgForm.submit();',
136   &>
137
138 % }
139
140 <BR>
141 % my $onclick = $cgi->param('lock_locationnum')
142 %                 ? 'document.OrderPkgForm.submit()'
143 %                 : 'standardize_new_location()';
144 <INPUT NAME    = "submitButton"
145        TYPE    = "button"
146        VALUE   = "<% mt("Order Package") |h %>"
147        onClick = "this.disabled=true; <% $onclick %>;"
148        <% $pkgpart ? '' : 'DISABLED' %>
149 >
150
151 </FORM>
152 </BODY>
153 </HTML>
154 <%init>
155
156 my $curuser = $FS::CurrentUser::CurrentUser;
157
158 die "access denied"
159   unless $curuser->access_right('Order customer package');
160
161 my $conf = new FS::Conf;
162 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
163
164 my $cust_main = '';
165 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
166   my $custnum = $1;
167   $cust_main = qsearchs({
168     'table'     => 'cust_main',
169     'hashref'   => { 'custnum' => $custnum },
170     'extra_sql' => ' AND '. $curuser->agentnums_sql,
171   });
172 }
173
174 my $prospect_main = '';
175 if ( $cgi->param('prospectnum') =~ /^(\d+)$/ ) {
176   my $prospectnum = $1;
177   $prospect_main = qsearchs({
178     'table'     => 'prospect_main',
179     'hashref'   => { 'prospectnum' => $prospectnum },
180     'extra_sql' => ' AND '. $curuser->agentnums_sql,
181   });
182 }
183
184 my $quotationnum = '';
185 if ( $cgi->param('quotationnum') =~ /^(\d+)$/ ) {
186   $quotationnum = $1;
187 }
188
189 die 'no custnum or prospectnum' unless $cust_main || $prospect_main;
190
191 my $part_pkg = '';
192 if ( $cgi->param('lock_pkgpart') ) {
193   $part_pkg = qsearchs({
194     'table'     => 'part_pkg',
195     'hashref'   => { 'pkgpart' => scalar($cgi->param('lock_pkgpart')) },
196     'extra_sql' => ' AND '. FS::part_pkg->agent_pkgs_sql(
197                               $cust_main ? $cust_main->agent
198                                          : $prospect_main->agent
199                             ),
200   })
201     or die "unknown pkgpart ". $cgi->param('lock_pkgpart');
202 }
203
204 my $pkgpart = $part_pkg ? $part_pkg->pkgpart : scalar($cgi->param('pkgpart'));
205
206 my $quantity = 1;
207 if ( $cgi->param('quantity') =~ /^\s*(\d+)\s*$/ ) {
208   $quantity = $1;
209 }
210
211 my $format = $date_format. ' %T %z (%Z)'; #false laziness w/REAL_cust_pkg.cgi?
212 my $start_date = '';
213 if( ! $conf->exists('order_pkg-no_start_date') && $cust_main ) {
214   $start_date = $cust_main->next_bill_date;
215   $start_date = $start_date ? time2str($format, $start_date) : '';
216 }
217
218 my $svcpart = scalar($cgi->param('svcpart'));
219
220 </%init>