Merge branch 'patch-19' of https://github.com/gjones2/Freeside
[freeside.git] / httemplate / elements / order_pkg.js
1 function pkg_changed () {
2   var form = document.OrderPkgForm;
3   var discountnum = form.discountnum;
4
5   if ( form.pkgpart.selectedIndex > 0 ) {
6
7     form.submitButton.disabled = false;
8     if ( discountnum ) {
9       if ( form.pkgpart.options[form.pkgpart.selectedIndex].getAttribute('data-can_discount') == 1 ) {
10         form.discountnum.disabled = false;
11         discountnum_changed(form.discountnum);
12       } else {
13         form.discountnum.disabled = true;
14         discountnum_changed(form.discountnum);
15       }
16     }
17
18     if ( form.pkgpart.options[form.pkgpart.selectedIndex].getAttribute('data-can_start_date') == 1 ) {
19       form.start_date_text.disabled = false;
20       form.start_date.style.backgroundColor = '#ffffff';
21       form.start_date_button.style.display = '';
22     } else {
23       form.start_date_text.disabled = true;
24       form.start_date.style.backgroundColor = '#dddddd';
25       form.start_date_button.style.display = 'none';
26     }
27
28   } else {
29     form.submitButton.disabled = true;
30     if ( discountnum ) { form.discountnum.disabled = true; }
31     discountnum_changed(form.discountnum);
32   }
33 }
34
35 function standardize_new_location() {
36   var form = document.OrderPkgForm;
37   var loc = form.locationnum;
38   if (loc.type == 'select-one' && loc.options[loc.selectedIndex].value == -1){
39     standardize_locations();
40   } else {
41     form.submit();
42   }
43 }
44
45 function submit_abort() {
46   document.OrderPkgForm.submitButton.disabled = false;
47   nd(1);
48 }