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