1 <& /elements/header-popup.html, mt($title) &>
3 <SCRIPT TYPE="text/javascript" SRC="../elements/order_pkg.js"></SCRIPT>
4 <& /elements/error.html &>
6 <FORM NAME="OrderPkgForm" ACTION="<% $p %>edit/process/change-cust_pkg.html" METHOD=POST>
7 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
10 <FONT CLASS="fsinnerbox-title"><% mt('Package') |h %></FONT>
11 <TABLE CLASS="fsinnerbox">
14 <TH ALIGN="right"><% mt('Current package') |h %></TH>
16 <FONT STYLE="background-color:#e8e8e8"><% $curuser->option('show_pkgnum') ? $cust_pkg->pkgnum.': ' : '' %><B><% $part_pkg->pkg |h %></B> - <% $part_pkg->comment |h %></FONT>
20 <& /elements/tr-select-cust-part_pkg.html,
21 'pre_label' => emt('New'),
22 'curr_value' => scalar($cgi->param('pkgpart')) || $cust_pkg->pkgpart,
23 'classnum' => $part_pkg->classnum,
24 'cust_main' => $cust_main,
27 <& /elements/tr-input-pkg-quantity.html,
28 'curr_value' => scalar($cgi->param('quantity')) || $cust_pkg->quantity
31 % if ($use_contract_end) {
32 <& /elements/tr-input-date-field.html, {
33 'name' => 'contract_end',
34 'value' => ($cgi->param('contract_end') || $cust_pkg->get('contract_end')),
35 'label' => '<B>Contract End</B>',
42 <& /elements/table-cust_pkg_usageprice.html,
43 'pkgpart' => (scalar($cgi->param('pkgpart')) || $cust_pkg->pkgpart),
44 'pkgnum' => ($cust_pkg->change_to_pkgnum || $pkgnum),
47 <FONT CLASS="fsinnerbox-title"><% mt('Change') |h %></FONT>
48 <TABLE CLASS="fsinnerbox">
50 <SCRIPT TYPE="text/javascript">
51 function delay_changed() {
52 var enable = document.OrderPkgForm.delay[1].checked;
53 document.getElementById('start_date_text').disabled = !enable;
54 document.getElementById('start_date_button').style.display =
55 (enable ? '' : 'none');
56 if (document.getElementById('start_date_button_disabled')) { // does this ever exist anymore?
57 document.getElementById('start_date_button_disabled').style.display =
58 (enable ? 'none' : '');
61 usageprice_disable(1);
63 var form = document.OrderPkgForm;
64 usageprice_disable(0,form.pkgpart.options[form.pkgpart.selectedIndex].value);
67 <&| /elements/onload.js &>
72 <TD> <INPUT TYPE="radio" NAME="delay" VALUE="0" \
73 <% !$cgi->param('delay') ? 'CHECKED' : '' %> \
74 onclick="delay_changed()"> Now </TD>
75 <TD> <INPUT TYPE="radio" NAME="delay" VALUE="1" \
76 <% $cgi->param('delay') ? 'CHECKED' : '' %> \
77 onclick="delay_changed()"> In the future
78 <& /elements/input-date-field.html, {
79 'name' => 'start_date',
80 'value' => ($cgi->param('start_date') || $cust_main->next_bill_date),
87 % my $discount_cust_pkg = $curuser->access_right('Discount customer package');
88 % my $waive_setup_fee = $curuser->access_right('Waive setup fee');
90 % if ( $discount_cust_pkg || $waive_setup_fee ) {
91 <FONT CLASS="fsinnerbox-title"><% mt('Discounting') |h %></FONT>
92 <TABLE CLASS="fsinnerbox">
93 <& /elements/tr-select-pkg-discount.html,
94 # curr_value_setup => $discount{setup},
95 # curr_value_recur => $discount{recur},
98 disable_waive_setup => 0,
99 carry_value_setup => $discount{setup},
100 carry_value_recur => $discount{recur},
106 <FONT CLASS="fsinnerbox-title"><% mt('Location') |h %></FONT>
107 <TABLE CLASS="fsinnerbox">
109 <& /elements/tr-select-cust_location.html,
111 'cust_main' => $cust_main,
118 <& /elements/standardize_locations.html,
119 'form' => "OrderPkgForm",
121 'with_census_functions' => 1,
122 'callback' => $conf->exists('tax_district_method')
123 ? 'wa_state_tax_district()'
124 : 'submit_continue()',
128 <& /elements/wa_state_tax_district.js &>
130 // wa_sate_tax_district() will call submit_continue() upon success,
131 // or submit_abort() upon error
132 function submit_continue() {
133 document.OrderPkgForm.submit();
137 <INPUT NAME = "submitButton"
139 VALUE = "<% mt("Change package") |h %>"
140 onClick = "this.disabled=true; standardize_new_location();"
141 <% #scalar($cgi->param('pkgpart')) ? '' : 'DISABLED' %>
150 my $conf = new FS::Conf;
152 my $curuser = $FS::CurrentUser::CurrentUser;
155 unless $curuser->access_right('Change customer package');
157 my $pkgnum = scalar($cgi->param('pkgnum'));
158 $pkgnum =~ /^(\d+)$/ or die "illegal pkgnum $pkgnum";
163 'table' => 'cust_pkg',
164 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
165 'hashref' => { 'pkgnum' => $pkgnum },
166 'extra_sql' => ' AND '. $curuser->agentnums_sql,
167 }) or die "unknown pkgnum $pkgnum";
169 my $cust_main = $cust_pkg->cust_main
170 or die "can't get cust_main record for custnum ". $cust_pkg->custnum.
171 " ( pkgnum ". cust_pkg->pkgnum. ")";
173 my $part_pkg = $cust_pkg->part_pkg;
175 my $title = "Change Package";
177 my $use_contract_end = $cust_pkg->get('contract_end') ? 1 : 0;
179 # if there's already a package change ordered, preload it
180 if ( $cust_pkg->change_to_pkgnum ) {
181 my $change_to = FS::cust_pkg->by_key($cust_pkg->change_to_pkgnum);
182 $cgi->param('delay', 1);
183 foreach(qw( start_date pkgpart locationnum quantity )) {
184 $cgi->param($_, $change_to->get($_));
186 if ($use_contract_end) {
187 $cgi->param('contract_end', $change_to->get('contract_end'));
189 $title = "Edit Scheduled Package Change";
192 # Get current values of discounts for selectboxes
193 my %discount = (setup => undef, recur => undef);
194 $discount{$_->setuprecur} = $_->discountnum
195 for qsearch('cust_pkg_discount', {
196 pkgnum => $cust_pkg->pkgnum,
199 $discount{setup} = '-2' if $cust_pkg->waive_setup;