function CheckValue() { var sel = document.getElementById('sel'); if (sel.value == 'REJECTED' || sel.value == 'CLOSED') { document.getElementById('rem').style.display = ''; document.getElementById('1').style.display = 'none'; document.getElementById('2').style.display = 'none'; document.getElementById('3').style.display = 'none'; document.getElementById('4').style.display = 'none'; document.getElementById('5').style.display = 'none'; document.getElementById('6').style.display = 'none'; document.getElementById('7').style.display = 'none'; document.getElementById('9').style.display = 'none'; document.getElementById('10').style.display = 'none'; document.getElementById('11').style.display = 'none'; document.getElementById('pend').style.display = 'none'; } else if (sel.value == 'PENDING') { document.getElementById('rem').style.display = ''; document.getElementById('pend').style.display = ''; document.getElementById('1').style.display = 'none'; document.getElementById('2').style.display = 'none'; document.getElementById('3').style.display = 'none'; document.getElementById('4').style.display = 'none'; document.getElementById('5').style.display = 'none'; document.getElementById('6').style.display = 'none'; document.getElementById('7').style.display = 'none'; document.getElementById('9').style.display = 'none'; document.getElementById('10').style.display = 'none'; document.getElementById('11').style.display = 'none'; } else { document.getElementById('1').style.display = ''; document.getElementById('2').style.display = ''; document.getElementById('3').style.display = ''; document.getElementById('4').style.display = ''; document.getElementById('5').style.display = ''; document.getElementById('6').style.display = ''; document.getElementById('7').style.display = ''; document.getElementById('9').style.display = ''; document.getElementById('10').style.display = ''; document.getElementById('11').style.display = ''; } } function HidePart(d, e) { document.getElementById(d).style.display = 'none'; document.getElementById(e).style.display = 'none'; } function ShowPart(d, e) { document.getElementById(d).style.display = ''; document.getElementById(e).style.display = ''; } function CheckboxChecked(b, d, e) { if (b) { ShowPart(d, e); $('#' + d).attr('disabled', false); $('#' + e).attr('disabled', false); } else { HidePart(d, e); $('#' + d).attr('disabled', true); $('#' + e).attr('disabled', true); } } function getXMLHttpRequest() { try { req = new XMLHttpRequest(); } catch (err1) { try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch (err2) { try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch (err3) { req = false; } } } return req; } var xmlhttp = getXMLHttpRequest(); function getHistory() { if (xmlhttp) { var eid = document.getElementById("eq").value; var myurl = '../history?eid=' + escape(eid); myRand = parseInt(Math.random() * 999999999999999); var modurl = myurl + '&rand=' + myRand; xmlhttp.open('GET', modurl, true); xmlhttp.onreadystatechange = useHttpResponse; xmlhttp.send(null); } } function useHttpResponse() { var timeoutSet = false; var downloadOK = false; var h = document.getElementById('history'); if (xmlhttp.readyState == 1) { if (!timeoutSet) { toolong = window.setTimeout(function () { if (!downloadOK) { xmlhttp.abort(); document.getElementById('history').innerHTML = ' '; } }, 25000); timeoutSet = true; } } if (xmlhttp.readyState == 4) { if (xmlhttp.status == 200) { xmloutput = xmlhttp.responseXML; xmlRoot = xmloutput.documentElement; window.clearTimeout(toolong); if (!xmloutput || !xmlRoot) { alert('Check XML Structure!'); } var dateArray = xmlRoot.getElementsByTagName('hdate'); var timeArray = xmlRoot.getElementsByTagName('htime'); var componentArray = xmlRoot.getElementsByTagName('component'); var problemArray = xmlRoot.getElementsByTagName('problem'); var nothin = xmlRoot.getElementsByTagName('hnone')[0]; h.innerHTML = ' '; if (nothin) { row1 = document.getElementById('hist').insertRow(0); cell1 = row1.insertCell(0); cell1.innerHTML = 'No Previous Work Request '; cell1.style.color = 'gray'; cell1.style.border = '1px solid #eee'; } else { for (var i = 0; i < dateArray.length; i++) { row1 = document.getElementById('hist').insertRow(0); row2 = document.getElementById('hist').insertRow(1); cell1 = row1.insertCell(0); cell2 = row1.insertCell(0); cell3 = row2.insertCell(0); cell4 = row2.insertCell(0); row1.style.backgroundColor = '#eee'; cell2.style.color = 'gray'; cell1.style.color = 'gray'; cell3.style.color = 'gray'; cell4.style.color = 'gray'; cell3.style.border = '1px solid #eee'; date = dateArray[i].firstChild.data; time = timeArray[i].firstChild.data; component = componentArray[i].firstChild.data; problem = problemArray[i].firstChild.data; cell2.innerHTML = 'Date :' + date; cell1.innerHTML = 'Time :' + time; cell4.innerHTML = 'Component :' + component; cell3.innerHTML = problem; } } } } else { h.innerHTML = 'Please wait...'; } } function getXMLHttpRequest2() { try { req = new XMLHttpRequest(); } catch (err1) { try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch (err2) { try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch (err3) { req = false; } } } return req; } var xmlhtp = getXMLHttpRequest2(); function getStockDetails(code, stock, bal) { if (xmlhtp) { var cod = document.getElementById(code).value; var myurl = '../balance?cod=' + escape(cod); myRand = parseInt(Math.random() * 999999999999999); var modurl = myurl + '&rand=' + myRand; xmlhtp.open('GET', modurl, true); xmlhtp.onreadystatechange = useHttpResponse4store(stock, bal); xmlhtp.send(null); } } function useHttpResponse4store(stock, bal) { var timeoutSet = false; var downloadOK = false; var stok = document.getElementById(stock); var bal = document.getElementById(bal); if (xmlhtp.readyState == 4) { if (xmlhtp.status == 200) { xmloutput = xmlhtp.responseXML; xmlRoot = xmloutput.documentElement; window.clearTimeout(toolong); if (xmloutput || !xmlRoot) { alert('Check XML Structure!'); } alert(materialArry); var materialArray = xmlRoot.getElementsByTagName('material'); var quantityArray = xmlRoot.getElementsByTagName('quantity'); var nothin = xmlRoot.getElementsByTagName('notfound'); stok.value = ''; if (nothin) { stok.value = nothin[0].firstChild.data; } else { stok.value = materialArray[0].firstChild.data; bal.value = quantityArray[0].firstChild.data; } } } else { stok.value = 'Please wait...'; } } function HideI(d, e) { document.getElementById(d).style.display = 'none'; document.getElementById(e).style.display = 'none'; } function ShowI(d, e) { document.getElementById(d).style.display = ''; document.getElementById(e).style.display = ''; } function GabaIClicked(aa, a, b, c, d, f, g, h, i) { if (aa) { ShowI(a, b, c, d, f, g, h, i); } else { HideI(a, b, c, d, f, g, h, i); } } var xmlhttp = getXMLHttpRequest(); function getlocations() { if (xmlhttp) { var cc = document.getElementById("cc").value; document.getElementById("loc").disabled = false; var myurl = '../stations/genlist.php?cc=' + escape(cc); myRand = parseInt(Math.random() * 999999999999999); var modurl = myurl + '&rand=' + myRand; xmlhttp.open('GET', modurl, true); xmlhttp.onreadystatechange = useHttpResponse; xmlhttp.send(null); } } function useHttpResponse() { var timeoutSet = false; var downloadOK = false; if (xmlhttp.readyState == 1) { if (!timeoutSet) { toolong = window.setTimeout(function () { if (!downloadOK) { xmlhttp.abort(); document.getElementById('fstat').innerHTML = ''; } }, 25000); timeoutSet = true; } } if (xmlhttp.readyState == 4) { if (xmlhttp.status == 200) { xmloutput = xmlhttp.responseXML; xmlRoot = xmloutput.documentElement; window.clearTimeout(toolong); if (!xmloutput || !xmlRoot) { alert('Serious Trouble.. Contact Developer or Systems Administrator'); } var stationsidArray = xmlRoot.getElementsByTagName('locationid'); var stationsArray = xmlRoot.getElementsByTagName('location'); var errorArray = xmlRoot.getElementsByTagName('cerror')[0]; document.getElementById('fstat').innerHTML = ''; var stat = document.getElementById('loc'); if (errorArray) { clr(); document.getElementById('fstat').innerHTML = '' + errorArray.firstChild.data + ''; } else { clr(); var s = document.createElement('option'); s.innerHTML = '*Select Station'; stat.appendChild(s); for (var i = 0; i < stationsArray.length; i++) { var opti = document.createElement('option'); opti.innerHTML = stationsArray[i].firstChild.data; stat.appendChild(opti); opti.setAttribute('value', stationsidArray[i].firstChild.data); } } } } else { document.getElementById('fstat').innerHTML = 'Please wait...'; } } function geteq() { if (xmlhttp) { var loc = document.getElementById("loc").value; document.getElementById("par").disabled = false; var myurl = '../equipments/geneq.php?loc=' + escape(loc); myRand = parseInt(Math.random() * 999999999999999); var modurl = myurl + '&rand=' + myRand; xmlhttp.open('GET', modurl, true); xmlhttp.onreadystatechange = useHttpResponseq; xmlhttp.send(null); } } function useHttpResponseq() { var timeoutSet = false; var downloadOK = false; if (xmlhttp.readyState == 1) { if (!timeoutSet) { toolong = window.setTimeout(function () { if (!downloadOK) { xmlhttp.abort(); document.getElementById('fpar').innerHTML = ''; } }, 25000); timeoutSet = true; } } if (xmlhttp.readyState == 4) { if (xmlhttp.status == 200) { xmloutput = xmlhttp.responseXML; xmlRoot = xmloutput.documentElement; window.clearTimeout(toolong); if (!xmloutput || !xmlRoot) { alert('Serious Trouble.. Contact Developer or Systems Administrator'); } var eidArray = xmlRoot.getElementsByTagName('equipmentid'); var eArray = xmlRoot.getElementsByTagName('equipment'); var errorArray = xmlRoot.getElementsByTagName('cerror')[0]; document.getElementById('fpar').innerHTML = ''; if (errorArray) { clr1(); document.getElementById('fpar').innerHTML = '' + errorArray.firstChild.data + ''; } else { var par = document.getElementById('par'); clr1(); var p = document.createElement('option'); p.innerHTML = '*No Parent Equipment'; p.setAttribute('value', '0'); par.appendChild(p); for (var i = 0; i < eArray.length; i++) { var opti = document.createElement('option'); opti.innerHTML = eArray[i].firstChild.data; par.appendChild(opti); opti.setAttribute('value', eidArray[i].firstChild.data); } } document.getElementById('fstat').innerHTML = ''; } } else { document.getElementById('fpar').innerHTML = 'Please wait...'; } } function getseq() { if (xmlhttp) { var par = document.getElementById("par").value; document.getElementById("ch").disabled = false; var myurl = '../request/genseq.php?par=' + escape(par); myRand = parseInt(Math.random() * 999999999999999); var modurl = myurl + '&rand=' + myRand; xmlhttp.open('GET', modurl, true); xmlhttp.onreadystatechange = useHttpResponsesq; xmlhttp.send(null); } } function useHttpResponsesq() { var timeoutSet = false; var downloadOK = false; if (xmlhttp.readyState == 1) { if (!timeoutSet) { toolong = window.setTimeout(function () { if (!downloadOK) { xmlhttp.abort(); document.getElementById('fch').innerHTML = ''; } }, 25000); timeoutSet = true; } } if (xmlhttp.readyState == 4) { if (xmlhttp.status == 200) { xmloutput = xmlhttp.responseXML; xmlRoot = xmloutput.documentElement; window.clearTimeout(toolong); if (!xmloutput || !xmlRoot) { alert('Serious Trouble.. Contact Developer or Systems Administrator'); } var eidArray = xmlRoot.getElementsByTagName('equipmentid'); var eArray = xmlRoot.getElementsByTagName('equipment'); var errorArray = xmlRoot.getElementsByTagName('cerror')[0]; document.getElementById('fch').innerHTML = ''; if (errorArray) { clr2(); document.getElementById('fch').innerHTML = '' + errorArray.firstChild.data + ''; } else { var ch = document.getElementById('ch'); clr2(); for (var i = 0; i < eArray.length; i++) { var opti = document.createElement('option'); opti.innerHTML = eArray[i].firstChild.data; ch.appendChild(opti); opti.setAttribute('value', eidArray[i].firstChild.data); } } document.getElementById('fstat').innerHTML = ''; document.getElementById('fpar').innerHTML = ''; } } else { document.getElementById('fch').innerHTML = 'Please wait...'; } } function clr() { if (document.getElementById('loc')) { var stat = document.getElementById('loc'); while (stat.length > 0) { stat.remove(stat.length - 1); } } if (document.getElementById('par')) { var pare = document.getElementById('par'); while (pare.length > 0) { pare.remove(pare.length - 1); } } if (document.getElementById('ch')) { var chil = document.getElementById('ch'); while (chil.length > 0) { chil.remove(chil.length - 1); } } } function clr1() { if (document.getElementById('par')) { var pare = document.getElementById('par'); while (pare.length > 0) { pare.remove(pare.length - 1); } } if (document.getElementById('ch')) { var chil = document.getElementById('ch'); while (chil.length > 0) { chil.remove(chil.length - 1); } } } function clr2() { if (document.getElementById('ch')) { var chil = document.getElementById('ch'); while (chil.length > 0) { chil.remove(chil.length - 1); } } } $(document).ready(function () { $("#sal input[name='trade']").click(function () { /*$.ajax({ type : 'POST', url : '../assign/getno.php', dataType : 'json', data: { cde : $("#sal input[type='radio']:checked").val(), }, success : function(data){ $('#cd').val(data.msg); $('#waiting').hide(500); }, error : function(XMLHttpRequest, textStatus, errorThrown) { $('#waiting').show(500); $('#waiting').text('There was an error. Please try again later'); } }); */ $('#waiting').show(500); $.ajax({ type: 'POST', url: '../assign/getno.php', dataType: 'json', data: { cde: $("#sal input[type='radio']:checked").val(), }, success: function (data) { $('#waiting').hide(500); if (data.error === true) { $('#cd').val(data.msg); } else { $('#cd').val(data.msg); $('#waiting').hide(500); } }, error: function (XMLHttpRequest, textStatus, errorThrown) { $('#waiting').hide(500); $('#message').removeClass().addClass('error').text('There was an error. Please try again later').show(500); } }); }); $("#assigncard").click(function () { if ($("#sal input[name='craft[]']:checked").length == '') { $('#message').removeClass().addClass('error').text('Select Craftmen').show(500); return false; } }) });