move misc/cust_pkg_usageprice.html to elements/table-cust_pkg_usageprice.html, RT...
authorIvan Kohler <ivan@freeside.biz>
Sat, 12 Mar 2016 02:56:59 +0000 (18:56 -0800)
committerIvan Kohler <ivan@freeside.biz>
Sat, 12 Mar 2016 02:56:59 +0000 (18:56 -0800)
httemplate/elements/table-cust_pkg_usageprice.html [new file with mode: 0644]
httemplate/misc/change_pkg.cgi
httemplate/misc/cust_pkg_usageprice.html [deleted file]
httemplate/misc/order_pkg.html

diff --git a/httemplate/elements/table-cust_pkg_usageprice.html b/httemplate/elements/table-cust_pkg_usageprice.html
new file mode 100644 (file)
index 0000000..b023e81
--- /dev/null
@@ -0,0 +1,125 @@
+<%doc>
+Sets up the xmlhttp, javascript and initial (empty) table for selecting cust_pkg_usageprice.
+Available values are based on pkgpart, and can be updated when changing pkgpart
+by passing the new pkgpart to the following javascript:
+
+  usageprice_pkg_changed( pkgpart, pkgnum )
+
+The pkgnum input is optional, and will be used to set initial selected values.
+
+If pkgpart is passed as an option to this element, will run usageprice_pkg_changed
+once to initialize table;  pkgnum can be passed as an option along with this.
+
+You can disable usageprice selection temporarily (remove the fields from the form)
+with the javascript usageprice_disable(1), and restore it with usageprice_disable(0,pkgnum).
+While disabled, calling usageprice_pkg_changed will have no effect.
+</%doc>
+
+<& /elements/xmlhttp.html,
+              'url'  => $p.'misc/xmlhttp-part_pkg_usageprice.html',
+              'subs' => [ 'get_part_pkg_usageprice' ],
+&>
+
+<FONT CLASS = "fsinnerbox-title" 
+      ID    = "cust_pkg_usageprice_title"
+      STYLE = "display:none"
+><% mt('Usage add-ons') |h %></FONT>
+<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 ID="cust_pkg_usageprice_table">
+
+</TABLE>
+<BR ID="cust_pkg_usageprice_br" STYLE="display:none">
+
+<SCRIPT>
+
+var usagepriceCache = {};
+var usagepriceDisabled = 0;
+
+function usageprice_disable (disabled, pkgpart) {
+  if (disabled) {
+    usageprice_pkg_changed(0);
+    usagepriceDisabled = 1;
+  } else {
+    usagepriceDisabled = 0;
+    usageprice_pkg_changed(pkgpart);
+  }
+}
+
+// main function to invoke when pkgpart changes
+function usageprice_pkg_changed (pkgpart, pkgnum) {
+  if (usagepriceDisabled) return;
+  clear_part_pkg_usageprice();
+
+  if (pkgpart) {
+    if (usagepriceCache[pkgpart]) {
+      update_part_pkg_usageprice(pkgpart);
+    } else {
+      get_part_pkg_usageprice( pkgpart || 0, pkgnum || 0, download_part_pkg_usageprice );
+    }
+  }
+}
+
+// removes table rows & hides table title
+function clear_part_pkg_usageprice () {
+  var table = document.getElementById('cust_pkg_usageprice_table');
+  for ( var r = table.rows.length - 1; r >= 0; r-- ) {
+    table.deleteRow(r);
+  }
+  document.getElementById('cust_pkg_usageprice_title').style.display = 'none';
+  document.getElementById('cust_pkg_usageprice_br').style.display = 'none';
+}
+
+// catches response from xmlhttp request, updates cache & calls update function
+function download_part_pkg_usageprice (part_pkg_usageprice) {
+  var usagepriceArray = JSON.parse(part_pkg_usageprice);
+  var pkgpart = usagepriceArray[0];
+  usagepriceCache[pkgpart] = usagepriceArray;
+  update_part_pkg_usageprice(pkgpart);
+}
+
+// updates from cache
+function update_part_pkg_usageprice (pkgpart) {
+  if (usagepriceDisabled) return;
+  clear_part_pkg_usageprice();
+
+  var usagepriceArray = usagepriceCache[pkgpart];
+  var table = document.getElementById('cust_pkg_usageprice_table');
+
+  // add the new usage price rows
+  var rownum = 0;
+  for ( var s = 1; s < usagepriceArray.length; s=s+2 ) {
+    var html = usagepriceArray[s];
+    var javascript = usagepriceArray[s+1];
+
+    var row = table.insertRow(rownum++);
+
+    var widget_cell = document.createElement('TD');
+    widget_cell.style.paddingTop = "3px";
+    widget_cell.colSpan = "2";
+    widget_cell.innerHTML = html;
+    row.appendChild(widget_cell);
+
+  }
+
+  if ( rownum > 0 ) {
+    document.getElementById('cust_pkg_usageprice_title').style.display = '';
+    document.getElementById('cust_pkg_usageprice_br').style.display = '';
+  } else {
+    document.getElementById('cust_pkg_usageprice_title').style.display = 'none';
+    document.getElementById('cust_pkg_usageprice_br').style.display = 'none';
+  }
+
+}
+
+% if ($opt{'pkgpart'}) {
+<&| /elements/onload.js &>
+usageprice_pkg_changed(<% $opt{'pkgpart'} %>, <% $opt{'pkgnum'} %>);
+</&>
+% }
+
+</SCRIPT>
+
+<%init>
+my %opt = @_;
+</%init>
+
+
index b562d24..e3ef4b7 100755 (executable)
 </TABLE>
 <BR>
 
