Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / httemplate / misc / change_pkg.cgi
index ec10b85..7425fbf 100755 (executable)
@@ -1,6 +1,7 @@
-<% include('/elements/header-popup.html', "Change Package") %>
+<& /elements/header-popup.html, mt($title) &>
 
-<% include('/elements/error.html') %>
+<SCRIPT TYPE="text/javascript" SRC="../elements/order_pkg.js"></SCRIPT>
+<& /elements/error.html &>
 
 <FORM NAME="OrderPkgForm" ACTION="<% $p %>edit/process/change-cust_pkg.html" METHOD=POST>
 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
@@ -8,39 +9,53 @@
 <% ntable('#cccccc') %>
 
   <TR>
-    <TH ALIGN="right">Current package</TH>
+    <TH ALIGN="right"><% mt('Current package') |h %></TH>
     <TD COLSPAN=7>
       <% $curuser->option('show_pkgnum') ? $cust_pkg->pkgnum.': ' : '' %><B><% $part_pkg->pkg |h %></B> - <% $part_pkg->comment |h %>
     </TD>
   </TR>
 
-  <% include('/elements/tr-select-cust-part_pkg.html',
-               'pre_label'  => 'New',
+  <& /elements/tr-select-cust-part_pkg.html,
+               'pre_label'  => emt('New'),
                'curr_value' => scalar($cgi->param('pkgpart')),
                'classnum'   => $part_pkg->classnum,
                'cust_main'  => $cust_main,
-               #'extra_sql'    => ' AND pkgpart != '. $cust_pkg->pkgpart,
-            )
-  %>
+  &>
 
-  <% include('/elements/tr-select-cust_location.html',
+  <& /elements/tr-select-cust_location.html,
                'cgi'       => $cgi,
                'cust_main' => $cust_main,
-            )
-  %>
+  &>
 
 </TABLE>
 
-<% include( '/elements/standardize_locations.html',
+<TABLE>
+  <TR>
+    <TD> Apply this change: </TD>
+    <TD> <INPUT TYPE="radio" NAME="delay" VALUE="0" \
+          <% !$cgi->param('delay') ? 'CHECKED' : '' %>> now </TD>
+    <TD> <INPUT TYPE="radio" NAME="delay" VALUE="1" \
+          <% $cgi->param('delay')  ? 'CHECKED' : '' %>> in the future
+      <& /elements/input-date-field.html, {
+  'name'  => 'start_date',
+  'value' => ($cgi->param('start_date') || $cust_main->next_bill_date),
+      } &>
+    </TD>
+  </TR>
+</TABLE>
+
+<& /elements/standardize_locations.html,
             'form'       => "OrderPkgForm",
-            'onlyship'   => 1,
-            'no_company' => 1,
             'callback'   => 'document.OrderPkgForm.submit();',
-          )
-%>
+&>
 
 <BR>
-<INPUT NAME="submitButton" TYPE="button" VALUE="Change package" onClick="this.disabled=true; standardize_locations();">
+<INPUT NAME    = "submitButton"
+       TYPE    = "button"
+       VALUE   = "<% mt("Change package") |h %>"
+       onClick = "this.disabled=true; standardize_new_location();"
+       <% scalar($cgi->param('pkgpart')) ? '' : 'DISABLED' %>
+>
 
 </FORM>
 </BODY>
@@ -73,4 +88,15 @@ my $cust_main = $cust_pkg->cust_main
 
 my $part_pkg = $cust_pkg->part_pkg;
 
+my $title = "Change Package";
+
+# if there's already a package change ordered, preload it
+if ( $cust_pkg->change_to_pkgnum ) {
+  my $change_to = FS::cust_pkg->by_key($cust_pkg->change_to_pkgnum);
+  $cgi->param('delay', 1);
+  foreach(qw( start_date pkgpart locationnum )) {
+    $cgi->param($_, $change_to->get($_));
+  }
+  $title = "Edit Scheduled Package Change";
+}
 </%init>