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