1 <& /elements/header-popup.html, mt($title) &>
3 <SCRIPT TYPE="text/javascript">
5 function enable_discount_pkg () {
6 if ( document.DiscountPkgForm.discountnum.selectedIndex > 0 ) {
7 document.DiscountPkgForm.submit.disabled = false;
9 document.DiscountPkgForm.submit.disabled = false;
15 <SCRIPT TYPE="text/javascript" SRC="../elements/order_pkg.js"></SCRIPT>
16 <& /elements/error.html &>
18 <FORM NAME="OrderPkgForm" ACTION="<% $p %>edit/process/change-cust_pkg.html" METHOD=POST>
19 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
22 <FONT CLASS="fsinnerbox-title"><% mt('Package') |h %></FONT>
23 <% ntable('#cccccc') %>
26 <TH ALIGN="right"><% mt('Current package') |h %></TH>
28 <FONT STYLE="background-color:#e8e8e8"><% $curuser->option('show_pkgnum') ? $cust_pkg->pkgnum.': ' : '' %><B><% $part_pkg->pkg |h %></B> - <% $part_pkg->comment |h %></FONT>
32 <& /elements/tr-select-cust-part_pkg.html,
33 'pre_label' => emt('New'),
34 'curr_value' => scalar($cgi->param('pkgpart')),
35 'classnum' => $part_pkg->classnum,
36 'cust_main' => $cust_main,
39 <& /elements/tr-input-pkg-quantity.html,
40 'curr_value' => $cust_pkg->quantity
43 % if ($use_contract_end) {
44 <& /elements/tr-input-date-field.html, {
45 'name' => 'contract_end',
46 'value' => ($cgi->param('contract_end') || $cust_pkg->get('contract_end')),
47 'label' => '<B>Contract End</B>',
55 <FONT CLASS="fsinnerbox-title"><% mt('Change') |h %></FONT>
56 <% ntable('#cccccc') %>
58 <SCRIPT TYPE="text/javascript">
59 function delay_changed() {
60 var enable = document.OrderPkgForm.delay[1].checked;
61 document.getElementById('start_date_text').disabled = !enable;
62 document.getElementById('start_date_button').style.display =
63 (enable ? '' : 'none');
64 document.getElementById('start_date_button_disabled').style.display =
65 (enable ? 'none' : '');
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 <% ntable("#cccccc") %>
94 % if ( $waive_setup_fee ) {
96 <TH ALIGN="right"><% mt('Waive setup fee') |h %> </TH>
97 <TD COLSPAN=6><INPUT TYPE="checkbox" NAME="waive_setup" VALUE="Y"></TD>
101 % if ( $discount_cust_pkg ) {
102 <% include('/elements/tr-select-discount.html',
103 'empty_label' => 'Select discount',
104 #'onchange' => 'enable_discount_pkg()',
106 'carry_value' => $carry_value,
108 #'setup_only' => $setup_only,
115 <FONT CLASS="fsinnerbox-title"><% mt('Location') |h %></FONT>
116 <% ntable('#cccccc') %>
118 <& /elements/tr-select-cust_location.html,
120 'cust_main' => $cust_main,
127 <& /elements/standardize_locations.html,
128 'form' => "OrderPkgForm",
130 'with_census_functions' => 1,
131 'callback' => 'document.OrderPkgForm.submit()',
134 <INPUT NAME = "submitButton"
136 VALUE = "<% mt("Change package") |h %>"
137 onClick = "this.disabled=true; standardize_new_location();"
138 <% scalar($cgi->param('pkgpart')) ? '' : 'DISABLED' %>
147 my $conf = new FS::Conf;
149 my $curuser = $FS::CurrentUser::CurrentUser;
152 unless $curuser->access_right('Change customer package');
154 my $pkgnum = scalar($cgi->param('pkgnum'));
155 $pkgnum =~ /^(\d+)$/ or die "illegal pkgnum $pkgnum";
160 'table' => 'cust_pkg',
161 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
162 'hashref' => { 'pkgnum' => $pkgnum },
163 'extra_sql' => ' AND '. $curuser->agentnums_sql,
164 }) or die "unknown pkgnum $pkgnum";
166 my $cust_main = $cust_pkg->cust_main
167 or die "can't get cust_main record for custnum ". $cust_pkg->custnum.
168 " ( pkgnum ". cust_pkg->pkgnum. ")";
170 my $part_pkg = $cust_pkg->part_pkg;
172 my $title = "Change Package";
174 my $use_contract_end = $cust_pkg->get('contract_end') ? 1 : 0;
176 # Pass previous discountnum to change screen
177 my $cust_pkg_discount = qsearchs(cust_pkg_discount => {
179 pkgnum => $cust_pkg->pkgnum,
183 ? $cust_pkg_discount->discountnum
186 # if there's already a package change ordered, preload it
187 if ( $cust_pkg->change_to_pkgnum ) {
188 my $change_to = FS::cust_pkg->by_key($cust_pkg->change_to_pkgnum);
189 $cgi->param('delay', 1);
190 foreach(qw( start_date pkgpart locationnum quantity )) {
191 $cgi->param($_, $change_to->get($_));
193 if ($use_contract_end) {
194 $cgi->param('contract_end', $change_to->get('contract_end'));
196 $title = "Edit Scheduled Package Change";