fix order package for quotes: don't display irrelevant fields, RT#22232 et al
[freeside.git] / httemplate / misc / order_pkg.html
1 <& /elements/header-popup.html, {
2      'title' =>  $quotationnum ? mt('Add package to quotation')
3                                : mt('Order new package'),
4      'nobr'  => 1,
5    }
6 &>
7
8 <LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2">
9 <SCRIPT TYPE="text/javascript" SRC="../elements/calendar_stripped.js"></SCRIPT>
10 <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT>
11 <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT>
12
13 <SCRIPT TYPE="text/javascript" SRC="../elements/order_pkg.js"></SCRIPT>
14
15 <& /elements/error.html &>
16
17 <FORM NAME="OrderPkgForm" ACTION="<% $p %>edit/process/quick-cust_pkg.cgi" METHOD="POST">
18
19 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $cust_main ? $cust_main->custnum : '' %>">
20 <INPUT TYPE="hidden" NAME="prospectnum" VALUE="<% $prospect_main ? $prospect_main->prospectnum : '' %>">
21 <INPUT TYPE="hidden" NAME="qualnum" VALUE="<% scalar($cgi->param('qualnum')) |h %>">
22 <INPUT TYPE="hidden" NAME="quotationnum" VALUE="<% $quotationnum %>">
23 % if ( $svcpart ) {
24     <INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>">
25 % }
26
27 % my $num_sales = $agent->num_sales;
28 % my $conf_pkg_referral = $conf->exists('pkg_referral');
29 % my $show_sales = $num_sales && $conf_pkg_referral;
30 % my $show_sales_table = $num_sales || $conf_pkg_referral;
31
32 % if ( $show_sales ) {
33   <FONT CLASS="fsinnerbox-title"><% mt('Sales') |h %></FONT>
34 % }
35 % if ( $show_sales_table ) {
36   <% ntable("#cccccc") %>
37 % }
38
39 <& /elements/tr-select-sales.html,
40      'curr_value' => scalar($cgi->param('salesnum')),
41      'agentnum'   => $agent->agentnum,
42      'th'         => 1,
43 &>
44
45 % if ( $conf->exists('pkg_referral') ) {
46   <& /elements/tr-select-part_referral.html,
47                'curr_value'    => scalar( $cgi->param('refnum') ), #get rid of empty_label first# || $cust_main->refnum,
48                'disable_empty' => 1,
49                'multiple'      => $conf->exists('pkg_referral-multiple'),
50                'colspan'       => 7,
51   &>
52 % }
53
54 % if ( $show_sales_table ) {
55   </TABLE><BR>
56 % }
57
58 <FONT CLASS="fsinnerbox-title"><% mt('Package') |h %></FONT>
59 <% ntable("#cccccc") %>
60
61 % if ( $part_pkg ) {
62     <INPUT TYPE="hidden" NAME="pkgpart" VALUE="<% $part_pkg->pkgpart %>">
63     <TR>
64       <TH ALIGN="right"><% mt('Package') |h %></TH>
65       <TD COLSPAN=6><% $part_pkg->pkg_comment |h %></TD>
66     </TR>
67 % } else {
68     <& /elements/tr-select-cust-part_pkg.html,
69                  'curr_value'    => $pkgpart,
70                  'classnum'      => -1,
71                  'cust_main'     => $cust_main,
72                  'prospect_main' => $prospect_main,
73     &>
74 % }
75
76 <& /elements/tr-input-pkg-quantity.html, curr_value => $quantity &>
77
78 % unless ( $quotationnum ) {
79
80 %   if ( $cust_main && $cust_main->payby =~ /^(CARD|CHEK)$/ ) {
81 %     my $what = lc(FS::payby->shortname($cust_main->payby));
82       <TR>
83         <TH ALIGN="right"><% mt("Disable automatic $what charge") |h %> </TH>
84         <TD COLSPAN=6><INPUT TYPE="checkbox" NAME="no_auto" VALUE="Y"></TD>
85       </TR>
86 %   }
87
88     <TR>
89       <TH ALIGN="right"><% mt('Start') |h %> </TD>
90       <TD COLSPAN=6>
91         <INPUT TYPE="radio" NAME="start" ID="start_now" VALUE="" <% $cgi->param('start') eq '' ? 'CHECKED' : ''%>>Now
92         &emsp;
93         <INPUT TYPE="radio" NAME="start" ID="start_on_hold" VALUE="on_hold" <% $cgi->param('start') eq 'on_hold' ? 'CHECKED' : ''%>>On hold
94         &emsp;
95         <INPUT TYPE="radio" NAME="start" ID="start_on_date" VALUE="on_date" <% $cgi->param('start') eq 'date' ? 'CHECKED' : ''%>>On date
96
97         <& /elements/input-date-field.html,{
98                     'name'      => 'start_date',
99                     'format'    => $date_format,
100                     'value'     => '',
101                     'noinit'    => 1,
102                   } &>
103       </TD>
104     </TR>
105
106     <TR>
107       <TH ALIGN="right"><% mt('Contract end date') |h %> </TD>
108       <TD COLSPAN=6>
109         <& /elements/input-date-field.html,{
110                     'name'      => 'contract_end',
111                     'format'    => $date_format,
112                     'value'     => '',
113                     'noinit'    => 1,
114                     } &>
115       </TD>
116     </TR>
117
118 % }
119
120 </TABLE><BR>
121
122 % my $discount_cust_pkg = $curuser->access_right('Discount customer package');
123 % my $waive_setup_fee   = $curuser->access_right('Waive setup fee');
124 %
125 % if ( $discount_cust_pkg || $waive_setup_fee ) {
126   <FONT CLASS="fsinnerbox-title"><% mt('Discounting') |h %></FONT>
127   <% ntable("#cccccc") %>
128
129 %   if ( $waive_setup_fee ) {
130       <TR>
131         <TH ALIGN="right"><% mt('Waive setup fee') |h %> </TH>
132         <TD COLSPAN=6><INPUT TYPE="checkbox" NAME="waive_setup" VALUE="Y"></TD>
133       </TR>
134 %   }
135
136 %   if ( $discount_cust_pkg ) {
137       <& /elements/tr-select-discount.html,
138                'element_etc' => 'DISABLED',
139                'colspan'     => 7,
140                'cgi'         => $cgi,
141       &>
142 %   }
143
144   </TABLE><BR>
145
146 % }
147
148
149 % my $lock_locationnum = scalar($cgi->param('lock_locationnum'));
150 % my $contact_title = $lock_locationnum ? 'Contact'
151 %                                       : 'Contact and Location';
152 <FONT CLASS="fsinnerbox-title"><% mt($contact_title) |h %></FONT>
153 <% ntable("#cccccc") %>
154
155 <& /elements/tr-select-contact.html,
156              'cgi'           => $cgi,
157              'cust_main'     => $cust_main,
158              'prospect_main' => $prospect_main,
159 &>
160
161 % if ( $cgi->param('lock_locationnum') ) {
162
163     <INPUT TYPE  = "hidden"
164            NAME  = "locationnum"
165            ID    = "locationnum"
166            VALUE = "<% scalar($cgi->param('lock_locationnum')) |h %>"
167     >
168
169 % } else {
170
171     <& /elements/tr-select-cust_location.html,
172                  'cgi'           => $cgi,
173                  'cust_main'     => $cust_main,
174                  'prospect_main' => $prospect_main,
175     &>
176
177 % }
178
179 </TABLE>
180
181 % unless ( $cgi->param('lock_locationnum') ) {
182
183   <& /elements/standardize_locations.html,
184                 'form'        => "OrderPkgForm",
185                 'callback'    => 'document.OrderPkgForm.submit()',
186                 'with_census' => 1,
187                 'with_census_functions' => 1,
188   &>
189
190 % }
191
192 <BR>
193 % my $onclick = $cgi->param('lock_locationnum')
194 %                 ? 'document.OrderPkgForm.submit()'
195 %                 : 'standardize_new_location()';
196 <INPUT NAME    = "submitButton"
197        TYPE    = "button"
198        VALUE   = "<% mt("Order Package") |h %>"
199        onClick = "this.disabled=true; <% $onclick %>;"
200        <% $pkgpart ? '' : 'DISABLED' %>
201 >
202
203 </FORM>
204 </BODY>
205 </HTML>
206 <%init>
207
208 my $curuser = $FS::CurrentUser::CurrentUser;
209
210 die "access denied"
211   unless $curuser->access_right('Order customer package');
212
213 my $conf = new FS::Conf;
214 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
215
216 my $cust_main = '';
217 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
218   my $custnum = $1;
219   $cust_main = qsearchs({
220     'table'     => 'cust_main',
221     'hashref'   => { 'custnum' => $custnum },
222     'extra_sql' => ' AND '. $curuser->agentnums_sql,
223   });
224 }
225
226 my $prospect_main = '';
227 if ( $cgi->param('prospectnum') =~ /^(\d+)$/ ) {
228   my $prospectnum = $1;
229   $prospect_main = qsearchs({
230     'table'     => 'prospect_main',
231     'hashref'   => { 'prospectnum' => $prospectnum },
232     'extra_sql' => ' AND '. $curuser->agentnums_sql,
233   });
234 }
235
236 my $quotationnum = '';
237 if ( $cgi->param('quotationnum') =~ /^(\d+)$/ ) {
238   $quotationnum = $1;
239 }
240
241 die 'no custnum or prospectnum' unless $cust_main || $prospect_main;
242
243 my $agent =  $cust_main ? $cust_main->agent
244                         : $prospect_main->agent;
245
246 my $part_pkg = '';
247 if ( $cgi->param('lock_pkgpart') ) {
248   $part_pkg = qsearchs({
249     'table'     => 'part_pkg',
250     'hashref'   => { 'pkgpart' => scalar($cgi->param('lock_pkgpart')) },
251     'extra_sql' => ' AND '. FS::part_pkg->agent_pkgs_sql($agent),
252   })
253     or die "unknown pkgpart ". $cgi->param('lock_pkgpart');
254 }
255
256 my $pkgpart = $part_pkg ? $part_pkg->pkgpart : scalar($cgi->param('pkgpart'));
257
258 my $quantity = 1;
259 if ( $cgi->param('quantity') =~ /^\s*(\d+)\s*$/ ) {
260   $quantity = $1;
261 }
262
263 my $format = $date_format. ' %T %z (%Z)'; #false laziness w/REAL_cust_pkg.cgi?
264
265 my $svcpart = scalar($cgi->param('svcpart'));
266
267 </%init>