summaryrefslogtreecommitdiff
path: root/httemplate/elements
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate/elements')
-rw-r--r--httemplate/elements/order_pkg.js25
-rw-r--r--httemplate/elements/select-part_pkg.html1
-rw-r--r--httemplate/elements/tr-justtitle.html3
-rw-r--r--httemplate/elements/tr-select-cust-part_pkg.html18
4 files changed, 33 insertions, 14 deletions
diff --git a/httemplate/elements/order_pkg.js b/httemplate/elements/order_pkg.js
index 1069a0ee4..762b2ddde 100644
--- a/httemplate/elements/order_pkg.js
+++ b/httemplate/elements/order_pkg.js
@@ -4,9 +4,15 @@ function pkg_changed () {
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 {
@@ -15,14 +21,17 @@ function pkg_changed () {
}
}
- if ( form.pkgpart.options[form.pkgpart.selectedIndex].getAttribute('data-can_start_date') == 1 ) {
- form.start_date_text.disabled = false;
- form.start_date.style.backgroundColor = '#ffffff';
- form.start_date_button.style.display = '';
+ 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 {
- form.start_date_text.disabled = true;
- form.start_date.style.backgroundColor = '#dddddd';
- form.start_date_button.style.display = 'none';
+ date_text.style.backgroundColor = '#dddddd';
+ date_text.disabled = true;
+ date_button.style.display = 'none';
+ date_button_disabled.style.display = '';
}
} else {
diff --git a/httemplate/elements/select-part_pkg.html b/httemplate/elements/select-part_pkg.html
index 439c4b53e..9d41b07dc 100644
--- a/httemplate/elements/select-part_pkg.html
+++ b/httemplate/elements/select-part_pkg.html
@@ -23,7 +23,6 @@ Example:
'empty_label' => 'Select package', #should this be the default?
'label_callback' => sub { shift->pkg_comment },
'hashref' => \%hash,
- 'extra_option_attributes' => [ 'can_discount', 'can_start_date' ],
%opt,
)
%>
diff --git a/httemplate/elements/tr-justtitle.html b/httemplate/elements/tr-justtitle.html
index e9eda8b18..b87f7e128 100644
--- a/httemplate/elements/tr-justtitle.html
+++ b/httemplate/elements/tr-justtitle.html
@@ -1,5 +1,5 @@
<TR>
- <TH CLASS="background" COLSPAN=<% $opt{colspan} || 2 %> ALIGN="left">
+ <TH CLASS="background" COLSPAN=<% $opt{colspan} || 2 %> ALIGN="left" <%$id%>>
<FONT SIZE="+1"><% $opt{value} %></FONT>
</TH>
</TR>
@@ -7,5 +7,6 @@
<%init>
my %opt = @_;
+my $id = 'ID="'.$opt{id}.'"' if $opt{id};
</%init>
diff --git a/httemplate/elements/tr-select-cust-part_pkg.html b/httemplate/elements/tr-select-cust-part_pkg.html
index 848ab0a4b..488f04a13 100644
--- a/httemplate/elements/tr-select-cust-part_pkg.html
+++ b/httemplate/elements/tr-select-cust-part_pkg.html
@@ -7,10 +7,11 @@
<SCRIPT TYPE="text/javascript">
- function part_pkg_opt(what, value, text, can_discount, can_start_date) {
+ function part_pkg_opt(what, value, text, can_discount, can_start_date, start_date) {
var optionName = new Option(text, value, false, false);
optionName.setAttribute('data-can_discount', can_discount);
optionName.setAttribute('data-can_start_date', can_start_date);
+ optionName.setAttribute('data-start_date', start_date || '');
var length = what.length;
what.options[length] = optionName;
}
@@ -19,7 +20,7 @@
what.form.pkgpart.disabled = 'disabled'; //disable part_pkg dropdown
var submitButton = what.form.submitButton; // || what.form.submit;
- if ( submitButton ) {
+ if ( submitButton && <% $opt{'curr_value'} ? 0 : 1 %> ) {
submitButton.disabled = true; //disable the submit button
}
var discountnum = what.form.discountnum;
@@ -38,16 +39,21 @@
// add the new packages
opt(what.form.pkgpart, '', 'Select package');
var packagesArray = eval('(' + part_pkg + ')' );
- for ( var s = 0; s < packagesArray.length; s=s+4 ) {
+ for ( var s = 0; s < packagesArray.length; s=s+5 ) {
+ //surely this should be some kind of JSON structure
var packagesLabel = packagesArray[s+1];
var can_discount = packagesArray[s+2];
var can_start_date = packagesArray[s+3];
+ var start_date = packagesArray[s+4];
part_pkg_opt(
- what.form.pkgpart, packagesArray[s], packagesLabel, can_discount, can_start_date
+ what.form.pkgpart, packagesArray[s], packagesLabel, can_discount, can_start_date, start_date
);
}
what.form.pkgpart.disabled = ''; //re-enable part_pkg dropdown
+% if ( $opt{'curr_value'} ) {
+ what.form.pkgpart.value = <% $opt{'curr_value'} %>;
+% }
}
@@ -58,6 +64,10 @@
);
}
+ window.onload = function() {
+ classnum_changed(document.getElementById('classnum'));
+ }
+
</SCRIPT>
<TR>