function save_partial_match(id){ var date = $('date_'+id).value; var pass_fail = $('pass_fail_'+id).value; var device_id = $('device_id_'+id).value; var device_name = $('device_name_'+id).value; var manufacturer = $('manufacturer_'+id).value; var model = $('model_'+id).value; var serial = $('serial_'+id).value; var extra_data = $('extra_data_'+id).value; var test_data = $('test_data_'+id).value; var filename = $('filename').value; var location = $('location_'+id).value; var comments = $('comments_'+id).value; var assoc_client = $('new_client_partial_'+id).value; new Ajax.Updater( 'test', '/index.php/process/savePartialMatch?date='+date+'&pass_fail='+pass_fail+'&date'+date+'&device_id='+device_id+'&device_name='+device_name+'&manufacturer='+manufacturer+'&model='+model+'&serial='+ serial+'&filename='+filename+'&location='+location+'&comments='+comments+'&assoc_client='+assoc_client, { method: 'post', parameters: 'extra_data='+extra_data+'&test_data='+test_data, evalScripts: true, asynchronous: false, onSuccess: function(){ $('device_id_'+id).disabled = true; $('device_name_'+id).disabled = true; $('manufacturer_'+id).disabled = true; $('model_'+id).disabled = true; $('serial_'+id).disabled = true; $('input_'+id).disabled = true; } } ); } function optionChanged(id){ var thisSelectedIndex = $('option_'+id).selectedIndex; var thisSelectedValue = $('option_'+id).options[thisSelectedIndex].value; //trying to associate device to a client if(thisSelectedValue == 2){ var selectedIndex = $('client_'+id).selectedIndex; var selectedValue = $('client_'+id).options[selectedIndex].value; //make sure a client is selected first. if not alert and don't continue if(selectedValue == -1) { $('option_'+id).selectedIndex = 0; alert('Please select a client first'); return; } }else{ //going back to original of just adding a new device restoreFields(id) $('device_id_'+id).show(); $('get_devices_'+id).hide(); $('device_id_option_'+id).selectedIndex = 0; $('device_id_option_'+id).disabled = true; return; } //if we are at this point client is select and associateToClient is selected //enable so client may use id from file $('device_id_option_'+id).disabled = false; new Ajax.Updater( 'get_devices_'+id, '/index.php/process/getDevices?&client_id='+selectedValue, { method: 'get', evalScripts: true, asynchronous: false, onSuccess: function(){ $('device_id_'+id).hide(); $('get_devices_'+id).show(); } } ); } function updateDevices(id){ var thisSelectedIndex = $('option_'+id).selectedIndex; var thisSelectedValue = $('option_'+id).options[thisSelectedIndex].value; if(thisSelectedValue == 1) return; var selectedIndex = $('client_'+id).selectedIndex; var selectedValue = $('client_'+id).options[selectedIndex].value; if(selectedValue == -1) { $('option_'+id).selectedIndex = 0; $('device_id_'+id).show(); $('get_devices_'+id).hide(); return; } new Ajax.Updater( 'get_devices_'+id, '/index.php/process/getDevices?client_id='+selectedValue, { method: 'get', evalScripts: true, asynchronous: false, onSuccess: function(){ $('device_id_'+id).hide(); $('get_devices_'+id).show(); } } ); } function save_no_match(id){ var selectedIndex = $('client_'+id).selectedIndex; var selectedValue = $('client_'+id).options[selectedIndex].value; if(selectedValue == -1) { alert('Please select a client first'); return false; } var optionSelectedIndex = $('option_'+id).selectedIndex; var optionSelectedValue = $('option_'+id).options[optionSelectedIndex].value; var getdeviceSelectedIndex = $('get_devices_'+id).selectedIndex; if(getdeviceSelectedIndex >= 0) var getdeviceSelectedValue = $('get_devices_'+id).options[getdeviceSelectedIndex].value; else getdeviceSelectedValue == -1; if(optionSelectedValue == 2 && getdeviceSelectedValue == -1){ alert("No Device Exists for Association"); return; }else if(optionSelectedValue == 2 && getdeviceSelectedValue == -2){ alert("Please Select a Device for Association"); return; } var date = $('date_'+id).value; var pass_fail = $('pass_fail_'+id).value; var client_id = $('client_'+id).value; var option = $('option_'+id).value; var get_devices = $('get_devices_'+id).value; var device_id = $('device_id_'+id).value; var device_name = $('device_name_'+id).value; var manufacturer = $('manufacturer_'+id).value; var model = $('model_'+id).value; var serial = $('serial_'+id).value; var extra_data = $('extra_data_'+id).value; var test_data = $('test_data_'+id).value; var filename = $('filename').value; var existingId = $('device_id_option_'+id).value; var location = $('location_'+id).value; var comments = $('comments_'+id).value; new Ajax.Updater( 'test', '/index.php/process/saveNoMatch?get_devices='+get_devices+'&date='+date+'&pass_fail='+pass_fail+'&option='+option+'&client_id='+client_id+'&device_id='+device_id+'&device_name='+device_name+'&manufacturer='+manufacturer+'&model='+model+'&serial='+ serial+'&filename='+filename+'&existingId='+existingId+'&location='+location+'&comments='+comments, { method: 'post', parameters: 'extra_data='+extra_data+'&test_data='+test_data, evalScripts: true, asynchronous: false, onSuccess: function(){ $('client_'+id).disabled = true; $('get_devices_'+id).disabled = true; $('option_'+id).disabled = true; $('device_id_'+id).disabled = true; $('device_name_'+id).disabled = true; $('manufacturer_'+id).disabled = true; $('model_'+id).disabled = true; $('serial_'+id).disabled = true; $('input_'+id).disabled = true; $('device_id_option_'+id).disabled = true; } } ); } function device_id_changed(id){ var h_device_name = $('hidden_device_name_'+id).value; var h_manufacturer = $('hidden_manufacturer_'+id).value; var h_model = $('hidden_model_'+id).value; var h_serial = $('hidden_serial_'+id).value; var getdeviceSelectedIndex = $('get_devices_'+id).selectedIndex; var getdeviceSelectedValue = $('get_devices_'+id).options[getdeviceSelectedIndex].value; new Ajax.Request( // 'test', '/index.php/process/deviceIdChanged?existing_device_id='+getdeviceSelectedValue+'&dn='+h_device_name+'&man='+h_manufacturer+'&mod='+h_model+'&ser='+h_serial, { method: 'get', evalScripts: true, asynchronous: false, onSuccess: function(transport){ d_response = transport.responseText; var json = eval('('+d_response+')'); var device_name = json.device_name; var manufacturer = json.manufacturer; var model = json.model; var serial = json.serial; $('device_name_'+id).innerHTML = json.device_name; $('manufacturer_'+id).innerHTML = json.manufacturer; $('model_'+id).innerHTML = json.model; $('serial_'+id).innerHTML = json.serial; } } ); } function restoreFields(id){ var h_device_name = $('hidden_device_name_'+id).value; var h_manufacturer = $('hidden_manufacturer_'+id).value; var h_model = $('hidden_model_'+id).value; var h_serial = $('hidden_serial_'+id).value; dn_option = "