X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Felements%2Forder_pkg.js;h=4e41fd64ab3a02a51ec7f2cf55997c16fd106025;hb=6db14d0fe65daec3d136edaa33a32a1fb24ba06a;hp=2c13ed2544beff08e81fe2013f136efc12bdd5da;hpb=990ffbe494523af17f1a3551a020e306ad9f8d7a;p=freeside.git diff --git a/httemplate/elements/order_pkg.js b/httemplate/elements/order_pkg.js index 2c13ed254..4e41fd64a 100644 --- a/httemplate/elements/order_pkg.js +++ b/httemplate/elements/order_pkg.js @@ -1,19 +1,48 @@ -function enable_order_pkg () { +function pkg_changed () { var form = document.OrderPkgForm; var discountnum = form.discountnum; if ( form.pkgpart.selectedIndex > 0 ) { + + var opt = form.pkgpart.options[form.pkgpart.selectedIndex]; + var date_button = document.getElementById('start_date_button'); + var date_button_disabled = document.getElementById('start_date_button_disabled'); + var date_text = document.getElementById('start_date_text'); + + form.submitButton.disabled = false; if ( discountnum ) { - if ( form.pkgpart.options[form.pkgpart.selectedIndex].getAttribute('data-can_discount') == 1 ) { + if ( opt.getAttribute('data-can_discount') == 1 ) { form.discountnum.disabled = false; + discountnum_changed(form.discountnum); } else { form.discountnum.disabled = true; + discountnum_changed(form.discountnum); } } + +// if this form element exists, then the start date is a future +// package change date; don't replace it + if ( form.delay ) { + return; + } + form.start_date_text.value = opt.getAttribute('data-start_date'); + if ( opt.getAttribute('data-can_start_date') == 1 ) { + date_text.style.backgroundColor = '#ffffff'; + date_text.disabled = false; + date_button.style.display = ''; + date_button_disabled.style.display = 'none'; + } else { + date_text.style.backgroundColor = '#dddddd'; + date_text.disabled = true; + date_button.style.display = 'none'; + date_button_disabled.style.display = ''; + } + } else { form.submitButton.disabled = true; if ( discountnum ) { form.discountnum.disabled = true; } + discountnum_changed(form.discountnum); } } @@ -26,3 +55,8 @@ function standardize_new_location() { form.submit(); } } + +function submit_abort() { + document.OrderPkgForm.submitButton.disabled = false; + nd(1); +}