-<% include('/misc/cust_pkg_usageprice.html',
+<& /elements/table-cust_pkg_usageprice.html,
      'pkgpart' => (scalar($cgi->param('pkgpart')) || $cust_pkg->pkgpart),
      'pkgnum'  => ($cust_pkg->change_to_pkgnum || $pkgnum),
-   ) %>
-<BR>
+&>
 
 <FONT CLASS="fsinnerbox-title"><% mt('Change') |h %></FONT>
 <% ntable('#cccccc') %>
diff --git a/httemplate/misc/cust_pkg_usageprice.html b/httemplate/misc/cust_pkg_usageprice.html
deleted file mode 100644 (file)
index f2e0f57..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-<%doc>
-Sets up the xmlhttp, javascript and initial (empty) table for selecting cust_pkg_usageprice.
-Available values are based on pkgpart, and can be updated when changing pkgpart
-by passing the new pkgpart to the following javascript:
-
-  usageprice_pkg_changed( pkgpart, pkgnum )
-
-The pkgnum input is optional, and will be used to set initial selected values.
-
-If pkgpart is passed as an option to this element, will run usageprice_pkg_changed
-once to initialize table;  pkgnum can be passed as an option along with this.
-
-You can disable usageprice selection temporarily (remove the fields from the form)
-with the javascript usageprice_disable(1), and restore it with usageprice_disable(0,pkgnum).
-While disabled, calling usageprice_pkg_changed will have no effect.
-</%doc>
-
-<& /elements/xmlhttp.html,
-              'url'  => $p.'misc/xmlhttp-part_pkg_usageprice.html',
-              'subs' => [ 'get_part_pkg_usageprice' ],
-&>
-
-<FONT CLASS = "fsinnerbox-title" 
-      ID    = "cust_pkg_usageprice_title"
-      STYLE = "display:none"
-><% mt('Usage add-ons') |h %></FONT>
-<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 ID="cust_pkg_usageprice_table">
-
-</TABLE>
-
-<SCRIPT>
-
-var usagepriceCache = {};
-var usagepriceDisabled = 0;
-
-function usageprice_disable (disabled, pkgpart) {
-  if (disabled) {
-    usageprice_pkg_changed(0);
-    usagepriceDisabled = 1;
-  } else {
-    usagepriceDisabled = 0;
-    usageprice_pkg_changed(pkgpart);
-  }
-}
-
-// main function to invoke when pkgpart changes
-function usageprice_pkg_changed (pkgpart, pkgnum) {
-  if (usagepriceDisabled) return;
-  clear_part_pkg_usageprice();
-
-  if (pkgpart) {
-    if (usagepriceCache[pkgpart]) {
-      update_part_pkg_usageprice(pkgpart);
-    } else {
-      get_part_pkg_usageprice( pkgpart || 0, pkgnum || 0, download_part_pkg_usageprice );
-    }
-  }
-}
-
-// removes table rows & hides table title
-function clear_part_pkg_usageprice () {
-  var table = document.getElementById('cust_pkg_usageprice_table');
-  for ( var r = table.rows.length - 1; r >= 0; r-- ) {
-    table.deleteRow(r);
-  }
-  document.getElementById('cust_pkg_usageprice_title').style.display = 'none';
-}
-
-// catches response from xmlhttp request, updates cache & calls update function
-function download_part_pkg_usageprice (part_pkg_usageprice) {
-  var usagepriceArray = JSON.parse(part_pkg_usageprice);
-  var pkgpart = usagepriceArray[0];
-  usagepriceCache[pkgpart] = usagepriceArray;
-  update_part_pkg_usageprice(pkgpart);
-}
-
-// updates from cache
-function update_part_pkg_usageprice (pkgpart) {
-  if (usagepriceDisabled) return;
-  clear_part_pkg_usageprice();
-
-  var usagepriceArray = usagepriceCache[pkgpart];
-  var table = document.getElementById('cust_pkg_usageprice_table');
-
-  // add the new usage price rows
-  var rownum = 0;
-  for ( var s = 1; s < usagepriceArray.length; s=s+2 ) {
-    var html = usagepriceArray[s];
-    var javascript = usagepriceArray[s+1];
-
-    var row = table.insertRow(rownum++);
-
-    var widget_cell = document.createElement('TD');
-    widget_cell.style.paddingTop = "3px";
-    widget_cell.colSpan = "2";
-    widget_cell.innerHTML = html;
-    row.appendChild(widget_cell);
-
-  }
-
-  if ( rownum > 0 ) {
-    document.getElementById('cust_pkg_usageprice_title').style.display = '';
-  } else {
-    document.getElementById('cust_pkg_usageprice_title').style.display = 'none';
-  }
-
-}
-
-% if ($opt{'pkgpart'}) {
-<&| /elements/onload.js &>
-usageprice_pkg_changed(<% $opt{'pkgpart'} %>, <% $opt{'pkgnum'} %>);
-</&>
-% }
-
-</SCRIPT>
-
-<%init>
-my %opt = @_;
-</%init>
-
-
index f3a573c..a08cb4b 100644 (file)
 
 </TABLE><BR>
 
-<& /misc/cust_pkg_usageprice.html,
+<& /elements/table-cust_pkg_usageprice.html,
      'pkgpart' => $pkgpart
 &>
 
-<BR>
-
 % my $discount_cust_pkg = $curuser->access_right('Discount customer package');
 % my $waive_setup_fee   = $curuser->access_right('Waive setup fee');
 %