1 <& /elements/header-popup.html, {
2 'title' => $quotationnum ? mt('Add package to quotation')
3 : mt('Order new package'),
8 <& /elements/xmlhttp.html,
9 'url' => $p.'misc/xmlhttp-part_pkg_usageprice.html',
10 'subs' => [ 'get_part_pkg_usageprice' ],
13 <& /elements/init_calendar.html &>
15 <SCRIPT TYPE="text/javascript" SRC="../elements/order_pkg.js"></SCRIPT>
17 <& /elements/error.html &>
19 <FORM NAME="OrderPkgForm" ACTION="<% $p %>edit/process/quick-cust_pkg.cgi" METHOD="POST">
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 %>">
26 <INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>">
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;
34 % if ( $show_sales ) {
35 <FONT CLASS="fsinnerbox-title"><% mt('Sales') |h %></FONT>
37 % if ( $show_sales_table ) {
38 <% ntable("#cccccc") %>
41 <& /elements/tr-select-sales.html,
42 'curr_value' => scalar($cgi->param('salesnum')),
43 'agentnum' => $agent->agentnum,
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,
51 'multiple' => $conf->exists('pkg_referral-multiple'),
56 % if ( $show_sales_table ) {
60 <FONT CLASS="fsinnerbox-title"><% mt('Package') |h %></FONT>
61 <% ntable("#cccccc") %>
64 <INPUT TYPE="hidden" NAME="pkgpart" VALUE="<% $part_pkg->pkgpart %>">
66 <TH ALIGN="right"><% mt('Package') |h %></TH>
67 <TD COLSPAN=6><% $part_pkg->pkg_comment |h %></TD>
70 <& /elements/tr-select-cust-part_pkg.html,
71 'curr_value' => $pkgpart,
73 'cust_main' => $cust_main,
74 'prospect_main' => $prospect_main,
78 <& /elements/tr-input-pkg-quantity.html, curr_value => $quantity &>
80 % if ( $cust_main && $cust_main->payby =~ /^(CARD|CHEK)$/ ) {
81 % my $what = lc(FS::payby->shortname($cust_main->payby));
83 <TH ALIGN="right"><% mt("Disable automatic $what charge") |h %> </TH>
84 <TD COLSPAN=6><INPUT TYPE="checkbox" NAME="no_auto" VALUE="Y"></TD>
89 <TH ALIGN="right"><% mt('Start') |h %> </TD>
91 <INPUT TYPE="radio" NAME="start" ID="start_now" VALUE="" <% $cgi->param('start') eq '' ? 'CHECKED' : ''%>>Now
93 <INPUT TYPE="radio" NAME="start" ID="start_on_hold" VALUE="on_hold" <% $cgi->param('start') eq 'on_hold' ? 'CHECKED' : ''%>>On hold
95 <INPUT TYPE="radio" NAME="start" ID="start_on_date" VALUE="on_date" <% $cgi->param('start') eq 'date' ? 'CHECKED' : ''%>>On date
97 <& /elements/input-date-field.html,{
98 'name' => 'start_date',
99 'format' => $date_format,
107 <TH ALIGN="right"><% mt('Contract end date') |h %> </TD>
109 <& /elements/input-date-field.html,{
110 'name' => 'contract_end',
111 'format' => $date_format,
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
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">
135 % my $discount_cust_pkg = $curuser->access_right('Discount customer package');
136 % my $waive_setup_fee = $curuser->access_right('Waive setup fee');
138 % if ( $discount_cust_pkg || $waive_setup_fee ) {
139 <FONT CLASS="fsinnerbox-title"><% mt('Discounting') |h %></FONT>
140 <% ntable("#cccccc") %>
142 % if ( $waive_setup_fee ) {
144 <TH ALIGN="right"><% mt('Waive setup fee') |h %> </TH>
145 <TD COLSPAN=6><INPUT TYPE="checkbox" NAME="waive_setup" VALUE="Y"></TD>
149 % if ( $discount_cust_pkg ) {
150 <& /elements/tr-select-discount.html,
151 'element_etc' => 'DISABLED',
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") %>
168 <& /elements/tr-select-contact.html,
170 'cust_main' => $cust_main,
171 'prospect_main' => $prospect_main,
174 % if ( $cgi->param('lock_locationnum') ) {
176 <INPUT TYPE = "hidden"
179 VALUE = "<% scalar($cgi->param('lock_locationnum')) |h %>"
184 <& /elements/tr-select-cust_location.html,
186 'cust_main' => $cust_main,
187 'prospect_main' => $prospect_main,
194 % unless ( $cgi->param('lock_locationnum') ) {
196 <& /elements/standardize_locations.html,
197 'form' => "OrderPkgForm",
198 'callback' => 'document.OrderPkgForm.submit()',
200 'with_census_functions' => 1,
206 % my $onclick = $cgi->param('lock_locationnum')
207 % ? 'document.OrderPkgForm.submit()'
208 % : 'standardize_new_location()';
209 <INPUT NAME = "submitButton"
211 VALUE = "<% mt("Order Package") |h %>"
212 onClick = "this.disabled=true; <% $onclick %>;"
213 <% $pkgpart ? '' : 'DISABLED' %>
221 my $curuser = $FS::CurrentUser::CurrentUser;
224 unless $curuser->access_right('Order customer package');
226 my $conf = new FS::Conf;
227 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
230 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
232 $cust_main = qsearchs({
233 'table' => 'cust_main',
234 'hashref' => { 'custnum' => $custnum },
235 'extra_sql' => ' AND '. $curuser->agentnums_sql,
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,
249 my $quotationnum = '';
250 if ( $cgi->param('quotationnum') =~ /^(\d+)$/ ) {
254 die 'no custnum or prospectnum' unless $cust_main || $prospect_main;
256 my $agent = $cust_main ? $cust_main->agent
257 : $prospect_main->agent;
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),
266 or die "unknown pkgpart ". $cgi->param('lock_pkgpart');
269 my $pkgpart = $part_pkg ? $part_pkg->pkgpart : scalar($cgi->param('pkgpart'));
272 if ( $cgi->param('quantity') =~ /^\s*(\d+)\s*$/ ) {
276 my $format = $date_format. ' %T %z (%Z)'; #false laziness w/REAL_cust_pkg.cgi?
278 my $svcpart = scalar($cgi->param('svcpart'));