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' => 'document.OrderPkgForm.submit()',
125 <INPUT NAME = "submitButton"
127 VALUE = "<% mt("Change package") |h %>"
128 onClick = "this.disabled=true; standardize_new_location();"
129 <% #scalar($cgi->param('pkgpart')) ? '' : 'DISABLED' %>
138 my $conf = new FS::Conf;
140 my $curuser = $FS::CurrentUser::CurrentUser;
143 unless $curuser->access_right('Change customer package');
145 my $pkgnum = scalar($cgi->param('pkgnum'));
146 $pkgnum =~ /^(\d+)$/ or die "illegal pkgnum $pkgnum";
151 'table' => 'cust_pkg',
152 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
153 'hashref' => { 'pkgnum' => $pkgnum },
154 'extra_sql' => ' AND '. $curuser->agentnums_sql,
155 }) or die "unknown pkgnum $pkgnum";
157 my $cust_main = $cust_pkg->cust_main
158 or die "can't get cust_main record for custnum ". $cust_pkg->custnum.
159 " ( pkgnum ". cust_pkg->pkgnum. ")";
161 my $part_pkg = $cust_pkg->part_pkg;
163 my $title = "Change Package";
165 my $use_contract_end = $cust_pkg->get('contract_end') ? 1 : 0;
167 # if there's already a package change ordered, preload it
168 if ( $cust_pkg->change_to_pkgnum ) {
169 my $change_to = FS::cust_pkg->by_key($cust_pkg->change_to_pkgnum);
170 $cgi->param('delay', 1);
171 foreach(qw( start_date pkgpart locationnum quantity )) {
172 $cgi->param($_, $change_to->get($_));
174 if ($use_contract_end) {
175 $cgi->param('contract_end', $change_to->get('contract_end'));
177 $title = "Edit Scheduled Package Change";
180 # Get current values of discounts for selectboxes
181 my %discount = (setup => undef, recur => undef);
182 $discount{$_->setuprecur} = $_->discountnum
183 for qsearch('cust_pkg_discount', {
184 pkgnum => $cust_pkg->pkgnum,
187 $discount{setup} = '-2' if $cust_pkg->waive_setup;