From ff8a7535a81005b7c66e8e75e5cfa8449a8cef04 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Fri, 5 Feb 2016 10:45:12 -0800 Subject: [PATCH] prevent changing Start before picking a package --- httemplate/elements/order_pkg.js | 26 +++++++++++----- httemplate/elements/tr-select-cust-part_pkg.html | 4 ++- httemplate/misc/order_pkg.html | 38 ++++++++++++++++++------ 3 files changed, 50 insertions(+), 18 deletions(-) diff --git a/httemplate/elements/order_pkg.js b/httemplate/elements/order_pkg.js index a850d2193..d8ee790c2 100644 --- a/httemplate/elements/order_pkg.js +++ b/httemplate/elements/order_pkg.js @@ -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); } diff --git a/httemplate/elements/tr-select-cust-part_pkg.html b/httemplate/elements/tr-select-cust-part_pkg.html index 23916d9e2..6244b6cb7 100644 --- a/httemplate/elements/tr-select-cust-part_pkg.html +++ b/httemplate/elements/tr-select-cust-part_pkg.html @@ -53,9 +53,11 @@ 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' %>, diff --git a/httemplate/misc/order_pkg.html b/httemplate/misc/order_pkg.html index e28250110..4e061e2f7 100644 --- a/httemplate/misc/order_pkg.html +++ b/httemplate/misc/order_pkg.html @@ -85,18 +85,38 @@ <% mt('Start') |h %> - param('start') eq '' ? 'CHECKED' : ''%>>Now + param('start') eq '' ? 'CHECKED' : ''%> + <% $pkgpart ? '' : 'DISABLED' %> + >Now   - param('start') eq 'on_hold' ? 'CHECKED' : ''%>>On hold + param('start') eq 'on_hold' ? 'CHECKED' : ''%> + <% $pkgpart ? '' : 'DISABLED' %> + >On hold   - param('start') eq 'date' ? 'CHECKED' : ''%>>On date + 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, - } &> -- 2.11.0