";
}
targetDiv.innerHTML = output;
}
var selectedContractor = [];
function selectContractor(){
//if(obj.value == 0) //this is just the selct title being selected
// return;
var obj = document.getElementById("selectContractor");
var hours = document.getElementById("subcontractorHours").value;
var contractorQuantity = 1;//document.getElementById("numContractors").value;
//if(contractorQuantity == "")
// contractorQuantity = 1;
var contractorNotes = document.getElementById("subcontractorNotes").value;
if(contractorNotes == "Notes")
contractorNotes = "";
//Need to add some error checking code here
if(obj.value in selectedContractor){
alert("Already selected");
}else{
var d=new Date();
var currentTime = parseInt(d.getTime()/1000);
//selectedContractor.push(obj.selectedIndex);
//alert(obj.selectedIndex);
//selectedContractor.push(obj.options[obj.selectedIndex].value);
//alert(obj.options[obj.selectedIndex].value);
selectedContractor[currentTime] = [];
selectedContractor[currentTime]["id"] = obj.options[obj.selectedIndex].value;
selectedContractor[currentTime]["name"] = obj.options[obj.selectedIndex].text;
selectedContractor[currentTime]["quantity"] = contractorQuantity;
selectedContractor[currentTime]["hours"] = hours;
selectedContractor[currentTime]["notes"] = contractorNotes;
selectedContractor[currentTime]["timestamp"] = currentTime;
selectedContractor[currentTime]["creation_date"] = currentTime;
//alert(selectedContractor[obj.options[obj.selectedIndex].value]);
var overtime = 0;
var doubletime = 0;
var traveltime = 0;
//callBrandFunction5("addTimesheetEntry", selectedContractor[currentTime]["id"], contractorQuantity, hours, "0", currentTime,"", "");
callBrandFunction8("addTimesheetEntry", selectedContractor[currentTime]['id'], contractorQuantity, hours, overtime, doubletime, traveltime, contractorNotes, currentTime, "", "");
}
renderContractor(obj);
}
function removeContractor(staffID, creationKey){
//selectedContractor.splice(index, 1);
//var contractorList = document.getElementById("selectContractor");
callBrandFunction2("removeTimesheetEntry", staffID, creationKey, "");
delete selectedContractor[creationKey];
renderContractor();
}
function renderContractor(){
var targetDiv = document.getElementById("contractors");
var output = "";
for(var index in selectedContractor){
//alert(index);
//alert(selectedContractor[index]);
output += "
";
output += "
";
output += "
"+selectedContractor[index]["name"]+"
";
//output += "
"+selectedContractor[index]["quantity"]+"
";
//output += "
"+selectedContractor[index]["hours"]+"
";
output += "";
output += "";
output +="
";
}
targetDiv.innerHTML = output;
}
var selectedOwnPlant = [];
function selectOwnPlant(){
obj = document.getElementById("selectOwnPlant");
if(obj == null){
alert("Unable to find HTML obj booking_date.");
return;
}
if(obj.value == 0){ //this is just the selct title being selected
return;
}
if(obj.options[obj.selectedIndex].value in selectedOwnPlant){
alert("Already selected");
}else{
var d=new Date();
var currentTime = parseInt(d.getTime()/1000);
selectedOwnPlant[currentTime] = [];
var plantID = obj.options[obj.selectedIndex].value;
//alert(plantID);
if(plantID.indexOf("Y_") == -1){
selectedOwnPlant[currentTime]["track"] = "N";
}else{
selectedOwnPlant[currentTime]["track"] = "Y";
plantID = plantID.replace("Y_","");
}
//alert(selectedOwnPlant[currentTime]["track"]);
/*var hours_obj = document.getElementById("OwnPlantHours");
if(obj == null){
alert("Unable to find HTML obj hours.");
return;
}
var hours = hours_obj.options[hours_obj.selectedIndex].value;
*/
var hours = document.getElementById("OwnPlantHours").value;
//var operatorObj = document.getElementById("ownPlantOperatorID");
var operatorID = 0;//operatorObj.options[operatorObj.selectedIndex].value;
var operatorName = "";//operatorObj.options[operatorObj.selectedIndex].text;
var moveTime = currentTime;
var movetime = "";
//alert(plantID);
selectedOwnPlant[currentTime]["plantID"] = plantID;
selectedOwnPlant[currentTime]["plantName"] = obj.options[obj.selectedIndex].text.trim();
selectedOwnPlant[currentTime]["operatorName"] = operatorName;
selectedOwnPlant[currentTime]["hours"] = hours;
selectedOwnPlant[currentTime]["move_time"] = movetime;
selectedOwnPlant[currentTime]["remove_time"] = "";
selectedOwnPlant[currentTime]["creation_date"] = currentTime;
//selectedOwnPlant[obj.options[obj.selectedIndex].value] = obj.options[obj.selectedIndex].text;
callBrandFunction5("addOwnPlantEntry", plantID, moveTime, operatorID, hours, currentTime,"", "");
}
renderOwnPlant();
renderMovedPlant();
}
function removeOwnPlant(plantID, creationKey){
delete selectedOwnPlant[creationKey];
callBrandFunction2("removeOwnPlantEntry", plantID, creationKey, "", "");
renderOwnPlant();
renderMovedPlant();
}
function renderOwnPlant(){
var targetDiv = document.getElementById("ownPlant");
var output = "";
for(var index in selectedOwnPlant){
if(index != 0){ //not sure what this element is here
output += "
"
output += "
";
output += "
"+selectedOwnPlant[index]["plantName"]+"
";
//output += "
"+selectedOwnPlant[index]["operatorName"]+"
";
//output += "
"+selectedOwnPlant[index]["hours"]+"
";
output += "";
//Comment out for now as plant is moved automatically when added to job
//Code may be required to request removal once on site
//if((selectedOwnPlant[index]['remove_time'] == "" || selectedOwnPlant[index]['remove_time'] > currentTime.getTime()/1000) && selectedOwnPlant[index]['move_time'] == "")
// output += "
";
}
output += "
";
}
targetDiv.innerHTML = output;
}
var selectedHiredPlant = [[]];
function addHiredPlant(){
var d=new Date();
var currentTime = parseInt(d.getTime()/1000);
var selectHiredPlantObj = document.getElementById("selectHiredPlant");
var selectHiredPlantSupplierObj = document.getElementById("selectHiredPlantSupplier");
var selectHiredPlantInObj = document.getElementById("selectHiredPlantIn");
var obj = document.getElementById("hp_start_date");
var start_date = "";
if(obj)
start_date = obj.value;
else{
alert("hp_start_date object not found");
return;
}
if(start_date == "Start Date")
start_date = "";
obj = document.getElementById("hp_off_hire");
var off_hire = 0;
if(obj){
if(obj.checked)
off_hire = 1;
}
obj = document.getElementById("hp_reference_no");
var reference_no = "";
if(obj)
reference_no = obj.value;
if(reference_no == "Reference no.")
reference_no = "";
//alert(selectHiredPlantObj.options[selectHiredPlantObj.selectedIndex].value);
//alert(selectHiredPlantSupplierObj.options[selectHiredPlantSupplierObj.selectedIndex].value);
//alert(selectHiredPlantInObj.value);
var hireID = selectHiredPlantObj.options[selectHiredPlantObj.selectedIndex].value;
//var orderedFor = selectHiredPlantInObj.value;
// if(orderedFor == "Delivery Time")
// orderedFor = "";
//alert(hireID);
selectedSupplier = "";
selectedSupplierName = "";
if(selectHiredPlantSupplierObj.options[selectHiredPlantSupplierObj.selectedIndex].value != 0){
selectedSupplier = selectHiredPlantSupplierObj.options[selectHiredPlantSupplierObj.selectedIndex].value;
selectedSupplierName = selectHiredPlantSupplierObj.options[selectHiredPlantSupplierObj.selectedIndex].text;
}
selectedHiredPlant[currentTime] = [];
selectedHiredPlant[currentTime]["hireID"] = hireID;
selectedHiredPlant[currentTime]["plantName"] = selectHiredPlantObj.options[selectHiredPlantObj.selectedIndex].text
selectedHiredPlant[currentTime]["supplierID"] = selectedSupplier;
selectedHiredPlant[currentTime]["supplierName"] = selectedSupplierName;
selectedHiredPlant[currentTime]["ordered_for"] = "";//orderedFor;
selectedHiredPlant[currentTime]["arrive_time"] = "";
selectedHiredPlant[currentTime]["move_time"] = "";
selectedHiredPlant[currentTime]["remove_time"] = "";
selectedHiredPlant[currentTime]["start_date"] = start_date;
selectedHiredPlant[currentTime]["reference_no"] = reference_no;
selectedHiredPlant[currentTime]["off_hire"] = off_hire;
selectedHiredPlant[currentTime]["creation_date"] = currentTime;
callBrandFunction6("addHiredPlant", selectedHiredPlant[currentTime]["hireID"], selectedHiredPlant[currentTime]["supplierID"], start_date, off_hire, reference_no, currentTime, "", "");
renderHiredPlant2();
}
function selectHiredPlant(obj){
return;
if(obj.value == 0) //this is just the selct title being selected
return;
if(obj.options[obj.selectedIndex].value in selectedHiredPlant){
alert("Already selected");
}else{
selectedHiredPlant[obj.options[obj.selectedIndex].value] = obj.options[obj.selectedIndex].text;
callBrandFunction1("addHiredPlantEntry", obj.options[obj.selectedIndex].value, "", "");
}
renderHiredPlant2();
}
function removeHiredPlant(hireID, key){
delete selectedHiredPlant[key];
callBrandFunction2("removeHiredPlantEntry", hireID, key, "", "");
renderHiredPlant2();
}
/*function renderHiredPlant(){
var targetDiv = document.getElementById("hiredPlant");
var output = "";
for(var index in selectedHiredPlant){
output += "
"+selectedHiredPlant[index]+"
";
output += addHireFields();
output +="
";
}
targetDiv.innerHTML = output;
}
*/
function renderHiredPlant2(){
//alert("renderHirePlant2 called");
var targetDiv = document.getElementById("hiredPlant");
var output = "";
var d=new Date();
var currentTime = parseInt(d.getTime()/1000);
for(var index in selectedHiredPlant){
if(index != 0){ //not sure what this element is here
output += "
";
output += "";
}
targetDiv.innerHTML = output;
}
function renderMovedPlant(){
//capability needs to be reviewed
return;
var targetDiv = document.getElementById("movePlant");
var output = "";
for(var index in selectedOwnPlant){
if(index != 0){ //not sure what this element is here
if(selectedOwnPlant[index]["move_time"] != "" && selectedOwnPlant[index]["track"] == "Y"){
output += "
"
output += "
";
output += "
"+selectedOwnPlant[index]["plantName"]+"
";
output += "
OWN
";
//output += "
"+selectedOwnPlant[index]["arrive_time"]+"
";
}
//output += "
"+selectedHiredPlant[index]["move_time"]+"
";
}
//output +"
";
//output += addHireFields();
//output +="
";
output += "";
}
for(var index in selectedHiredPlant){
if(index != 0){ //not sure what this element is here
if(selectedHiredPlant[index]["move_time"] != ""){
output += "
"
output += "
";
output += "
"+selectedHiredPlant[index]["plantName"]+"
";
output += "
"+selectedHiredPlant[index]["supplierName"]+"
";
//output += "
"+selectedHiredPlant[index]["arrive_time"]+"
";
}
//output += "
"+selectedHiredPlant[index]["move_time"]+"
";
}
//output +"
";
//output += addHireFields();
//output +="
";
output += "";
}
targetDiv.innerHTML = output;
}
function addHireFields(){
var output = "*";
//Supplier
//timeOnSite
output = "";
//removeFromSite
return output;
}
function moveOwnPlant(plantID){
var d=new Date();
var currentTime = parseInt(d.getTime()/1000);
callBrandFunction1("moveOwnPlant", plantID, "", "");
selectedOwnPlant[plantID]["move_time"] = currentTime;
renderOwnPlant();
renderMovedPlant();
}
function movePlant(hiredID, creation_date){
var d=new Date();
var currentTime = parseInt(d.getTime()/1000);
callBrandFunction2("moveHirePlant", hiredID, creation_date, "", "");
selectedHiredPlant[creation_date]["move_time"] = currentTime;
renderHiredPlant2();
renderMovedPlant();
}
function removeMovedPlant(hiredID, creation_date){
callBrandFunction2("movePlant_cancel", hiredID, creation_date, "", "");
selectedHiredPlant[creation_date]["move_time"] = "";
renderHiredPlant2();
renderMovedPlant();
}
function removeOwnMovedPlant(plantID){
callBrandFunction1("moveOwnPlant_cancel", plantID, "", "");
selectedOwnPlant[plantID]["move_time"] = "";
renderOwnPlant();
renderMovedPlant();
}
var selectedMaterial = [[]];
function addMaterial(materialusageID){
var d=new Date();
var currentTime = parseInt(d.getTime()/1000);
//Check if this is an edit by pulling back materail
var selectMaterialObj = document.getElementById("selectMaterial");
var selectMaterialQuantityEstimateObj = document.getElementById("materialQuatityEstimate");
var selectMaterialQuantityActualObj = document.getElementById("materialQuatityActual");
var materialCostObj = document.getElementById("materialCost");
var selectMaterialSupplierObj = document.getElementById("selectMaterialSupplier");
var selectMaterialInObj = document.getElementById("selectMaterialIn");
var selectMaterialMaterialNotesObj = document.getElementById("selectMaterialNotes");
//Need to clean out quanity obj
if(selectMaterialQuantityEstimateObj.value == "Quantity ordered")
selectMaterialQuantityEstimateObj.value = "";
if(selectMaterialQuantityActualObj.value == "Quantity delivered")
selectMaterialQuantityActualObj.value = "";
//alert(selectHiredPlantObj.options[selectHiredPlantObj.selectedIndex].value);
//alert(selectHiredPlantSupplierObj.options[selectHiredPlantSupplierObj.selectedIndex].value);
//alert(selectHiredPlantInObj.value);
var materialID = selectMaterialObj.options[selectMaterialObj.selectedIndex].value;
//alert(materialID);
selectedMaterial[currentTime] = [];
selectedMaterial[currentTime]["materialID"] = materialID;
//selectedMaterial[currentTime]["materialName"] = selectMaterialObj.options[selectMaterialObj.selectedIndex].text
var selectValue = selectMaterialObj.options[selectMaterialObj.selectedIndex].text;
var extractedName = selectValue.split('~');
selectedMaterial[currentTime]["materialName"] = extractedName[0];
selectedMaterial[currentTime]["quantity_estimate"] = selectMaterialQuantityEstimateObj.value
selectedMaterial[currentTime]["quantity_actual"] = selectMaterialQuantityActualObj.value;
selectedMaterial[currentTime]["supplierID"] = selectMaterialSupplierObj.options[selectMaterialSupplierObj.selectedIndex].value;
selectedMaterial[currentTime]["supplierName"] = selectMaterialSupplierObj.options[selectMaterialSupplierObj.selectedIndex].text;
//var orderedFor = selectMaterialInObj.options[selectMaterialInObj.selectedIndex].text;
var orderedFor = selectMaterialInObj.value;
if(orderedFor == "Delivery Time")
orderedFor = "";
//if(selectMaterialInObj.value != 0)
// selectedMaterial[currentTime]["ordered_for"] = selectMaterialInObj.options[selectMaterialInObj.selectedIndex].text;
//else
selectedMaterial[currentTime]["ordered_for"] = orderedFor;
if(materialCostObj.value != "Material cost")
selectedMaterial[currentTime]["cost"] = materialCostObj.value;
else
selectedMaterial[currentTime]["cost"] = "";
if(selectMaterialMaterialNotesObj.value != "Delivery notes")
selectedMaterial[currentTime]["delivery_notes"] = selectMaterialMaterialNotesObj.value;
else
selectedMaterial[currentTime]["delivery_notes"] = "";
selectedMaterial[currentTime]["arrive_time"] = "";
selectedMaterial[currentTime]["move_time"] = "";
selectedMaterial[currentTime]["creation_date"] = currentTime;
//selectedMaterial[materialID]["remove_time"] = "";
//alert(selectedMaterial[currentTime]["ordered_for"]);
var reload = "";
if(materialusageID != 0)
reload = "full_reload";
callBrandFunction9("addMaterial", materialusageID, selectedMaterial[currentTime]["materialID"], selectedMaterial[currentTime]["quantity_estimate"], selectedMaterial[currentTime]["quantity_actual"], selectedMaterial[currentTime]["cost"],selectedMaterial[currentTime]["supplierID"], selectedMaterial[currentTime]["ordered_for"], selectedMaterial[currentTime]["delivery_notes"], currentTime, "", reload, "Materials");
//Need to rest quanity obj titles
selectMaterialQuantityEstimateObj.value = "Quantity ordered";
selectMaterialQuantityActualObj.value = "Quantity delivered";
renderSelectedMaterial();
}
function renderSelectedMaterial(){
var targetDiv = document.getElementById("materials");
var output = "";
var d=new Date();
var currentTime = parseInt(d.getTime()/1000);
for(var index in selectedMaterial){
if(index != 0){ //not sure what this element is here
output += "