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 <% ntable('#cccccc') %>
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 <% ntable('#cccccc') %>
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),
88 <FONT CLASS="fsinnerbox-title"><% mt('Location') |h %></FONT>
89 <% ntable('#cccccc') %>
91 <& /elements/tr-select-cust_location.html,
93 'cust_main' => $cust_main,
100 <& /elements/standardize_locations.html,
101 'form' => "OrderPkgForm",
103 'with_census_functions' => 1,
104 'callback' => 'document.OrderPkgForm.submit()',
107 <INPUT NAME = "submitButton"
109 VALUE = "<% mt("Change package") |h %>"
110 onClick = "this.disabled=true; standardize_new_location();"
111 <% #scalar($cgi->param('pkgpart')) ? '' : 'DISABLED' %>
120 my $conf = new FS::Conf;
122 my $curuser = $FS::CurrentUser::CurrentUser;
125 unless $curuser->access_right('Change customer package');
127 my $pkgnum = scalar($cgi->param('pkgnum'));
128 $pkgnum =~ /^(\d+)$/ or die "illegal pkgnum $pkgnum";
133 'table' => 'cust_pkg',
134 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
135 'hashref' => { 'pkgnum' => $pkgnum },
136 'extra_sql' => ' AND '. $curuser->agentnums_sql,
137 }) or die "unknown pkgnum $pkgnum";
139 my $cust_main = $cust_pkg->cust_main
140 or die "can't get cust_main record for custnum ". $cust_pkg->custnum.
141 " ( pkgnum ". cust_pkg->pkgnum. ")";
143 my $part_pkg = $cust_pkg->part_pkg;
145 my $title = "Change Package";
147 my $use_contract_end = $cust_pkg->get('contract_end') ? 1 : 0;
149 # if there's already a package change ordered, preload it
150 if ( $cust_pkg->change_to_pkgnum ) {
151 my $change_to = FS::cust_pkg->by_key($cust_pkg->change_to_pkgnum);
152 $cgi->param('delay', 1);
153 foreach(qw( start_date pkgpart locationnum quantity )) {
154 $cgi->param($_, $change_to->get($_));
156 if ($use_contract_end) {
157 $cgi->param('contract_end', $change_to->get('contract_end'));
159 $title = "Edit Scheduled Package Change";