prevent changing Start before picking a package
authorIvan Kohler <ivan@freeside.biz>
Fri, 5 Feb 2016 18:45:12 +0000 (10:45 -0800)
committerIvan Kohler <ivan@freeside.biz>
Fri, 5 Feb 2016 18:45:12 +0000 (10:45 -0800)
httemplate/elements/order_pkg.js
httemplate/elements/tr-select-cust-part_pkg.html
httemplate/misc/order_pkg.html

index a850d21..d8ee790 100644 (file)
@@ -5,15 +5,15 @@ function pkg_changed () {
 
   usageprice_pkg_changed( opt.value );
 
-  if ( form.pkgpart.selectedIndex > 0 ) {
+  var date_button = document.getElementById('start_date_button');
+  var date_button_disabled = document.getElementById('start_date_disabled');
+  var date_text = document.getElementById('start_date_text');
 
-    var date_button = document.getElementById('start_date_button');
-    var date_button_disabled = document.getElementById('start_date_disabled');
-    var date_text = document.getElementById('start_date_text');
+  var radio_now = document.getElementById('start_now');
+  var radio_on_hold = document.getElementById('start_on_hold');
+  var radio_on_date = document.getElementById('start_on_date');
 
-    var radio_now = document.getElementById('start_now');
-    var radio_on_hold = document.getElementById('start_on_hold');
-    var radio_on_date = document.getElementById('start_on_date');
+  if ( form.pkgpart.selectedIndex > 0 ) {
 
     form.submitButton.disabled = false;
     if ( discountnum ) {
@@ -39,8 +39,9 @@ function pkg_changed () {
       date_button_disabled.style.display = 'none';
       if ( radio_on_date ) {
         // un-disable all the buttons that might get disabled
-        radio_on_date.disabled = false;
         radio_now.disabled = false;
+        radio_on_hold.disabled = false;
+        radio_on_date.disabled = false;
         // if a start date has been entered, assume the user wants it
         if ( form.start_date_text.value.length > 0 ) {
           radio_now.checked = false;
@@ -72,6 +73,15 @@ function pkg_changed () {
 
   } else {
     form.submitButton.disabled = true;
+
+    date_text.style.backgroundColor = '#dddddd';
+    date_text.disabled = true;
+    date_button.style.display = 'none';
+    date_button_disabled.style.display = '';
+    radio_now.disabled = true;
+    radio_on_date.disabled = true;
+    radio_on_hold.disabled = true;
+
     if ( discountnum ) { form.discountnum.disabled = true; }
     discountnum_changed(form.discountnum);
   }
index 23916d9..6244b6c 100644 (file)
 
         what.form.pkgpart.disabled = ''; //re-enable part_pkg dropdown
 %       if ( $opt{'curr_value'} ) {
-        what.form.pkgpart.value = <% $opt{'curr_value'} %>;
+          what.form.pkgpart.value = <% $opt{'curr_value'} %>;
 %       }
 
+        pkg_changed();
+
       }
 
       get_part_pkg( <% $cust_main     ? $cust_main->custnum         : '0' %>,
index e282501..4e061e2 100644 (file)
     <TR>
       <TH ALIGN="right"><% mt('Start') |h %> </TD>
       <TD COLSPAN=6>
-        <INPUT TYPE="radio" NAME="start" ID="start_now" VALUE="" <% $cgi->param('start') eq '' ? 'CHECKED' : ''%>>Now
+        <INPUT TYPE  = "radio"
+               NAME  = "start"
+               ID    = "start_now"
+               VALUE = ""
+               <% $cgi->param('start') eq '' ? 'CHECKED' : ''%>
+               <% $pkgpart ? '' : 'DISABLED' %>
+        >Now
         &emsp;
-        <INPUT TYPE="radio" NAME="start" ID="start_on_hold" VALUE="on_hold" <% $cgi->param('start') eq 'on_hold' ? 'CHECKED' : ''%>>On hold
+        <INPUT TYPE  = "radio"
+               NAME  = "start"
+               ID    = "start_on_hold"
+               VALUE = "on_hold"
+               <% $cgi->param('start') eq 'on_hold' ? 'CHECKED' : ''%>
+               <% $pkgpart ? '' : 'DISABLED' %>
+        >On hold
         &emsp;
-        <INPUT TYPE="radio" NAME="start" ID="start_on_date" VALUE="on_date" <% $cgi->param('start') eq 'date' ? 'CHECKED' : ''%>>On date
+        <INPUT TYPE  = "radio" 
+               NAME  = "start" 
+               ID    = "start_on_date" 
+               VALUE = "on_date" 
+               <% $cgi->param('start') eq 'date' ? 'CHECKED' : ''%>
+               <% $pkgpart ? '' : 'DISABLED' %>
+        >On date
+
+        <& /elements/input-date-field.html,
+             { 'name'      => 'start_date',
+               'format'    => $date_format,
+               'value'     => '',
+               'noinit'    => 1,
+             }
+        &>
 
-        <& /elements/input-date-field.html,{
-                    'name'      => 'start_date',
-                    'format'    => $date_format,
-                    'value'     => '',
-                    'noinit'    => 1,
-                  } &>
       </TD>
     </TR>