delayed package start option, #20686
[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     var opt = form.pkgpart.options[form.pkgpart.selectedIndex];
8     var date_button = document.getElementById('start_date_button');
9     var date_button_disabled = document.getElementById('start_date_button_disabled');
10     var date_text = document.getElementById('start_date_text');
11
12
13     form.submitButton.disabled = false;
14     if ( discountnum ) {
15       if ( opt.getAttribute('data-can_discount') == 1 ) {
16         form.discountnum.disabled = false;
17         discountnum_changed(form.discountnum);
18       } else {
19         form.discountnum.disabled = true;
20         discountnum_changed(form.discountnum);
21       }
22     }
23
24     form.start_date_text.value = opt.getAttribute('data-start_date');
25     if ( opt.getAttribute('data-can_start_date') == 1 ) {
26       date_text.style.backgroundColor = '#ffffff';
27       date_text.disabled = false;
28       date_button.style.display = '';
29       date_button_disabled.style.display = 'none';
30     } else {
31       date_text.style.backgroundColor = '#dddddd';
32       date_text.disabled = true;
33       date_button.style.display = 'none';
34       date_button_disabled.style.display = '';
35     }
36
37   } else {
38     form.submitButton.disabled = true;
39     if ( discountnum ) { form.discountnum.disabled = true; }
40     discountnum_changed(form.discountnum);
41   }
42 }
43
44 function standardize_new_location() {
45   var form = document.OrderPkgForm;
46   var loc = form.locationnum;
47   if (loc.type == 'select-one' && loc.options[loc.selectedIndex].value == -1){
48     standardize_locations();
49   } else {
50     form.submit();
51   }
52 }
53
54 function submit_abort() {
55   document.OrderPkgForm.submitButton.disabled = false;
56   nd(1);
57 }