1 function pkg_changed () {
2 var form = document.OrderPkgForm;
3 var discountnum = form.discountnum;
5 if ( form.pkgpart.selectedIndex > 0 ) {
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_disabled');
10 var date_text = document.getElementById('start_date_text');
12 var radio_now = document.getElementById('start_now');
13 //var radio_on_hold = document.getElementById('start_on_hold');
14 var radio_on_date = document.getElementById('start_on_date');
16 form.submitButton.disabled = false;
18 if ( opt.getAttribute('data-can_discount') == 1 ) {
19 form.discountnum.disabled = false;
20 discountnum_changed(form.discountnum);
22 form.discountnum.disabled = true;
23 discountnum_changed(form.discountnum);
27 // if this form element exists, then the start date is a future
28 // package change date; don't replace it
32 form.start_date_text.value = opt.getAttribute('data-start_date');
33 if ( opt.getAttribute('data-can_start_date') == 1 ) {
34 date_text.style.backgroundColor = '#ffffff';
35 date_text.disabled = false;
36 date_button.style.display = '';
37 date_button_disabled.style.display = 'none';
38 if ( radio_on_date ) {
39 radio_on_date.disabled = false;
40 if ( form.start_date_text.value.length > 0 && radio_now.checked ) {
41 radio_now.checked = false;
42 radio_on_date.checked = true;
46 date_text.style.backgroundColor = '#dddddd';
47 date_text.disabled = true;
48 date_button.style.display = 'none';
49 date_button_disabled.style.display = '';
50 if ( radio_on_date ) {
51 if ( radio_on_date.checked ) {
52 radio_on_date.checked = false;
53 radio_now.checked = true;
55 radio_on_date.disabled = true;
59 get_part_pkg_usageprice( opt.value, update_part_pkg_usageprice );
62 form.submitButton.disabled = true;
63 if ( discountnum ) { form.discountnum.disabled = true; }
64 discountnum_changed(form.discountnum);
68 function update_part_pkg_usageprice(part_pkg_usageprice) {
70 var table = document.getElementById('cust_pkg_usageprice_table');
72 // black the current usage price rows
73 for ( var r = table.rows.length - 1; r >= 0; r-- ) {
77 // add the new usage price rows
79 var usagepriceArray = eval('(' + part_pkg_usageprice + ')' );
80 for ( var s = 0; s < usagepriceArray.length; s=s+2 ) {
81 //surely this should be some kind of JSON structure
82 var html = usagepriceArray[s+0];
83 var javascript = usagepriceArray[s+1];
85 // a lot like ("inspiried by") edit/elements/edit.html function spawn_<%$field%>
87 // XXX evaluate the javascript
88 //if (window.ActiveXObject) {
89 // window.execScript(newfunc);
90 //} else { /* (window.XMLHttpRequest) */
91 // //window.eval(newfunc);
92 // setTimeout(newfunc, 0);
95 var row = table.insertRow(rownum++);
97 //var label_cell = document.createElement('TD');
99 //label_cell.id = '<% $field %>_label' + <%$field%>_fieldnum;
101 //label_cell.style.textAlign = "right";
102 //label_cell.style.verticalAlign = "top";
103 //label_cell.style.borderTop = "1px solid black";
104 //label_cell.style.paddingTop = "5px";
106 //label_cell.innerHTML = '<% $label %>';
108 //row.appendChild(label_cell);
110 var widget_cell = document.createElement('TD');
112 //widget_cell.style.borderTop = "1px solid black";
113 widget_cell.style.paddingTop = "3px";
114 widget_cell.colSpan = "2";
116 widget_cell.innerHTML = html;
118 row.appendChild(widget_cell);
123 document.getElementById('cust_pkg_usageprice_title').style.display = '';
125 document.getElementById('cust_pkg_usageprice_title').style.display = 'none';
131 function standardize_new_location() {
132 var form = document.OrderPkgForm;
133 var loc = form.locationnum;
134 if (loc.type == 'select-one' && loc.options[loc.selectedIndex].value == -1){
135 standardize_locations();
141 function submit_abort() {
142 document.OrderPkgForm.submitButton.disabled = false;