4e41fd64ab3a02a51ec7f2cf55997c16fd106025
[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 // if this form element exists, then the start date is a future
25 // package change date; don't replace it
26     if ( form.delay ) {
27       return;
28     }
29     form.start_date_text.value = opt.getAttribute('data-start_date');
30     if ( opt.getAttribute('data-can_start_date') == 1 ) {
31       date_text.style.backgroundColor = '#ffffff';
32       date_text.disabled = false;
33       date_button.style.display = '';
34       date_button_disabled.style.display = 'none';
35     } else {
36       date_text.style.backgroundColor = '#dddddd';
37       date_text.disabled = true;
38       date_button.style.display = 'none';
39       date_button_disabled.style.display = '';
40     }
41
42   } else {
43     form.submitButton.disabled = true;
44     if ( discountnum ) { form.discountnum.disabled = true; }
45     discountnum_changed(form.discountnum);
46   }
47 }
48
49 function standardize_new_location() {
50   var form = document.OrderPkgForm;
51   var loc = form.locationnum;
52   if (loc.type == 'select-one' && loc.options[loc.selectedIndex].value == -1){
53     standardize_locations();
54   } else {
55     form.submit();
56   }
57 }
58
59 function submit_abort() {
60   document.OrderPkgForm.submitButton.disabled = false;
61   nd(1);
62 }